ILIAS  release_8 Revision v8.19-1-g4e8f2f9140c
All Data Structures Namespaces Files Functions Variables Modules Pages
ilCalendarCategory Class Reference

Stores calendar categories. More...

+ Collaboration diagram for ilCalendarCategory:

Public Member Functions

 __construct (int $a_cat_id=0)
 
 getCategoryID ()
 
 setTitle (string $a_title)
 
 getTitle ()
 
 setColor (string $a_color)
 
 getColor ()
 
 setType (int $a_type)
 
 getType ()
 
 setObjId (int $a_obj_id)
 
 getObjId ()
 
 getObjType ()
 
 getLocationType ()
 
 setLocationType (int $a_type)
 
 setRemoteUrl (string $a_url)
 
 getRemoteUrl ()
 
 setRemoteUser (string $a_user)
 
 getRemoteUser ()
 
 setRemotePass (string $a_pass)
 
 getRemotePass ()
 
 setRemoteSyncLastExecution (ilDateTime $dt)
 Set remote sync last execution. More...
 
 getRemoteSyncLastExecution ()
 Get last execution date of remote sync. More...
 
 add ()
 
 update ()
 
 delete ()
 
 validate ()
 

Static Public Member Functions

static _getInstanceByObjId (int $a_obj_id)
 get instance by obj_id More...
 
static getInstanceByCategoryId (int $a_cat_id)
 
static lookupCategorySortIndex (int $a_type_id)
 Lookup sort index of calendar type. More...
 
static lookupAppointments (int $a_category_id)
 get all assigned appointment ids More...
 

Data Fields

const LTYPE_LOCAL = 1
 
const LTYPE_REMOTE = 2
 
const DEFAULT_COLOR = '#04427e'
 
const TYPE_UNDEFINED = 0
 
const TYPE_USR = 1
 
const TYPE_OBJ = 2
 
const TYPE_GLOBAL = 3
 
const TYPE_CH = 4
 
const TYPE_BOOK = 5
 

Protected Attributes

int $cat_id = 0
 
string $color = ''
 
int $type = self::TYPE_USR
 
int $obj_id = 0
 
string $obj_type = ''
 
string $title = ''
 
int $location = self::LTYPE_LOCAL
 
string $remote_url = ''
 
string $remote_user = ''
 
string $remote_pass = ''
 
ilDateTime $remote_sync = null
 
ilDBInterface $db
 

Static Protected Attributes

static array $SORTED_TYPES
 

Private Member Functions

 read ()
 

Static Private Attributes

static array $instances = []
 

Detailed Description

Stores calendar categories.

Author
Stefan Meyer smeye.nosp@m.r.il.nosp@m.ias@g.nosp@m.mx.d.nosp@m.e

Definition at line 31 of file class.ilCalendarCategory.php.

Constructor & Destructor Documentation

◆ __construct()

ilCalendarCategory::__construct ( int  $a_cat_id = 0)

Definition at line 70 of file class.ilCalendarCategory.php.

References $DIC, and read().

71  {
72  global $DIC;
73 
74  $this->db = $DIC->database();
75  $this->cat_id = $a_cat_id;
76 
77  $this->read();
78  }
global $DIC
Definition: feed.php:28
+ Here is the call graph for this function:

Member Function Documentation

◆ _getInstanceByObjId()

static ilCalendarCategory::_getInstanceByObjId ( int  $a_obj_id)
static

get instance by obj_id

Definition at line 83 of file class.ilCalendarCategory.php.

References $DIC, $ilDB, $query, $res, and ilDBConstants\FETCHMODE_OBJECT.

Referenced by ilCalendarPresentationGUI\__construct(), ilCalendarPresentationGUI\addStandardTabs(), ilCalendarAppEventListener\createCategory(), ilCalendarSubscriptionGUI\getModalForSubscription(), ilCalendarSubscriptionGUI\show(), and ilCalendarAppEventListener\updateCategory().

84  {
85  global $DIC;
86 
87  $ilDB = $DIC['ilDB'];
88  $query = "SELECT cat_id FROM cal_categories " .
89  "WHERE obj_id = " . $ilDB->quote($a_obj_id, 'integer') . " " .
90  "AND type = " . $ilDB->quote(self::TYPE_OBJ, 'integer');
91  $res = $ilDB->query($query);
92  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
93  return new ilCalendarCategory((int) $row->cat_id);
94  }
95  return null;
96  }
$res
Definition: ltiservices.php:69
Stores calendar categories.
global $DIC
Definition: feed.php:28
$query
+ Here is the caller graph for this function:

