Index: branches/5.0.x/core/units/configuration/configuration_event_handler.php =================================================================== diff -u -r12117 -r12233 --- branches/5.0.x/core/units/configuration/configuration_event_handler.php (.../configuration_event_handler.php) (revision 12117) +++ branches/5.0.x/core/units/configuration/configuration_event_handler.php (.../configuration_event_handler.php) (revision 12233) @@ -1,6 +1,6 @@ Application->GetVar($event->getPrefixSpecial(true)); - $state_country_hash = Array( - 'Comm_State' => 'Comm_Country', - 'Comm_Shipping_State' => 'Comm_Shipping_Country' - ); + $state_country_hash = Array ( + 'Comm_State' => 'Comm_Country', + 'Comm_Shipping_State' => 'Comm_Shipping_Country' + ); $field_name = $object->GetDBField('VariableName'); - if (isset($state_country_hash[$field_name])) { + if (array_key_exists($field_name, $state_country_hash)) { // if this is state field $check_state = $object->GetDBField('VariableValue'); $check_country = $field_values[ $state_country_hash[$field_name] ]['VariableValue']; @@ -93,8 +91,7 @@ if ($state_iso !== false) { $object->SetDBField('VariableValue', $state_iso); } - else - { + else { $errormsgs = $this->Application->GetVar('errormsgs'); $errors = !$errormsgs || !isset($errormsgs[$event->Prefix_Special]) ? Array() : $errormsgs[$event->Prefix_Special]; @@ -105,7 +102,6 @@ $event->status = erFAIL; } } - } /** @@ -116,13 +112,50 @@ function OnAfterItemUpdate(&$event) { $object =& $event->getObject(); + /* @var $object kDBItem */ + if ($object->GetDBField('element_type') == 'password') { if (trim($object->GetDBField('VariableValue')) == '') { $field_options = $object->GetFieldOptions('VariableValue'); unset($field_options['skip_empty']); $object->SetFieldOptions('VariableValue', $field_options); } } + + // 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'); + + if (in_array($variable_name, $watch_variables)) { + $changed = $this->Application->GetVar($event->getPrefixSpecial() . '_changed', Array ()); + + if ($variable_value != $object->GetOriginalField('VariableValue')) { + $changed[$variable_name] = $variable_value; + $this->Application->SetVar($event->getPrefixSpecial() . '_changed', $changed); + } + + switch ($variable_name) { + case 'Require_AdminSSL': + case 'AdminSSL_URL': + static $skin_deleted = false; + + if (array_key_exists($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; + } + } + } /** @@ -157,17 +190,9 @@ } if ($event->status == erSUCCESS) { // reset cache - $refresh_sections = false; - if ($items_info) { - $id_field = $this->Application->getUnitOption($event->Prefix, 'IDField'); - $table_name = $this->Application->getUnitOption($event->Prefix, 'TableName'); + $changed = $this->Application->GetVar($event->getPrefixSpecial() . '_changed', Array ()); + $refresh_sections = array_key_exists('AdvancedUserManagement', $changed) || array_key_exists('Site_Name', $changed); - $sql = 'SELECT ' . $id_field . ' - FROM ' . $table_name . ' - WHERE ' . $id_field . ' IN (' . implode(',', array_keys($items_info)) . ') AND (VariableName = "AdvancedUserManagement")'; - $refresh_sections = $this->Conn->GetCol($sql); - } - if ($refresh_sections) { // reset sections too, because of AdvancedUserManagement $event->SetRedirectParam('refresh_tree', 1);