diff --git a/www/docs/admin/index.php b/www/docs/admin/index.php
index 5e70ab2716..7d070aca3d 100644
--- a/www/docs/admin/index.php
+++ b/www/docs/admin/index.php
@@ -45,6 +45,11 @@
?>
Recently registered users
+
query("SELECT firstname,
diff --git a/www/docs/admin/users.php b/www/docs/admin/users.php
new file mode 100644
index 0000000000..861805fbb9
--- /dev/null
+++ b/www/docs/admin/users.php
@@ -0,0 +1,110 @@
+ array(
+ 'Name',
+ 'Email',
+ 'Confirmed?',
+ 'Registration time'
+ ),
+ 'rows' => array(),
+);
+
+$alert_data = array(
+ 'header' => array(
+ 'Email',
+ 'Created',
+ 'State',
+ 'Criteria',
+ ),
+ 'rows' => array(),
+);
+
+if ($search = get_http_var('s')) {
+ $q = $db->query("
+ SELECT firstname, lastname, email, user_id, confirmed, registrationtime
+ FROM users
+ WHERE email LIKE :search OR firstname LIKE :search OR lastname LIKE :search",
+ array(':search' => "%$search%"));
+
+ $USERURL = new \MySociety\TheyWorkForYou\Url('userview');
+ for ($row=0; $row<$q->rows(); $row++) {
+ $USERURL->insert(array('u' => $q->field($row, 'user_id')));
+ if ($q->field($row, 'confirmed') == 1) {
+ $confirmed = 'Yes';
+ $name = '' . _htmlspecialchars($q->field($row, 'firstname'))
+ . ' ' . _htmlspecialchars($q->field($row, 'lastname')) . '';
+ } else {
+ $confirmed = 'No';
+ $name = _htmlspecialchars($q->field($row, 'firstname') . ' ' . $q->field($row, 'lastname'));
+ }
+
+ $user_data['rows'][] = array(
+ $name,
+ $q->field($row, 'email'),
+ $confirmed,
+ $q->field($row, 'registrationtime'),
+ );
+ }
+
+ $q = $db->query("
+ SELECT email, criteria, created, confirmed, deleted
+ FROM alerts WHERE email = :search",
+ array(':search' => $search));
+
+ for ($row=0; $row<$q->rows(); $row++) {
+ $confirmed = $q->field($row, 'confirmed');
+ $deleted = $q->field($row, 'deleted');
+ if ($deleted == 2) {
+ $state = 'Suspended';
+ } elseif ($deleted == 1) {
+ $state = 'Deleted';
+ } elseif ($confirmed) {
+ $state = 'Confirmed';
+ } else {
+ $state = 'Unconfirmed';
+ }
+
+ $alert_data['rows'][] = array(
+ $q->field($row, 'email'),
+ $q->field($row, 'created'),
+ $state,
+ $q->field($row, 'criteria'),
+ );
+ }
+}
+
+$PAGE->page_start();
+$PAGE->stripe_start();
+
+?>
+
+block_start(array('title'=>'Users'));
+$PAGE->display_table($user_data);
+$PAGE->block_end();
+
+$PAGE->block_start(array('title'=>'Alerts'));
+$PAGE->display_table($alert_data);
+$PAGE->block_end();
+
+$menu = $PAGE->admin_menu();
+$PAGE->stripe_end(array(
+ array(
+ 'type' => 'html',
+ 'content' => $menu,
+ )
+));
+
+$PAGE->page_end();