From 82972be85e63db7affcc3c4bc423bffaf573e92d Mon Sep 17 00:00:00 2001 From: Zered Date: Mon, 5 Aug 2013 06:08:33 +0200 Subject: [PATCH] Adding a "User waiting for permanent deletion" table in admin page --- mod/admin.php | 29 ++++++++++++++++++++++++----- view/templates/admin_users.tpl | 29 +++++++++++++++++++++++++---- 2 files changed, 49 insertions(+), 9 deletions(-) diff --git a/mod/admin.php b/mod/admin.php index 1042bbd502..4539e4192b 100644 --- a/mod/admin.php +++ b/mod/admin.php @@ -655,7 +655,7 @@ function admin_page_users_post(&$a){ info( t('Registration successful. Email send to user').EOL ); } } - + if (x($_POST,'page_users_block')){ foreach($users as $uid){ q("UPDATE `user` SET `blocked`=1-`blocked` WHERE `uid`=%s", @@ -771,19 +771,35 @@ function admin_page_users(&$a){ $e['login_date'] = relative_date($e['login_date']); $e['lastitem_date'] = relative_date($e['lastitem_date']); $e['is_admin'] = ($e['email'] === $a->config['admin_email']); + $e['deleted'] = ($e['account_removed']?relative_date($e['account_expires_on']):False); return $e; } $users = array_map("_setup_users", $users); // Get rid of dashes in key names, Smarty3 can't handle them - foreach($users as $key => $user) { - $new_user = array(); - foreach($user as $k => $v) { + // and extracting deleted users + + $tmp_users = Array(); + $deleted = Array(); + + while(count($users)) { + $new_user = Array(); + foreach( array_pop($users) as $k => $v) { $k = str_replace('-','_',$k); $new_user[$k] = $v; } - $users[$key] = $new_user; + if($new_user['deleted']) { + array_push($deleted, $new_user); + } + else { + array_push($tmp_users, $new_user); + } + } + //Reversing the two array, and moving $tmp_users to $users + array_reverse($deleted); + while(count($tmp_users)) { + array_push($users, array_pop($tmp_users)); } $t = get_markup_template("admin_users.tpl"); @@ -794,6 +810,7 @@ function admin_page_users(&$a){ '$submit' => t('Submit'), '$select_all' => t('select all'), '$h_pending' => t('User registrations waiting for confirm'), + '$h_deleted' => t('User waiting for permanent deletion'), '$th_pending' => array( t('Request date'), t('Name'), t('Email') ), '$no_pending' => t('No registrations.'), '$approve' => t('Approve'), @@ -806,6 +823,7 @@ function admin_page_users(&$a){ '$h_users' => t('Users'), '$h_newuser' => t('New User'), + '$th_deleted' => array( t('Name'), t('Email'), t('Register date'), t('Last login'), t('Last item'), t('Deleted since') ), '$th_users' => array( t('Name'), t('Email'), t('Register date'), t('Last login'), t('Last item'), t('Account') ), '$confirm_delete_multi' => t('Selected users will be deleted!\n\nEverything these users had posted on this site will be permanently deleted!\n\nAre you sure?'), @@ -817,6 +835,7 @@ function admin_page_users(&$a){ '$baseurl' => $a->get_baseurl(true), '$pending' => $pending, + 'deleted' => $deleted, '$users' => $users, '$newusername' => array('new_user_name', t("Name"), '', t("Name of the new user.")), '$newusernickname' => array('new_user_nickname', t("Nickname"), '', t("Nickname of the new user.")), diff --git a/view/templates/admin_users.tpl b/view/templates/admin_users.tpl index 67ad40768f..f8d183d1ac 100644 --- a/view/templates/admin_users.tpl +++ b/view/templates/admin_users.tpl @@ -52,9 +52,6 @@

{{$no_pending}}

{{/if}} - - -

{{$h_users}}

{{if $users}} @@ -69,7 +66,7 @@ {{foreach $users as $u}} - + @@ -100,6 +97,30 @@ NO USERS?!? {{/if}} + {{if $deleted}} +

{{$h_deleted}}

+
{{$u.nickname}}{{$u.nickname}} {{$u.name}} {{$u.register_date}}
+ + + + {{foreach $th_deleted as $th}}{{/foreach}} + + + + {{foreach $deleted as $u}} + + + + + + + + + + {{/foreach}} + +
{{$th}}
{{$u.nickname}}{{$u.name}}{{$u.register_date}}{{$u.lastitem_date}}
+ {{/if}}

{{$h_newuser}}