Permalink
Browse files

bulk user functionality, user activate, deactivate and delete

  • Loading branch information...
1 parent b71cf3e commit 1de1c7d707b69695855bb512a77367eb101d0dd0 @tylerryan tylerryan committed Apr 3, 2012
@@ -0,0 +1,22 @@
+<?php defined('C5_EXECUTE') or die("Access Denied.");
+// used when confirming bulk user operations.. would you like to do xyz to the following users??
+if(is_array($users)) { ?>
+<table class="zebra-striped" width="100%" cellspacing="0" cellpadding="0" border="0">
+ <thead>
+ <tr>
+ <th><?php echo t('Username')?></th>
+ <th><?php echo t('Email')?></th>
+ <th><?php echo t('# Logins')?></th>
+ </tr>
+ </thead>
+ <tbody>
+ <?php foreach($users as $ui) { ?>
+ <tr>
+ <td><?php echo $ui->getUserName(); ?></td>
+ <td><?php echo $ui->getUserEmail(); ?></td>
+ <td><?php echo number_format($ui->getNumLogins(),0); ?></td>
+ </tr>
+ <?php } ?>
+ </tbody>
+</table>
+<?php } ?>
@@ -32,6 +32,9 @@
<select id="ccm-<?=$searchInstance?>-list-multiple-operations" class="span3" disabled>
<option value="">** <?=t('With Selected')?></option>
<option value="properties"><?=t('Edit Properties')?></option>
+ <option value="activate"><?=t('Activate')?></option>
+ <option value="deactivate"><?=t('Deactivate')?></option>
+ <option value="delete"><?=t('Delete')?></option>
<? if ($mode == 'choose_multiple') { ?>
<option value="choose"><?=t('Choose')?></option>
<? } ?>

Large diffs are not rendered by default.

