var $first_unit_threshold = 0;// Threshold for 1st unit for Work units plugin.
var $unit_totals_only = 0; // Totals only option for the Work units plugin.
+ var $active_users = 0; // Count of active users in group.
+ // We need a non-zero count to display some menus.
+
// Constructor.
function __construct($id, $org_id) {
$mdb2 = getConnection();
}
*/
}
+
+ // Determine active user count in a separate query.
+ // TODO: If performance becomes an issue, ivestigate combining 2 queries in one.
+ // At this time we only need to know if at least 1 active user exists.
+ $sql = "select count(*) as user_count from tt_users".
+ " where group_id = $id and org_id = $org_id and status = 1";
+ $res = $mdb2->query($sql);
+ if (is_a($res, 'PEAR_Error')) {
+ return;
+ }
+ $val = $res->fetchRow();
+ $this->active_users = $val['user_count'];
}
}
return;
}
- // setOnBehalfUser sets on behalf user both the object and the session.
+ // setOnBehalfUser sets on behalf user both the object and the session.
function setOnBehalfUser($user_id) {
// Unset things first.
$this->behalf_name = $onBehalfUserName;
return;
}
+
+ // The exists() function determines if an active user exists in context of a page.
+ // If we are working as self, true.
+ // If we are working in a subgroup with active users, true.
+ // If we are working in a subgroup without active users, false.
+ function exists() {
+ if (!$this->behalfGroup)
+ return true; // Working as self.
+ else if ($this->behalfGroup->active_users)
+ return true; // Subgroup has users.
+
+ return false;
+ }
}
<br>
<table cellspacing="0" cellpadding="4" width="100%" border="0">
<tr>
- <td align="center"> Anuko Time Tracker 1.18.29.4595 | Copyright © <a href="https://www.anuko.com/lp/tt_3.htm" target="_blank">Anuko</a> |
+ <td align="center"> Anuko Time Tracker 1.18.29.4596 | 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>
<table cellspacing="0" cellpadding="3" width="100%" border="0">
<tr>
<td align="center" bgcolor="#d9d9d9" nowrap height="17" background="images/subm_bg.gif">
- {if $user->can('track_own_time') || $user->can('track_time')}
+ {if $user->exists() && ($user->can('track_own_time') || $user->can('track_time'))}
<a class="mainMenu" href="time.php">{$i18n.menu.time}</a>
{/if}
- {if $user->isPluginEnabled('ex') && ($user->can('track_own_expenses') || $user->can('track_expenses'))}
+ {if $user->exists() && $user->isPluginEnabled('ex') && ($user->can('track_own_expenses') || $user->can('track_expenses'))}
· <a class="mainMenu" href="expenses.php">{$i18n.menu.expenses}</a>
{/if}
- {if $user->can('view_own_reports') || $user->can('view_reports')}
+ {if $user->exists() && ($user->can('view_own_reports') || $user->can('view_reports'))}
· <a class="mainMenu" href="reports.php">{$i18n.menu.reports}</a>
{/if}
- {if $user->isPluginEnabled('iv') && ($user->can('view_own_invoices') || $user->can('manage_invoices'))}
+ {if $user->exists() && $user->isPluginEnabled('iv') && ($user->can('view_own_invoices') || $user->can('manage_invoices'))}
· <a class="mainMenu" href="invoices.php">{$i18n.title.invoices}</a>
{/if}
- {if ($user->isPluginEnabled('ch') && ($user->can('view_own_charts') || $user->can('view_charts'))) && ($smarty.const.MODE_PROJECTS == $user->getTrackingMode()
- || $smarty.const.MODE_PROJECTS_AND_TASKS == $user->getTrackingMode() || $user->isPluginEnabled('cl'))}
+ {if ($user->exists() && $user->isPluginEnabled('ch') && ($user->can('view_own_charts') || $user->can('view_charts'))) &&
+ ($smarty.const.MODE_PROJECTS == $user->getTrackingMode() || $smarty.const.MODE_PROJECTS_AND_TASKS == $user->getTrackingMode() ||
+ $user->isPluginEnabled('cl'))}
· <a class="mainMenu" href="charts.php">{$i18n.menu.charts}</a>
{/if}
{if ($user->can('view_own_projects') || $user->can('manage_projects')) && ($smarty.const.MODE_PROJECTS == $user->getTrackingMode() || $smarty.const.MODE_PROJECTS_AND_TASKS == $user->getTrackingMode())}
<table cellspacing="0" cellpadding="3" width="100%" border="0">
<tr>
<td align="center" bgcolor="#d9d9d9" height="17" style="background-repeat: repeat-x;" background="../images/subm_bg.gif">
- {if $user->can('track_own_time') || $user->can('track_time')}
+ {if $user->exists() && ($user->can('track_own_time') || $user->can('track_time'))}
<a class="mainMenu" href="time.php">{$i18n.menu.time}</a>
{/if}
- {if $user->isPluginEnabled('ex') && ($user->can('track_own_expenses') || $user->can('track_expenses'))}
+ {if $user->exists() && $user->isPluginEnabled('ex') && ($user->can('track_own_expenses') || $user->can('track_expenses'))}
· <a class="mainMenu" href="expenses.php">{$i18n.menu.expenses}</a>
{/if}
- {if ($user->can('view_own_projects') || $user->can('manage_projects')) && ($smarty.const.MODE_PROJECTS == $user->tracking_mode || $smarty.const.MODE_PROJECTS_AND_TASKS == $user->tracking_mode)}
+ {if ($user->can('view_own_projects') || $user->can('manage_projects')) && ($smarty.const.MODE_PROJECTS == $user->getTrackingMode() || $smarty.const.MODE_PROJECTS_AND_TASKS == $user->getTrackingMode())}
· <a class="mainMenu" href="projects.php">{$i18n.menu.projects}</a>
{/if}
- {if ($user->can('view_own_tasks') || $user->can('manage_tasks')) && $smarty.const.MODE_PROJECTS_AND_TASKS == $user->tracking_mode}
+ {if ($user->can('view_own_tasks') || $user->can('manage_tasks')) && $smarty.const.MODE_PROJECTS_AND_TASKS == $user->getTrackingMode()}
· <a class="mainMenu" href="tasks.php">{$i18n.menu.tasks}</a>
{/if}
{if $user->can('view_users') || $user->can('manage_users')}
header('Location: feature_disabled.php');
exit();
}
+if (!$user->exists()) {
+ header('Location: access_denied.php'); // Nobody to display a chart for.
+ exit();
+}
if ($user->behalf_id && (!$user->can('view_charts') || !$user->checkBehalfId())) {
header('Location: access_denied.php'); // Trying on behalf, but no right or wrong user.
exit();
$user->setOnBehalfUser($user_id);
} else {
$user_id = $user->getUser();
- // Handle a situation for no users in on behalf group.
- if ($user->behalfGroup && $user_id == $user->id)
- $user_id = null;
}
$uc = new ttUserConfig();
header('Location: feature_disabled.php');
exit();
}
+if (!$user->exists()) {
+ header('Location: access_denied.php'); // Nobody to enter expenses for.
+ exit();
+}
if ($user->behalf_id && (!$user->can('track_expenses') || !$user->checkBehalfId())) {
header('Location: access_denied.php'); // Trying on behalf, but no right or wrong user.
exit();
$user->setOnBehalfUser($user_id);
} else {
$user_id = $user->getUser();
- // Handle a situation for no users in on behalf group.
- if ($user->behalfGroup && $user_id == $user->id)
- $user_id = null;
}
// Initialize and store date in session.
header('Location: feature_disabled.php');
exit();
}
+if (!$user->exists()) {
+ header('Location: access_denied.php'); // Nobody to enter expenses for.
+ exit();
+}
if ($user->behalf_id && (!$user->can('track_expenses') || !$user->checkBehalfId())) {
header('Location: access_denied.php'); // Trying on behalf, but no right or wrong user.
exit();
$user->setOnBehalfUser($user_id);
} else {
$user_id = $user->getUser();
- // Handle a situation for no users in on behalf group.
- if ($user->behalfGroup && $user_id == $user->id)
- $user_id = null;
}
// Initialize and store date in session.
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();
}
header('Location: access_denied.php');
exit();
}
-if (MODE_PROJECTS_AND_TASKS != $user->tracking_mode) {
+if (MODE_PROJECTS_AND_TASKS != $user->getTrackingMode()) {
header('Location: feature_disabled.php');
exit();
}
// End of access checks.
if($user->can('manage_tasks')) {
- $active_tasks = ttTeamHelper::getActiveTasks($user->group_id);
- $inactive_tasks = ttTeamHelper::getInactiveTasks($user->group_id);
+ $active_tasks = ttTeamHelper::getActiveTasks($user->getGroup());
+ $inactive_tasks = ttTeamHelper::getInactiveTasks($user->getGroup());
} else
$active_tasks = $user->getAssignedTasks();