aboutsummaryrefslogtreecommitdiff
path: root/actions/bulk_user_admin/delete_by_domain.php
diff options
context:
space:
mode:
authorSilvio Rhatto <rhatto@riseup.net>2014-03-15 14:48:09 -0300
committerSilvio Rhatto <rhatto@riseup.net>2014-03-15 14:48:09 -0300
commitbd1864363fada1c3122b053b83c4d8b9526bbfa3 (patch)
treed9384adec24d864e71c169f3b52605a53228e02c /actions/bulk_user_admin/delete_by_domain.php
downloadelgg-bd1864363fada1c3122b053b83c4d8b9526bbfa3.tar.gz
elgg-bd1864363fada1c3122b053b83c4d8b9526bbfa3.tar.bz2
Squashed 'mod/bulk_user_admin/' content from commit 17664c9
git-subtree-dir: mod/bulk_user_admin git-subtree-split: 17664c9c5af5ee2d74b7c378ccc52ee65074ad6c
Diffstat (limited to 'actions/bulk_user_admin/delete_by_domain.php')
-rw-r--r--actions/bulk_user_admin/delete_by_domain.php36
1 files changed, 36 insertions, 0 deletions
diff --git a/actions/bulk_user_admin/delete_by_domain.php b/actions/bulk_user_admin/delete_by_domain.php
new file mode 100644
index 000000000..c51076936
--- /dev/null
+++ b/actions/bulk_user_admin/delete_by_domain.php
@@ -0,0 +1,36 @@
+<?php
+/**
+ * Bulk delete users by email
+ */
+
+$domain = get_input('domain');
+
+$errors = array();
+
+$options = array(
+ 'limit' => 50,
+ 'offset' => 0,
+);
+
+$users = bulk_user_admin_get_users_by_email_domain($domain, $options);
+
+while ($users) {
+ foreach ($users as $user) {
+ if (!$user->delete()) {
+ $errors[] = "Could not delete $user->name ($user->username).";
+ }
+ }
+
+ $options['offset'] = $options['offset'] + $options['limit'];
+ $users = bulk_user_admin_get_users_by_email_domain($domain, $options);
+}
+
+if ($errors) {
+ foreach ($errors as $error) {
+ register_error($error);
+ }
+} else {
+ system_message("Users deleted.");
+}
+
+forward(REFERER);