PageRenderTime 27ms CodeModel.GetById 20ms RepoModel.GetById 0ms app.codeStats 0ms

/concreteOLD/single_pages/dashboard/users/groups.php

https://bitbucket.org/selfeky/xclusivescardwebsite
PHP | 286 lines | 228 code | 38 blank | 20 comment | 22 complexity | f01756b36dcdb81bda14338a090f41a3 MD5 | raw file
  1. <?php
  2. defined('C5_EXECUTE') or die("Access Denied.");
  3. $section = 'groups';
  4. function checkExpirationOptions($g) {
  5. if ($_POST['gUserExpirationIsEnabled']) {
  6. $date = Loader::helper('form/date_time');
  7. switch($_POST['gUserExpirationMethod']) {
  8. case 'SET_TIME':
  9. $g->setGroupExpirationByDateTime($date->translate('gUserExpirationSetDateTime'), $_POST['gUserExpirationAction']);
  10. break;
  11. case 'INTERVAL':
  12. $g->setGroupExpirationByInterval($_POST['gUserExpirationIntervalDays'], $_POST['gUserExpirationIntervalHours'], $_POST['gUserExpirationIntervalMinutes'], $_POST['gUserExpirationAction']);
  13. break;
  14. }
  15. } else {
  16. $g->removeGroupExpiration();
  17. }
  18. }
  19. if ($_REQUEST['task'] == 'edit') {
  20. $g = Group::getByID(intval($_REQUEST['gID']));
  21. if (is_object($g)) {
  22. if ($_POST['update']) {
  23. $gName = $_POST['gName'];
  24. $gDescription = $_POST['gDescription'];
  25. } else {
  26. $gName = $g->getGroupName();
  27. $gDescription = $g->getGroupDescription();
  28. }
  29. $editMode = true;
  30. }
  31. }
  32. $txt = Loader::helper('text');
  33. $ih = Loader::helper('concrete/interface');
  34. $valt = Loader::helper('validation/token');
  35. if (!$editMode) {
  36. Loader::model('search/group');
  37. $gl = new GroupSearch();
  38. if (isset($_GET['gKeywords'])) {
  39. $gl->filterByKeywords($_GET['gKeywords']);
  40. }
  41. $gResults = $gl->getPage();
  42. ?>
  43. <?php echo Loader::helper('concrete/dashboard')->getDashboardPaneHeaderWrapper(t('Groups'), false, 'span12 offset2', false)?>
  44. <?php
  45. $tp = new TaskPermission();
  46. if ($tp->canAccessGroupSearch()) { ?>
  47. <div class="ccm-pane-options">
  48. <div class="ccm-pane-options-permanent-search">
  49. <form method="get" action="<?php echo $this->url('/dashboard/users/groups')?>">
  50. <div class="span7">
  51. <?php $form = Loader::helper('form'); ?>
  52. <?php echo $form->label('gKeywords', t('Keywords'))?>
  53. <div class="input">
  54. <input type="text" name="gKeywords" value="<?php echo htmlentities($_REQUEST['gKeywords'])?>" />
  55. <input class="btn" type="submit" value="<?php echo t('Search')?>" />
  56. </div>
  57. <input type="hidden" name="group_submit_search" value="1" />
  58. </div>
  59. </form>
  60. </div>
  61. </div>
  62. <div class="ccm-pane-body <?php if (!$gl->requiresPaging()) { ?> ccm-pane-body-footer <?php } ?>">
  63. <?php if (count($gResults) > 0) {
  64. $gl->displaySummary();
  65. foreach ($gResults as $g) { ?>
  66. <div class="ccm-group">
  67. <a class="ccm-group-inner" href="<?php echo $this->url('/dashboard/users/groups?task=edit&gID=' . $g['gID'])?>" style="background-image: url(<?php echo ASSETS_URL_IMAGES?>/icons/group.png)"><?php echo t($g['gName'])?></a>
  68. <?php if ($g['gDescription']) { ?>
  69. <div class="ccm-group-description"><?php echo $g['gDescription']?></div>
  70. <?php } ?>
  71. </div>
  72. <?php }
  73. } else { ?>
  74. <p><?php echo t('No groups found.')?></p>
  75. <?php } ?>
  76. </div>
  77. <?php if ($gl->requiresPaging()) { ?>
  78. <div class="ccm-pane-footer">
  79. <?php echo $gl->displayPagingV2();?>
  80. </div>
  81. <?php } ?>
  82. <?php } else { ?>
  83. <div class="ccm-pane-body ccm-pane-body-footer">
  84. <p><?php echo t('You do not have access to group search. This setting may be changed in the access section of the dashboard settings page.')?></p>
  85. </div>
  86. <?php } ?>
  87. <?php echo Loader::helper('concrete/dashboard')->getDashboardPaneFooterWrapper(false);?>
  88. <?php } else { ?>
  89. <?php echo Loader::helper('concrete/dashboard')->getDashboardPaneHeaderWrapper(t('Edit Group'), false, false, false)?>
  90. <form method="post" id="update-group-form" action="<?php echo $this->url('/dashboard/users/groups/', 'update_group')?>">
  91. <?php echo $valt->output('add_or_update_group')?>
  92. <div class="ccm-pane-body">
  93. <?php
  94. $form = Loader::helper('form');
  95. $date = Loader::helper('form/date_time');
  96. $u=new User();
  97. $delConfirmJS = t('Are you sure you want to permanently remove this group?');
  98. if($u->isSuperUser() == false){ ?>
  99. <?php echo t('You must be logged in as %s to remove groups.', USER_SUPER)?>
  100. <?php }else{ ?>
  101. <script type="text/javascript">
  102. deleteGroup = function() {
  103. if (confirm('<?php echo $delConfirmJS?>')) {
  104. location.href = "<?php echo $this->url('/dashboard/users/groups', 'delete', intval($_REQUEST['gID']), $valt->generate('delete_group_' . intval($_REQUEST['gID']) ))?>";
  105. }
  106. }
  107. </script>
  108. <?php } ?>
  109. <fieldset>
  110. <div class="clearfix">
  111. <?php echo $form->label('gName', t('Name'))?>
  112. <div class="input">
  113. <input type="text" name="gName" class="span6" value="<?php echo Loader::helper('text')->entities(t($gName))?>" />
  114. </div>
  115. </div>
  116. <div class="clearfix">
  117. <?php echo $form->label('gDescription', t('Description'))?>
  118. <div class="input">
  119. <textarea name="gDescription" rows="6" class="span6"><?php echo Loader::helper("text")->entities($gDescription)?></textarea>
  120. </div>
  121. </div>
  122. </fieldset>
  123. <fieldset>
  124. <legend><?php echo t("Group Expiration Options")?></legend>
  125. <label></label>
  126. <div class="input">
  127. <ul class="inputs-list">
  128. <li>
  129. <label>
  130. <?php echo $form->checkbox('gUserExpirationIsEnabled', 1, $g->isGroupExpirationEnabled())?>
  131. <span><?php echo t('Automatically remove users from this group')?></span></label>
  132. <div style="padding-left: 15px; padding-top: 10px; padding-bottom: 10px">
  133. <?php echo $form->select("gUserExpirationMethod", array(
  134. 'SET_TIME' => t('at a specific date and time'),
  135. 'INTERVAL' => t('once a certain amount of time has passed')
  136. ), $g->getGroupExpirationMethod(), array('disabled' => true));?>
  137. </div>
  138. </li>
  139. </ul>
  140. </div>
  141. <div id="gUserExpirationSetTimeOptions" style="display: none">
  142. <div class="clearfix">
  143. <?php echo $form->label('gUserExpirationSetDateTime', t('Expiration Date'))?>
  144. <div class="input">
  145. <?php echo $date->datetime('gUserExpirationSetDateTime', $g->getGroupExpirationDateTime())?>
  146. </div>
  147. </div>
  148. </div>
  149. <div id="gUserExpirationIntervalOptions" style="display: none">
  150. <div class="clearfix">
  151. <label><?php echo t('Accounts expire after')?></label>
  152. <div class="input">
  153. <table style="width: 1%; margin-bottom: 0px">
  154. <tr>
  155. <?php
  156. $days = $g->getGroupExpirationIntervalDays();
  157. $hours = $g->getGroupExpirationIntervalHours();
  158. $minutes = $g->getGroupExpirationIntervalMinutes();
  159. $style = 'width: 60px';
  160. ?>
  161. <td valign="top"><strong><?php echo t('Days')?></strong><br/>
  162. <?php echo $form->text('gUserExpirationIntervalDays', $days, array('style' => $style, 'class' => 'span1'))?>
  163. </td>
  164. <td valign="top"><strong><?php echo t('Hours')?></strong><br/>
  165. <?php echo $form->text('gUserExpirationIntervalHours', $hours, array('style' => $style, 'class' => 'span1'))?>
  166. </td>
  167. <td valign="top"><strong><?php echo t('Minutes')?></strong><br/>
  168. <?php echo $form->text('gUserExpirationIntervalMinutes', $minutes, array('style' => $style, 'class' => 'span1'))?>
  169. </td>
  170. </tr>
  171. </table>
  172. </div>
  173. </div>
  174. </div>
  175. <div id="gUserExpirationAction" style="display: none">
  176. <div class="clearfix">
  177. <?php echo $form->label('gUserExpirationAction', t('Expiration Action'))?>
  178. <div class="input">
  179. <?php echo $form->select("gUserExpirationAction", array(
  180. 'REMOVE' => t('Remove the user from this group'),
  181. 'DEACTIVATE' => t('Deactivate the user account'),
  182. 'REMOVE_DEACTIVATE' => t('Remove the user from the group and deactivate the account')
  183. ), $g->getGroupExpirationAction());?>
  184. </div>
  185. </div>
  186. </div>
  187. <input type="hidden" name="gID" value="<?php echo intval($_REQUEST['gID'])?>" />
  188. <input type="hidden" name="task" value="edit" />
  189. </fieldset>
  190. </div>
  191. <div class="ccm-pane-footer">
  192. <?php echo $ih->submit(t('Update'), 'update-group-form', 'right', 'primary')?>
  193. <?php print $ih->button_js(t('Delete'), "deleteGroup()", 'right', 'error');?>
  194. <?php echo $ih->button(t('Cancel'), $this->url('/dashboard/users/groups'), 'left')?>
  195. </div>
  196. </form>
  197. <?php echo Loader::helper('concrete/dashboard')->getDashboardPaneFooterWrapper(false);?>
  198. <?php } ?>
  199. <script type="text/javascript">
  200. ccm_checkGroupExpirationOptions = function() {
  201. var sel = $("select[name=gUserExpirationMethod]");
  202. var cb = $("input[name=gUserExpirationIsEnabled]");
  203. if (cb.prop('checked')) {
  204. sel.attr('disabled', false);
  205. switch(sel.val()) {
  206. case 'SET_TIME':
  207. $("#gUserExpirationSetTimeOptions").show();
  208. $("#gUserExpirationIntervalOptions").hide();
  209. break;
  210. case 'INTERVAL':
  211. $("#gUserExpirationSetTimeOptions").hide();
  212. $("#gUserExpirationIntervalOptions").show();
  213. break;
  214. }
  215. $("#gUserExpirationAction").show();
  216. } else {
  217. sel.attr('disabled', true);
  218. $("#gUserExpirationSetTimeOptions").hide();
  219. $("#gUserExpirationIntervalOptions").hide();
  220. $("#gUserExpirationAction").hide();
  221. }
  222. }
  223. $(function() {
  224. $("input[name=gUserExpirationIsEnabled]").click(ccm_checkGroupExpirationOptions);
  225. $("select[name=gUserExpirationMethod]").change(ccm_checkGroupExpirationOptions);
  226. ccm_checkGroupExpirationOptions();
  227. /*
  228. $("div#gUserExpirationIntervalOptions input").focus(function() {
  229. if ($('input[name=gUserExpirationIntervalDays]').val() == '<?php echo t("Days")?>' &&
  230. $('input[name=gUserExpirationIntervalHours]').val() == '<?php echo t("Hours")?>' &&
  231. $('input[name=gUserExpirationIntervalMinutes]').val() == '<?php echo t("Minutes")?>') {
  232. $("div#gUserExpirationIntervalOptions input").val("");
  233. $("div#gUserExpirationIntervalOptions input").css('color', '#000');
  234. }
  235. });
  236. $("div#gUserExpirationIntervalOptions input").blur(function() {
  237. if ($('input[name=gUserExpirationIntervalDays]').val() == '' &&
  238. $('input[name=gUserExpirationIntervalHours]').val() == '' &&
  239. $('input[name=gUserExpirationIntervalMinutes]').val() == '') {
  240. $('input[name=gUserExpirationIntervalDays]').val('<?php echo t("Days")?>');
  241. $('input[name=gUserExpirationIntervalHours]').val('<?php echo t("Hours")?>');
  242. $('input[name=gUserExpirationIntervalMinutes]').val('<?php echo t("Minutes")?>');
  243. $("div#gUserExpirationIntervalOptions input").css('color', '#aaa');
  244. }
  245. });
  246. */
  247. });
  248. </script>