PageRenderTime 49ms CodeModel.GetById 18ms RepoModel.GetById 0ms app.codeStats 0ms

/concrete/single_pages/dashboard/users/groups.php

http://github.com/concrete5/concrete5
PHP | 281 lines | 260 code | 21 blank | 0 comment | 10 complexity | 306dc6568ef014a6bf01b11ba9dc55eb MD5 | raw file
Possible License(s): MIT, LGPL-2.1, MPL-2.0-no-copyleft-exception, BSD-3-Clause
  1. <?php
  2. defined('C5_EXECUTE') or die("Access Denied.");
  3. $valt = Loader::helper('validation/token');
  4. $ih = Loader::helper('concrete/ui');
  5. $form = Loader::helper('form');
  6. $date = Loader::helper('form/date_time');
  7. if (isset($group)) {
  8. ?>
  9. <form method="post" id="update-group-form" class="form-stacked" action="<?=$view->url('/dashboard/users/groups/', 'update_group')?>" role="form">
  10. <?=$valt->output('add_or_update_group')?>
  11. <?php
  12. $u = Core::make(Concrete\Core\User\User::class);
  13. $delConfirmJS = t('Are you sure you want to permanently remove this group?');
  14. if ($u->isSuperUser() == false) {
  15. ?>
  16. <?=t('You must be logged in as %s to remove groups.', USER_SUPER)?>
  17. <?php
  18. } else {
  19. ?>
  20. <script type="text/javascript">
  21. deleteGroup = function() {
  22. if (confirm('<?=$delConfirmJS?>')) {
  23. location.href = "<?=$view->url('/dashboard/users/groups', 'delete', $group->getGroupID(), $valt->generate('delete_group_' . $group->getGroupID()))?>";
  24. }
  25. }
  26. </script>
  27. <?php
  28. }
  29. ?>
  30. <fieldset>
  31. <legend><?=t('Group Details')?></legend>
  32. <div class="form-group">
  33. <label for="gName"><?=t('Name')?></label>
  34. <input type="text" name="gName" id="gName" class="form-control" value="<?=Loader::helper('text')->entities($group->getGroupName())?>" />
  35. </div>
  36. <div class="form-group">
  37. <label for="gDescription"><?=t('Description')?></label>
  38. <textarea name="gDescription" id="gDescription" rows="6" class="form-control"><?=Loader::helper("text")->entities($group->getGroupDescription())?></textarea>
  39. </div>
  40. </fieldset>
  41. <fieldset>
  42. <div class="form-group">
  43. <div class="checkbox">
  44. <label>
  45. <?=$form->checkbox('gIsBadge', 1, $group->isGroupBadge())?>
  46. <span><?=t('This group is a badge.')?> <i class="fa fa-question-circle launch-tooltip" title="<?=t('Badges are publicly viewable in user profiles, and display pictures and a custom description. Badges can be automatically assigned or given out by administrators.')?>"></i> </span>
  47. </label>
  48. </div>
  49. </div>
  50. <div id="gUserBadgeOptions" style="display: none">
  51. <div class="form-group">
  52. <label for="gBadgeFID"><?=t('Image')?></label>
  53. <?php
  54. $af = Loader::helper('concrete/asset_library');
  55. echo $af->image('gBadgeFID', 'gBadgeFID', t('Choose Badge Image'), $group->getGroupBadgeImageObject());
  56. ?>
  57. </div>
  58. <div class="form-group">
  59. <label for="gBadgeDescription"><?=t('Badge Description')?></label>
  60. <?=$form->textarea('gBadgeDescription', h($group->getGroupBadgeDescription()), array('rows' => 6, 'class' => 'form-control'))?>
  61. </div>
  62. <div class="form-group">
  63. <label for="gBadgeCommunityPointValue"><?=t('Community Points')?></label>
  64. <?=$form->text('gBadgeCommunityPointValue', h($group->getGroupBadgeCommunityPointValue()), array('class' => 'form-control'))?>
  65. </div>
  66. </div>
  67. </fieldset>
  68. <fieldset>
  69. <legend><?=t('Automation')?></legend>
  70. <div class="form-group">
  71. <div class="checkbox">
  72. <label>
  73. <?=$form->checkbox('gIsAutomated', 1, $group->isGroupAutomated())?>
  74. <span><?=t('This group is automatically entered.')?> <i class="fa fa-question-circle launch-tooltip" title="<?=t("Automated Groups aren't assigned by administrators. They are checked against code at certain times that determines whether users should enter them.")?>"></i> </span>
  75. </label>
  76. </div>
  77. </div>
  78. <div id="gAutomationOptions" style="display: none">
  79. <div class="form-group">
  80. <label><?=t('Check Group')?></label>
  81. <div class="checkbox">
  82. <label>
  83. <?=$form->checkbox('gCheckAutomationOnRegister', 1, $group->checkGroupAutomationOnRegister())?>
  84. <span><?=t('When a user registers.')?></span>
  85. </label>
  86. </div>
  87. <div class="checkbox">
  88. <label>
  89. <?=$form->checkbox('gCheckAutomationOnLogin', 1, $group->checkGroupAutomationOnLogin())?>
  90. <span><?=t('When a user signs in.')?></span>
  91. </label>
  92. </div>
  93. <div class="checkbox">
  94. <label>
  95. <?=$form->checkbox('gCheckAutomationOnJobRun', 1, $group->checkGroupAutomationOnJobRun())?>
  96. <span><?=t('When the "Check Automated Groups" Job runs.')?></span>
  97. </label>
  98. </div>
  99. </div>
  100. <div class="alert alert-info">
  101. <?php
  102. $path = h($group->getGroupAutomationControllerClass());
  103. echo t('For custom automated group actions, make sure an automation group controller exists at %s', $path);
  104. ?>
  105. </div>
  106. </div>
  107. <div class="form-group">
  108. <div class="checkbox">
  109. <label>
  110. <?=$form->checkbox('gUserExpirationIsEnabled', 1, $group->isGroupExpirationEnabled())?>
  111. <span><?=t('Automatically remove users from this group')?></span></label></div>
  112. </div>
  113. <div class="form-group">
  114. <?=$form->select("gUserExpirationMethod", array(
  115. 'SET_TIME' => t('at a specific date and time'),
  116. 'INTERVAL' => t('once a certain amount of time has passed'),
  117. ), $group->getGroupExpirationMethod(), array('disabled' => true, 'class' => 'form-control'));
  118. ?>
  119. </div>
  120. <div id="gUserExpirationSetTimeOptions" style="display: none">
  121. <div class="form-group">
  122. <label for="gUserExpirationSetDateTime"><?=t('Expiration Date')?></label>
  123. <?=$date->datetime('gUserExpirationSetDateTime', $group->getGroupExpirationDateTime())?>
  124. </div>
  125. </div>
  126. <div id="gUserExpirationIntervalOptions" style="display: none">
  127. <div class="form-group">
  128. <label for=""><?=t('Accounts expire after')?></label>
  129. <div>
  130. <table class="table" style="width: auto">
  131. <tr>
  132. <th><?=t('Days')?></th>
  133. <th><?=t('Hours')?></th>
  134. <th><?=t('Minutes')?></th>
  135. </tr>
  136. <tr>
  137. <?php
  138. $days = $group->getGroupExpirationIntervalDays();
  139. $hours = $group->getGroupExpirationIntervalHours();
  140. $minutes = $group->getGroupExpirationIntervalMinutes();
  141. $style = 'width: 60px';
  142. ?>
  143. <td valign="top">
  144. <?=$form->text('gUserExpirationIntervalDays', $days, array('style' => $style))?>
  145. </td>
  146. <td valign="top">
  147. <?=$form->text('gUserExpirationIntervalHours', $hours, array('style' => $style))?>
  148. </td>
  149. <td valign="top">
  150. <?=$form->text('gUserExpirationIntervalMinutes', $minutes, array('style' => $style))?>
  151. </td>
  152. </tr>
  153. </table>
  154. </div>
  155. </div>
  156. </div>
  157. <div id="gUserExpirationAction" style="display: none">
  158. <div class="form-group">
  159. <label for="gUserExpirationAction"><?=t('Expiration Action')?></label>
  160. <?=$form->select("gUserExpirationAction", array(
  161. 'REMOVE' => t('Remove the user from this group'),
  162. 'DEACTIVATE' => t('Deactivate the user account'),
  163. 'REMOVE_DEACTIVATE' => t('Remove the user from the group and deactivate the account'),
  164. ), $group->getGroupExpirationAction(),
  165. array('class' => 'form-control'));
  166. ?>
  167. </div>
  168. </div>
  169. <input type="hidden" name="gID" value="<?=$group->getGroupID()?>" />
  170. </fieldset>
  171. <div class="ccm-dashboard-form-actions-wrapper">
  172. <div class="ccm-dashboard-form-actions">
  173. <a href="<?=$view->url('/dashboard/users/groups')?>" class="btn btn-default pull-left"><?=t('Cancel')?></a>
  174. <button class="btn pull-right btn-primary" style="margin-left: 10px" type="submit"><?=t('Update Group')?></button>
  175. <?php if ($u->isSuperUser()) {
  176. ?>
  177. <?php echo $ih->button_js(t('Delete'), "deleteGroup()", 'right', 'btn-danger');
  178. ?>
  179. <?php
  180. }
  181. ?>
  182. </div>
  183. </div>
  184. </form>
  185. <script type="text/javascript">
  186. ccm_checkGroupExpirationOptions = function() {
  187. var sel = $("select[name=gUserExpirationMethod]");
  188. var cb = $("input[name=gUserExpirationIsEnabled]");
  189. if (cb.prop('checked')) {
  190. sel.attr('disabled', false);
  191. switch(sel.val()) {
  192. case 'SET_TIME':
  193. $("#gUserExpirationSetTimeOptions").show();
  194. $("#gUserExpirationIntervalOptions").hide();
  195. break;
  196. case 'INTERVAL':
  197. $("#gUserExpirationSetTimeOptions").hide();
  198. $("#gUserExpirationIntervalOptions").show();
  199. break;
  200. }
  201. $("#gUserExpirationAction").show();
  202. } else {
  203. sel.attr('disabled', true);
  204. $("#gUserExpirationSetTimeOptions").hide();
  205. $("#gUserExpirationIntervalOptions").hide();
  206. $("#gUserExpirationAction").hide();
  207. }
  208. }
  209. $(function() {
  210. $("input[name=gUserExpirationIsEnabled]").click(ccm_checkGroupExpirationOptions);
  211. $("select[name=gUserExpirationMethod]").change(ccm_checkGroupExpirationOptions);
  212. ccm_checkGroupExpirationOptions();
  213. $('input[name=gIsBadge]').on('click', function() {
  214. if ($(this).is(':checked')) {
  215. $('#gUserBadgeOptions').show();
  216. } else {
  217. $('#gUserBadgeOptions').hide();
  218. }
  219. }).triggerHandler('click');
  220. $('input[name=gIsAutomated]').on('click', function() {
  221. if ($(this).is(':checked')) {
  222. $('#gAutomationOptions').show();
  223. } else {
  224. $('#gAutomationOptions').hide();
  225. }
  226. }).triggerHandler('click');
  227. });
  228. </script>
  229. <?php
  230. } else {
  231. ?>
  232. <?php if ($canAddGroup) {
  233. ?>
  234. <div class="ccm-dashboard-header-buttons">
  235. <a href="<?php echo View::url('/dashboard/users/add_group')?>" class="btn btn-primary"><?php echo t("Add Group")?></a>
  236. </div>
  237. <?php
  238. }
  239. ?>
  240. <?php Loader::element('group/search', array('controller' => $searchController, 'selectMode' => false))?>
  241. <?php
  242. } ?>