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');
40 $team_id = $request->getParameter('id');
41 $team_details = ttTeamHelper::getTeamDetails($team_id);
43 if ($request->isPost()) {
44 $cl_team_name = trim($request->getParameter('team_name'));
45 $cl_manager_name = trim($request->getParameter('manager_name'));
46 $cl_manager_login = trim($request->getParameter('manager_login'));
47 if (!$auth->isPasswordExternal()) {
48 $cl_password1 = $request->getParameter('password1');
49 $cl_password2 = $request->getParameter('password2');
51 $cl_manager_email = trim($request->getParameter('manager_email'));
53 $cl_team_name = $team_details['team_name'];
54 $cl_manager_name = $team_details['manager_name'];
55 $cl_manager_login = $team_details['manager_login'];
56 if (!$auth->isPasswordExternal()) {
57 $cl_password1 = $cl_password2 = '';
59 $cl_manager_email = $team_details['manager_email'];
62 $form = new Form('teamForm');
63 $form->addInput(array('type'=>'text','maxlength'=>'80','name'=>'team_name','value'=>$cl_team_name));
64 $form->addInput(array('type'=>'text','maxlength'=>'100','name'=>'manager_name','value'=>$cl_manager_name));
65 $form->addInput(array('type'=>'text','maxlength'=>'100','name'=>'manager_login','value'=>$cl_manager_login));
66 if (!$auth->isPasswordExternal()) {
67 $form->addInput(array('type'=>'password','maxlength'=>'30','name'=>'password1','value'=>$cl_password1));
68 $form->addInput(array('type'=>'password','maxlength'=>'30','name'=>'password2','value'=>$cl_password2));
70 $form->addInput(array('type'=>'text','maxlength'=>'100','name'=>'manager_email','value'=>$cl_manager_email));
71 $form->addInput(array('type'=>'hidden','name'=>'id','value'=>$team_id));
72 $form->addInput(array('type'=>'submit','name'=>'btn_save','value'=>$i18n->get('button.save')));
73 $form->addInput(array('type'=>'submit','name'=>'btn_cancel','value'=>$i18n->get('button.cancel')));
75 if ($request->isPost()) {
76 if ($request->getParameter('btn_save')) {
77 // Create fields array for ttAdmin instance.
79 'old_group_name' => $team_details['team_name'],
80 'new_group_name' => $cl_team_name,
81 'user_id' => $team_details['manager_id'],
82 'user_name' => $cl_manager_name,
83 'old_login' => $team_details['manager_login'],
84 'new_login' => $cl_manager_login,
85 'password1' => $cl_password1,
86 'password2' => $cl_password2,
87 'email' => $cl_manager_email);
90 $admin = new ttAdmin($err);
91 $result = $admin->updateGroup($team_id, $fields);
93 header('Location: admin_teams.php');
98 if ($request->getParameter('btn_cancel')) {
99 header('Location: admin_teams.php');
104 $smarty->assign('auth_external', $auth->isPasswordExternal());
105 $smarty->assign('forms', array($form->getName()=>$form->toArray()));
106 $smarty->assign('onload', 'onLoad="document.teamForm.manager_name.focus()"');
107 $smarty->assign('title', $i18n->get('title.edit_team'));
108 $smarty->assign('content_page_name', 'admin_team_edit.tpl');
109 $smarty->display('index.tpl');