ILIAS  release_4-4 Revision
ilCalendarCategories Class Reference

class for calendar categories More...

+ Collaboration diagram for ilCalendarCategories:

Public Member Functions

 setCHUserId ($a_user_id)
 Set ch user id. More...
 
 getCHUserId ()
 Get ch user id. More...
 
 getMode ()
 
 getTargetRefId ()
 
 initialize ($a_mode, $a_source_ref_id=0, $a_use_cache=false)
 initialize visible categories More...
 
 getCategoryInfo ($a_cat_id)
 public More...
 
 getCategoriesInfo ()
 get categories More...
 
 getCategories ($a_include_subitem_calendars=false)
 get categories More...
 
 getSubitemCategories ($a_cat_id)
 get subitem categories for a specific category More...
 
 prepareCategoriesOfUserForSelection ()
 prepare categories of users for selection More...
 
 getNotificationCalendars ()
 Get all calendars that allow send of notifications (Editable and course group calendars) More...
 
 isEditable ($a_cat_id)
 check if category is editable More...
 
 isVisible ($a_cat_id)
 check if category is visible More...
 
 readConsultationHoursCalendar ($a_target_ref_id=NULL)
 Read personal consultation hours calendar. More...
 
 readBookingCalendar ($user_id=NULL)
 Read booking manager calendar. More...
 

Static Public Member Functions

static _getInstance ($a_usr_id=0)
 get singleton instance More...
 
static _lookupCategoryIdByObjId ($a_obj_id)
 lookup category by obj_id More...
 
static _isOwner ($a_usr_id, $a_cal_id)
 check if user is owner of a category More...
 
static deletePDItemsCache ($a_usr_id)
 Delete cache (add remove desktop item) More...
 
static deleteRepositoryCache ($a_usr_id)
 Delete cache. More...
 
static lookupPrivateCategories ($a_user_id)
 Lookup private categories of user. More...
 

Data Fields

const MODE_REPOSITORY = 2
 
const MODE_REMOTE_ACCESS = 3
 
const MODE_PERSONAL_DESKTOP_MEMBERSHIP = 4
 
const MODE_PERSONAL_DESKTOP_ITEMS = 5
 
const MODE_MANAGE = 6
 
const MODE_CONSULTATION = 7
 
const MODE_PORTFOLIO_CONSULTATION = 8
 
const MODE_REMOTE_SELECTED = 9
 

Protected Member Functions

 __construct ($a_usr_id=0)
 Singleton instance. More...
 
 sleep ()
 Serialize categories. More...
 
 wakeup ($a_ser)
 Load from serialize string. More...
 
 setMode ($a_mode)
 
 setTargetRefId ($a_ref_id)
 
 readPDCalendars ()
 Read categories of user. More...
 
 readSelectedCalendar ($a_cal_id)
 Read info about selected calendar. More...
 
 readSelectedItemCalendars ()
 Read categories of selected items. More...
 
 readReposCalendars ()
 Read available repository calendars. More...
 
 readPublicCalendars ()
 Read public calendars. More...
 
 readPrivateCalendars ()
 Read private calendars. More...
 
 readSelectedCategories ($a_obj_ids)
 read selected categories More...
 
 addSubitemCalendars ()
 Add subitem calendars E.g. More...
 

Protected Attributes

 $db
 
 $user_id
 
 $mode = 0
 
 $categories = array()
 
 $categories_info = array()
 
 $subitem_categories = array()
 
 $root_ref_id = 0
 
 $root_obj_id = 0
 
 $ch_user_id = 0
 
 $target_ref_id = 0
 

Static Protected Attributes

static $instance = null
 

Detailed Description

class for calendar categories

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

Definition at line 37 of file class.ilCalendarCategories.php.

Constructor & Destructor Documentation

◆ __construct()

ilCalendarCategories::__construct (   $a_usr_id = 0)
protected

Singleton instance.

protected

Parameters
int$a_usr_iduser id
Returns

Definition at line 74 of file class.ilCalendarCategories.php.

References $ilUser.

75  {
76  global $ilUser,$ilDB;
77 
78  $this->user_id = $a_usr_id;
79  if(!$this->user_id)
80  {
81  $this->user_id = $ilUser->getId();
82  }
83  $this->db = $ilDB;
84  }
global $ilUser
Definition: imgupload.php:15

Member Function Documentation

◆ _getInstance()

static ilCalendarCategories::_getInstance (   $a_usr_id = 0)
static

get singleton instance

public

Parameters
int$a_usr_iduser id
Returns
ilCalendarCategories

Definition at line 94 of file class.ilCalendarCategories.php.

Referenced by ilCalendarScheduleFilterBookings\__construct(), ilCalendarAppointmentsTableGUI\__construct(), ilCalendarChangedAppointmentsTableGUI\__construct(), ilCalendarPresentationGUI\__construct(), ilCalendarSchedule\__construct(), ilCalendarAppointmentColors\__construct(), ilCalendarAppointmentGUI\distributeNotifications(), ilCalendarAppointmentGUI\edit(), ilCalendarAppointmentGUI\editResponsibleUsers(), ilCalendarScheduleFilterHidden\filterCategories(), ilCalendarSelectionBlockGUI\getCalendars(), ilCalendarSchedule\getChangedEvents(), ilCalendarSchedule\getEvents(), ilCalendarAppointmentPanelGUI\getHTML(), ilCalendarRemoteAccessHandler\handleRequest(), ilPDCalendarBlockGUI\initCategories(), ilCalendarBlockGUI\initCategories(), ilCalendarAppointmentGUI\initForm(), ilCalendarCategoryGUI\initFormCategory(), ilCalendarCategoryTableGUI\parse(), ilCalendarManageTableGUI\parse(), ilPortfolioPageGUI\renderConsultationHours(), ilCalendarAppointmentGUI\save(), ilCalendarCategoryGUI\saveSelection(), ilCalendarMonthGUI\show(), ilCalendarCategoryGUI\showAssignedAppointments(), ilCalendarAppointmentGUI\showInfoScreen(), and ilCalendarPresentationGUI\synchroniseExternalCalendars().

