From 91f127aa192430faa62c59530f42ee5d82b9f7e3 Mon Sep 17 00:00:00 2001 From: Nik Okuntseff Date: Sat, 1 Dec 2018 15:46:45 +0000 Subject: [PATCH] Some optimization related to confirm save feature. --- WEB-INF/lib/ttGroup.class.php | 2 -- WEB-INF/lib/ttUser.class.php | 12 +++++++----- WEB-INF/templates/footer.tpl | 2 +- expense_edit.php | 2 +- mobile/expense_edit.php | 2 +- mobile/time_edit.php | 2 +- time_edit.php | 2 +- 7 files changed, 12 insertions(+), 12 deletions(-) diff --git a/WEB-INF/lib/ttGroup.class.php b/WEB-INF/lib/ttGroup.class.php index 86536349..44e225b2 100644 --- a/WEB-INF/lib/ttGroup.class.php +++ b/WEB-INF/lib/ttGroup.class.php @@ -50,7 +50,6 @@ class ttGroup { var $allow_overlap = 0; // Whether to allow overlapping time entries. var $future_entries = 0; // Whether to allow creating future entries. var $uncompleted_indicators = 0; // Uncompleted time entry indicators (show nowhere or on users page). - var $confirm_save = 0; // Whether to show warnings for save action when date changed. var $bcc_email = null; // Bcc email. var $allow_ip = null; // Specification from where user is allowed access. var $password_complexity = null; // Password complexity example. @@ -112,7 +111,6 @@ class ttGroup { $this->allow_overlap = $config->getDefinedValue('allow_overlap'); $this->future_entries = $config->getDefinedValue('future_entries'); $this->uncompleted_indicators = $config->getDefinedValue('uncompleted_indicators'); - $this->confirm_save = $config->getDefinedValue('confirm_save'); /* if ($this->isPluginEnabled('wu')) { $minutes_in_unit = $config->getIntValue('minutes_in_unit'); diff --git a/WEB-INF/lib/ttUser.class.php b/WEB-INF/lib/ttUser.class.php index 7a102a27..60f4f984 100644 --- a/WEB-INF/lib/ttUser.class.php +++ b/WEB-INF/lib/ttUser.class.php @@ -60,7 +60,6 @@ class ttUser { var $allow_overlap = 0; // Whether to allow overlapping time entries. var $future_entries = 0; // Whether to allow creating future entries. var $uncompleted_indicators = 0; // Uncompleted time entry indicators (show nowhere or on users page). - var $confirm_save = 0; // Whether to show warnings for save action when date changed. var $bcc_email = null; // Bcc email. var $allow_ip = null; // Specification from where user is allowed access. var $password_complexity = null; // Password complexity example. @@ -144,7 +143,6 @@ class ttUser { $this->allow_overlap = $config->getDefinedValue('allow_overlap'); $this->future_entries = $config->getDefinedValue('future_entries'); $this->uncompleted_indicators = $config->getDefinedValue('uncompleted_indicators'); - $this->confirm_save = $config->getDefinedValue('confirm_save'); if ($this->isPluginEnabled('wu')) { $minutes_in_unit = $config->getIntValue('minutes_in_unit'); if ($minutes_in_unit) $this->minutes_in_unit = $minutes_in_unit; @@ -203,9 +201,13 @@ class ttUser { return ($this->behalfGroup ? $this->behalfGroup->config : $this->config); } - // getConfirmSave returns confirm_save option for user. - function getConfirmSave() { - return ($this->behalfGroup ? $this->behalfGroup->confirm_save : $this->confirm_save); + // getConfigOption returns true if an option is defined for group. + // This helps us keeping a set of user attributes smaller. + // We determine whether the option is set only on pages that need to know. + // For example: confirm_save is used only on time and expense edit pages. + function getConfigOption($name) { + $config = new ttConfigHelper($this->getConfig()); + return $config->getDefinedValue($name); } // can - determines whether user has a right to do something. diff --git a/WEB-INF/templates/footer.tpl b/WEB-INF/templates/footer.tpl index 90b3e900..b17fa675 100644 --- a/WEB-INF/templates/footer.tpl +++ b/WEB-INF/templates/footer.tpl @@ -12,7 +12,7 @@
-
 Anuko Time Tracker 1.18.29.4554 | Copyright © Anuko | +  Anuko Time Tracker 1.18.29.4555 | Copyright © Anuko | {$i18n.footer.credits} | {$i18n.footer.license} | {$i18n.footer.improve} diff --git a/expense_edit.php b/expense_edit.php index a4bb6a4f..9768fa23 100644 --- a/expense_edit.php +++ b/expense_edit.php @@ -51,7 +51,7 @@ if (!$expense_item || $expense_item['invoice_id']) { } $item_date = new DateAndTime(DB_DATEFORMAT, $expense_item['date']); -$confirm_save = $user->getConfirmSave(); +$confirm_save = $user->getConfigOption('confirm_save'); // Initialize variables. $cl_date = $cl_client = $cl_project = $cl_item_name = $cl_cost = null; diff --git a/mobile/expense_edit.php b/mobile/expense_edit.php index 9cae0181..d139530c 100644 --- a/mobile/expense_edit.php +++ b/mobile/expense_edit.php @@ -51,7 +51,7 @@ if (!$expense_item || $expense_item['invoice_id']) { } $item_date = new DateAndTime(DB_DATEFORMAT, $expense_item['date']); -$confirm_save = $user->getConfirmSave(); +$confirm_save = $user->getConfigOption('confirm_save'); // Initialize variables. $cl_date = $cl_client = $cl_project = $cl_item_name = $cl_cost = null; diff --git a/mobile/time_edit.php b/mobile/time_edit.php index 3094df64..92522043 100644 --- a/mobile/time_edit.php +++ b/mobile/time_edit.php @@ -57,7 +57,7 @@ if ($user->isPluginEnabled('cf')) { } $item_date = new DateAndTime(DB_DATEFORMAT, $time_rec['date']); -$confirm_save = $user->getConfirmSave(); +$confirm_save = $user->getConfigOption('confirm_save'); // Initialize variables. $cl_start = $cl_finish = $cl_duration = $cl_date = $cl_note = $cl_project = $cl_task = $cl_billable = null; diff --git a/time_edit.php b/time_edit.php index 5dd958b5..08a5f392 100644 --- a/time_edit.php +++ b/time_edit.php @@ -57,7 +57,7 @@ if ($user->isPluginEnabled('cf')) { } $item_date = new DateAndTime(DB_DATEFORMAT, $time_rec['date']); -$confirm_save = $user->getConfirmSave(); +$confirm_save = $user->getConfigOption('confirm_save'); // Initialize variables. $cl_start = $cl_finish = $cl_duration = $cl_date = $cl_note = $cl_project = $cl_task = $cl_billable = null; -- 2.20.1