diff options
author | Silvio Rhatto <rhatto@riseup.net> | 2014-03-15 14:48:09 -0300 |
---|---|---|
committer | Silvio Rhatto <rhatto@riseup.net> | 2014-03-15 14:48:09 -0300 |
commit | bd1864363fada1c3122b053b83c4d8b9526bbfa3 (patch) | |
tree | d9384adec24d864e71c169f3b52605a53228e02c /actions | |
download | elgg-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')
-rw-r--r-- | actions/bulk_user_admin/delete.php | 30 | ||||
-rw-r--r-- | actions/bulk_user_admin/delete_by_domain.php | 36 |
2 files changed, 66 insertions, 0 deletions
diff --git a/actions/bulk_user_admin/delete.php b/actions/bulk_user_admin/delete.php new file mode 100644 index 000000000..0d7a7e7df --- /dev/null +++ b/actions/bulk_user_admin/delete.php @@ -0,0 +1,30 @@ +<?php +/** + * Bulk delete users + */ + +$guids = get_input('bulk_user_admin_guids'); +$errors = array(); + +foreach ($guids as $guid) { + $user = get_entity($guid); + + if (!$user instanceof ElggUser) { + $errors[] = "$guid is not a user."; + continue; + } + + if (!$user->delete()) { + $errors[] = "Could not delete $user->name ($user->username)."; + } +} + +if ($errors) { + foreach ($errors as $error) { + register_error($error); + } +} else { + system_message("Users deleted."); +} + +forward(REFERER); 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); |