zen.php 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. <?php
  2. /**
  3. * The zen file of company module of ZenTaoPMS.
  4. *
  5. * @copyright Copyright 2009-2023 禅道软件(青岛)有限公司(ZenTao Software (Qingdao) Co., Ltd. www.zentao.net)
  6. * @license ZPL(https://zpl.pub/page/zplv12.html) or AGPL(https://www.gnu.org/licenses/agpl-3.0.en.html)
  7. * @author Wang XuePeng <wangxuepeng@easycorp.ltd>
  8. * @package company
  9. * @link https://www.zentao.net
  10. */
  11. class companyZen extends company
  12. {
  13. /**
  14. * 将当前的URI保存到session中。
  15. * Save current uri into session.
  16. *
  17. * @access public
  18. * @return void
  19. */
  20. public function saveUriIntoSession()
  21. {
  22. $uri = $this->app->getURI(true);
  23. $this->session->set('productList', $uri, 'product');
  24. $this->session->set('productPlanList', $uri, 'product');
  25. $this->session->set('releaseList', $uri, 'product');
  26. $this->session->set('storyList', $uri, 'product');
  27. $this->session->set('projectList', $uri, 'project');
  28. $this->session->set('riskList', $uri, 'project');
  29. $this->session->set('opportunityList', $uri, 'project');
  30. $this->session->set('trainplanList', $uri, 'project');
  31. $this->session->set('taskList', $uri, 'execution');
  32. $this->session->set('buildList', $uri, 'execution');
  33. $this->session->set('bugList', $uri, 'qa');
  34. $this->session->set('caseList', $uri, 'qa');
  35. $this->session->set('testtaskList', $uri, 'qa');
  36. $this->session->set('effortList', $uri, 'my');
  37. $this->session->set('meetingList', $uri, 'my');
  38. $this->session->set('meetingList', $uri, 'project');
  39. $this->session->set('meetingroomList', $uri, 'admin');
  40. }
  41. /**
  42. * 加载所有的搜索模块。
  43. * Load all search module.
  44. *
  45. * @param int $userID
  46. * @param string|int $queryID
  47. * @access public
  48. * @return string
  49. */
  50. public function loadAllSearchModule($userID, $queryID)
  51. {
  52. return $this->buildDyanmicSearchForm($this->loadProduct(), $this->loadProject(), $this->loadExecution(), $userID, $queryID);
  53. }
  54. /**
  55. * 加载产品搜索模块。
  56. * Load product search module.
  57. *
  58. * @access public
  59. * @return array
  60. */
  61. public function loadProduct()
  62. {
  63. $products = $this->loadModel('product')->getPairs('nocode');
  64. $products = array($this->lang->company->product) + $products;
  65. $this->view->products = $products;
  66. return $products;
  67. }
  68. /**
  69. * 加载项目搜索模块。
  70. * Load project search module.
  71. *
  72. * @access public
  73. * @return array
  74. */
  75. public function loadProject()
  76. {
  77. $projects = $this->loadModel('project')->getPairsByProgram();
  78. $this->view->projects = array($this->lang->company->project) + $projects;;
  79. return $projects;
  80. }
  81. /**
  82. * 加载执行搜索模块。
  83. * Load execution search module.
  84. *
  85. * @access public
  86. * @return array
  87. */
  88. public function loadExecution()
  89. {
  90. $this->app->loadLang('execution');
  91. $executions = $this->loadModel('execution')->getPairs(0, 'all', 'nocode|multiple');
  92. $executionList = $this->execution->getByIdList(array_keys($executions));
  93. foreach($executionList as $execution)
  94. {
  95. if(isset($projects[$execution->project])) $executions[$execution->id] = $projects[$execution->project] . $executions[$execution->id];
  96. }
  97. $executions = array($this->lang->execution->common) + $executions;
  98. $this->view->executions = $executions;
  99. return $executions;
  100. }
  101. /**
  102. * 加载用户模块。
  103. * Load user module.
  104. *
  105. * @access public
  106. * @param int $userID
  107. * @return array
  108. */
  109. public function loadUserModule($userID)
  110. {
  111. $user = $userID ? $this->loadModel('user')->getById($userID, 'id') : '';
  112. $account = $user ? $user->account : 'all';
  113. $userIdPairs = $this->loadModel('user')->getPairs('noclosed|nodeleted|noletter|useid');
  114. $userIdPairs[''] = $this->lang->company->user;
  115. $this->view->userIdPairs = $userIdPairs;
  116. $accountPairs = $this->user->getPairs('nodeleted|noletter|all');
  117. $accountPairs[''] = '';
  118. $this->view->accountPairs = $accountPairs;
  119. return array($account, $accountPairs);
  120. }
  121. /**
  122. * 构建动态搜索表单。
  123. * Build dynamic search form.
  124. *
  125. * @param array $products
  126. * @param array $projects
  127. * @param array $executions
  128. * @param int $userID
  129. * @param int $queryID
  130. * @access public
  131. * @return string
  132. */
  133. public function buildDyanmicSearchForm($products, $projects, $executions, $userID, $queryID)
  134. {
  135. list($account, $accountPairs) = $this->loadUserModule($userID);
  136. $executions[0] = '';
  137. $products[0] = '';
  138. $projects[0] = '';
  139. ksort($executions);
  140. ksort($products);
  141. ksort($projects);
  142. $executions['all'] = $this->lang->execution->allExecutions;
  143. $products['all'] = $this->lang->product->allProduct;
  144. $projects['all'] = $this->lang->project->all;
  145. foreach(array_keys($this->lang->action->search->label) as $action)
  146. {
  147. if($action) $this->lang->action->search->label[$action] .= " [ $action ]";
  148. }
  149. $this->config->company->dynamic->search['actionURL'] = $this->createLink('company', 'dynamic', "browseType=bysearch&param=myQueryID");
  150. $this->config->company->dynamic->search['queryID'] = $queryID;
  151. $this->config->company->dynamic->search['params']['action']['values'] = $this->lang->action->search->label;
  152. if($this->config->vision == 'rnd') $this->config->company->dynamic->search['params']['product']['values'] = $products;
  153. $this->config->company->dynamic->search['params']['project']['values'] = $projects;
  154. $this->config->company->dynamic->search['params']['execution']['values'] = $executions;
  155. $this->config->company->dynamic->search['params']['actor']['values'] = $accountPairs;
  156. $this->loadModel('search')->setSearchParams($this->config->company->dynamic->search);
  157. return $account;
  158. }
  159. }