当前位置: 首页>>代码示例>>PHP>>正文


PHP Tasks::save方法代码示例

本文整理汇总了PHP中Tasks::save方法的典型用法代码示例。如果您正苦于以下问题:PHP Tasks::save方法的具体用法?PHP Tasks::save怎么用?PHP Tasks::save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Tasks的用法示例。


在下文中一共展示了Tasks::save方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: create

 public function create($action, $uid, $taskdata, $pre_task = 0)
 {
     if (!isset(\Tasks::$types[$action])) {
         return $this->err('任务类型错误');
     }
     if (in_array($action, array('checkout', 'update', 'delete'))) {
         if (!isset($taskdata['project_id'])) {
             return $this->err('需要project_id');
         }
     }
     if (in_array($action, array('rsync'))) {
         if (!isset($taskdata['server_id'])) {
             return $this->err('需要server_id');
         }
     }
     $record = new \Tasks();
     $record->type = $action;
     $record->command = json_encode($taskdata);
     $record->pre_task = $pre_task;
     $record->status = 'created';
     $record->create_time = date('Y-m-d H:i:s');
     $record->execute_time = '0000-00-00 00:00:00';
     $record->output = '';
     $record->uid = $uid;
     $record->save();
     return $record->id;
 }
开发者ID:xiaomantou88,项目名称:svn_publisher,代码行数:27,代码来源:TaskHelper.php

示例2: post_add_new

 public function post_add_new()
 {
     $data = Input::all();
     $UserValidation = Validator::make(Input::all(), array('new' => 'required|max:100'));
     if (!$UserValidation->fails()) {
         $user_id = Auth::id();
         $task = new Tasks();
         $task->task_name = $data['new'];
         $task->user_id = $user_id;
         $task->created_at = new DateTime();
         $task->save();
         $tasks = Auth::user()->tasks;
         $response = $tasks;
         return $response;
     }
 }
开发者ID:krumpak,项目名称:todo-list,代码行数:16,代码来源:TasksController.php

示例3: actionCreate_task

 public function actionCreate_task($track = null)
 {
     if (!Yii::app()->my->access("edit")) {
         return false;
     }
     $task = new Tasks();
     $task->track = $track;
     // если значения переданы –выводим их
     if (isset($_REQUEST['Tasks'])) {
         foreach ($_REQUEST['Tasks'] as $key => $value) {
             $task->{$key} = $value;
         }
         if ($task->save()) {
             Yii::app()->notify->add("Новое задание успешно создано", "success");
             $this->redirect(array('/task/' . $task->id . '/edit'));
         } else {
             Yii::app()->notify->addErrors($task->getErrors());
             Yii::app()->notify->add("Не удалось создать задание", "danger");
         }
     }
     $this->render("task", array("task" => $task));
 }
开发者ID:Kapodastr,项目名称:grow,代码行数:22,代码来源:EditorController.php

示例4: actionCreate

 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     if (Yii::app()->user->checkAccess('createTasks')) {
         $model = new Tasks();
         $Milestones = Milestones::model()->with('Projects.Company.Cusers')->together()->findAll(array('condition' => 'Cusers.user_id = :user_id AND t.project_id = :project_id AND Projects.project_endDate > CURDATE()', 'params' => array(':user_id' => Yii::app()->user->id, ':project_id' => Yii::app()->user->getState('project_selected'))));
         $Cases = Cases::model()->with('Projects.Company.Cusers')->together()->findAll(array('condition' => 'Cusers.user_id = :user_id AND t.project_id = :project_id', 'params' => array(':user_id' => Yii::app()->user->id, ':project_id' => Yii::app()->user->getState('project_selected'))));
         if (isset($_POST['Tasks'])) {
             $model->attributes = $_POST['Tasks'];
             $model->user_id = Yii::app()->user->id;
             $model->status_id = Status::STATUS_PENDING;
             $model->project_id = Yii::app()->user->getState('project_selected');
             $model->task_startDate = date("Y-m-d");
             //new CDbExpression('NOW()');
             if ($model->save()) {
                 // Guardar log
                 $attributes = array('log_date' => date("Y-m-d G:i:s"), 'log_activity' => 'TaskCreated', 'log_resourceid' => $model->primaryKey, 'log_type' => 'created', 'user_id' => Yii::app()->user->id, 'module_id' => Yii::app()->controller->id, 'project_id' => $model->project_id);
                 Logs::model()->saveLog($attributes);
                 // avisar a los participantes del proyecto que una nueva tarea se ha agregado
                 $Users = Projects::model()->findAllUsersByProject($model->project_id);
                 $recipientsList = array();
                 foreach ($Users as $user) {
                     $recipientsList[] = array('name' => $user->CompleteName, 'email' => $user->user_email);
                 }
                 $subject = Yii::t('email', 'TaskStatusChanged') . " - " . $model->task_name;
                 $str = $this->renderPartial('//templates/tasks/statusChanged', array('task' => $model, 'username' => Yii::app()->user->CompleteName, 'task_url' => "http://" . $_SERVER['SERVER_NAME'] . Yii::app()->createUrl('tasks/view', array('id' => $model->task_id)), 'applicationName' => Yii::app()->name, 'applicationUrl' => "http://" . $_SERVER['SERVER_NAME'] . Yii::app()->request->baseUrl), true);
                 Yii::import('application.extensions.phpMailer.yiiPhpMailer');
                 $mailer = new yiiPhpMailer();
                 $mailer->pushMail($subject, $str, $recipientsList, Emails::PRIORITY_NORMAL);
                 $this->redirect(array('view', 'id' => $model->task_id));
             }
         }
         $this->render('create', array('model' => $model, 'status' => Status::model()->findAll(), 'types' => TaskTypes::model()->findAll(), 'stages' => TaskStages::model()->findAll(), 'milestones' => $Milestones, 'cases' => $Cases, 'allowEdit' => true));
     } else {
         throw new CHttpException(403, Yii::t('site', '403_Error'));
     }
 }
