ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
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)
 @access 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.

@access protected

Parameters
int$a_usr_iduser id
Returns

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

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 $ilDB
global $ilUser
Definition: imgupload.php:15

References $ilDB, and $ilUser.

Member Function Documentation

◆ _getInstance()

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

get singleton instance

@access public

Parameters
int$a_usr_iduser id
Returns
ilCalendarCategories

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

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

References $instance.

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

+ 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

@access public

Parameters
intusr_id
intcal_id
Returns
bool

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

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 }

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

Referenced by ilCalendarShared\getSharedCalendarsForUser().

+ Here is the caller graph for this function:

◆ _lookupCategoryIdByObjId()

static ilCalendarCategories::_lookupCategoryIdByObjId (   $a_obj_id)
static

lookup category by obj_id

@access public

Parameters
intobj_id
Returns
int cat_id

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

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

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

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

+ Here is the caller graph for this function:

◆ addSubitemCalendars()

ilCalendarCategories::addSubitemCalendars ( )
protected

Add subitem calendars E.g.

session calendars in courses, groups

Parameters

return

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

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

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

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

+ 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.

155 {
156 ilCalendarCache::getInstance()->deleteByAdditionalKeys(
157 $a_usr_id,
158 self::MODE_PERSONAL_DESKTOP_ITEMS,
159 'categories'
160 );
161 }
static getInstance()
get singleton instance

References ilCalendarCache\getInstance().

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

+ 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.

169 {
170 ilCalendarCache::getInstance()->deleteByAdditionalKeys(
171 $a_usr_id,
172 self::MODE_REPOSITORY,
173 'categories'
174 );
175
176 }

References ilCalendarCache\getInstance().

Referenced by ilCalendarAppEventListener\handleEvent().

+ 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 @access 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

@access public

Parameters

return

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)

@access public

Parameters

return

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().

+ 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().

+ 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.

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
$info
Definition: example_052.php:80

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

+ 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

@access public

Parameters
intmode
intref_id of root node
Returns

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

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 {
276 include_once('./Services/Calendar/classes/class.ilCalendarUserSettings.php');
278 {
279 $this->readPDCalendars();
280 }
281 else
282 {
284 }
285 break;
286
288 $this->readSelectedCalendar($a_source_ref_id);
289 break;
290
292 $this->readPDCalendars();
293 break;
294
297 break;
298
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
306 $this->readPDCalendars();
308 break;
309
311 #$this->readPrivateCalendars();
312 $this->setTargetRefId($a_source_ref_id);
313 $this->readConsultationHoursCalendar($a_source_ref_id);
314 break;
315
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(),
327 $this->user_id,
328 $a_mode,
329 'categories'
330 );
331 }
332 }
readPDCalendars()
Read categories of user.
readSelectedItemCalendars()
Read categories of selected items.
readSelectedCalendar($a_cal_id)
Read info about selected calendar.
wakeup($a_ser)
Load from serialize string.
readReposCalendars()
Read available repository calendars.
readConsultationHoursCalendar($a_target_ref_id=NULL)
Read personal consultation hours calendar.
static _getInstance()
get instance for logged in user
static _lookupObjId($a_id)

References ilCalendarUserSettings\_getInstance(), ilObject\_lookupObjId(), ilCalendarUserSettings\CAL_SELECTION_MEMBERSHIP, ilCalendarCache\getInstance(), getMode(), MODE_CONSULTATION, MODE_MANAGE, MODE_PERSONAL_DESKTOP_ITEMS, MODE_PERSONAL_DESKTOP_MEMBERSHIP, MODE_PORTFOLIO_CONSULTATION, MODE_REMOTE_ACCESS, MODE_REMOTE_SELECTED, MODE_REPOSITORY, readConsultationHoursCalendar(), readPDCalendars(), readReposCalendars(), readSelectedCalendar(), readSelectedItemCalendars(), setMode(), setTargetRefId(), and wakeup().

+ Here is the call graph for this function:

◆ isEditable()

ilCalendarCategories::isEditable (   $a_cat_id)

check if category is editable

@access 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

@access 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

return

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

989 {
990 global $ilDB;
991
992 // First read private calendars of user
993 $set = $ilDB->query("SELECT * FROM cal_categories ".
994 "WHERE type = ".$ilDB->quote(ilCalendarCategory::TYPE_USR ,'integer')." ".
995 "AND obj_id = ".$ilDB->quote($a_user_id,'integer'));
996 $cats = array();
997 while ($rec = $ilDB->fetchAssoc($set))
998 {
999 $cats[] = $rec;
1000 }
1001 return $cats;
1002 }

