ILIAS  trunk Revision v11.0_alpha-2638-g80c1d007f79
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 26 of file class.ilCalendarCategory.php.

Constructor & Destructor Documentation

◆ __construct()

ilCalendarCategory::__construct ( int  $a_cat_id = 0)

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

References $DIC, and read().

66  {
67  global $DIC;
68 
69  $this->db = $DIC->database();
70  $this->cat_id = $a_cat_id;
71 
72  $this->read();
73  }
global $DIC
Definition: shib_login.php:26
+ 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 78 of file class.ilCalendarCategory.php.

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

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

79  {
80  global $DIC;
81 
82  $ilDB = $DIC['ilDB'];
83  $query = "SELECT cat_id FROM cal_categories " .
84  "WHERE obj_id = " . $ilDB->quote($a_obj_id, 'integer') . " " .
85  "AND type = " . $ilDB->quote(self::TYPE_OBJ, 'integer');
86  $res = $ilDB->query($query);
87  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
88  return new ilCalendarCategory((int) $row->cat_id);
89  }
90  return null;
91  }
$res
Definition: ltiservices.php:66
Stores calendar categories.
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
global $DIC
Definition: shib_login.php:26
+ Here is the caller graph for this function:

◆ add()

ilCalendarCategory::add ( )

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

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

237  : int
238  {
239  $next_id = $this->db->nextId('cal_categories');
240  $query = "INSERT INTO cal_categories (cat_id,obj_id,color,type,title,loc_type,remote_url,remote_user,remote_pass,remote_sync) " .
241  "VALUES ( " .
242  $this->db->quote($next_id, 'integer') . ", " .
243  $this->db->quote($this->getObjId(), 'integer') . ", " .
244  $this->db->quote($this->getColor(), 'text') . ", " .
245  $this->db->quote($this->getType(), 'integer') . ", " .
246  /*
247  * The title needs to be truncated to fit into the table column. This is a pretty
248  * brute force method for doing so, but right now I can't find a better place for it.
249  */
250  $this->db->quote(mb_substr($this->getTitle(), 0, 128), 'text') . ", " .
251  $this->db->quote($this->getLocationType(), 'integer') . ', ' .
252  $this->db->quote($this->getRemoteUrl(), 'text') . ', ' .
253  $this->db->quote($this->getRemoteUser(), 'text') . ', ' .
254  $this->db->quote($this->getRemotePass(), 'text') . ', ' .
255  $this->db->quote(
257  'timestamp'
258  ) . ' ' .
259  ")";
260 
261  $this->db->manipulate($query);
262 
263  $this->cat_id = $next_id;
264  return $this->cat_id;
265  }
const IL_CAL_DATETIME
getRemoteSyncLastExecution()
Get last execution date of remote sync.
+ Here is the call graph for this function:

◆ delete()

ilCalendarCategory::delete ( )

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

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

291  : void
292  {
293  $query = "DELETE FROM cal_categories " .
294  "WHERE cat_id = " . $this->db->quote($this->cat_id, 'integer') . " ";
295  $res = $this->db->manipulate($query);
296 
298 
299  foreach (ilCalendarCategoryAssignments::_getAssignedAppointments(array($this->cat_id)) as $app_id) {
300  ilCalendarEntry::_delete($app_id);
301  }
303  }
$res
Definition: ltiservices.php:66
static _delete(int $a_entry_id)
static _deleteCategories(int $a_cat_id)
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 128 of file class.ilCalendarCategory.php.

References $cat_id.

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

128  : int
129  {
130  return $this->cat_id;
131  }
+ Here is the caller graph for this function:

◆ getColor()

ilCalendarCategory::getColor ( )

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

References $color.

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

148  : string
149  {
150  return $this->color;
151  }
+ Here is the caller graph for this function:

◆ getInstanceByCategoryId()

static ilCalendarCategory::getInstanceByCategoryId ( int  $a_cat_id)
static

◆ getLocationType()

ilCalendarCategory::getLocationType ( )

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

References $location.

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

178  : int
179  {
180  return $this->location;
181  }
+ Here is the caller graph for this function:

◆ getObjId()

ilCalendarCategory::getObjId ( )

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

References $obj_id.

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

168  : int
169  {
170  return $this->obj_id;
171  }
+ Here is the caller graph for this function:

