本文整理汇总了PHP中app\models\Task::load方法的典型用法代码示例。如果您正苦于以下问题:PHP Task::load方法的具体用法?PHP Task::load怎么用?PHP Task::load使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\models\Task
的用法示例。
在下文中一共展示了Task::load方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: actionSubmit
/**
* 提交任务
*
* @param $projectId 没有projectId则显示列表
* @return string
*/
public function actionSubmit($projectId = null)
{
// 为了方便用户更改表名,避免表名直接定死
$projectTable = Project::tableName();
$groupTable = Group::tableName();
if (!$projectId) {
// 显示所有项目列表
$projects = Project::find()->leftJoin(Group::tableName(), "`{$groupTable}`.`project_id` = `{$projectTable}`.`id`")->where(["`{$projectTable}`.status" => Project::STATUS_VALID, "`{$groupTable}`.`user_id`" => $this->uid])->asArray()->all();
return $this->render('select-project', ['projects' => $projects]);
}
$task = new Task();
$conf = Project::getConf($projectId);
if (!$conf) {
throw new \Exception(yii::t('task', 'unknown project'));
}
if (\Yii::$app->request->getIsPost()) {
$group = Group::find()->where(['user_id' => $this->uid, 'project_id' => $projectId])->count();
if (!$group) {
throw new \Exception(yii::t('task', 'you are not the member of project'));
}
if ($task->load(\Yii::$app->request->post())) {
// 是否需要审核
$status = $conf->audit == Project::AUDIT_YES ? Task::STATUS_SUBMIT : Task::STATUS_PASS;
$task->user_id = $this->uid;
$task->project_id = $projectId;
$task->status = $status;
if ($task->save()) {
return $this->redirect('@web/task/');
}
}
}
$tpl = $conf->repo_type == Project::REPO_GIT ? 'submit-git' : 'submit-svn';
return $this->render($tpl, ['task' => $task, 'conf' => $conf]);
}
示例2: actionCreate
/**
* Creates a new Task model.
* If creation is successful, the browser will be redirected to the 'view' page.
* @return mixed
*/
public function actionCreate()
{
$course_id = Yii::$app->request->get('course_id');
$model = new Task();
if ($model->load(Yii::$app->request->post())) {
$model = $model->validateAttr($model);
if (empty($model->errors)) {
$resourceModel = new Resource();
$model = $resourceModel->uploadImg($model, 'image');
if ($model->save()) {
return $this->redirect(['view', 'id' => $model->id]);
}
}
}
$model->course_id = $course_id;
if (!json_decode($model->answer_json)) {
$model->answer_json = '';
}
$chapterName = $courseName = null;
if (!empty($course_id)) {
$chapterName = Course::findModel($course_id)->name;
$courseName = Course::findRoot($course_id)->name;
}
return $this->render('create', ['model' => $model, 'courseId' => $course_id, 'chapterName' => $chapterName, 'courseName' => $courseName]);
}
示例3: actionCreate
/**
* Creates a new Task model.
* If creation is successful, the browser will be redirected to the 'view' page.
* @return mixed
*/
public function actionCreate()
{
$model = new Task();
if ($model->load(Yii::$app->request->post()) && $model->save()) {
return $this->getAjaxResponse();
}
}
示例4: actionSubmit
/**
* 提交任务
*
* @param $projectId
* @return string
*/
public function actionSubmit($projectId = null)
{
$task = new Task();
if ($projectId) {
$conf = Project::find()->where(['id' => $projectId, 'status' => Project::STATUS_VALID])->one();
}
if (\Yii::$app->request->getIsPost()) {
if (!$conf) {
throw new \Exception(yii::t('task', 'unknown project'));
}
$group = Group::find()->where(['user_id' => $this->uid, 'project_id' => $projectId])->count();
if (!$group) {
throw new \Exception(yii::t('task', 'you are not the member of project'));
}
if ($task->load(\Yii::$app->request->post())) {
// 是否需要审核
$status = $conf->audit == Project::AUDIT_YES ? Task::STATUS_SUBMIT : Task::STATUS_PASS;
$task->user_id = $this->uid;
$task->project_id = $projectId;
$task->status = $status;
if ($task->save()) {
return $this->redirect('/task/');
}
}
}
if ($projectId) {
$tpl = $conf->repo_type == Project::REPO_GIT ? 'submit-git' : 'submit-svn';
return $this->render($tpl, ['task' => $task, 'conf' => $conf]);
}
// 成员所属项目
$projects = Project::find()->leftJoin(Group::tableName(), '`group`.project_id=project.id')->where(['project.status' => Project::STATUS_VALID, '`group`.user_id' => $this->uid])->asArray()->all();
return $this->render('select-project', ['projects' => $projects]);
}
示例5: actionCreate
public function actionCreate()
{
$task = new Task();
if ($task->load(Yii::$app->request->post()) && $task->save()) {
Yii::$app->getSession()->setFlash("success", 'The record was saved.');
return $this->redirect(["task/"]);
}
return $this->render("create", ["models" => ["task" => $task]]);
}
示例6: actionCreate
/**
* Creates a new Task model.
* If creation is successful, the browser will be redirected to the 'view' page.
* @return mixed
*/
public function actionCreate()
{
$model = new Task();
if ($model->load(Yii::$app->request->post()) && $model->save()) {
return $this->redirect(['index']);
} else {
return $this->render('create', ['model' => $model]);
}
}
示例7: actionCreate
/**
* Creates a new Task model.
* If creation is successful, the browser will be redirected to the 'view' page.
* @return mixed
*/
public function actionCreate()
{
$model = new Task();
$modelDevice = new Device();
$modelAction = new Action();
if ($model->load(Yii::$app->request->post()) && $model->save()) {
return $this->redirect(['view', 'id' => $model->id]);
} else {
return $this->render('create', ['model' => $model, 'from_device_ids' => ArrayHelper::map($modelDevice->getDeviceMaster(), 'id', 'name'), 'to_device_ids' => ArrayHelper::map($modelDevice->getDeviceAll(), 'id', 'name'), 'action_ids' => ArrayHelper::map($modelAction->getActionAll(), 'id', 'name')]);
}
}
示例8: actionCreate
/**
* Creates a new Task model.
* If creation is successful, the browser will be redirected to the 'view' page.
* @return mixed test
*/
public function actionCreate()
{
$model = new Task();
$categories = Category::find()->all();
$units = DicUnit::find()->all();
if ($model->load(Yii::$app->request->post()) && $model->save()) {
return $this->redirect(['view', 'id' => $model->id]);
} else {
return $this->render('create', ['model' => $model, 'categories' => $categories, 'units' => $units]);
}
}
示例9: actionSubmit
/**
* 提交任务
*
* @param $projectId
* @return string
*/
public function actionSubmit($projectId = null)
{
$task = new Task();
if ($projectId) {
// svn下无trunk
$nonTrunk = false;
$conf = Project::find()->where(['id' => $projectId, 'status' => Project::STATUS_VALID])->one();
$conf = Project::getConf($projectId);
// 第一次可能会因为更新而耗时,但一般不会,第一次初始化会是在检测里
if ($conf->repo_type == Project::REPO_SVN && !file_exists(Project::getDeployFromDir())) {
$version = Repo::getRevision($conf);
$version->updateRepo();
}
// 为了简化svn无trunk, branches时,不需要做查看分支,直接就是主干
$svnTrunk = sprintf('%s/trunk', Project::getDeployFromDir());
// svn下无trunk目录
if (!file_exists($svnTrunk)) {
$nonTrunk = true;
}
}
if (\Yii::$app->request->getIsPost()) {
if (!$conf) {
throw new \Exception(yii::t('task', 'unknown project'));
}
$group = Group::find()->where(['user_id' => $this->uid, 'project_id' => $projectId])->count();
if (!$group) {
throw new \Exception(yii::t('task', 'you are not the member of project'));
}
if ($task->load(\Yii::$app->request->post())) {
// 是否需要审核
$status = $conf->audit == Project::AUDIT_YES ? Task::STATUS_SUBMIT : Task::STATUS_PASS;
$task->user_id = $this->uid;
$task->project_id = $projectId;
$task->status = $status;
if ($task->save()) {
return $this->redirect('/task/');
}
}
}
if ($projectId) {
$tpl = $conf->repo_type == Project::REPO_GIT ? 'submit-git' : 'submit-svn';
return $this->render($tpl, ['task' => $task, 'conf' => $conf, 'nonTrunk' => $nonTrunk]);
}
// 成员所属项目
$projects = Project::find()->leftJoin(Group::tableName(), '`group`.project_id=project.id')->where(['project.status' => Project::STATUS_VALID, '`group`.user_id' => $this->uid])->asArray()->all();
return $this->render('select-project', ['projects' => $projects]);
}
示例10: actionCreate
/**
* Creates a new Task model.
* If creation is successful, the browser will be redirected to the 'view' page.
* @return mixed
* @throws UserException
*/
public function actionCreate()
{
$goalId = (int) Yii::$app->request->get('goal_id', 0);
if (!$goalId) {
throw new UserException('Goal id is not provided');
}
$goal = Goal::findOne($goalId);
if (!$goal) {
throw new UserException("Goal [{$goalId}] not found");
}
$model = new Task(['goal_id' => $goalId]);
if ($model->load(Yii::$app->request->post()) && $model->save()) {
return $this->redirect(Yii::$app->request->post('referrer') ?: $model->goal->urlTaskList());
} else {
return $this->render('create', ['model' => $model]);
}
}
示例11: actionUpdate
/**
* Updates an existing Task model.
* If update is successful, the browser will be redirected to the 'update' page.
* @param integer $id
* @return mixed
*/
public function actionUpdate($id = null, $partner_id = null)
{
if ($id) {
$model = $this->findModel($id);
} else {
$model = new Task();
}
if ($model->load(Yii::$app->request->post()) && $model->save()) {
Yii::$app->session->setFlash('success', __('Your changes have been saved successfully.'));
return $this->redirect(['index']);
} else {
if (!$id) {
$model->timestamp = Yii::$app->formatter->asDate(time());
$model->user_id = Yii::$app->user->id;
if ($partner_id) {
$model->select_partner = Partner::findOne($partner_id);
}
}
return $this->renderAjax('update', ['model' => $model]);
}
}
示例12: actionCreate
/**
* Creates a new Task model.
* If creation is successful, the browser will be redirected to the 'view' page.
* @return mixed
*/
public function actionCreate()
{
$model = new Task();
if ($model->load(Yii::$app->request->post())) {
$model->attachment = UploadedFile::getInstance($model, 'attachment');
$model->task_start = date('Y-m-d', strtotime($model->task_start));
$model->task_end = date('Y-m-d', strtotime($model->task_end));
if ($model->attachment) {
$fileName = sprintf('%s.%s', $model->task_to . time(), $model->attachment->extension);
$model->attachment->saveAs('uploads/' . $fileName);
$model->attachment = $fileName;
} else {
$model->attachment = '';
}
if ($model->validate() && $model->save()) {
Yii::$app->getSession()->setFlash('success', Yii::t('app', 'Data Permintaan Tugas Berhasil Disimpan'));
return $this->redirect(['index']);
} else {
Yii::$app->getSession()->setFlash('error', Yii::t('app', 'Data Permintaan Tugas Gagal Disimpan'));
}
}
return $this->render('create', ['model' => $model]);
}
示例13: actionCreate
/**
* Creates a new Task model.
* If creation is successful, the browser will be redirected to the 'view' page.
* @param integer $projectId
* @return mixed
*/
public function actionCreate($projectId)
{
$model = new Task();
if ($model->load(Yii::$app->request->post())) {
if (strtotime($model->delivery_date) >= strtotime(Yii::$app->formatter->asDate('now', 'yyyy-MM-dd'))) {
$students = $_POST['Task']['students'];
$model->status = Task::NEW_TASK;
$model->project_id = $projectId;
$model->save();
foreach ($students as $value) {
Yii::$app->db->createCommand()->insert('student_evidence', ['task_id' => $model->id, 'project_id' => $model->project_id, 'evidence_id' => null, 'student_id' => $value, 'status' => Task::NEW_TASK])->execute();
$this->setNotification($value, $model->id, $model->project_id, Notification::NEW_TASK);
}
Yii::$app->getSession()->setFlash('success', 'Petición creada exitosamente');
return $this->redirect(['student-evidence/index']);
} else {
Yii::$app->getSession()->setFlash('danger', 'La fecha de entrega no puede ser anterior a la fecha actual');
return $this->render('create', ['model' => $model, 'projectId' => $projectId]);
}
} else {
return $this->render('create', ['model' => $model]);
}
}
示例14: actionCreate
/**
* Creates a new Task model.
* If creation is successful, the browser will be redirected to the 'view' page.
* @return mixed
*/
public function actionCreate()
{
if (($role = priviledge::getRole()) == 'Admin') {
$model = new Task();
if ($model->load(Yii::$app->request->post()) && $model->validate()) {
$model->url = strtolower($model->url);
$model->status = 'Pending';
//$model->user_id = \Yii::$app->user->identity;
$mode = new LoginForm();
$mode->username = \Yii::$app->user->identity->username;
$user = new User();
if ($user = $mode->getUser()) {
$model->user_id = $user->id;
}
$listsocmed = $_POST['Task']['socmed'];
$model->facebook = 'No';
$model->twitter = 'No';
foreach ($listsocmed as $value) {
if ($value == 'Facebook') {
$model->facebook = 'Yes';
}
if ($value == 'Twitter') {
$model->twitter = 'Yes';
}
}
if ($model->save()) {
return $this->redirect(['view', 'id' => $model->task_id]);
} else {
return $this->render('create', ['model' => $model]);
}
} else {
return $this->render('create', ['model' => $model]);
}
} else {
throw new ForbiddenHttpException();
}
}
示例15: actionTaskEdit
public function actionTaskEdit()
{
if (isset($_GET['task_id'])) {
$task = Task::findOne($_GET['task_id']);
} else {
$task = new Task();
}
/**
* @var Task $task
*/
$post = \Yii::$app->request->post();
if ($task->load($post) && $task->validate()) {
$task = TaskManager::editTask($task, $post['Task']['time'], $post['Task']['command'], $post['Task']['status'], $post['Task']['comment']);
\Yii::$app->response->redirect('/?r=tasks/task-edit&task_id=' . $task->task_id);
}
return $this->render('task_edit', array('task' => $task, 'methods' => TaskLoader::getAllMethods(self::$tasks_controllers_folder, self::$tasks_namespace)));
}