public function init() { parent::init(); if (!$this->model->isNewRecord) { $this->answers = $this->model->answer; } }
public function getParameter() { $ok = false; if (self::$_objectParamPermission == 1) { $ok = Yii::app()->user->checkAccess(DaWebUser::ROLE_DEV); if ($ok) { self::$_objectParamPermission = 2; } else { self::$_objectParamPermission = 3; } } else { if (self::$_objectParamPermission == 2) { $ok = true; } } $link = null; if ($ok) { /** * @var DaObject $object */ $object = $this->model->getObjectInstance(); $link = Yii::app()->createUrl(BackendModule::ROUTE_INSTANCE_VIEW, array(ObjectUrlRule::PARAM_OBJECT => ObjectParameter::ID_OBJECT, ObjectUrlRule::PARAM_OBJECT_INSTANCE => $this->objectParameter->getIdParameter(), ObjectUrlRule::PARAM_GROUP_OBJECT => DaObject::ID_OBJECT, ObjectUrlRule::PARAM_GROUP_INSTANCE => $object->id_object, ObjectUrlRule::PARAM_GROUP_PARAMETER => 75)); } return $link; }
public function init() { parent::init(); if (!$this->model->asa('FileUploadableBehavior') instanceof FileUploadableBehavior) { $this->model->attachBehavior('FileUploadableBehavior', array('class' => 'fileUpload.FileUploadableBehavior', 'resetScope' => true)); } Yii::app()->clientScript->registerCoreScript('jquery.ui'); }
public function init() { parent::init(); if ($this->isInt()) { $this->model->addValidator(CValidator::createValidator('numerical', $this->model, $this->attributeName, array('on' => 'backendInsert, backendUpdate'))); } else { $this->model->addValidator(CValidator::createValidator('length', $this->model, $this->attributeName, array('on' => 'backendInsert, backendUpdate', 'max' => 255))); } }
public function init() { parent::init(); $this->roles = Yii::app()->authManager->getAuthItems(CAuthItem::TYPE_ROLE); if (!$this->model->isNewRecord) { $currentRoles = Yii::app()->authManager->getAuthItems(CAuthItem::TYPE_ROLE, $this->model->id_user); foreach ($currentRoles as $role) { $this->currentRoles[] = $role->name; } } }
public function getCaption() { /** * @var DaActiveRecord $model */ $model = $this->model; if (!$model->isNewRecord) { return 'Изменить пароль'; } return parent::getCaption(); }
public function run() { if ($this->model->isNewRecord) { return; } $idBanner = $this->model->getIdInstance(); $sql = 'SELECT view_type AS type, view_count AS stat FROM da_stat_view WHERE id_object=:obj AND id_instance=:inst'; $rows = Yii::app()->db->createCommand($sql)->queryAll(true, array(':obj' => Banner::ID_OBJECT, ':inst' => $idBanner)); $view = array(); foreach ($rows as $row) { $view[$row['type']] = $row['stat']; } $this->viewStat = $view; parent::run(); }
public function init() { parent::init(); if (!$this->model->asa('DateTimeBehavior') instanceof DateTimeBehavior) { $this->model->attachBehavior('DateTimeBehavior', array('class' => 'ygin.components.dateTime.DateTimeBehavior')); } $objectParam = $this->getObjectParameter(); $dateTimeForm = new DateTimeForm(); $dateTimeForm->dateTimeAttribute = $objectParam->getFieldName(); $dateTimeForm->isTimeAvailable = $this->getIsTimeAvailable(); $dateTimeForm->owner = $this->model; if ($objectParam->isRequired()) { $dateTimeForm->required = true; } $this->model->addDateTimeForm($dateTimeForm); }
public function init() { parent::init(); // Элемент работает с одним типом пхп скрипта. $idPhpScriptType = HU::get(ObjectUrlRule::PARAM_SYSTEM_MODULE); $idPhpScript = $this->model->{$this->attributeName}; if ($idPhpScript == null && $idPhpScriptType == null) { $this->render = false; return; } if ($idPhpScript != null) { $this->phpScript = PhpScriptInstance::model()->findByAttributes(array('id_php_script' => $idPhpScript)); if ($this->phpScript == null) { $this->error = 'Ошибка определения обработчика. Возможно, был удален php-скрипт, привязанный к данному экземпляру.'; return; } } else { if ($idPhpScriptType != null) { // новый раздел $this->phpScript = new PhpScriptInstance(); $this->phpScript->id_php_script_type = $idPhpScriptType; } } }
public function init() { parent::init(); $this->model->addValidator(CValidator::createValidator('length', $this->model, $this->attributeName, array('on' => 'backendInsert, backendUpdate', 'max' => 255))); }
public function init() { parent::init(); $this->modules = SiteModule::model()->resetScope()->findAll(); }
public function init() { parent::init(); $this->htmlOptions = CMap::mergeArray(array('class' => 'b-instance-list-select-multi'), $this->htmlOptions); $this->columnHtmlOptions = CMap::mergeArray(array('class' => $this->htmlOptions['class'], 'offset' => 'col-md-offset-1'), $this->columnHtmlOptions); }