Ejemplo n.º 1
0
 public function init()
 {
     parent::init();
     if (!$this->model->isNewRecord) {
         $this->answers = $this->model->answer;
     }
 }
Ejemplo n.º 2
0
 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;
 }
Ejemplo n.º 3
0
 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');
 }
Ejemplo n.º 4
0
 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)));
     }
 }
Ejemplo n.º 5
0
 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;
         }
     }
 }
Ejemplo n.º 6
0
 public function getCaption()
 {
     /**
      * @var DaActiveRecord $model
      */
     $model = $this->model;
     if (!$model->isNewRecord) {
         return 'Изменить пароль';
     }
     return parent::getCaption();
 }
Ejemplo n.º 7
0
 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();
 }
Ejemplo n.º 8
0
 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);
 }
Ejemplo n.º 9
0
 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;
         }
     }
 }
Ejemplo n.º 10
0
 public function init()
 {
     parent::init();
     $this->model->addValidator(CValidator::createValidator('length', $this->model, $this->attributeName, array('on' => 'backendInsert, backendUpdate', 'max' => 255)));
 }
Ejemplo n.º 11
0
 public function init()
 {
     parent::init();
     $this->modules = SiteModule::model()->resetScope()->findAll();
 }
Ejemplo n.º 12
0
 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);
 }