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 | 0b487846ecd43b99933255280565aaec32f98faa (patch) | |
tree | 11214c6eda8c6d1b922908d2fa6f178e3f15c818 /mod/bulk_user_admin/actions | |
parent | a89ba6df7133bc7f0b8ea96d4a5673887b267af4 (diff) | |
parent | bd1864363fada1c3122b053b83c4d8b9526bbfa3 (diff) | |
download | elgg-0b487846ecd43b99933255280565aaec32f98faa.tar.gz elgg-0b487846ecd43b99933255280565aaec32f98faa.tar.bz2 |
Merge commit 'bd1864363fada1c3122b053b83c4d8b9526bbfa3' as 'mod/bulk_user_admin'
Diffstat (limited to 'mod/bulk_user_admin/actions')
-rw-r--r-- | mod/bulk_user_admin/actions/bulk_user_admin/delete.php | 30 | ||||
-rw-r--r-- | mod/bulk_user_admin/actions/bulk_user_admin/delete_by_domain.php | 36 |
2 files changed, 66 insertions, 0 deletions
diff --git a/mod/bulk_user_admin/actions/bulk_user_admin/delete.php b/mod/bulk_user_admin/actions/bulk_user_admin/delete.php new file mode 100644 index 000000000..0d7a7e7df --- /dev/null +++ b/mod/bulk_user_admin/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/mod/bulk_user_admin/actions/bulk_user_admin/delete_by_domain.php b/mod/bulk_user_admin/actions/bulk_user_admin/delete_by_domain.php new file mode 100644 index 000000000..c51076936 --- /dev/null +++ b/mod/bulk_user_admin/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); |