$id = (int)$fields['id'];
if (isset($fields['name'])) $name_part = 'name = '.$mdb2->quote($fields['name']);
+ if (isset($fields['rank'])) $rank_part = ', rank = '.(int)$fields['rank'];
if (isset($fields['description'])) $descr_part = ', description = '.$mdb2->quote($fields['description']);
if (isset($fields['status'])) $status_part = ', status = '.(int)$fields['status'];
if (isset($fields['rights'])) $rights_part = ', rights = '.$mdb2->quote($fields['rights']);
- $parts = trim($name_part.$descr_part.$status_part.$rights_part, ',');
+ $parts = trim($name_part.$rank_part.$descr_part.$status_part.$rights_part, ',');
$sql = "update tt_roles set $parts where id = $id and team_id = $user->team_id";
$affected = $mdb2->exec($sql);
return (!is_a($affected, 'PEAR_Error'));
return $result;
}
+ // getInactiveRolesForUser - returns an array of relevant active roles for user with rank less than self.
+ // "Relevant" means that client roles are filtered out if Client plugin is disabled.
+ static function getInactiveRolesForUser()
+ {
+ global $user;
+ $result = array();
+ $mdb2 = getConnection();
+
+ $sql = "select id, name, description, rank, rights from tt_roles where team_id = $user->team_id and rank < $user->rank and status = 0 order by rank";
+ $res = $mdb2->query($sql);
+ $result = array();
+ if (!is_a($res, 'PEAR_Error')) {
+ while ($val = $res->fetchRow()) {
+ $val['is_client'] = in_array('track_own_time', explode(',', $val['rights'])) ? 0 : 1; // Clients do not have data entry right.
+ if ($val['is_client'] && !$user->isPluginEnabled('cl'))
+ continue; // Skip adding a client role.
+ $result[] = $val;
+ }
+ }
+ return $result;
+ }
+
// getAllRoles - obtains all roles defined for team.
static function getAllRoles($team_id) {
$mdb2 = getConnection();
<br>
<table cellspacing="0" cellpadding="4" width="100%" border="0">
<tr>
- <td align="center"> Anuko Time Tracker 1.17.50.4090 | Copyright © <a href="https://www.anuko.com/lp/tt_3.htm" target="_blank">Anuko</a> |
+ <td align="center"> Anuko Time Tracker 1.17.51.4091 | 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>
<td align="right">{$i18n.label.currency}:</td>
<td>{$forms.profileForm.currency.control}</td>
</tr>
- {if defined(DEBUG_ROLES)}
+ {if $user->can('manage_roles')}
<tr>
<td align="right" nowrap>{$i18n.label.roles}:</td>
<td><a href="roles.php">{$i18n.label.configure}</a></td>
if (ttRoleHelper::update(array(
'id' => $cl_role_id,
'name' => $cl_name,
+ 'rank' => $cl_rank,
'description' => $cl_description,
'status' => $cl_status))) {
header('Location: roles.php');
exit();
}
-$smarty->assign('active_roles', ttTeamHelper::getActiveRoles($user->team_id));
-$smarty->assign('inactive_roles', ttTeamHelper::getInactiveRoles($user->team_id));
+$smarty->assign('active_roles', ttTeamHelper::getActiveRolesForUser());
+$smarty->assign('inactive_roles', ttTeamHelper::getInactiveRolesForUser());
$smarty->assign('title', $i18n->getKey('title.roles'));
$smarty->assign('content_page_name', 'roles.tpl');
$smarty->display('index.tpl');