95  {
96  if(self::$instance)
97  {
98  return self::$instance;
99  }
100  return self::$instance = new ilCalendarCategories($a_usr_id);
101  }
class for calendar categories
+ Here is the caller graph for this function:

◆ _isOwner()

static ilCalendarCategories::_isOwner (   $a_usr_id,
  $a_cal_id 
)
static

check if user is owner of a category

public

Parameters
intusr_id
intcal_id
Returns
bool

Definition at line 137 of file class.ilCalendarCategories.php.

References $query, $res, and ilCalendarCategory\TYPE_USR.

Referenced by ilCalendarShared\getSharedCalendarsForUser().

138  {
139  global $ilDB;
140 
141  $query = "SELECT * FROM cal_categories ".
142  "WHERE cat_id = ".$ilDB->quote($a_cal_id ,'integer')." ".
143  "AND obj_id = ".$ilDB->quote($a_usr_id ,'integer')." ".
144  "AND type = ".$ilDB->quote(ilCalendarCategory::TYPE_USR ,'integer')." ";
145  $res = $ilDB->query($query);
146  return $res->numRows() ? true : false;
147  }
+ Here is the caller graph for this function:

◆ _lookupCategoryIdByObjId()

static ilCalendarCategories::_lookupCategoryIdByObjId (   $a_obj_id)
static

lookup category by obj_id

public

Parameters
intobj_id
Returns
int cat_id

Definition at line 111 of file class.ilCalendarCategories.php.

References $query, $res, $row, DB_FETCHMODE_OBJECT, and ilCalendarCategory\TYPE_OBJ.

Referenced by ilCalendarAppEventListener\createAppointments(), ilCalendarAppEventListener\deleteCategory(), ilDataLoader\generateCalendarEntries(), and ilCalendarAppointmentGUI\initForm().

112  {
113  global $ilDB;
114 
115  $query = "SELECT cat_id FROM cal_categories ".
116  "WHERE obj_id = ".$ilDB->quote($a_obj_id ,'integer')." ".
117  "AND type = ".$ilDB->quote(ilCalendarCategory::TYPE_OBJ,'integer')." ";
118 
119  $res = $ilDB->query($query);
120  while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
121  {
122  return $row->cat_id;
123  }
124  return 0;
125  }
const DB_FETCHMODE_OBJECT
Definition: class.ilDB.php:11
+ Here is the caller graph for this function:

◆ addSubitemCalendars()

ilCalendarCategories::addSubitemCalendars ( )
protected

Add subitem calendars E.g.

session calendars in courses, groups

Parameters

Definition at line 920 of file class.ilCalendarCategories.php.

References $query, $res, $row, and DB_FETCHMODE_OBJECT.

Referenced by readPDCalendars(), readSelectedCalendar(), and readSelectedItemCalendars().

921  {
922  global $ilDB;
923 
924  $course_ids = array();
925  foreach($this->categories as $cat_id)
926  {
927  if($this->categories_info[$cat_id]['obj_type'] == 'crs' or $this->categories_info[$cat_id]['obj_type'] == 'grp')
928  {
929  $course_ids[] = $this->categories_info[$cat_id]['obj_id'];
930  }
931  }
932 
933  $query = "SELECT od2.obj_id sess_id, od1.obj_id crs_id,cat_id FROM object_data od1 ".
934  "JOIN object_reference or1 ON od1.obj_id = or1.obj_id ".
935  "JOIN tree t ON or1.ref_id = t.parent ".
936  "JOIN object_reference or2 ON t.child = or2.ref_id ".
937  "JOIN object_data od2 ON or2.obj_id = od2.obj_id ".
938  "JOIN cal_categories cc ON od2.obj_id = cc.obj_id ".
939  "WHERE od2.type = 'sess' ".
940  "AND (od1.type = 'crs' OR od1.type = 'grp') ".
941  "AND ".$ilDB->in('od1.obj_id',$course_ids,false,'integer').' '.
942  "AND or2.deleted IS NULL";
943 
944  $res = $ilDB->query($query);
945  $cat_ids = array();
946  $course_sessions = array();
947  while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
948  {
949  $cat_ids[] = $row->cat_id;
950  $course_sessions[$row->crs_id][$row->sess_id] = $row->cat_id;
951  $this->subitem_categories[] = $row->cat_id;
952  }
953 
954  foreach($this->categories as $cat_id)
955  {
956  if(
957  ($this->categories_info[$cat_id]['obj_type'] == 'crs' ||
958  $this->categories_info[$cat_id]['obj_type'] == 'grp' ) &&
959  isset($this->categories_info[$cat_id]['obj_id']) &&
960  isset($course_sessions[$this->categories_info[$cat_id]['obj_id']]) &&
961  is_array($course_sessions[$this->categories_info[$cat_id]['obj_id']]))
962  {
963  foreach($course_sessions[$this->categories_info[$cat_id]['obj_id']] as $sess_id => $sess_cat_id)
964  {
965  $this->categories_info[$cat_id]['subitem_ids'][$sess_id] = $sess_cat_id;
966  $this->categories_info[$cat_id]['subitem_obj_ids'][$sess_cat_id] = $sess_id;
967  }
968  }
969  else
970  {
971  $this->categories_info[$cat_id]['subitem_ids'] = array();
972  $this->categories_info[$cat_id]['subitem_obj_ids'] = array();
973  }
974  }
975  }
const DB_FETCHMODE_OBJECT
Definition: class.ilDB.php:11
+ Here is the caller graph for this function:

◆ deletePDItemsCache()

static ilCalendarCategories::deletePDItemsCache (   $a_usr_id)
static

Delete cache (add remove desktop item)

Parameters
object$a_usr_id
Returns

Definition at line 154 of file class.ilCalendarCategories.php.

