From 76f3134756824d993512086b0e503b500bc7ecf5 Mon Sep 17 00:00:00 2001 From: Eike Foken Date: Wed, 21 Sep 2011 02:05:10 +0200 Subject: [PATCH] Improve user profile --- application/controllers/users.php | 3 ++- application/helpers/MY_date_helper.php | 6 +++++- application/models/experiment.php | 13 +++++++++++++ application/models/project.php | 13 +++++++++++++ application/views/users/profile.php | 11 +++++++++++ assets/css/style.css | 4 ++-- 6 files changed, 46 insertions(+), 4 deletions(-) diff --git a/application/controllers/users.php b/application/controllers/users.php index de1eb47..116f22f 100644 --- a/application/controllers/users.php +++ b/application/controllers/users.php @@ -32,6 +32,7 @@ class Users extends MY_Controller { */ public function __construct() { parent::__construct(); + $this->load->model('experiment'); } /** @@ -40,7 +41,7 @@ class Users extends MY_Controller { * @param string $username */ public function profile($username) { - $data['user'] = $this->user->profile($username); + $data['user'] = $this->user->profile(urldecode($username)); $this->load->view('users/profile', $data); } } diff --git a/application/helpers/MY_date_helper.php b/application/helpers/MY_date_helper.php index 6f0287f..f31c012 100644 --- a/application/helpers/MY_date_helper.php +++ b/application/helpers/MY_date_helper.php @@ -121,7 +121,11 @@ if (!function_exists('relative_time')) { * @return string */ function relative_time($date, $show_seconds = false) { - $diff = time() - strtotime($date); + if (is_integer($date)) { + $diff = time() - $date; + } else { + $diff = time() - strtotime($date); + } if ($diff < 120 && !$show_seconds) { $output = _('just now'); diff --git a/application/models/experiment.php b/application/models/experiment.php index 034c4cc..93f105e 100644 --- a/application/models/experiment.php +++ b/application/models/experiment.php @@ -159,6 +159,19 @@ class Experiment extends CI_Model { return $query->result_array(); } + /** + * Counts all experiments. + * + * @param string $userId + * @return integer + */ + public function count($userId = false) { + if ($userId) { + $this->db->where('creator_id', $userId); + } + return $this->db->count_all_results('experiments'); + } + /** * Search for a specific experiment and return a list of possible results. * diff --git a/application/models/project.php b/application/models/project.php index 7452c21..abce4e0 100644 --- a/application/models/project.php +++ b/application/models/project.php @@ -145,6 +145,19 @@ class Project extends CI_Model { return $this->_addShortNames($result); } + /** + * Counts all projects. + * + * @param string $userId + * @return integer + */ + public function count($userId = false) { + if ($userId) { + $this->db->where('owner', $userId); + } + return $this->db->count_all_results('projects'); + } + /** * Counts all experiments for the specified project. * diff --git a/application/views/users/profile.php b/application/views/users/profile.php index 3251458..01b2c87 100644 --- a/application/views/users/profile.php +++ b/application/views/users/profile.php @@ -10,8 +10,19 @@

: firstname;?> lastname;?>
+ : group), $user->group_description);?>
: institution;?>
: phone;?>
+ : last_activity);?>
+

+

+ email, _('Send email'), 'class="button mail"');?> +

+ +

ScattPort-

+

+ : project->count($user->id);?>
+ : experiment->count($user->id);?>

diff --git a/assets/css/style.css b/assets/css/style.css index 9aa104d..983231c 100644 --- a/assets/css/style.css +++ b/assets/css/style.css @@ -574,8 +574,8 @@ a.copy { padding-left: 30px; } -a.clear { - background: url(../images/icons/broom.png) 10px center no-repeat #f3f3f3; +a.mail { + background: url(../images/icons/mail.png) 10px center no-repeat #f3f3f3; padding-left: 30px; }