zen.php 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. <?php
  2. /**
  3. * The zen file of space 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 Yanyi Cao <caoyanyi@easycorp.ltd>
  8. * @package space
  9. * @link https://www.zentao.net
  10. */
  11. class spaceZen extends space
  12. {
  13. /**
  14. * 获取空间下的应用实例。
  15. * Get space instances.
  16. *
  17. * @param string $browseType
  18. * @access protected
  19. * @return array
  20. */
  21. protected function getSpaceInstances($browseType = 'all')
  22. {
  23. $instances = array();
  24. if(!$this->config->inCompose)
  25. {
  26. $instances = $this->space->getSpaceInstances(0, $browseType);
  27. foreach($instances as $instance)
  28. {
  29. $instance->externalID = 0;
  30. $instance->orgID = $instance->id;
  31. $instance->type = 'store';
  32. if(in_array($instance->appName, $this->config->space->zentaoApps))
  33. {
  34. $externalApp = $this->space->getExternalAppByApp($instance);
  35. if($externalApp) $instance->externalID = $externalApp->id;
  36. }
  37. }
  38. }
  39. $maxID = 0;
  40. $pipelines = array();
  41. if($browseType == 'all' || $browseType == 'running') $pipelines = $this->loadModel('pipeline')->getList('', 'id_desc');
  42. if(!empty($instances)) $maxID = max(array_keys($instances));
  43. foreach($pipelines as $key => $pipeline)
  44. {
  45. $maxID ++;
  46. if($pipeline->createdBy == 'system' && !$this->config->inCompose) unset($pipelines[$key]);
  47. $pipeline->createdAt = $pipeline->createdDate;
  48. $pipeline->appName = zget($this->lang->space->appType, $pipeline->type);
  49. $pipeline->status = 'running';
  50. $pipeline->type = 'external';
  51. $pipeline->externalID = $pipeline->id;
  52. $pipeline->orgID = $pipeline->id;
  53. $pipeline->id = $maxID;
  54. }
  55. return array_merge($instances, $pipelines);
  56. }
  57. }