return true;
}
+
+ // getUsers obtains users in a group, as specififed by options.
+ function getUsers($options) {
+
+ $mdb2 = getConnection();
+
+ $skipClients = !isset($options['include_clients']);
+ $includeSelf = isset($options['include_self']);
+
+ $select_part = 'select u.id, u.name';
+ if (!isset($options['include_clients'])) $select_part .= ', r.rights';
+
+ $from_part = ' from tt_users u';
+
+ $left_joins = null;
+ if (isset($options['max_rank']) || $skipClients)
+ $left_joins .= ' left join tt_roles r on (u.role_id = r.id)';
+
+ $where_part = " where u.team_id = $this->team_id";
+ if (isset($options['status'])) $where_part .= ' and u.status = '.(int)$options['status'];
+ if ($includeSelf) {
+ $where_part .= " and (u.id = $this->id || r.rank <= ".(int)$options['max_rank'].')';
+ } else {
+ if (isset($options['max_rank'])) $where_part .= ' and r.rank <= '.(int)$options['max_rank'];
+ }
+
+ $sql = $select_part.$from_part.$left_joins.$where_part;
+ $res = $mdb2->query($sql);
+ $user_list = array();
+ if (is_a($res, 'PEAR_Error'))
+ return false;
+
+ while ($val = $res->fetchRow()) {
+ if ($skipClients) {
+ $isClient = in_array('track_own_time', explode(',', $val['rights'])) ? 0 : 1; // Clients do not have track_own_time right.
+ if ($isClient)
+ continue; // Skip adding clients.
+ }
+ $user_list[] = $val;
+ }
+
+ if (isset($options['self_first'])) {
+ // Put own entry at the front.
+ $cnt = count($user_list);
+ for($i = 0; $i < $cnt; $i++) {
+ if ($user_list[$i]['id'] == $this->id) {
+ $self = $user_list[$i]; // Found self.
+ array_unshift($user_list, $self); // Put own entry at the front.
+ array_splice($user_list, $i+1, 1); // Remove duplicate.
+ }
+ }
+ }
+ return $user_list;
+ }
}
<br>
<table cellspacing="0" cellpadding="4" width="100%" border="0">
<tr>
- <td align="center"> Anuko Time Tracker 1.17.70.4162 | Copyright © <a href="https://www.anuko.com/lp/tt_3.htm" target="_blank">Anuko</a> |
+ <td align="center"> Anuko Time Tracker 1.17.71.4163 | Copyright © <a href="https://www.anuko.com/lp/tt_3.htm" target="_blank">Anuko</a> |
<a href="https://www.anuko.com/lp/tt_4.htm" target="_blank">{$i18n.footer.credits}</a> |
<a href="https://www.anuko.com/lp/tt_5.htm" target="_blank">{$i18n.footer.license}</a> |
<a href="https://www.anuko.com/lp/tt_7.htm" target="_blank">{$i18n.footer.improve}</a>
<tr><td class="sectionHeaderNoBorder">{$i18n.form.users.active_users}</td></tr>
{/if}
<tr>
- <td width="35%" class="tableHeader">{$i18n.label.person_name}</td>
- <td width="35%" class="tableHeader">{$i18n.label.login}</td>
- <td width="10%" class="tableHeader">{$i18n.form.users.role}</td>
+ <td width="30%" class="tableHeader">{$i18n.label.person_name}</td>
+ <td width="30%" class="tableHeader">{$i18n.label.login}</td>
+ <td width="20%" class="tableHeader">{$i18n.form.users.role}</td>
<td width="10%" class="tableHeader">{$i18n.label.edit}</td>
<td width="10%" class="tableHeader">{$i18n.label.delete}</td>
</tr>
<table cellspacing="1" cellpadding="3" border="0" width="100%">
<tr><td class="sectionHeaderNoBorder">{$i18n.form.users.inactive_users}</td></tr>
<tr>
- <td width="35%" class="tableHeader">{$i18n.label.person_name}</td>
- <td width="35%" class="tableHeader">{$i18n.label.login}</td>
- <td width="10%" class="tableHeader">{$i18n.form.users.role}</td>
+ <td width="30%" class="tableHeader">{$i18n.label.person_name}</td>
+ <td width="30%" class="tableHeader">{$i18n.label.login}</td>
+ <td width="20%" class="tableHeader">{$i18n.form.users.role}</td>
<td width="10%" class="tableHeader">{$i18n.label.edit}</td>
<td width="10%" class="tableHeader">{$i18n.label.delete}</td>
</tr>
import('ttTeamHelper');
// Access checks.
-if (!ttAccessAllowed('view_own_charts')) {
+if (!(ttAccessAllowed('view_own_charts') || ttAccessAllowed('view_charts'))) {
header('Location: access_denied.php');
exit();
}
// User dropdown. Changes the user "on behalf" of whom we are working.
if ($user->can('view_charts')) {
- $user_list = ttTeamHelper::getActiveUsers(array('putSelfFirst'=>true));
- if (count($user_list) > 1) {
+ if ($user->can('view_own_charts'))
+ $options = array('status'=>ACTIVE,'max_rank'=>$user->rank-1,'include_self'=>true,'self_first'=>true);
+ else
+ $options = array('status'=>ACTIVE,'max_rank'=>$user->rank-1);
+ $user_list = $user->getUsers($options);
+ if (count($user_list) >= 1) {
$chart_form->addInput(array('type'=>'combobox',
'onchange'=>'this.form.submit();',
'name'=>'onBehalfUser',