Index: branches/5.2.x/core/units/admin/admin_events_handler.php =================================================================== diff -u -N -r14588 -r14609 --- branches/5.2.x/core/units/admin/admin_events_handler.php (.../admin_events_handler.php) (revision 14588) +++ branches/5.2.x/core/units/admin/admin_events_handler.php (.../admin_events_handler.php) (revision 14609) @@ -1,6 +1,6 @@ Conn->Query('DELETE FROM ' . TABLE_PREFIX . 'CachedUrls'); } - function OnResetSections(&$event) + /** + * Resets tree section cache and refreshes admin section tree + * + * @param kEvent $event + * @return void + * @access protected + */ + protected function OnResetSections(&$event) { if ($this->Application->GetVar('ajax') == 'yes') { $event->status = kEvent::erSTOP; @@ -585,14 +594,15 @@ function OnCSVImportStep(&$event) { $import_helper =& $this->Application->recallObject('CSVHelper'); - /* @var $export_helper kCSVHelper */ + /* @var $import_helper kCSVHelper */ $prefix_special = $import_helper->ImportData('prefix'); $prefix_elems = preg_split('/\.|_/', $prefix_special, 2); $perm_sections = $this->Application->getUnitOption($prefix_elems[0], 'PermSection'); - if(!$this->Application->CheckPermission($perm_sections['main'].'.add') && !$this->Application->CheckPermission($perm_sections['main'].'.edit')) { + + if ( !$this->Application->CheckPermission($perm_sections['main'] . '.add') && !$this->Application->CheckPermission($perm_sections['main'] . '.edit') ) { $event->status = kEvent::erPERM_FAIL; - return ; + return; } $import_helper->ImportStep(); @@ -1080,13 +1090,20 @@ } - function runSchemaText($sql) + /** + * Run given schema sqls and return error, if any + * + * @param $sql + * @return string + * @access protected + */ + protected function runSchemaText($sql) { - $table_prefix = 'restore'.TABLE_PREFIX; -// $table_prefix = TABLE_PREFIX; + $table_prefix = 'restore' . TABLE_PREFIX; - if (strlen($table_prefix) > 0) { + if ( strlen($table_prefix) > 0 ) { $replacements = Array ('INSERT INTO ', 'UPDATE ', 'ALTER TABLE ', 'DELETE FROM ', 'REPLACE INTO '); + foreach ($replacements as $replacement) { $sql = str_replace($replacement, $replacement . $table_prefix, $sql); } @@ -1095,69 +1112,68 @@ $sql = str_replace('CREATE TABLE ', 'CREATE TABLE IF NOT EXISTS ' . $table_prefix, $sql); $sql = str_replace('DROP TABLE ', 'DROP TABLE IF EXISTS ' . $table_prefix, $sql); - $commands = explode("# --------------------------------------------------------",$sql); - if(count($commands)>0) - { -// $query_func = getConnectionInterface('query',$dbo_type); -// $errorno_func = getConnectionInterface('errorno',$dbo_type); -// $errormsg_func = getConnectionInterface('errormsg',$dbo_type); + $commands = explode("# --------------------------------------------------------", $sql); - for($i = 0; $i < count($commands); $i++) - { - $cmd = $commands[$i]; - $cmd = trim($cmd); - if(strlen($cmd)>0) - { - $this->Conn->Query($cmd); - if($this->Conn->errorCode != 0) - { - return $this->Conn->errorMessage." COMMAND:
$cmd
"; - } - } - } - } + if ( count($commands) > 0 ) { + for ($i = 0; $i < count($commands); $i++) { + $cmd = trim( $commands[$i] ); + + if ( strlen($cmd) > 0 ) { + $this->Conn->Query($cmd); + + if ( $this->Conn->hasError() ) { + return $this->Conn->getErrorMsg() . " COMMAND:
$cmd
"; + } + } + } + } + + return ''; } - function runSQLText($allsql) + /** + * Runs given sqls and return error message, if any + * + * @param $all_sqls + * @return string + * @access protected + */ + protected function runSQLText($all_sqls) { $line = 0; -// $query_func = getConnectionInterface('query',$dbo_type); -// $errorno_func = getConnectionInterface('errorno',$dbo_type); -// $errormsg_func = getConnectionInterface('errormsg',$dbo_type); - while($line0 && substr($sql,0,1)!="#") - { - $table_prefix = 'restore'.TABLE_PREFIX; + while ( $line < count($all_sqls) ) { + $sql = $all_sqls[$line]; + if ( strlen(trim($sql)) > 0 && substr($sql, 0, 1) != "#" ) { + $table_prefix = 'restore' . TABLE_PREFIX; - if (strlen($table_prefix) > 0) { + if ( strlen($table_prefix) > 0 ) { $replacements = Array ('INSERT INTO ', 'UPDATE ', 'ALTER TABLE ', 'DELETE FROM ', 'REPLACE INTO '); + foreach ($replacements as $replacement) { $sql = str_replace($replacement, $replacement . $table_prefix, $sql); } } $sql = str_replace('CREATE TABLE ', 'CREATE TABLE IF NOT EXISTS ' . $table_prefix, $sql); $sql = str_replace('DROP TABLE ', 'DROP TABLE IF EXISTS ' . $table_prefix, $sql); - $sql = trim($sql); - if(strlen($sql)>0) - { + + if ( strlen($sql) > 0 ) { $this->Conn->Query($sql); - if($this->Conn->errorCode != 0) - { - return $this->Conn->errorMessage." COMMAND:
$sql
"; - } + if ( $this->Conn->hasError() ) { + return $this->Conn->getErrorMsg() . " COMMAND:
$sql
"; + } } } + $line++; } + + return ''; } - /** * Starts restore process *