ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
class.ilCalendarActions.php
Go to the documentation of this file.
1<?php
2
3/* Copyright (c) 1998-2014 ILIAS open source, Extended GPL, see docs/LICENSE */
4
13{
17 protected static $instance = null;
18
22 protected $cats = null;
23
27 protected $user_id;
28
32 protected function __construct()
33 {
34 global $DIC;
35
36 $this->user_id = $DIC->user()->getId();
37
38 include_once("./Services/Calendar/classes/class.ilCalendarCategories.php");
39 $this->cats = ilCalendarCategories::_getInstance($this->user_id);
40 if ($this->cats->getMode() == 0) {
41 include_once("./Services/Calendar/exceptions/class.ilCalCategoriesNotInitializedException.php");
42 throw new ilCalCategoriesNotInitializedException("ilCalendarActions needs ilCalendarCategories to be initialized for user " . $this->user_id . ".");
43 }
44 }
45
51 public static function getInstance()
52 {
53 if (!is_object(self::$instance)) {
54 self::$instance = new ilCalendarActions();
55 }
56 return self::$instance;
57 }
58
65 public function checkSettingsCal($a_cat_id)
66 {
67 $info = $this->cats->getCategoryInfo($a_cat_id);
68 return $info['settings'];
69 }
70
77 public function checkShareCal($a_cat_id)
78 {
79 $info = $this->cats->getCategoryInfo($a_cat_id);
80 if ($info['type'] == ilCalendarCategory::TYPE_USR && $info['obj_id'] == $this->user_id) {
81 return true;
82 }
83
84 return false;
85 }
86
93 public function checkUnshareCal($a_cat_id)
94 {
95 $info = $this->cats->getCategoryInfo($a_cat_id);
96 if ($info['accepted']) {
97 return true;
98 }
99
100 return false;
101 }
102
109 public function checkSynchronizeCal($a_cat_id)
110 {
111 $info = $this->cats->getCategoryInfo($a_cat_id);
112 if ($info['remote']) {
113 return true;
114 }
115
116 return false;
117 }
118
125 public function checkAddEvent($a_cat_id)
126 {
127 $info = $this->cats->getCategoryInfo($a_cat_id);
128 return $info['editable'];
129 }
130
137 public function checkDeleteCal($a_cat_id)
138 {
139 $info = $this->cats->getCategoryInfo($a_cat_id);
140 if ($info['type'] == ilCalendarCategory::TYPE_USR && $info['obj_id'] == $this->user_id) {
141 return true;
142 }
143 if ($info['type'] == ilCalendarCategory::TYPE_GLOBAL && $info['settings']) {
144 return true;
145 }
146
147 return false;
148 }
149}
An exception for terminatinating execution or to throw for unit testing.
Exception being thrown if code relies on initialization of calendar categories but no initialization ...
Checks if certain actions can be performed.
checkUnshareCal($a_cat_id)
Check un-sharing (other users) calendar.
checkAddEvent($a_cat_id)
Check if adding an event is possible.
checkShareCal($a_cat_id)
Check sharing (own) calendar.
checkSynchronizeCal($a_cat_id)
Check synchronize remote calendar.
checkDeleteCal($a_cat_id)
Check if adding an event is possible.
static getInstance()
Get instance.
checkSettingsCal($a_cat_id)
Check calendar editing.
static _getInstance($a_usr_id=0)
get singleton instance
$DIC
Definition: xapitoken.php:46