Improve user profile

This commit is contained in:
Eike Foken
2011-09-21 02:05:10 +02:00
parent b792faf9b0
commit 76f3134756
6 changed files with 46 additions and 4 deletions

View File

@@ -32,6 +32,7 @@ class Users extends MY_Controller {
*/ */
public function __construct() { public function __construct() {
parent::__construct(); parent::__construct();
$this->load->model('experiment');
} }
/** /**
@@ -40,7 +41,7 @@ class Users extends MY_Controller {
* @param string $username * @param string $username
*/ */
public function profile($username) { public function profile($username) {
$data['user'] = $this->user->profile($username); $data['user'] = $this->user->profile(urldecode($username));
$this->load->view('users/profile', $data); $this->load->view('users/profile', $data);
} }
} }

View File

@@ -121,7 +121,11 @@ if (!function_exists('relative_time')) {
* @return string * @return string
*/ */
function relative_time($date, $show_seconds = false) { function relative_time($date, $show_seconds = false) {
if (is_integer($date)) {
$diff = time() - $date;
} else {
$diff = time() - strtotime($date); $diff = time() - strtotime($date);
}
if ($diff < 120 && !$show_seconds) { if ($diff < 120 && !$show_seconds) {
$output = _('just now'); $output = _('just now');

View File

@@ -159,6 +159,19 @@ class Experiment extends CI_Model {
return $query->result_array(); 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. * Search for a specific experiment and return a list of possible results.
* *

View File

@@ -145,6 +145,19 @@ class Project extends CI_Model {
return $this->_addShortNames($result); 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. * Counts all experiments for the specified project.
* *

View File

@@ -10,8 +10,19 @@
<h3><?=_('Personal information');?></h3> <h3><?=_('Personal information');?></h3>
<p> <p>
<strong><?=_('Name');?>:</strong> <?=$user->firstname;?> <?=$user->lastname;?><br /> <strong><?=_('Name');?>:</strong> <?=$user->firstname;?> <?=$user->lastname;?><br />
<strong><?=_('Group');?>:</strong> <?=anchor('users/group/' . urlencode($user->group), $user->group_description);?><br />
<strong><?=_('Institution');?>:</strong> <?=$user->institution;?><br /> <strong><?=_('Institution');?>:</strong> <?=$user->institution;?><br />
<strong><?=_('Phone number');?>:</strong> <?=$user->phone;?><br /> <strong><?=_('Phone number');?>:</strong> <?=$user->phone;?><br />
<strong><?=_('Last activity');?>:</strong> <?=relative_time((integer) $user->last_activity);?><br />
</p>
<p>
<?=safe_mailto($user->email, _('Send email'), 'class="button mail"');?>
</p>
<h3>ScattPort-<?=_('Statistics');?></h3>
<p>
<strong><?=_('Projects');?>:</strong> <?=$this->project->count($user->id);?><br />
<strong><?=_('Experiments');?>:</strong> <?=$this->experiment->count($user->id);?><br />
</p> </p>
</div> </div>

View File

@@ -574,8 +574,8 @@ a.copy {
padding-left: 30px; padding-left: 30px;
} }
a.clear { a.mail {
background: url(../images/icons/broom.png) 10px center no-repeat #f3f3f3; background: url(../images/icons/mail.png) 10px center no-repeat #f3f3f3;
padding-left: 30px; padding-left: 30px;
} }