From f22a586b11af9c617fdc4241d3ffa0344d4d6a50 Mon Sep 17 00:00:00 2001 From: Nik Okuntseff Date: Mon, 29 Apr 2019 16:09:21 +0000 Subject: [PATCH] Refactoring. Moved week_menu config option to plugin config. --- WEB-INF/lib/ttUser.class.php | 5 +++++ WEB-INF/lib/ttWeekViewHelper.class.php | 12 +++++++----- WEB-INF/resources/ca.lang.php | 1 + WEB-INF/resources/cs.lang.php | 1 + WEB-INF/resources/da.lang.php | 1 + WEB-INF/resources/de.lang.php | 1 + WEB-INF/resources/en.lang.php | 1 + WEB-INF/resources/es.lang.php | 1 + WEB-INF/resources/et.lang.php | 2 ++ WEB-INF/resources/fa.lang.php | 1 + WEB-INF/resources/fi.lang.php | 1 + WEB-INF/resources/fr.lang.php | 1 + WEB-INF/resources/gr.lang.php | 2 ++ WEB-INF/resources/he.lang.php | 1 + WEB-INF/resources/hu.lang.php | 1 + WEB-INF/resources/it.lang.php | 2 ++ WEB-INF/resources/ja.lang.php | 1 + WEB-INF/resources/ko.lang.php | 1 + WEB-INF/resources/nl.lang.php | 2 ++ WEB-INF/resources/no.lang.php | 1 + WEB-INF/resources/pl.lang.php | 1 + WEB-INF/resources/pt-br.lang.php | 1 + WEB-INF/resources/pt.lang.php | 1 + WEB-INF/resources/ro.lang.php | 1 + WEB-INF/resources/ru.lang.php | 1 + WEB-INF/resources/sk.lang.php | 3 ++- WEB-INF/resources/sl.lang.php | 1 + WEB-INF/resources/sr.lang.php | 3 ++- WEB-INF/resources/sv.lang.php | 1 + WEB-INF/resources/tr.lang.php | 1 + WEB-INF/resources/zh-cn.lang.php | 1 + WEB-INF/resources/zh-tw.lang.php | 1 + WEB-INF/templates/display_options.tpl | 9 --------- WEB-INF/templates/footer.tpl | 2 +- WEB-INF/templates/header.tpl | 2 +- WEB-INF/templates/week.tpl | 6 +++--- WEB-INF/templates/week_view.tpl | 4 ++++ display_options.php | 8 +------- group_edit.php | 2 +- plugins.php | 10 ---------- week.php | 27 ++++++++++++++++---------- week_view.php | 22 +++++++++++++-------- 42 files changed, 90 insertions(+), 57 deletions(-) diff --git a/WEB-INF/lib/ttUser.class.php b/WEB-INF/lib/ttUser.class.php index 14e7007b..62c786ce 100644 --- a/WEB-INF/lib/ttUser.class.php +++ b/WEB-INF/lib/ttUser.class.php @@ -248,6 +248,11 @@ class ttUser { return ($this->behalfGroup ? $this->behalfGroup->configHelper->getConfig() : $this->configHelper->getConfig()); } + // getConfigHelper returns ttConfigHelper instance for active group. + function getConfigHelper() { + return ($this->behalfGroup ? $this->behalfGroup->configHelper : $this->configHelper); + } + // 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. diff --git a/WEB-INF/lib/ttWeekViewHelper.class.php b/WEB-INF/lib/ttWeekViewHelper.class.php index 1144cea6..34864816 100644 --- a/WEB-INF/lib/ttWeekViewHelper.class.php +++ b/WEB-INF/lib/ttWeekViewHelper.class.php @@ -167,6 +167,7 @@ class ttWeekViewHelper { global $i18n; $dataArray = array(); + $includeNotes = $user->isOptionEnabled('week_notes'); // Construct the first row for a brand new entry. $dataArray[] = array('row_id' => null,'label' => $i18n->get('form.week.new_entry').':'); // Insert row. @@ -175,7 +176,7 @@ class ttWeekViewHelper { $control_id = '0_'. $dayHeaders[$i]; $dataArray[0][$dayHeaders[$i]] = array('control_id' => $control_id, 'tt_log_id' => null,'duration' => null); } - if ($user->isPluginEnabled('wvns')) { + if ($includeNotes) { // Construct the second row for daily comments for a brand new entry. $dataArray[] = array('row_id' => null,'label' => $i18n->get('label.notes').':'); // Insert row. // Insert empty cells with proper control ids. @@ -209,7 +210,7 @@ class ttWeekViewHelper { $dataArray[$pos][$dayHeaders[$i]] = array('control_id' => $control_id, 'tt_log_id' => null,'duration' => null); } // Insert row for comments. - if ($user->isPluginEnabled('wvns')) { + if ($includeNotes) { $dataArray[] = array('row_id' => $row_id.'_notes','label' => $i18n->get('label.notes').':'); $pos++; // Insert empty cells with proper control ids. @@ -223,7 +224,7 @@ class ttWeekViewHelper { // Insert actual cell data from $record (one cell only). $dataArray[$pos][$day_header] = array('control_id' => $pos.'_'. $day_header, 'tt_log_id' => $record['id'],'duration' => $record['duration']); // Insert existing comment from $record into the comment cell. - if ($user->isPluginEnabled('wvns')) { + if ($includeNotes) { $pos++; $dataArray[$pos][$day_header] = array('control_id' => $pos.'_'. $day_header, 'tt_log_id' => $record['id'],'note' => $record['comment']); } @@ -273,7 +274,8 @@ class ttWeekViewHelper { $control_id = '0_'. $dayHeaders[$i]; $dataArray[0][$dayHeaders[$i]] = array('control_id' => $control_id, 'tt_log_id' => null,'duration' => null); } - if ($user->isPluginEnabled('wvns')) { + $includeNotes = $user->isOptionEnabled('week_notes'); + if ($includeNotes) { // Construct the second row for daily comments for a brand new entry. $dataArray[] = array('row_id' => null,'label' => $i18n->get('label.notes').':'); // Insert row. // Insert empty cells with proper control ids. @@ -299,7 +301,7 @@ class ttWeekViewHelper { $dataArray[$pos][$dayHeaders[$i]] = array('control_id' => $control_id, 'tt_log_id' => null,'duration' => null); } // Insert row for comments. - if ($user->isPluginEnabled('wvns')) { + if ($includeNotes) { $dataArray[] = array('row_id' => $row_id.'_notes','label' => $i18n->get('label.notes').':'); $pos++; // Insert empty cells with proper control ids. diff --git a/WEB-INF/resources/ca.lang.php b/WEB-INF/resources/ca.lang.php index e24a13d5..bd3af048 100644 --- a/WEB-INF/resources/ca.lang.php +++ b/WEB-INF/resources/ca.lang.php @@ -259,6 +259,7 @@ $i18n_key_words = array( // 'label.paid_status' => 'Paid status', // 'label.paid' => 'Paid', // 'label.mark_paid' => 'Mark paid', +// 'label.week_menu' => 'Week menu', // 'label.week_note' => 'Week note', // 'label.week_list' => 'Week list', // 'label.work_units' => 'Work units', diff --git a/WEB-INF/resources/cs.lang.php b/WEB-INF/resources/cs.lang.php index 2aa9ebb3..2d6f06ce 100644 --- a/WEB-INF/resources/cs.lang.php +++ b/WEB-INF/resources/cs.lang.php @@ -269,6 +269,7 @@ $i18n_key_words = array( // 'label.paid_status' => 'Paid status', // 'label.paid' => 'Paid', // 'label.mark_paid' => 'Mark paid', +// 'label.week_menu' => 'Week menu', // 'label.week_note' => 'Week note', // 'label.week_list' => 'Week list', // 'label.work_units' => 'Work units', diff --git a/WEB-INF/resources/da.lang.php b/WEB-INF/resources/da.lang.php index aa4e97be..70b55920 100644 --- a/WEB-INF/resources/da.lang.php +++ b/WEB-INF/resources/da.lang.php @@ -248,6 +248,7 @@ $i18n_key_words = array( // 'label.paid_status' => 'Paid status', // 'label.paid' => 'Paid', // 'label.mark_paid' => 'Mark paid', +// 'label.week_menu' => 'Week menu', // 'label.week_note' => 'Week note', // 'label.week_list' => 'Week list', // 'label.work_units' => 'Work units', diff --git a/WEB-INF/resources/de.lang.php b/WEB-INF/resources/de.lang.php index 49837588..2863b31a 100644 --- a/WEB-INF/resources/de.lang.php +++ b/WEB-INF/resources/de.lang.php @@ -236,6 +236,7 @@ $i18n_key_words = array( 'label.paid_status' => 'Bezahlstatus', 'label.paid' => 'Bezahlt', 'label.mark_paid' => 'Als bezahlt setzen', +// 'label.week_menu' => 'Week menu', 'label.week_note' => 'Wochennotiz', 'label.week_list' => 'Wochenliste', 'label.work_units' => 'Arbeitseinheiten', diff --git a/WEB-INF/resources/en.lang.php b/WEB-INF/resources/en.lang.php index f7d8ac4b..9e5d4249 100644 --- a/WEB-INF/resources/en.lang.php +++ b/WEB-INF/resources/en.lang.php @@ -226,6 +226,7 @@ $i18n_key_words = array( 'label.paid_status' => 'Paid status', 'label.paid' => 'Paid', 'label.mark_paid' => 'Mark paid', +'label.week_menu' => 'Week menu', 'label.week_note' => 'Week note', 'label.week_list' => 'Week list', 'label.work_units' => 'Work units', diff --git a/WEB-INF/resources/es.lang.php b/WEB-INF/resources/es.lang.php index 97d3c50a..e56faf98 100644 --- a/WEB-INF/resources/es.lang.php +++ b/WEB-INF/resources/es.lang.php @@ -262,6 +262,7 @@ $i18n_key_words = array( // 'label.paid_status' => 'Paid status', // 'label.paid' => 'Paid', // 'label.mark_paid' => 'Mark paid', +// 'label.week_menu' => 'Week menu', // 'label.week_note' => 'Week note', // 'label.week_list' => 'Week list', // 'label.work_units' => 'Work units', diff --git a/WEB-INF/resources/et.lang.php b/WEB-INF/resources/et.lang.php index 41fe752c..81661146 100644 --- a/WEB-INF/resources/et.lang.php +++ b/WEB-INF/resources/et.lang.php @@ -252,6 +252,8 @@ $i18n_key_words = array( 'label.paid_status' => 'Makse olek', 'label.paid' => 'Makstud', 'label.mark_paid' => 'Märgi makstuks', +// TODO: translate the following. +// 'label.week_menu' => 'Week menu', 'label.week_note' => 'Nädala märge', 'label.week_list' => 'Nädala nimekiri', 'label.work_units' => 'Töö ühikud', diff --git a/WEB-INF/resources/fa.lang.php b/WEB-INF/resources/fa.lang.php index c3831228..f7bed309 100644 --- a/WEB-INF/resources/fa.lang.php +++ b/WEB-INF/resources/fa.lang.php @@ -260,6 +260,7 @@ $i18n_key_words = array( // 'label.paid_status' => 'Paid status', // 'label.paid' => 'Paid', // 'label.mark_paid' => 'Mark paid', +// 'label.week_menu' => 'Week menu', // 'label.week_note' => 'Week note', // 'label.week_list' => 'Week list', // 'label.work_units' => 'Work units', diff --git a/WEB-INF/resources/fi.lang.php b/WEB-INF/resources/fi.lang.php index 05750331..3db44e33 100644 --- a/WEB-INF/resources/fi.lang.php +++ b/WEB-INF/resources/fi.lang.php @@ -252,6 +252,7 @@ $i18n_key_words = array( // 'label.paid_status' => 'Paid status', // 'label.paid' => 'Paid', // 'label.mark_paid' => 'Mark paid', +// 'label.week_menu' => 'Week menu', // 'label.week_note' => 'Week note', // 'label.week_list' => 'Week list', // 'label.work_units' => 'Work units', diff --git a/WEB-INF/resources/fr.lang.php b/WEB-INF/resources/fr.lang.php index b8eb0d5b..b037216a 100644 --- a/WEB-INF/resources/fr.lang.php +++ b/WEB-INF/resources/fr.lang.php @@ -246,6 +246,7 @@ $i18n_key_words = array( // 'label.paid_status' => 'Paid status', // 'label.paid' => 'Paid', // 'label.mark_paid' => 'Mark paid', +// 'label.week_menu' => 'Week menu', // 'label.week_note' => 'Week note', // 'label.week_list' => 'Week list', // 'label.work_units' => 'Work units', diff --git a/WEB-INF/resources/gr.lang.php b/WEB-INF/resources/gr.lang.php index 49ab0a12..0e504e03 100644 --- a/WEB-INF/resources/gr.lang.php +++ b/WEB-INF/resources/gr.lang.php @@ -238,6 +238,8 @@ $i18n_key_words = array( 'label.paid_status' => 'Κατάσταση πληρωμής', 'label.paid' => 'Πληρωμένο', 'label.mark_paid' => 'Σήμανση πληρωμένα', +// TODO: translate the following. +// 'label.week_menu' => 'Week menu', 'label.week_note' => 'Σημείωση εβδομάδας', 'label.week_list' => 'Λίστα εβδομάδων', // TODO: translate the following. diff --git a/WEB-INF/resources/he.lang.php b/WEB-INF/resources/he.lang.php index d8e99d69..e3ffac91 100644 --- a/WEB-INF/resources/he.lang.php +++ b/WEB-INF/resources/he.lang.php @@ -268,6 +268,7 @@ $i18n_key_words = array( // 'label.paid_status' => 'Paid status', // 'label.paid' => 'Paid', // 'label.mark_paid' => 'Mark paid', +// 'label.week_menu' => 'Week menu', // 'label.week_note' => 'Week note', // 'label.week_list' => 'Week list', // 'label.work_units' => 'Work units', diff --git a/WEB-INF/resources/hu.lang.php b/WEB-INF/resources/hu.lang.php index 441db3fe..8cd38171 100644 --- a/WEB-INF/resources/hu.lang.php +++ b/WEB-INF/resources/hu.lang.php @@ -265,6 +265,7 @@ $i18n_key_words = array( // 'label.paid_status' => 'Paid status', // 'label.paid' => 'Paid', // 'label.mark_paid' => 'Mark paid', +// 'label.week_menu' => 'Week menu', // 'label.week_note' => 'Week note', // 'label.week_list' => 'Week list', // 'label.work_units' => 'Work units', diff --git a/WEB-INF/resources/it.lang.php b/WEB-INF/resources/it.lang.php index 4b76fef3..311e2c5d 100644 --- a/WEB-INF/resources/it.lang.php +++ b/WEB-INF/resources/it.lang.php @@ -242,6 +242,8 @@ $i18n_key_words = array( 'label.paid_status' => 'Stato pagamento', 'label.paid' => 'Pagato', 'label.mark_paid' => 'Segna come pagato', +// TODO: translate the following. +// 'label.week_menu' => 'Week menu', 'label.week_note' => 'Nota settimanale', 'label.week_list' => 'Lista settimanale', // TODO: translate the following. diff --git a/WEB-INF/resources/ja.lang.php b/WEB-INF/resources/ja.lang.php index 6db17410..dbb6b32c 100644 --- a/WEB-INF/resources/ja.lang.php +++ b/WEB-INF/resources/ja.lang.php @@ -269,6 +269,7 @@ $i18n_key_words = array( // 'label.paid_status' => 'Paid status', // 'label.paid' => 'Paid', // 'label.mark_paid' => 'Mark paid', +// 'label.week_menu' => 'Week menu', // 'label.week_note' => 'Week note', // 'label.week_list' => 'Week list', // 'label.work_units' => 'Work units', diff --git a/WEB-INF/resources/ko.lang.php b/WEB-INF/resources/ko.lang.php index d8ed7b8c..c39a44fd 100644 --- a/WEB-INF/resources/ko.lang.php +++ b/WEB-INF/resources/ko.lang.php @@ -269,6 +269,7 @@ $i18n_key_words = array( // 'label.paid_status' => 'Paid status', // 'label.paid' => 'Paid', // 'label.mark_paid' => 'Mark paid', +// 'label.week_menu' => 'Week menu', // 'label.week_note' => 'Week note', // 'label.week_list' => 'Week list', // 'label.work_units' => 'Work units', diff --git a/WEB-INF/resources/nl.lang.php b/WEB-INF/resources/nl.lang.php index 859741a2..dbfaccb5 100644 --- a/WEB-INF/resources/nl.lang.php +++ b/WEB-INF/resources/nl.lang.php @@ -226,6 +226,8 @@ $i18n_key_words = array( 'label.paid_status' => 'Status van betaling', 'label.paid' => 'Betaald', 'label.mark_paid' => 'Markeer als betaald', +// TODO: translate the following. +// 'label.week_menu' => 'Week menu', 'label.week_note' => 'Week aantekening', 'label.week_list' => 'Week overzicht', 'label.work_units' => 'Werk eenheid', diff --git a/WEB-INF/resources/no.lang.php b/WEB-INF/resources/no.lang.php index 5a108fc5..0ea49bbd 100644 --- a/WEB-INF/resources/no.lang.php +++ b/WEB-INF/resources/no.lang.php @@ -267,6 +267,7 @@ $i18n_key_words = array( // 'label.paid_status' => 'Paid status', // 'label.paid' => 'Paid', // 'label.mark_paid' => 'Mark paid', +// 'label.week_menu' => 'Week menu', // 'label.week_note' => 'Week note', // 'label.week_list' => 'Week list', // 'label.work_units' => 'Work units', diff --git a/WEB-INF/resources/pl.lang.php b/WEB-INF/resources/pl.lang.php index 60f5e1af..00ef9c00 100644 --- a/WEB-INF/resources/pl.lang.php +++ b/WEB-INF/resources/pl.lang.php @@ -253,6 +253,7 @@ $i18n_key_words = array( // 'label.paid_status' => 'Paid status', // 'label.paid' => 'Paid', // 'label.mark_paid' => 'Mark paid', +// 'label.week_menu' => 'Week menu', // 'label.week_note' => 'Week note', // 'label.week_list' => 'Week list', // 'label.work_units' => 'Work units', diff --git a/WEB-INF/resources/pt-br.lang.php b/WEB-INF/resources/pt-br.lang.php index 5013cde5..f45dab5b 100644 --- a/WEB-INF/resources/pt-br.lang.php +++ b/WEB-INF/resources/pt-br.lang.php @@ -250,6 +250,7 @@ $i18n_key_words = array( // 'label.paid_status' => 'Paid status', // 'label.paid' => 'Paid', // 'label.mark_paid' => 'Mark paid', +// 'label.week_menu' => 'Week menu', // 'label.week_note' => 'Week note', // 'label.week_list' => 'Week list', // 'label.work_units' => 'Work units', diff --git a/WEB-INF/resources/pt.lang.php b/WEB-INF/resources/pt.lang.php index cc44e6f1..27aed7b2 100644 --- a/WEB-INF/resources/pt.lang.php +++ b/WEB-INF/resources/pt.lang.php @@ -255,6 +255,7 @@ $i18n_key_words = array( // 'label.paid_status' => 'Paid status', // 'label.paid' => 'Paid', // 'label.mark_paid' => 'Mark paid', +// 'label.week_menu' => 'Week menu', // 'label.week_note' => 'Week note', // 'label.week_list' => 'Week list', // 'label.work_units' => 'Work units', diff --git a/WEB-INF/resources/ro.lang.php b/WEB-INF/resources/ro.lang.php index 94690cd5..a9bb3500 100644 --- a/WEB-INF/resources/ro.lang.php +++ b/WEB-INF/resources/ro.lang.php @@ -266,6 +266,7 @@ $i18n_key_words = array( // 'label.paid_status' => 'Paid status', // 'label.paid' => 'Paid', // 'label.mark_paid' => 'Mark paid', +// 'label.week_menu' => 'Week menu', // 'label.week_note' => 'Week note', // 'label.week_list' => 'Week list', // 'label.work_units' => 'Work units', diff --git a/WEB-INF/resources/ru.lang.php b/WEB-INF/resources/ru.lang.php index 22d9a2bd..c2022009 100644 --- a/WEB-INF/resources/ru.lang.php +++ b/WEB-INF/resources/ru.lang.php @@ -225,6 +225,7 @@ $i18n_key_words = array( 'label.paid_status' => 'Статус оплаты', 'label.paid' => 'Оплачено', 'label.mark_paid' => 'Отметить оплату', +'label.week_menu' => 'Меню недели', 'label.week_note' => 'Комментарий недели', 'label.week_list' => 'Список недели', 'label.work_units' => 'Единицы работы', diff --git a/WEB-INF/resources/sk.lang.php b/WEB-INF/resources/sk.lang.php index 664c26f5..249f4561 100644 --- a/WEB-INF/resources/sk.lang.php +++ b/WEB-INF/resources/sk.lang.php @@ -256,7 +256,8 @@ $i18n_key_words = array( // 'label.quantity' => 'Quantity', // 'label.paid_status' => 'Paid status', // 'label.paid' => 'Paid', -// 'button.mark_paid' => 'Mark paid', +// 'label.mark_paid' => 'Mark paid', +// 'label.week_menu' => 'Week menu', // 'label.week_note' => 'Week note', // 'label.week_list' => 'Week list', // 'label.work_units' => 'Work units', diff --git a/WEB-INF/resources/sl.lang.php b/WEB-INF/resources/sl.lang.php index d9001b1e..c56e11f4 100644 --- a/WEB-INF/resources/sl.lang.php +++ b/WEB-INF/resources/sl.lang.php @@ -250,6 +250,7 @@ $i18n_key_words = array( // 'label.paid_status' => 'Paid status', // 'label.paid' => 'Paid', // 'label.mark_paid' => 'Mark paid', +// 'label.week_menu' => 'Week menu', // 'label.week_note' => 'Week note', // 'label.week_list' => 'Week list', // 'label.work_units' => 'Work units', diff --git a/WEB-INF/resources/sr.lang.php b/WEB-INF/resources/sr.lang.php index 79769f9c..cdb4eae4 100644 --- a/WEB-INF/resources/sr.lang.php +++ b/WEB-INF/resources/sr.lang.php @@ -251,7 +251,8 @@ $i18n_key_words = array( // 'label.quantity' => 'Quantity', // 'label.paid_status' => 'Paid status', // 'label.paid' => 'Paid', -// 'button.mark_paid' => 'Mark paid', +// 'label.mark_paid' => 'Mark paid', +// 'label.week_menu' => 'Week menu', // 'label.week_note' => 'Week note', // 'label.week_list' => 'Week list', // 'label.work_units' => 'Work units', diff --git a/WEB-INF/resources/sv.lang.php b/WEB-INF/resources/sv.lang.php index a442a6e4..ab34828b 100644 --- a/WEB-INF/resources/sv.lang.php +++ b/WEB-INF/resources/sv.lang.php @@ -247,6 +247,7 @@ $i18n_key_words = array( // 'label.paid_status' => 'Paid status', // 'label.paid' => 'Paid', // 'label.mark_paid' => 'Mark paid', +// 'label.week_menu' => 'Week menu', // 'label.week_note' => 'Week note', // 'label.week_list' => 'Week list', // 'label.work_units' => 'Work units', diff --git a/WEB-INF/resources/tr.lang.php b/WEB-INF/resources/tr.lang.php index 2ed0eef3..fcebeebf 100644 --- a/WEB-INF/resources/tr.lang.php +++ b/WEB-INF/resources/tr.lang.php @@ -273,6 +273,7 @@ $i18n_key_words = array( // 'label.paid_status' => 'Paid status', // 'label.paid' => 'Paid', // 'label.mark_paid' => 'Mark paid', +// 'label.week_menu' => 'Week menu', // 'label.week_note' => 'Week note', // 'label.week_list' => 'Week list', // 'label.work_units' => 'Work units', diff --git a/WEB-INF/resources/zh-cn.lang.php b/WEB-INF/resources/zh-cn.lang.php index 868bf16a..62eff58d 100644 --- a/WEB-INF/resources/zh-cn.lang.php +++ b/WEB-INF/resources/zh-cn.lang.php @@ -259,6 +259,7 @@ $i18n_key_words = array( // 'label.paid_status' => 'Paid status', // 'label.paid' => 'Paid', // 'label.mark_paid' => 'Mark paid', +// 'label.week_menu' => 'Week menu', // 'label.week_note' => 'Week note', // 'label.week_list' => 'Week list', // 'label.work_units' => 'Work units', diff --git a/WEB-INF/resources/zh-tw.lang.php b/WEB-INF/resources/zh-tw.lang.php index fa8d4a00..82b9bc63 100644 --- a/WEB-INF/resources/zh-tw.lang.php +++ b/WEB-INF/resources/zh-tw.lang.php @@ -265,6 +265,7 @@ $i18n_key_words = array( // 'label.paid_status' => 'Paid status', // 'label.paid' => 'Paid', // 'label.mark_paid' => 'Mark paid', +// 'label.week_menu' => 'Week menu', // 'label.week_note' => 'Week note', // 'label.week_list' => 'Week list', // 'label.work_units' => 'Work units', diff --git a/WEB-INF/templates/display_options.tpl b/WEB-INF/templates/display_options.tpl index d11b0888..d7bbdd57 100644 --- a/WEB-INF/templates/display_options.tpl +++ b/WEB-INF/templates/display_options.tpl @@ -1,14 +1,5 @@ {$forms.displayOptionsForm.open} -{if $show_week_menu} - - - - - - -{/if} - diff --git a/WEB-INF/templates/footer.tpl b/WEB-INF/templates/footer.tpl index 0545cff5..6a036454 100644 --- a/WEB-INF/templates/footer.tpl +++ b/WEB-INF/templates/footer.tpl @@ -12,7 +12,7 @@
 
