design.html.php 3.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. <?php
  2. /**
  3. * The design view file of workflowgroup module of ZenTaoPMS.
  4. *
  5. * @copyright Copyright 2009-2015 青岛易软天创网络科技有限公司(QingDao Nature Easy Soft Network Technology Co,LTD, www.cnezsoft.com)
  6. * @license ZPL (http://zpl.pub/page/zplv12.html)
  7. * @author Yidong Wang <yidong@chandao.com>
  8. * @package workflowgroup
  9. * @version $Id$
  10. * @link http://www.zentao.net
  11. */
  12. namespace zin;
  13. featurebar
  14. (
  15. backbtn(set::back("workflowgroup-{$group->type}"), $lang->goback),
  16. li(setClass('nav-item font-bold ml-2'), $group->name)
  17. );
  18. $cols = $config->workflowgroup->dtable->design->fieldList;
  19. $cols['buildin']['map'] = $lang->workflow->buildinList;
  20. $cols['app']['map'] = $apps;
  21. if(common::checkNotCN()) $cols['actions']['width'] = '160px';
  22. if($group->main == '1') $cols['actions']['width'] = '60px';
  23. foreach($cols['actions']['list'] as $actionKey => $action) $cols['actions']['list'][$actionKey]['url']['params'] = sprintf($action['url']['params'], $group->id);
  24. $data = initTableData($flows, $cols, $this->workflowgroup);
  25. $hasPriv = array();
  26. $checkPriv = function($actionKey, $flow) use ($group, $cols, &$hasPriv)
  27. {
  28. $action = $cols['actions']['list'][$actionKey];
  29. $module = $action['url']['module'];
  30. $method = $action['url']['method'];
  31. if(!isset($hasPriv[$module][$method])) $hasPriv[$module][$method] = hasPriv($module, $method);
  32. $enabled = $hasPriv[$module][$method];
  33. if(!$enabled) return false;
  34. if(($actionKey == 'setExclusive' || $actionKey == 'designFlow') && $group->main == '1') return false;
  35. if($actionKey == 'setExclusive') $enabled = empty($flow->group);
  36. if($actionKey == 'activateFlow') $enabled = empty($flow->buildin) && strpos(",{$group->disabledModules},", ",{$flow->module},") !== false && $flow->defaultStatus != 'pause';
  37. if($actionKey == 'deactivateFlow') $enabled = empty($flow->buildin) && strpos(",{$group->disabledModules},", ",{$flow->module},") === false;
  38. if($actionKey == 'designFlow')
  39. {
  40. $enabled = $group->id == $flow->group;
  41. $designUrl = array('url' => createLink('workflowgroup', 'designFlow', "groupID={$group->id}&flowModule={$flow->module}&flowBuildin={$flow->buildin}"));
  42. }
  43. return array_merge(array('name' => $actionKey, 'disabled' => !$enabled), $designUrl ?? array());
  44. };
  45. foreach($data as $flow)
  46. {
  47. $flow->exclusive = zget($lang->workflowgroup->workflow->exclusiveList, empty($flow->group) ? 0 : 1, '');
  48. $flow->status = (empty($flow->buildin) && strpos(",{$group->disabledModules},", ",{$flow->module},") !== false) ? 'pause' : 'normal';
  49. $flow->actions = array();
  50. foreach($cols['actions']['menu'] as $actionKey)
  51. {
  52. if(strpos($actionKey, '|') !== false)
  53. {
  54. $hasEnabled = false;
  55. foreach(explode('|', $actionKey) as $actionKey)
  56. {
  57. if($hasEnabled) break;
  58. $action = $checkPriv($actionKey, $flow);
  59. if(is_array($action) && !$action['disabled'])
  60. {
  61. $flow->actions[] = $action;
  62. $hasEnabled = true;
  63. }
  64. }
  65. if(!$hasEnabled) $flow->actions[] = $action;
  66. }
  67. else
  68. {
  69. $flow->actions[] = $checkPriv($actionKey, $flow);
  70. }
  71. }
  72. $flow->actions = array_values(array_filter($flow->actions));
  73. }
  74. dtable
  75. (
  76. set::cols($cols),
  77. set::data($data),
  78. set::orderBy($orderBy),
  79. set::sortLink(createLink('workflowgroup', 'design', "groupID={$group->id}&orderBy={name}_{sortType}")),
  80. set::footPager(usePager())
  81. );