diff --git a/workflow/engine/classes/class.Installer.php b/workflow/engine/classes/class.Installer.php index 15011f5ff..ce0351a82 100755 --- a/workflow/engine/classes/class.Installer.php +++ b/workflow/engine/classes/class.Installer.php @@ -133,19 +133,13 @@ class Installer //Delete workspace directory if exists //Drop databases $this->run_query("DROP DATABASE IF EXISTS " . $wf, "Drop database $wf"); - $this->run_query("DROP DATABASE IF EXISTS " . $rb, "Drop database $rb"); - $this->run_query("DROP DATABASE IF EXISTS " . $rp, "Drop database $rp"); } $this->run_query("CREATE DATABASE IF NOT EXISTS " . $wf . " DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci", "Create database $wf"); - $this->run_query("CREATE DATABASE IF NOT EXISTS " . $rb . " DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci", "Create database $rb"); - $this->run_query("CREATE DATABASE IF NOT EXISTS " . $rp . " DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci", "Create database $rp"); - + if ($this->cc_status == 1) { $host = ($islocal) ? "localhost" : "%"; $this->run_query("GRANT ALL PRIVILEGES ON `$wf`.* TO $wf@'$host' IDENTIFIED BY '{$this->options['password']}' WITH GRANT OPTION", "Grant privileges for user $wf on database $wf"); - $this->run_query("GRANT ALL PRIVILEGES ON `$rb`.* TO $rb@'$host' IDENTIFIED BY '{$this->options['password']}' WITH GRANT OPTION", "Grant privileges for user $rb on database $rb"); - $this->run_query("GRANT ALL PRIVILEGES ON `$rp`.* TO $rp@'$host' IDENTIFIED BY '{$this->options['password']}' WITH GRANT OPTION", "Grant privileges for user $rp on database $rp"); } /* Dump schema workflow && data */ @@ -165,23 +159,23 @@ class Installer $qwv = $this->query_sql_file(PATH_WORKFLOW_MYSQL_DATA . $values, $this->connection_database); $this->log($qwv, isset($qwv['errors'])); - $http = (G::is_https() == true) ? 'https' : 'http'; - $lang = defined( 'SYS_LANG' ) ? SYS_LANG : 'en'; - $host = $_SERVER['SERVER_NAME'] . ($_SERVER['SERVER_PORT'] != '80' ? ':' . $_SERVER['SERVER_PORT'] : ''); + $http = (G::is_https() == true) ? 'https' : 'http'; + $lang = defined( 'SYS_LANG' ) ? SYS_LANG : 'en'; + $host = $_SERVER['SERVER_NAME'] . ($_SERVER['SERVER_PORT'] != '80' ? ':' . $_SERVER['SERVER_PORT'] : ''); $workspace = $this->options['name']; - - $endpoint = sprintf( - '%s://%s/sys%s/%s/%s/oauth2/grant', - $http, - $host, - $workspace, - $lang, - SYS_SKIN + + $endpoint = sprintf( + '%s://%s/sys%s/%s/%s/oauth2/grant', + $http, + $host, + $workspace, + $lang, + SYS_SKIN ); - - // inserting the outh_client + + // inserting the outh_client $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' )"); + ('x-pm-local-client','179ad45c6ce2cb97cf1029e212046e81','PM Web Designer','ProcessMaker Web Designer App','www.processmaker.com','" . $endpoint . "','00000000000000000000000000000001' )"); $this->run_query( $query ); /* Dump schema rbac && data */ diff --git a/workflow/engine/classes/class.wsTools.php b/workflow/engine/classes/class.wsTools.php index 5c07f97e0..ced4d8b25 100755 --- a/workflow/engine/classes/class.wsTools.php +++ b/workflow/engine/classes/class.wsTools.php @@ -61,7 +61,7 @@ class workspaceTools * @param bool $first true if this is the first workspace to be upgrade */ public function upgrade($first = false, $buildCacheView = false, $workSpace = SYS_SYS, $onedb = false, $lang = 'en') - { + { $start = microtime(true); CLI::logging("> Updating database...\n"); $this->upgradeDatabase($onedb); @@ -465,7 +465,7 @@ class workspaceTools * @param string $lang not currently used */ public function upgradeCacheView($fill = true, $checkOnly = false, $lang = "en") - { + { $this->initPropel(true); //require_once ('classes/model/AppCacheView.php'); @@ -479,19 +479,17 @@ class workspaceTools //setup the appcacheview object, and the path for the sql files $appCache = new AppCacheView(); $appCache->setPathToAppCacheFiles(PATH_METHODS . 'setup' . PATH_SEP . 'setupSchemas' . PATH_SEP); - + $userGrants = $appCache->checkGrantsForUser(false); - $currentUser = $userGrants['user']; $currentUserIsSuper = $userGrants['super']; - //if user does not have the SUPER privilege we need to use the root user and grant the SUPER priv. to normal user. if (!$currentUserIsSuper) { $appCache->checkGrantsForUser(true); $appCache->setSuperForUser($currentUser); $currentUserIsSuper = true; } - + CLI::logging("-> Creating table\n"); //now check if table APPCACHEVIEW exists, and it have correct number of fields, etc. $res = $appCache->checkAppCacheView(); @@ -499,7 +497,7 @@ class workspaceTools CLI::logging("-> Update DEL_LAST_INDEX field in APP_DELEGATION table\n"); //Update APP_DELEGATION.DEL_LAST_INDEX data $res = $appCache->updateAppDelegationDelLastIndex($lang, $checkOnly); - + CLI::logging("-> Verifying roles permissions in RBAC \n"); //Update table RBAC permissions Bootstrap::LoadSystem( 'rbac' ); @@ -683,7 +681,7 @@ class workspaceTools * @return array bool upgradeSchema for more information */ public function upgradeDatabase ($onedb = false, $checkOnly = false) - { + { G::LoadClass("patch"); $this->initPropel( true ); p11835::$dbAdapter = $this->dbAdapter; @@ -725,6 +723,12 @@ class workspaceTools public function upgradeSchema($schema, $checkOnly = false, $rbac = false, $onedb = false) { $dbInfo = $this->getDBInfo(); + + if ($dbInfo['DB_NAME'] == $dbInfo['DB_RBAC_NAME']) { + $onedb = true; + } else { + $onedb = false; + } if (strcmp($dbInfo["DB_ADAPTER"], "mysql") != 0) { throw new Exception("Only MySQL is supported"); @@ -733,7 +737,6 @@ class workspaceTools $this->setFormatRows(); $workspaceSchema = $this->getSchema($rbac); - $oDataBase = $this->getDatabase($rbac); if (!$onedb) { diff --git a/workflow/engine/classes/model/AppCacheView.php b/workflow/engine/classes/model/AppCacheView.php index 003a20d0b..8e7b5ab3a 100755 --- a/workflow/engine/classes/model/AppCacheView.php +++ b/workflow/engine/classes/model/AppCacheView.php @@ -1201,7 +1201,6 @@ class AppCacheView extends BaseAppCacheView $rs1->next(); $row = $rs1->getRow(); $mysqlUser = str_replace('@', "'@'", $row[0]); - $super = false; $sql = "SELECT * @@ -1211,8 +1210,8 @@ class AppCacheView extends BaseAppCacheView $rs1 = $stmt->executeQuery($sql, ResultSet::FETCHMODE_ASSOC); $rs1->next(); $row = $rs1->getRow(); - - if (is_array($row = $rs1->getRow())) { + + if ($row['PRIVILEGE_TYPE'] == 'SUPER') { $super = G::LoadTranslation('ID_TRUE'); //true; } diff --git a/workflow/engine/controllers/installer.php b/workflow/engine/controllers/installer.php index 5588a53b2..c7785368f 100755 --- a/workflow/engine/controllers/installer.php +++ b/workflow/engine/controllers/installer.php @@ -562,8 +562,10 @@ class Installer extends Controller public function setGrantPrivilegesMySQL ($psUser, $psPassword, $psDatabase, $host) { $host = ($host == 'localhost' || $host == '127.0.0.1' ? 'localhost' : '%'); + $sql = sprintf( "GRANT ALL PRIVILEGES ON `%s`.* TO %s@'%s' IDENTIFIED BY '%s' WITH GRANT OPTION", $psDatabase, $psUser, $host, $psPassword ); $query = @mysql_query( $sql, $this->link ); + if (! $query) { $errorMessage = mysql_error( $this->link ); $this->installLog( G::LoadTranslation('ID_MYSQL_ERROR', SYS_LANG, Array($errorMessage) ) ); @@ -710,6 +712,7 @@ class Installer extends Controller $dbText .= sprintf( " define ('DB_REPORT_NAME', '%s' );\n", $wf_workpace ); $dbText .= sprintf( " define ('DB_REPORT_USER', '%s' );\n", $wf ); $dbText .= sprintf( " define ('DB_REPORT_PASS', '%s' );\n", $wfPass ); + if (defined('PARTNER_FLAG') || isset($_REQUEST['PARTNER_FLAG'])) { $dbText .= "\n"; $dbText .= " define ('PARTNER_FLAG', " . ((defined('PARTNER_FLAG')) ? PARTNER_FLAG : ((isset($_REQUEST['PARTNER_FLAG'])) ? $_REQUEST['PARTNER_FLAG']:'false')) . ");\n"; @@ -785,9 +788,6 @@ class Installer extends Controller $query = sprintf( "UPDATE USERS SET USR_USERNAME = '%s', USR_PASSWORD = '%s' WHERE USR_UID = '00000000000000000000000000000001' ", $adminUsername, md5( $adminPassword ) ); $this->mysqlQuery( $query ); - $query = sprintf( "USE %s;", $rb_workpace ); - $this->mysqlQuery( $query ); - $query = sprintf( "UPDATE RBAC_USERS SET USR_USERNAME = '%s', USR_PASSWORD = '%s' WHERE USR_UID = '00000000000000000000000000000001' ", $adminUsername, md5( $adminPassword ) ); $this->mysqlQuery( $query );