/** * Displays a particular model. * @param integer $id the ID of the model to be displayed */ public function actionView($id) { if (Yii::app()->user->checkAccess('viewTasks')) { $workers = new CActiveDataProvider('Users', array('criteria' => array('condition' => 'Tasks.task_id = :task_id', 'params' => array(':task_id' => $id), 'together' => true, 'order' => 't.user_name', 'with' => array('Tasks')))); Users::model()->verifyUserInProject((int) Yii::app()->user->getState('project_selected'), 1); $availableUsers = Users::model()->availablesUsersToTakeTask(Yii::app()->user->getState('project_selected'), $id); $this->render('view', array('model' => $this->loadModel($id), 'workers' => $workers, 'hasTodoList' => Todolist::model()->findList($id), 'availableUsers' => $availableUsers)); } else { throw new CHttpException(403, Yii::t('site', '403_Error')); } }
/** * Returns the data model based on the primary key given in the GET variable. * If the data model is not found, an HTTP exception will be raised. * @param integer the ID of the model to be loaded */ public function loadModel($id) { $model = Todolist::model()->find(array('condition' => 't.task_id = :task_id AND t.todolist_id = :todolist_id', 'params' => array(':todolist_id' => $_POST['id'], ':task_id' => $_POST['task_id']))); if ($model === null) { throw new CHttpException(404, Yii::t('site', '404_Error')); } return $model; }
/** * Get list of subtask or toDolist * @param int $task_id * @return model of todolist */ public function getTodoList($task_id) { return Todolist::model()->findActivity($task_id); }
public function findActivity($task_id) { return Todolist::model()->with('Task')->findAll(array('condition' => 't.task_id = :task_id', 'params' => array(':task_id' => $task_id), 'order' => 't.todolist_position ASC', 'together' => true)); }