References ilCalendarCache\getInstance().

Referenced by ilObjUser\_addDesktopItem(), ilObjUser\_dropDesktopItem(), and ilCalendarAppEventListener\handleEvent().

155  {
156  ilCalendarCache::getInstance()->deleteByAdditionalKeys(
157  $a_usr_id,
158  self::MODE_PERSONAL_DESKTOP_ITEMS,
159  'categories'
160  );
161  }
static getInstance()
get singleton instance
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ deleteRepositoryCache()

static ilCalendarCategories::deleteRepositoryCache (   $a_usr_id)
static

Delete cache.

Parameters
object$a_usr_id
Returns

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

References ilCalendarCache\getInstance().

Referenced by ilCalendarAppEventListener\handleEvent().

169  {
170  ilCalendarCache::getInstance()->deleteByAdditionalKeys(
171  $a_usr_id,
172  self::MODE_REPOSITORY,
173  'categories'
174  );
175 
176  }
static getInstance()
get singleton instance
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getCategories()

ilCalendarCategories::getCategories (   $a_include_subitem_calendars = false)

get categories

Parameters
$a_include_subitemsinclude subitem calendars public
Returns

Definition at line 379 of file class.ilCalendarCategories.php.

380  {
381  if($a_include_subitem_calendars)
382  {
383  return array_merge((array) $this->categories, (array) $this->subitem_categories);
384  }
385 
386  return $this->categories ? $this->categories : array();
387  }

◆ getCategoriesInfo()

ilCalendarCategories::getCategoriesInfo ( )

get categories

public

Parameters

Definition at line 368 of file class.ilCalendarCategories.php.

369  {
370  return $this->categories_info ? $this->categories_info : array();
371  }

◆ getCategoryInfo()

ilCalendarCategories::getCategoryInfo (   $a_cat_id)

public

Parameters

Definition at line 341 of file class.ilCalendarCategories.php.

342  {
343  if(isset($this->categories_info[$a_cat_id]))
344  {
345  return $this->categories_info[$a_cat_id];
346  }
347 
348  if(in_array($a_cat_id,(array) $this->subitem_categories))
349  {
350  foreach($this->categories as $cat_id)
351  {
352  if(in_array($a_cat_id,$this->categories_info[$cat_id]['subitem_ids']))
353  {
354  return $this->categories_info[$cat_id];
355  }
356  }
357  }
358  }

◆ getCHUserId()

ilCalendarCategories::getCHUserId ( )

Get ch user id.

Returns
type

Definition at line 222 of file class.ilCalendarCategories.php.

References $ch_user_id.

Referenced by readConsultationHoursCalendar().

223  {
224  return $this->ch_user_id;
225  }
+ Here is the caller graph for this function:

◆ getMode()

ilCalendarCategories::getMode ( )

Definition at line 232 of file class.ilCalendarCategories.php.

References $mode.

Referenced by initialize().

233  {
234  return $this->mode;
235  }
+ Here is the caller graph for this function:

◆ getNotificationCalendars()

ilCalendarCategories::getNotificationCalendars ( )

Get all calendars that allow send of notifications (Editable and course group calendars)

Returns

Definition at line 446 of file class.ilCalendarCategories.php.

References ilObject\_lookupType(), and ilCalendarCategory\TYPE_OBJ.

447  {
448  $not = array();
449  foreach($this->categories_info as $info)
450  {
451  if($info['type'] == ilCalendarCategory::TYPE_OBJ and $info['editable'] == true)
452  {
453  if(ilObject::_lookupType($info['obj_id']) == 'crs' or ilObject::_lookupType($info['obj_id']) == 'grp')
454  {
455  $not[] = $info['cat_id'];
456  }
457  }
458  }
459  return $not;
460  }
static _lookupType($a_id, $a_reference=false)
lookup object type
+ Here is the call graph for this function:

◆ getSubitemCategories()

ilCalendarCategories::getSubitemCategories (   $a_cat_id)

get subitem categories for a specific category

Parameters
int$a_category_idId of category in question
Returns
array Array of category ids

Definition at line 395 of file class.ilCalendarCategories.php.

396  {
397  if(!isset($this->categories_info[$a_cat_id]['subitem_ids']))
398  {
399  return array($a_cat_id);
400  }
401  return array_merge((array) $this->categories_info[$a_cat_id]['subitem_ids'],array($a_cat_id));
402  }

◆ getTargetRefId()

ilCalendarCategories::getTargetRefId ( )

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

References $target_ref_id.

◆ initialize()

ilCalendarCategories::initialize (   $a_mode,
  $a_source_ref_id = 0,
  $a_use_cache = false 
)

initialize visible categories

public

Parameters
intmode
intref_id of root node
Returns

Definition at line 255 of file class.ilCalendarCategories.php.

References $user_id, ilCalendarUserSettings\_getInstance(), ilObject\_lookupObjId(), ilCalendarUserSettings\CAL_SELECTION_MEMBERSHIP, ilCalendarCache\getInstance(), getMode(), readConsultationHoursCalendar(), readPDCalendars(), readReposCalendars(), readSelectedCalendar(), readSelectedItemCalendars(), setMode(), setTargetRefId(), and wakeup().