◆ add()

ilCalendarCategory::add ( )

Definition at line 242 of file class.ilCalendarCategory.php.

References $cat_id, $query, getColor(), getLocationType(), getObjId(), getRemotePass(), getRemoteSyncLastExecution(), getRemoteUrl(), getRemoteUser(), getTitle(), getType(), IL_CAL_DATETIME, and ilTimeZone\UTC.

242  : int
243  {
244  $next_id = $this->db->nextId('cal_categories');
245  $query = "INSERT INTO cal_categories (cat_id,obj_id,color,type,title,loc_type,remote_url,remote_user,remote_pass,remote_sync) " .
246  "VALUES ( " .
247  $this->db->quote($next_id, 'integer') . ", " .
248  $this->db->quote($this->getObjId(), 'integer') . ", " .
249  $this->db->quote($this->getColor(), 'text') . ", " .
250  $this->db->quote($this->getType(), 'integer') . ", " .
251  $this->db->quote($this->getTitle(), 'text') . ", " .
252  $this->db->quote($this->getLocationType(), 'integer') . ', ' .
253  $this->db->quote($this->getRemoteUrl(), 'text') . ', ' .
254  $this->db->quote($this->getRemoteUser(), 'text') . ', ' .
255  $this->db->quote($this->getRemotePass(), 'text') . ', ' .
256  $this->db->quote(
258  'timestamp'
259  ) . ' ' .
260  ")";
261 
262  $this->db->manipulate($query);
263 
264  $this->cat_id = $next_id;
265  return $this->cat_id;
266  }
const IL_CAL_DATETIME
getRemoteSyncLastExecution()
Get last execution date of remote sync.
$query
+ Here is the call graph for this function:

◆ delete()

ilCalendarCategory::delete ( )

Definition at line 288 of file class.ilCalendarCategory.php.

References $query, $res, ilCalendarEntry\_delete(), ilCalendarCategoryAssignments\_deleteByCategoryId(), ilCalendarVisibility\_deleteCategories(), and ilCalendarCategoryAssignments\_getAssignedAppointments().

288  : void
289  {
290  $query = "DELETE FROM cal_categories " .
291  "WHERE cat_id = " . $this->db->quote($this->cat_id, 'integer') . " ";
292  $res = $this->db->manipulate($query);
293 
295 
296  foreach (ilCalendarCategoryAssignments::_getAssignedAppointments(array($this->cat_id)) as $app_id) {
297  ilCalendarEntry::_delete($app_id);
298  }
300  }
$res
Definition: ltiservices.php:69
static _delete(int $a_entry_id)
static _deleteCategories(int $a_cat_id)
$query
static _getAssignedAppointments(array $a_cat_id)
Get assigned apointments.
static _deleteByCategoryId(int $a_cat_id)
Delete assignments by category id public.
+ Here is the call graph for this function:

◆ getCategoryID()

ilCalendarCategory::getCategoryID ( )

Definition at line 133 of file class.ilCalendarCategory.php.

References $cat_id.

Referenced by ilCalendarRemoteReader\importIcal(), and read().

133  : int
134  {
135  return $this->cat_id;
136  }
+ Here is the caller graph for this function:

◆ getColor()

ilCalendarCategory::getColor ( )

Definition at line 153 of file class.ilCalendarCategory.php.

References $color.

Referenced by add(), update(), and validate().

153  : string
154  {
155  return $this->color;
156  }
+ Here is the caller graph for this function:

◆ getInstanceByCategoryId()

static ilCalendarCategory::getInstanceByCategoryId ( int  $a_cat_id)
static

◆ getLocationType()

ilCalendarCategory::getLocationType ( )

Definition at line 183 of file class.ilCalendarCategory.php.

References $location.

Referenced by add(), update(), and validate().

183  : int
184  {
185  return $this->location;
186  }
+ Here is the caller graph for this function:

◆ getObjId()

ilCalendarCategory::getObjId ( )

Definition at line 173 of file class.ilCalendarCategory.php.

References $obj_id.

Referenced by add(), read(), and update().

173  : int
174  {
175  return $this->obj_id;
176  }
+ Here is the caller graph for this function:

◆ getObjType()

ilCalendarCategory::getObjType ( )

Definition at line 178 of file class.ilCalendarCategory.php.

References $obj_type.

