setting.html.php 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. <?php
  2. /**
  3. * The setting view file of message module of ZenTaoPMS.
  4. * @copyright Copyright 2009-2023 禅道软件(青岛)有限公司(ZenTao Software (Qingdao) Co., Ltd. www.zentao.net)
  5. * @license ZPL(https://zpl.pub/page/zplv12.html) or AGPL(https://www.gnu.org/licenses/agpl-3.0.en.html)
  6. * @author Mengyi Liu <liumengyi@easycorp.ltd>
  7. * @package message
  8. * @link https://www.zentao.net
  9. */
  10. namespace zin;
  11. /* First row. */
  12. $messageSetting = is_string($config->message->setting) ? json_decode($config->message->setting, true) : $config->message->setting;
  13. $headerThs = array(h::th());
  14. foreach($lang->message->typeList as $type => $typeName)
  15. {
  16. $headerThs[] = h::th
  17. (
  18. checkbox
  19. (
  20. on::click('toggleColumnChecked'),
  21. set::id("type-{$type}"),
  22. set::name("type-{$type}"),
  23. set::value(1),
  24. set::text($typeName)
  25. )
  26. );
  27. }
  28. $bodyTrs = array();
  29. foreach($config->message->objectTypes as $objectType => $actions)
  30. {
  31. if(!isset($objectTypes[$objectType])) continue;
  32. $bodyTr = array();
  33. $bodyTr[] = h::td
  34. (
  35. div
  36. (
  37. width('150px'),
  38. checkbox
  39. (
  40. on::click('toggleLaneChecked'),
  41. set::id("objectType-{$objectType}"),
  42. set::name("objectType-{$objectType}"),
  43. set::value(1),
  44. set::text($objectTypes[$objectType])
  45. )
  46. )
  47. );
  48. foreach($lang->message->typeList as $type => $typeName)
  49. {
  50. $cell = array();
  51. if(isset($config->message->available[$type][$objectType]))
  52. {
  53. $availableActions = array();
  54. foreach($config->message->available[$type][$objectType] as $action)
  55. {
  56. if(in_array($type, array('sms', 'webhook')) && $objectType == 'kanbancard' && $action == 'nearing') continue;
  57. if(!isset($objectActions[$objectType][$action])) continue;
  58. $availableActions[$action] = $objectActions[$objectType][$action];
  59. }
  60. $selected = isset($messageSetting[$type]['setting'][$objectType]) ? join(',', $messageSetting[$type]['setting'][$objectType]) : '';
  61. foreach($availableActions as $key => $value)
  62. {
  63. $cell[] = checkbox
  64. (
  65. set::rootClass('w-1/2'),
  66. set::id("messageSetting{$type}{$objectType}{$key}"),
  67. set::name("messageSetting[$type][setting][$objectType][]"),
  68. set::title($value),
  69. set::value($key),
  70. set::checked(strpos(",{$selected},", ",{$key},") !== false),
  71. set::text($value)
  72. );
  73. }
  74. if(isset($config->message->condition[$type][$objectType]))
  75. {
  76. $moduleName = $objectType == 'case' ? 'testcase' : $objectType;
  77. $this->app->loadLang($moduleName);
  78. foreach(explode(',', $config->message->condition[$type][$objectType]) as $condition)
  79. {
  80. $listKey = $condition . 'List';
  81. $list = isset($this->lang->{$moduleName}->{$listKey}) ? $this->lang->{$moduleName}->{$listKey} : $users;
  82. $cell[] = picker
  83. (
  84. set::name("messageSetting[{$type}][condition][{$objectType}][{$condition}][]"),
  85. set::items($list),
  86. set::value(isset($messageSetting[$type]['condition'][$objectType][$condition]) ? join(',', $messageSetting[$type]['condition'][$objectType][$condition]) : ''),
  87. set::multiple(true)
  88. );
  89. }
  90. }
  91. }
  92. $bodyTr[] = h::td
  93. (
  94. div
  95. (
  96. setClass('flex content-center items-center flex-wrap'),
  97. $cell
  98. )
  99. );
  100. }
  101. $bodyTrs[] = h::tr($bodyTr);
  102. }
  103. $bodyTrs[] = h::tr
  104. (
  105. h::td($lang->message->blockUser),
  106. h::td
  107. (
  108. picker
  109. (
  110. set::name('blockUser'),
  111. set::items($users),
  112. set::value(isset($config->message->blockUser) ? $config->message->blockUser: ''),
  113. set::menu(array('checkbox' => true)),
  114. set::multiple(true)
  115. )
  116. )
  117. );
  118. panel
  119. (
  120. form
  121. (
  122. h::table
  123. (
  124. setClass('table condensed bordered'),
  125. h::thead(h::tr($headerThs)),
  126. h::tbody($bodyTrs)
  127. )
  128. )
  129. );
  130. render();