256  {
257  $this->setMode($a_mode);
258  if($a_use_cache)
259  {
260  // Read categories from cache
261  if($cats = ilCalendarCache::getInstance()->getEntry($this->user_id.':'.$a_mode.':categories:'.(int) $a_source_ref_id))
262  {
263  if($this->getMode() != self::MODE_CONSULTATION &&
264  $this->getMode() != self::MODE_PORTFOLIO_CONSULTATION)
265  {
266  $this->wakeup($cats);
267  return;
268  }
269  }
270  }
271 
272 
273  switch($this->getMode())
274  {
275  case self::MODE_REMOTE_ACCESS:
276  include_once('./Services/Calendar/classes/class.ilCalendarUserSettings.php');
278  {
279  $this->readPDCalendars();
280  }
281  else
282  {
283  $this->readSelectedItemCalendars();
284  }
285  break;
286 
287  case self::MODE_REMOTE_SELECTED:
288  $this->readSelectedCalendar($a_source_ref_id);
289  break;
290 
291  case self::MODE_PERSONAL_DESKTOP_MEMBERSHIP:
292  $this->readPDCalendars();
293  break;
294 
295  case self::MODE_PERSONAL_DESKTOP_ITEMS:
296  $this->readSelectedItemCalendars();
297  break;
298 
299  case self::MODE_REPOSITORY:
300  $this->root_ref_id = $a_source_ref_id;
301  $this->root_obj_id = ilObject::_lookupObjId($this->root_ref_id);
302  $this->readReposCalendars();
303  break;
304 
305  case self::MODE_MANAGE:
306  $this->readPDCalendars();
307  $this->readSelectedItemCalendars();
308  break;
309 
310  case self::MODE_CONSULTATION:
311  #$this->readPrivateCalendars();
312  $this->setTargetRefId($a_source_ref_id);
313  $this->readConsultationHoursCalendar($a_source_ref_id);
314  break;
315 
316  case self::MODE_PORTFOLIO_CONSULTATION:
318  break;
319  }
320 
321  if($a_use_cache)
322  {
323  // Store in cache
324  ilCalendarCache::getInstance()->storeEntry(
325  $this->user_id.':'.$a_mode.':categories:'.(int) $a_source_ref_id,
326  $this->sleep(),
328  $a_mode,
329  'categories'
330  );
331  }
332  }
static getInstance()
get singleton instance
readSelectedItemCalendars()
Read categories of selected items.
wakeup($a_ser)
Load from serialize string.
readConsultationHoursCalendar($a_target_ref_id=NULL)
Read personal consultation hours calendar.
static _getInstance()
get instance for logged in user
static _lookupObjId($a_id)
readSelectedCalendar($a_cal_id)
Read info about selected calendar.
readReposCalendars()
Read available repository calendars.
readPDCalendars()
Read categories of user.
+ Here is the call graph for this function:

◆ isEditable()

ilCalendarCategories::isEditable (   $a_cat_id)

check if category is editable

public

Parameters
int$a_cat_idcategory id
Returns

Definition at line 469 of file class.ilCalendarCategories.php.

470  {
471  return isset($this->categories_info[$a_cat_id]['editable']) and $this->categories_info[$a_cat_id]['editable'];
472  }

◆ isVisible()

ilCalendarCategories::isVisible (   $a_cat_id)

check if category is visible

public

Parameters
int$a_cat_idcategory id
Returns

Definition at line 481 of file class.ilCalendarCategories.php.

482  {
483  return in_array($a_cat_id,$this->categories) or
484  in_array($a_cat_id,(array) $this->subitem_categories);
485  }

◆ lookupPrivateCategories()

static ilCalendarCategories::lookupPrivateCategories (   $a_user_id)
static

Lookup private categories of user.

Parameters

Definition at line 983 of file class.ilCalendarCategories.php.

References ilCalendarCategory\TYPE_USR.

Referenced by ilUserExporter\getXmlExportTailDependencies().

984  {
985  global $ilDB;
986 
987  // First read private calendars of user
988  $set = $ilDB->query("SELECT * FROM cal_categories ".
989  "WHERE type = ".$ilDB->quote(ilCalendarCategory::TYPE_USR ,'integer')." ".
990  "AND obj_id = ".$ilDB->quote($a_user_id,'integer'));
991  $cats = array();
992  while ($rec = $ilDB->fetchAssoc($set))
993  {
994  $cats[] = $rec;
995  }
996  return $cats;
997  }
+ Here is the caller graph for this function:

◆ prepareCategoriesOfUserForSelection()

ilCalendarCategories::prepareCategoriesOfUserForSelection ( )

prepare categories of users for selection

public

Parameters
intuser id
Returns

Definition at line 412 of file class.ilCalendarCategories.php.

References $lng, and ilCalendarCategory\TYPE_USR.

413  {
414  global $lng;
415 
416  $has_personal_calendar = false;
417  foreach($this->categories_info as $info)
418  {
419  if($info['obj_type'] == 'sess')
420  {
421  continue;
422  }
423  if($info['type'] == ilCalendarCategory::TYPE_USR and $info['editable'])
424  {
425  $has_personal_calendar = true;
426  }
427 
428  if($info['editable'])
429  {
430  $cats[$info['cat_id']] = $info['title'];
431  }
432  }
433  // If there
434  if(!$has_personal_calendar)
435  {
436  $cats[0] = $lng->txt('cal_default_calendar');
437  }
438  return $cats ? $cats : array();
439  }
global $lng
Definition: privfeed.php:40

◆ readBookingCalendar()

ilCalendarCategories::readBookingCalendar (   $user_id = NULL)

Read booking manager calendar.

Parameters
int$user_id
Returns

Definition at line 819 of file class.ilCalendarCategories.php.

References $query, $res, $row, $user_id, DB_FETCHMODE_OBJECT, and ilCalendarCategory\TYPE_BOOK.

Referenced by readPDCalendars(), and readSelectedItemCalendars().

820  {
821  global $ilDB;
822 
823  if(!$user_id)
824  {
826  }
827 
828  $query = "SELECT * FROM cal_categories ".
829  "WHERE type = ".$ilDB->quote(ilCalendarCategory::TYPE_BOOK,'integer').' '.
830  "AND obj_id = ".$ilDB->quote($user_id,'integer');
831  $res = $ilDB->query($query);
832  while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
833  {
834  $this->categories[] = $row->cat_id;
835  $this->categories_info[$row->cat_id]['obj_id'] = $row->obj_id;
836  $this->categories_info[$row->cat_id]['cat_id'] = $row->cat_id;
837  $this->categories_info[$row->cat_id]['title'] = $row->title;
838  $this->categories_info[$row->cat_id]['color'] = $row->color;
839  $this->categories_info[$row->cat_id]['type'] = $row->type;
840  $this->categories_info[$row->cat_id]['editable'] = false;
841  $this->categories_info[$row->cat_id]['accepted'] = false;
842  $this->categories_info[$row->cat_id]['remote'] = false;
843  }
844  }
const DB_FETCHMODE_OBJECT
Definition: class.ilDB.php:11
+ Here is the caller graph for this function:

