Example #1
0
 public function isDisabled()
 {
     // if (Yii::$app->user->username !== 'admin') {
     //     return true;
     // }
     return parent::isDisabled();
 }
Example #2
0
 /**
  * Override isDisabled method if you need as shown in the
  * example below. You can override similarly other methods
  * like isActive, isMovable etc.
  */
 public function isDisabled()
 {
     if (!Yii::$app->user->can('admin')) {
         return true;
     }
     return parent::isDisabled();
 }
Example #3
0
 /**
  * @inheritdoc
  */
 public function beforeSave($insert)
 {
     if (parent::beforeSave($insert)) {
         $this->id_student = Yii::$app->session['id_student'];
         $this->collapsed = 1;
         return true;
     } else {
         return false;
     }
 }
Example #4
0
 public function attributeLabels()
 {
     $attributeLabels = parent::attributeLabels();
     return $attributeLabels + ['alias' => Yii::t('app', 'Alias'), 'created' => Yii::t('app', 'Created'), 'updated' => Yii::t('app', 'Updated'), 'owner' => Yii::t('app', 'Owner'), 'editor' => Yii::t('app', 'Editor'), 'h1' => Yii::t('app', 'H1'), 'title' => Yii::t('app', 'Title'), 'keywords' => Yii::t('app', 'Keywords'), 'description' => Yii::t('app', 'Keywords')];
 }
Example #5
0
 /**
  * Validation of source query data
  *
  * @throws InvalidConfigException
  */
 protected function validateSourceData()
 {
     if (empty($this->query) || !$this->query instanceof ActiveQuery) {
         throw new InvalidConfigException("The 'query' property must be defined and must be an instance of '" . ActiveQuery::className() . "'.");
     }
     $class = isset($this->query->modelClass) ? $this->query->modelClass : null;
     if (empty($class) || !is_subclass_of($class, ActiveRecord::className())) {
         throw new InvalidConfigException("The 'query' must be implemented using 'ActiveRecord::find()' method.");
     }
     $trait = 'kartik\\tree\\models\\TreeTrait';
     if (!self::usesTrait($class, $trait)) {
         throw new InvalidConfigException("The model class '{$class}' for the 'query' must use the trait '{$trait}' or extend from '" . Tree::className() . "''.");
     }
 }
Example #6
0
 public function afterDelete()
 {
     self::buildCache();
     parent::afterDelete();
 }
Example #7
0
 /**
  * Override isDisabled method if you need as shown in the
  * example below. You can override similarly other methods
  * like isActive, isMovable etc.
  *
  * @return bool
  */
 public function isDisabled()
 {
     return parent::isDisabled();
 }
Example #8
0
 /**
  * @return array
  */
 public function behaviors()
 {
     return array_merge(parent::behaviors(), [['class' => SluggableBehavior::className(), 'attribute' => 'name', 'ensureUnique' => true], ['class' => TimestampBehavior::className()], ['class' => ImageAttachmentBehavior::className()]]);
 }
Example #9
0
 public function rules()
 {
     $rules = parent::rules();
     $rules[] = [['description'], 'string'];
     return $rules;
 }
Example #10
0
 /**
  * @inheritdoc
  * (array) rules :
  * @return array
  */
 public function rules()
 {
     $rules = parent::rules();
     $rules[] = [['route', 'target', 'title'], 'safe'];
     return $rules;
 }
Example #11
0
 /**
  * @inheritdoc
  * (array) rules :
  * @return array
  */
 public function rules()
 {
     $rules = parent::rules();
     $rules[] = [['codes', 'name1', 'classmark'], 'safe'];
     return $rules;
 }
Example #12
0
File: Doctree.php Project: C12D/api
 /**
      * Override isDisabled method if you need as shown in the  
      * example below. You can override similarly other methods
      * like isActive, isMovable etc.
     
     public function isDisabled()
     {
         if (Yii::$app->user->id !== '1') {
             return true;
         }
         return parent::isDisabled();
     }
 */
 public function rules()
 {
     $rules = parent::rules();
     $rules[] = ['description', 'safe'];
     return $rules;
 }