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('ttRoleHelper');
 
  33 import('ttConfigHelper');
 
  36 if (!ttAccessAllowed('manage_advanced_settings')) {
 
  37   header('Location: access_denied.php');
 
  40 // End of access checks.
 
  42 $group = ttGroupHelper::getGroupAttrs($user->getGroup());
 
  44 if ($request->isPost()) {
 
  45   $cl_group = trim($request->getParameter('group_name'));
 
  46   $cl_description = trim($request->getParameter('description'));
 
  47   $cl_bcc_email = trim($request->getParameter('bcc_email'));
 
  48   $cl_allow_ip = trim($request->getParameter('allow_ip'));
 
  50   $cl_group = $group['name'];
 
  51   $cl_description = $group['description'];
 
  52   $cl_bcc_email = $group['bcc_email'];
 
  53   $cl_allow_ip = $group['allow_ip'];
 
  56 $form = new Form('groupAdvancedForm');
 
  57 $form->addInput(array('type'=>'text','maxlength'=>'200','name'=>'group_name','value'=>$cl_group,'enable'=>$advanced_settings));
 
  58 $form->addInput(array('type'=>'textarea','name'=>'description','style'=>'width: 250px; height: 40px;','value'=>$cl_description));
 
  59 $form->addInput(array('type'=>'text','maxlength'=>'100','name'=>'bcc_email','value'=>$cl_bcc_email));
 
  60 $form->addInput(array('type'=>'text','maxlength'=>'100','name'=>'allow_ip','value'=>$cl_allow_ip));
 
  62 $form->addInput(array('type'=>'submit','name'=>'btn_save','value'=>$i18n->get('button.save')));
 
  64 if ($request->isPost()) {
 
  65   if ($request->getParameter('btn_save')) {
 
  66     // Validate user input.
 
  67     if (!ttValidString($cl_group)) $err->add($i18n->get('error.field'), $i18n->get('label.group_name'));
 
  68     if (!ttValidString($cl_description, true)) $err->add($i18n->get('error.field'), $i18n->get('label.description'));
 
  69     if (!ttValidEmail($cl_bcc_email, true)) $err->add($i18n->get('error.field'), $i18n->get('label.bcc'));
 
  70     if (!ttValidIP($cl_allow_ip, true)) $err->add($i18n->get('error.field'), $i18n->get('form.group_edit.allow_ip'));
 
  71     // Finished validating user input.
 
  74       if ($user->updateGroup(array(
 
  76         'description' => $cl_description,
 
  77         'bcc_email' => $cl_bcc_email,
 
  78         'allow_ip' => $cl_allow_ip))) {
 
  79         header('Location: success.php');
 
  82         $err->add($i18n->get('error.db'));
 
  87 $smarty->assign('forms', array($form->getName()=>$form->toArray()));
 
  88 $smarty->assign('title', $i18n->get('title.edit_group'));
 
  89 $smarty->assign('content_page_name', 'group_advanced_edit.tpl');
 
  90 $smarty->display('index.tpl');