◆ readConsultationHoursCalendar()

ilCalendarCategories::readConsultationHoursCalendar (   $a_target_ref_id = NULL)

Read personal consultation hours calendar.

Parameters
int$user_id
Returns

Definition at line 744 of file class.ilCalendarCategories.php.

References $categories, $query, $res, $row, ilObject\_lookupObjId(), DB_FETCHMODE_OBJECT, getCHUserId(), setCHUserId(), and ilCalendarCategory\TYPE_CH.

Referenced by initialize(), readPDCalendars(), readReposCalendars(), and readSelectedItemCalendars().

745  {
746  global $ilDB;
747 
748  if(!$this->getCHUserId())
749  {
750  $this->setCHUserId($this->user_id);
751  }
752 
753  if($a_target_ref_id)
754  {
755  $target_obj_id = ilObject::_lookupObjId($a_target_ref_id);
756 
757  $query = 'SELECT DISTINCT(cc.cat_id) FROM booking_entry be '.
758  'LEFT JOIN booking_obj_assignment bo ON be.booking_id = bo.booking_id '.
759  'JOIN cal_entries ce ON be.booking_id = ce.context_id '.
760  'JOIN cal_cat_assignments ca ON ce.cal_id = ca.cal_id '.
761  'JOIN cal_categories cc ON ca.cat_id = cc.cat_id '.
762  'WHERE ((bo.target_obj_id IS NULL) OR bo.target_obj_id = '.$ilDB->quote($target_obj_id,'integer').' ) '.
763  'AND cc.obj_id = '.$ilDB->quote($this->getCHUserId(),'integer');
764 
765 
766  $res = $ilDB->query($query);
767  $categories = array();
768  while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
769  {
770  $categories[] = $row->cat_id;
771  }
772 
773  if($categories)
774  {
775  $query = 'SELECT * FROM cal_categories '.
776  'WHERE '.$ilDB->in('cat_id',$categories,false,'integer');
777  $res = $ilDB->query($query);
778  while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
779  {
780  $this->categories[] = $row->cat_id;
781  $this->categories_info[$row->cat_id]['obj_id'] = $row->obj_id;
782  $this->categories_info[$row->cat_id]['cat_id'] = $row->cat_id;
783  $this->categories_info[$row->cat_id]['title'] = $row->title;
784  $this->categories_info[$row->cat_id]['color'] = $row->color;
785  $this->categories_info[$row->cat_id]['type'] = $row->type;
786  $this->categories_info[$row->cat_id]['editable'] = false;
787  $this->categories_info[$row->cat_id]['accepted'] = false;
788  $this->categories_info[$row->cat_id]['remote'] = false;
789  }
790  }
791  }
792  else // no category given
793  {
794  $query = "SELECT * FROM cal_categories cc ".
795  "WHERE type = ".$ilDB->quote(ilCalendarCategory::TYPE_CH,'integer').' '.
796  "AND obj_id = ".$ilDB->quote($this->getCHUserId(),'integer');
797  $res = $ilDB->query($query);
798  while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
799  {
800  $this->categories[] = $row->cat_id;
801  $this->categories_info[$row->cat_id]['obj_id'] = $row->obj_id;
802  $this->categories_info[$row->cat_id]['cat_id'] = $row->cat_id;
803  $this->categories_info[$row->cat_id]['title'] = $row->title;
804  $this->categories_info[$row->cat_id]['color'] = $row->color;
805  $this->categories_info[$row->cat_id]['type'] = $row->type;
806  $this->categories_info[$row->cat_id]['editable'] = false;
807  $this->categories_info[$row->cat_id]['accepted'] = false;
808  $this->categories_info[$row->cat_id]['remote'] = false;
809  }
810  }
811  return true;
812  }
setCHUserId($a_user_id)
Set ch user id.
const DB_FETCHMODE_OBJECT
Definition: class.ilDB.php:11
static _lookupObjId($a_id)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ readPDCalendars()

ilCalendarCategories::readPDCalendars ( )
protected

Read categories of user.

protected

Parameters

Definition at line 497 of file class.ilCalendarCategories.php.

References ilParticipants\_getMembershipByType(), addSubitemCalendars(), readBookingCalendar(), readConsultationHoursCalendar(), readPrivateCalendars(), readPublicCalendars(), and readSelectedCategories().

Referenced by initialize().

498  {
499  global $rbacsystem;
500 
501 
502  $this->readPublicCalendars();
503  $this->readPrivateCalendars();
505  $this->readBookingCalendar();
506 
507  include_once('./Services/Membership/classes/class.ilParticipants.php');
508  $this->readSelectedCategories(ilParticipants::_getMembershipByType($this->user_id,'crs'));
509  $this->readSelectedCategories(ilParticipants::_getMembershipByType($this->user_id,'grp'));
510 
511  $this->addSubitemCalendars();
512  }
addSubitemCalendars()
Add subitem calendars E.g.
static _getMembershipByType($a_usr_id, $a_type, $a_only_member_role=false)
get membership by type Get course or group membership
readConsultationHoursCalendar($a_target_ref_id=NULL)
Read personal consultation hours calendar.
readPublicCalendars()
Read public calendars.
readSelectedCategories($a_obj_ids)
read selected categories
readBookingCalendar($user_id=NULL)
Read booking manager calendar.
readPrivateCalendars()
Read private calendars.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ readPrivateCalendars()

ilCalendarCategories::readPrivateCalendars ( )
protected

Read private calendars.

