Index: branches/5.2.x/core/units/configuration/configuration_event_handler.php =================================================================== diff -u -N -r14637 -r14787 --- branches/5.2.x/core/units/configuration/configuration_event_handler.php (.../configuration_event_handler.php) (revision 14637) +++ branches/5.2.x/core/units/configuration/configuration_event_handler.php (.../configuration_event_handler.php) (revision 14787) @@ -1,6 +1,6 @@ getObject(); /* @var $object kDBItem */ - if ($object->GetDBField('ElementType') == 'password') { - if (trim($object->GetDBField('VariableValue')) == '') { + if ( $object->GetDBField('ElementType') == 'password' ) { + if ( trim($object->GetDBField('VariableValue')) == '' ) { $field_options = $object->GetFieldOptions('VariableValue'); unset($field_options['skip_empty']); $object->SetFieldOptions('VariableValue', $field_options); @@ -165,38 +167,25 @@ // allows to check if variable's value was changed now $variable_name = $object->GetDBField('VariableName'); - $variable_value = $object->GetDBField('VariableValue'); - $watch_variables = Array ( - 'Require_AdminSSL', 'AdminSSL_URL', 'AdvancedUserManagement', - 'Site_Name', 'AdminConsoleInterface', 'UsePopups' - ); + $changed = $this->Application->GetVar($event->getPrefixSpecial() . '_changed', Array ()); - if (in_array($variable_name, $watch_variables)) { - $changed = $this->Application->GetVar($event->getPrefixSpecial() . '_changed', Array ()); + if ( $object->GetDBField('VariableValue') != $object->GetOriginalField('VariableValue') ) { + $changed[] = $variable_name; + $this->Application->SetVar($event->getPrefixSpecial() . '_changed', $changed); + } - if ($variable_value != $object->GetOriginalField('VariableValue')) { - $changed[] = $variable_name; - $this->Application->SetVar($event->getPrefixSpecial() . '_changed', $changed); - } + if ( $variable_name == 'Require_AdminSSL' || $variable_name == 'AdminSSL_URL' ) { + // when administrative console is moved to SSL mode, then delete skin + if ( in_array($variable_name, $changed) && !$skin_deleted ) { + $skin_helper =& $this->Application->recallObject('SkinHelper'); + /* @var $skin_helper SkinHelper */ - switch ($variable_name) { - case 'Require_AdminSSL': - case 'AdminSSL_URL': - static $skin_deleted = false; + $skin_file = $skin_helper->getSkinPath(); + if ( file_exists($skin_file) ) { + unlink($skin_file); + } - if (in_array($variable_name, $changed) && !$skin_deleted) { - // when administrative console is moved to SSL mode, then delete skin - $skin_helper =& $this->Application->recallObject('SkinHelper'); - /* @var $skin_helper SkinHelper */ - - $skin_file = $skin_helper->getSkinPath(); - if (file_exists($skin_file)) { - unlink($skin_file); - } - - $skin_deleted = true; - } - break; + $skin_deleted = true; } } @@ -210,30 +199,31 @@ */ function OnUpdate(&$event) { - if ($this->Application->CheckPermission('SYSTEM_ACCESS.READONLY', 1)) { + if ( $this->Application->CheckPermission('SYSTEM_ACCESS.READONLY', 1) ) { $event->status = kEvent::erFAIL; - return ; + return; } - $items_info = $this->Application->GetVar( $event->getPrefixSpecial(true) ); + $items_info = $this->Application->GetVar($event->getPrefixSpecial(true)); // 1. save user selected module root category $new_category_id = getArrayValue($items_info, 'ModuleRootCategory', 'VariableValue'); - if ($new_category_id !== false) { + if ( $new_category_id !== false ) { unset($items_info['ModuleRootCategory']); } $object =& $event->getObject( Array('skip_autoload' => true) ); /* @var $object kDBItem */ - if ($items_info) { + if ( $items_info ) { $has_error = false; + foreach ($items_info as $id => $field_values) { $object->Clear(); // clear validation errors from previous variable $object->Load($id); - $object->SetFieldsFromHash($field_values); + $object->SetFieldsFromHash($field_values); - if (!$object->Update($id)) { + if ( !$object->Update($id) ) { // don't stop when error found ! $has_error = true; } @@ -242,40 +232,43 @@ $event->status = $has_error ? kEvent::erFAIL : kEvent::erSUCCESS; } - if ($event->status == kEvent::erSUCCESS) { - if ($new_category_id !== false) { + if ( $event->status == kEvent::erSUCCESS ) { + if ( $new_category_id !== false ) { // root category was submitted $module = $this->Application->GetVar('module'); $root_category_id = $this->Application->findModule('Name', $module, 'RootCat'); - if ($root_category_id != $new_category_id) { + if ( $root_category_id != $new_category_id ) { // root category differs from one in db - $fields_hash = Array('RootCat' => $new_category_id); - $this->Conn->doUpdate($fields_hash, TABLE_PREFIX.'Modules', 'Name = '.$this->Conn->qstr($module)); + $fields_hash = Array ('RootCat' => $new_category_id); + $this->Conn->doUpdate($fields_hash, TABLE_PREFIX . 'Modules', 'Name = ' . $this->Conn->qstr($module)); } } // reset cache $changed = $this->Application->GetVar($event->getPrefixSpecial() . '_changed', Array ()); - $require_refresh = Array ( - 'AdvancedUserManagement', 'Site_Name', 'AdminConsoleInterface', 'UsePopups' - ); + $require_refresh = Array ('AdvancedUserManagement', 'Site_Name', 'AdminConsoleInterface', 'UsePopups'); $refresh_sections = array_intersect($require_refresh, $changed); $require_full_refresh = Array ('Site_Name', 'AdminConsoleInterface'); - if (array_intersect($require_full_refresh, $changed)) { + if ( array_intersect($require_full_refresh, $changed) ) { $event->SetRedirectParam('refresh_all', 1); - } elseif ($refresh_sections) { - // reset sections too, because of AdvancedUserManagement + } + elseif ( $refresh_sections ) { $event->SetRedirectParam('refresh_tree', 1); } - $this->Application->DeleteUnitCache($refresh_sections ? true : false); + if ( $refresh_sections ) { + // reset sections too, because of AdvancedUserManagement + $this->Application->DeleteSectionCache(); + } + + $this->Application->DeleteUnitCache($changed); } - elseif ($this->Application->GetVar('errors_' . $event->getPrefixSpecial())) { + elseif ( $this->Application->GetVar('errors_' . $event->getPrefixSpecial()) ) { // because we have list out there, and this is item - $this->Application->removeObject( $event->getPrefixSpecial() ); + $this->Application->removeObject($event->getPrefixSpecial()); } // keeps module and section in REQUEST to ensure, that last admin template will work