releases.php 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <?php
  2. /**
  3. * The productplans 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 releasesEntry extends entry
  13. {
  14. /**
  15. * GET method.
  16. *
  17. * @param int $productID
  18. * @access public
  19. * @return string
  20. */
  21. public function get($productID = 0)
  22. {
  23. if(empty($productID)) $productID = $this->param('product');
  24. if(empty($productID)) return $this->sendError(400, 'Need product id.');
  25. $control = $this->loadController('release', 'browse');
  26. $control->browse($productID, $this->param('branch', 'all'), $this->param('status', 'all'), $this->param('order', 't1.date_desc'), '', 0, $this->param('limit', 20), $this->param('page', 1));
  27. /* Response */
  28. $data = $this->getData();
  29. if(isset($data->status) and $data->status == 'success')
  30. {
  31. $result = array();
  32. $releases = $data->data->releases;
  33. $pager = $data->data->pager;
  34. foreach($releases as $release) $result[] = $this->format($release, 'deleted:bool,date:date,mailto:userList');
  35. return $this->send(200, array('page' => $pager->pageID, 'total' => $pager->recTotal, 'limit' => $pager->recPerPage, 'releases' => $result));
  36. }
  37. if(isset($data->status) and $data->status == 'fail') return $this->sendError(zget($data, 'code', 400), $data->message);
  38. return $this->sendError(400, 'error');
  39. }
  40. }