178  : string
179  {
180  return $this->obj_type;
181  }

◆ getRemotePass()

ilCalendarCategory::getRemotePass ( )

Definition at line 218 of file class.ilCalendarCategory.php.

References $remote_pass.

Referenced by add(), ilCalendarCategoryGUI\doSynchronisation(), and update().

218  : string
219  {
220  return $this->remote_pass;
221  }
+ Here is the caller graph for this function:

◆ getRemoteSyncLastExecution()

ilCalendarCategory::getRemoteSyncLastExecution ( )

Get last execution date of remote sync.

Definition at line 234 of file class.ilCalendarCategory.php.

References $remote_sync.

Referenced by add(), and update().

234  : ilDateTime
235  {
236  if ($this->remote_sync instanceof ilDateTime) {
237  return $this->remote_sync;
238  }
239  return new ilDateTime();
240  }
+ Here is the caller graph for this function:

◆ getRemoteUrl()

ilCalendarCategory::getRemoteUrl ( )

Definition at line 198 of file class.ilCalendarCategory.php.

References $remote_url.

Referenced by add(), ilCalendarCategoryGUI\doSynchronisation(), update(), and validate().

198  : string
199  {
200  return $this->remote_url;
201  }
+ Here is the caller graph for this function:

◆ getRemoteUser()

ilCalendarCategory::getRemoteUser ( )

Definition at line 208 of file class.ilCalendarCategory.php.

References $remote_user.

Referenced by add(), ilCalendarCategoryGUI\doSynchronisation(), and update().

208  : string
209  {
210  return $this->remote_user;
211  }
+ Here is the caller graph for this function:

◆ getTitle()

ilCalendarCategory::getTitle ( )

Definition at line 143 of file class.ilCalendarCategory.php.

References $title.

Referenced by add(), update(), and validate().

143  : string
144  {
145  return $this->title;
146  }
+ Here is the caller graph for this function:

◆ getType()

ilCalendarCategory::getType ( )

Definition at line 163 of file class.ilCalendarCategory.php.

References $type.

Referenced by add(), read(), update(), and validate().

163  : int
164  {
165  return $this->type;
166  }
+ Here is the caller graph for this function:

◆ lookupAppointments()

static ilCalendarCategory::lookupAppointments ( int  $a_category_id)
static

get all assigned appointment ids

Returns
int[]

Definition at line 118 of file class.ilCalendarCategory.php.

References $DIC, $ilDB, $query, $res, ilDBConstants\FETCHMODE_OBJECT, and ILIAS\Repository\int().

118  : array
119  {
120  global $DIC;
121 
122  $ilDB = $DIC['ilDB'];
123  $query = "SELECT * FROM cal_cat_assignments " .
124  'WHERE cat_id = ' . $ilDB->quote($a_category_id, 'integer');
125  $res = $ilDB->query($query);
126  $apps = [];
127  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
128  $apps[] = (int) $row->cal_id;
129  }
130  return $apps;
131  }
$res
Definition: ltiservices.php:69
global $DIC
Definition: feed.php:28
$query
+ Here is the call graph for this function:

◆ lookupCategorySortIndex()

static ilCalendarCategory::lookupCategorySortIndex ( int  $a_type_id)
static

Lookup sort index of calendar type.

Definition at line 109 of file class.ilCalendarCategory.php.

Referenced by ilCalendarSelectionBlockGUI\getCalendars(), and ilCalendarManageTableGUI\parse().

109  : int
110  {
111  return (int) array_search($a_type_id, self::$SORTED_TYPES);
112  }
+ Here is the caller graph for this function:

◆ read()

ilCalendarCategory::read ( )
private

Definition at line 313 of file class.ilCalendarCategory.php.

References $query, $res, ilObject\_lookupTitle(), ilObject\_lookupType(), ilDBConstants\FETCHMODE_OBJECT, getCategoryID(), getObjId(), getType(), if, IL_CAL_DATETIME, and ILIAS\Repository\int().

Referenced by __construct().

