diff --git a/rbac/engine/config/schema.xml b/rbac/engine/config/schema.xml index 2fc6b8b87..3c7807171 100755 --- a/rbac/engine/config/schema.xml +++ b/rbac/engine/config/schema.xml @@ -199,7 +199,7 @@ - + diff --git a/workflow/engine/classes/class.system.php b/workflow/engine/classes/class.system.php index b03495e62..4a90da7b1 100755 --- a/workflow/engine/classes/class.system.php +++ b/workflow/engine/classes/class.system.php @@ -682,6 +682,16 @@ class System return System::getSchema( PATH_TRUNK . "workflow/engine/config/schema.xml" ); } + /** + * Retrieves the system schema rbac. + * + * @return schema content in an array + */ + public static function getSystemSchemaRbac () + { + return System::getSchema( PATH_TRUNK . "rbac/engine/config/schema.xml" ); + } + /** * Retrieves the schema for a plugin. * diff --git a/workflow/engine/classes/class.wsTools.php b/workflow/engine/classes/class.wsTools.php index ba91be406..fe238ecdd 100755 --- a/workflow/engine/classes/class.wsTools.php +++ b/workflow/engine/classes/class.wsTools.php @@ -134,6 +134,12 @@ class workspaceTools $this->dbHost = $values["DB_HOST"]; $this->dbUser = $values["DB_USER"]; $this->dbPass = $values["DB_PASS"]; + + $this->dbRbacHost = $values["DB_RBAC_HOST"]; + $this->dbRbacName = $values["DB_RBAC_NAME"]; + $this->dbRbacUser = $values["DB_RBAC_USER"]; + $this->dbRbacPass = $values["DB_RBAC_PASS"]; + return $this->dbInfo = $values; } @@ -330,20 +336,25 @@ class workspaceTools * * @return database connection */ - private function getDatabase() - { + private function getDatabase($rbac = false) + { if (isset($this->db) && $this->db->isConnected()) { return $this->db; } + G::LoadSystem('database_' . strtolower($this->dbAdapter)); - $this->db = new database($this->dbAdapter, $this->dbHost, $this->dbUser, $this->dbPass, $this->dbName); + if ($rbac = true){ + $this->db = new database($this->dbAdapter, $this->dbRbacHost, $this->dbRbacUser, $this->dbRbacPass, $this->dbRbacName); + } else { + $this->db = new database($this->dbAdapter, $this->dbHost, $this->dbUser, $this->dbPass, $this->dbName); + } if (!$this->db->isConnected()) { $this->db->logQuery('No available connection to database!'); throw new Exception("Could not connect to database"); } return $this->db; } - + /** * Close any database opened with getDatabase */ @@ -370,9 +381,15 @@ class workspaceTools * * @return array with the database schema */ - public function getSchema() + public function getSchema($rbac = null) { - $oDataBase = $this->getDatabase(); + + + if($rbac == null){ + $oDataBase = $this->getDatabase(); + } else { + $oDataBase = $this->getDatabase(true); + } $aOldSchema = array(); @@ -632,7 +649,9 @@ class workspaceTools $this->initPropel( true ); p11835::isApplicable(); $systemSchema = System::getSystemSchema(); + $systemSchemaRbac = System::getSystemSchemaRbac();// obtiene el Schema de Rbac $this->upgradeSchema( $systemSchema ); + $this->upgradeSchema( $systemSchemaRbac, false, true );// Hace Upgrade de Rbac $this->upgradeData(); p11835::execute(); return true; @@ -646,7 +665,7 @@ class workspaceTools * @return array bool the changes if checkOnly is true, else return * true on success */ - public function upgradeSchema($schema, $checkOnly = false) + public function upgradeSchema($schema, $checkOnly = false, $rbac = false) { $dbInfo = $this->getDBInfo(); @@ -654,9 +673,16 @@ class workspaceTools throw new Exception("Only MySQL is supported"); } - $workspaceSchema = $this->getSchema(); + if($rbac == true) { + $workspaceSchema = $this->getSchema(true); + } else { + $workspaceSchema = $this->getSchema(); + } + $changes = System::compareSchema($workspaceSchema, $schema); + $changed = (count($changes['tablesToAdd']) > 0 || count($changes['tablesToAlter']) > 0 || count($changes['tablesWithNewIndex']) > 0 || count($changes['tablesToAlterIndex']) > 0); + if ($checkOnly || (!$changed)) { if ($changed) { return $changes; @@ -665,8 +691,11 @@ class workspaceTools return $changed; } } - - $oDataBase = $this->getDatabase(); + if($rbac == true) { + $oDataBase = $this->getDatabaseRbac(); + } else { + $oDataBase = $this->getDatabase(); + } $oDataBase->iFetchType = MYSQL_NUM; $oDataBase->logQuery(count($changes));