Index: trunk/kernel/units/custom_fields/custom_fields_event_handler.php =================================================================== diff -u -N -r4926 -r6625 --- trunk/kernel/units/custom_fields/custom_fields_event_handler.php (.../custom_fields_event_handler.php) (revision 4926) +++ trunk/kernel/units/custom_fields/custom_fields_event_handler.php (.../custom_fields_event_handler.php) (revision 6625) @@ -1,6 +1,6 @@ Conn->qstr( $this->Application->GetVar('cf_type') ); $main_prefix = $this->Conn->GetOne($sql); - + $section = $this->Application->getUnitOption($main_prefix.'.custom', 'PermSection'); $event->setEventParam('PermSection', $section); return parent::CheckPermission($event); } - + /** * Apply any custom changes to list's sql query * @@ -28,26 +28,26 @@ function SetCustomQuery(&$event) { $object =& $event->getObject(); - + $item_type = $this->Application->GetVar('cf_type'); if (!$item_type) { $prefix = $event->getEventParam('SourcePrefix'); $item_type = $this->Application->getUnitOption($prefix, 'ItemType'); } - + if ($event->Special == 'general') { $object->addFilter('generaltab_filter', '%1$s.OnGeneralTab = 1'); } - + if ($item_type) { $object->addFilter('itemtype_filter', '%1$s.Type = '.$item_type); } - + if (!($this->Application->isDebugMode() && $this->Application->IsAdmin())) { $object->addFilter('user_filter', '%1$s.IsSystem = 0'); } } - + /** * Prevents from duplicate item creation * @@ -56,19 +56,19 @@ function OnBeforeItemCreate(&$event) { $object =& $event->getObject(); - + $live_table = $this->Application->getUnitOption($event->Prefix, 'TableName'); $sql = 'SELECT COUNT(*) FROM '.$live_table.' WHERE FieldName = '.$this->Conn->qstr($object->GetDBField('FieldName')).' AND Type = '.$object->GetDBField('Type'); $found = $this->Conn->GetOne($sql); - + if ($found) { $event->status = erFAIL; $object->SetError('FieldName', 'duplicate', 'la_error_CustomExists'); } } - + /** * Occurse after deleting item, id of deleted item * is stored as 'id' param of event @@ -80,11 +80,11 @@ { $object =& $event->getObject(); $main_prefix = $this->getPrefixByItemType($object->GetDBField('Type')); - + $ml_helper =& $this->Application->recallObject('kMultiLanguageHelper'); $ml_helper->deleteField($main_prefix.'-cdata', $event->getEventParam('id')); } - + /** * Get config prefix based on item type * @@ -98,7 +98,7 @@ WHERE ItemType = '.$item_type; return $this->Conn->GetOne($sql); } - + /** * Enter description here... * @@ -109,22 +109,22 @@ if ($event->MasterEvent->status != erSUCCESS) { return false; } - + $object =& $event->getObject(); $main_prefix = $this->getPrefixByItemType($object->GetDBField('Type')); - + $this->Application->HandleEvent( new kEvent($main_prefix.'-cdata:OnCreateCustomFields') ); - + $ml_helper =& $this->Application->recallObject('kMultiLanguageHelper'); $ml_helper->createFields($main_prefix.'-cdata'); } - + function OnMassDelete(&$event) { parent::OnMassDelete($event); $event->redirect_params = Array('opener' => 's'); } - + /** * Prepare temp tables for creating new item * but does not create it. Actual create is