taskcomponent.php 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <?php
  2. /**
  3. * The task component entry point of ZenTaoPMS.
  4. *
  5. * @copyright Copyright 2009-2023 禅道软件(青岛)有限公司(ZenTao Software (Qingdao) Co., Ltd. www.cnezsoft.com)
  6. * @license ZPL(http://zpl.pub/page/zplv12.html) or AGPL(https://www.gnu.org/licenses/agpl-3.0.en.html)
  7. * @author Chunsheng Wang <chunsheng@cnezsoft.com>
  8. * @package entries
  9. * @version 1
  10. * @link https://www.zentao.net
  11. */
  12. class taskComponentEntry extends entry
  13. {
  14. /**
  15. * POST method.
  16. *
  17. * @param int $taskID
  18. * @access public
  19. * @return string
  20. */
  21. public function post($taskID)
  22. {
  23. $control = $this->loadController('task', 'batchCreate');
  24. $fields = 'name,color,type,assignedTo,parent,estimate,story,module,pri,desc,estStarted,deadline';
  25. $this->batchSetPost($fields);
  26. $fields = explode(',', $fields);
  27. foreach($fields as $field) $this->setArrayPost($field);
  28. $task = $this->loadModel('task')->getById($taskID);
  29. $control->batchCreate($task->execution, 0, 0, $taskID);
  30. $data = $this->getData();
  31. if(!$data) return $this->send400('error');
  32. if(isset($data->status) and $data->status == 'fail') return $this->sendError(zget($data, 'code', 400), $data->message);
  33. $task = $this->task->getById($data->idList[0]);
  34. return $this->send(200, $this->format($task, 'deadline:date,openedBy:user,openedDate:time,assignedTo:user,assignedDate:time,realStarted:time,finishedBy:user,finishedDate:time,closedBy:user,closedDate:time,canceledBy:user,canceledDate:time,lastEditedBy:user,lastEditedDate:time,deleted:bool,mailto:userList'));
  35. }
  36. public function setArrayPost($field)
  37. {
  38. $_POST[$field] = array('0' => $_POST[$field]);
  39. }
  40. }