protected

Returns

Definition at line 676 of file class.ilCalendarCategories.php.

References $ilUser, $query, $res, $row, DB_FETCHMODE_OBJECT, ilCalendarSharedStatus\getAcceptedCalendars(), ilCalendarCategory\LTYPE_REMOTE, and ilCalendarCategory\TYPE_USR.

Referenced by readPDCalendars(), readReposCalendars(), and readSelectedItemCalendars().

677  {
678  global $ilUser;
679  global $ilDB;
680 
681  // First read private calendars of user
682  $query = "SELECT cat_id FROM cal_categories ".
683  "WHERE type = ".$this->db->quote(ilCalendarCategory::TYPE_USR ,'integer')." ".
684  "AND obj_id = ".$this->db->quote($ilUser->getId(),'integer')." ";
685  $res = $this->db->query($query);
686  while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
687  {
688  $cat_ids[] = $row->cat_id;
689  }
690 
691  // Read shared calendars
692  include_once('./Services/Calendar/classes/class.ilCalendarSharedStatus.php');
693  $accepted_ids = ilCalendarSharedStatus::getAcceptedCalendars($ilUser->getId());
694  if(!$cat_ids = array_merge((array) $cat_ids, $accepted_ids))
695  {
696  return true;
697  }
698 
699 
700  // user categories
701  $query = "SELECT * FROM cal_categories ".
702  "WHERE type = ".$this->db->quote(ilCalendarCategory::TYPE_USR ,'integer')." ".
703  "AND ".$ilDB->in('cat_id',$cat_ids,false,'integer')." ".
704  "ORDER BY title ";
705 
706  $res = $this->db->query($query);
707  while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
708  {
709  $this->categories[] = $row->cat_id;
710  $this->categories_info[$row->cat_id]['obj_id'] = $row->obj_id;
711  $this->categories_info[$row->cat_id]['cat_id'] = $row->cat_id;
712  $this->categories_info[$row->cat_id]['title'] = $row->title;
713  $this->categories_info[$row->cat_id]['color'] = $row->color;
714  $this->categories_info[$row->cat_id]['type'] = $row->type;
715 
716  include_once './Services/Calendar/classes/class.ilCalendarShared.php';
717  if(in_array($row->cat_id, $accepted_ids))
718  {
719  $shared = new ilCalendarShared($row->cat_id);
720  if($shared->isEditableForUser($ilUser->getId()))
721  {
722  $this->categories_info[$row->cat_id]['editable'] = true;
723  }
724  else
725  {
726  $this->categories_info[$row->cat_id]['editable'] = false;
727  }
728  }
729  else
730  {
731  $this->categories_info[$row->cat_id]['editable'] = true;
732  }
733 
734  $this->categories_info[$row->cat_id]['accepted'] = in_array($row->cat_id, $accepted_ids);
735  $this->categories_info[$row->cat_id]['remote'] = ($row->loc_type == ilCalendarCategory::LTYPE_REMOTE);
736  }
737  }
Handles shared calendars.
getAcceptedCalendars($a_usr_id)
get accepted shared calendars
const DB_FETCHMODE_OBJECT
Definition: class.ilDB.php:11
global $ilUser
Definition: imgupload.php:15
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ readPublicCalendars()

ilCalendarCategories::readPublicCalendars ( )
protected

Read public calendars.

protected

Returns

Definition at line 644 of file class.ilCalendarCategories.php.

References $query, $res, $row, ilCalendarSettings\_getInstance(), DB_FETCHMODE_OBJECT, ilCalendarCategory\LTYPE_REMOTE, and ilCalendarCategory\TYPE_GLOBAL.

Referenced by readPDCalendars(), readReposCalendars(), and readSelectedItemCalendars().

645  {
646  global $rbacsystem,$ilAccess;
647 
648  // global categories
649  $query = "SELECT * FROM cal_categories ".
650  "WHERE type = ".$this->db->quote(ilCalendarCategory::TYPE_GLOBAL ,'integer')." ".
651  "ORDER BY title ";
652 
653  $res = $this->db->query($query);
654  while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
655  {
656  $this->categories[] = $row->cat_id;
657  $this->categories_info[$row->cat_id]['obj_id'] = $row->obj_id;
658  $this->categories_info[$row->cat_id]['cat_id'] = $row->cat_id;
659  $this->categories_info[$row->cat_id]['title'] = $row->title;
660  $this->categories_info[$row->cat_id]['color'] = $row->color;
661  $this->categories_info[$row->cat_id]['type'] = $row->type;
662  $this->categories_info[$row->cat_id]['editable'] = $rbacsystem->checkAccess('edit_event',ilCalendarSettings::_getInstance()->getCalendarSettingsId());
663  $this->categories_info[$row->cat_id]['accepted'] = false;
664  $this->categories_info[$row->cat_id]['remote'] = ($row->loc_type == ilCalendarCategory::LTYPE_REMOTE);
665  }
666 
667  return true;
668  }
static _getInstance()
get singleton instance
const DB_FETCHMODE_OBJECT
Definition: class.ilDB.php:11
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ readReposCalendars()

ilCalendarCategories::readReposCalendars ( )
protected

Read available repository calendars.

protected

Parameters

Definition at line 589 of file class.ilCalendarCategories.php.

References $GLOBALS, $res, $row, ilCalendarSettings\_getInstance(), ilObject\_lookupType(), DB_FETCHMODE_OBJECT, readConsultationHoursCalendar(), readPrivateCalendars(), readPublicCalendars(), and readSelectedCategories().

Referenced by initialize().

