Changeset View
Changeset View
Standalone View
Standalone View
core/units/admin/admin_events_handler.php
Show First 20 Lines • Show All 76 Lines • ▼ Show 20 Line(s) | |||||
if ( array_key_exists($event->Name, $tools_events) ) { | if ( array_key_exists($event->Name, $tools_events) ) { | ||||
$perm_value = $this->Application->CheckPermission($tools_events[$event->Name]); | $perm_value = $this->Application->CheckPermission($tools_events[$event->Name]); | ||||
} | } | ||||
if ( $event->Name == 'OnSaveMenuFrameWidth' ) { | if ( $event->Name == 'OnSaveMenuFrameWidth' ) { | ||||
$perm_value = $this->Application->isAdminUser; | $perm_value = $this->Application->isAdminUser; | ||||
} | } | ||||
/** @var kPermissionsHelper $perm_helper */ | |||||
$perm_helper = $this->Application->recallObject('PermissionsHelper'); | $perm_helper = $this->Application->recallObject('PermissionsHelper'); | ||||
/* @var $perm_helper kPermissionsHelper */ | |||||
$csv_events = Array ('OnCSVImportBegin', 'OnCSVImportStep', 'OnExportCSV', 'OnGetCSV'); | $csv_events = Array ('OnCSVImportBegin', 'OnCSVImportStep', 'OnExportCSV', 'OnGetCSV'); | ||||
if ( in_array($event->Name, $csv_events) ) { | if ( in_array($event->Name, $csv_events) ) { | ||||
/** @var kCSVHelper $csv_helper */ | |||||
$csv_helper = $this->Application->recallObject('CSVHelper'); | $csv_helper = $this->Application->recallObject('CSVHelper'); | ||||
/* @var $csv_helper kCSVHelper */ | |||||
$prefix = $csv_helper->getPrefix(stripos($event->Name, 'import') !== false); | $prefix = $csv_helper->getPrefix(stripos($event->Name, 'import') !== false); | ||||
$perm_mapping = Array ( | $perm_mapping = Array ( | ||||
'OnCSVImportBegin' => 'OnProcessSelected', | 'OnCSVImportBegin' => 'OnProcessSelected', | ||||
'OnCSVImportStep' => 'OnProcessSelected', | 'OnCSVImportStep' => 'OnProcessSelected', | ||||
'OnExportCSV' => 'OnLoad', | 'OnExportCSV' => 'OnLoad', | ||||
'OnGetCSV' => 'OnLoad', | 'OnGetCSV' => 'OnLoad', | ||||
▲ Show 20 Lines • Show All 69 Lines • ▼ Show 20 Line(s) | |||||
$this->Application->rebuildCache('master:config_files', kCache::REBUILD_LATER, CacheSettings::$unitCacheRebuildTime); | $this->Application->rebuildCache('master:config_files', kCache::REBUILD_LATER, CacheSettings::$unitCacheRebuildTime); | ||||
} | } | ||||
else { | else { | ||||
$this->Application->rebuildDBCache('config_files', kCache::REBUILD_LATER, CacheSettings::$unitCacheRebuildTime); | $this->Application->rebuildDBCache('config_files', kCache::REBUILD_LATER, CacheSettings::$unitCacheRebuildTime); | ||||
} | } | ||||
$this->OnResetParsedData($event); | $this->OnResetParsedData($event); | ||||
/** @var SkinHelper $skin_helper */ | |||||
$skin_helper = $this->Application->recallObject('SkinHelper'); | $skin_helper = $this->Application->recallObject('SkinHelper'); | ||||
/* @var $skin_helper SkinHelper */ | |||||
$skin_helper->deleteCompiled(); | $skin_helper->deleteCompiled(); | ||||
} | } | ||||
/** | /** | ||||
* Resets parsed data from unit configs | * Resets parsed data from unit configs | ||||
* | * | ||||
* @param kEvent $event | * @param kEvent $event | ||||
Show All 36 Lines | |||||
* Compiles all templates (with a progress bar) | * Compiles all templates (with a progress bar) | ||||
* | * | ||||
* @param kEvent $event | * @param kEvent $event | ||||
* @return void | * @return void | ||||
* @access protected | * @access protected | ||||
*/ | */ | ||||
protected function OnCompileTemplates(kEvent $event) | protected function OnCompileTemplates(kEvent $event) | ||||
{ | { | ||||
/** @var NParserCompiler $compiler */ | |||||
$compiler = $this->Application->recallObject('NParserCompiler'); | $compiler = $this->Application->recallObject('NParserCompiler'); | ||||
/* @var $compiler NParserCompiler */ | |||||
$compiler->CompileTemplatesStep(); | $compiler->CompileTemplatesStep(); | ||||
$event->status = kEvent::erSTOP; | $event->status = kEvent::erSTOP; | ||||
} | } | ||||
/** | /** | ||||
* Deletes all compiled templates | * Deletes all compiled templates | ||||
* | * | ||||
▲ Show 20 Lines • Show All 243 Lines • ▼ Show 20 Line(s) | |||||
* @access protected | * @access protected | ||||
*/ | */ | ||||
protected function OnRebuildThemes(kEvent $event) | protected function OnRebuildThemes(kEvent $event) | ||||
{ | { | ||||
if ( $this->Application->GetVar('ajax') == 'yes' ) { | if ( $this->Application->GetVar('ajax') == 'yes' ) { | ||||
$event->status = kEvent::erSTOP; | $event->status = kEvent::erSTOP; | ||||
} | } | ||||
/** @var kThemesHelper $themes_helper */ | |||||
$themes_helper = $this->Application->recallObject('ThemesHelper'); | $themes_helper = $this->Application->recallObject('ThemesHelper'); | ||||
/* @var $themes_helper kThemesHelper */ | |||||
$themes_helper->refreshThemes(); | $themes_helper->refreshThemes(); | ||||
$event->SetRedirectParam('action_completed', 1); | $event->SetRedirectParam('action_completed', 1); | ||||
} | } | ||||
/** | /** | ||||
* Saves grid column widths after their resize by user | * Saves grid column widths after their resize by user | ||||
▲ Show 20 Lines • Show All 99 Lines • ▼ Show 20 Line(s) | |||||
* Called by AJAX to perform CSV export | * Called by AJAX to perform CSV export | ||||
* | * | ||||
* @param kEvent $event | * @param kEvent $event | ||||
* @return void | * @return void | ||||
* @access protected | * @access protected | ||||
*/ | */ | ||||
protected function OnExportCSV(kEvent $event) | protected function OnExportCSV(kEvent $event) | ||||
{ | { | ||||
/** @var kCSVHelper $csv_helper */ | |||||
$csv_helper = $this->Application->recallObject('CSVHelper'); | $csv_helper = $this->Application->recallObject('CSVHelper'); | ||||
/* @var $csv_helper kCSVHelper */ | |||||
$csv_helper->PrefixSpecial = $csv_helper->getPrefix(false); | $csv_helper->PrefixSpecial = $csv_helper->getPrefix(false); | ||||
$csv_helper->grid = $this->Application->GetVar('grid'); | $csv_helper->grid = $this->Application->GetVar('grid'); | ||||
$csv_helper->ExportStep(); | $csv_helper->ExportStep(); | ||||
$event->status = kEvent::erSTOP; | $event->status = kEvent::erSTOP; | ||||
} | } | ||||
/** | /** | ||||
* Returning created by AJAX CSV file | * Returning created by AJAX CSV file | ||||
* | * | ||||
* @param kEvent $event | * @param kEvent $event | ||||
* @return void | * @return void | ||||
* @access protected | * @access protected | ||||
*/ | */ | ||||
protected function OnGetCSV(kEvent $event) | protected function OnGetCSV(kEvent $event) | ||||
{ | { | ||||
/** @var kCSVHelper $csv_helper */ | |||||
$csv_helper = $this->Application->recallObject('CSVHelper'); | $csv_helper = $this->Application->recallObject('CSVHelper'); | ||||
/* @var $csv_helper kCSVHelper */ | |||||
$csv_helper->GetCSV(); | $csv_helper->GetCSV(); | ||||
} | } | ||||
/** | /** | ||||
* Start CSV import | * Start CSV import | ||||
* | * | ||||
* @param kEvent $event | * @param kEvent $event | ||||
* @return void | * @return void | ||||
* @access protected | * @access protected | ||||
*/ | */ | ||||
protected function OnCSVImportBegin(kEvent $event) | protected function OnCSVImportBegin(kEvent $event) | ||||
{ | { | ||||
/** @var kDBItem $object */ | |||||
$object = $event->getObject(Array ('skip_autoload' => true)); | $object = $event->getObject(Array ('skip_autoload' => true)); | ||||
Lint: CodingStandard.Array.Array.SpaceAfterKeyword: There must be no space between the Array keyword and the opening parenthesis | |||||
PHP keywords must be lowercase; expected "array" but found "Array" Lint: Generic.PHP.LowerCaseKeyword.Found: PHP keywords must be lowercase; expected "array" but found "Array" | |||||
/* @var $object kDBItem */ | |||||
$object->setID(0); | $object->setID(0); | ||||
$field_values = $this->getSubmittedFields($event); | $field_values = $this->getSubmittedFields($event); | ||||
$object->SetFieldsFromHash($field_values); | $object->SetFieldsFromHash($field_values); | ||||
$event->setEventParam('form_data', $field_values); | $event->setEventParam('form_data', $field_values); | ||||
$event->redirect = false; | $event->redirect = false; | ||||
$result = 'required'; | $result = 'required'; | ||||
if ( $object->GetDBField('ImportFile') ) { | if ( $object->GetDBField('ImportFile') ) { | ||||
/** @var kCSVHelper $csv_helper */ | |||||
$csv_helper = $this->Application->recallObject('CSVHelper'); | $csv_helper = $this->Application->recallObject('CSVHelper'); | ||||
/* @var $csv_helper kCSVHelper */ | |||||
$csv_helper->PrefixSpecial = $csv_helper->getPrefix(true); | $csv_helper->PrefixSpecial = $csv_helper->getPrefix(true); | ||||
$csv_helper->grid = $this->Application->GetVar('grid'); | $csv_helper->grid = $this->Application->GetVar('grid'); | ||||
$result = $csv_helper->ImportStart($object->GetField('ImportFile', 'file_paths')); | $result = $csv_helper->ImportStart($object->GetField('ImportFile', 'file_paths')); | ||||
if ( $result === true ) { | if ( $result === true ) { | ||||
$event->redirect = $this->Application->GetVar('next_template'); | $event->redirect = $this->Application->GetVar('next_template'); | ||||
$event->SetRedirectParam('PrefixSpecial', $this->Application->GetVar('PrefixSpecial')); | $event->SetRedirectParam('PrefixSpecial', $this->Application->GetVar('PrefixSpecial')); | ||||
Show All 11 Lines | |||||
* Performs one CSV import step | * Performs one CSV import step | ||||
* | * | ||||
* @param kEvent $event | * @param kEvent $event | ||||
* @return void | * @return void | ||||
* @access protected | * @access protected | ||||
*/ | */ | ||||
protected function OnCSVImportStep(kEvent $event) | protected function OnCSVImportStep(kEvent $event) | ||||
{ | { | ||||
/** @var kCSVHelper $import_helper */ | |||||
$import_helper = $this->Application->recallObject('CSVHelper'); | $import_helper = $this->Application->recallObject('CSVHelper'); | ||||
/* @var $import_helper kCSVHelper */ | |||||
$import_helper->ImportStep(); | $import_helper->ImportStep(); | ||||
$event->status = kEvent::erSTOP; | $event->status = kEvent::erSTOP; | ||||
} | } | ||||
/** | /** | ||||
* Shows unit config filename, where requested prefix is defined | * Shows unit config filename, where requested prefix is defined | ||||
* | * | ||||
▲ Show 20 Lines • Show All 56 Lines • ▼ Show 20 Line(s) | |||||
* Backup all data | * Backup all data | ||||
* | * | ||||
* @param kEvent $event | * @param kEvent $event | ||||
* @return void | * @return void | ||||
* @access protected | * @access protected | ||||
*/ | */ | ||||
protected function OnBackup(kEvent $event) | protected function OnBackup(kEvent $event) | ||||
{ | { | ||||
/** @var BackupHelper $backup_helper */ | |||||
$backup_helper = $this->Application->recallObject('BackupHelper'); | $backup_helper = $this->Application->recallObject('BackupHelper'); | ||||
/* @var $backup_helper BackupHelper */ | |||||
if ( !$backup_helper->initBackup() ) { | if ( !$backup_helper->initBackup() ) { | ||||
$event->status = kEvent::erFAIL; | $event->status = kEvent::erFAIL; | ||||
} | } | ||||
$event->redirect = 'tools/backup2'; | $event->redirect = 'tools/backup2'; | ||||
} | } | ||||
/** | /** | ||||
* Perform next backup step | * Perform next backup step | ||||
* | * | ||||
* @param kEvent $event | * @param kEvent $event | ||||
* @return void | * @return void | ||||
* @access protected | * @access protected | ||||
*/ | */ | ||||
protected function OnBackupProgress(kEvent $event) | protected function OnBackupProgress(kEvent $event) | ||||
{ | { | ||||
/** @var BackupHelper $backup_helper */ | |||||
$backup_helper = $this->Application->recallObject('BackupHelper'); | $backup_helper = $this->Application->recallObject('BackupHelper'); | ||||
/* @var $backup_helper BackupHelper */ | |||||
$done_percent = $backup_helper->performBackup(); | $done_percent = $backup_helper->performBackup(); | ||||
if ( $done_percent == 100 ) { | if ( $done_percent == 100 ) { | ||||
$event->redirect = 'tools/backup3'; | $event->redirect = 'tools/backup3'; | ||||
return; | return; | ||||
} | } | ||||
Show All 17 Lines | |||||
* Starts restore process | * Starts restore process | ||||
* | * | ||||
* @param kEvent $event | * @param kEvent $event | ||||
* @return void | * @return void | ||||
* @access protected | * @access protected | ||||
*/ | */ | ||||
protected function OnRestore(kEvent $event) | protected function OnRestore(kEvent $event) | ||||
{ | { | ||||
/** @var BackupHelper $backup_helper */ | |||||
$backup_helper = $this->Application->recallObject('BackupHelper'); | $backup_helper = $this->Application->recallObject('BackupHelper'); | ||||
/* @var $backup_helper BackupHelper */ | |||||
$backup_helper->initRestore(); | $backup_helper->initRestore(); | ||||
$event->redirect = 'tools/restore3'; | $event->redirect = 'tools/restore3'; | ||||
} | } | ||||
/** | /** | ||||
* Performs next restore step | * Performs next restore step | ||||
* | * | ||||
* @param kEvent $event | * @param kEvent $event | ||||
* @return void | * @return void | ||||
* @access protected | * @access protected | ||||
*/ | */ | ||||
protected function OnRestoreProgress(kEvent $event) | protected function OnRestoreProgress(kEvent $event) | ||||
{ | { | ||||
/** @var BackupHelper $backup_helper */ | |||||
$backup_helper = $this->Application->recallObject('BackupHelper'); | $backup_helper = $this->Application->recallObject('BackupHelper'); | ||||
/* @var $backup_helper BackupHelper */ | |||||
$done_percent = $backup_helper->performRestore(); | $done_percent = $backup_helper->performRestore(); | ||||
if ( $done_percent == BackupHelper::SQL_ERROR_DURING_RESTORE ) { | if ( $done_percent == BackupHelper::SQL_ERROR_DURING_RESTORE ) { | ||||
$event->redirect = 'tools/restore4'; | $event->redirect = 'tools/restore4'; | ||||
} | } | ||||
elseif ( $done_percent == BackupHelper::FAILED_READING_BACKUP_FILE ) { | elseif ( $done_percent == BackupHelper::FAILED_READING_BACKUP_FILE ) { | ||||
$this->Application->StoreVar('adm.restore_error', 'File read error'); | $this->Application->StoreVar('adm.restore_error', 'File read error'); | ||||
Show All 26 Lines | |||||
* Deletes one backup file | * Deletes one backup file | ||||
* | * | ||||
* @param kEvent $event | * @param kEvent $event | ||||
* @return void | * @return void | ||||
* @access protected | * @access protected | ||||
*/ | */ | ||||
protected function OnDeleteBackup(kEvent $event) | protected function OnDeleteBackup(kEvent $event) | ||||
{ | { | ||||
/** @var BackupHelper $backup_helper */ | |||||
$backup_helper = $this->Application->recallObject('BackupHelper'); | $backup_helper = $this->Application->recallObject('BackupHelper'); | ||||
/* @var $backup_helper BackupHelper */ | |||||
$backup_helper->delete(); | $backup_helper->delete(); | ||||
} | } | ||||
/** | /** | ||||
* Starts restore process | * Starts restore process | ||||
* | * | ||||
* @param kEvent $event | * @param kEvent $event | ||||
▲ Show 20 Lines • Show All 114 Lines • ▼ Show 20 Line(s) | |||||
} | } | ||||
if ( $ret['value'] === false ) { | if ( $ret['value'] === false ) { | ||||
$ret['code'] = 2; | $ret['code'] = 2; | ||||
$ret['message'] = 'Key "' . $key . '" doesn\'t exist'; | $ret['message'] = 'Key "' . $key . '" doesn\'t exist'; | ||||
} | } | ||||
} | } | ||||
/** @var JSONHelper $json_helper */ | |||||
$json_helper = $this->Application->recallObject('JSONHelper'); | $json_helper = $this->Application->recallObject('JSONHelper'); | ||||
/* @var $json_helper JSONHelper */ | |||||
echo $json_helper->encode($ret); | echo $json_helper->encode($ret); | ||||
} | } | ||||
/** | /** | ||||
* Retrieves data from memory cache | * Retrieves data from memory cache | ||||
* | * | ||||
* @param kEvent $event | * @param kEvent $event | ||||
Show All 13 Lines | |||||
} | } | ||||
else { | else { | ||||
$value = $this->Application->GetVar('value'); | $value = $this->Application->GetVar('value'); | ||||
$res = $this->Application->setCache($key, $value); | $res = $this->Application->setCache($key, $value); | ||||
$ret['result'] = $res ? 'OK' : 'FAILED'; | $ret['result'] = $res ? 'OK' : 'FAILED'; | ||||
} | } | ||||
/** @var JSONHelper $json_helper */ | |||||
$json_helper = $this->Application->recallObject('JSONHelper'); | $json_helper = $this->Application->recallObject('JSONHelper'); | ||||
/* @var $json_helper JSONHelper */ | |||||
echo $json_helper->encode($ret); | echo $json_helper->encode($ret); | ||||
} | } | ||||
/** | /** | ||||
* Deploy changes | * Deploy changes | ||||
* | * | ||||
* Usage: "php tools/run_event.php adm:OnDeploy b674006f3edb1d9cd4d838c150b0567d" | * Usage: "php tools/run_event.php adm:OnDeploy b674006f3edb1d9cd4d838c150b0567d" | ||||
Show All 24 Lines | |||||
* | * | ||||
* @param kEvent $event | * @param kEvent $event | ||||
* @param bool $dry_run | * @param bool $dry_run | ||||
* @return void | * @return void | ||||
* @access protected | * @access protected | ||||
*/ | */ | ||||
protected function _deploymentAction(kEvent $event, $dry_run = false) | protected function _deploymentAction(kEvent $event, $dry_run = false) | ||||
{ | { | ||||
/** @var DeploymentHelper $deployment_helper */ | |||||
$deployment_helper = $this->Application->recallObject('DeploymentHelper'); | $deployment_helper = $this->Application->recallObject('DeploymentHelper'); | ||||
/* @var $deployment_helper DeploymentHelper */ | |||||
$deployment_helper->setEvent($event); | $deployment_helper->setEvent($event); | ||||
if ( $deployment_helper->deployAll($dry_run) ) { | if ( $deployment_helper->deployAll($dry_run) ) { | ||||
$event->SetRedirectParam('action_completed', 1); | $event->SetRedirectParam('action_completed', 1); | ||||
if ( !$deployment_helper->isCommandLine ) { | if ( !$deployment_helper->isCommandLine ) { | ||||
// browser invocation -> don't perform redirect | // browser invocation -> don't perform redirect | ||||
▲ Show 20 Lines • Show All 181 Lines • Show Last 20 Lines |
There must be no space between the Array keyword and the opening parenthesis