From 1e307e9869b15cf1f76dcfda8f6fd49d05014d14 Mon Sep 17 00:00:00 2001 From: Fabio Comuni Date: Wed, 29 Jun 2011 12:05:09 +0200 Subject: [PATCH] Fix bug #98, add "never" to relative_date(), fix batch operations --- include/datetime.php | 4 ++++ mod/admin.php | 25 +++++++------------------ view/admin_users.tpl | 7 +++---- 3 files changed, 14 insertions(+), 22 deletions(-) diff --git a/include/datetime.php b/include/datetime.php index a5b388e76..ade202cad 100644 --- a/include/datetime.php +++ b/include/datetime.php @@ -178,6 +178,10 @@ function relative_date($posted_date) { $abs = strtotime($localtime); $etime = time() - $abs; + if ($abs==False) { + return t('never'); + } + if ($etime < 1) { return t('less than a second ago'); } diff --git a/mod/admin.php b/mod/admin.php index 920adf05d..9a92f4e15 100644 --- a/mod/admin.php +++ b/mod/admin.php @@ -327,11 +327,8 @@ function admin_page_site(&$a) { * Users admin page */ function admin_page_users_post(&$a){ - $users=array(); $pending=array(); - foreach($_POST as $k=>$v){ - if (substr($k,0,5)=="user_") $users[] = substr($k,5,strlen($k)-5); - if (substr($k,0,8)=="pending_") $users[] = substr($k,8,strlen($k)-8); - } + $pending = ( x(£_POST, 'pending') ? $_POST['pending'] : Array() ); + $users = ( x($_POST, 'user') ? $_POST['user'] : Array() ); if (x($_POST,'page_users_block')){ foreach($users as $uid){ @@ -350,13 +347,13 @@ function admin_page_users_post(&$a){ } if (x($_POST,'page_users_approve')){ - require_once("include/regmod.php"); + require_once("mod/regmod.php"); foreach($pending as $hash){ user_allow($hash); } } if (x($_POST,'page_users_deny')){ - require_once("include/regmod.php"); + require_once("mod/regmod.php"); foreach($pending as $hash){ user_deny($hash); } @@ -409,22 +406,15 @@ function admin_page_users(&$a){ $a->set_pager_itemspage(100); } - $users = q("SELECT `user` . * , `contact`.`name` , `contact`.`url` , `contact`.`micro` , `lastitem`.`lastitem_date` - FROM ( - SELECT MAX(`item`.`changed`) as `lastitem_date`, `item`.`uid` - FROM `item` - WHERE `item`.`type` = 'wall' - GROUP BY `item`.`uid` - ) AS `lastitem` , `user` + $users = q("SELECT `user` . * , `contact`.`name` , `contact`.`url` , `contact`.`micro` + FROM `user` LEFT JOIN `contact` ON `user`.`uid` = `contact`.`uid` WHERE `user`.`verified` =1 AND `contact`.`self` =1 - AND `lastitem`.`uid` = `user`.`uid` ORDER BY `contact`.`name` LIMIT %d, %d ", intval($a->pager['start']), intval($a->pager['itemspage']) - ); function _setup_users($e){ @@ -437,7 +427,6 @@ function admin_page_users(&$a){ $e['page-flags'] = $accounts[$e['page-flags']]; $e['register_date'] = relative_date($e['register_date']); $e['login_date'] = relative_date($e['login_date']); - $e['lastitem_date'] = relative_date($e['lastitem_date']); return $e; } $users = array_map("_setup_users", $users); @@ -459,7 +448,7 @@ function admin_page_users(&$a){ '$unblock' => t('Unblock'), '$h_users' => t('Users'), - '$th_users' => array( t('Name'), t('Email'), t('Register date'), t('Last login'), t('Last item'), t('Account') ), + '$th_users' => array( t('Name'), t('Email'), t('Register date'), t('Last login'), 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?'), '$confirm_delete' => t('The user {0} will be deleted!\n\nEverything this user has posted on this site will be permanently deleted!\n\nAre you sure?'), diff --git a/view/admin_users.tpl b/view/admin_users.tpl index 952a8992b..6e677f7dc 100644 --- a/view/admin_users.tpl +++ b/view/admin_users.tpl @@ -31,7 +31,7 @@ $u.created $u.name $u.email - + @@ -68,12 +68,11 @@ $u.email $u.register_date $u.login_date - $u.lastitem_date $u.page-flags - + - + {{ endfor }}