if ($name == 'ROLE') {
// We get here when processing <role> tags for the current group.
- $role_id = ttRoleHelper::insert(array(
+ $role_id = $this->insertRole(array(
'group_id' => $this->current_group_id,
'org_id' => $this->org_id,
'name' => $attrs['NAME'],
return $last_id;
}
+ // insertRole - inserts a role into tt_roles table.
+ private function insertRole($fields)
+ {
+ $mdb2 = getConnection();
+
+ $group_id = (int) $fields['group_id'];
+ $org_id = (int) $fields['org_id'];
+ $name = $fields['name'];
+ $rank = (int) $fields['rank'];
+ $description = $fields['description'];
+ $rights = $fields['rights'];
+ $status = $fields['status'];
+
+ $sql = "insert into tt_roles (group_id, org_id, name, rank, description, rights, status)
+ values ($group_id, $org_id, ".$mdb2->quote($name).", $rank, ".$mdb2->quote($description).", ".$mdb2->quote($rights).", ".$mdb2->quote($status).")";
+ $affected = $mdb2->exec($sql);
+ if (is_a($affected, 'PEAR_Error'))
+ return false;
+
+ $sql = "SELECT LAST_INSERT_ID() AS last_id";
+ $res = $mdb2->query($sql);
+ $val = $res->fetchRow();
+ $last_id = $val['last_id'];
+ return $last_id;
+ }
+
// The insertClient function inserts a new client as well as client to project binds.
private function insertClient($fields)
{
// insert - inserts an entry into tt_roles table.
static function insert($fields)
{
+ global $user;
$mdb2 = getConnection();
- $group_id = (int) $fields['group_id'];
- $org_id = (int) $fields['org_id'];
+ $group_id = $user->getGroup();
+ $org_id = $user->org_id;
$name = $fields['name'];
$rank = (int) $fields['rank'];
$description = $fields['description'];
<br>
<table cellspacing="0" cellpadding="4" width="100%" border="0">
<tr>
- <td align="center"> Anuko Time Tracker 1.18.28.4542 | Copyright © <a href="https://www.anuko.com/lp/tt_3.htm" target="_blank">Anuko</a> |
+ <td align="center"> Anuko Time Tracker 1.18.28.4543 | 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>
if (!$existing_role) {
// Insert a role with default user rights.
if (ttRoleHelper::insert(array(
- 'group_id' => $user->group_id,
- 'org_id' => $user->org_id,
'name' => $cl_name,
'rank' => $cl_rank,
'description' => $cl_description,