From b04f30ecf2347104131b8dccf7bb349b5ec72762 Mon Sep 17 00:00:00 2001 From: brettp Date: Fri, 1 Oct 2010 21:01:39 +0000 Subject: Added admin page to validate, resend validation requests, or delete unvalidated users. git-svn-id: http://code.elgg.org/elgg/trunk@6997 36083f99-b078-4883-b0ff-0f9b5a30f544 --- mod/uservalidationbyemail/actions/bulk_action.php | 18 ++++++++ mod/uservalidationbyemail/actions/delete.php | 52 +++++++++++++++++++++ .../actions/resend_validation.php | 52 +++++++++++++++++++++ mod/uservalidationbyemail/actions/validate.php | 53 ++++++++++++++++++++++ mod/uservalidationbyemail/languages/en.php | 29 +++++++++++- mod/uservalidationbyemail/lib/functions.php | 41 +++++++++++++++++ mod/uservalidationbyemail/start.php | 10 ++++ .../views/default/admin/users/unvalidated.php | 35 ++++++++++++++ .../uservalidationbyemail/unvalidated_user.php | 53 ++++++++++++++++++++++ 9 files changed, 342 insertions(+), 1 deletion(-) create mode 100644 mod/uservalidationbyemail/actions/bulk_action.php create mode 100644 mod/uservalidationbyemail/actions/delete.php create mode 100644 mod/uservalidationbyemail/actions/resend_validation.php create mode 100644 mod/uservalidationbyemail/actions/validate.php create mode 100644 mod/uservalidationbyemail/views/default/admin/users/unvalidated.php create mode 100644 mod/uservalidationbyemail/views/default/uservalidationbyemail/unvalidated_user.php (limited to 'mod') diff --git a/mod/uservalidationbyemail/actions/bulk_action.php b/mod/uservalidationbyemail/actions/bulk_action.php new file mode 100644 index 000000000..fbbcc1c93 --- /dev/null +++ b/mod/uservalidationbyemail/actions/bulk_action.php @@ -0,0 +1,18 @@ +delete()) { + $error = TRUE; + continue; + } +} + +access_show_hidden_entities($access); + +if (count($user_guids) == 1) { + $message_txt = elgg_echo('uservalidationbyemail:messages:deleted_user'); + $error_txt = elgg_echo('uservalidationbyemail:errors:could_not_delete_user'); +} else { + $message_txt = elgg_echo('uservalidationbyemail:messages:deleted_users'); + $error_txt = elgg_echo('uservalidationbyemail:errors:could_not_delete_users'); +} + +if ($error) { + register_error($error_txt); +} else { + system_message($message_txt); +} + +forward(REFERRER); \ No newline at end of file diff --git a/mod/uservalidationbyemail/actions/resend_validation.php b/mod/uservalidationbyemail/actions/resend_validation.php new file mode 100644 index 000000000..70c2244b9 --- /dev/null +++ b/mod/uservalidationbyemail/actions/resend_validation.php @@ -0,0 +1,52 @@ +enable()) { + $error = TRUE; + continue; + } +} + +access_show_hidden_entities($access); + +if (count($user_guids) == 1) { + $message_txt = elgg_echo('uservalidationbyemail:messages:validated_user'); + $error_txt = elgg_echo('uservalidationbyemail:errors:could_not_validate_user'); +} else { + $message_txt = elgg_echo('uservalidationbyemail:messages:validated_users'); + $error_txt = elgg_echo('uservalidationbyemail:errors:could_not_validate_users'); +} + +if ($error) { + register_error($error_txt); +} else { + system_message($message_txt); +} + +forward(REFERRER); \ No newline at end of file diff --git a/mod/uservalidationbyemail/languages/en.php b/mod/uservalidationbyemail/languages/en.php index 6b3a6f708..31dec24a3 100644 --- a/mod/uservalidationbyemail/languages/en.php +++ b/mod/uservalidationbyemail/languages/en.php @@ -24,7 +24,34 @@ If you can't click on the link, copy and paste it to your browser manually. 'email:confirm:success' => "You have confirmed your email address!", 'email:confirm:fail' => "Your email address could not be verified...", - 'uservalidationbyemail:registerok' => "To activate your account, please confirm your email address by clicking on the link we just sent you." + 'uservalidationbyemail:registerok' => "To activate your account, please confirm your email address by clicking on the link we just sent you.", + + 'uservalidationbyemail:admin:no_unvalidated_users' => 'No unvalidated users.', + + 'uservalidationbyemail:admin:unvalidated' => 'Unvalidated', + 'uservalidationbyemail:admin:user_created' => 'Registered %s', + 'uservalidationbyemail:admin:resend_validation' => 'Resend validation', + 'uservalidationbyemail:admin:validate' => 'Validate', + 'uservalidationbyemail:admin:delete' => 'Delete', + 'uservalidationbyemail:confirm_validate_user' => 'Validate %s?', + 'uservalidationbyemail:confirm_resend_validation' => 'Resend validation email to %s?', + 'uservalidationbyemail:confirm_delete' => 'Delete %s?', + 'uservalidationbyemail:admin:with_checked' => 'With checked:', + + 'uservalidationbyemail:errors:unknown_users' => 'Unknown users', + 'uservalidationbyemail:errors:could_not_validate_user' => 'Could not validate user.', + 'uservalidationbyemail:errors:could_not_validate_users' => 'Could not validate all checked users.', + 'uservalidationbyemail:errors:could_not_delete_user' => 'Could not delete user.', + 'uservalidationbyemail:errors:could_not_delete_users' => 'Could not delete all checked users.', + 'uservalidationbyemail:errors:could_not_resend_validation' => 'Could not resend validation request.', + 'uservalidationbyemail:errors:could_not_resend_validations' => 'Could not resend all validation requests to checked users.', + + 'uservalidationbyemail:messages:validated_user' => 'User validated.', + 'uservalidationbyemail:messages:validated_users' => 'All checked users validated.', + 'uservalidationbyemail:messages:deleted_user' => 'User deleted.', + 'uservalidationbyemail:messages:deleted_users' => 'All checked users deleted.', + 'uservalidationbyemail:messages:resent_validation' => 'Validation request resent.', + 'uservalidationbyemail:messages:resent_validations' => 'Validation requests resent to all checked users.' ); diff --git a/mod/uservalidationbyemail/lib/functions.php b/mod/uservalidationbyemail/lib/functions.php index ed66b40d4..0610c1809 100644 --- a/mod/uservalidationbyemail/lib/functions.php +++ b/mod/uservalidationbyemail/lib/functions.php @@ -104,4 +104,45 @@ function uservalidationbyemail_set_user_validation_status($user_guid, $status, $ } return FALSE; +} + +/** + * Returns the validation status of a user. + * + * @param unknown_type $user_guid + * @return int|null + */ +function uservalidationbyemail_get_user_validation_status($user_guid) { + return get_metadata_byname($user_guid, 'validated'); +} + +/** + * Returns all users who haven't been validated. + * + * "Unvalidated" means metadata of validated is not set or not truthy. + * We can't use the elgg_get_entities_from_metadata() because you can't say + * "where the entity has metadata set OR it's not equal to 1". + * + * This doesn't include any security, so should be called ONLY be admin users! + * @return array + */ +function uservalidationbyemail_get_unvalidated_users() { + global $CONFIG; + + $validated_id = get_metastring_id('validated'); + $one_id = get_metastring_id(1); + + // thanks to daveb@freenode for the SQL tips! + $q = "SELECT e.* FROM {$CONFIG->dbprefix}entities e + WHERE e.type = 'user' + AND NOT EXISTS ( + SELECT 1 FROM {$CONFIG->dbprefix}metadata md + WHERE md.entity_guid = e.guid + AND md.name_id = $validated_id + AND md.value_id = $one_id) + + ORDER BY e.guid DESC"; + + $users = get_data($q, 'entity_row_to_elggstar'); + return $users; } \ No newline at end of file diff --git a/mod/uservalidationbyemail/start.php b/mod/uservalidationbyemail/start.php index 677fea231..1dcb5509f 100644 --- a/mod/uservalidationbyemail/start.php +++ b/mod/uservalidationbyemail/start.php @@ -33,6 +33,16 @@ function uservalidationbyemail_init() { // register Walled Garden public pages register_plugin_hook('public_pages', 'walled_garden', 'uservalidationbyemail_public_pages'); + + // admin interface to manually validate users + elgg_add_admin_submenu_item('unvalidated', elgg_echo('uservalidationbyemail:admin:unvalidated'), 'users'); + + $action_path = dirname(__FILE__) . '/actions'; + + register_action('uservalidationbyemail/validate', FALSE, "$action_path/validate.php", TRUE); + register_action('uservalidationbyemail/resend_validation', FALSE, "$action_path/resend_validation.php", TRUE); + register_action('uservalidationbyemail/delete', FALSE, "$action_path/delete.php", TRUE); + register_action('uservalidationbyemail/bulk_action', FALSE, "$action_path/bulk_action.php", TRUE); } /** diff --git a/mod/uservalidationbyemail/views/default/admin/users/unvalidated.php b/mod/uservalidationbyemail/views/default/admin/users/unvalidated.php new file mode 100644 index 000000000..4a14482df --- /dev/null +++ b/mod/uservalidationbyemail/views/default/admin/users/unvalidated.php @@ -0,0 +1,35 @@ + $user)); + } +} else { + echo elgg_echo('uservalidationbyemail:admin:no_unvalidated_users'); + return; +} + +$form_body .= elgg_echo('uservalidationbyemail:admin:with_checked') . elgg_view('input/pulldown', array( + 'internalname' => 'action_type', + 'options_values' => array( + 'validate' => elgg_echo('uservalidationbyemail:admin:validate'), + 'resend_validation' => elgg_echo('uservalidationbyemail:admin:resend_validation'), + 'delete' => elgg_echo('uservalidationbyemail:admin:delete'), + ) +)); + +$form_body .= '
' . elgg_view('input/button', array('value' => elgg_echo('submit'))); + +echo elgg_view('input/form', array( + 'action' => $vars['url'] . 'action/uservalidationbyemail/bulk_action', + 'body' => $form_body +)); \ No newline at end of file diff --git a/mod/uservalidationbyemail/views/default/uservalidationbyemail/unvalidated_user.php b/mod/uservalidationbyemail/views/default/uservalidationbyemail/unvalidated_user.php new file mode 100644 index 000000000..06c4e633e --- /dev/null +++ b/mod/uservalidationbyemail/views/default/uservalidationbyemail/unvalidated_user.php @@ -0,0 +1,53 @@ + 'user_guids', +// 'options' => array("$user->username - \"$user->name\" <$user->email>" => $user->guid) +//)); +$checkbox = ""; + +$created = sprintf(elgg_echo('uservalidationbyemail:admin:user_created'), elgg_view_friendly_time($user->time_created)); + +$validate = elgg_view('output/confirmlink', array( + 'confirm' => sprintf(elgg_echo('uservalidationbyemail:confirm_validate_user'), $user->username), + 'href' => $vars['url'] . "action/uservalidationbyemail/validate/?user_guids[]=$user->guid", + 'text' => elgg_echo('uservalidationbyemail:admin:validate') +)); + +$resend_email = elgg_view('output/confirmlink', array( + 'confirm' => sprintf(elgg_echo('uservalidationbyemail:confirm_resend_validation'), $user->username), + 'href' => $vars['url'] . "action/uservalidationbyemail/resend_validation/?user_guids[]=$user->guid", + 'text' => elgg_echo('uservalidationbyemail:admin:resend_validation') +)); + +$delete = elgg_view('output/confirmlink', array( + 'confirm' => sprintf(elgg_echo('uservalidationbyemail:confirm_delete'), $user->username), + 'href' => $vars['url'] . "action/uservalidationbyemail/delete/?user_guids[]=$user->guid", + 'text' => elgg_echo('uservalidationbyemail:admin:delete') +)); + +// @todo All of these hard coded styles need to be removed. +// they're here because you can't currently extend the admin css. +?> + +
+
+ +
+ + + +
+ +
+
-- cgit v1.2.3