Add triggers for APP_CACHE_VIEW during installation.

This commit is contained in:
Alexandre Rosenfeld
2011-02-23 21:37:12 +00:00
parent ced0f4d771
commit 7f9d0bac81
2 changed files with 36 additions and 1 deletions

View File

@@ -193,7 +193,7 @@ class Installer
/* Dump schema workflow && data */
$this->log("Importing database schema:\n");
$this->log("Import database schema:\n");
$myPortA = explode(":",$this->options['database']['hostname']);
if(count($myPortA)<2) {
$myPortA[1]="3306";
@@ -217,6 +217,19 @@ class Installer
$qrv = $this->query_sql_file(PATH_RBAC_MYSQL_DATA.$values,$this->connection_database);
$this->log($qrv, isset($qrv['errors']));
mysql_select_db($wf,$this->connection_database);
require_once("propel/Propel.php");
require_once('classes/model/AppCacheView.php');
$appCache = new AppCacheView();
$appCache->setPathToAppCacheFiles ( PATH_METHODS . 'setup/setupSchemas/' );
$triggers = $appCache->getTriggers("en");
$this->log("Create 'cases list cache' triggers");
foreach ($triggers as $triggerName => $trigger) {
$this->run_query($trigger, "-> Trigger $triggerName");
}
$path_site = $this->options['path_data']."/sites/".$this->options['name']."/";
$db_file = $path_site."db.php";
@mkdir($path_site,0777,true);

View File

@@ -1162,6 +1162,28 @@ class AppCacheView extends BaseAppCacheView {
return 'exists';
}
/**
* Retrieve the SQL code to create the APP_CACHE_VIEW triggers.
*
* @return array each value is a SQL statement to create a trigger.
*/
function getTriggers($lang){
$triggerFiles = array(
'triggerApplicationDelete.sql',
'triggerApplicationUpdate.sql',
'triggerAppDelegationUpdate.sql',
'triggerAppDelegationInsert.sql');
$triggers = array();
foreach ($triggerFiles as $triggerFile) {
$trigger = file_get_contents("{$this->pathToAppCacheFiles}/$triggerFile");
if ($trigger === false)
throw new Exception("Could not read trigger contents in $triggerFile");
$trigger = str_replace('{lang}', $lang, $trigger);
$triggers[$triggerFile] = $trigger;
}
return $triggers;
}
function getFormatedUser($sFormat, $aCaseUser, $userIndex){
require_once('classes/model/Users.php');
$oUser = new Users();