ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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 $ilDB;
98 
99  $this->db = $ilDB;
100 
101  $this->initStorage();
102  $this->read();
103  $this->readCalendarSettingsId();
104  }
105 
114  public static function _getInstance()
115  {
116  if (self::$instance) {
117  return self::$instance;
118  }
119  return self::$instance = new ilCalendarSettings();
120  }
121 
126  public static function lookupCalendarActivated($a_obj_id)
127  {
129  return false;
130  }
131  $type = ilObject::_lookupType($a_obj_id);
132  // lookup global setting
133  $gl_activated = false;
134  switch ($type) {
135  case 'crs':
136  $gl_activated = ilCalendarSettings::_getInstance()->isCourseCalendarEnabled();
137  break;
138 
139  case 'grp':
140  $gl_activated = ilCalendarSettings::_getInstance()->isGroupCalendarEnabled();
141  break;
142 
143  default:
144  return false;
145  }
146  // look individual object setting
147  include_once './Services/Container/classes/class.ilContainer.php';
149  $a_obj_id,
150  'cont_show_calendar',
151  $gl_activated
152  );
153  }
154 
160  public function useCache($a_status)
161  {
162  $this->cache_enabled = $a_status;
163  }
164 
169  public function isCacheUsed()
170  {
171  return $this->cache_enabled;
172  }
173 
179  public function setCacheMinutes($a_min)
180  {
181  $this->cache_minutes = $a_min;
182  }
183 
188  public function getCacheMinutes()
189  {
190  return (int) $this->cache_minutes;
191  }
192 
199  public function setEnabled($a_enabled)
200  {
201  $this->enabled = $a_enabled;
202  }
203 
210  public function isEnabled()
211  {
212  return (bool) $this->enabled;
213  }
214 
221  public function setDefaultWeekStart($a_start)
222  {
223  $this->week_start = $a_start;
224  }
225 
232  public function getDefaultWeekStart()
233  {
234  return $this->week_start;
235  }
236 
242  public function setDefaultTimeZone($a_zone)
243  {
244  $this->timezone = $a_zone;
245  }
246 
252  public function getDefaultTimeZone()
253  {
254  return $this->timezone;
255  }
256 
264  public function setDefaultDateFormat($a_format)
265  {
266  $this->date_format = $a_format;
267  }
268 
275  public function getDefaultDateFormat()
276  {
277  return $this->date_format;
278  }
279 
287  public function setDefaultTimeFormat($a_format)
288  {
289  $this->time_format = $a_format;
290  }
291 
298  public function getDefaultTimeFormat()
299  {
300  return $this->time_format;
301  }
302 
307  public function getDefaultDayStart()
308  {
309  return $this->day_start;
310  }
311 
317  public function setDefaultDayStart($a_start)
318  {
319  $this->day_start = $a_start;
320  }
321 
326  public function getDefaultDayEnd()
327  {
328  return $this->day_end;
329  }
330 
336  public function setDefaultDayEnd($a_end)
337  {
338  $this->day_end = $a_end;
339  }
340 
345  public function areConsultationHoursEnabled()
346  {
348  }
349 
354  public function enableConsultationHours($a_status)
355  {
356  $this->consultation_hours = $a_status;
357  }
358 
359 
367  public function getCalendarSettingsId()
368  {
369  return $this->cal_settings_id;
370  }
371 
377  public function setEnableGroupMilestones($a_enablegroupmilestones)
378  {
379  $this->enablegroupmilestones = $a_enablegroupmilestones;
380  }
381 
387  public function getEnableGroupMilestones()
388  {
389  return $this->enablegroupmilestones;
390  }
391 
397  {
398  return (bool) $this->sync_cache_enabled;
399  }
400 
405  public function enableSynchronisationCache($a_status)
406  {
407  $this->sync_cache_enabled = $a_status;
408  }
409 
415  public function setSynchronisationCacheMinutes($a_min)
416  {
417  $this->sync_cache_minutes = $a_min;
418  }
419 
425  {
427  }
428 
433  public function isNotificationEnabled()
434  {
435  return (bool) $this->notification;
436  }
437 
443  public function enableNotification($a_status)
444  {
445  $this->notification = $a_status;
446  }
447 
448  public function isUserNotificationEnabled()
449  {
451  }
452 
453  public function enableUserNotification($a_not)
454  {
455  $this->notification_user = $a_not;
456  }
457 
463  public function enableCGRegistration($a_status)
464  {
465  $this->cg_registration = $a_status;
466  }
467 
468  public function isCGRegistrationEnabled()
469  {
470  return $this->cg_registration;
471  }
472 
473  public function enableCourseCalendar($a_stat)
474  {
475  $this->course_cal_enabled = $a_stat;
476  }
477 
478  public function isCourseCalendarEnabled()
479  {
481  }
482 
483  public function enableGroupCalendar($a_stat)
484  {
485  $this->group_cal_enabled = $a_stat;
486  }
487 
488  public function isGroupCalendarEnabled()
489  {
491  }
492 
493  public function enableWebCalSync($a_stat)
494  {
495  $this->webcal_sync = $a_stat;
496  }
497 
498  public function isWebCalSyncEnabled()
499  {
500  return $this->webcal_sync;
501  }
502 
503  public function setWebCalSyncHours($a_hours)
504  {
505  $this->webcal_sync_hours = $a_hours;
506  }
507 
508  public function getWebCalSyncHours()
509  {
511  }
512 
518  public function setShowWeeks($a_val)
519  {
520  $this->show_weeks = $a_val;
521  }
522 
528  public function getShowWeeks()
529  {
530  return $this->show_weeks;
531  }
532 
533  public function enableBatchFileDownloads($a_stat)
534  {
535  $this->batch_file_downloads = $a_stat;
536  }
537 
538  public function isBatchFileDownloadsEnabled()
539  {
541  }
542 
548  public function save()
549  {
550  $this->storage->set('enabled', (int) $this->isEnabled());
551  $this->storage->set('default_timezone', $this->getDefaultTimeZone());
552  $this->storage->set('default_week_start', $this->getDefaultWeekStart());
553  $this->storage->set('default_date_format', $this->getDefaultDateFormat());
554  $this->storage->set('default_time_format', $this->getDefaultTimeFormat());
555  $this->storage->set('enable_grp_milestones', (int) $this->getEnableGroupMilestones());
556  $this->storage->set('default_day_start', (int) $this->getDefaultDayStart());
557  $this->storage->set('default_day_end', (int) $this->getDefaultDayEnd());
558  $this->storage->set('cache_minutes', (int) $this->getCacheMinutes());
559  $this->storage->set('sync_cache_enabled', (int) $this->isSynchronisationCacheEnabled());
560  $this->storage->set('sync_cache_minutes', (int) $this->getSynchronisationCacheMinutes());
561  $this->storage->set('cache_enabled', (int) $this->isCacheUsed());
562  $this->storage->set('notification', (int) $this->isNotificationEnabled());
563  $this->storage->set('consultation_hours', (int) $this->areConsultationHoursEnabled());
564  $this->storage->set('cg_registration', (int) $this->isCGRegistrationEnabled());
565  $this->storage->set('course_cal', (int) $this->isCourseCalendarEnabled());
566  $this->storage->set('group_cal', (int) $this->isGroupCalendarEnabled());
567  $this->storage->set('notification_user', (int) $this->isUserNotificationEnabled());
568  $this->storage->set('webcal_sync', (int) $this->isWebCalSyncEnabled());
569  $this->storage->set('webcal_sync_hours', (int) $this->getWebCalSyncHours());
570  $this->storage->set('show_weeks', (int) $this->getShowWeeks());
571  $this->storage->set('batch_files', (int) $this->isBatchFileDownloadsEnabled());
572  }
573 
581  private function read()
582  {
583  $this->setEnabled($this->storage->get('enabled'));
584  $this->setDefaultTimeZone($this->storage->get('default_timezone', ilTimeZone::_getDefaultTimeZone()));
585  $this->setDefaultWeekStart($this->storage->get('default_week_start', self::WEEK_START_MONDAY));
586  $this->setDefaultDateFormat($this->storage->get('default_date_format', self::DATE_FORMAT_DMY));
587  $this->setDefaultTimeFormat($this->storage->get('default_time_format', self::TIME_FORMAT_24));
588  $this->setEnableGroupMilestones($this->storage->get('enable_grp_milestones'));
589  $this->setDefaultDayStart($this->storage->get('default_day_start', self::DEFAULT_DAY_START));
590  $this->setDefaultDayEnd($this->storage->get('default_day_end', self::DEFAULT_DAY_END));
591  $this->useCache($this->storage->get('cache_enabled'), $this->cache_enabled);
592  $this->setCacheMinutes($this->storage->get('cache_minutes', self::DEFAULT_CACHE_MINUTES));
593  $this->enableSynchronisationCache($this->storage->get('sync_cache_enabled'), $this->isSynchronisationCacheEnabled());
594  $this->setSynchronisationCacheMinutes($this->storage->get('sync_cache_minutes', self::DEFAULT_SYNC_CACHE_MINUTES));
595  $this->enableNotification($this->storage->get('notification', $this->isNotificationEnabled()));
596  $this->enableConsultationHours($this->storage->get('consultation_hours', $this->areConsultationHoursEnabled()));
597  $this->enableCGRegistration($this->storage->get('cg_registration', $this->isCGRegistrationEnabled()));
598  $this->enableCourseCalendar($this->storage->get('course_cal', $this->isCourseCalendarEnabled()));
599  $this->enableGroupCalendar($this->storage->get('group_cal', $this->isGroupCalendarEnabled()));
600  $this->enableUserNotification($this->storage->get('notification_user', $this->isUserNotificationEnabled()));
601  $this->enableWebCalSync($this->storage->get('webcal_sync', $this->isWebCalSyncEnabled()));
602  $this->setWebCalSyncHours($this->storage->get('webcal_sync_hours', $this->getWebCalSyncHours()));
603  $this->setShowWeeks($this->storage->get('show_weeks', $this->getShowWeeks()));
604  $this->enableBatchFileDownloads($this->storage->get('batch_files', $this->isBatchFileDownloadsEnabled()));
605  }
606 
614  private function readCalendarSettingsId()
615  {
616  $query = "SELECT ref_id FROM object_reference obr " .
617  "JOIN object_data obd ON obd.obj_id = obr.obj_id " .
618  "WHERE type = 'cals'";
619 
620  $set = $this->db->query($query);
621  $row = $this->db->fetchAssoc($set);
622 
623  $this->cal_settings_id = $row["ref_id"];
624  return true;
625  }
626 
632  private function initStorage()
633  {
634  include_once('./Services/Administration/classes/class.ilSetting.php');
635  $this->storage = new ilSetting('calendar');
636  }
637 }
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.
Set timezone
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.
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
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