Index: trunk/core/units/configuration/configuration_event_handler.php =================================================================== diff -u -N -r4625 -r4653 --- trunk/core/units/configuration/configuration_event_handler.php (.../configuration_event_handler.php) (revision 4625) +++ trunk/core/units/configuration/configuration_event_handler.php (.../configuration_event_handler.php) (revision 4653) @@ -2,7 +2,20 @@ class ConfigurationEventHandler extends InpDBEventHandler { + /** + * Changes permission section to one from REQUEST, not from config + * + * @param kEvent $event + */ + function CheckPermission(&$event) + { + $event->setEventParam('PermSection', $this->Application->GetVar('section')); + return parent::CheckPermission($event); + } + + + /** * Apply any custom changes to list's sql query * * @param kEvent $event @@ -101,36 +114,48 @@ function OnUpdate(&$event) { if (!$this->Application->CheckPermission('SYSTEM_ACCESS.READONLY', 1)) { + + // 1. save user selected module root category + $items_info = $this->Application->GetVar($event->getPrefixSpecial(true)); + $new_category_id = getArrayValue($items_info, 'ModuleRootCategory', 'VariableValue'); + if ($new_category_id) { + unset($items_info['ModuleRootCategory']); + $this->Application->SetVar($event->getPrefixSpecial(true), $items_info); + } + parent::OnUpdate($event); + + if ($event->status == erSUCCESS && $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) { + // 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)); + } + } } - $event->SetRedirectParam('opener', 's'); - if ($this->Application->GetVar('errormsgs')) { // because we have list out there, and this is item $this->Application->removeObject($event->getPrefixSpecial()); $event->redirect = false; } } - - function OnCancel(&$event) - { - parent::OnCancel($event); - $event->SetRedirectParam('opener', 's'); - } /** * Enter description here... * * @param kEvent $event */ - function OnChangeCountry(&$event) + /*function OnChangeCountry(&$event) { $event->setPseudoClass('_List'); $object = &$event->getObject( Array('per_page'=>-1) ); $object->Query(); - //$object->SetDBField(''); - $array_records = &$object->Records; + $array_records =& $object->Records; foreach($array_records as $i=>$record){ if ($record['VariableName']=='Comm_Country'){ $values = $this->Application->GetVar('conf'); @@ -140,6 +165,28 @@ $event->redirect_params = Array('opener' => 's', 'pass'=>'all,conf'); //stay! $event->redirect = false; + }*/ + + /** + * Allows to process module root category selection + * + * @param kEvent $event + */ + function OnSelectItems(&$event) + { + $object =& $event->getObject( Array('skip_autoload' => true) ); + + $items_info = $this->Application->GetVar('c'); + list($resource_id, $field_values) = each($items_info); + + if ($resource_id) { + $sql = 'SELECT CategoryId + FROM '.TABLE_PREFIX.'Category + WHERE ResourceId = '.$resource_id; + $category_id = $this->Conn->GetOne($sql); + $this->Application->StoreVar('ModuleRootCategory', $category_id); + } + $this->finalizePopup($event); } }