Improve user profile
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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');
|
||||
|
||||
@@ -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.
|
||||
*
|
||||
|
||||
@@ -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.
|
||||
*
|
||||
|
||||
@@ -10,8 +10,19 @@
|
||||
<h3><?=_('Personal information');?></h3>
|
||||
<p>
|
||||
<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><?=_('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>
|
||||
</div>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user