Oops, something went wrong.
@@ -471,7 +471,59 @@ ccm_setupUserSearch = function() {
href: CCM_TOOLS_PATH + '/users/bulk_properties?' + uIDstring,
title: ccmi18n.properties
});
- break;
+ break;
+ case "activate":
+ uIDstring = '';
+ $("td.ccm-user-list-cb input[type=checkbox]:checked").each(function() {
+ uIDstring=uIDstring+'&uID[]='+$(this).val();
+ });
+ jQuery.fn.dialog.open({
+ width: 630,
+ height: 450,
+ modal: false,
+ href: CCM_TOOLS_PATH + '/users/bulk_activate?' + uIDstring,
+ title: ccmi18n.user_activate
+ });
+ break;
+ case "deactivate":
+ uIDstring = '';
+ $("td.ccm-user-list-cb input[type=checkbox]:checked").each(function() {
+ uIDstring=uIDstring+'&uID[]='+$(this).val();
+ });
+ jQuery.fn.dialog.open({
+ width: 630,
+ height: 450,
+ modal: false,
+ href: CCM_TOOLS_PATH + '/users/bulk_deactivate?' + uIDstring,
+ title: ccmi18n.user_deactivate
+ });
+ break;
+ case "password_reset":
+ uIDstring = '';
+ $("td.ccm-user-list-cb input[type=checkbox]:checked").each(function() {
+ uIDstring=uIDstring+'&uID[]='+$(this).val();
+ });
+ jQuery.fn.dialog.open({
+ width: 630,
+ height: 450,
+ modal: false,
+ href: CCM_TOOLS_PATH + '/users/bulk_password_reset?' + uIDstring,
+ title: ccmi18n.user_password_reset
+ });
+ break;
+ case "delete":
+ uIDstring = '';
+ $("td.ccm-user-list-cb input[type=checkbox]:checked").each(function() {
+ uIDstring=uIDstring+'&uID[]='+$(this).val();
+ });
+ jQuery.fn.dialog.open({
+ width: 630,
+ height: 450,
+ modal: false,
+ href: CCM_TOOLS_PATH + '/users/bulk_delete?' + uIDstring,
+ title: ccmi18n.user_delete
+ });
+ break;
}
$(this).get(0).selectedIndex = 0;
@@ -68,7 +68,11 @@
ok: "<?=t('Ok')?>",
newsflowLoading: "<?=t("Checking for updates.")?>",
authoredBy: "<?=t('by')?>",
- x: "<?=t('x')?>"
+ x: "<?=t('x')?>",
+ user_activate: "<?=t('Activate Users')?>",
+ user_deactivate: "<?=t('Deactivate Users')?>",
+ user_password_reset: "<?=t('Reset Passwords')?>",
+ user_delete: "<?=t('Delete')?>"
}
var ccmi18n_sitemap = {
@@ -0,0 +1,59 @@
+<?php defined('C5_EXECUTE') or die("Access Denied.");
+$form = Loader::helper('form');
+$ih = Loader::helper('concrete/interface');
+$tp = new TaskPermission();
+if (!$tp->canAccessUserSearch()) {
+ die(t("Access Denied."));
+}
+
+$users = array();
+if (is_array($_REQUEST['uID'])) {
+ foreach($_REQUEST['uID'] as $uID) {
+ $ui = UserInfo::getByID($uID);
+ $users[] = $ui;
+ }
+}
+
+if ($_POST['task'] == 'activate') {
+ foreach($users as $ui) {
+ if(!$ui->isActive()) {
+ $ui->activate();
+ }
+ }
+ echo Loader::helper('json')->encode(array('error'=>false));
+ exit;
+}
+
+if (!isset($_REQUEST['reload'])) { ?>
+ <div id="ccm-user-bulk-activate-wrapper">
+<? } ?>
+
+ <div id="ccm-user-activate" class="ccm-ui">
+ <form method="post" id="ccm-user-bulk-activate" action="<?php echo REL_DIR_FILES_TOOLS_REQUIRED ?>/users/bulk_activate">
+ <?php
+ echo $form->hidden('task','activate');
+ foreach($users as $ui) {
+ echo $form->hidden('uID[]' , $ui->getUserID());
+ }
+ ?>
+ <?php echo t('Are you sure you would like to activate the following users?');?><br/><br/>
+ <?php Loader::element('users/confirm_list',array('users'=>$users)); ?>
+ </form>
+ </div>
+ <div class="dialog-buttons">
+ <?=$ih->button_js(t('Cancel'), 'jQuery.fn.dialog.closeTop()', 'left', 'btn')?>
+ <?=$ih->button_js(t('Activate'), 'ccm_userBulkActivate()', 'right', 'btn primary')?>
+ </div>
+<?
+if (!isset($_REQUEST['reload'])) { ?>
+</div>
+<? } ?>
+
+<script type="text/javascript">
+ccm_userBulkActivate = function() {
+ $("#ccm-user-bulk-activate").ajaxSubmit(function(resp) {
+ });
+ jQuery.fn.dialog.closeTop();
+ ccm_setupUserSearch();
+};
+</script>
@@ -0,0 +1,59 @@
+<?php defined('C5_EXECUTE') or die("Access Denied.");
+$form = Loader::helper('form');
+$ih = Loader::helper('concrete/interface');
+$tp = new TaskPermission();
+if (!$tp->canAccessUserSearch()) {
+ die(t("Access Denied."));
+}
+
+$users = array();
+if (is_array($_REQUEST['uID'])) {
+ foreach($_REQUEST['uID'] as $uID) {
+ $ui = UserInfo::getByID($uID);
+ $users[] = $ui;
+ }
+}
+
+if ($_POST['task'] == 'deactivate') {
+ foreach($users as $ui) {
+ if($ui->isActive()) {
+ $ui->deactivate();
+ }
+ }
+ echo Loader::helper('json')->encode(array('error'=>false));
+ exit;
+}
+
+if (!isset($_REQUEST['reload'])) { ?>
+ <div id="ccm-user-bulk-deactivate-wrapper">
+<? } ?>
+
+ <div id="ccm-user-deactivate" class="ccm-ui">
+ <form method="post" id="ccm-user-bulk-deactivate" action="<?php echo REL_DIR_FILES_TOOLS_REQUIRED ?>/users/bulk_deactivate">
+ <?php
+ echo $form->hidden('task','deactivate');
+ foreach($users as $ui) {
+ echo $form->hidden('uID[]' , $ui->getUserID());
+ }
+ ?>
+ <?php echo t('Are you sure you would like to deactivate the following users?');?><br/><br/>
+ <?php Loader::element('users/confirm_list',array('users'=>$users)); ?>
+ </form>
+ </div>
+ <div class="dialog-buttons">
+ <?=$ih->button_js(t('Cancel'), 'jQuery.fn.dialog.closeTop()', 'left', 'btn')?>
+ <?=$ih->button_js(t('Deactivate'), 'ccm_userBulkDeactivate()', 'right', 'btn primary')?>
+ </div>
+<?
+if (!isset($_REQUEST['reload'])) { ?>
+</div>
+<? } ?>
+
+<script type="text/javascript">
+ccm_userBulkDeactivate = function() {
+ $("#ccm-user-bulk-deactivate").ajaxSubmit(function(resp) {
+ });
+ jQuery.fn.dialog.closeTop();
+ ccm_setupUserSearch();
+};
+</script>
@@ -0,0 +1,75 @@
+<?php defined('C5_EXECUTE') or die("Access Denied.");
+$form = Loader::helper('form');
+$ih = Loader::helper('concrete/interface');
+$tp = new TaskPermission();
+$u = new User();
+if (!$tp->canAccessUserSearch()) {
+ die(t("Access Denied."));
+}
+
+$users = array();
+$excluded = false;
+$excluded_user_ids = array();
+$excluded_user_ids[] = $u->getUserID(); // can't delete yourself
+$excluded_user_ids[] = USER_SUPER_ID; // can't delete the super user (admin)
+
+if (is_array($_REQUEST['uID'])) {
+ foreach($_REQUEST['uID'] as $uID) {
+ $ui = UserInfo::getByID($uID);
+
+ if((in_array($ui->getUserID(),$excluded_user_ids))) {
+ $excluded = true;
+ } else {
+ $users[] = $ui;
+ }
+ }
+}
+
+
+if ($_POST['task'] == 'delete') {
+ foreach($users as $ui) {
+ if(!(in_array($ui->getUserID(),$excluded_user_ids))) {
+ $ui->delete();
+ }
+ }
+ echo Loader::helper('json')->encode(array('error'=>false));
+ exit;
+}
+
+if (!isset($_REQUEST['reload'])) { ?>
+ <div id="ccm-user-bulk-delete-wrapper">
+<? } ?>
+
+ <div id="ccm-user-delete" class="ccm-ui">
+ <form method="post" id="ccm-user-bulk-delete" action="<?php echo REL_DIR_FILES_TOOLS_REQUIRED ?>/users/bulk_delete">
+ <?php
+ echo $form->hidden('task','delete');
+ foreach($users as $ui) {
+ echo $form->hidden('uID[]' , $ui->getUserID());
+ }
+ if($excluded) { ?>
+ <div class="alert-message info">
+ <?php echo t("Users you don't have permission to bulk-delete have been removed from this list."); ?>
+ </div>
+ <?php } ?>
+ <?php echo t('Are you sure you would like to delete the following users?');?><br/><br/>
+ <?php Loader::element('users/confirm_list',array('users'=>$users)); ?>
+ </form>
+ </div>
+ <div class="dialog-buttons">
+ <?=$ih->button_js(t('Cancel'), 'jQuery.fn.dialog.closeTop()', 'left', 'btn')?>
+ <?=$ih->button_js(t('Delete'), 'ccm_userBulkActivate()', 'right', 'btn error')?>
+ </div>
+<?
+if (!isset($_REQUEST['reload'])) { ?>
+</div>
+<? } ?>
+
+<script type="text/javascript">
+ccm_userBulkActivate = function() {
+ $("#ccm-user-bulk-delete").ajaxSubmit(function(resp) {
+ });
+ jQuery.fn.dialog.closeTop();
+ ccm_setupUserSearch();
+};
+</script>

0 comments on commit 1de1c7d

Please sign in to comment.