Work in progress populating repo...
authorNik Okuntseff <support@anuko.com>
Mon, 29 Feb 2016 03:22:03 +0000 (19:22 -0800)
committerNik Okuntseff <support@anuko.com>
Mon, 29 Feb 2016 03:22:33 +0000 (19:22 -0800)
Included a few files to see how the process is going to work...

15 files changed:
.htaccess [new file with mode: 0644]
access_denied.php [new file with mode: 0644]
admin_options.php [new file with mode: 0644]
admin_team_add.php [new file with mode: 0644]
admin_team_delete.php [new file with mode: 0644]
admin_team_edit.php [new file with mode: 0644]
admin_teams.php [new file with mode: 0644]
cf_custom_field_add.php [new file with mode: 0644]
cf_custom_field_delete.php [new file with mode: 0644]
cf_custom_field_edit.php [new file with mode: 0644]
cf_custom_fields.php [new file with mode: 0644]
cf_dropdown_option_add.php [new file with mode: 0644]
cf_dropdown_option_delete.php [new file with mode: 0644]
cf_dropdown_option_edit.php [new file with mode: 0644]
cf_dropdown_options.php [new file with mode: 0644]

diff --git a/.htaccess b/.htaccess
new file mode 100644 (file)
index 0000000..c91ca1c
--- /dev/null
+++ b/.htaccess
@@ -0,0 +1 @@
+AddDefaultCharset utf-8
diff --git a/access_denied.php b/access_denied.php
new file mode 100644 (file)
index 0000000..f046a53
--- /dev/null
@@ -0,0 +1,37 @@
+<?php
+// +----------------------------------------------------------------------+
+// | Anuko Time Tracker
+// +----------------------------------------------------------------------+
+// | Copyright (c) Anuko International Ltd. (https://www.anuko.com)
+// +----------------------------------------------------------------------+
+// | LIBERAL FREEWARE LICENSE: This source code document may be used
+// | by anyone for any purpose, and freely redistributed alone or in
+// | combination with other software, provided that the license is obeyed.
+// |
+// | There are only two ways to violate the license:
+// |
+// | 1. To redistribute this code in source form, with the copyright
+// |    notice or license removed or altered. (Distributing in compiled
+// |    forms without embedded copyright notices is permitted).
+// |
+// | 2. To redistribute modified versions of this code in *any* form
+// |    that bears insufficient indications that the modifications are
+// |    not the work of the original author(s).
+// |
+// | This license applies to this document only, not any other software
+// | that it may be combined with.
+// |
+// +----------------------------------------------------------------------+
+// | Contributors:
+// | https://www.anuko.com/time_tracker/credits.htm
+// +----------------------------------------------------------------------+
+
+require_once('initialize.php');
+
+$errors->add($i18n->getKey('error.access_denied'));  
+if ($auth->isAuthenticated()) $GLOBALS['SMARTY']->assign('authenticated', true); // Used in header.tpl for menu display.
+
+$smarty->assign('title', $i18n->getKey('label.error'));
+$smarty->assign('content_page_name', 'access_denied.tpl');
+$smarty->display('index.tpl');
+?>
\ No newline at end of file
diff --git a/admin_options.php b/admin_options.php
new file mode 100644 (file)
index 0000000..ac90921
--- /dev/null
@@ -0,0 +1,71 @@
+<?php
+// +----------------------------------------------------------------------+
+// | Anuko Time Tracker
+// +----------------------------------------------------------------------+
+// | Copyright (c) Anuko International Ltd. (https://www.anuko.com)
+// +----------------------------------------------------------------------+
+// | LIBERAL FREEWARE LICENSE: This source code document may be used
+// | by anyone for any purpose, and freely redistributed alone or in
+// | combination with other software, provided that the license is obeyed.
+// |
+// | There are only two ways to violate the license:
+// |
+// | 1. To redistribute this code in source form, with the copyright
+// |    notice or license removed or altered. (Distributing in compiled
+// |    forms without embedded copyright notices is permitted).
+// |
+// | 2. To redistribute modified versions of this code in *any* form
+// |    that bears insufficient indications that the modifications are
+// |    not the work of the original author(s).
+// |
+// | This license applies to this document only, not any other software
+// | that it may be combined with.
+// |
+// +----------------------------------------------------------------------+
+// | Contributors:
+// | https://www.anuko.com/time_tracker/credits.htm
+// +----------------------------------------------------------------------+
+
+require_once('initialize.php');
+import('form.Form');
+import('ttUserHelper');
+
+// Access check.
+if (!ttAccessCheck(right_administer_site)) {
+  header('Location: access_denied.php');
+  exit();
+}
+
+if ($request->getMethod() == 'POST') {
+  $cl_password1 = $request->getParameter('password1');
+  $cl_password2 = $request->getParameter('password2');
+}
+
+$form = new Form('optionsForm');
+$form->addInput(array('type'=>'text','aspassword'=>true,'maxlength'=>'30','name'=>'password1','style'=>'width: 150px;','value'=>$cl_password1));
+$form->addInput(array('type'=>'text','aspassword'=>true,'maxlength'=>'30','name'=>'password2','style'=>"width: 150px;",'value'=>$cl_password2));
+$form->addInput(array('type'=>'submit','name'=>'btn_submit','value'=>$i18n->getKey('button.submit')));
+
+if ($request->getMethod() == 'POST') {
+  if ($cl_password1 || $cl_password2) {
+       // Validate user input.
+       if (!ttValidString($cl_password1)) $errors->add($i18n->getKey('error.field'), $i18n->getKey('label.password'));
+       if (!ttValidString($cl_password2)) $errors->add($i18n->getKey('error.field'), $i18n->getKey('label.confirm_password'));
+    if ($cl_password1 !== $cl_password2)
+      $errors->add($i18n->getKey('error.not_equal'), $i18n->getKey('label.password'), $i18n->getKey('label.confirm_password'));
+  }
+
+  if ($errors->isEmpty() && $cl_password1) {
+    if (ttUserHelper::setPassword($user->id, $cl_password1)) {
+      header('Location: admin_teams.php');
+      exit();
+    } else
+      $errors->add($i18n->getKey('error.db'));
+  }
+} // post
+
+$smarty->assign('forms', array($form->getName()=>$form->toArray()));
+$smarty->assign('title', $i18n->getKey('title.options'));
+$smarty->assign('content_page_name', 'admin_options.tpl');
+$smarty->display('index.tpl');
+?>
\ No newline at end of file
diff --git a/admin_team_add.php b/admin_team_add.php
new file mode 100644 (file)
index 0000000..b41571c
--- /dev/null
@@ -0,0 +1,104 @@
+<?php
+// +----------------------------------------------------------------------+
+// | Anuko Time Tracker
+// +----------------------------------------------------------------------+
+// | Copyright (c) Anuko International Ltd. (https://www.anuko.com)
+// +----------------------------------------------------------------------+
+// | LIBERAL FREEWARE LICENSE: This source code document may be used
+// | by anyone for any purpose, and freely redistributed alone or in
+// | combination with other software, provided that the license is obeyed.
+// |
+// | There are only two ways to violate the license:
+// |
+// | 1. To redistribute this code in source form, with the copyright
+// |    notice or license removed or altered. (Distributing in compiled
+// |    forms without embedded copyright notices is permitted).
+// |
+// | 2. To redistribute modified versions of this code in *any* form
+// |    that bears insufficient indications that the modifications are
+// |    not the work of the original author(s).
+// |
+// | This license applies to this document only, not any other software
+// | that it may be combined with.
+// |
+// +----------------------------------------------------------------------+
+// | Contributors:
+// | https://www.anuko.com/time_tracker/credits.htm
+// +----------------------------------------------------------------------+
+
+require_once('initialize.php');
+import('form.Form');
+import('ttUserHelper');
+
+// Access check.
+if (!ttAccessCheck(right_administer_site)) {
+  header('Location: access_denied.php');
+  exit();
+}
+
+if ($request->getMethod() == 'POST') {
+  $cl_team_name = trim($request->getParameter('team_name'));
+  $cl_manager_name = trim($request->getParameter('manager_name'));
+  $cl_manager_login = trim($request->getParameter('manager_login'));
+  if (!$auth->isPasswordExternal()) {
+    $cl_password1 = $request->getParameter('password1');
+    $cl_password2 = $request->getParameter('password2');
+  }
+  $cl_manager_email = trim($request->getParameter('manager_email'));
+}
+  
+$form = new Form('teamForm');
+$form->addInput(array('type'=>'text','maxlength'=>'200','name'=>'team_name','value'=>$cl_team_name));
+$form->addInput(array('type'=>'text','maxlength'=>'100','name'=>'manager_name','value'=>$cl_manager_name));
+$form->addInput(array('type'=>'text','maxlength'=>'100','name'=>'manager_login','value'=>$cl_manager_login));
+if (!$auth->isPasswordExternal()) {
+  $form->addInput(array('type'=>'text','maxlength'=>'30','name'=>'password1','aspassword'=>true,'value'=>$cl_password1));
+  $form->addInput(array('type'=>'text','maxlength'=>'30','name'=>'password2','aspassword'=>true,'value'=>$cl_password2));
+}
+$form->addInput(array('type'=>'text','maxlength'=>'100','name'=>'manager_email','value'=>$cl_manager_email));
+$form->addInput(array('type'=>'submit','name'=>'btn_submit','value'=>$i18n->getKey('button.submit')));
+
+if ($request->getMethod() == 'POST') {
+  // Validate user input.
+  if (!ttValidString($cl_team_name, true)) $errors->add($i18n->getKey('error.field'), $i18n->getKey('label.team_name'));
+  if (!ttValidString($cl_manager_name)) $errors->add($i18n->getKey('error.field'), $i18n->getKey('label.manager_name'));
+  if (!ttValidString($cl_manager_login)) $errors->add($i18n->getKey('error.field'), $i18n->getKey('label.manager_login'));
+  if (!$auth->isPasswordExternal()) {
+       if (!ttValidString($cl_password1)) $errors->add($i18n->getKey('error.field'), $i18n->getKey('label.password'));
+       if (!ttValidString($cl_password2)) $errors->add($i18n->getKey('error.field'), $i18n->getKey('label.confirm_password'));
+    if ($cl_password1 !== $cl_password2)
+      $errors->add($i18n->getKey('error.not_equal'), $i18n->getKey('label.password'), $i18n->getKey('label.confirm_password'));
+  }    
+  if (!ttValidEmail($cl_manager_email, true)) $errors->add($i18n->getKey('error.field'), $i18n->getKey('label.email'));
+    
+  if ($errors->isEmpty()) {
+    if (!ttUserHelper::getUserByLogin($cl_manager_login)) {
+      // Create a new team.
+      if (!defined('CURRENCY_DEFAULT')) define('CURRENCY_DEFAULT', '$');
+      $team_id = ttTeamHelper::insert(array('name'=>$cl_team_name,'currency'=>CURRENCY_DEFAULT));
+      if ($team_id) {
+      // Team created, now create a team manager.
+        $user_id = ttUserHelper::insert(array(
+         'team_id' => $team_id,
+         'role' => ROLE_MANAGER,
+          'name' => $cl_manager_name,
+          'login' => $cl_manager_login,
+          'password' => $cl_password1,
+         'email' => $cl_manager_email));
+      }
+      if ($team_id && $user_id) {
+        header('Location: admin_teams.php');
+      } else
+        $errors->add($i18n->getKey('error.db'));
+    } else
+      $errors->add($i18n->getKey('error.user_exists'));
+  }
+}
+
+$smarty->assign('auth_external', $auth->isPasswordExternal());
+$smarty->assign('forms', array($form->getName()=>$form->toArray()));
+$smarty->assign('onload', 'onLoad="document.teamForm.team.focus()"');
+$smarty->assign('content_page_name', 'admin_team_add.tpl');
+$smarty->assign('title', $i18n->getKey('title.create_team'));
+$smarty->display('index.tpl');
+?>
\ No newline at end of file
diff --git a/admin_team_delete.php b/admin_team_delete.php
new file mode 100644 (file)
index 0000000..2500318
--- /dev/null
@@ -0,0 +1,68 @@
+<?php
+// +----------------------------------------------------------------------+
+// | Anuko Time Tracker
+// +----------------------------------------------------------------------+
+// | Copyright (c) Anuko International Ltd. (https://www.anuko.com)
+// +----------------------------------------------------------------------+
+// | LIBERAL FREEWARE LICENSE: This source code document may be used
+// | by anyone for any purpose, and freely redistributed alone or in
+// | combination with other software, provided that the license is obeyed.
+// |
+// | There are only two ways to violate the license:
+// |
+// | 1. To redistribute this code in source form, with the copyright
+// |    notice or license removed or altered. (Distributing in compiled
+// |    forms without embedded copyright notices is permitted).
+// |
+// | 2. To redistribute modified versions of this code in *any* form
+// |    that bears insufficient indications that the modifications are
+// |    not the work of the original author(s).
+// |
+// | This license applies to this document only, not any other software
+// | that it may be combined with.
+// |
+// +----------------------------------------------------------------------+
+// | Contributors:
+// | https://www.anuko.com/time_tracker/credits.htm
+// +----------------------------------------------------------------------+
+
+require_once('initialize.php');
+import('form.Form');
+import('ttTeamHelper');
+
+// Access check.
+if (!ttAccessCheck(right_administer_site)) {
+  header('Location: access_denied.php');
+  exit();
+}
+
+$team_id = (int)$request->getParameter('id');
+$team_details = ttTeamHelper::getTeamDetails($team_id);
+$team_name = $team_details['team_name'];
+
+$form = new Form('teamForm');
+$form->addInput(array('type'=>'hidden','name'=>'id','value'=>$team_id));
+$form->addInput(array('type'=>'submit','name'=>'btn_delete','value'=>$i18n->getKey('label.delete')));
+$form->addInput(array('type'=>'submit','name'=>'btn_cancel','value'=>$i18n->getKey('button.cancel')));
+
+if ($request->getMethod() == 'POST') {
+  if ($request->getParameter('btn_delete')) {
+    if (ttTeamHelper::markDeleted($team_id)) {
+      header('Location: admin_teams.php');
+      exit();
+    } else
+      $errors->add($i18n->getKey('error.db'));
+  }
+
+  if ($request->getParameter('btn_cancel')) {
+    header('Location: admin_teams.php');
+    exit();
+  }
+}
+       
+$smarty->assign('team_to_delete', $team_name);
+$smarty->assign('forms', array($form->getName()=>$form->toArray()));
+$smarty->assign('title', $i18n->getKey('title.delete_team'));
+$smarty->assign('content_page_name', 'admin_team_delete.tpl');
+$smarty->display('index.tpl');
+?>
\ No newline at end of file
diff --git a/admin_team_edit.php b/admin_team_edit.php
new file mode 100644 (file)
index 0000000..c6181a6
--- /dev/null
@@ -0,0 +1,123 @@
+<?php
+// +----------------------------------------------------------------------+
+// | Anuko Time Tracker
+// +----------------------------------------------------------------------+
+// | Copyright (c) Anuko International Ltd. (https://www.anuko.com)
+// +----------------------------------------------------------------------+
+// | LIBERAL FREEWARE LICENSE: This source code document may be used
+// | by anyone for any purpose, and freely redistributed alone or in
+// | combination with other software, provided that the license is obeyed.
+// |
+// | There are only two ways to violate the license:
+// |
+// | 1. To redistribute this code in source form, with the copyright
+// |    notice or license removed or altered. (Distributing in compiled
+// |    forms without embedded copyright notices is permitted).
+// |
+// | 2. To redistribute modified versions of this code in *any* form
+// |    that bears insufficient indications that the modifications are
+// |    not the work of the original author(s).
+// |
+// | This license applies to this document only, not any other software
+// | that it may be combined with.
+// |
+// +----------------------------------------------------------------------+
+// | Contributors:
+// | https://www.anuko.com/time_tracker/credits.htm
+// +----------------------------------------------------------------------+
+
+require_once('initialize.php');
+import('form.Form');
+import('ttUserHelper');
+import('ttTeamHelper');
+
+// Access check.
+if (!ttAccessCheck(right_administer_site)) {
+  header('Location: access_denied.php');
+  exit();
+}
+
+$team_id = $request->getParameter('id');
+$team_details = ttTeamHelper::getTeamDetails($team_id);        
+  
+if ($request->getMethod() == 'POST') {
+  $cl_team_name = trim($request->getParameter('team_name'));
+  $cl_manager_name = trim($request->getParameter('manager_name'));
+  $cl_manager_login = trim($request->getParameter('manager_login'));
+  if (!$auth->isPasswordExternal()) {
+    $cl_password1 = $request->getParameter('password1');
+    $cl_password2 = $request->getParameter('password2');
+  }
+  $cl_manager_email = trim($request->getParameter('manager_email'));
+} else {
+  $cl_team_name = $team_details['team_name'];
+  $cl_manager_name = $team_details['manager_name'];
+  $cl_manager_login = $team_details['manager_login'];
+  if (!$auth->isPasswordExternal()) {
+    $cl_password1 = $cl_password2 = '';
+  }
+  $cl_manager_email = $team_details['manager_email'];
+}
+  
+$form = new Form('teamForm');
+$form->addInput(array('type'=>'text','maxlength'=>'80','name'=>'team_name','value'=>$cl_team_name));
+$form->addInput(array('type'=>'text','maxlength'=>'100','name'=>'manager_name','value'=>$cl_manager_name));
+$form->addInput(array('type'=>'text','maxlength'=>'100','name'=>'manager_login','value'=>$cl_manager_login));
+if (!$auth->isPasswordExternal()) {
+  $form->addInput(array('type'=>'text','maxlength'=>'30','name'=>'password1','aspassword'=>true,'value'=>$cl_password1));
+  $form->addInput(array('type'=>'text','maxlength'=>'30','name'=>'password2','aspassword'=>true,'value'=>$cl_password2));
+}
+$form->addInput(array('type'=>'text','maxlength'=>'100','name'=>'manager_email','value'=>$cl_manager_email));
+$form->addInput(array('type'=>'hidden','name'=>'id','value'=>$team_id));
+$form->addInput(array('type'=>'submit','name'=>'btn_save','value'=>$i18n->getKey('button.save')));
+$form->addInput(array('type'=>'submit','name'=>'btn_cancel','value'=>$i18n->getKey('button.cancel')));
+
+if ($request->getMethod() == 'POST') {
+  if ($request->getParameter('btn_save')) {
+       // Validate user input.
+    if (!ttValidString($cl_team_name, true)) $errors->add($i18n->getKey('error.field'), $i18n->getKey('label.team_name'));
+    if (!ttValidString($cl_manager_name)) $errors->add($i18n->getKey('error.field'), $i18n->getKey('label.manager_name'));
+    if (!ttValidString($cl_manager_login)) $errors->add($i18n->getKey('error.field'), $i18n->getKey('label.manager_login'));
+       if (!$auth->isPasswordExternal() && ($cl_password1 || $cl_password2)) {
+      if (!ttValidString($cl_password1)) $errors->add($i18n->getKey('error.field'), $i18n->getKey('label.password'));
+      if (!ttValidString($cl_password2)) $errors->add($i18n->getKey('error.field'), $i18n->getKey('label.confirm_password'));
+      if ($cl_password1 !== $cl_password2)
+        $errors->add($i18n->getKey('error.not_equal'), $i18n->getKey('label.password'), $i18n->getKey('label.confirm_password'));
+    }  
+    if (!ttValidEmail($cl_manager_email, true)) $errors->add($i18n->getKey('error.field'), $i18n->getKey('label.email'));
+      
+    // New login must be unique.
+    if ($cl_manager_login != $team_details['manager_login'])
+      if (ttUserHelper::getUserByLogin($cl_manager_login)) $errors->add($i18n->getKey('error.user_exists'));
+        
+    if ($errors->isEmpty()) {
+      $update_result = ttTeamHelper::update($team_id, array('name'=>$cl_team_name));
+      if ($update_result) {
+        $update_result = ttUserHelper::update($team_details['manager_id'], array(
+          'name' => $cl_manager_name,
+          'login' => $cl_manager_login,
+          'password' => $cl_password1,
+          'email' => $cl_manager_email,
+          'status' => ACTIVE));
+      }
+      if ($update_result) {
+        header('Location: admin_teams.php');
+        exit();
+      } else
+        $errors->add($i18n->getKey('error.db'));
+    }
+  }
+
+  if ($request->getParameter('btn_cancel')) {
+    header('Location: admin_teams.php');
+    exit();
+  }
+} // POST
+
+$smarty->assign('auth_external', $auth->isPasswordExternal());
+$smarty->assign('forms', array($form->getName()=>$form->toArray()));
+$smarty->assign('onload', 'onLoad="document.teamForm.manager_name.focus()"');
+$smarty->assign('title', $i18n->getKey('title.edit_team'));
+$smarty->assign('content_page_name', 'admin_team_edit.tpl');
+$smarty->display('index.tpl');
+?>
\ No newline at end of file
diff --git a/admin_teams.php b/admin_teams.php
new file mode 100644 (file)
index 0000000..73777d2
--- /dev/null
@@ -0,0 +1,43 @@
+<?php
+// +----------------------------------------------------------------------+
+// | Anuko Time Tracker
+// +----------------------------------------------------------------------+
+// | Copyright (c) Anuko International Ltd. (https://www.anuko.com)
+// +----------------------------------------------------------------------+
+// | LIBERAL FREEWARE LICENSE: This source code document may be used
+// | by anyone for any purpose, and freely redistributed alone or in
+// | combination with other software, provided that the license is obeyed.
+// |
+// | There are only two ways to violate the license:
+// |
+// | 1. To redistribute this code in source form, with the copyright
+// |    notice or license removed or altered. (Distributing in compiled
+// |    forms without embedded copyright notices is permitted).
+// |
+// | 2. To redistribute modified versions of this code in *any* form
+// |    that bears insufficient indications that the modifications are
+// |    not the work of the original author(s).
+// |
+// | This license applies to this document only, not any other software
+// | that it may be combined with.
+// |
+// +----------------------------------------------------------------------+
+// | Contributors:
+// | https://www.anuko.com/time_tracker/credits.htm
+// +----------------------------------------------------------------------+
+       
+require_once('initialize.php');
+import('form.Form');
+import('ttTeamHelper');
+
+// Access check.
+if (!ttAccessCheck(right_administer_site)) {
+  header('Location: access_denied.php');
+  exit();
+}
+
+$smarty->assign('teams', ttTeamHelper::getTeams());
+$smarty->assign('title', $i18n->getKey('title.teams'));
+$smarty->assign('content_page_name', 'admin_teams.tpl');
+$smarty->display('index.tpl');
+?>
\ No newline at end of file
diff --git a/cf_custom_field_add.php b/cf_custom_field_add.php
new file mode 100644 (file)
index 0000000..1818b57
--- /dev/null
@@ -0,0 +1,75 @@
+<?php
+// +----------------------------------------------------------------------+
+// | Anuko Time Tracker
+// +----------------------------------------------------------------------+
+// | Copyright (c) Anuko International Ltd. (https://www.anuko.com)
+// +----------------------------------------------------------------------+
+// | LIBERAL FREEWARE LICENSE: This source code document may be used
+// | by anyone for any purpose, and freely redistributed alone or in
+// | combination with other software, provided that the license is obeyed.
+// |
+// | There are only two ways to violate the license:
+// |
+// | 1. To redistribute this code in source form, with the copyright
+// |    notice or license removed or altered. (Distributing in compiled
+// |    forms without embedded copyright notices is permitted).
+// |
+// | 2. To redistribute modified versions of this code in *any* form
+// |    that bears insufficient indications that the modifications are
+// |    not the work of the original author(s).
+// |
+// | This license applies to this document only, not any other software
+// | that it may be combined with.
+// |
+// +----------------------------------------------------------------------+
+// | Contributors:
+// | https://www.anuko.com/time_tracker/credits.htm
+// +----------------------------------------------------------------------+
+
+require_once('initialize.php');
+require_once('plugins/CustomFields.class.php');
+import('form.Form');
+
+// Access check.
+if (!ttAccessCheck(right_manage_team)) {
+  header('Location: access_denied.php');
+  exit();
+}
+
+if ($request->getMethod() == 'POST') {
+  $cl_field_name = trim($request->getParameter('name'));
+  $cl_field_type = $request->getParameter('type');
+  $cl_required = $request->getParameter('required');
+  if (!$cl_required)
+    $cl_required = 0;
+}
+       
+$form = new Form('fieldForm');
+$form->addInput(array('type'=>'text','maxlength'=>'100','name'=>'name','value'=>''));
+$form->addInput(array('type'=>'combobox','name'=>'type',
+  'data'=>array(CustomFields::TYPE_TEXT=>$i18n->getKey('label.type_text'),
+                CustomFields::TYPE_DROPDOWN=>$i18n->getKey('label.type_dropdown'))
+));
+$form->addInput(array('type'=>'checkbox','name'=>'required','data'=>1,'value'=>'0'));
+$form->addInput(array('type'=>'submit','name'=>'btn_add','value'=>$i18n->getKey('button.add')));       
+
+if ($request->getMethod() == 'POST') {
+  // Validate user input.
+  if (!ttValidString($cl_field_name)) $errors->add($i18n->getKey('error.field'), $i18n->getKey('label.thing_name'));
+
+  if ($errors->isEmpty()) {
+    $res = CustomFields::insertField($cl_field_name, $cl_field_type, $cl_required);
+    if ($res) {
+      header('Location: cf_custom_fields.php');
+      exit();
+    } else
+      $errors->add($i18n->getKey('error.db'));
+  }
+}
+
+$smarty->assign('forms', array($form->getName()=>$form->toArray()));
+$smarty->assign('onload', 'onLoad="document.fieldForm.name.focus()"');
+$smarty->assign('title', $i18n->getKey('title.cf_add_custom_field'));
+$smarty->assign('content_page_name', 'cf_custom_field_add.tpl');
+$smarty->display('index.tpl');
+?>
\ No newline at end of file
diff --git a/cf_custom_field_delete.php b/cf_custom_field_delete.php
new file mode 100644 (file)
index 0000000..6f42e31
--- /dev/null
@@ -0,0 +1,77 @@
+<?php
+// +----------------------------------------------------------------------+
+// | Anuko Time Tracker
+// +----------------------------------------------------------------------+
+// | Copyright (c) Anuko International Ltd. (https://www.anuko.com)
+// +----------------------------------------------------------------------+
+// | LIBERAL FREEWARE LICENSE: This source code document may be used
+// | by anyone for any purpose, and freely redistributed alone or in
+// | combination with other software, provided that the license is obeyed.
+// |
+// | There are only two ways to violate the license:
+// |
+// | 1. To redistribute this code in source form, with the copyright
+// |    notice or license removed or altered. (Distributing in compiled
+// |    forms without embedded copyright notices is permitted).
+// |
+// | 2. To redistribute modified versions of this code in *any* form
+// |    that bears insufficient indications that the modifications are
+// |    not the work of the original author(s).
+// |
+// | This license applies to this document only, not any other software
+// | that it may be combined with.
+// |
+// +----------------------------------------------------------------------+
+// | Contributors:
+// | https://www.anuko.com/time_tracker/credits.htm
+// +----------------------------------------------------------------------+
+
+require_once('initialize.php');
+require_once('plugins/CustomFields.class.php');
+import('form.Form');
+
+// Access check.
+if (!ttAccessCheck(right_manage_team)) {
+  header('Location: access_denied.php');
+  exit();
+}
+
+$id = $request->getParameter('id');
+
+$form = new Form('fieldDeleteForm');
+
+if ($request->getMethod() == 'POST') {
+  if ($request->getParameter('btn_delete'))  {
+       // Delete button pressed.
+       $res = CustomFields::deleteField($id);
+    if ($res) {
+      header('Location: cf_custom_fields.php');
+      exit();
+    } else {
+      $errors->add($i18n->getKey('error.db'));
+    }
+  }
+  if ($request->getParameter('btn_cancel')) {
+       // Cancel button pressed.
+       header('Location: cf_custom_fields.php');
+       exit();
+  }
+} else {
+  $field = CustomFields::getField($id);        
+  if (false === $field)
+    $errors->add($i18n->getKey('error.db'));
+
+  if ($errors->isEmpty()) {
+    $form->addInput(array('type'=>'hidden','name'=>'id','value'=>$id));
+    $form->addInput(array('type'=>'submit','name'=>'btn_delete','value'=>$i18n->getKey('label.delete')));
+    $form->addInput(array('type'=>'submit','name'=>'btn_cancel','value'=>$i18n->getKey('button.cancel')));
+  }
+}
+       
+$smarty->assign('field', $field['label']);
+$smarty->assign('forms', array($form->getName()=>$form->toArray()));
+$smarty->assign('onload', 'onLoad="document.fieldDeleteForm.btn_cancel.focus()"');
+$smarty->assign('title', $i18n->getKey('title.cf_delete_custom_field'));
+$smarty->assign('content_page_name', 'cf_custom_field_delete.tpl');
+$smarty->display('index.tpl');
+?>
\ No newline at end of file
diff --git a/cf_custom_field_edit.php b/cf_custom_field_edit.php
new file mode 100644 (file)
index 0000000..796ad17
--- /dev/null
@@ -0,0 +1,82 @@
+<?php
+// +----------------------------------------------------------------------+
+// | Anuko Time Tracker
+// +----------------------------------------------------------------------+
+// | Copyright (c) Anuko International Ltd. (https://www.anuko.com)
+// +----------------------------------------------------------------------+
+// | LIBERAL FREEWARE LICENSE: This source code document may be used
+// | by anyone for any purpose, and freely redistributed alone or in
+// | combination with other software, provided that the license is obeyed.
+// |
+// | There are only two ways to violate the license:
+// |
+// | 1. To redistribute this code in source form, with the copyright
+// |    notice or license removed or altered. (Distributing in compiled
+// |    forms without embedded copyright notices is permitted).
+// |
+// | 2. To redistribute modified versions of this code in *any* form
+// |    that bears insufficient indications that the modifications are
+// |    not the work of the original author(s).
+// |
+// | This license applies to this document only, not any other software
+// | that it may be combined with.
+// |
+// +----------------------------------------------------------------------+
+// | Contributors:
+// | https://www.anuko.com/time_tracker/credits.htm
+// +----------------------------------------------------------------------+
+
+require_once('initialize.php');
+require_once('plugins/CustomFields.class.php');
+import('form.Form');
+
+// Access check.
+if (!ttAccessCheck(right_manage_team)) {
+  header('Location: access_denied.php');
+  exit();
+}
+
+$cl_id = $request->getParameter('id');
+$field = CustomFields::getField($cl_id);
+if (false === $field)
+  $errors->add($i18n->getKey('error.db'));
+
+$form = new Form('fieldForm');
+if ($errors->isEmpty()) {
+  $form->addInput(array('type'=>'text','maxlength'=>'100','name'=>'name','value'=>$field['label']));
+  $form->addInput(array('type'=>'hidden','name'=>'id','value'=>$cl_id));
+  $form->addInput(array('type'=>'checkbox','name'=>'required','data'=>1,'value'=>$field['required']));
+  $form->addInput(array('type'=>'combobox','name'=>'type','value'=>$field['type'],
+    'data'=>array(CustomFields::TYPE_TEXT=>$i18n->getKey('label.type_text'),
+                  CustomFields::TYPE_DROPDOWN=>$i18n->getKey('label.type_dropdown'))
+  ));
+  $form->addInput(array('type'=>'submit','name'=>'btn_save','value'=>$i18n->getKey('button.save')));   
+}    
+
+if ($request->getMethod() == 'POST') {
+  $cl_name = trim($request->getParameter('name'));
+  $cl_type = $request->getParameter('type');
+  $cl_required = $request->getParameter('required');
+  if (!$cl_required)
+    $cl_required = 0;
+  
+  // Validate user input.
+  if (!ttValidString($cl_name)) $errors->add($i18n->getKey('error.field'), $i18n->getKey('label.thing_name'));
+
+  if ($errors->isEmpty()) {
+    $res = CustomFields::updateField($cl_id, $cl_name, $cl_type, $cl_required);
+    if ($res) {
+      header('Location: cf_custom_fields.php');
+      exit();
+    } else {
+      $errors->add($i18n->getKey('error.db'));
+    }
+  }
+}
+
+$smarty->assign('forms', array($form->getName()=>$form->toArray()));
+$smarty->assign('onload', 'onLoad="document.fieldForm.name.focus()"');
+$smarty->assign('title', $i18n->getKey('title.cf_edit_custom_field'));
+$smarty->assign('content_page_name', 'cf_custom_field_edit.tpl');
+$smarty->display('index.tpl');
+?>
\ No newline at end of file
diff --git a/cf_custom_fields.php b/cf_custom_fields.php
new file mode 100644 (file)
index 0000000..942817d
--- /dev/null
@@ -0,0 +1,61 @@
+<?php
+// +----------------------------------------------------------------------+
+// | Anuko Time Tracker
+// +----------------------------------------------------------------------+
+// | Copyright (c) Anuko International Ltd. (https://www.anuko.com)
+// +----------------------------------------------------------------------+
+// | LIBERAL FREEWARE LICENSE: This source code document may be used
+// | by anyone for any purpose, and freely redistributed alone or in
+// | combination with other software, provided that the license is obeyed.
+// |
+// | There are only two ways to violate the license:
+// |
+// | 1. To redistribute this code in source form, with the copyright
+// |    notice or license removed or altered. (Distributing in compiled
+// |    forms without embedded copyright notices is permitted).
+// |
+// | 2. To redistribute modified versions of this code in *any* form
+// |    that bears insufficient indications that the modifications are
+// |    not the work of the original author(s).
+// |
+// | This license applies to this document only, not any other software
+// | that it may be combined with.
+// |
+// +----------------------------------------------------------------------+
+// | Contributors:
+// | https://www.anuko.com/time_tracker/credits.htm
+// +----------------------------------------------------------------------+
+
+require_once('initialize.php');
+require_once('plugins/CustomFields.class.php');
+import('form.Form');
+
+// Access check.
+if (!ttAccessCheck(right_manage_team)) {
+  header('Location: access_denied.php');
+  exit();
+}
+
+$form = new Form('customFieldsForm');
+
+if ($request->getMethod() == 'POST') {
+  if ($request->getParameter('btn_add')) {
+       // The Add button clicked. Redirect to cf_custom_field_add.php page.
+       header('Location: cf_custom_field_add.php');
+       exit();
+  }
+} else {
+  $form->addInput(array('type'=>'submit','name'=>'btn_add','value'=>$i18n->getKey('button.add')));
+       
+  $fields = CustomFields::getFields();
+  // At this time only one custom field is supported. Disable the Add button if we already have one or more custom fields.
+  if (count($fields) > 0)
+    $form->getElement('btn_add')->setEnable(false);
+}
+
+$smarty->assign('forms', array($form->getName()=>$form->toArray()));
+$smarty->assign('custom_fields', $fields);
+$smarty->assign('title', $i18n->getKey('title.cf_custom_fields'));
+$smarty->assign('content_page_name', 'cf_custom_fields.tpl');
+$smarty->display('index.tpl');
+?>
\ No newline at end of file
diff --git a/cf_dropdown_option_add.php b/cf_dropdown_option_add.php
new file mode 100644 (file)
index 0000000..d13c33b
--- /dev/null
@@ -0,0 +1,73 @@
+<?php
+// +----------------------------------------------------------------------+
+// | Anuko Time Tracker
+// +----------------------------------------------------------------------+
+// | Copyright (c) Anuko International Ltd. (https://www.anuko.com)
+// +----------------------------------------------------------------------+
+// | LIBERAL FREEWARE LICENSE: This source code document may be used
+// | by anyone for any purpose, and freely redistributed alone or in
+// | combination with other software, provided that the license is obeyed.
+// |
+// | There are only two ways to violate the license:
+// |
+// | 1. To redistribute this code in source form, with the copyright
+// |    notice or license removed or altered. (Distributing in compiled
+// |    forms without embedded copyright notices is permitted).
+// |
+// | 2. To redistribute modified versions of this code in *any* form
+// |    that bears insufficient indications that the modifications are
+// |    not the work of the original author(s).
+// |
+// | This license applies to this document only, not any other software
+// | that it may be combined with.
+// |
+// +----------------------------------------------------------------------+
+// | Contributors:
+// | https://www.anuko.com/time_tracker/credits.htm
+// +----------------------------------------------------------------------+
+
+require_once('initialize.php');
+require_once('plugins/CustomFields.class.php');
+import('form.Form');
+
+// Access check.
+if (!ttAccessCheck(right_manage_team)) {
+  header('Location: access_denied.php');
+  exit();
+}
+
+$cl_field_id = $request->getParameter('field_id');
+$field = CustomFields::getField($cl_field_id);
+if (false === $field)
+  $errors->add($i18n->getKey('error.db'));
+    
+$form = new Form('optionAddForm');
+if ($errors->isEmpty()) {
+  $form->addInput(array('type'=>'hidden','name'=>'field_id','value'=>$cl_field_id));
+  $form->addInput(array('type'=>'text','maxlength'=>'100','name'=>'name','value'=>''));
+  $form->addInput(array('type'=>'submit','name'=>'btn_add','value'=>$i18n->getKey('button.add')));
+}
+  
+if ($request->getMethod() == 'POST') {
+  $cl_option_name = trim($request->getParameter('name'));
+  
+  // Validate user input.
+  if (!ttValidString($cl_option_name)) $errors->add($i18n->getKey('error.field'), $i18n->getKey('label.thing_name'));
+         
+  if ($errors->isEmpty()) {
+       $res = CustomFields::insertOption($cl_field_id, $cl_option_name);
+    if ($res) {
+      header("Location: cf_dropdown_options.php?field_id=$cl_field_id");
+      exit();
+    } else {
+      $errors->add($i18n->getKey('error.db'));
+    }
+  }
+}
+
+$smarty->assign('forms', array($form->getName()=>$form->toArray()));
+$smarty->assign('onload', 'onLoad="document.optionAddForm.name.focus()"');
+$smarty->assign('title', $i18n->getKey('title.cf_add_dropdown_option'));
+$smarty->assign('content_page_name', 'cf_dropdown_option_add.tpl');
+$smarty->display('index.tpl');
+?>
\ No newline at end of file
diff --git a/cf_dropdown_option_delete.php b/cf_dropdown_option_delete.php
new file mode 100644 (file)
index 0000000..8ae9456
--- /dev/null
@@ -0,0 +1,79 @@
+<?php
+// +----------------------------------------------------------------------+
+// | Anuko Time Tracker
+// +----------------------------------------------------------------------+
+// | Copyright (c) Anuko International Ltd. (https://www.anuko.com)
+// +----------------------------------------------------------------------+
+// | LIBERAL FREEWARE LICENSE: This source code document may be used
+// | by anyone for any purpose, and freely redistributed alone or in
+// | combination with other software, provided that the license is obeyed.
+// |
+// | There are only two ways to violate the license:
+// |
+// | 1. To redistribute this code in source form, with the copyright
+// |    notice or license removed or altered. (Distributing in compiled
+// |    forms without embedded copyright notices is permitted).
+// |
+// | 2. To redistribute modified versions of this code in *any* form
+// |    that bears insufficient indications that the modifications are
+// |    not the work of the original author(s).
+// |
+// | This license applies to this document only, not any other software
+// | that it may be combined with.
+// |
+// +----------------------------------------------------------------------+
+// | Contributors:
+// | https://www.anuko.com/time_tracker/credits.htm
+// +----------------------------------------------------------------------+
+
+require_once('initialize.php');
+require_once('plugins/CustomFields.class.php');
+import('form.Form');
+
+// Access check.
+if (!ttAccessCheck(right_manage_team)) {
+  header('Location: access_denied.php');
+  exit();
+}
+
+$cl_id = $request->getParameter('id');
+$form = new Form('optionDeleteForm');
+
+if ($request->getMethod() == 'POST') {
+
+  // Determine field id for redirect.
+  $field_id = CustomFields::getFieldIdForOption($cl_id);
+  if ($request->getParameter('btn_delete'))  {
+       // Delete button pressed.
+       $res = CustomFields::deleteOption($cl_id);
+    if ($res) {
+      header("Location: cf_dropdown_options.php?field_id=$field_id");
+      exit();
+    } else {
+      $errors->add($i18n->getKey('error.db'));
+    }
+  }
+  if ($request->getParameter('btn_cancel')) {
+       // Cancel button pressed.
+       header("Location: cf_dropdown_options.php?field_id=$field_id");
+       exit();
+  }
+} else {
+  $option = CustomFields::getOptionName($cl_id);       
+  if (false === $option)
+    $errors->add($i18n->getKey('error.db'));
+
+  if ($errors->isEmpty()) {
+    $form->addInput(array('type'=>'hidden','name'=>'id','value'=>$cl_id));
+    $form->addInput(array('type'=>'submit','name'=>'btn_delete','value'=>$i18n->getKey('label.delete')));
+    $form->addInput(array('type'=>'submit','name'=>'btn_cancel','value'=>$i18n->getKey('button.cancel')));
+  }
+}
+       
+$smarty->assign('option', $option);
+$smarty->assign('forms', array($form->getName()=>$form->toArray()));
+$smarty->assign('onload', 'onLoad="document.optionDeleteForm.btn_cancel.focus()"');
+$smarty->assign('title', $i18n->getKey('title.cf_delete_dropdown_option'));
+$smarty->assign('content_page_name', 'cf_dropdown_option_delete.tpl');
+$smarty->display('index.tpl');
+?>
\ No newline at end of file
diff --git a/cf_dropdown_option_edit.php b/cf_dropdown_option_edit.php
new file mode 100644 (file)
index 0000000..bd19043
--- /dev/null
@@ -0,0 +1,75 @@
+<?php
+// +----------------------------------------------------------------------+
+// | Anuko Time Tracker
+// +----------------------------------------------------------------------+
+// | Copyright (c) Anuko International Ltd. (https://www.anuko.com)
+// +----------------------------------------------------------------------+
+// | LIBERAL FREEWARE LICENSE: This source code document may be used
+// | by anyone for any purpose, and freely redistributed alone or in
+// | combination with other software, provided that the license is obeyed.
+// |
+// | There are only two ways to violate the license:
+// |
+// | 1. To redistribute this code in source form, with the copyright
+// |    notice or license removed or altered. (Distributing in compiled
+// |    forms without embedded copyright notices is permitted).
+// |
+// | 2. To redistribute modified versions of this code in *any* form
+// |    that bears insufficient indications that the modifications are
+// |    not the work of the original author(s).
+// |
+// | This license applies to this document only, not any other software
+// | that it may be combined with.
+// |
+// +----------------------------------------------------------------------+
+// | Contributors:
+// | https://www.anuko.com/time_tracker/credits.htm
+// +----------------------------------------------------------------------+
+
+require_once('initialize.php');
+require_once('plugins/CustomFields.class.php');
+import('form.Form');
+
+// Access check.
+if (!ttAccessCheck(right_manage_team)) {
+  header('Location: access_denied.php');
+  exit();
+}
+
+$cl_id = $request->getParameter('id');
+$cl_name = CustomFields::getOptionName($cl_id);
+if (false === $cl_name)
+  $errors->add($i18n->getKey('error.db'));
+
+$form = new Form('optionEditForm');
+if ($errors->isEmpty()) {
+  $form->addInput(array('type'=>'text','maxlength'=>'100','name'=>'name','value'=>$cl_name));
+  $form->addInput(array('type'=>'hidden','name'=>'id','value'=>$cl_id));
+  $form->addInput(array('type'=>'submit','name'=>'btn_save','value'=>$i18n->getKey('button.save')));
+}      
+
+if ($request->getMethod() == 'POST') {
+  $cl_name = trim($request->getParameter('name'));
+  
+  // Validate user input.
+  if (!ttValidString($cl_name)) $errors->add($i18n->getKey('error.field'), $i18n->getKey('label.thing_name'));
+
+  if ($errors->isEmpty()) {
+    $res = CustomFields::updateOption($cl_id, $cl_name);
+    if ($res) {
+      // Determine field id for redirect.
+      $field_id = CustomFields::getFieldIdForOption($cl_id);
+      header("Location: cf_dropdown_options.php?field_id=$field_id");
+      exit();
+    } else {
+      $errors->add($i18n->getKey('error.db'));
+    }
+  }
+}
+
+$smarty->assign('forms', array($form->getName()=>$form->toArray()));
+$smarty->assign('onload', 'onLoad="document.optionEditForm.name.focus()"');
+$smarty->assign('title', $i18n->getKey('title.cf_edit_dropdown_option'));
+$smarty->assign('content_page_name', 'cf_dropdown_option_edit.tpl');
+$smarty->display('index.tpl');
+?>
\ No newline at end of file
diff --git a/cf_dropdown_options.php b/cf_dropdown_options.php
new file mode 100644 (file)
index 0000000..c8713ca
--- /dev/null
@@ -0,0 +1,52 @@
+<?php
+// +----------------------------------------------------------------------+
+// | Anuko Time Tracker
+// +----------------------------------------------------------------------+
+// | Copyright (c) Anuko International Ltd. (https://www.anuko.com)
+// +----------------------------------------------------------------------+
+// | LIBERAL FREEWARE LICENSE: This source code document may be used
+// | by anyone for any purpose, and freely redistributed alone or in
+// | combination with other software, provided that the license is obeyed.
+// |
+// | There are only two ways to violate the license:
+// |
+// | 1. To redistribute this code in source form, with the copyright
+// |    notice or license removed or altered. (Distributing in compiled
+// |    forms without embedded copyright notices is permitted).
+// |
+// | 2. To redistribute modified versions of this code in *any* form
+// |    that bears insufficient indications that the modifications are
+// |    not the work of the original author(s).
+// |
+// | This license applies to this document only, not any other software
+// | that it may be combined with.
+// |
+// +----------------------------------------------------------------------+
+// | Contributors:
+// | https://www.anuko.com/time_tracker/credits.htm
+// +----------------------------------------------------------------------+
+
+require_once('initialize.php');
+require_once('plugins/CustomFields.class.php');
+import('form.Form');
+
+// Access check.
+if (!ttAccessCheck(right_manage_team)) {
+  header('Location: access_denied.php');
+  exit();
+}
+
+$field_id = $request->getParameter('field_id');
+$options = CustomFields::getOptions($field_id);
+if (false === $options)
+  $errors->add($i18n->getKey('error.db'));
+
+$form = new Form('dropdownOptionsForm');
+
+$smarty->assign('forms', array($form->getName()=>$form->toArray()));
+$smarty->assign('field_id', $field_id);
+$smarty->assign('options', $options);
+$smarty->assign('title', $i18n->getKey('title.cf_dropdown_options'));
+$smarty->assign('content_page_name', 'cf_dropdown_options.tpl');
+$smarty->display('index.tpl');
+?>
\ No newline at end of file