◆ getObjType()

ilCalendarCategory::getObjType ( )

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

References $obj_type.

173  : string
174  {
175  return $this->obj_type;
176  }

◆ getRemotePass()

ilCalendarCategory::getRemotePass ( )

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

References $remote_pass.

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

213  : string
214  {
215  return $this->remote_pass;
216  }
+ Here is the caller graph for this function:

◆ getRemoteSyncLastExecution()

ilCalendarCategory::getRemoteSyncLastExecution ( )

Get last execution date of remote sync.

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

References $remote_sync.

Referenced by add(), and update().

229  : ilDateTime
230  {
231  if ($this->remote_sync instanceof ilDateTime) {
232  return $this->remote_sync;
233  }
234  return new ilDateTime();
235  }
+ Here is the caller graph for this function:

◆ getRemoteUrl()

ilCalendarCategory::getRemoteUrl ( )

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

References $remote_url.

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

193  : string
194  {
195  return $this->remote_url;
196  }
+ Here is the caller graph for this function:

◆ getRemoteUser()

ilCalendarCategory::getRemoteUser ( )

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

References $remote_user.

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

203  : string
204  {
205  return $this->remote_user;
206  }
+ Here is the caller graph for this function:

◆ getTitle()

ilCalendarCategory::getTitle ( )

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

References $title.

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

138  : string
139  {
140  return $this->title;
141  }
+ Here is the caller graph for this function:

◆ getType()

ilCalendarCategory::getType ( )

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

References $type.

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

158  : int
159  {
160  return $this->type;
161  }
+ 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 113 of file class.ilCalendarCategory.php.

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

113  : array
114  {
115  global $DIC;
116 
117  $ilDB = $DIC['ilDB'];
118  $query = "SELECT * FROM cal_cat_assignments " .
119  'WHERE cat_id = ' . $ilDB->quote($a_category_id, 'integer');
120  $res = $ilDB->query($query);
121  $apps = [];
122  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
123  $apps[] = (int) $row->cal_id;
124  }
125  return $apps;
126  }
$res
Definition: ltiservices.php:66
global $DIC
Definition: shib_login.php:26
+ 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 104 of file class.ilCalendarCategory.php.

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

104  : int
105  {
106  return (int) array_search($a_type_id, self::$SORTED_TYPES);
107  }
+ Here is the caller graph for this function:

◆ read()

ilCalendarCategory::read ( )
private

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

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

Referenced by __construct().

316  : void
317  {
318  if (!$this->cat_id) {
319  return;
320  }
321 
322  $query = "SELECT * FROM cal_categories " .
323  "WHERE cat_id = " . $this->db->quote($this->getCategoryID(), 'integer') . " ";
324  $res = $this->db->query($query);
325  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
326  $this->cat_id = (int) $row->cat_id;
327  $this->obj_id = (int) $row->obj_id;
328  $this->type = (int) $row->type;
329  $this->color = (string) $row->color;
330  $this->title = (string) $row->title;
331  $this->location = (int) $row->loc_type;
332  $this->remote_url = (string) $row->remote_url;
333  $this->remote_user = (string) $row->remote_user;
334  $this->remote_pass = (string) $row->remote_pass;
335 
336  if ($row->remote_sync) {
337  $this->remote_sync = new ilDateTime((string) $row->remote_sync, IL_CAL_DATETIME, 'UTC');
338  } else {
339  $this->remote_sync = new ilDateTime();
340  }
341  }
342  if ($this->getType() == self::TYPE_OBJ) {
343  $this->title = ilObject::_lookupTitle($this->getObjId());
344  $this->obj_type = ilObject::_lookupType($this->getObjId());
345  }
346  }
$res
Definition: ltiservices.php:66
const IL_CAL_DATETIME
if(!file_exists('../ilias.ini.php'))
static _lookupTitle(int $obj_id)
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 143 of file class.ilCalendarCategory.php.

143  : void
144  {
145  $this->color = $a_color;
146  }

◆ setLocationType()

ilCalendarCategory::setLocationType ( int  $a_type)

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

183  : void
184  {
185  $this->location = $a_type;
186  }

◆ setObjId()

ilCalendarCategory::setObjId ( int  $a_obj_id)

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

