From 755e0c8aa218c7e6b844da043e5c1b8281d7caa0 Mon Sep 17 00:00:00 2001 From: nathangray Date: Mon, 5 Mar 2018 15:07:37 -0700 Subject: [PATCH] * Calendar - add preference to display birthdays as events as well as holidays --- calendar/inc/class.calendar_hooks.inc.php | 8 +++++++- calendar/js/et2_widget_daycol.js | 20 ++++++++++++++------ calendar/js/et2_widget_event.js | 2 +- calendar/lang/egw_en.lang | 4 ++-- 4 files changed, 24 insertions(+), 10 deletions(-) diff --git a/calendar/inc/class.calendar_hooks.inc.php b/calendar/inc/class.calendar_hooks.inc.php index f8d4935922..ec60b81daf 100644 --- a/calendar/inc/class.calendar_hooks.inc.php +++ b/calendar/inc/class.calendar_hooks.inc.php @@ -161,6 +161,11 @@ class calendar_hooks 'Sunday' => lang('Sunday'), 'Saturday' => lang('Saturday') ); + $birthdays_as_events = array( + 0 => lang('None'), + 'birthday' => lang('Birthdays'), + 'holiday' => lang('Holidays') + ); if (!isset($hook_data['setup'])) { @@ -315,7 +320,8 @@ class calendar_hooks 'admin' => False ), 'birthdays_as_events' => array( - 'type' => 'checkbox', + 'type' => 'multiselect', + 'values' => $birthdays_as_events, 'label' => 'Show birthdays as events', 'name' => 'birthdays_as_events', 'help' => 'Show birthdays as all day non-blocking events as well as via mouseover of the date.', diff --git a/calendar/js/et2_widget_daycol.js b/calendar/js/et2_widget_daycol.js index 9dfaf55931..4aa2b8bd49 100644 --- a/calendar/js/et2_widget_daycol.js +++ b/calendar/js/et2_widget_daycol.js @@ -416,6 +416,14 @@ var et2_calendar_daycol = (function(){ "use strict"; return et2_valueWidget.exte // Holidays and birthdays var holidays = et2_calendar_view.get_holidays(this,this.options.date.substring(0,4)); var holiday_list = []; + var holiday_pref = (egw.preference('birthdays_as_events','calendar')||'').split(','); +debugger; + // Show holidays as events on mobile or by preference + var holidays_as_events = egwIsMobile() || egw.preference('birthdays_as_events','calendar') === true || + holiday_pref.indexOf('holiday') >= 0; + + var birthdays_as_events = egwIsMobile() || holiday_pref.indexOf('birthday') >= 0; + if(holidays && holidays[this.options.date]) { holidays = holidays[this.options.date]; @@ -423,8 +431,8 @@ var et2_calendar_daycol = (function(){ "use strict"; return et2_valueWidget.exte { if (typeof holidays[i]['birthyear'] !== 'undefined') { - // Show holidays as events on mobile or by preference - if(egwIsMobile() || egw.preference('birthdays_as_events','calendar')) + // Show birthdays as events on mobile or by preference + if(birthdays_as_events) { // Create event this._parent.date_helper.set_value(this.options.date.substring(0,4)+'-'+ @@ -460,7 +468,7 @@ var et2_calendar_daycol = (function(){ "use strict"; return et2_valueWidget.exte else { // Show holidays as events on mobile - if(egwIsMobile()) + if(holidays_as_events) { // Create event this._parent.date_helper.set_value(this.options.date.substring(0,4)+'-'+ @@ -564,7 +572,7 @@ var et2_calendar_daycol = (function(){ "use strict"; return et2_valueWidget.exte { this.day_class_holiday(); } - + // Apply styles to hidden events this._out_of_view(); }, @@ -926,7 +934,7 @@ var et2_calendar_daycol = (function(){ "use strict"; return et2_valueWidget.exte { // If hidden, skip it - it takes too long if(!this.div.is(':visible')) return; - + // Sort events into minimally-overlapping columns var columns = this._spread_events(); @@ -1106,7 +1114,7 @@ var et2_calendar_daycol = (function(){ "use strict"; return et2_valueWidget.exte app.calendar.update_state({view: 'day',date: this.date.toJSON()}); return false; } - + }, /** diff --git a/calendar/js/et2_widget_event.js b/calendar/js/et2_widget_event.js index 0e94802598..1d1cb9a0ae 100644 --- a/calendar/js/et2_widget_event.js +++ b/calendar/js/et2_widget_event.js @@ -251,7 +251,7 @@ var et2_calendar_event = (function(){ "use strict"; return et2_valueWidget.exten this._actionObject.id = 'calendar::' + id; } - this._need_actions_linked = true; + this._need_actions_linked = !this.options.readonly; // Make sure category stuff is there // Fake it to use the cache / call - if already there, these will return diff --git a/calendar/lang/egw_en.lang b/calendar/lang/egw_en.lang index 41eb9e0054..1f44e16814 100644 --- a/calendar/lang/egw_en.lang +++ b/calendar/lang/egw_en.lang @@ -493,8 +493,8 @@ show all status incl. rejected events calendar en Show all status incl. rejected show all status, but rejected calendar en Show all status, but rejected show all status, but unknown calendar en Show all status, but unknown show also events just owned by selected user calendar en Show also events just owned by selected user -show birthdays as all day non-blocking events as well as via mouseover of the date. calendar en Show birthdays as all day non-blocking events as well as via mouseover of the date. -show birthdays as events calendar en Show birthdays as events +show birthdays as all day non-blocking events as well as via mouseover of the date. calendar en Show as all day non-blocking events as well as via mouseover of the date. +show birthdays as events calendar en Show as events show birthdays from addressbook admin en Show birthdays from address book show default view on main screen calendar en Show calendar on main screen show empty rows in planner calendar en Show empty rows in planner