References $ilDB, and ilCalendarCategory\TYPE_USR.

Referenced by ilUserExporter\getXmlExportTailDependencies().

+ Here is the caller graph for this function:

◆ prepareCategoriesOfUserForSelection()

ilCalendarCategories::prepareCategoriesOfUserForSelection ( )

prepare categories of users for selection

@access public

Parameters
intuser id
Returns

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

413 {
414 global $lng;
415
416 $has_personal_calendar = false;
417 foreach($this->categories_info as $info)
418 {
419 if($info['obj_type'] == 'sess' || $info['obj_type'] == 'exc')
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

References $info, $lng, and ilCalendarCategory\TYPE_USR.

◆ readBookingCalendar()

ilCalendarCategories::readBookingCalendar (   $user_id = NULL)

Read booking manager calendar.

Parameters
int$user_id
Returns

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

825 {
826 global $ilDB;
827
828 if(!$user_id)
829 {
831 }
832
833 $query = "SELECT * FROM cal_categories ".
834 "WHERE type = ".$ilDB->quote(ilCalendarCategory::TYPE_BOOK,'integer').' '.
835 "AND obj_id = ".$ilDB->quote($user_id,'integer');
836 $res = $ilDB->query($query);
837 while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
838 {
839 $this->categories[] = $row->cat_id;
840 $this->categories_info[$row->cat_id]['obj_id'] = $row->obj_id;
841 $this->categories_info[$row->cat_id]['cat_id'] = $row->cat_id;
842 $this->categories_info[$row->cat_id]['title'] = $row->title;
843 $this->categories_info[$row->cat_id]['color'] = $row->color;
844 $this->categories_info[$row->cat_id]['type'] = $row->type;
845 $this->categories_info[$row->cat_id]['editable'] = false;
846 $this->categories_info[$row->cat_id]['accepted'] = false;
847 $this->categories_info[$row->cat_id]['remote'] = false;
848 }
849 }

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

Referenced by readPDCalendars(), and readSelectedItemCalendars().

+ 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 749 of file class.ilCalendarCategories.php.

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

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

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

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ readPDCalendars()

ilCalendarCategories::readPDCalendars ( )
protected

Read categories of user.

@access protected

Parameters

return void

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

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');
510
511 $this->addSubitemCalendars();
512 }
readPrivateCalendars()
Read private calendars.
addSubitemCalendars()
Add subitem calendars E.g.
readSelectedCategories($a_obj_ids)
read selected categories
readPublicCalendars()
Read public calendars.
readBookingCalendar($user_id=NULL)
Read booking manager calendar.
static _getMembershipByType($a_usr_id, $a_type, $a_only_member_role=false)
get membership by type Get course or group membership

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

Referenced by initialize().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ readPrivateCalendars()

ilCalendarCategories::readPrivateCalendars ( )
protected

Read private calendars.

@access protected

Returns

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

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

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

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

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ readPublicCalendars()

ilCalendarCategories::readPublicCalendars ( )
protected

Read public calendars.

@access protected

Returns

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

650 {
651 global $rbacsystem,$ilAccess;
652
653 // global categories
654 $query = "SELECT * FROM cal_categories ".
655 "WHERE type = ".$this->db->quote(ilCalendarCategory::TYPE_GLOBAL ,'integer')." ".
656 "ORDER BY title ";
657
658 $res = $this->db->query($query);
659 while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
660 {
661 $this->categories[] = $row->cat_id;
662 $this->categories_info[$row->cat_id]['obj_id'] = $row->obj_id;
663 $this->categories_info[$row->cat_id]['cat_id'] = $row->cat_id;
664 $this->categories_info[$row->cat_id]['title'] = $row->title;
665 $this->categories_info[$row->cat_id]['color'] = $row->color;
666 $this->categories_info[$row->cat_id]['type'] = $row->type;
667 $this->categories_info[$row->cat_id]['editable'] = $rbacsystem->checkAccess('edit_event',ilCalendarSettings::_getInstance()->getCalendarSettingsId());
668 $this->categories_info[$row->cat_id]['accepted'] = false;
669 $this->categories_info[$row->cat_id]['remote'] = ($row->loc_type == ilCalendarCategory::LTYPE_REMOTE);
670 }
671
672 return true;
673 }
static _getInstance()
get singleton instance

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

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

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ readReposCalendars()

ilCalendarCategories::readReposCalendars ( )
protected

Read available repository calendars.

@access protected

Parameters

return

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

595 {
596 global $ilAccess,$tree;
597 global $ilDB;
598
599 $this->readPublicCalendars();
600 $this->readPrivateCalendars();
602
603 #$query = "SELECT ref_id,obd.obj_id obj_id FROM tree t1 ".
604 # "JOIN object_reference obr ON t1.child = obr.ref_id ".
605 # "JOIN object_data obd ON obd.obj_id = obr.obj_id ".
606 # "WHERE t1.lft >= (SELECT lft FROM tree WHERE child = ".$this->db->quote($this->root_ref_id,'integer')." ) ".
607 # "AND t1.lft <= (SELECT rgt FROM tree WHERE child = ".$this->db->quote($this->root_ref_id,'integer')." ) ".
608 # "AND ".$ilDB->in('type',array('crs','grp','sess'),false,'text')." ".
609 # "AND tree = 1";
610
611 $subtree_query = $GLOBALS['tree']->getSubTreeQuery(
612 $this->root_ref_id,
613 array('object_reference.ref_id','object_data.obj_id'),
614 array('crs','grp','sess','exc')
615 );
616
617 $res = $ilDB->query($subtree_query);
618 $obj_ids = array();
619 while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
620 {
621 if($tree->isDeleted($row->ref_id))
622 {
623 continue;
624 }
625
626 $obj_type = ilObject::_lookupType($row->obj_id);
627 if($obj_type == 'crs' or $obj_type == 'grp')
628 {
629 // Check for global/local activation
630 if(!ilCalendarSettings::_getInstance()->lookupCalendarActivated($row->obj_id))
631 {
632 continue;
633 }
634 }
635 if($ilAccess->checkAccess('read','',$row->ref_id))
636 {
637 $obj_ids[] = $row->obj_id;
638 }
639 }
640 $this->readSelectedCategories($obj_ids);
641 }
$GLOBALS['PHPCAS_CLIENT']
This global variable is used by the interface class phpCAS.
Definition: CAS.php:276

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

Referenced by initialize().

+ 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.

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 }
Stores calendar categories.

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