开发者ID:lanzelotik,项目名称:celestic-community,代码行数:40,代码来源:TasksController.php

示例5: executeXlsTasksImport

 public function executeXlsTasksImport(sfWebRequest $request)
 {
     app::setPageTitle('Import Spreadsheet', $this->getResponse());
     if ($request->isMethod(sfRequest::PUT)) {
         if ($request->hasParameter('import_file')) {
             if (is_file($import_spreadsheet_file = sfConfig::get('sf_upload_dir') . '/' . $request->getParameter('import_file'))) {
                 $import_fields = $this->getUser()->getAttribute('import_fields');
                 $data = new Spreadsheet_Excel_Reader($import_spreadsheet_file);
                 $projects_id = $request->getParameter('projects_id');
                 if ($request->getParameter('import_first_row') == 1) {
                     $first_row = 1;
                 } elseif ($data->rowcount() > 2) {
                     $first_row = 2;
                 } else {
                     $first_row = 1;
                 }
                 for ($i = $first_row; $i <= $data->rowcount(); $i++) {
                     $t = new Tasks();
                     $t->setCreatedBy($this->getUser()->getAttribute('id'))->setCreatedAt(date('Y-m-d H:i:s'))->setProjectsId($request->getParameter('projects_id'));
                     $extra_fields = array();
                     for ($j = 1; $j <= $data->colcount(); $j++) {
                         if (isset($import_fields[$j])) {
                             $v = $data->val($i, $j);
                             if (strlen(trim($v)) == 0) {
                                 continue;
                             }
                             switch ($import_fields[$j]) {
                                 case 'TasksGroups':
                                     if ($id = app::getProjectCfgItemIdByName($v, 'TasksGroups', $projects_id)) {
                                         $t->setTasksGroupsId($id);
                                     } else {
                                         $cfg = new TasksGroups();
                                         $cfg->setName($v);
                                         $cfg->setProjectsId($projects_id);
                                         $cfg->save();
                                         $t->setTasksGroupsId($cfg->getId());
                                     }
                                     break;
                                 case 'Versions':
                                     if ($id = app::getProjectCfgItemIdByName($v, 'Versions', $projects_id)) {
                                         $t->setVersionsId($id);
                                     } else {
                                         $cfg = new Versions();
                                         $cfg->setName($v);
                                         $cfg->setProjectsId($projects_id);
                                         $cfg->save();
                                         $t->setVersionsId($cfg->getId());
                                     }
                                     break;
                                 case 'ProjectsPhases':
                                     if ($id = app::getProjectCfgItemIdByName($v, 'ProjectsPhases', $projects_id)) {
                                         $t->setProjectsPhasesId($id);
                                     } else {
                                         $cfg = new ProjectsPhases();
                                         $cfg->setName($v);
                                         $cfg->setProjectsId($projects_id);
                                         $cfg->save();
                                         $t->setProjectsPhasesId($cfg->getId());
                                     }
                                     break;
                                 case 'TasksPriority':
                                     if ($id = app::getCfgItemIdByName($v, 'TasksPriority')) {
                                         $t->setTasksPriorityId($id);
                                     } else {
                                         $cfg = new TasksPriority();
                                         $cfg->setName($v);
                                         $cfg->save();
                                         $t->setTasksPriorityId($cfg->getId());
                                     }
                                     break;
                                 case 'TasksLabels':
                                     if ($id = app::getCfgItemIdByName($v, 'TasksLabels')) {
                                         $t->setTasksLabelId($id);
                                     } else {
                                         $cfg = new TasksLabels();
                                         $cfg->setName($v);
                                         $cfg->save();
                                         $t->setTasksLabelId($cfg->getId());
                                     }
                                     break;
                                 case 'name':
                                     $t->setName($v);
                                     break;
                                 case 'TasksStatus':
                                     if ($id = app::getCfgItemIdByName($v, 'TasksStatus')) {
                                         $t->setTasksStatusId($id);
                                     } else {
                                         $cfg = new TasksStatus();
                                         $cfg->setName($v);
                                         $cfg->save();
                                         $t->setTasksStatusId($cfg->getId());
                                     }
                                     break;
                                 case 'TasksTypes':
                                     if ($id = app::getCfgItemIdByName($v, 'TasksTypes')) {
                                         $t->setTasksTypeId($id);
                                     } else {
                                         $cfg = new TasksTypes();
                                         $cfg->setName($v);
                                         $cfg->save();
//.........这里部分代码省略.........
开发者ID:noikiy,项目名称:qdpm,代码行数:101,代码来源:actions.class.php


注:本文中的Tasks::save方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。