public function behaviors()
 {
     $behaviors = ['access' => ['class' => \yii\web\AccessControl::className(), 'only' => ['down', 'up', 'reset'], 'rules' => [['actions' => ['down', 'up'], 'allow' => true, 'roles' => ['@']]]], 'verbs' => ['class' => \yii\web\VerbFilter::className(), 'actions' => ['down' => ['get'], 'up' => ['get'], 'reset' => ['get']]]];
     return array_replace_recursive(parent::behaviors(), $behaviors);
 }
 public static function booleanActions()
 {
     return array_merge(parent::booleanActions(), ['duplicate' => ['scenario' => 'duplicate', 'attributes' => ['attribute' => 'duplicate', 'blamable' => 'duplicated_by', 'date' => 'duplicated_at'], 'title' => ['Duplicate', 'Set as Unique'], 'afterAction' => function ($model) {
         $model->load(\Yii::$app->request->post());
         switch (is_array($model->duplicate_id)) {
             case true:
                 $model->duplicate_id = implode(',', $model->duplicate_id);
                 break;
         }
     }]]);
 }
 /**
  * Lists all Token models.
  * @return mixed
  */
 public function actionIndex()
 {
     return parent::actionIndex(TokenSearch::className(), ['with' => ['user']]);
 }
 /**
  * Lists all Category models.
  * @return mixed
  */
 public function actionIndex()
 {
     return parent::actionIndex(CategorySearch::className(), ['queryOptions' => ['with' => ['parent']]]);
 }
 public function actionForm($type = null, $id = null)
 {
     $options = ['modelOptions' => [], 'title' => function ($model) {
         if ($model->isNewRecord) {
             return "Create Alert";
         } else {
             $header = 'Update Alert: ' . ' Matching ' . $model->properName($model->priority) . ' ' . ($model->remote_type == 'any' ? 'Anything' : $model->properName($model->remote_type));
         }
         if (!empty($model->remote_for) && !($model->remote_for == 'any')) {
             $header .= ' for ' . $model->properName($model->remote_for);
         }
         if (!empty($model->remote_id)) {
             $header .= ' ' . (!$model->remote_id ? 'with Any id' : ' with id ' . $model->remote_id);
         }
         return $header;
     }];
     $options['force'] = true;
     return parent::actionForm($type, $id, $options);
 }
 /**
  * Get the query that orders items by their activity
  */
 protected function getOrderByQuery()
 {
     $localOrderBy = ["(" . new Expression("SELECT COUNT(*) FROM " . \nitm\widgets\models\Vote::tableName() . " WHERE \n\t\t\t\tparent_id=id AND \n\t\t\t\tparent_type='" . $this->model->isWhat()) . "'\n\t\t\t)" => SORT_DESC, "(CASE status \n\t\t\t\tWHEN 'normal' THEN 0\n\t\t\t\tWHEN 'important' THEN 1 \n\t\t\t\tWHEN 'critical' THEN 2\n\t\t\tEND)" => SORT_DESC];
     return array_merge(parent::getOrderByQuery(), $localOrderBy);
 }
示例#7
0
 public function behaviors()
 {
     $behaviors = ['access' => ['only' => ['down', 'up', 'reset'], 'rules' => [['actions' => ['down', 'up', 'reset'], 'allow' => true, 'roles' => ['@']]]], 'verbs' => ['actions' => ['down' => ['get'], 'up' => ['get'], 'reset' => ['get']]]];
     return array_merge_recursive(parent::behaviors(), $behaviors);
 }