Index: branches/unlabeled/unlabeled-1.10.2/core/units/config_search/config_search_event_handler.php =================================================================== diff -u -N -r4381 -r5725 --- branches/unlabeled/unlabeled-1.10.2/core/units/config_search/config_search_event_handler.php (.../config_search_event_handler.php) (revision 4381) +++ branches/unlabeled/unlabeled-1.10.2/core/units/config_search/config_search_event_handler.php (.../config_search_event_handler.php) (revision 5725) @@ -3,6 +3,20 @@ class ConfigSearchEventHandler extends InpDBEventHandler { /** + * Changes permission section to one from REQUEST, not from config + * + * @param kEvent $event + */ + function CheckPermission(&$event) + { + $module = $this->Application->GetVar('module'); + $main_prefix = $this->Application->findModule('Name', $module, 'Var'); + $section = $this->Application->getUnitOption($main_prefix.'.search', 'PermSection'); + $event->setEventParam('PermSection', $section); + return parent::CheckPermission($event); + } + + /** * Apply any custom changes to list's sql query * * @param kEvent $event @@ -28,7 +42,7 @@ */ function OnUpdate(&$event) { - if (!$this->Application->CheckPermission('SYSTEM_ACCESS.READONLY', 0)) { + if (!$this->Application->CheckPermission('SYSTEM_ACCESS.READONLY', 1)) { parent::OnUpdate($event); $conf_update = new kEvent('conf:OnUpdate'); @@ -53,16 +67,11 @@ function OnCreateCustomField(&$event) { $custom_field =& $event->MasterEvent->getObject(); - if ($custom_field->GetDBField('Type') == 6) { - // user custom fields are not searchable + if ($custom_field->GetDBField('Type') == 6 || $custom_field->GetDBField('IsSystem') == 1) { + // user & system custom fields are not searchable return false; } - $sql = 'SELECT Module - FROM '.TABLE_PREFIX.'ItemTypes - WHERE ItemType = '.$custom_field->GetDBField('Type'); - $module_name = $this->Conn->GetOne($sql); - $object =& $event->getObject( Array('skip_autoload' => true) ); $custom_id = $custom_field->GetID(); @@ -79,7 +88,13 @@ $cf_search['Description'] = $custom_field->GetDBField('Prompt'); $cf_search['ConfigHeader'] = $custom_field->GetDBField('Heading'); // 'la_Text_CustomFields'; $cf_search['TableName'] = 'CustomField'; - $cf_search['ModuleName'] = $module_name; + + $sql = 'SELECT Module + FROM '.TABLE_PREFIX.'ItemTypes + WHERE ItemType = '.$custom_field->GetDBField('Type'); + + $cf_search['ModuleName'] = $this->Conn->GetOne($sql); + $object->SetFieldsFromHash($cf_search); $result = $object->isLoaded() ? $object->Update() : $object->Create();