fwrite($file, "</fav_reports>\n");
unset($fav_reports);
+ // Write roles.
+ fwrite($file, "<roles>\n");
+ $roles = ttTeamHelper::getRoles($user->team_id);
+ foreach ($roles as $role) {
+ fwrite($file, "\t<role rank=\"".$role['rank']."\"".
+ " rights=\"".$role['rights']."\">\n");
+ fwrite($file, "\t\t<name><![CDATA[".$role['name']."]]></name>\n");
+ fwrite($file, "\t</role>\n");
+ }
+ fwrite($file, "</roles>\n");
+ unset($roles);
+
// Cleanup.
unset($users);
$this->userMap = array();
import('ttCustomFieldHelper');
import('ttFavReportHelper');
import('ttExpenseHelper');
+import('ttRoleHelper');
// ttImportHelper - this class is used to import team data from a file.
class ttImportHelper {
|| $name == 'INVOICE_HEADER'
|| $name == 'USER_PROJECT_BIND'
|| $name == 'EXPENSE_ITEM'
- || $name == 'FAV_REPORT') {
+ || $name == 'FAV_REPORT'
+ || $name == 'ROLE') {
$this->currentElement = $attrs;
}
$this->currentTag = $name;
'group_by' => $this->currentElement['GROUP_BY'],
'chtotalsonly' => (int) $this->currentElement['SHOW_TOTALS_ONLY']));
}
+
+ if ($name == 'ROLE' && $this->canImport) {
+ ttRoleHelper::insert(array(
+ 'team_id' => $this->team_id,
+ 'name' => $this->currentElement['NAME'],
+ 'rank' => $this->currentElement['RANK'],
+ 'rights' => $this->currentElement['RIGHTS'],
+ 'status' => $this->currentElement['STATUS']));
+ }
$this->currentTag = '';
}
--- /dev/null
+<?php
+// +----------------------------------------------------------------------+
+// | Anuko Time Tracker
+// +----------------------------------------------------------------------+
+// | Copyright (c) Anuko International Ltd. (https://www.anuko.com)
+// +----------------------------------------------------------------------+
+// | LIBERAL FREEWARE LICENSE: This source code document may be used
+// | by anyone for any purpose, and freely redistributed alone or in
+// | combination with other software, provided that the license is obeyed.
+// |
+// | There are only two ways to violate the license:
+// |
+// | 1. To redistribute this code in source form, with the copyright
+// | notice or license removed or altered. (Distributing in compiled
+// | forms without embedded copyright notices is permitted).
+// |
+// | 2. To redistribute modified versions of this code in *any* form
+// | that bears insufficient indications that the modifications are
+// | not the work of the original author(s).
+// |
+// | This license applies to this document only, not any other software
+// | that it may be combined with.
+// |
+// +----------------------------------------------------------------------+
+// | Contributors:
+// | https://www.anuko.com/time_tracker/credits.htm
+// +----------------------------------------------------------------------+
+
+// The ttRoleHelper is a class to help with custom group roles.
+class ttRoleHelper {
+ // insert - inserts an entry into tt_roles table.
+ static function insert($fields)
+ {
+ $mdb2 = getConnection();
+
+ $team_id = (int) $fields['team_id'];
+ $name = $fields['name'];
+ $rank = (int) $fields['rank'];
+ $rights = $fields['rights'];
+ $status = $fields['status'];
+
+ $sql = "insert into tt_roles (team_id, name, rank, rights, status)
+ values ($team_id, ".$mdb2->quote($name).", $rank, ".$mdb2->quote($rights).", ".$mdb2->quote($status).")";
+ $affected = $mdb2->exec($sql);
+ if (is_a($affected, 'PEAR_Error'))
+ return false;
+
+ return true;
+ }
+}
return false;
}
+ // getRoles - obtains all roles defined for team.
+ static function getRoles($team_id) {
+ $mdb2 = getConnection();
+
+ $result = array();
+ $sql = "select * from tt_roles where team_id = $team_id";
+ $res = $mdb2->query($sql);
+ $result = array();
+ if (!is_a($res, 'PEAR_Error')) {
+ while ($val = $res->fetchRow()) {
+ $result[] = $val;
+ }
+ return $result;
+ }
+ return false;
+ }
+
// getExpenseItems - obtains all expense items for all users in team.
static function getExpenseItems($team_id) {
$mdb2 = getConnection();
<br>
<table cellspacing="0" cellpadding="4" width="100%" border="0">
<tr>
- <td align="center"> Anuko Time Tracker 1.17.28.4007 | Copyright © <a href="https://www.anuko.com/lp/tt_3.htm" target="_blank">Anuko</a> |
+ <td align="center"> Anuko Time Tracker 1.17.28.4008 | 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>
# Structure for table tt_roles. This table stores customized team roles.
#
CREATE TABLE `tt_roles` (
- `id` int(11) NOT NULL auto_increment, # role id
- `team_id` int(11) NOT NULL, # team id
- `name` varchar(80) default NULL, # role name - may be used to rename standard roles
- `rank` int(11) default 0, # Role rank and identifier in comparison with other roles,
- # used to determine what "lesser roles" are
- # and also identifies a role within a team, used as role in tt_users.
+ `id` int(11) NOT NULL auto_increment, # Role id. Identifies roles for all groups on the server.
+ `team_id` int(11) NOT NULL, # Team id the role is defined for.
+ `name` varchar(80) default NULL, # Role name - custom role name. In case we are editing a
+ # predefined role (USER, etc.), we can rename the role here.
+ `rank` int(11) default 0, # Role rank, an integer value between 0-324. Predefined role ranks:
+ # USER - 4, CLIENT - 16, COMANAGER - 68, MANAGER - 324.
+ # Rank is used to determine what "lesser roles" are in each group
+ # for sutuations such as "manage_users".
+ # It also identifies a role within a team (by its "rank").
+ # Value of rank is to be used in role field in tt_users table,
+ # just like standard roles now.
`rights` text default NULL, # Comma-separated list of rights assigned to a role.
# NULL here for predefined roles (4, 16, 68, 324 - manager)
# means a hard-coded set of default access rights.
- `status` tinyint(4) default 1, # role status
+ `status` tinyint(4) default 1, # Role status.
PRIMARY KEY (`id`)
);
-# Create an index that guarantees unique active and inactive role ranks per team.
+# Create an index that guarantees unique active and inactive role ranks in each group.
create unique index role_idx on tt_roles(team_id, rank, status);