2 // +----------------------------------------------------------------------+
3 // | Anuko Time Tracker
4 // +----------------------------------------------------------------------+
5 // | Copyright (c) Anuko International Ltd. (https://www.anuko.com)
6 // +----------------------------------------------------------------------+
7 // | LIBERAL FREEWARE LICENSE: This source code document may be used
8 // | by anyone for any purpose, and freely redistributed alone or in
9 // | combination with other software, provided that the license is obeyed.
11 // | There are only two ways to violate the license:
13 // | 1. To redistribute this code in source form, with the copyright
14 // | notice or license removed or altered. (Distributing in compiled
15 // | forms without embedded copyright notices is permitted).
17 // | 2. To redistribute modified versions of this code in *any* form
18 // | that bears insufficient indications that the modifications are
19 // | not the work of the original author(s).
21 // | This license applies to this document only, not any other software
22 // | that it may be combined with.
24 // +----------------------------------------------------------------------+
26 // | https://www.anuko.com/time_tracker/credits.htm
27 // +----------------------------------------------------------------------+
29 require_once('initialize.php');
31 import('ttUserHelper');
32 import('ttTeamHelper');
35 if (!ttAccessAllowed('administer_site')) {
36 header('Location: access_denied.php');
39 // End of access checks.
41 $group_id = $request->getParameter('id');
42 $group_details = ttTeamHelper::getTeamDetails($group_id);
44 if ($request->isPost()) {
45 $cl_group_name = trim($request->getParameter('group_name'));
46 $cl_manager_name = trim($request->getParameter('manager_name'));
47 $cl_manager_login = trim($request->getParameter('manager_login'));
48 if (!$auth->isPasswordExternal()) {
49 $cl_password1 = $request->getParameter('password1');
50 $cl_password2 = $request->getParameter('password2');
52 $cl_manager_email = trim($request->getParameter('manager_email'));
54 $cl_group_name = $group_details['team_name'];
55 $cl_manager_name = $group_details['manager_name'];
56 $cl_manager_login = $group_details['manager_login'];
57 if (!$auth->isPasswordExternal()) {
58 $cl_password1 = $cl_password2 = '';
60 $cl_manager_email = $group_details['manager_email'];
63 $form = new Form('groupForm');
64 $form->addInput(array('type'=>'text','maxlength'=>'80','name'=>'group_name','value'=>$cl_group_name));
65 $form->addInput(array('type'=>'text','maxlength'=>'100','name'=>'manager_name','value'=>$cl_manager_name));
66 $form->addInput(array('type'=>'text','maxlength'=>'100','name'=>'manager_login','value'=>$cl_manager_login));
67 if (!$auth->isPasswordExternal()) {
68 $form->addInput(array('type'=>'password','maxlength'=>'30','name'=>'password1','value'=>$cl_password1));
69 $form->addInput(array('type'=>'password','maxlength'=>'30','name'=>'password2','value'=>$cl_password2));
71 $form->addInput(array('type'=>'text','maxlength'=>'100','name'=>'manager_email','value'=>$cl_manager_email));
72 $form->addInput(array('type'=>'hidden','name'=>'id','value'=>$group_id));
73 $form->addInput(array('type'=>'submit','name'=>'btn_save','value'=>$i18n->get('button.save')));
74 $form->addInput(array('type'=>'submit','name'=>'btn_cancel','value'=>$i18n->get('button.cancel')));
76 if ($request->isPost()) {
77 if ($request->getParameter('btn_save')) {
78 // Create fields array for ttAdmin instance.
80 'old_group_name' => $group_details['team_name'],
81 'new_group_name' => $cl_group_name,
82 'user_id' => $group_details['manager_id'],
83 'user_name' => $cl_manager_name,
84 'old_login' => $group_details['manager_login'],
85 'new_login' => $cl_manager_login,
86 'password1' => $cl_password1,
87 'password2' => $cl_password2,
88 'email' => $cl_manager_email);
91 $admin = new ttAdmin($err);
92 $result = $admin->updateGroup($group_id, $fields);
94 header('Location: admin_groups.php');
99 if ($request->getParameter('btn_cancel')) {
100 header('Location: admin_groups.php');
105 $smarty->assign('auth_external', $auth->isPasswordExternal());
106 $smarty->assign('forms', array($form->getName()=>$form->toArray()));
107 $smarty->assign('onload', 'onLoad="document.groupForm.manager_name.focus()"');
108 $smarty->assign('title', $i18n->get('title.edit_group'));
109 $smarty->assign('content_page_name', 'admin_group_edit.tpl');
110 $smarty->display('index.tpl');