590  {
591  global $ilAccess,$tree;
592  global $ilDB;
593 
594  $this->readPublicCalendars();
595  $this->readPrivateCalendars();
597 
598  #$query = "SELECT ref_id,obd.obj_id obj_id FROM tree t1 ".
599  # "JOIN object_reference obr ON t1.child = obr.ref_id ".
600  # "JOIN object_data obd ON obd.obj_id = obr.obj_id ".
601  # "WHERE t1.lft >= (SELECT lft FROM tree WHERE child = ".$this->db->quote($this->root_ref_id,'integer')." ) ".
602  # "AND t1.lft <= (SELECT rgt FROM tree WHERE child = ".$this->db->quote($this->root_ref_id,'integer')." ) ".
603  # "AND ".$ilDB->in('type',array('crs','grp','sess'),false,'text')." ".
604  # "AND tree = 1";
605 
606  $subtree_query = $GLOBALS['tree']->getSubTreeQuery(
607  $this->root_ref_id,
608  array('object_reference.ref_id','object_data.obj_id'),
609  array('crs','grp','sess')
610  );
611 
612  $res = $ilDB->query($subtree_query);
613  $obj_ids = array();
614  while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
615  {
616  if($tree->isDeleted($row->ref_id))
617  {
618  continue;
619  }
620 
621  $obj_type = ilObject::_lookupType($row->obj_id);
622  if($obj_type == 'crs' or $obj_type == 'grp')
623  {
624  // Check for global/local activation
625  if(!ilCalendarSettings::_getInstance()->lookupCalendarActivated($row->obj_id))
626  {
627  continue;
628  }
629  }
630  if($ilAccess->checkAccess('read','',$row->ref_id))
631  {
632  $obj_ids[] = $row->obj_id;
633  }
634  }
635  $this->readSelectedCategories($obj_ids);
636  }
static _getInstance()
get singleton instance
readConsultationHoursCalendar($a_target_ref_id=NULL)
Read personal consultation hours calendar.
const DB_FETCHMODE_OBJECT
Definition: class.ilDB.php:11
readPublicCalendars()
Read public calendars.
$GLOBALS['ct_recipient']
readSelectedCategories($a_obj_ids)
read selected categories
static _lookupType($a_id, $a_reference=false)
lookup object type
readPrivateCalendars()
Read private calendars.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ readSelectedCalendar()

ilCalendarCategories::readSelectedCalendar (   $a_cal_id)
protected

Read info about selected calendar.

Parameters
type$a_cal_id

Definition at line 518 of file class.ilCalendarCategories.php.

References addSubitemCalendars(), readSelectedCategories(), and ilCalendarCategory\TYPE_OBJ.

Referenced by initialize().

519  {
520  include_once './Services/Calendar/classes/class.ilCalendarCategory.php';
521  $cat = new ilCalendarCategory($a_cal_id);
522  if($cat->getType() == ilCalendarCategory::TYPE_OBJ)
523  {
524  $this->readSelectedCategories(array($cat->getObjId()));
525  $this->addSubitemCalendars();
526  }
527  else
528  {
529  $this->categories[] = $a_cal_id;
530  }
531  }
addSubitemCalendars()
Add subitem calendars E.g.
Stores calendar categories.
readSelectedCategories($a_obj_ids)
read selected categories
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ readSelectedCategories()

ilCalendarCategories::readSelectedCategories (   $a_obj_ids)
protected

read selected categories

protected

Returns

Definition at line 852 of file class.ilCalendarCategories.php.

References $query, $ref_id, $res, $row, ilObject\_getAllReferences(), ilCalendarSettings\_getInstance(), ilObject\_lookupType(), DB_FETCHMODE_OBJECT, and ilCalendarCategory\TYPE_OBJ.

Referenced by readPDCalendars(), readReposCalendars(), readSelectedCalendar(), and readSelectedItemCalendars().

853  {
854  global $ilAccess,$tree;
855  global $ilDB;
856 
857  if(!count($a_obj_ids))
858  {
859  return true;
860  }
861 
862  $query = "SELECT * FROM cal_categories ".
863  "WHERE type = ".$this->db->quote(ilCalendarCategory::TYPE_OBJ ,'integer')." ".
864  "AND ".$ilDB->in('obj_id',$a_obj_ids,false,'integer')." ".
865  "ORDER BY title ";
866 
867  $res = $this->db->query($query);
868  while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
869  {
870  // check activation/deactivation
871  $obj_type = ilObject::_lookupType($row->obj_id);
872  if($obj_type == 'crs' or $obj_type == 'grp')
873  {
874  if(!ilCalendarSettings::_getInstance()->lookupCalendarActivated($row->obj_id))
875  {
876  continue;
877  }
878  }
879 
880  $editable = false;
881  $exists = false;
882  foreach(ilObject::_getAllReferences($row->obj_id) as $ref_id)
883  {
884  if($ilAccess->checkAccess('edit_event','',$ref_id))
885  {
886  $exists = true;
887  $editable = true;
888  break;
889  }
890  elseif($ilAccess->checkAccess('read','',$ref_id))
891  {
892  $exists = true;
893  }
894  }
895  if(!$exists)
896  {
897  continue;
898  }
899  $this->categories_info[$row->cat_id]['editable'] = $editable;
900 
901  $this->categories[] = $row->cat_id;
902  $this->categories_info[$row->cat_id]['obj_id'] = $row->obj_id;
903  $this->categories_info[$row->cat_id]['cat_id'] = $row->cat_id;
904  $this->categories_info[$row->cat_id]['color'] = $row->color;
905  #$this->categories_info[$row->cat_id]['title'] = ilObject::_lookupTitle($row->obj_id);
906  $this->categories_info[$row->cat_id]['title'] = $row->title;
907  $this->categories_info[$row->cat_id]['obj_type'] = ilObject::_lookupType($row->obj_id);
908  $this->categories_info[$row->cat_id]['type'] = $row->type;
909  $this->categories_info[$row->cat_id]['remote'] = false;
910 
911  }
912  }
static _getInstance()
get singleton instance
static _getAllReferences($a_id)
get all reference ids of object
const DB_FETCHMODE_OBJECT
Definition: class.ilDB.php:11
static _lookupType($a_id, $a_reference=false)
lookup object type
$ref_id
Definition: sahs_server.php:39
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ readSelectedItemCalendars()

