Ejemplo n.º 1
0
 /**
  * @inheritdoc
  */
 public function disableContentContainer(ContentContainerActiveRecord $container)
 {
     parent::disableContentContainer($container);
     foreach (Task::find()->contentContainer($container)->all() as $task) {
         $task->delete();
     }
 }
Ejemplo n.º 2
0
 public function run()
 {
     if (Yii::$app->user->isGuest) {
         return;
     }
     $tasks = Task::GetUsersOpenTasks();
     if (count($tasks) === 0) {
         return;
     }
     return $this->render('mytasks', array('tasks' => $tasks));
 }
 /**
  * Setup additional filters
  */
 public function setupFilters()
 {
     $this->activeQuery->andWhere(['content.object_model' => Task::className()]);
     if (in_array('tasks_meAssigned', $this->filters) || in_array('tasks_open', $this->filters) || in_array('tasks_finished', $this->filters) || in_array('tasks_notassigned', $this->filters) || in_array('tasks_byme', $this->filters)) {
         $this->activeQuery->leftJoin('task', 'content.object_id=task.id AND content.object_model=:taskModel', [':taskModel' => Task::className()]);
         if (in_array('tasks_meAssigned', $this->filters)) {
             $this->activeQuery->leftJoin('task_user', 'task.id=task_user.task_id AND task_user.user_id=:userId', [':userId' => Yii::$app->user->id]);
             $this->activeQuery->andWhere('task_user.id IS NOT null');
         }
         if (in_array('tasks_notassigned', $this->filters)) {
             $this->activeQuery->andWhere("(SELECT COUNT(*) FROM task_user WHERE task_id=task.id) = 0");
         }
         if (in_array('tasks_byme', $this->filters)) {
             $this->activeQuery->andWhere(['task.created_by' => Yii::$app->user->id]);
         }
         if (in_array('tasks_open', $this->filters)) {
             $this->activeQuery->andWhere(['task.status' => Task::STATUS_OPEN]);
         }
         if (in_array('tasks_finished', $this->filters)) {
             $this->activeQuery->andWhere(['task.status' => Task::STATUS_FINISHED]);
         }
     }
 }
 protected function getTaskById($id)
 {
     $task = Task::find()->contentContainer($this->contentContainer)->readable()->where(['task.id' => $id])->one();
     if ($task === null) {
         throw new HttpException(404, "Could not load task!");
     }
     return $task;
 }
Ejemplo n.º 5
0
 public function getTask()
 {
     return $this->hasOne(Task::className(), ['id' => 'task_id']);
 }