protected function rightsForOperation($operation, $is_deny = 0) { $params = array('aco_class' => $this->objects[0], 'aco_key' => !empty($this->objects[1]) ? $this->objects[1] : '', 'aco_value' => !empty($this->objects[2]) ? $this->objects[2] : '', 'action' => $operation); $items = AccessItem::model()->findAllByAttributes($params); $data = array(); foreach ($items as $item) { if ($item['aro_class']) { $data[] = array('id' => $item->getAroId(), 'text' => $item->getAroText()); } } $extraResults = array(); $buildInRoles = Role::builtInRoles(); foreach ($buildInRoles as $roleName => $roleTitle) { $extraResults['User:roles:' . $roleName] = $roleTitle; } return $this->widget('Select2', array('name' => $this->htmlOptions['name'] . '[' . $operation . ']', 'id' => $this->htmlOptions['id'] . '_' . $operation, 'data' => $data, 'htmlOptions' => array('class' => 'rightsselect', 'data-aco_class' => $params['aco_class'], 'data-aco_key' => $params['aco_key'], 'data-aco_value' => $params['aco_value'], 'data-operation' => $params['action'], 'data-is_deny' => $is_deny), 'classNames' => array(array('User', 'User:id:', 'id', 'email,login,displayname'), array('User', 'User:roles:', '_roles.name', 'title'), $extraResults)), true); }
public function form() { $timezoneList = timezone_identifiers_list(); sort($timezoneList); $timezoneList = array_combine($timezoneList, $timezoneList); // Общие настроки $ret = array('elements' => array(Form::tab(Yii::t('cms', 'General settings')), 'sitename' => array('type' => 'text', 'size' => 60), 'adminEmail' => array('type' => 'text', 'size' => 60), 'language' => array('type' => 'LanguageSelect', 'empty' => null), 'timezone' => array('type' => 'dropdownlist', 'items' => $timezoneList), 'autoSave' => array('type' => 'checkbox'), 'slugTransliterate' => array('type' => 'checkbox'), 'slugLowercase' => array('type' => 'checkbox'), 'pageOnError403' => array('type' => 'PageSelect'), 'pageOnError404' => array('type' => 'PageSelect'), Form::tab(Yii::t('cms', 'Appearance')), 'theme' => array('type' => 'ThemeSelect', 'empty' => null), 'defaultsPerPage' => array('type' => 'Slider', 'options' => array('min' => 1, 'max' => 50)), 'showWidgetAppearance' => array('type' => 'checkbox'), 'ajaxPager' => array('type' => 'checkbox'), 'ajaxPagerScroll' => array('type' => 'checkbox'), Form::tab(Yii::t('cms', 'Users')), 'defaultsShowEmail' => array('type' => 'dropdownlist', 'items' => Role::builtInRoles()), 'defaultsSendMessage' => array('type' => 'dropdownlist', 'items' => Role::builtInRoles()), 'userExtraFields' => array('type' => 'FieldSet'), Form::tab(Yii::t('cms', 'Performance')), 'cacheTime' => array('type' => 'Slider', 'options' => array('min' => 0, 'max' => 3600, 'step' => 60), 'hint' => Yii::t('cms', 'in seconds, 0 = off, 3600 - one hour')))); // Настройки для юнитов $units = ContentUnit::getInstalledUnits(); $ret['elements'][] = Form::tab(Yii::t('cms', 'Units settings')); foreach ($units as $unitClass) { if (method_exists($unitClass, 'settings')) { $elems = call_user_func(array($unitClass, 'settings'), $unitClass); if (is_array($elems) && !empty($elems)) { $ret['elements'][] = Form::section(call_user_func(array($unitClass, 'name'))); foreach ($elems as $k => $elem) { $ret['elements'][$unitClass . '.' . $k] = $elem; } } } } return self::localizedForm($ret); }
public function getFewRecordsTitle($attrName, $attrValue) { if ($attrName == 'roles') { $builtInRoles = Role::builtInRoles(); if (isset($builtInRoles[$attrValue])) { return $builtInRoles[$attrValue]; } else { $role = Role::model()->findByAttributes(array('name' => $attrValue)); if ($role) { return $role->title; } else { return parent::getFewRecordsTitle($attrName, $attrValue); } } } elseif ($attrName == 'login') { $user = User::getByLogin($attrValue); if ($user) { return $user->getFullname(); } else { return parent::getFewRecordsTitle($attrName, $attrValue); } } else { return parent::getFewRecordsTitle($attrName, $attrValue); } }