This shows you the differences between two versions of the page.
Both sides previous revision Previous revision | |||
koding:hostcms:informacionnye_sistemy:podmena_polja_siteuser_id [06.05.15 в 15:33] Артем Куц удалено |
— (current) | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | <code><?php | ||
- | defined('HOSTCMS') || exit('HostCMS: access denied.'); | ||
- | |||
- | /** | ||
- | * observer. | ||
- | * @author KAD artem.kuts@gmail.com | ||
- | |||
- | Core_Event::attach('Informationsystem_Item_Controller_Edit.onBeforeExecute', array('Informationsystem_Group_Observer', 'onBeforeExecute')); | ||
- | |||
- | */ | ||
- | |||
- | class Informationsystem_Group_Observer | ||
- | { | ||
- | static public function onBeforeExecute($object, $operation) | ||
- | { | ||
- | |||
- | // ID информационной системы, для которой требуется производить подмену | ||
- | $informationsystem_id = 17; | ||
- | |||
- | $siteID = CURRENT_SITE; | ||
- | $windowID = $operation[1]->getWindowId(); | ||
- | |||
- | $_object = $object->getObject(); | ||
- | $modelName = $_object->getModelName(); | ||
- | $oSeparatorField = new Admin_Form_Entity_Separator(); | ||
- | |||
- | if ($_object->informationsystem->id != $informationsystem_id) return; | ||
- | |||
- | // Отображение формы, операция NULL | ||
- | if (is_null($operation[0]) || $operation[0] == '') | ||
- | { | ||
- | |||
- | $oMainTab = $object->getTab('main'); | ||
- | $oChangedField = $oMainTab->getField("siteuser_id"); | ||
- | |||
- | |||
- | $oSiteusers = Core_Entity::factory('siteuser')->getAllBySite_id($siteID); | ||
- | |||
- | $aSiteusers = array(); | ||
- | |||
- | foreach ($oSiteusers as $oSiteuser) | ||
- | { | ||
- | $aSiteusers[$oSiteuser->id] = $oSiteuser->surname . " " . $oSiteuser->name . " " . $oSiteuser->patronymic; | ||
- | } | ||
- | |||
- | $oHtmlSelect = Core::factory('Admin_Form_Entity_Select') | ||
- | ->name($oChangedField->name) | ||
- | ->value($oChangedField->value) | ||
- | ->caption("Пользователь") | ||
- | ->options(array(0 => "..") + $aSiteusers) | ||
- | ->style("width: 300px;"); | ||
- | ; | ||
- | |||
- | $oMainTab->addAfter($oHtmlSelect, $oChangedField); | ||
- | $oMainTab->addAfter($oSeparatorField, $oChangedField); | ||
- | $oMainTab->delete($oChangedField); | ||
- | } | ||
- | } | ||
- | }</code> |