From cc873980abb9d1d9206f333bd465ecd6a55b609b Mon Sep 17 00:00:00 2001 From: brettp Date: Sun, 20 Feb 2011 04:42:49 +0000 Subject: Fixes #2658. Merged uservalidationbyemail changes from 1.7 to 1.8. This plugin needs cleanup. git-svn-id: http://code.elgg.org/elgg/trunk@8357 36083f99-b078-4883-b0ff-0f9b5a30f544 --- .../views/default/admin/users/unvalidated.php | 5 +- .../forms/uservalidationbyemail/bulk_action.php | 92 ++++++++++++++++------ .../views/default/uservalidationbyemail/js.php | 27 +++++++ .../uservalidationbyemail/unvalidated_user.php | 2 +- 4 files changed, 98 insertions(+), 28 deletions(-) create mode 100644 mod/uservalidationbyemail/views/default/uservalidationbyemail/js.php (limited to 'mod/uservalidationbyemail/views/default') diff --git a/mod/uservalidationbyemail/views/default/admin/users/unvalidated.php b/mod/uservalidationbyemail/views/default/admin/users/unvalidated.php index 0b94ab039..f34447b65 100644 --- a/mod/uservalidationbyemail/views/default/admin/users/unvalidated.php +++ b/mod/uservalidationbyemail/views/default/admin/users/unvalidated.php @@ -1,3 +1,6 @@ 'unvalidated-users', + '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 index d5060d7e5..fb0d9e5b1 100644 --- a/mod/uservalidationbyemail/views/default/forms/uservalidationbyemail/bulk_action.php +++ b/mod/uservalidationbyemail/views/default/forms/uservalidationbyemail/bulk_action.php @@ -16,22 +16,33 @@ access_show_hidden_entities(TRUE); $options = array( 'type' => 'user', - 'metadata_name' => 'validated', - 'metadata_value' => 0, + 'wheres' => uservalidationbyemail_get_unvalidated_users_sql_where(), 'limit' => $limit, - 'offset' => $offset + 'offset' => $offset, + 'count' => TRUE, ); -$users = elgg_get_entities_from_metadata($options); +$count = elgg_get_entities($options); + +if (!$count) { + access_show_hidden_entities($hidden_entities); + elgg_set_ignore_access($ia); + + echo elgg_view('page_elements/contentwrapper', array( + 'body' => elgg_echo('uservalidationbyemail:admin:no_unvalidated_users') + )); + return; +} -$options['count'] = TRUE; -$count = elgg_get_entities_from_metadata($options); +$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( - 'baseurl' => elgg_get_site_url() . 'pg/admin/users/unvalidated', +$pagination = elgg_view('navigation/pagination',array( + 'baseurl' => $vars['url'] . '/pg/uservalidationbyemail/admin/', 'offset' => $offset, 'count' => $count, 'limit' => $limit, @@ -39,25 +50,54 @@ $pagination = elgg_view('navigation/pagination', array( echo $pagination; -if ($users) { - foreach ($users as $user) { - $form_body .= elgg_view('uservalidationbyemail/unvalidated_user', array('theuser' => $user)); - } -} else { - echo elgg_echo('uservalidationbyemail:admin:no_unvalidated_users'); - return; -} +$bulk_actions_checkbox = ''; + +$validate = elgg_view('output/url', array( + 'is_action' => TRUE, + 'js' => 'title="' . elgg_echo('uservalidationbyemail:confirm_validate_checked') . '"', + 'href' => $vars['url'] . "action/uservalidationbyemail/validate/", + 'text' => elgg_echo('uservalidationbyemail:admin:validate'), + 'class' => 'unvalidated-users-bulk-post', +)); -$form_body .= elgg_echo('uservalidationbyemail:admin:with_checked') . elgg_view('input/dropdown', array( - 'name' => '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'), - ), - 'value' => 'resend_validation', +$resend_email = elgg_view('output/url', array( + 'is_action' => TRUE, + 'js' => 'title="' . elgg_echo('uservalidationbyemail:confirm_resend_validation_checked') . '"', + 'href' => $vars['url'] . "action/uservalidationbyemail/resend_validation/", + 'text' => elgg_echo('uservalidationbyemail:admin:resend_validation'), + 'class' => 'unvalidated-users-bulk-post', )); -$form_body .= '
' . elgg_view('input/submit', array('value' => elgg_echo('submit'))); +$delete = elgg_view('output/url', array( + 'is_action' => TRUE, + 'js' => 'title="' . elgg_echo('uservalidationbyemail:confirm_delete_checked') . '"', + 'href' => $vars['url'] . "action/uservalidationbyemail/delete/", + 'text' => elgg_echo('uservalidationbyemail:admin:delete'), + 'class' => 'unvalidated-users-bulk-post', +)); + +$bulk_actions = <<<___END +
+
+ $resend_email | $validate | $delete +
+ + $bulk_actions_checkbox +
+___END; + +//$bulk_actions = elgg_view('page_elements/contentwrapper', array('body' => $bulk_actions)); + +echo $bulk_actions; + + +foreach ($users as $user) { + echo elgg_view('uservalidationbyemail/unvalidated_user', array('user' => $user)); +} + +if ($count > 5) { + echo $bulk_actions; +} -echo $form_body; \ No newline at end of file +echo $pagination; \ 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..c1ca58559 --- /dev/null +++ b/mod/uservalidationbyemail/views/default/uservalidationbyemail/js.php @@ -0,0 +1,27 @@ +elgg.provide('elgg.uservalidationbyemail'); + +elgg.uservalidationbyemail.init = function() { + $('.unvalidated-users-checkall').click(function() { + checked = $(this).attr('checked'); + $('form[name=unvalidated-users]').find('input[type=checkbox]').attr('checked', checked); + }); + + $('.unvalidated-users-bulk-post').click(function(event) { + $form = $('form[name=unvalidated-users]'); + event.preventDefault(); + + // check there are selected users + if ($form.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_event_handler('init', 'system', elgg.uservalidationbyemail.init); \ 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 index 295f4170e..209dbe02b 100644 --- a/mod/uservalidationbyemail/views/default/uservalidationbyemail/unvalidated_user.php +++ b/mod/uservalidationbyemail/views/default/uservalidationbyemail/unvalidated_user.php @@ -6,7 +6,7 @@ * @subpackage UserValidationByEmail.Administration */ -$user = elgg_extract('theuser', $vars); +$user = elgg_extract('user', $vars); // doesn't work. //$checkbox = elgg_view('input/checkboxes', array( -- cgit v1.2.3