// | https://www.anuko.com/time_tracker/credits.htm
// +----------------------------------------------------------------------+
-import('ttTeamHelper');
+import('ttGroupHelper');
// Class ttFavReportHelper is used to help with favorite report related tasks.
class ttFavReportHelper {
$user_options = array('max_rank'=>$max_rank);
$users = $user->getUsers($user_options); // Active and inactive users.
} elseif ($user->isClient()) {
- $users = ttTeamHelper::getUsersForClient(); // Active and inactive users for clients.
+ $users = ttGroupHelper::getUsersForClient(); // Active and inactive users for clients.
}
foreach ($users as $single_user) {
$user_ids[] = $single_user['id'];
} else {
$users_to_adjust = explode(',', $options['users']); // Users to adjust.
if ($user->isClient()) {
- $users = ttTeamHelper::getUsersForClient(); // Active and inactive users for clients.
+ $users = ttGroupHelper::getUsersForClient(); // Active and inactive users for clients.
foreach ($users as $single_user) {
$user_ids[] = $single_user['id'];
}
return false;
}
- // The getActiveUsers obtains all active users in a given group.
+ // The getActiveUsers obtains all active users excluding clients in a given group.
static function getActiveUsers($options = null) {
global $user;
global $i18n;
$group_id = $user->getGroup();
$org_id = $user->org_id;
+ $client_part = " and u.client_id is null";
+
if (isset($options['getAllFields']))
- $sql = "select u.*, r.name as role_name, r.rank from tt_users u left join tt_roles r on (u.role_id = r.id) where u.group_id = $group_id and u.org_id = $org_id and u.status = 1 order by upper(u.name)";
+ $sql = "select u.*, r.name as role_name, r.rank from tt_users u left join tt_roles r on (u.role_id = r.id) where u.group_id = $group_id and u.org_id = $org_id and u.status = 1 $client_part order by upper(u.name)";
else
- $sql = "select id, name from tt_users where group_id = $group_id and org_id = $org_id and status = 1 order by upper(name)";
+ $sql = "select u.id, u.name from tt_users u where u.group_id = $group_id and u.org_id = $org_id and u.status = 1 $client_part order by upper(u.name)";
$res = $mdb2->query($sql);
$user_list = array();
if (is_a($res, 'PEAR_Error'))
$user_list[] = $val;
}
- if (isset($options['putSelfFirst'])) {
- // Put own entry at the front.
- $cnt = count($user_list);
- for($i = 0; $i < $cnt; $i++) {
- if ($user_list[$i]['id'] == $user->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;
}
}
return $user_list;
}
+
+ // The getUsersForClient obtains all active and inactive users in a group that are relevant to a client.
+ static function getUsersForClient() {
+ global $user;
+ $mdb2 = getConnection();
+
+ $group_id = $user->getGroup();
+ $org_id = $user->org_id;
+
+ $sql = "select u.id, u.name from tt_user_project_binds upb".
+ " inner join tt_client_project_binds cpb on (upb.project_id = cpb.project_id and cpb.client_id = $user->client_id)".
+ " inner join tt_users u on (u.id = upb.user_id and u.group_id = $group_id and u.org_id = $org_id)".
+ " where (u.status = 1 or u.status = 0)".
+ " group by u.id".
+ " order by upper(u.name)";
+ $res = $mdb2->query($sql);
+ $user_list = array();
+ if (is_a($res, 'PEAR_Error'))
+ return false;
+ while ($val = $res->fetchRow()) {
+ $user_list[] = $val;
+ }
+ return $user_list;
+ }
}
// Class ttTeamHelper - contains helper functions that operate with groups.
class ttTeamHelper {
- // The getUsersForClient obtains all active and inactive users in a group that are relevant to a client.
- static function getUsersForClient() {
- global $user;
- $mdb2 = getConnection();
-
- $sql = "select u.id, u.name from tt_user_project_binds upb".
- " inner join tt_client_project_binds cpb on (upb.project_id = cpb.project_id and cpb.client_id = $user->client_id)".
- " inner join tt_users u on (u.id = upb.user_id)".
- " where (u.status = 1 or u.status = 0)".
- " group by u.id".
- " order by upper(u.name)";
- $res = $mdb2->query($sql);
- $user_list = array();
- if (is_a($res, 'PEAR_Error'))
- return false;
- while ($val = $res->fetchRow()) {
- $user_list[] = $val;
- }
- return $user_list;
- }
-
// The swapRolesWith swaps existing user role with that of another user.
static function swapRolesWith($user_id) {
global $user;
$this->role_id = $val['role_id'];
$this->role_name = $val['role_name'];
$this->rights = explode(',', $val['rights']);
- $this->is_client = !in_array('track_own_time', $this->rights);
$this->rank = $val['rank'];
$this->client_id = $val['client_id'];
+ $this->is_client = $this->client_id && !in_array('track_own_time', $this->rights);
$this->email = $val['email'];
$this->lang = $val['lang'];
$this->decimal_mark = $val['decimal_mark'];
<br>
<table cellspacing="0" cellpadding="4" width="100%" border="0">
<tr>
- <td align="center"> Anuko Time Tracker 1.18.29.4635 | Copyright © <a href="https://www.anuko.com/lp/tt_3.htm" target="_blank">Anuko</a> |
+ <td align="center"> Anuko Time Tracker 1.18.29.4636 | 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>
header('Location: access_denied.php');
exit();
}
-if (MODE_PROJECTS != $user->tracking_mode && MODE_PROJECTS_AND_TASKS != $user->tracking_mode) {
+if (MODE_PROJECTS != $user->getTrackingMode() && MODE_PROJECTS_AND_TASKS != $user->getTrackingMode()) {
header('Location: feature_disabled.php');
exit();
}
}
// End of access checks.
-$uncompleted_indicators = $user->getConfigOption('uncompleted_indicators');
+// Prepare a list of active users.
+if ($user->can('view_users'))
+ $options = array('status'=>ACTIVE,'include_clients'=>true,'include_login'=>true,'include_role'=>true);
+else /* if ($user->can('manage_users')) */
+ $options = array('status'=>ACTIVE,'max_rank'=>$user->rank-1,'include_clients'=>true,'include_self'=>true,'include_login'=>true,'include_role'=>true);
+$active_users = $user->getUsers($options);
-// Get users.
-$active_users = ttGroupHelper::getActiveUsers(array('getAllFields'=>true));
+// Prepare a list of inactive users.
if($user->can('manage_users')) {
- $can_delete_manager = (1 == count($active_users));
- $inactive_users = ttTeamHelper::getInactiveUsers($user->group_id, true);
+ $options = array('status'=>INACTIVE,'max_rank'=>$user->rank-1,'include_clients'=>true,'include_login'=>true,'include_role'=>true);
+ $inactive_users = $user->getUsers($options);
}
+$uncompleted_indicators = $user->getConfigOption('uncompleted_indicators');
if ($uncompleted_indicators) {
// Check each active user if they have an uncompleted time entry.
foreach ($active_users as $key => $user) {
import('form.Form');
import('form.ActionForm');
import('DateAndTime');
-import('ttTeamHelper');
import('ttGroupHelper');
import('Period');
import('ttProjectHelper');
$users = $user->getUsers($options); // Active and inactive users.
}
elseif ($user->isClient())
- $users = ttTeamHelper::getUsersForClient(); // Active and inactive users for clients.
+ $users = ttGroupHelper::getUsersForClient(); // Active and inactive users for clients.
foreach ($users as $single_user) {
$user_list[$single_user['id']] = $single_user['name'];
} else {
$group_id = $user->getGroup();
}
-$uncompleted_indicators = $user->getConfigOption('uncompleted_indicators');
$form = new Form('usersForm');
if ($user->can('manage_subgroups')) {
$inactive_users = $user->getUsers($options);
}
+$uncompleted_indicators = $user->getConfigOption('uncompleted_indicators');
if ($uncompleted_indicators) {
// Check each active user if they have an uncompleted time entry.
foreach ($active_users as $key => $user) {