Merged in bugfix/HOR-3670-MN5 (pull request #5949)

HOR-3670-MN5

Approved-by: Julio Cesar Laura Avendaño <contact@julio-laura.com>
This commit is contained in:
Marco Antonio Nina Mena
2017-08-15 13:27:20 +00:00
committed by Julio Cesar Laura Avendaño
6 changed files with 86 additions and 158 deletions

View File

@@ -1,5 +1,6 @@
<?php
use ProcessMaker\Core\Installer;
use ProcessMaker\Core\System;
use ProcessMaker\Util\FixReferencePath;
use ProcessMaker\Plugins\Adapters\PluginAdapter;
@@ -1696,7 +1697,7 @@ class WorkspaceTools
}
$workspace = new WorkspaceTools($workspaceName);
if (PmInstaller::isset_site($workspaceName)) {
if (Installer::isset_site($workspaceName)) {
if ($overwrite) {
if (!$workspace->workspaceExists()) {
throw new Exception('We can not overwrite this workspace because the workspace ' . $workspaceName . ' does not exist please check the lower case and upper case.');

View File

@@ -1,11 +1,7 @@
<?php
/**
* new Site create v1.1
* Jan 15th, 2011
*
* @author krlos P.C <carlos@colosa.com>
*/
use ProcessMaker\Core\Installer;
class newSiteProxy extends HttpProxyController
{
@@ -15,7 +11,7 @@ class newSiteProxy extends HttpProxyController
$ao_db_drop = (isset( $_POST['AO_DB_DROP'] )) ? true : false;
$name = trim( $_POST['NW_TITLE'] );
$inst = new PmInstaller();
$inst = new Installer();
if ($inst->isset_site($name)) {
if($ao_db_drop === true){
if(!file_exists(PATH_DATA . "sites/" . $name)){

View File

@@ -1,30 +1,9 @@
<?php
/**
* autoinstallProcess.php
*
* ProcessMaker Open Source Edition
* Copyright (C) 2004 - 2008 Colosa Inc.23
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
* Coral Gables, FL, 33134, USA, or email info@colosa.com.
*/
use ProcessMaker\Core\Installer;
use ProcessMaker\Plugins\PluginRegistry;
$inst = new PmInstaller();
$inst = new Installer();
$oProcess = new Processes();

View File

@@ -1,27 +1,8 @@
<?php
/**
* autoinstallProcess.php
*
* ProcessMaker Open Source Edition
* Copyright (C) 2004 - 2008 Colosa Inc.23
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
* Coral Gables, FL, 33134, USA, or email info@colosa.com.
*/
$inst = new PmInstaller();
use ProcessMaker\Core\Installer;
$inst = new Installer();
$oProcess = new Processes();

View File

@@ -1,12 +1,15 @@
<?php
use ProcessMaker\Core\Installer;
global $RBAC;
$RBAC->allows(basename(__FILE__), basename(__FILE__));
if (isset( $_POST['form']['NW_TITLE'] )) {
$action = (isset( $_POST['form']['ACTION'] )) ? trim( $_POST['form']['ACTION'] ) : 'test';
$name = trim( $_POST['form']['NW_TITLE'] );
$inst = new PmInstaller();
$inst = new Installer();
$isset = $inst->isset_site( $name );

View File

@@ -1,46 +1,14 @@
<?php
/**
* class.Installer.php
*
* @package workflow.engine.ProcessMaker
*
* ProcessMaker Open Source Edition
* Copyright (C) 2004 - 2011 Colosa Inc.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
* Coral Gables, FL, 33134, USA, or email info@colosa.com.
*
*/
//
// It works with the table CONFIGURATION in a WF dataBase
//
// Copyright (C) 2007 COLOSA
//
// License: LGPL, see LICENSE
////////////////////////////////////////////////////
namespace ProcessMaker\Core;
/**
* Processmaker Installer
*
* @package workflow.engine.ProcessMaker
* @author maborak
* @copyright 2008 COLOSA
*/
class PmInstaller
use AppCacheView;
use Archive_Tar;
use Configuration;
use Exception;
use G;
class Installer
{
public $options = Array();
@@ -86,11 +54,11 @@ class PmInstaller
*/
public static function isset_site($name = "workflow")
{
$pathSites = PATH_DATA . 'sites/'. '*';
$pathSites = PATH_DATA . 'sites/' . '*';
$directories = glob($pathSites, GLOB_ONLYDIR);
foreach ($directories as $directory){
foreach ($directories as $directory) {
$site = basename($directory);
if(strtolower($site) === strtolower($name)){
if (strtolower($site) === strtolower($name)) {
return true;
}
}
@@ -139,7 +107,7 @@ class PmInstaller
$islocal = (strcmp(substr($this->options['database']['hostname'], 0, strlen('localhost')), 'localhost') === 0) || (strcmp(substr($this->options['database']['hostname'], 0, strlen('127.0.0.1')), '127.0.0.1') === 0);
$this->wf_site_name = $wf = $this->options['advanced']['ao_db_wf'];
$this->wf_user_db = isset($this->options['advanced']['ao_user_wf'])?$this->options['advanced']['ao_user_wf']:uniqid('wf_');
$this->wf_user_db = isset($this->options['advanced']['ao_user_wf']) ? $this->options['advanced']['ao_user_wf'] : uniqid('wf_');
$this->rbac_site_name = $rb = $this->options['advanced']['ao_db_rb'];
$this->report_site_name = $rp = $this->options['advanced']['ao_db_rp'];
@@ -178,7 +146,7 @@ class PmInstaller
$this->log($qwv, isset($qwv['errors']));
$http = (G::is_https() == true) ? 'https' : 'http';
$lang = defined( 'SYS_LANG' ) ? SYS_LANG : 'en';
$lang = defined('SYS_LANG') ? SYS_LANG : 'en';
$host = $_SERVER['SERVER_NAME'] . ($_SERVER['SERVER_PORT'] != '80' ? ':' . $_SERVER['SERVER_PORT'] : '');
$workspace = $this->options['name'];
@@ -192,9 +160,9 @@ class PmInstaller
);
// inserting the outh_client
$query = ( "INSERT INTO OAUTH_CLIENTS (CLIENT_ID,CLIENT_SECRET,CLIENT_NAME,CLIENT_DESCRIPTION,CLIENT_WEBSITE,REDIRECT_URI,USR_UID ) VALUES
$query = ("INSERT INTO OAUTH_CLIENTS (CLIENT_ID,CLIENT_SECRET,CLIENT_NAME,CLIENT_DESCRIPTION,CLIENT_WEBSITE,REDIRECT_URI,USR_UID ) VALUES
('x-pm-local-client','179ad45c6ce2cb97cf1029e212046e81','PM Web Designer','ProcessMaker Web Designer App','www.processmaker.com','" . $endpoint . "','00000000000000000000000000000001' )");
$this->run_query( $query );
$this->run_query($query);
/* Dump schema rbac && data */
$pws = PATH_RBAC_MYSQL_DATA . $schema;
@@ -206,8 +174,8 @@ class PmInstaller
mysql_select_db($wf, $this->connection_database);
require_once ("propel/Propel.php");
require_once ('classes/model/AppCacheView.php');
require_once("propel/Propel.php");
require_once('classes/model/AppCacheView.php');
$appCache = new AppCacheView();
$appCache->setPathToAppCacheFiles(PATH_METHODS . 'setup/setupSchemas/');
@@ -235,7 +203,7 @@ class PmInstaller
$db_text .= " define ('SYSTEM_NAME', '" . SYSTEM_NAME . "');\n";
}
}
$db_text .="?>";
$db_text .= "?>";
$fp = @fopen($db_file, "w");
$this->log("Create: " . $db_file . " => " . ((!$fp) ? $fp : "OK") . "\n", $fp === false);
@@ -249,9 +217,9 @@ class PmInstaller
$content = 'system_utc_time_zone = 1' . "\n";
$fp = @fopen($envIniFile, 'w');
$this->log('Create: ' . $envIniFile . ' => ' . ((!$fp)? $fp : 'OK') . "\n", $fp === false);
$this->log('Create: ' . $envIniFile . ' => ' . ((!$fp) ? $fp : 'OK') . "\n", $fp === false);
$ff = @fputs($fp, $content, strlen($content));
$this->log('Write: ' . $envIniFile . ' => ' . ((!$ff)? $ff : 'OK') . "\n", $ff === false);
$this->log('Write: ' . $envIniFile . ' => ' . ((!$ff) ? $ff : 'OK') . "\n", $ff === false);
fclose($fp);
/*----------------------------------********---------------------------------*/
@@ -294,16 +262,16 @@ class PmInstaller
$dataFile = pathinfo($value);
$nameSkinTmp = $dataFile['filename'];
$tar = new Archive_Tar( $value );
$tar = new Archive_Tar($value);
$pathSkinTmp = $pathSkinPartner . 'tmp' . PATH_SEP;
G::rm_dir($pathSkinTmp);
G::verifyPath($pathSkinTmp, true);
chmod( $pathSkinTmp, 0777);
chmod($pathSkinTmp, 0777);
$tar->extract($pathSkinTmp);
$pathSkinName = $pathSkinTmp . $nameSkinTmp . PATH_SEP;
chmod( $pathSkinName, 0777);
chmod($pathSkinName, 0777);
G::verifyPath(PATH_CORE . 'skinEngine' . PATH_SEP . 'tmp', true);
$skinClassic = PATH_CORE . 'skinEngine' . PATH_SEP . 'tmp' . PATH_SEP;
@@ -365,7 +333,7 @@ class PmInstaller
$ch = curl_init();
$postData = array();
// resolv the plugin name
$plugins = glob(PATH_CORE."plugins/*.tar");
$plugins = glob(PATH_CORE . "plugins/*.tar");
if (count($plugins) > 0) {
$pluginName = $plugins[0];
@@ -388,42 +356,42 @@ class PmInstaller
}
}
function copyFile($fromDir, $toDir, $chmod=0777)
function copyFile($fromDir, $toDir, $chmod = 0777)
{
$errors = array();
$messages = array();
if (!is_writable($toDir)) {
$errors[]='target '.$toDir.' is not writable';
$errors[] = 'target ' . $toDir . ' is not writable';
}
if (!is_dir($toDir)) {
$errors[]='target '.$toDir.' is not a directory';
$errors[] = 'target ' . $toDir . ' is not a directory';
}
if (!is_dir($fromDir)) {
$errors[]='source '.$fromDir.' is not a directory';
$errors[] = 'source ' . $fromDir . ' is not a directory';
}
if (!empty($errors)) {
return false;
}
$exceptions = array ('.','..');
$exceptions = array('.', '..');
$handle = opendir($fromDir);
while (false !== ($item=readdir($handle))) {
if (!in_array($item,$exceptions)) {
$from = str_replace('//','/',$fromDir.'/'.$item);
$to = str_replace('//','/',$toDir.'/'.$item);
while (false !== ($item = readdir($handle))) {
if (!in_array($item, $exceptions)) {
$from = str_replace('//', '/', $fromDir . '/' . $item);
$to = str_replace('//', '/', $toDir . '/' . $item);
if (is_file($from)) {
if (@copy($from,$to)) {
chmod($to,$chmod);
touch($to,filemtime($from));
if (@copy($from, $to)) {
chmod($to, $chmod);
touch($to, filemtime($from));
}
}
if (is_dir($from)) {
if (@mkdir($to)) {
chmod($to,$chmod);
chmod($to, $chmod);
}
$this->copyFile($from,$to,$chmod);
$this->copyFile($from, $to, $chmod);
}
}
}
@@ -445,11 +413,11 @@ class PmInstaller
if ($value['CFG_UID'] == 'ENVIRONMENT_SETTINGS') {
$query = 'INSERT INTO CONFIGURATION (CFG_UID, OBJ_UID, CFG_VALUE, PRO_UID, USR_UID, APP_UID) VALUES';
$query .= "('" .
$value['CFG_UID'] . "', '".
$value['OBJ_UID'] . "', '".
$value['CFG_VALUE'] . "', '".
$value['PRO_UID'] . "', '".
$value['USR_UID'] . "', '".
$value['CFG_UID'] . "', '" .
$value['OBJ_UID'] . "', '" .
$value['CFG_VALUE'] . "', '" .
$value['PRO_UID'] . "', '" .
$value['USR_UID'] . "', '" .
$value['APP_UID'] . "')";
mysql_select_db($this->wf_site_name, $this->connection_database);
$this->run_query($query, "Copy configuracion environment");
@@ -580,7 +548,7 @@ class PmInstaller
if (PHP_OS == 'WINNT') {
return $def;
} else {
return (int) substr(sprintf('%o', @fileperms($file)), - 4);
return (int)substr(sprintf('%o', @fileperms($file)), -4);
}
}
@@ -750,7 +718,7 @@ class PmInstaller
{
array_push($this->report, $text);
if ($failed) {
throw new Exception(is_string($text) ? $text : var_export($text, true) );
throw new Exception(is_string($text) ? $text : var_export($text, true));
}
}
}