{$i18n.form.display_options.menu}
{$forms.displayOptionsForm.menu_week.control} {$i18n.label.what_is_it}
 
{$i18n.title.time}
- {/if} -{if $user->isPluginEnabled('wvn')} +{if $show_week_note} @@ -96,7 +96,7 @@ function fillDropdowns() {
 Anuko Time Tracker 1.19.4.4999 | Copyright © Anuko | +  Anuko Time Tracker 1.19.4.5000 | Copyright © Anuko | {$i18n.footer.credits} | {$i18n.footer.license} | {$i18n.footer.improve} diff --git a/WEB-INF/templates/header.tpl b/WEB-INF/templates/header.tpl index 0862523a..8e3dd763 100644 --- a/WEB-INF/templates/header.tpl +++ b/WEB-INF/templates/header.tpl @@ -108,7 +108,7 @@   {if $user->exists() && ($user->can('track_own_time') || $user->can('track_time'))} {$i18n.menu.time} - {if $user->isPluginEnabled('wv') && $user->getConfigOption('menu_week')} + {if $user->isPluginEnabled('wv') && $user->isOptionEnabled('week_menu')} {$i18n.menu.week} {/if} {/if} diff --git a/WEB-INF/templates/week.tpl b/WEB-INF/templates/week.tpl index 8d56707f..6f97c4d2 100644 --- a/WEB-INF/templates/week.tpl +++ b/WEB-INF/templates/week.tpl @@ -68,7 +68,7 @@ function fillDropdowns() { {$forms.weekTimeForm.task.control}
{$i18n.label.week_note}: {$forms.weekTimeForm.note.control}
 
-{if $user->isPluginEnabled('wvl')} +{if $show_week_list}
@@ -181,7 +181,7 @@ function fillDropdowns() { {if $time_records} - {if $user->isPluginEnabled('wvl')} + {if $show_week_list} diff --git a/WEB-INF/templates/week_view.tpl b/WEB-INF/templates/week_view.tpl index d3253e9d..17b02cb4 100644 --- a/WEB-INF/templates/week_view.tpl +++ b/WEB-INF/templates/week_view.tpl @@ -1,5 +1,9 @@ {$forms.weekViewForm.open}
{$i18n.label.week_total}: {$week_total}
+ + + + diff --git a/display_options.php b/display_options.php index a7426aaa..ec4ddd95 100644 --- a/display_options.php +++ b/display_options.php @@ -37,21 +37,17 @@ if (!ttAccessAllowed('manage_basic_settings')) { } // End of access checks. -$config = new ttConfigHelper($user->getConfig()); +$config = $user->getConfigHelper(); if ($request->isPost()) { - $cl_menu_week = $request->getParameter('menu_week'); $cl_time_note_on_separate_row = $request->getParameter('time_note_on_separate_row'); $cl_report_note_on_separate_row = $request->getParameter('report_note_on_separate_row'); } else { - $cl_menu_week = $config->getDefinedValue('menu_week'); $cl_time_note_on_separate_row = $config->getDefinedValue('time_note_on_separate_row'); $cl_report_note_on_separate_row = $config->getDefinedValue('report_note_on_separate_row'); } $form = new Form('displayOptionsForm'); -// Menu. -$form->addInput(array('type'=>'checkbox','name'=>'menu_week','value'=>$cl_menu_week)); // Time page. // $form->addInput(array('type'=>'checkbox','name'=>'time_client','value'=>$cl_time_client)); @@ -74,7 +70,6 @@ $form->addInput(array('type'=>'submit','name'=>'btn_save','value'=>$i18n->get('b if ($request->isPost()){ if ($err->no()) { // Update config. - $config->setDefinedValue('menu_week', $cl_menu_week); $config->setDefinedValue('time_note_on_separate_row', $cl_time_note_on_separate_row); $config->setDefinedValue('report_note_on_separate_row', $cl_report_note_on_separate_row); if ($user->updateGroup(array('config' => $config->getConfig()))) { @@ -86,7 +81,6 @@ if ($request->isPost()){ } $smarty->assign('forms', array($form->getName()=>$form->toArray())); -$smarty->assign('show_week_menu', $user->isPluginEnabled('wv')); $smarty->assign('title', $i18n->get('title.display_options')); $smarty->assign('content_page_name', 'display_options.tpl'); $smarty->display('index.tpl'); diff --git a/group_edit.php b/group_edit.php index 894546e5..abc06b46 100644 --- a/group_edit.php +++ b/group_edit.php @@ -70,7 +70,7 @@ if ($request->isPost() && $groupChanged) { $groups = $user->getGroupsForDropdown(); $group = ttGroupHelper::getGroupAttrs($group_id); -$config = new ttConfigHelper($group['config']); +$config = $user->getConfigHelper(); $advanced_settings = $home_group ? $user->can('manage_advanced_settings') : true; if (!defined('CURRENCY_DEFAULT')) define('CURRENCY_DEFAULT', '$'); diff --git a/plugins.php b/plugins.php index 4d2972bf..bc26e586 100644 --- a/plugins.php +++ b/plugins.php @@ -144,16 +144,6 @@ if ($request->isPost()) { $plugins .= ',at'; if ($cl_work) $plugins .= ',wk'; - - // Recycle week view plugin options as they are not configured on this page. - $existing_plugins = explode(',', $user->getPlugins()); - if (in_array('wvn', $existing_plugins)) - $plugins .= ',wvn'; - if (in_array('wvl', $existing_plugins)) - $plugins .= ',wvl'; - if (in_array('wvns', $existing_plugins)) - $plugins .= ',wvns'; - $plugins = trim($plugins, ','); // Prepare a new config string. diff --git a/week.php b/week.php index 2ef77447..a77e987f 100644 --- a/week.php +++ b/week.php @@ -143,29 +143,33 @@ else // Build day totals (total durations for each day in week). $dayTotals = ttWeekViewHelper::getDayTotals($dataArray, $dayHeaders); +$showWeekNote = $user->isOptionEnabled('week_note'); +$showWeekNotes = $user->isOptionEnabled('week_notes'); + // Define rendering class for a label field to the left of durations. class LabelCellRenderer extends DefaultCellRenderer { function render(&$table, $value, $row, $column, $selected = false) { global $user; + $showNotes = $user->isOptionEnabled('week_notes'); $this->setOptions(array('width'=>200,'valign'=>'middle')); // Special handling for a new week entry (row 0, or 0 and 1 if we show notes). if (0 == $row) { $this->setOptions(array('style'=>'text-align: center; font-weight: bold; vertical-align: top;')); - } else if ($user->isPluginEnabled('wvns') && (1 == $row)) { + } else if ($showNotes && (1 == $row)) { $this->setOptions(array('style'=>'text-align: right; vertical-align: top;')); - } else if ($user->isPluginEnabled('wvns') && (0 != $row % 2)) { + } else if ($showNotes && (0 != $row % 2)) { $this->setOptions(array('style'=>'text-align: right;')); } // Special handling for not billable entries. - $ignoreRow = $user->isPluginEnabled('wvns') ? 1 : 0; + $ignoreRow = $showNotes ? 1 : 0; if ($row > $ignoreRow) { $row_id = $table->getValueAtName($row,'row_id'); $billable = ttWeekViewHelper::parseFromWeekViewRow($row_id, 'bl'); if (!$billable) { - if (($user->isPluginEnabled('wvns') && (0 == $row % 2)) || !$user->isPluginEnabled('wvns')) { + if (($showNotes && (0 == $row % 2)) || !$showNotes) { $this->setOptions(array('style'=>'color: red;')); // TODO: style it properly in CSS. } } @@ -179,6 +183,7 @@ class LabelCellRenderer extends DefaultCellRenderer { class WeekViewCellRenderer extends DefaultCellRenderer { function render(&$table, $value, $row, $column, $selected = false) { global $user; + $showNotes = $user->isOptionEnabled('week_notes'); $field_name = $table->getValueAt($row,$column)['control_id']; // Our text field names (and ids) are like x_y (row_column). $field = new TextField($field_name); @@ -189,11 +194,11 @@ class WeekViewCellRenderer extends DefaultCellRenderer { $field->setFormName($table->getFormName()); $field->setStyle('width: 60px;'); // TODO: need to style everything properly, eventually. // Provide visual separation for new entry row. - $rowToSeparate = $user->isPluginEnabled('wvns') ? 1 : 0; + $rowToSeparate = $showNotes ? 1 : 0; if ($rowToSeparate == $row) { $field->setStyle('width: 60px; margin-bottom: 40px'); } - if ($user->isPluginEnabled('wvns')) { + if ($showNotes) { if (0 == $row % 2) { $field->setValue($table->getValueAt($row,$column)['duration']); // Duration for even rows. } else { @@ -383,7 +388,7 @@ if ($request->isPost()) { $control_id = $rowNumber.'_'.$dayHeader; // Handle durations and comments in separate blocks of code. - if (!$user->isPluginEnabled('wvns') || (0 == $rowNumber % 2)) { + if (!$showWeekNotes || (0 == $rowNumber % 2)) { // Handle durations row here. // Obtain existing and posted durations. @@ -422,7 +427,7 @@ if ($request->isPost()) { // Note: no need to check for a possible conflict with an already existing row // because we are doing an insert that does not affect already existing data. - if ($user->isPluginEnabled('wvn')) { + if ($showWeekNote) { $fields['note'] = $request->getParameter('note'); } } @@ -430,7 +435,7 @@ if ($request->isPost()) { $fields['start_date'] = $startDate->toString(DB_DATEFORMAT); // To be able to determine date for the entry using $dayHeader. $fields['duration'] = $postedDuration; $fields['browser_today'] = $request->getParameter('browser_today', null); - if ($user->isPluginEnabled('wvns')) { + if ($showWeekNotes) { // Take note value from the control below duration. $noteRowNumber = $rowNumber + 1; $note_control_id = $noteRowNumber.'_'.$dayHeader; @@ -448,7 +453,7 @@ if ($request->isPost()) { } if (!$result) break; // Break out of the loop in case of first error. - } else if ($user->isPluginEnabled('wvns')) { + } else if ($showWeekNotes) { // Handle commments row here. // Obtain existing and posted comments. @@ -516,6 +521,8 @@ $smarty->assign('show_navigation', !$user->getConfigOption('menu_week')); $smarty->assign('show_client', $showClient); $smarty->assign('show_project', $showProject); $smarty->assign('show_task', $showTask); +$smarty->assign('show_week_note', $showWeekNote); +$smarty->assign('show_week_list', $user->isOptionEnabled('week_list')); $smarty->assign('show_files', $showFiles); $smarty->assign('title', $i18n->get('menu.week')); $smarty->assign('content_page_name', 'week.tpl'); diff --git a/week_view.php b/week_view.php index 0d369bf9..149842e8 100644 --- a/week_view.php +++ b/week_view.php @@ -35,28 +35,34 @@ if (!ttAccessAllowed('manage_advanced_settings')) { exit(); } +$config = $user->getConfigHelper(); + if ($request->isPost()) { + $cl_week_menu = $request->getParameter('week_menu'); $cl_week_note = $request->getParameter('week_note'); $cl_week_list = $request->getParameter('week_list'); $cl_notes = $request->getParameter('notes'); } else { - $plugins = explode(',', $user->plugins); - $cl_week_note = in_array('wvn', $plugins); - $cl_week_list = in_array('wvl', $plugins); - $cl_notes = in_array('wvns', $plugins); + $cl_week_menu = $config->getDefinedValue('week_menu'); + $cl_week_note = $config->getDefinedValue('week_note'); + $cl_week_list = $config->getDefinedValue('week_list'); + $cl_notes = $config->getDefinedValue('week_notes'); } - $form = new Form('weekViewForm'); +$form->addInput(array('type'=>'checkbox','name'=>'week_menu','value'=>$cl_week_menu)); $form->addInput(array('type'=>'checkbox','name'=>'week_note','value'=>$cl_week_note)); $form->addInput(array('type'=>'checkbox','name'=>'week_list','value'=>$cl_week_list)); $form->addInput(array('type'=>'checkbox','name'=>'notes','value'=>$cl_notes)); $form->addInput(array('type'=>'submit','name'=>'btn_save','value'=>$i18n->get('button.save'))); if ($request->isPost()){ - if (!$user->enablePlugin('wvn', $cl_week_note) || - !$user->enablePlugin('wvl', $cl_week_list) || - !$user->enablePlugin('wvns', $cl_notes)) { + // Update config. + $config->setDefinedValue('week_menu', $cl_week_menu); + $config->setDefinedValue('week_note', $cl_week_note); + $config->setDefinedValue('week_list', $cl_week_list); + $config->setDefinedValue('week_notes', $cl_notes); + if (!$user->updateGroup(array('config' => $config->getConfig()))) { $err->add($i18n->get('error.db')); } } -- 2.20.1
{$forms.weekViewForm.week_menu.control} {$i18n.label.what_is_it}
{$forms.weekViewForm.week_note.control} {$i18n.label.what_is_it}