doc.php 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. <?php
  2. /**
  3. * The doc 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 docEntry extends entry
  13. {
  14. /**
  15. * GET method.
  16. *
  17. * @param int $docID
  18. * @access public
  19. * @return string
  20. */
  21. public function get($docID)
  22. {
  23. $this->resetOpenApp($this->param('tab', 'doc'));
  24. $control = $this->loadController('doc', 'view');
  25. $doc = $this->loadModel('doc')->getByID($docID, 0, true);
  26. if(!$doc) return $this->send400('error');
  27. unset($doc->draft);
  28. if(!empty($doc->files)) $doc->files = array_values((array)$doc->files);
  29. $lib = null;
  30. if($doc->lib) $lib = $this->doc->getLibByID((int)$doc->lib);
  31. $doc->libName = $lib ? $lib->name : '';
  32. $doc->preAndNext = array();
  33. $doc->preAndNext['pre'] = '';
  34. $doc->preAndNext['next'] = '';
  35. return $this->send(200, $this->format($doc, 'addedBy:user,addedDate:time,assignedTo:user,assignedDate:date,editedBy:user,editedDate:time,mailto:userList'));
  36. }
  37. /**
  38. * PUT method.
  39. *
  40. * @param int $storyID
  41. * @access public
  42. * @return string
  43. */
  44. public function put($storyID)
  45. {
  46. $control = $this->loadController('story', 'edit');
  47. $oldStory = $this->loadModel('story')->getByID($storyID);
  48. /* Set $_POST variables. */
  49. $fields = 'type';
  50. $this->batchSetPost($fields, $oldStory);
  51. $this->setPost('parent', 0);
  52. $control->edit($storyID);
  53. $this->getData();
  54. $story = $this->story->getByID($storyID);
  55. return $this->sendSuccess(200, $this->format($story, 'openedDate:time,assignedDate:time,reviewedDate:time,lastEditedDate:time,closedDate:time,deleted:bool'));
  56. }
  57. /**
  58. * DELETE method.
  59. *
  60. * @param int $storyID
  61. * @access public
  62. * @return string
  63. */
  64. public function delete($storyID)
  65. {
  66. $control = $this->loadController('story', 'delete');
  67. $control->delete($storyID, 'yes');
  68. $this->getData();
  69. return $this->sendSuccess(200, 'success');
  70. }
  71. }