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
//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 */

View File

@@ -481,10 +481,8 @@ class workspaceTools
$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);
@@ -726,6 +724,12 @@ class workspaceTools
{
$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) {

View File

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

View File

@@ -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 );