313  : void
314  {
315  if (!$this->cat_id) {
316  return;
317  }
318 
319  $query = "SELECT * FROM cal_categories " .
320  "WHERE cat_id = " . $this->db->quote($this->getCategoryID(), 'integer') . " ";
321  $res = $this->db->query($query);
322  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
323  $this->cat_id = (int) $row->cat_id;
324  $this->obj_id = (int) $row->obj_id;
325  $this->type = (int) $row->type;
326  $this->color = (string) $row->color;
327  $this->title = (string) $row->title;
328  $this->location = (int) $row->loc_type;
329  $this->remote_url = (string) $row->remote_url;
330  $this->remote_user = (string) $row->remote_user;
331  $this->remote_pass = (string) $row->remote_pass;
332 
333  if ($row->remote_sync) {
334  $this->remote_sync = new ilDateTime((string) $row->remote_sync, IL_CAL_DATETIME, 'UTC');
335  } else {
336  $this->remote_sync = new ilDateTime();
337  }
338  }
339  if ($this->getType() == self::TYPE_OBJ) {
340  $this->title = ilObject::_lookupTitle($this->getObjId());
341  $this->obj_type = ilObject::_lookupType($this->getObjId());
342  }
343  }
$res
Definition: ltiservices.php:69
const IL_CAL_DATETIME
if(!file_exists(getcwd() . '/ilias.ini.php'))
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Definition: confirmReg.php:20
static _lookupTitle(int $obj_id)
$query
static _lookupType(int $id, bool $reference=false)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setColor()

ilCalendarCategory::setColor ( string  $a_color)

Definition at line 148 of file class.ilCalendarCategory.php.

148  : void
149  {
150  $this->color = $a_color;
151  }

◆ setLocationType()

ilCalendarCategory::setLocationType ( int  $a_type)

Definition at line 188 of file class.ilCalendarCategory.php.

188  : void
189  {
190  $this->location = $a_type;
191  }

◆ setObjId()

ilCalendarCategory::setObjId ( int  $a_obj_id)

Definition at line 168 of file class.ilCalendarCategory.php.

168  : void
169  {
170  $this->obj_id = $a_obj_id;
171  }

◆ setRemotePass()

ilCalendarCategory::setRemotePass ( string  $a_pass)

Definition at line 213 of file class.ilCalendarCategory.php.

213  : void
214  {
215  $this->remote_pass = $a_pass;
216  }

◆ setRemoteSyncLastExecution()

ilCalendarCategory::setRemoteSyncLastExecution ( ilDateTime  $dt)

Set remote sync last execution.

Definition at line 226 of file class.ilCalendarCategory.php.

226  : void
227  {
228  $this->remote_sync = $dt;
229  }

◆ setRemoteUrl()

ilCalendarCategory::setRemoteUrl ( string  $a_url)

Definition at line 193 of file class.ilCalendarCategory.php.

193  : void
194  {
195  $this->remote_url = $a_url;
196  }

◆ setRemoteUser()

ilCalendarCategory::setRemoteUser ( string  $a_user)

Definition at line 203 of file class.ilCalendarCategory.php.

203  : void
204  {
205  $this->remote_user = $a_user;
206  }

◆ setTitle()

ilCalendarCategory::setTitle ( string  $a_title)

Definition at line 138 of file class.ilCalendarCategory.php.

138  : void
139  {
140  $this->title = $a_title;
141  }

◆ setType()

ilCalendarCategory::setType ( int  $a_type)

Definition at line 158 of file class.ilCalendarCategory.php.

158  : void
159  {
160  $this->type = $a_type;
161  }

◆ update()

ilCalendarCategory::update ( )

Definition at line 268 of file class.ilCalendarCategory.php.

References $query, $res, getColor(), getLocationType(), getObjId(), getRemotePass(), getRemoteSyncLastExecution(), getRemoteUrl(), getRemoteUser(), getTitle(), getType(), IL_CAL_DATETIME, and ilTimeZone\UTC.

268  : void
269  {
270  $query = "UPDATE cal_categories " .
271  "SET obj_id = " . $this->db->quote($this->getObjId(), 'integer') . ", " .
272  "color = " . $this->db->quote($this->getColor(), 'text') . ", " .
273  "type = " . $this->db->quote($this->getType(), 'integer') . ", " .
274  "title = " . $this->db->quote($this->getTitle(), 'text') . ", " .
275  "loc_type = " . $this->db->quote($this->getLocationType(), 'integer') . ', ' .
276  "remote_url = " . $this->db->quote($this->getRemoteUrl(), 'text') . ', ' .
277  "remote_user = " . $this->db->quote($this->getRemoteUser(), 'text') . ', ' .
278  "remote_pass = " . $this->db->quote($this->getRemotePass(), 'text') . ', ' .
279  'remote_sync = ' . $this->db->quote($this->getRemoteSyncLastExecution()->get(
281  '',
283  ), 'timestamp') . ' ' .
284  "WHERE cat_id = " . $this->db->quote($this->cat_id, 'integer') . " ";
285  $res = $this->db->manipulate($query);
286  }
$res
Definition: ltiservices.php:69
const IL_CAL_DATETIME
getRemoteSyncLastExecution()
Get last execution date of remote sync.
$query
+ Here is the call graph for this function:

