From e616d14ff2173bd13155592c0bdba23636376ffe Mon Sep 17 00:00:00 2001 From: Nik Okuntseff Date: Thu, 22 Mar 2018 23:49:20 +0000 Subject: [PATCH] Moving away from using the timestamp field. --- WEB-INF/lib/ttAdmin.class.php | 15 ++++++++++----- WEB-INF/lib/ttTeamHelper.class.php | 8 ++++---- WEB-INF/templates/footer.tpl | 2 +- admin_options.php | 20 ++++++++++++++++++++ admin_team_edit.php | 2 +- 5 files changed, 36 insertions(+), 11 deletions(-) diff --git a/WEB-INF/lib/ttAdmin.class.php b/WEB-INF/lib/ttAdmin.class.php index 9e29eeeb..87fe00bc 100644 --- a/WEB-INF/lib/ttAdmin.class.php +++ b/WEB-INF/lib/ttAdmin.class.php @@ -183,8 +183,8 @@ class ttAdmin { return true; } - // validateTeamInfo validates team information entered by user. - function validateTeamInfo($fields) { + // validateGroupInfo validates group information entered by user. + function validateGroupInfo($fields) { global $i18n; global $auth; @@ -233,9 +233,9 @@ class ttAdmin { return $result; } - // updateTeam validates user input and updates the team with new information. - function updateTeam($team_id, $fields) { - if (!$this->validateTeamInfo($fields)) return false; // Can't continue as user input is invalid. + // updateGroup validates user input and updates the group with new information. + function updateGroup($team_id, $fields) { + if (!$this->validateGroupInfo($fields)) return false; // Can't continue as user input is invalid. global $user; $mdb2 = getConnection(); @@ -263,4 +263,9 @@ class ttAdmin { return true; } + + // updateSelf validates user input and updates admin account with new information. + function updateSelf($fields) { + return false; // Not yet implemeneted. + } } diff --git a/WEB-INF/lib/ttTeamHelper.class.php b/WEB-INF/lib/ttTeamHelper.class.php index 1c9e30fd..9f3e0a90 100644 --- a/WEB-INF/lib/ttTeamHelper.class.php +++ b/WEB-INF/lib/ttTeamHelper.class.php @@ -898,8 +898,8 @@ class ttTeamHelper { // Get all team ids for teams created or modified more than 8 months ago. // $ts = date('Y-m-d', strtotime('-1 year')); - $ts = date('Y-m-d', strtotime('-8 month')); - $sql = "select id from tt_teams where timestamp < '$ts' order by id"; + $ts = $mdb2->quote(date('Y-m-d', strtotime('-8 month'))); + $sql = "select id from tt_teams where created < $ts and (modified is null or modified < $ts) order by id"; $res = $mdb2->query($sql); $count = 0; @@ -935,7 +935,7 @@ class ttTeamHelper { $count = 0; $ts = date('Y-m-d', strtotime('-2 years')); - $sql = "select count(*) as cnt from tt_log where user_id in ($user_list) and timestamp > '$ts'"; + $sql = "select count(*) as cnt from tt_log where user_id in ($user_list) and created > '$ts'"; $res = $mdb2->query($sql); if (!is_a($res, 'PEAR_Error')) { if ($val = $res->fetchRow()) { @@ -950,7 +950,7 @@ class ttTeamHelper { // We will consider a team inactive if it has 5 or less time entries made more than 1 year ago. $count_last_year = 0; $ts = date('Y-m-d', strtotime('-1 year')); - $sql = "select count(*) as cnt from tt_log where user_id in ($user_list) and timestamp > '$ts'"; + $sql = "select count(*) as cnt from tt_log where user_id in ($user_list) and created > '$ts'"; $res = $mdb2->query($sql); if (!is_a($res, 'PEAR_Error')) { if ($val = $res->fetchRow()) { diff --git a/WEB-INF/templates/footer.tpl b/WEB-INF/templates/footer.tpl index 1ddc76d9..0427ace0 100644 --- a/WEB-INF/templates/footer.tpl +++ b/WEB-INF/templates/footer.tpl @@ -12,7 +12,7 @@
-
 Anuko Time Tracker 1.17.65.4136 | Copyright © Anuko | +  Anuko Time Tracker 1.17.65.4137 | Copyright © Anuko | {$i18n.footer.credits} | {$i18n.footer.license} | {$i18n.footer.improve} diff --git a/admin_options.php b/admin_options.php index 6f812558..e728c830 100644 --- a/admin_options.php +++ b/admin_options.php @@ -61,6 +61,26 @@ $form->addInput(array('type'=>'text','maxlength'=>'100','name'=>'email','value'= $form->addInput(array('type'=>'submit','name'=>'btn_submit','value'=>$i18n->getKey('button.submit'))); if ($request->isPost()) { +/* + * This is work in progress... refactoring to replace the block below. + + // Create fields array for ttAdmin instance. + $fields = array( + 'name' => $cl_name, + 'login' => $cl_login, + 'password1' => $cl_password1, + 'password2' => $cl_password2, + 'email' => $cl_email); + + import('ttAdmin'); + $admin = new ttAdmin($err); + $result = $admin->updateSelf($fields); + if ($result) { + header('Location: admin_teams.php'); + exit(); + } + */ + // Validate user input. if (!ttValidString($cl_name)) $err->add($i18n->getKey('error.field'), $i18n->getKey('label.person_name')); if (!ttValidString($cl_login)) $err->add($i18n->getKey('error.field'), $i18n->getKey('label.login')); diff --git a/admin_team_edit.php b/admin_team_edit.php index 42884585..63f8fe7a 100644 --- a/admin_team_edit.php +++ b/admin_team_edit.php @@ -88,7 +88,7 @@ if ($request->isPost()) { import('ttAdmin'); $admin = new ttAdmin($err); - $result = $admin->updateTeam($team_id, $fields); + $result = $admin->updateGroup($team_id, $fields); if ($result) { header('Location: admin_teams.php'); exit(); -- 2.20.1