ilCalendarCategories::readSelectedItemCalendars ( )
protected

Read categories of selected items.

Parameters

Definition at line 539 of file class.ilCalendarCategories.php.

References $ilUser, ilObjUser\_lookupDesktopItems(), addSubitemCalendars(), readBookingCalendar(), readConsultationHoursCalendar(), readPrivateCalendars(), readPublicCalendars(), and readSelectedCategories().

Referenced by initialize().

540  {
541  global $ilUser,$ilAccess;
542 
543  $this->readPublicCalendars();
544  $this->readPrivateCalendars();
546  $this->readBookingCalendar();
547 
548  $obj_ids = array();
549 
550  $courses = array();
551  $groups = array();
552  $sessions = array();
553  foreach(ilObjUser::_lookupDesktopItems($ilUser->getId(),array('crs','grp','sess')) as $item)
554  {
555  if($ilAccess->checkAccess('read','',$item['ref_id']))
556  {
557  switch($item['type'])
558  {
559  case 'crs':
560  $courses[] = $item['obj_id'];
561  break;
562 
563  case 'sess':
564  $sessions[] = $item['obj_id'];
565  break;
566 
567  case 'grp':
568  $groups[] = $item['obj_id'];
569  break;
570 
571  }
572  }
573  }
574  $this->readSelectedCategories($courses);
575  $this->readSelectedCategories($sessions);
576  $this->readSelectedCategories($groups);
577 
578  $this->addSubitemCalendars();
579 
580  }
addSubitemCalendars()
Add subitem calendars E.g.
readConsultationHoursCalendar($a_target_ref_id=NULL)
Read personal consultation hours calendar.
readPublicCalendars()
Read public calendars.
readSelectedCategories($a_obj_ids)
read selected categories
readBookingCalendar($user_id=NULL)
Read booking manager calendar.
static _lookupDesktopItems($user_id, $a_types="")
get all desktop items of user and specified type
global $ilUser
Definition: imgupload.php:15
readPrivateCalendars()
Read private calendars.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setCHUserId()

ilCalendarCategories::setCHUserId (   $a_user_id)

Set ch user id.

Parameters
int$a_user_id

Definition at line 212 of file class.ilCalendarCategories.php.

Referenced by readConsultationHoursCalendar().

213  {
214  $this->ch_user_id = $a_user_id;
215  }
+ Here is the caller graph for this function:

◆ setMode()

ilCalendarCategories::setMode (   $a_mode)
protected

Definition at line 227 of file class.ilCalendarCategories.php.

Referenced by initialize().

228  {
229  $this->mode = $a_mode;
230  }
+ Here is the caller graph for this function:

◆ setTargetRefId()

ilCalendarCategories::setTargetRefId (   $a_ref_id)
protected

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

Referenced by initialize().

238  {
239  $this->target_ref_id = $a_ref_id;
240  }
+ Here is the caller graph for this function:

◆ sleep()

ilCalendarCategories::sleep ( )
protected

Serialize categories.

Returns

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

184  {
185  return serialize(
186  array(
187  'categories' => $this->categories,
188  'categories_info' => $this->categories_info,
189  'subitem_categories'=> $this->subitem_categories
190  )
191  );
192  }

◆ wakeup()

ilCalendarCategories::wakeup (   $a_ser)
protected

Load from serialize string.

Parameters
stringserialize categories
Returns

Definition at line 199 of file class.ilCalendarCategories.php.

Referenced by initialize().

200  {
201  $info = unserialize($a_ser);
202 
203  $this->categories = $info['categories'];
204  $this->categories_info = $info['categories_info'];
205  $this->subitem_categories = $info['subitem_categories'];
206  }
+ Here is the caller graph for this function:

Field Documentation

◆ $categories

ilCalendarCategories::$categories = array()
protected

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

Referenced by readConsultationHoursCalendar().

◆ $categories_info

ilCalendarCategories::$categories_info = array()
protected

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

◆ $ch_user_id

ilCalendarCategories::$ch_user_id = 0
protected

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

Referenced by getCHUserId().

◆ $db

ilCalendarCategories::$db
protected

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

◆ $instance

ilCalendarCategories::$instance = null
staticprotected

Definition at line 48 of file class.ilCalendarCategories.php.

◆ $mode

ilCalendarCategories::$mode = 0
protected

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

Referenced by getMode().

◆ $root_obj_id

ilCalendarCategories::$root_obj_id = 0
protected

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

◆ $root_ref_id

ilCalendarCategories::$root_ref_id = 0
protected

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

◆ $subitem_categories

ilCalendarCategories::$subitem_categories = array()
protected

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

◆ $target_ref_id

ilCalendarCategories::$target_ref_id = 0
protected

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

Referenced by getTargetRefId().

◆ $user_id

ilCalendarCategories::$user_id
protected

Definition at line 52 of file class.ilCalendarCategories.php.

Referenced by initialize(), and readBookingCalendar().

◆ MODE_CONSULTATION

const ilCalendarCategories::MODE_CONSULTATION = 7

◆ MODE_MANAGE

const ilCalendarCategories::MODE_MANAGE = 6

Definition at line 43 of file class.ilCalendarCategories.php.

Referenced by ilCalendarManageTableGUI\parse().

◆ MODE_PERSONAL_DESKTOP_ITEMS

◆ MODE_PERSONAL_DESKTOP_MEMBERSHIP

const ilCalendarCategories::MODE_PERSONAL_DESKTOP_MEMBERSHIP = 4

◆ MODE_PORTFOLIO_CONSULTATION

◆ MODE_REMOTE_ACCESS

const ilCalendarCategories::MODE_REMOTE_ACCESS = 3

◆ MODE_REMOTE_SELECTED

const ilCalendarCategories::MODE_REMOTE_SELECTED = 9

◆ MODE_REPOSITORY

const ilCalendarCategories::MODE_REPOSITORY = 2

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