aboutsummaryrefslogtreecommitdiff
path: root/mod/bulk_user_admin/views
diff options
context:
space:
mode:
Diffstat (limited to 'mod/bulk_user_admin/views')
-rw-r--r--mod/bulk_user_admin/views/default/admin/user.php98
-rw-r--r--mod/bulk_user_admin/views/default/admin/users/email_domain_stats.php12
-rw-r--r--mod/bulk_user_admin/views/default/bulk_user_admin/css.php26
-rw-r--r--mod/bulk_user_admin/views/default/bulk_user_admin/email_domain_stats.php49
-rw-r--r--mod/bulk_user_admin/views/default/bulk_user_admin/search_by_domain.php16
-rw-r--r--mod/bulk_user_admin/views/default/bulk_user_admin/user.php49
6 files changed, 250 insertions, 0 deletions
diff --git a/mod/bulk_user_admin/views/default/admin/user.php b/mod/bulk_user_admin/views/default/admin/user.php
new file mode 100644
index 000000000..c63f091ec
--- /dev/null
+++ b/mod/bulk_user_admin/views/default/admin/user.php
@@ -0,0 +1,98 @@
+<?php
+/**
+ * Display a list of users to delete in bulk.
+ *
+ * Also used to show the search by domain results
+ */
+
+// Are we performing a search
+$limit = get_input('limit', 10);
+$offset = get_input('offset', 0);
+$domain = get_input('domain');
+
+$context = elgg_get_context();
+
+if (!$domain) {
+ $title = elgg_echo('admin:user');
+} else {
+ $title = "Users in the domain $domain";
+}
+
+elgg_set_context('search');
+
+$options = array(
+ 'type' => 'user',
+ 'limit' => $limit,
+ 'offset' => $offset,
+ 'full_view' => false
+);
+
+if ($domain) {
+ $users = bulk_user_admin_get_users_by_email_domain($domain, $options);
+ $options['count'] = true;
+ $users_count = bulk_user_admin_get_users_by_email_domain($domain, $options);
+} else {
+ $users = elgg_get_entities($options);
+ $options['count'] = true;
+ $users_count = elgg_get_entities($options);
+}
+
+$pagination = elgg_view('navigation/pagination', array(
+ 'baseurl' => current_page_url(),
+ 'offset' => $offset,
+ 'count' => $users_count
+));
+
+$form_body = '';
+foreach ($users as $user) {
+ $form_body .= elgg_view('bulk_user_admin/user', array('entity' => $user));
+}
+
+$delete_button = elgg_view('input/submit', array(
+ 'value' => 'Delete checked',
+));
+
+$form_body .= $delete_button;
+
+$site = elgg_get_config('site');
+
+$checked_form = elgg_view('input/form', array(
+ 'action' => $site->url . 'action/bulk_user_admin/delete',
+ 'body' => $form_body
+));
+
+
+$domain_form = '';
+
+if ($domain) {
+ $delete_button = "<br /><br />" . elgg_view('input/submit', array(
+ 'value' => 'Delete all in domain',
+ ));
+
+ $hidden = elgg_view('input/hidden', array(
+ 'name' => 'domain',
+ 'value' => $domain
+ ));
+
+ $form_body = $delete_button . $hidden;
+
+ $domain_form = elgg_view('input/form', array(
+ 'action' => $site->url . 'action/bulk_user_admin/delete_by_domain',
+ 'body' => $form_body
+ ));
+
+}
+
+$summary = "<div>$users_count user(s) found</div>";
+
+if ($domain) {
+ $summary .= '<br />';
+ $summary .= elgg_view('output/url', array(
+ 'href' => elgg_http_remove_url_query_element(current_page_url(), 'domain'),
+ 'text' => 'All users'
+ ));
+}
+
+elgg_set_context('admin');
+
+echo $title . $summary . $pagination . $checked_form . $domain_form . $pagination; \ No newline at end of file
diff --git a/mod/bulk_user_admin/views/default/admin/users/email_domain_stats.php b/mod/bulk_user_admin/views/default/admin/users/email_domain_stats.php
new file mode 100644
index 000000000..0caa50331
--- /dev/null
+++ b/mod/bulk_user_admin/views/default/admin/users/email_domain_stats.php
@@ -0,0 +1,12 @@
+<?php
+/**
+ * Shows a list of email domains on the site and how many users have are part of the domain.
+ */
+
+$title = 'Email domain stats';
+
+$domain_list = elgg_view('bulk_user_admin/email_domain_stats', array(
+ 'domains' => bulk_user_admin_get_email_domain_stats()
+));
+
+echo $title . $domain_list; \ No newline at end of file
diff --git a/mod/bulk_user_admin/views/default/bulk_user_admin/css.php b/mod/bulk_user_admin/views/default/bulk_user_admin/css.php
new file mode 100644
index 000000000..3254c1700
--- /dev/null
+++ b/mod/bulk_user_admin/views/default/bulk_user_admin/css.php
@@ -0,0 +1,26 @@
+
+table.bulk_user_admin_email_domains {
+ width: 300px;
+}
+
+table.bulk_user_admin_email_domains th {
+ text-align: center;
+ font-weight: bold;
+ font-size: 125%;
+}
+
+table.bulk_user_admin_email_domains td {
+ padding: 3px;
+}
+
+table.bulk_user_admin_email_domains td.center {
+ text-align: center;
+}
+
+table.bulk_user_admin_email_domains tr.odd {
+ background-color: #fff;
+}
+
+table.bulk_user_admin_email_domains tr.even {
+ background-color: #dedede;
+} \ No newline at end of file
diff --git a/mod/bulk_user_admin/views/default/bulk_user_admin/email_domain_stats.php b/mod/bulk_user_admin/views/default/bulk_user_admin/email_domain_stats.php
new file mode 100644
index 000000000..3936eb0ea
--- /dev/null
+++ b/mod/bulk_user_admin/views/default/bulk_user_admin/email_domain_stats.php
@@ -0,0 +1,49 @@
+<?php
+
+$domains = $vars['domains'];
+
+?>
+<table class="bulk_user_admin_email_domains">
+ <tr>
+ <th>Domain</th>
+ <th>Registered users</th>
+ </tr>
+<?php
+
+
+$i = 0;
+foreach ($domains as $domain_info) {
+ if (!$domain_info->domain) {
+ continue;
+ }
+
+ $domain = elgg_view('output/url', array(
+ 'text' => $domain_info->domain,
+ 'href' => $domain_info->domain
+ ));
+
+ $url = elgg_http_add_url_query_elements($vars['url'] . 'admin/user', array('domain' => $domain_info->domain));
+
+ // can't use $_GET variables in admin
+ // otherwise admin_page_handler() tries to call the view: view/name?variable=value
+ // which clearly doesn't work
+ // so we'll pass the domain via post
+ $users = '<form id="domain:' . $domain_info->domain . '" action="' . elgg_get_site_url() . 'admin/user" method="post">';
+ $users .= elgg_view('input/hidden', array('name' => 'domain', 'value' => $domain_info->domain));
+ $users .= '</form>';
+ $users .= '<a href="javascript:document.forms[\'domain:' . $domain_info->domain . '\'].submit();">' . $domain_info->count . '</a>';
+
+ $class = ($i % 2) ? 'odd' : 'even';
+
+ echo <<<___HTML
+ <tr class="$class">
+ <td>$domain</td>
+ <td class="center">$users</td>
+ </tr>
+___HTML;
+
+ $i++;
+}
+
+?>
+</table> \ No newline at end of file
diff --git a/mod/bulk_user_admin/views/default/bulk_user_admin/search_by_domain.php b/mod/bulk_user_admin/views/default/bulk_user_admin/search_by_domain.php
new file mode 100644
index 000000000..5c65a3903
--- /dev/null
+++ b/mod/bulk_user_admin/views/default/bulk_user_admin/search_by_domain.php
@@ -0,0 +1,16 @@
+<?php
+/**
+ * Search by email domain
+ */
+?>
+<div id="search-box">
+ <form action="<?php echo current_page_url() ?>" method="get">
+ <b>Search by email domain</b>
+ <?php
+
+ echo elgg_view('input/text', array('name' => 'domain'));
+
+ ?>
+ <input type="submit" value="Search by domain" />
+ </form>
+</div>
diff --git a/mod/bulk_user_admin/views/default/bulk_user_admin/user.php b/mod/bulk_user_admin/views/default/bulk_user_admin/user.php
new file mode 100644
index 000000000..d05d92fd3
--- /dev/null
+++ b/mod/bulk_user_admin/views/default/bulk_user_admin/user.php
@@ -0,0 +1,49 @@
+<?php
+/**
+ * Show a user for bulk actions. Includes a checkbox on the left.
+ */
+if($vars['entity'] instanceof ElggUser){
+$icon = elgg_view_entity_icon($vars['entity'], 'small');
+
+$banned = $vars['entity']->isBanned();
+$user = $vars['entity'];
+
+$checkbox = "<input type=\"checkbox\" name=\"bulk_user_admin_guids[]\" value=\"$user->guid\">";
+$first_login = elgg_view_friendly_time($user->time_created);
+$last_login = elgg_view_friendly_time($user->last_login);
+$last_action = elgg_view_friendly_time($user->last_action);
+$objects = elgg_get_entities(array(
+ 'owner_guid' => $user->guid,
+ 'count' => true
+));
+
+$db_prefix = elgg_get_config('dbprefix');
+
+$q = "SELECT COUNT(id) as count FROM {$db_prefix}annotations WHERE owner_guid = $user->guid";
+$data = get_data($q);
+$annotations = (int) $data[0]->count;
+
+$q = "SELECT COUNT(id) as count FROM {$db_prefix}metadata WHERE owner_guid = $user->guid";
+$data = get_data($q);
+$metadata = (int) $data[0]->count;
+
+// the CSS for classless <label> is really, really annoying.
+$info = <<<___HTML
+<label style="font-size: inherit; font-weight: inherit; color: inherit;">
+<p>$checkbox $user->name | $user->username | $user->email | $user->guid </p>
+<p>Last login: $last_login | First login: $first_login | Last action: $last_action</p>
+<p>Objects: $objects | Annotations: $annotations | Metadata: $metadata</p>
+___HTML;
+
+if ($banned) {
+ $info .= '<div id="profile_banned">';
+ $info .= elgg_echo('profile:banned');
+ $info .= '<br />';
+ $info .= $user->ban_reason;
+ $info .= '</div>';
+}
+
+$info .= '</label>';
+
+echo elgg_view('page/components/image_block', array('image' => $icon, 'body' => $info));
+} \ No newline at end of file