ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
class.ilCalendarSettings.php
Go to the documentation of this file.
1 <?php
2 /*
3  +-----------------------------------------------------------------------------+
4  | ILIAS open source |
5  +-----------------------------------------------------------------------------+
6  | Copyright (c) 1998-2006 ILIAS open source, University of Cologne |
7  | |
8  | This program is free software; you can redistribute it and/or |
9  | modify it under the terms of the GNU General Public License |
10  | as published by the Free Software Foundation; either version 2 |
11  | of the License, or (at your option) any later version. |
12  | |
13  | This program is distributed in the hope that it will be useful, |
14  | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15  | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16  | GNU General Public License for more details. |
17  | |
18  | You should have received a copy of the GNU General Public License |
19  | along with this program; if not, write to the Free Software |
20  | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21  +-----------------------------------------------------------------------------+
22 */
23 
24 include_once('Services/Calendar/classes/class.ilTimeZone.php');
25 
36 {
37  const WEEK_START_MONDAY = 1;
38  const WEEK_START_SUNDAY = 0;
39 
40  const DEFAULT_DAY_START = 8;
41  const DEFAULT_DAY_END = 19;
42 
43  const DATE_FORMAT_DMY = 1;
44  const DATE_FORMAT_YMD = 2;
45  const DATE_FORMAT_MDY = 3;
46 
47  const TIME_FORMAT_24 = 1;
48  const TIME_FORMAT_12 = 2;
49 
52 
53  const DEFAULT_SHOW_WEEKS = true;
54 
55  private static $instance = null;
56 
57  private $db = null;
58  private $storage = null;
59  private $timezone = null;
60  private $time_format = null;
61  private $week_start = 0;
62  private $day_start = null;
63  private $day_end = null;
64  private $enabled = false;
65  private $cal_settings_id = 0;
66 
67  private $consultation_hours = false;
68 
69  private $cache_enabled = true;
70  private $cache_minutes = 1;
71 
72  private $sync_cache_enabled = true;
73  private $sync_cache_minutes = 10;
74 
75  private $notification = false;
76  private $notification_user = false;
77 
78  private $cg_registration = false;
79 
80  private $course_cal_enabled = true;
81  private $group_cal_enabled = true;
82 
83  private $webcal_sync = false;
84  private $webcal_sync_hours = 2;
85  private $show_weeks = false;
86 
87  private $batch_file_downloads = false;
88 
95  private function __construct()
96  {
97  global $DIC;
98 
99  $ilDB = $DIC['ilDB'];
100 
101  $this->db = $ilDB;
102 
103  $this->initStorage();
104  $this->read();
105  $this->readCalendarSettingsId();
106  }
107 
116  public static function _getInstance()
117  {
118  if (self::$instance) {
119  return self::$instance;
120  }
121  return self::$instance = new ilCalendarSettings();
122  }
123 
128  public static function lookupCalendarActivated($a_obj_id)
129  {
131  return false;
132  }
133  $type = ilObject::_lookupType($a_obj_id);
134  // lookup global setting
135  $gl_activated = false;
136  switch ($type) {
137  case 'crs':
138  $gl_activated = ilCalendarSettings::_getInstance()->isCourseCalendarEnabled();
139  break;
140 
141  case 'grp':
142  $gl_activated = ilCalendarSettings::_getInstance()->isGroupCalendarEnabled();
143  break;
144 
145  default:
146  return false;
147  }
148  // look individual object setting
149  include_once './Services/Container/classes/class.ilContainer.php';
151  $a_obj_id,
152  'cont_show_calendar',
153  $gl_activated
154  );
155  }
156 
162  public function useCache($a_status)
163  {
164  $this->cache_enabled = $a_status;
165  }
166 
171  public function isCacheUsed()
172  {
173  return $this->cache_enabled;
174  }
175 
181  public function setCacheMinutes($a_min)
182  {
183  $this->cache_minutes = $a_min;
184  }
185 
190  public function getCacheMinutes()
191  {
192  return (int) $this->cache_minutes;
193  }
194 
201  public function setEnabled($a_enabled)
202  {
203  $this->enabled = $a_enabled;
204  }
205 
212  public function isEnabled()
213  {
214  return (bool) $this->enabled;
215  }
216 
223  public function setDefaultWeekStart($a_start)
224  {
225  $this->week_start = $a_start;
226  }
227 
234  public function getDefaultWeekStart()
235  {
236  return $this->week_start;
237  }
238 
244  public function setDefaultTimeZone($a_zone)
245  {
246  $this->timezone = $a_zone;
247  }
248 
254  public function getDefaultTimeZone()
255  {
256  return $this->timezone;
257  }
258 
266  public function setDefaultDateFormat($a_format)
267  {
268  $this->date_format = $a_format;
269  }
270 
277  public function getDefaultDateFormat()
278  {
279  return $this->date_format;
280  }
281 
289  public function setDefaultTimeFormat($a_format)
290  {
291  $this->time_format = $a_format;
292  }
293 
300  public function getDefaultTimeFormat()
301  {
302  return $this->time_format;
303  }
304 
309  public function getDefaultDayStart()
310  {
311  return $this->day_start;
312  }
313 
319  public function setDefaultDayStart($a_start)
320  {
321  $this->day_start = $a_start;
322  }
323 
328  public function getDefaultDayEnd()
329  {
330  return $this->day_end;
331  }
332 
338  public function setDefaultDayEnd($a_end)
339  {
340  $this->day_end = $a_end;
341  }
342 
347  public function areConsultationHoursEnabled()
348  {
350  }
351 
356  public function enableConsultationHours($a_status)
357  {
358  $this->consultation_hours = $a_status;
359  }
360 
361 
369  public function getCalendarSettingsId()
370  {
371  return $this->cal_settings_id;
372  }
373 
379  public function setEnableGroupMilestones($a_enablegroupmilestones)
380  {
381  $this->enablegroupmilestones = $a_enablegroupmilestones;
382  }
383 
389  public function getEnableGroupMilestones()
390  {
391  return $this->enablegroupmilestones;
392  }
393 
399  {
400  return (bool) $this->sync_cache_enabled;
401  }
402 
407  public function enableSynchronisationCache($a_status)
408  {
409  $this->sync_cache_enabled = $a_status;
410  }
411 
417  public function setSynchronisationCacheMinutes($a_min)
418  {
419  $this->sync_cache_minutes = $a_min;
420  }
421 
427  {
429  }
430 
435  public function isNotificationEnabled()
436  {
437  return (bool) $this->notification;
438  }
439 
445  public function enableNotification($a_status)
446  {
447  $this->notification = $a_status;
448  }
449 
450  public function isUserNotificationEnabled()
451  {
453  }
454 
455  public function enableUserNotification($a_not)
456  {
457  $this->notification_user = $a_not;
458  }
459 
465  public function enableCGRegistration($a_status)
466  {
467  $this->cg_registration = $a_status;
468  }
469 
470  public function isCGRegistrationEnabled()
471  {
472  return $this->cg_registration;
473  }
474 
475  public function enableCourseCalendar($a_stat)
476  {
477  $this->course_cal_enabled = $a_stat;
478  }
479 
480  public function isCourseCalendarEnabled()
481  {
483  }
484 
485  public function enableGroupCalendar($a_stat)
486  {
487  $this->group_cal_enabled = $a_stat;
488  }
489 
490  public function isGroupCalendarEnabled()
491  {
493  }
494 
495  public function enableWebCalSync($a_stat)
496  {
497  $this->webcal_sync = $a_stat;
498  }
499 
500  public function isWebCalSyncEnabled()
501  {
502  return $this->webcal_sync;
503  }
504 
505  public function setWebCalSyncHours($a_hours)
506  {
507  $this->webcal_sync_hours = $a_hours;
508  }
509 
510  public function getWebCalSyncHours()
511  {
513  }
514 
520  public function setShowWeeks($a_val)
521  {
522  $this->show_weeks = $a_val;
523  }
524 
530  public function getShowWeeks()
531  {
532  return $this->show_weeks;
533  }
534 
535  public function enableBatchFileDownloads($a_stat)
536  {
537  $this->batch_file_downloads = $a_stat;
538  }
539 
540  public function isBatchFileDownloadsEnabled()
541  {
543  }
544 
550  public function save()
551  {
552  $this->storage->set('enabled', (int) $this->isEnabled());
553  $this->storage->set('default_timezone', $this->getDefaultTimeZone());
554  $this->storage->set('default_week_start', $this->getDefaultWeekStart());
555  $this->storage->set('default_date_format', $this->getDefaultDateFormat());
556  $this->storage->set('default_time_format', $this->getDefaultTimeFormat());
557  $this->storage->set('enable_grp_milestones', (int) $this->getEnableGroupMilestones());
558  $this->storage->set('default_day_start', (int) $this->getDefaultDayStart());
559  $this->storage->set('default_day_end', (int) $this->getDefaultDayEnd());
560  $this->storage->set('cache_minutes', (int) $this->getCacheMinutes());
561  $this->storage->set('sync_cache_enabled', (int) $this->isSynchronisationCacheEnabled());
562  $this->storage->set('sync_cache_minutes', (int) $this->getSynchronisationCacheMinutes());
563  $this->storage->set('cache_enabled', (int) $this->isCacheUsed());
564  $this->storage->set('notification', (int) $this->isNotificationEnabled());
565  $this->storage->set('consultation_hours', (int) $this->areConsultationHoursEnabled());
566  $this->storage->set('cg_registration', (int) $this->isCGRegistrationEnabled());
567  $this->storage->set('course_cal', (int) $this->isCourseCalendarEnabled());
568  $this->storage->set('group_cal', (int) $this->isGroupCalendarEnabled());
569  $this->storage->set('notification_user', (int) $this->isUserNotificationEnabled());
570  $this->storage->set('webcal_sync', (int) $this->isWebCalSyncEnabled());
571  $this->storage->set('webcal_sync_hours', (int) $this->getWebCalSyncHours());
572  $this->storage->set('show_weeks', (int) $this->getShowWeeks());
573  $this->storage->set('batch_files', (int) $this->isBatchFileDownloadsEnabled());
574  }
575 
583  private function read()
584  {
585  $this->setEnabled($this->storage->get('enabled'));
586  $this->setDefaultTimeZone($this->storage->get('default_timezone', ilTimeZone::_getDefaultTimeZone()));
587  $this->setDefaultWeekStart($this->storage->get('default_week_start', self::WEEK_START_MONDAY));
588  $this->setDefaultDateFormat($this->storage->get('default_date_format', self::DATE_FORMAT_DMY));
589  $this->setDefaultTimeFormat($this->storage->get('default_time_format', self::TIME_FORMAT_24));
590  $this->setEnableGroupMilestones($this->storage->get('enable_grp_milestones'));
591  $this->setDefaultDayStart($this->storage->get('default_day_start', self::DEFAULT_DAY_START));
592  $this->setDefaultDayEnd($this->storage->get('default_day_end', self::DEFAULT_DAY_END));
593  $this->useCache($this->storage->get('cache_enabled'), $this->cache_enabled);
594  $this->setCacheMinutes($this->storage->get('cache_minutes', self::DEFAULT_CACHE_MINUTES));
595  $this->enableSynchronisationCache($this->storage->get('sync_cache_enabled'), $this->isSynchronisationCacheEnabled());
596  $this->setSynchronisationCacheMinutes($this->storage->get('sync_cache_minutes', self::DEFAULT_SYNC_CACHE_MINUTES));
597  $this->enableNotification($this->storage->get('notification', $this->isNotificationEnabled()));
598  $this->enableConsultationHours($this->storage->get('consultation_hours', $this->areConsultationHoursEnabled()));
599  $this->enableCGRegistration($this->storage->get('cg_registration', $this->isCGRegistrationEnabled()));
600  $this->enableCourseCalendar($this->storage->get('course_cal', $this->isCourseCalendarEnabled()));
601  $this->enableGroupCalendar($this->storage->get('group_cal', $this->isGroupCalendarEnabled()));
602  $this->enableUserNotification($this->storage->get('notification_user', $this->isUserNotificationEnabled()));
603  $this->enableWebCalSync($this->storage->get('webcal_sync', $this->isWebCalSyncEnabled()));
604  $this->setWebCalSyncHours($this->storage->get('webcal_sync_hours', $this->getWebCalSyncHours()));
605  $this->setShowWeeks($this->storage->get('show_weeks', $this->getShowWeeks()));
606  $this->enableBatchFileDownloads($this->storage->get('batch_files', $this->isBatchFileDownloadsEnabled()));
607  }
608 
616  private function readCalendarSettingsId()
617  {
618  $query = "SELECT ref_id FROM object_reference obr " .
619  "JOIN object_data obd ON obd.obj_id = obr.obj_id " .
620  "WHERE type = 'cals'";
621 
622  $set = $this->db->query($query);
623  $row = $this->db->fetchAssoc($set);
624 
625  $this->cal_settings_id = $row["ref_id"];
626  return true;
627  }
628 
634  private function initStorage()
635  {
636  include_once('./Services/Administration/classes/class.ilSetting.php');
637  $this->storage = new ilSetting('calendar');
638  }
639 }
getDefaultTimeFormat()
get default time format
static _getDefaultTimeZone()
Calculate and set default time zone.
getCacheMinutes()
Get cache minutes.
getDefaultTimeZone()
get derfault time zone
setSynchronisationCacheMinutes($a_min)
Set synchronisation cache minutes.
static _getInstance()
get singleton instance
getDefaultWeekStart()
get default week start
enableConsultationHours($a_status)
En/Disable consultation hours.
isNotificationEnabled()
Course group notification enabled.
isCacheUsed()
Check if cache is used.
$type
setShowWeeks($a_val)
Set show weeks.
global $DIC
Definition: saml.php:7
setDefaultDayStart($a_start)
Set default start of day.
getShowWeeks()
Get show weeks.
setDefaultDateFormat($a_format)
set default date format
setEnableGroupMilestones($a_enablegroupmilestones)
Set Enable milestone planning feature for groups.
static lookupCalendarActivated($a_obj_id)
getDefaultDateFormat()
get default date format
setDefaultDayEnd($a_end)
set default end of day
setDefaultTimeFormat($a_format)
set default time format
getCalendarSettingsId()
Get calendar settings id (Used for permission checks)
getDefaultDayStart()
Get default end of day.
getSynchronisationCacheMinutes()
get synchronisation cache minutes
getDefaultDayEnd()
Get default end of day.
setCacheMinutes($a_min)
Set time of cache storage.
areConsultationHoursEnabled()
Check if consultation hours are enabled.
setDefaultTimeZone($a_zone)
set default timezone
notification()
Definition: notification.php:2
$query
setEnabled($a_enabled)
set enabled
static _lookupType($a_id, $a_reference=false)
lookup object type
$row
Stores all calendar relevant settings.
enableSynchronisationCache($a_status)
En/Disable synchronisation cache.
isEnabled()
is calendar enabled
global $ilDB
getEnableGroupMilestones()
Get Enable milestone planning feature for groups.
enableNotification($a_status)
Enable course group notification.
readCalendarSettingsId()
Read ref_id of calendar settings.
__construct()
singleton contructor
useCache($a_status)
Enable cache.
enableCGRegistration($a_status)
Enable optional registration for courses and groups.
isSynchronisationCacheEnabled()
Check if cache is active for calendar synchronisation.
static _lookupContainerSetting($a_id, $a_keyword, $a_default_value=null)
Lookup a container setting.
initStorage()
Init storage class (ilSetting) private.
setDefaultWeekStart($a_start)
set week start