zen.php 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. <?php
  2. /**
  3. * The control file of kanban module 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 Guangming Sun<sunguangming@easycorp.ltd>
  8. * @package kanban
  9. * @version $Id: control.php 4460 2021-10-26 11:03:02Z chencongzhi520@gmail.com $
  10. * @link https://www.zentao.net
  11. */
  12. class kanbanZen extends kanban
  13. {
  14. /**
  15. * 创建看板时,向视图文件发送变量。
  16. * Assign variables to the view file when creating a kanban.
  17. *
  18. * @param int $spaceID
  19. * @param string $type
  20. * @param int $copyKanbanID
  21. * @param string $extra
  22. * @access public
  23. * @return void
  24. */
  25. protected function assignCreateVars($spaceID, $type, $copyKanbanID, $extra)
  26. {
  27. $extra = str_replace(array(',', ' '), array('&', ''), $extra);
  28. parse_str($extra, $output);
  29. $enableImport = 'on';
  30. $importObjects = array_keys($this->lang->kanban->importObjectList);
  31. if($copyKanbanID)
  32. {
  33. $copyKanban = $this->kanban->getByID($copyKanbanID);
  34. $enableImport = empty($copyKanban->object) ? 'off' : 'on';
  35. $importObjects = empty($copyKanban->object) ? array() : explode(',', $copyKanban->object);
  36. $spaceID = $copyKanban->space;
  37. }
  38. unset($this->lang->kanban->featureBar['space']['involved']);
  39. $space = $this->kanban->getSpaceById($spaceID);
  40. $spaceUsers = $spaceID == 0 ? ',' : trim($space->owner) . ',' . trim($space->team);
  41. $spacePairs = $this->kanban->getSpacePairs($type);
  42. $users = $this->loadModel('user')->getPairs('noclosed|nodeleted');
  43. $ownerPairs = (isset($spacePairs[$spaceID])) ? $this->user->getPairs('noclosed|nodeleted', '', 0, $spaceUsers) : $users;
  44. $this->view->users = $users;
  45. $this->view->ownerPairs = $ownerPairs;
  46. $this->view->spaceID = $spaceID;
  47. $this->view->spacePairs = $spacePairs;
  48. $this->view->type = $type;
  49. $this->view->typeList = $this->lang->kanban->featureBar['space'];
  50. $this->view->kanbans = $this->kanban->getPairs();
  51. $this->view->copyKanbanID = $copyKanbanID;
  52. $this->view->copyKanban = $copyKanbanID ? $copyKanban : '';
  53. $this->view->enableImport = $enableImport;
  54. $this->view->importObjects = $importObjects;
  55. $this->view->copyRegion = isset($output['copyRegion']) ? 1 : 0;
  56. $this->view->spaceTeam = !empty($space->team) ? $space->team : '';
  57. $this->display();
  58. }
  59. /**
  60. * 设置用户头像。
  61. * Set user avatar data.
  62. *
  63. * @access public
  64. * @return void
  65. */
  66. public function setUserAvatar()
  67. {
  68. /* Get user list. */
  69. $userList = array();
  70. $users = $this->loadModel('user')->getPairs('noletter|nodeleted');
  71. $avatarPairs = $this->user->getAvatarPairs('all');
  72. foreach($avatarPairs as $account => $avatar)
  73. {
  74. if(!isset($users[$account])) continue;
  75. $userList[$account]['realname'] = $users[$account];
  76. $userList[$account]['avatar'] = $avatar;
  77. }
  78. $userList['closed']['account'] = 'Closed';
  79. $userList['closed']['realname'] = 'Closed';
  80. $userList['closed']['avatar'] = '';
  81. $this->view->userList = $userList;
  82. }
  83. /**
  84. * 模态框内移动看板。
  85. * Move card by modal.
  86. *
  87. * @param int $cardID
  88. * @access public
  89. * @return void
  90. */
  91. public function moveCardByModal($cardID)
  92. {
  93. $card = $this->kanban->getCardByID($cardID);
  94. if($_POST)
  95. {
  96. $this->lang->kanban->region = $this->lang->kanbanregion->name;
  97. $this->lang->kanban->lane = $this->lang->kanbanlane->name;
  98. $this->lang->kanban->column = $this->lang->kanbancolumn->common;
  99. $formData = form::data($this->config->kanban->form->moveCard)->get();
  100. if(dao::isError()) return $this->send(array('result' => 'fail', 'message' => dao::getError()));
  101. $cell = $this->kanban->getCellByCard($cardID, $card->kanban);
  102. $this->kanban->moveCard($cardID, $cell->column, $formData->column, $cell->lane, $formData->lane, $card->kanban);
  103. }
  104. else
  105. {
  106. $this->view->regions = $this->kanban->getRegionPairs($card->kanban);
  107. $this->view->card = $this->kanban->getCardByID($cardID);
  108. $this->display();
  109. }
  110. }
  111. }