aboutsummaryrefslogtreecommitdiff
path: root/mod/uservalidationbyemail
diff options
context:
space:
mode:
Diffstat (limited to 'mod/uservalidationbyemail')
-rw-r--r--mod/uservalidationbyemail/actions/bulk_action.php18
-rw-r--r--mod/uservalidationbyemail/actions/delete.php51
-rw-r--r--mod/uservalidationbyemail/actions/resend_validation.php51
-rw-r--r--mod/uservalidationbyemail/actions/validate.php53
-rw-r--r--mod/uservalidationbyemail/languages/en.php64
-rw-r--r--mod/uservalidationbyemail/lib/functions.php108
-rw-r--r--mod/uservalidationbyemail/manifest.xml17
-rw-r--r--mod/uservalidationbyemail/start.php255
-rw-r--r--mod/uservalidationbyemail/views/default/admin/users/unvalidated.php9
-rw-r--r--mod/uservalidationbyemail/views/default/forms/uservalidationbyemail/bulk_action.php112
-rw-r--r--mod/uservalidationbyemail/views/default/uservalidationbyemail/css.php12
-rw-r--r--mod/uservalidationbyemail/views/default/uservalidationbyemail/js.php28
-rw-r--r--mod/uservalidationbyemail/views/default/uservalidationbyemail/unvalidated_user.php50
13 files changed, 828 insertions, 0 deletions
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 @@
+<?php
+/**
+ * Dispatches a bulk action to real action.
+ *
+ * @package Elgg.Core.Plugin
+ * @subpackage UserValidationByEmail
+ */
+
+$action_type = get_input('action_type');
+$valid_actions = array('delete', 'resend_validation', 'validate');
+
+if (!in_array($action_type, $valid_actions)) {
+ forward(REFERRER);
+}
+
+$action_name = "uservalidationbyemail/$action_type";
+
+action($action_name); \ No newline at end of file
diff --git a/mod/uservalidationbyemail/actions/delete.php b/mod/uservalidationbyemail/actions/delete.php
new file mode 100644
index 000000000..b076d3048
--- /dev/null
+++ b/mod/uservalidationbyemail/actions/delete.php
@@ -0,0 +1,51 @@
+<?php
+/**
+ * Delete a user or users by guid
+ *
+ * @package Elgg.Core.Plugin
+ * @subpackage UserValidationByEmail
+ */
+
+$user_guids = get_input('user_guids');
+$error = FALSE;
+
+if (!$user_guids) {
+ register_error(elgg_echo('uservalidationbyemail:errors:unknown_users'));
+ forward(REFERRER);
+}
+
+$access = access_get_show_hidden_status();
+access_show_hidden_entities(TRUE);
+
+foreach ($user_guids as $guid) {
+ $user = get_entity($guid);
+ if (!$user instanceof ElggUser) {
+ $error = TRUE;
+ continue;
+ }
+
+ // don't delete validated users
+ $is_validated = elgg_get_user_validation_status($guid);
+ if ($is_validated !== FALSE || !$user->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..586509b13
--- /dev/null
+++ b/mod/uservalidationbyemail/actions/resend_validation.php
@@ -0,0 +1,51 @@
+<?php
+/**
+ * Resends validation emails to a user or users by guid
+ *
+ * @package Elgg.Core.Plugin
+ * @subpackage UserValidationByEmail
+ */
+
+$user_guids = get_input('user_guids');
+$error = FALSE;
+
+if (!$user_guids) {
+ register_error(elgg_echo('uservalidationbyemail:errors:unknown_users'));
+ forward(REFERRER);
+}
+
+$access = access_get_show_hidden_status();
+access_show_hidden_entities(TRUE);
+
+foreach ($user_guids as $guid) {
+ $user = get_entity($guid);
+ if (!$user instanceof ElggUser) {
+ $error = TRUE;
+ continue;
+ }
+
+ // don't resend emails to validated users
+ $is_validated = elgg_get_user_validation_status($guid);
+ if ($is_validated !== FALSE || !uservalidationbyemail_request_validation($guid, true)) {
+ $error = TRUE;
+ continue;
+ }
+}
+
+access_show_hidden_entities($access);
+
+if (count($user_guids) == 1) {
+ $message_txt = elgg_echo('uservalidationbyemail:messages:resent_validation');
+ $error_txt = elgg_echo('uservalidationbyemail:errors:could_not_resend_validation');
+} else {
+ $message_txt = elgg_echo('uservalidationbyemail:messages:resent_validations');
+ $error_txt = elgg_echo('uservalidationbyemail:errors:could_not_resend_validations');
+}
+
+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/validate.php b/mod/uservalidationbyemail/actions/validate.php
new file mode 100644
index 000000000..d6be9cfe5
--- /dev/null
+++ b/mod/uservalidationbyemail/actions/validate.php
@@ -0,0 +1,53 @@
+<?php
+/**
+ * Validate a user or users by guid
+ *
+ * @package Elgg.Core.Plugin
+ * @subpackage UserValidationByEmail
+ */
+
+$user_guids = get_input('user_guids');
+$error = FALSE;
+
+if (!$user_guids) {
+ register_error(elgg_echo('uservalidationbyemail:errors:unknown_users'));
+ forward(REFERRER);
+}
+
+$access = access_get_show_hidden_status();
+access_show_hidden_entities(TRUE);
+
+foreach ($user_guids as $guid) {
+ $user = get_entity($guid);
+ if (!$user instanceof ElggUser) {
+ $error = TRUE;
+ continue;
+ }
+
+ // only validate if not validated
+ $is_validated = elgg_get_user_validation_status($guid);
+ $validate_success = elgg_set_user_validation_status($guid, TRUE, 'manual');
+
+ if ($is_validated !== FALSE || !($validate_success && $user->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
new file mode 100644
index 000000000..df576a0e0
--- /dev/null
+++ b/mod/uservalidationbyemail/languages/en.php
@@ -0,0 +1,64 @@
+<?php
+/**
+ * Email user validation plugin language pack.
+ *
+ * @package Elgg.Core.Plugin
+ * @subpackage ElggUserValidationByEmail
+ */
+
+$english = array(
+ 'admin:users:unvalidated' => 'Unvalidated',
+
+ 'email:validate:subject' => "%s please confirm your email address for %s!",
+ 'email:validate:body' => "%s,
+
+Before you can start you using %s, you must confirm your email address.
+
+Please confirm your email address by clicking on the link below:
+
+%s
+
+If you can't click on the link, copy and paste it to your browser manually.
+
+%s
+%s
+",
+ '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:login:fail' => "Your account is not validated so the log in attempt failed. Another validation email has been sent.",
+
+ '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:confirm_validate_checked' => 'Validate checked users?',
+ 'uservalidationbyemail:confirm_resend_validation_checked' => 'Resend validation to checked users?',
+ 'uservalidationbyemail:confirm_delete_checked' => 'Delete checked users?',
+ 'uservalidationbyemail:check_all' => 'All',
+
+ '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.'
+
+);
+
+add_translation("en", $english); \ No newline at end of file
diff --git a/mod/uservalidationbyemail/lib/functions.php b/mod/uservalidationbyemail/lib/functions.php
new file mode 100644
index 000000000..f3091f94d
--- /dev/null
+++ b/mod/uservalidationbyemail/lib/functions.php
@@ -0,0 +1,108 @@
+<?php
+/**
+ * Helper functions
+ *
+ * @package Elgg.Core.Plugin
+ * @subpackage UserValidationByEmail
+ */
+
+/**
+ * Generate an email activation code.
+ *
+ * @param int $user_guid The guid of the user
+ * @param string $email_address Email address
+ * @return string
+ */
+function uservalidationbyemail_generate_code($user_guid, $email_address) {
+
+ $site_url = elgg_get_site_url();
+
+ // Note I bind to site URL, this is important on multisite!
+ return md5($user_guid . $email_address . $site_url . get_site_secret());
+}
+
+/**
+ * Request user validation email.
+ * Send email out to the address and request a confirmation.
+ *
+ * @param int $user_guid The user's GUID
+ * @param bool $admin_requested Was it requested by admin
+ * @return mixed
+ */
+function uservalidationbyemail_request_validation($user_guid, $admin_requested = FALSE) {
+
+ $site = elgg_get_site_entity();
+
+ $user_guid = (int)$user_guid;
+ $user = get_entity($user_guid);
+
+ if (($user) && ($user instanceof ElggUser)) {
+ // Work out validate link
+ $code = uservalidationbyemail_generate_code($user_guid, $user->email);
+ $link = "{$site->url}uservalidationbyemail/confirm?u=$user_guid&c=$code";
+
+
+ // Send validation email
+ $subject = elgg_echo('email:validate:subject', array($user->name, $site->name));
+ $body = elgg_echo('email:validate:body', array($user->name, $site->name, $link, $site->name, $site->url));
+ $result = notify_user($user->guid, $site->guid, $subject, $body, NULL, 'email');
+
+ if ($result && !$admin_requested) {
+ system_message(elgg_echo('uservalidationbyemail:registerok'));
+ }
+
+ return $result;
+ }
+
+ return FALSE;
+}
+
+/**
+ * Validate a user
+ *
+ * @param int $user_guid
+ * @param string $code
+ * @return bool
+ */
+function uservalidationbyemail_validate_email($user_guid, $code) {
+ $user = get_entity($user_guid);
+
+ if ($code == uservalidationbyemail_generate_code($user_guid, $user->email)) {
+ return elgg_set_user_validation_status($user_guid, true, 'email');
+ }
+
+ return false;
+}
+
+/**
+ * Return a where clause to get entities
+ *
+ * "Unvalidated" means metadata of validated is not set or not truthy.
+ * We can't use elgg_get_entities_from_metadata() because you can't say
+ * "where the entity has metadata set OR it's not equal to 1".
+ *
+ * @return array
+ */
+function uservalidationbyemail_get_unvalidated_users_sql_where() {
+ global $CONFIG;
+
+ $validated_id = get_metastring_id('validated');
+ if ($validated_id === false) {
+ $validated_id = add_metastring('validated');
+ }
+ $one_id = get_metastring_id('1');
+ if ($one_id === false) {
+ $one_id = add_metastring('1');
+ }
+
+ // thanks to daveb@freenode for the SQL tips!
+ $wheres = array();
+ $wheres[] = "e.enabled='no'";
+ $wheres[] = "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)";
+
+ return $wheres;
+} \ No newline at end of file
diff --git a/mod/uservalidationbyemail/manifest.xml b/mod/uservalidationbyemail/manifest.xml
new file mode 100644
index 000000000..800dd2641
--- /dev/null
+++ b/mod/uservalidationbyemail/manifest.xml
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<plugin_manifest xmlns="http://www.elgg.org/plugin_manifest/1.8">
+ <name>User Validation by Email</name>
+ <author>Core developers</author>
+ <version>1.8</version>
+ <category>bundled</category>
+ <category>security</category>
+ <description>Simple user account validation via email.</description>
+ <website>http://www.elgg.org/</website>
+ <copyright>See COPYRIGHT.txt</copyright>
+ <license>GNU General Public License version 2</license>
+ <requires>
+ <type>elgg_release</type>
+ <version>1.8</version>
+ </requires>
+ <activate_on_install>true</activate_on_install>
+</plugin_manifest>
diff --git a/mod/uservalidationbyemail/start.php b/mod/uservalidationbyemail/start.php
new file mode 100644
index 000000000..f44d2ab50
--- /dev/null
+++ b/mod/uservalidationbyemail/start.php
@@ -0,0 +1,255 @@
+<?php
+/**
+ * Email user validation plugin.
+ * Non-admin accounts are invalid until their email address is confirmed.
+ *
+ * @package Elgg.Core.Plugin
+ * @subpackage UserValidationByEmail
+ */
+
+elgg_register_event_handler('init', 'system', 'uservalidationbyemail_init');
+
+function uservalidationbyemail_init() {
+
+ require_once dirname(__FILE__) . '/lib/functions.php';
+
+ // Register page handler to validate users
+ // This doesn't need to be an action because security is handled by the validation codes.
+ elgg_register_page_handler('uservalidationbyemail', 'uservalidationbyemail_page_handler');
+
+ // mark users as unvalidated and disable when they register
+ elgg_register_plugin_hook_handler('register', 'user', 'uservalidationbyemail_disable_new_user');
+
+ // canEdit override to allow not logged in code to disable a user
+ elgg_register_plugin_hook_handler('permissions_check', 'user', 'uservalidationbyemail_allow_new_user_can_edit');
+
+ // prevent users from logging in if they aren't validated
+ register_pam_handler('uservalidationbyemail_check_auth_attempt', "required");
+
+ // when requesting a new password
+ elgg_register_plugin_hook_handler('action', 'user/requestnewpassword', 'uservalidationbyemail_check_request_password');
+
+ // prevent the engine from logging in users via login()
+ elgg_register_event_handler('login', 'user', 'uservalidationbyemail_check_manual_login');
+
+ // make admin users always validated
+ elgg_register_event_handler('make_admin', 'user', 'uservalidationbyemail_validate_new_admin_user');
+
+ // register Walled Garden public pages
+ elgg_register_plugin_hook_handler('public_pages', 'walled_garden', 'uservalidationbyemail_public_pages');
+
+ // admin interface to manually validate users
+ elgg_register_admin_menu_item('administer', 'unvalidated', 'users');
+
+ elgg_extend_view('css/admin', 'uservalidationbyemail/css');
+ elgg_extend_view('js/elgg', 'uservalidationbyemail/js');
+
+ $action_path = dirname(__FILE__) . '/actions';
+
+ elgg_register_action('uservalidationbyemail/validate', "$action_path/validate.php", 'admin');
+ elgg_register_action('uservalidationbyemail/resend_validation', "$action_path/resend_validation.php", 'admin');
+ elgg_register_action('uservalidationbyemail/delete', "$action_path/delete.php", 'admin');
+ elgg_register_action('uservalidationbyemail/bulk_action', "$action_path/bulk_action.php", 'admin');
+}
+
+/**
+ * Disables a user upon registration.
+ *
+ * @param string $hook
+ * @param string $type
+ * @param bool $value
+ * @param array $params
+ * @return bool
+ */
+function uservalidationbyemail_disable_new_user($hook, $type, $value, $params) {
+ $user = elgg_extract('user', $params);
+
+ // no clue what's going on, so don't react.
+ if (!$user instanceof ElggUser) {
+ return;
+ }
+
+ // another plugin is requesting that registration be terminated
+ // no need for uservalidationbyemail
+ if (!$value) {
+ return $value;
+ }
+
+ // has the user already been validated?
+ if (elgg_get_user_validation_status($user->guid) == true) {
+ return $value;
+ }
+
+ // disable user to prevent showing up on the site
+ // set context so our canEdit() override works
+ elgg_push_context('uservalidationbyemail_new_user');
+ $hidden_entities = access_get_show_hidden_status();
+ access_show_hidden_entities(TRUE);
+
+ // Don't do a recursive disable. Any entities owned by the user at this point
+ // are products of plugins that hook into create user and might need
+ // access to the entities.
+ // @todo That ^ sounds like a specific case...would be nice to track it down...
+ $user->disable('uservalidationbyemail_new_user', FALSE);
+
+ // set user as unvalidated and send out validation email
+ elgg_set_user_validation_status($user->guid, FALSE);
+ uservalidationbyemail_request_validation($user->guid);
+
+ elgg_pop_context();
+ access_show_hidden_entities($hidden_entities);
+
+ return $value;
+}
+
+/**
+ * Override the canEdit() call for if we're in the context of registering a new user.
+ *
+ * @param string $hook
+ * @param string $type
+ * @param bool $value
+ * @param array $params
+ * @return bool|null
+ */
+function uservalidationbyemail_allow_new_user_can_edit($hook, $type, $value, $params) {
+ // $params['user'] is the user to check permissions for.
+ // we want the entity to check, which is a user.
+ $user = elgg_extract('entity', $params);
+
+ if (!($user instanceof ElggUser)) {
+ return;
+ }
+
+ $context = elgg_get_context();
+ if ($context == 'uservalidationbyemail_new_user' || $context == 'uservalidationbyemail_validate_user') {
+ return TRUE;
+ }
+
+ return;
+}
+
+/**
+ * Checks if an account is validated
+ *
+ * @params array $credentials The username and password
+ * @return bool
+ */
+function uservalidationbyemail_check_auth_attempt($credentials) {
+
+ if (!isset($credentials['username'])) {
+ return;
+ }
+
+ $username = $credentials['username'];
+
+ // See if the user exists and isn't validated
+ $access_status = access_get_show_hidden_status();
+ access_show_hidden_entities(TRUE);
+
+ $user = get_user_by_username($username);
+ if ($user && isset($user->validated) && !$user->validated) {
+ // show an error and resend validation email
+ uservalidationbyemail_request_validation($user->guid);
+ access_show_hidden_entities($access_status);
+ throw new LoginException(elgg_echo('uservalidationbyemail:login:fail'));
+ }
+
+ access_show_hidden_entities($access_status);
+}
+
+/**
+ * Checks sent passed validation code and user guids and validates the user.
+ *
+ * @param array $page
+ * @return bool
+ */
+function uservalidationbyemail_page_handler($page) {
+
+ if (isset($page[0]) && $page[0] == 'confirm') {
+ $code = sanitise_string(get_input('c', FALSE));
+ $user_guid = get_input('u', FALSE);
+
+ // new users are not enabled by default.
+ $access_status = access_get_show_hidden_status();
+ access_show_hidden_entities(true);
+
+ $user = get_entity($user_guid);
+
+ if ($code && $user) {
+ if (uservalidationbyemail_validate_email($user_guid, $code)) {
+
+ elgg_push_context('uservalidationbyemail_validate_user');
+ system_message(elgg_echo('email:confirm:success'));
+ $user = get_entity($user_guid);
+ $user->enable();
+ elgg_pop_context();
+
+ try {
+ login($user);
+ } catch(LoginException $e){
+ register_error($e->getMessage());
+ }
+ } else {
+ register_error(elgg_echo('email:confirm:fail'));
+ }
+ } else {
+ register_error(elgg_echo('email:confirm:fail'));
+ }
+
+ access_show_hidden_entities($access_status);
+ } else {
+ register_error(elgg_echo('email:confirm:fail'));
+ }
+
+ // forward to front page
+ forward('');
+}
+
+/**
+ * Make sure any admin users are automatically validated
+ *
+ * @param string $event
+ * @param string $type
+ * @param ElggUser $user
+ */
+function uservalidationbyemail_validate_new_admin_user($event, $type, $user) {
+ if ($user instanceof ElggUser && !$user->validated) {
+ elgg_set_user_validation_status($user->guid, TRUE, 'admin_user');
+ }
+}
+
+/**
+ * Registers public pages to allow in the case walled garden has been enabled.
+ */
+function uservalidationbyemail_public_pages($hook, $type, $return_value, $params) {
+ $return_value[] = 'uservalidationbyemail/confirm';
+ return $return_value;
+}
+
+/**
+ * Prevent a manual code login with login().
+ *
+ * @param string $event
+ * @param string $type
+ * @param ElggUser $user
+ * @return bool
+ *
+ * @throws LoginException
+ */
+function uservalidationbyemail_check_manual_login($event, $type, $user) {
+ $access_status = access_get_show_hidden_status();
+ access_show_hidden_entities(TRUE);
+
+ if (($user instanceof ElggUser) && !$user->isEnabled() && !$user->validated) {
+ // send new validation email
+ uservalidationbyemail_request_validation($user->getGUID());
+
+ // restore hidden entities settings
+ access_show_hidden_entities($access_status);
+
+ // throw error so we get a nice error message
+ throw new LoginException(elgg_echo('uservalidationbyemail:login:fail'));
+ }
+
+ access_show_hidden_entities($access_status);
+}
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..62a35d0bb
--- /dev/null
+++ b/mod/uservalidationbyemail/views/default/admin/users/unvalidated.php
@@ -0,0 +1,9 @@
+<?php
+/**
+ * List of unvalidated users
+ */
+
+echo elgg_view_form('uservalidationbyemail/bulk_action', array(
+ 'id' => 'uservalidationbyemail-form',
+ 'action' => 'action/uservalidationbyemail/bulk_action'
+));
diff --git a/mod/uservalidationbyemail/views/default/forms/uservalidationbyemail/bulk_action.php b/mod/uservalidationbyemail/views/default/forms/uservalidationbyemail/bulk_action.php
new file mode 100644
index 000000000..9199922d6
--- /dev/null
+++ b/mod/uservalidationbyemail/views/default/forms/uservalidationbyemail/bulk_action.php
@@ -0,0 +1,112 @@
+<?php
+/**
+ * Admin area to view, validate, resend validation email, or delete unvalidated users.
+ *
+ * @package Elgg.Core.Plugin
+ * @subpackage UserValidationByEmail.Administration
+ */
+
+$limit = get_input('limit', 10);
+$offset = get_input('offset', 0);
+
+// can't use elgg_list_entities() and friends because we don't use the default view for users.
+$ia = elgg_set_ignore_access(TRUE);
+$hidden_entities = access_get_show_hidden_status();
+access_show_hidden_entities(TRUE);
+
+$options = array(
+ 'type' => 'user',
+ 'wheres' => uservalidationbyemail_get_unvalidated_users_sql_where(),
+ 'limit' => $limit,
+ 'offset' => $offset,
+ 'count' => TRUE,
+);
+$count = elgg_get_entities($options);
+
+if (!$count) {
+ access_show_hidden_entities($hidden_entities);
+ elgg_set_ignore_access($ia);
+
+ echo elgg_autop(elgg_echo('uservalidationbyemail:admin:no_unvalidated_users'));
+ return TRUE;
+}
+
+$options['count'] = FALSE;
+
+$users = elgg_get_entities($options);
+
+access_show_hidden_entities($hidden_entities);
+elgg_set_ignore_access($ia);
+
+// setup pagination
+$pagination = elgg_view('navigation/pagination',array(
+ 'base_url' => 'admin/users/unvalidated',
+ 'offset' => $offset,
+ 'count' => $count,
+ 'limit' => $limit,
+));
+
+$bulk_actions_checkbox = '<label><input type="checkbox" id="uservalidationbyemail-checkall" />'
+ . elgg_echo('uservalidationbyemail:check_all') . '</label>';
+
+$validate = elgg_view('output/url', array(
+ 'href' => 'action/uservalidationbyemail/validate/',
+ 'text' => elgg_echo('uservalidationbyemail:admin:validate'),
+ 'title' => elgg_echo('uservalidationbyemail:confirm_validate_checked'),
+ 'class' => 'uservalidationbyemail-submit',
+ 'is_action' => true,
+ 'is_trusted' => true,
+));
+
+$resend_email = elgg_view('output/url', array(
+ 'href' => 'action/uservalidationbyemail/resend_validation/',
+ 'text' => elgg_echo('uservalidationbyemail:admin:resend_validation'),
+ 'title' => elgg_echo('uservalidationbyemail:confirm_resend_validation_checked'),
+ 'class' => 'uservalidationbyemail-submit',
+ 'is_action' => true,
+ 'is_trusted' => true,
+));
+
+$delete = elgg_view('output/url', array(
+ 'href' => 'action/uservalidationbyemail/delete/',
+ 'text' => elgg_echo('uservalidationbyemail:admin:delete'),
+ 'title' => elgg_echo('uservalidationbyemail:confirm_delete_checked'),
+ 'class' => 'uservalidationbyemail-submit',
+ 'is_action' => true,
+ 'is_trusted' => true,
+));
+
+$bulk_actions = <<<___END
+ <ul class="elgg-menu elgg-menu-general elgg-menu-hz float-alt">
+ <li>$resend_email</li><li>$validate</li><li>$delete</li>
+ </ul>
+
+ $bulk_actions_checkbox
+___END;
+
+if (is_array($users) && count($users) > 0) {
+ $html = '<ul class="elgg-list elgg-list-distinct">';
+ foreach ($users as $user) {
+ $html .= "<li id=\"unvalidated-user-{$user->guid}\" class=\"elgg-item uservalidationbyemail-unvalidated-user-item\">";
+ $html .= elgg_view('uservalidationbyemail/unvalidated_user', array('user' => $user));
+ $html .= '</li>';
+ }
+ $html .= '</ul>';
+}
+
+echo <<<___END
+<div class="elgg-module elgg-module-inline uservalidation-module">
+ <div class="elgg-head">
+ $bulk_actions
+ </div>
+ <div class="elgg-body">
+ $html
+ </div>
+</div>
+___END;
+
+if ($count > 5) {
+ echo $bulk_actions;
+}
+
+echo $pagination;
diff --git a/mod/uservalidationbyemail/views/default/uservalidationbyemail/css.php b/mod/uservalidationbyemail/views/default/uservalidationbyemail/css.php
new file mode 100644
index 000000000..afe334713
--- /dev/null
+++ b/mod/uservalidationbyemail/views/default/uservalidationbyemail/css.php
@@ -0,0 +1,12 @@
+<?php
+/**
+ * CSS for user validation by email
+ */
+?>
+
+.uservalidation-module > .elgg-head * {
+ color: white;
+}
+.uservalidation-module > .elgg-body * {
+ color: #333;
+} \ No newline at end of file
diff --git a/mod/uservalidationbyemail/views/default/uservalidationbyemail/js.php b/mod/uservalidationbyemail/views/default/uservalidationbyemail/js.php
new file mode 100644
index 000000000..948a54651
--- /dev/null
+++ b/mod/uservalidationbyemail/views/default/uservalidationbyemail/js.php
@@ -0,0 +1,28 @@
+
+elgg.provide('elgg.uservalidationbyemail');
+
+elgg.uservalidationbyemail.init = function() {
+ $('#uservalidationbyemail-checkall').click(function() {
+ var checked = $(this).attr('checked') == 'checked';
+ $('#uservalidationbyemail-form .elgg-body').find('input[type=checkbox]').attr('checked', checked);
+ });
+
+ $('.uservalidationbyemail-submit').click(function(event) {
+ var $form = $('#uservalidationbyemail-form');
+ event.preventDefault();
+
+ // check if there are selected users
+ if ($('#uservalidationbyemail-form .elgg-body').find('input[type=checkbox]:checked').length < 1) {
+ return false;
+ }
+
+ // confirmation
+ if (!confirm($(this).attr('title'))) {
+ return false;
+ }
+
+ $form.attr('action', $(this).attr('href')).submit();
+ });
+};
+
+elgg.register_hook_handler('init', 'system', elgg.uservalidationbyemail.init);
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..5c652a637
--- /dev/null
+++ b/mod/uservalidationbyemail/views/default/uservalidationbyemail/unvalidated_user.php
@@ -0,0 +1,50 @@
+<?php
+/**
+ * Formats and list an unvalidated user.
+ *
+ * @package Elgg.Core.Plugin
+ * @subpackage UserValidationByEmail.Administration
+ */
+
+$user = elgg_extract('user', $vars);
+
+$checkbox = elgg_view('input/checkbox', array(
+ 'name' => 'user_guids[]',
+ 'value' => $user->guid,
+ 'default' => false,
+));
+
+$created = elgg_echo('uservalidationbyemail:admin:user_created', array(elgg_view_friendly_time($user->time_created)));
+
+$validate = elgg_view('output/confirmlink', array(
+ 'confirm' => elgg_echo('uservalidationbyemail:confirm_validate_user', array($user->username)),
+ 'href' => "action/uservalidationbyemail/validate/?user_guids[]=$user->guid",
+ 'text' => elgg_echo('uservalidationbyemail:admin:validate')
+));
+
+$resend_email = elgg_view('output/confirmlink', array(
+ 'confirm' => elgg_echo('uservalidationbyemail:confirm_resend_validation', array($user->username)),
+ 'href' => "action/uservalidationbyemail/resend_validation/?user_guids[]=$user->guid",
+ 'text' => elgg_echo('uservalidationbyemail:admin:resend_validation')
+));
+
+$delete = elgg_view('output/confirmlink', array(
+ 'confirm' => elgg_echo('uservalidationbyemail:confirm_delete', array($user->username)),
+ 'href' => "action/uservalidationbyemail/delete/?user_guids[]=$user->guid",
+ 'text' => elgg_echo('uservalidationbyemail:admin:delete')
+));
+$menu = 'test';
+$block = <<<___END
+ <label>$user->username: "$user->name" &lt;$user->email&gt;</label>
+ <div class="uservalidationbyemail-unvalidated-user-details">
+ $created
+ </div>
+___END;
+
+$menu = <<<__END
+ <ul class="elgg-menu elgg-menu-general elgg-menu-hz float-alt">
+ <li>$resend_email</li><li>$validate</li><li>$delete</li>
+ </ul>
+__END;
+
+echo elgg_view_image_block($checkbox, $block, array('image_alt' => $menu));