◆ validate()

ilCalendarCategory::validate ( )

Definition at line 302 of file class.ilCalendarCategory.php.

References getColor(), getLocationType(), getRemoteUrl(), getTitle(), getType(), and LTYPE_REMOTE.

302  : bool
303  {
304  if ($this->getLocationType() == ilCalendarCategory::LTYPE_REMOTE && !$this->getRemoteUrl()) {
305  return false;
306  }
307  if (strlen($this->getTitle()) && strlen($this->getColor()) && $this->getType()) {
308  return true;
309  }
310  return false;
311  }
+ Here is the call graph for this function:

Field Documentation

◆ $cat_id

int ilCalendarCategory::$cat_id = 0
protected

Definition at line 55 of file class.ilCalendarCategory.php.

Referenced by add(), and getCategoryID().

◆ $color

string ilCalendarCategory::$color = ''
protected

Definition at line 56 of file class.ilCalendarCategory.php.

Referenced by getColor().

◆ $db

ilDBInterface ilCalendarCategory::$db
protected

Definition at line 68 of file class.ilCalendarCategory.php.

◆ $instances

array ilCalendarCategory::$instances = []
staticprivate

Definition at line 36 of file class.ilCalendarCategory.php.

◆ $location

int ilCalendarCategory::$location = self::LTYPE_LOCAL
protected

Definition at line 62 of file class.ilCalendarCategory.php.

Referenced by getLocationType().

◆ $obj_id

int ilCalendarCategory::$obj_id = 0
protected

Definition at line 58 of file class.ilCalendarCategory.php.

Referenced by getObjId().

◆ $obj_type

string ilCalendarCategory::$obj_type = ''
protected

Definition at line 59 of file class.ilCalendarCategory.php.

Referenced by getObjType().

◆ $remote_pass

string ilCalendarCategory::$remote_pass = ''
protected

Definition at line 65 of file class.ilCalendarCategory.php.

Referenced by getRemotePass().

◆ $remote_sync

ilDateTime ilCalendarCategory::$remote_sync = null
protected

Definition at line 66 of file class.ilCalendarCategory.php.

Referenced by getRemoteSyncLastExecution().

◆ $remote_url

string ilCalendarCategory::$remote_url = ''
protected

Definition at line 63 of file class.ilCalendarCategory.php.

Referenced by getRemoteUrl().

◆ $remote_user

string ilCalendarCategory::$remote_user = ''
protected

Definition at line 64 of file class.ilCalendarCategory.php.

Referenced by getRemoteUser().

◆ $SORTED_TYPES

array ilCalendarCategory::$SORTED_TYPES
staticprotected
Initial value:
= array(
0 => self::TYPE_GLOBAL,
1 => self::TYPE_USR,
2 => self::TYPE_CH,
3 => self::TYPE_BOOK,
4 => self::TYPE_OBJ
)

Definition at line 47 of file class.ilCalendarCategory.php.

◆ $title

string ilCalendarCategory::$title = ''
protected

Definition at line 60 of file class.ilCalendarCategory.php.

Referenced by getTitle().

◆ $type

int ilCalendarCategory::$type = self::TYPE_USR
protected

Definition at line 57 of file class.ilCalendarCategory.php.

Referenced by getType().

◆ DEFAULT_COLOR

const ilCalendarCategory::DEFAULT_COLOR = '#04427e'

◆ LTYPE_LOCAL

const ilCalendarCategory::LTYPE_LOCAL = 1

Definition at line 33 of file class.ilCalendarCategory.php.

Referenced by ilCalendarCategoryGUI\initFormCategory().

◆ LTYPE_REMOTE

◆ TYPE_BOOK

◆ TYPE_CH

◆ TYPE_GLOBAL

◆ TYPE_OBJ

◆ TYPE_UNDEFINED

const ilCalendarCategory::TYPE_UNDEFINED = 0

Definition at line 40 of file class.ilCalendarCategory.php.

Referenced by ilCalendarAppointmentGUI\save().

◆ TYPE_USR


The documentation for this class was generated from the following file: