Merged in norah/processmaker/BUG15479 (pull request #768)

BUG-15479 ProcessMaker en una sola Base de Datos
This commit is contained in:
Julio Cesar Laura Avendaño
2014-09-10 10:00:36 -04:00
4 changed files with 32 additions and 36 deletions

View File

@@ -133,19 +133,13 @@ class Installer
//Delete workspace directory if exists //Delete workspace directory if exists
//Drop databases //Drop databases
$this->run_query("DROP DATABASE IF EXISTS " . $wf, "Drop database $wf"); $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 " . $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) { if ($this->cc_status == 1) {
$host = ($islocal) ? "localhost" : "%"; $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 `$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 */ /* Dump schema workflow && data */
@@ -165,23 +159,23 @@ class Installer
$qwv = $this->query_sql_file(PATH_WORKFLOW_MYSQL_DATA . $values, $this->connection_database); $qwv = $this->query_sql_file(PATH_WORKFLOW_MYSQL_DATA . $values, $this->connection_database);
$this->log($qwv, isset($qwv['errors'])); $this->log($qwv, isset($qwv['errors']));
$http = (G::is_https() == true) ? 'https' : 'http'; $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'] : ''); $host = $_SERVER['SERVER_NAME'] . ($_SERVER['SERVER_PORT'] != '80' ? ':' . $_SERVER['SERVER_PORT'] : '');
$workspace = $this->options['name']; $workspace = $this->options['name'];
$endpoint = sprintf( $endpoint = sprintf(
'%s://%s/sys%s/%s/%s/oauth2/grant', '%s://%s/sys%s/%s/%s/oauth2/grant',
$http, $http,
$host, $host,
$workspace, $workspace,
$lang, $lang,
SYS_SKIN 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 $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 ); $this->run_query( $query );
/* Dump schema rbac && data */ /* Dump schema rbac && data */

View File

@@ -61,7 +61,7 @@ class workspaceTools
* @param bool $first true if this is the first workspace to be upgrade * @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') public function upgrade($first = false, $buildCacheView = false, $workSpace = SYS_SYS, $onedb = false, $lang = 'en')
{ {
$start = microtime(true); $start = microtime(true);
CLI::logging("> Updating database...\n"); CLI::logging("> Updating database...\n");
$this->upgradeDatabase($onedb); $this->upgradeDatabase($onedb);
@@ -465,7 +465,7 @@ class workspaceTools
* @param string $lang not currently used * @param string $lang not currently used
*/ */
public function upgradeCacheView($fill = true, $checkOnly = false, $lang = "en") public function upgradeCacheView($fill = true, $checkOnly = false, $lang = "en")
{ {
$this->initPropel(true); $this->initPropel(true);
//require_once ('classes/model/AppCacheView.php'); //require_once ('classes/model/AppCacheView.php');
@@ -479,19 +479,17 @@ class workspaceTools
//setup the appcacheview object, and the path for the sql files //setup the appcacheview object, and the path for the sql files
$appCache = new AppCacheView(); $appCache = new AppCacheView();
$appCache->setPathToAppCacheFiles(PATH_METHODS . 'setup' . PATH_SEP . 'setupSchemas' . PATH_SEP); $appCache->setPathToAppCacheFiles(PATH_METHODS . 'setup' . PATH_SEP . 'setupSchemas' . PATH_SEP);
$userGrants = $appCache->checkGrantsForUser(false); $userGrants = $appCache->checkGrantsForUser(false);
$currentUser = $userGrants['user']; $currentUser = $userGrants['user'];
$currentUserIsSuper = $userGrants['super']; $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 user does not have the SUPER privilege we need to use the root user and grant the SUPER priv. to normal user.
if (!$currentUserIsSuper) { if (!$currentUserIsSuper) {
$appCache->checkGrantsForUser(true); $appCache->checkGrantsForUser(true);
$appCache->setSuperForUser($currentUser); $appCache->setSuperForUser($currentUser);
$currentUserIsSuper = true; $currentUserIsSuper = true;
} }
CLI::logging("-> Creating table\n"); CLI::logging("-> Creating table\n");
//now check if table APPCACHEVIEW exists, and it have correct number of fields, etc. //now check if table APPCACHEVIEW exists, and it have correct number of fields, etc.
$res = $appCache->checkAppCacheView(); $res = $appCache->checkAppCacheView();
@@ -499,7 +497,7 @@ class workspaceTools
CLI::logging("-> Update DEL_LAST_INDEX field in APP_DELEGATION table\n"); CLI::logging("-> Update DEL_LAST_INDEX field in APP_DELEGATION table\n");
//Update APP_DELEGATION.DEL_LAST_INDEX data //Update APP_DELEGATION.DEL_LAST_INDEX data
$res = $appCache->updateAppDelegationDelLastIndex($lang, $checkOnly); $res = $appCache->updateAppDelegationDelLastIndex($lang, $checkOnly);
CLI::logging("-> Verifying roles permissions in RBAC \n"); CLI::logging("-> Verifying roles permissions in RBAC \n");
//Update table RBAC permissions //Update table RBAC permissions
Bootstrap::LoadSystem( 'rbac' ); Bootstrap::LoadSystem( 'rbac' );
@@ -683,7 +681,7 @@ class workspaceTools
* @return array bool upgradeSchema for more information * @return array bool upgradeSchema for more information
*/ */
public function upgradeDatabase ($onedb = false, $checkOnly = false) public function upgradeDatabase ($onedb = false, $checkOnly = false)
{ {
G::LoadClass("patch"); G::LoadClass("patch");
$this->initPropel( true ); $this->initPropel( true );
p11835::$dbAdapter = $this->dbAdapter; p11835::$dbAdapter = $this->dbAdapter;
@@ -725,6 +723,12 @@ class workspaceTools
public function upgradeSchema($schema, $checkOnly = false, $rbac = false, $onedb = false) public function upgradeSchema($schema, $checkOnly = false, $rbac = false, $onedb = false)
{ {
$dbInfo = $this->getDBInfo(); $dbInfo = $this->getDBInfo();
if ($dbInfo['DB_NAME'] == $dbInfo['DB_RBAC_NAME']) {
$onedb = true;
} else {
$onedb = false;
}
if (strcmp($dbInfo["DB_ADAPTER"], "mysql") != 0) { if (strcmp($dbInfo["DB_ADAPTER"], "mysql") != 0) {
throw new Exception("Only MySQL is supported"); throw new Exception("Only MySQL is supported");
@@ -733,7 +737,6 @@ class workspaceTools
$this->setFormatRows(); $this->setFormatRows();
$workspaceSchema = $this->getSchema($rbac); $workspaceSchema = $this->getSchema($rbac);
$oDataBase = $this->getDatabase($rbac); $oDataBase = $this->getDatabase($rbac);
if (!$onedb) { if (!$onedb) {

View File

@@ -1201,7 +1201,6 @@ class AppCacheView extends BaseAppCacheView
$rs1->next(); $rs1->next();
$row = $rs1->getRow(); $row = $rs1->getRow();
$mysqlUser = str_replace('@', "'@'", $row[0]); $mysqlUser = str_replace('@', "'@'", $row[0]);
$super = false; $super = false;
$sql = "SELECT * $sql = "SELECT *
@@ -1211,8 +1210,8 @@ class AppCacheView extends BaseAppCacheView
$rs1 = $stmt->executeQuery($sql, ResultSet::FETCHMODE_ASSOC); $rs1 = $stmt->executeQuery($sql, ResultSet::FETCHMODE_ASSOC);
$rs1->next(); $rs1->next();
$row = $rs1->getRow(); $row = $rs1->getRow();
if (is_array($row = $rs1->getRow())) { if ($row['PRIVILEGE_TYPE'] == 'SUPER') {
$super = G::LoadTranslation('ID_TRUE'); //true; $super = G::LoadTranslation('ID_TRUE'); //true;
} }

View File

@@ -562,8 +562,10 @@ class Installer extends Controller
public function setGrantPrivilegesMySQL ($psUser, $psPassword, $psDatabase, $host) public function setGrantPrivilegesMySQL ($psUser, $psPassword, $psDatabase, $host)
{ {
$host = ($host == 'localhost' || $host == '127.0.0.1' ? 'localhost' : '%'); $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 ); $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 ); $query = @mysql_query( $sql, $this->link );
if (! $query) { if (! $query) {
$errorMessage = mysql_error( $this->link ); $errorMessage = mysql_error( $this->link );
$this->installLog( G::LoadTranslation('ID_MYSQL_ERROR', SYS_LANG, Array($errorMessage) ) ); $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_NAME', '%s' );\n", $wf_workpace );
$dbText .= sprintf( " define ('DB_REPORT_USER', '%s' );\n", $wf ); $dbText .= sprintf( " define ('DB_REPORT_USER', '%s' );\n", $wf );
$dbText .= sprintf( " define ('DB_REPORT_PASS', '%s' );\n", $wfPass ); $dbText .= sprintf( " define ('DB_REPORT_PASS', '%s' );\n", $wfPass );
if (defined('PARTNER_FLAG') || isset($_REQUEST['PARTNER_FLAG'])) { if (defined('PARTNER_FLAG') || isset($_REQUEST['PARTNER_FLAG'])) {
$dbText .= "\n"; $dbText .= "\n";
$dbText .= " define ('PARTNER_FLAG', " . ((defined('PARTNER_FLAG')) ? PARTNER_FLAG : ((isset($_REQUEST['PARTNER_FLAG'])) ? $_REQUEST['PARTNER_FLAG']:'false')) . ");\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 ) ); $query = sprintf( "UPDATE USERS SET USR_USERNAME = '%s', USR_PASSWORD = '%s' WHERE USR_UID = '00000000000000000000000000000001' ", $adminUsername, md5( $adminPassword ) );
$this->mysqlQuery( $query ); $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 ) ); $query = sprintf( "UPDATE RBAC_USERS SET USR_USERNAME = '%s', USR_PASSWORD = '%s' WHERE USR_UID = '00000000000000000000000000000001' ", $adminUsername, md5( $adminPassword ) );
$this->mysqlQuery( $query ); $this->mysqlQuery( $query );