From: Nik Okuntseff Date: Sat, 24 Nov 2018 21:20:27 +0000 (+0000) Subject: Initial coding of group editor done. X-Git-Tag: timetracker_1.19-1~554 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=2908e17af44b65d6a97e299edd03293ddd802802;p=timetracker.git Initial coding of group editor done. --- diff --git a/WEB-INF/lib/ttRoleHelper.class.php b/WEB-INF/lib/ttRoleHelper.class.php index fc9a4c13..ee151462 100644 --- a/WEB-INF/lib/ttRoleHelper.class.php +++ b/WEB-INF/lib/ttRoleHelper.class.php @@ -124,6 +124,9 @@ class ttRoleHelper { global $user; $mdb2 = getConnection(); + $group_id = $user->getActiveGroup(); + $org_id = $user->org_id; + $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']; @@ -131,7 +134,7 @@ class ttRoleHelper { 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.$rank_part.$descr_part.$status_part.$rights_part, ','); - $sql = "update tt_roles set $parts where id = $id and group_id = $user->group_id"; + $sql = "update tt_roles set $parts where id = $id and group_id = $group_id and org_id = $org_id"; $affected = $mdb2->exec($sql); return (!is_a($affected, 'PEAR_Error')); } @@ -141,9 +144,11 @@ class ttRoleHelper { global $user; $mdb2 = getConnection(); + $group_id = $user->getActiveGroup(); + $org_id = $user->org_id; // Mark the task as deleted. - $sql = "update tt_roles set status = NULL where id = $role_id and group_id = $user->group_id"; + $sql = "update tt_roles set status = NULL where id = $role_id and group_id = $group_id and org_id = $org_id"; $affected = $mdb2->exec($sql); return (!is_a($affected, 'PEAR_Error')); } diff --git a/WEB-INF/lib/ttTeamHelper.class.php b/WEB-INF/lib/ttTeamHelper.class.php index b861e669..b4454a92 100644 --- a/WEB-INF/lib/ttTeamHelper.class.php +++ b/WEB-INF/lib/ttTeamHelper.class.php @@ -290,7 +290,10 @@ class ttTeamHelper { $result = array(); $mdb2 = getConnection(); - $sql = "select id, name, description, rank, rights from tt_roles where group_id = $user->group_id and org_id = $user->org_id and rank < $user->rank and status = 1 order by rank"; + $group_id = $user->getActiveGroup(); + $org_id = $user->org_id; + + $sql = "select id, name, description, rank, rights from tt_roles where group_id = $group_id and org_id = $org_id and rank < $user->rank and status = 1 order by rank"; $res = $mdb2->query($sql); $result = array(); if (!is_a($res, 'PEAR_Error')) { @@ -348,7 +351,10 @@ class ttTeamHelper { $result = array(); $mdb2 = getConnection(); - $sql = "select id, name, description, rank, rights from tt_roles where group_id = $user->group_id and org_id = $user->org_id and rank < $user->rank and status = 0 order by rank"; + $group_id = $user->getActiveGroup(); + $org_id = $user->org_id; + + $sql = "select id, name, description, rank, rights from tt_roles where group_id = $group_id and org_id = $org_id and rank < $user->rank and status = 0 order by rank"; $res = $mdb2->query($sql); $result = array(); if (!is_a($res, 'PEAR_Error')) { diff --git a/WEB-INF/templates/footer.tpl b/WEB-INF/templates/footer.tpl index 5c42acc7..06d71595 100644 --- a/WEB-INF/templates/footer.tpl +++ b/WEB-INF/templates/footer.tpl @@ -12,7 +12,7 @@
-
 Anuko Time Tracker 1.18.28.4511 | Copyright © Anuko | +  Anuko Time Tracker 1.18.28.4512 | Copyright © Anuko | {$i18n.footer.credits} | {$i18n.footer.license} | {$i18n.footer.improve} diff --git a/WEB-INF/templates/group_edit.tpl b/WEB-INF/templates/group_edit.tpl index 8ccb258f..8f683de4 100644 --- a/WEB-INF/templates/group_edit.tpl +++ b/WEB-INF/templates/group_edit.tpl @@ -26,6 +26,14 @@ function handleTaskRequiredCheckbox() {
+{if isTrue($smarty.const.SUBGROUP_DEBUG)} +{if $user->can('manage_subgroups')} + + + + +{/if} +{/if} {if $user->can('manage_basic_settings')} @@ -42,17 +50,9 @@ function handleTaskRequiredCheckbox() { {if $user->can('manage_roles')} - + {/if} -{if $smarty.const.SUBGROUP_DEBUG == 'true'} - {if $user->can('manage_subgroups')} - - - - - {/if} -{/if} diff --git a/group_edit.php b/group_edit.php index 84c66df9..ed2002d7 100644 --- a/group_edit.php +++ b/group_edit.php @@ -44,7 +44,14 @@ if ($group_id && !$user->isGroupValid($group_id)) { } // End of access checks. +if ($group_id) { + // We are passed a valid group_id. + // Set on behalf group accordingly. + $user->setOnBehalfGroup($group_id); +} + if (!$group_id) $group_id = $user->getActiveGroup(); +$groups = $user->getGroupsForDropdown(); $group = ttGroupHelper::getGroupAttrs($group_id); $config = new ttConfigHelper($group['config']); @@ -96,6 +103,16 @@ if ($request->isPost()) { $form = new Form('groupForm'); $form->addInput(array('type'=>'hidden','name'=>'id','value'=>$group_id)); +if (count($groups) > 1) { + $form->addInput(array('type'=>'combobox', + 'onchange'=>'document.groupForm.group_changed.value=1;document.groupForm.submit();', + 'name'=>'group', + 'style'=>'width: 250px;', + 'value'=>$group_id, + 'data'=>$groups, + 'datakeys'=>array('id','name'))); + $form->addInput(array('type'=>'hidden','name'=>'group_changed')); +} $form->addInput(array('type'=>'text','maxlength'=>'200','name'=>'group_name','value'=>$cl_group,'enable'=>$advanced_settings)); $form->addInput(array('type'=>'textarea','name'=>'description','style'=>'width: 250px; height: 40px;','value'=>$cl_description)); $form->addInput(array('type'=>'text','maxlength'=>'7','name'=>'currency','value'=>$cl_currency)); @@ -182,7 +199,16 @@ if ($advanced_settings) { $form->addInput(array('type'=>'submit','name'=>'btn_save','value'=>$i18n->get('button.save'))); if ($user->can('delete_group')) $form->addInput(array('type'=>'submit','name'=>'btn_delete','value'=>$i18n->get('button.delete'))); +$form->setValueByElement('group_changed',''); + if ($request->isPost()) { + if ($request->getParameter('group_changed')) { + // User changed the group in dropdown. + $new_group_id = $request->getParameter('group'); + // Redirect to self. + header('Location: group_edit.php?id='.$new_group_id); + exit(); + } if ($request->getParameter('btn_delete')) { // Delete button pressed, redirect. @@ -234,6 +260,8 @@ if ($request->isPost()) { } // isPost $smarty->assign('auth_external', $auth->isPasswordExternal()); +$smarty->assign('group_id', $group_id); +$smarty->assign('group_dropdown', count($groups) > 1); $smarty->assign('forms', array($form->getName()=>$form->toArray())); $smarty->assign('onload', 'onLoad="handleTaskRequiredCheckbox(); handlePluginCheckboxes();"'); $smarty->assign('title', $i18n->get('title.edit_group')); diff --git a/roles.php b/roles.php index cd17da3c..fe68329d 100644 --- a/roles.php +++ b/roles.php @@ -36,8 +36,19 @@ if (!ttAccessAllowed('manage_roles')) { header('Location: access_denied.php'); exit(); } +$group_id = (int)$request->getParameter('group_id'); +if ($group_id && !$user->isGroupValid($group_id)) { + header('Location: access_denied.php'); + exit(); +} // End of access checks. +if ($group_id) { + // We are passed a valid group_id (most likely from group_edit.php). + // Set on behalf group accordingly. + $user->setOnBehalfGroup($group_id); +} + $smarty->assign('active_roles', ttTeamHelper::getActiveRolesForUser()); $smarty->assign('inactive_roles', ttTeamHelper::getInactiveRolesForUser()); $smarty->assign('title', $i18n->get('title.roles'));
{$i18n.label.group}:{$forms.groupForm.group.control}
{$i18n.label.group_name} (*):
{$i18n.label.roles}:{$i18n.label.configure}{$i18n.label.configure}
{$i18n.label.subgroups}:{$i18n.label.configure}
{$i18n.label.language}: {$forms.groupForm.lang.control}