163  : void
164  {
165  $this->obj_id = $a_obj_id;
166  }

◆ setRemotePass()

ilCalendarCategory::setRemotePass ( string  $a_pass)

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

208  : void
209  {
210  $this->remote_pass = $a_pass;
211  }

◆ setRemoteSyncLastExecution()

ilCalendarCategory::setRemoteSyncLastExecution ( ilDateTime  $dt)

Set remote sync last execution.

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

221  : void
222  {
223  $this->remote_sync = $dt;
224  }

◆ setRemoteUrl()

ilCalendarCategory::setRemoteUrl ( string  $a_url)

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

188  : void
189  {
190  $this->remote_url = $a_url;
191  }

◆ setRemoteUser()

ilCalendarCategory::setRemoteUser ( string  $a_user)

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

198  : void
199  {
200  $this->remote_user = $a_user;
201  }

◆ setTitle()

ilCalendarCategory::setTitle ( string  $a_title)

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

133  : void
134  {
135  $this->title = $a_title;
136  }

◆ setType()

ilCalendarCategory::setType ( int  $a_type)

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

153  : void
154  {
155  $this->type = $a_type;
156  }

◆ update()

ilCalendarCategory::update ( )

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

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

267  : void
268  {
269  $query = "UPDATE cal_categories " .
270  "SET obj_id = " . $this->db->quote($this->getObjId(), 'integer') . ", " .
271  "color = " . $this->db->quote($this->getColor(), 'text') . ", " .
272  "type = " . $this->db->quote($this->getType(), 'integer') . ", " .
273  /*
274  * The title needs to be truncated to fit into the table column. This is a pretty
275  * brute force method for doing so, but right now I can't find a better place for it.
276  */
277  "title = " . $this->db->quote(mb_substr($this->getTitle(), 0, 128), 'text') . ", " .
278  "loc_type = " . $this->db->quote($this->getLocationType(), 'integer') . ', ' .
279  "remote_url = " . $this->db->quote($this->getRemoteUrl(), 'text') . ', ' .
280  "remote_user = " . $this->db->quote($this->getRemoteUser(), 'text') . ', ' .
281  "remote_pass = " . $this->db->quote($this->getRemotePass(), 'text') . ', ' .
282  'remote_sync = ' . $this->db->quote($this->getRemoteSyncLastExecution()->get(
284  '',
286  ), 'timestamp') . ' ' .
287  "WHERE cat_id = " . $this->db->quote($this->cat_id, 'integer') . " ";
288  $res = $this->db->manipulate($query);
289  }
$res
Definition: ltiservices.php:66
const IL_CAL_DATETIME
getRemoteSyncLastExecution()
Get last execution date of remote sync.
+ Here is the call graph for this function:

◆ validate()

ilCalendarCategory::validate ( )

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

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

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

Field Documentation

◆ $cat_id

int ilCalendarCategory::$cat_id = 0
protected

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

Referenced by add(), and getCategoryID().

◆ $color

string ilCalendarCategory::$color = ''
protected

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

Referenced by getColor().

◆ $db

ilDBInterface ilCalendarCategory::$db
protected

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

◆ $instances

array ilCalendarCategory::$instances = []
staticprivate

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

◆ $location

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

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

Referenced by getLocationType().

◆ $obj_id

int ilCalendarCategory::$obj_id = 0
protected

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

Referenced by getObjId().

◆ $obj_type

string ilCalendarCategory::$obj_type = ''
protected

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

Referenced by getObjType().

◆ $remote_pass

string ilCalendarCategory::$remote_pass = ''
protected

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

Referenced by getRemotePass().

◆ $remote_sync

ilDateTime ilCalendarCategory::$remote_sync = null
protected

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

Referenced by getRemoteSyncLastExecution().

◆ $remote_url

string ilCalendarCategory::$remote_url = ''
protected

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

Referenced by getRemoteUrl().

◆ $remote_user

string ilCalendarCategory::$remote_user = ''
protected

Definition at line 59 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 42 of file class.ilCalendarCategory.php.

◆ $title

string ilCalendarCategory::$title = ''
protected

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

Referenced by getTitle().

◆ $type

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

Definition at line 52 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 28 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 35 of file class.ilCalendarCategory.php.

◆ TYPE_USR


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