productplanlinkstories.php 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <?php
  2. /**
  3. * The productplanlinkstories 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 productplanLinkStoriesEntry extends entry
  13. {
  14. /**
  15. * POST method.
  16. *
  17. * @param int $planID
  18. * @access public
  19. * @return string
  20. */
  21. public function post($planID)
  22. {
  23. $control = $this->loadController('productplan', 'linkStory');
  24. $fields = 'stories';
  25. $this->batchSetPost($fields);
  26. $control->linkStory($planID);
  27. $data = $this->getData();
  28. if(isset($data->result) and $data->result == 'success')
  29. {
  30. $control = $this->loadController('productplan', 'view');
  31. $control->view($planID);
  32. $data = $this->getData();
  33. if(!$data or !isset($data->status)) return $this->send400('error');
  34. if(isset($data->status) and $data->status == 'fail') return $this->sendError(zget($data, 'code', 400), $data->message);
  35. $plan = $data->data->plan;
  36. $plan->stories = $data->data->planStories;
  37. $plan->bugs = $data->data->planBugs;
  38. $plan = $this->format($plan, 'begin:date,end:date,deleted:bool,stories:array,bugs:array');
  39. return $this->send(200, $plan);
  40. }
  41. $this->sendError(400, array('message' => isset($data->message) ? $data->message : 'error'));
  42. }
  43. }