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');
 
  35 if (!ttAccessAllowed('administer_site')) {
 
  36   header('Location: access_denied.php');
 
  39 // End of access checks.
 
  41 $group_id = $request->getParameter('id');
 
  43 $admin = new ttAdmin();
 
  44 $group_details = $admin->getGroupDetails($group_id);
 
  46 if ($request->isPost()) {
 
  47   $cl_group_name = trim($request->getParameter('group_name'));
 
  48   $cl_manager_name = trim($request->getParameter('manager_name'));
 
  49   $cl_manager_login = trim($request->getParameter('manager_login'));
 
  50   if (!$auth->isPasswordExternal()) {
 
  51     $cl_password1 = $request->getParameter('password1');
 
  52     $cl_password2 = $request->getParameter('password2');
 
  54   $cl_manager_email = trim($request->getParameter('manager_email'));
 
  56   $cl_group_name = $group_details['group_name'];
 
  57   $cl_manager_name = $group_details['manager_name'];
 
  58   $cl_manager_login = $group_details['manager_login'];
 
  59   if (!$auth->isPasswordExternal()) {
 
  60     $cl_password1 = $cl_password2 = '';
 
  62   $cl_manager_email = $group_details['manager_email'];
 
  65 $form = new Form('groupForm');
 
  66 $form->addInput(array('type'=>'text','maxlength'=>'80','name'=>'group_name','value'=>$cl_group_name));
 
  67 $form->addInput(array('type'=>'text','maxlength'=>'100','name'=>'manager_name','value'=>$cl_manager_name));
 
  68 $form->addInput(array('type'=>'text','maxlength'=>'100','name'=>'manager_login','value'=>$cl_manager_login));
 
  69 if (!$auth->isPasswordExternal()) {
 
  70   $form->addInput(array('type'=>'password','maxlength'=>'30','name'=>'password1','value'=>$cl_password1));
 
  71   $form->addInput(array('type'=>'password','maxlength'=>'30','name'=>'password2','value'=>$cl_password2));
 
  73 $form->addInput(array('type'=>'text','maxlength'=>'100','name'=>'manager_email','value'=>$cl_manager_email));
 
  74 $form->addInput(array('type'=>'hidden','name'=>'id','value'=>$group_id));
 
  75 $form->addInput(array('type'=>'submit','name'=>'btn_save','value'=>$i18n->get('button.save')));
 
  76 $form->addInput(array('type'=>'submit','name'=>'btn_cancel','value'=>$i18n->get('button.cancel')));
 
  78 if ($request->isPost()) {
 
  79   if ($request->getParameter('btn_save')) {
 
  80     // Create fields array for ttAdmin instance.
 
  82       'old_group_name' => $group_details['group_name'],
 
  83       'new_group_name' => $cl_group_name,
 
  84       'user_id' => $group_details['manager_id'],
 
  85       'user_name' => $cl_manager_name,
 
  86       'old_login' => $group_details['manager_login'],
 
  87       'new_login' => $cl_manager_login,
 
  88       'password1' => $cl_password1,
 
  89       'password2' => $cl_password2,
 
  90       'email' => $cl_manager_email);
 
  93     $admin = new ttAdmin($err);
 
  94     $result = $admin->updateGroup($group_id, $fields);
 
  96       header('Location: admin_groups.php');
 
 101   if ($request->getParameter('btn_cancel')) {
 
 102     header('Location: admin_groups.php');
 
 107 $smarty->assign('auth_external', $auth->isPasswordExternal());
 
 108 $smarty->assign('forms', array($form->getName()=>$form->toArray()));
 
 109 $smarty->assign('onload', 'onLoad="document.groupForm.manager_name.focus()"');
 
 110 $smarty->assign('title', $i18n->get('title.edit_group'));
 
 111 $smarty->assign('content_page_name', 'admin_group_edit.tpl');
 
 112 $smarty->display('index.tpl');