Referenced by initialize().

+ 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

@access protected

Returns

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

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

References $ilDB, $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().

+ 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

return

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

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 $exercises = array();
554 foreach(ilObjUser::_lookupDesktopItems($ilUser->getId(),array('crs','grp','sess','exc')) as $item)
555 {
556 if($ilAccess->checkAccess('read','',$item['ref_id']))
557 {
558 switch($item['type'])
559 {
560 case 'crs':
561 $courses[] = $item['obj_id'];
562 break;
563
564 case 'sess':
565 $sessions[] = $item['obj_id'];
566 break;
567
568 case 'grp':
569 $groups[] = $item['obj_id'];
570 break;
571
572 case 'exc':
573 $exercises[] = $item['obj_id'];
574 break;
575 }
576 }
577 }
578 $this->readSelectedCategories($courses);
579 $this->readSelectedCategories($sessions);
580 $this->readSelectedCategories($groups);
581 $this->readSelectedCategories($exercises);
582
583 $this->addSubitemCalendars();
584
585 }
static _lookupDesktopItems($user_id, $a_types="")
get all desktop items of user and specified type

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

Referenced by initialize().

+ 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.

213 {
214 $this->ch_user_id = $a_user_id;
215 }

Referenced by readConsultationHoursCalendar().

+ Here is the caller graph for this function:

◆ setMode()

ilCalendarCategories::setMode (   $a_mode)
protected

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

228 {
229 $this->mode = $a_mode;
230 }

Referenced by initialize().

+ Here is the caller graph for this function:

◆ setTargetRefId()

ilCalendarCategories::setTargetRefId (   $a_ref_id)
protected

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

238 {
239 $this->target_ref_id = $a_ref_id;
240 }

Referenced by initialize().

+ 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.

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 }

References $info.

Referenced by initialize().

+ 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.

Referenced by _getInstance().

◆ $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 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 initialize(), and ilCalendarManageTableGUI\parse().

◆ MODE_PERSONAL_DESKTOP_ITEMS

◆ MODE_PERSONAL_DESKTOP_MEMBERSHIP

◆ 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: