ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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
 
 $logger = null
 ilLogger More...
 

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

References $GLOBALS, $ilDB, and $ilUser.

80  {
81  global $ilUser,$ilDB;
82 
83  $this->logger = $GLOBALS['DIC']->logger()->cal();
84 
85  $this->user_id = $a_usr_id;
86  if(!$this->user_id)
87  {
88  $this->user_id = $ilUser->getId();
89  }
90  $this->db = $ilDB;
91  }
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
$ilUser
Definition: imgupload.php:18
global $ilDB

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

102  {
103  if(self::$instance)
104  {
105  return self::$instance;
106  }
107  return self::$instance = new ilCalendarCategories($a_usr_id);
108  }
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 144 of file class.ilCalendarCategories.php.

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

Referenced by ilCalendarShared\getSharedCalendarsForUser().

145  {
146  global $ilDB;
147 
148  $query = "SELECT * FROM cal_categories ".
149  "WHERE cat_id = ".$ilDB->quote($a_cal_id ,'integer')." ".
150  "AND obj_id = ".$ilDB->quote($a_usr_id ,'integer')." ".
151  "AND type = ".$ilDB->quote(ilCalendarCategory::TYPE_USR ,'integer')." ";
152  $res = $ilDB->query($query);
153  return $res->numRows() ? true : false;
154  }
global $ilDB
+ 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 118 of file class.ilCalendarCategories.php.

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

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

119  {
120  global $ilDB;
121 
122  $query = "SELECT cat_id FROM cal_categories ".
123  "WHERE obj_id = ".$ilDB->quote($a_obj_id ,'integer')." ".
124  "AND type = ".$ilDB->quote(ilCalendarCategory::TYPE_OBJ,'integer')." ";
125 
126  $res = $ilDB->query($query);
127  while($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT))
128  {
129  return $row->cat_id;
130  }
131  return 0;
132  }
global $ilDB
+ 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 932 of file class.ilCalendarCategories.php.

References $ilDB, $query, $res, $row, array, and ilDBConstants\FETCHMODE_OBJECT.

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

933  {
934  global $ilDB;
935 
936  $course_ids = array();
937  foreach($this->categories as $cat_id)
938  {
939  if($this->categories_info[$cat_id]['obj_type'] == 'crs' or $this->categories_info[$cat_id]['obj_type'] == 'grp')
940  {
941  $course_ids[] = $this->categories_info[$cat_id]['obj_id'];
942  }
943  }
944 
945  $query = "SELECT od2.obj_id sess_id, od1.obj_id crs_id,cat_id FROM object_data od1 ".
946  "JOIN object_reference or1 ON od1.obj_id = or1.obj_id ".
947  "JOIN tree t ON or1.ref_id = t.parent ".
948  "JOIN object_reference or2 ON t.child = or2.ref_id ".
949  "JOIN object_data od2 ON or2.obj_id = od2.obj_id ".
950  "JOIN cal_categories cc ON od2.obj_id = cc.obj_id ".
951  "WHERE ".$ilDB->in('od2.type',array('sess','exc'),false,'text').
952  "AND (od1.type = 'crs' OR od1.type = 'grp') ".
953  "AND ".$ilDB->in('od1.obj_id',$course_ids,false,'integer').' '.
954  "AND or2.deleted IS NULL";
955 
956  $res = $ilDB->query($query);
957  $cat_ids = array();
958  $course_sessions = array();
959  while($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT))
960  {
961  $cat_ids[] = $row->cat_id;
962  $course_sessions[$row->crs_id][$row->sess_id] = $row->cat_id;
963  $this->subitem_categories[] = $row->cat_id;
964  }
965 
966  foreach($this->categories as $cat_id)
967  {
968  if(
969  ($this->categories_info[$cat_id]['obj_type'] == 'crs' ||
970  $this->categories_info[$cat_id]['obj_type'] == 'grp' ) &&
971  isset($this->categories_info[$cat_id]['obj_id']) &&
972  isset($course_sessions[$this->categories_info[$cat_id]['obj_id']]) &&
973  is_array($course_sessions[$this->categories_info[$cat_id]['obj_id']]))
974  {
975  foreach($course_sessions[$this->categories_info[$cat_id]['obj_id']] as $sess_id => $sess_cat_id)
976  {
977  $this->categories_info[$cat_id]['subitem_ids'][$sess_id] = $sess_cat_id;
978  $this->categories_info[$cat_id]['subitem_obj_ids'][$sess_cat_id] = $sess_id;
979  }
980  }
981  else
982  {
983  $this->categories_info[$cat_id]['subitem_ids'] = array();
984  $this->categories_info[$cat_id]['subitem_obj_ids'] = array();
985  }
986  }
987  }
Create styles array
The data for the language used.
global $ilDB
+ 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 161 of file class.ilCalendarCategories.php.

References ilCalendarCache\getInstance().

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

162  {
163  ilCalendarCache::getInstance()->deleteByAdditionalKeys(
164  $a_usr_id,
165  self::MODE_PERSONAL_DESKTOP_ITEMS,
166  'categories'
167  );
168  }
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 175 of file class.ilCalendarCategories.php.

References ilCalendarCache\getInstance().

Referenced by ilCalendarAppEventListener\handleEvent().

176  {
177  ilCalendarCache::getInstance()->deleteByAdditionalKeys(
178  $a_usr_id,
179  self::MODE_REPOSITORY,
180  'categories'
181  );
182 
183  }
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 386 of file class.ilCalendarCategories.php.

References array.

387  {
388  if($a_include_subitem_calendars)
389  {
390  return array_merge((array) $this->categories, (array) $this->subitem_categories);
391  }
392 
393  return $this->categories ? $this->categories : array();
394  }
Create styles array
The data for the language used.

◆ getCategoriesInfo()

ilCalendarCategories::getCategoriesInfo ( )

get categories

public

Parameters

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

References array.

376  {
377  return $this->categories_info ? $this->categories_info : array();
378  }
Create styles array
The data for the language used.

◆ getCategoryInfo()

ilCalendarCategories::getCategoryInfo (   $a_cat_id)

public

Parameters

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

References array.

349  {
350  if(isset($this->categories_info[$a_cat_id]))
351  {
352  return $this->categories_info[$a_cat_id];
353  }
354 
355  if(in_array($a_cat_id,(array) $this->subitem_categories))
356  {
357  foreach($this->categories as $cat_id)
358  {
359  if(in_array($a_cat_id,$this->categories_info[$cat_id]['subitem_ids']))
360  {
361  return $this->categories_info[$cat_id];
362  }
363  }
364  }
365  }
Create styles array
The data for the language used.

◆ getCHUserId()

ilCalendarCategories::getCHUserId ( )

Get ch user id.

Returns
type

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

References $ch_user_id.

Referenced by readConsultationHoursCalendar().

230  {
231  return $this->ch_user_id;
232  }
+ Here is the caller graph for this function:

◆ getMode()

ilCalendarCategories::getMode ( )

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

References $mode.

Referenced by initialize().

240  {
241  return $this->mode;
242  }
+ 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 453 of file class.ilCalendarCategories.php.

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

454  {
455  $not = array();
456  foreach($this->categories_info as $info)
457  {
458  if($info['type'] == ilCalendarCategory::TYPE_OBJ and $info['editable'] == true)
459  {
460  if(ilObject::_lookupType($info['obj_id']) == 'crs' or ilObject::_lookupType($info['obj_id']) == 'grp')
461  {
462  $not[] = $info['cat_id'];
463  }
464  }
465  }
466  return $not;
467  }
$info
Definition: example_052.php:80
Create styles array
The data for the language used.
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 402 of file class.ilCalendarCategories.php.

References array.

403  {
404  if(!isset($this->categories_info[$a_cat_id]['subitem_ids']))
405  {
406  return array($a_cat_id);
407  }
408  return array_merge((array) $this->categories_info[$a_cat_id]['subitem_ids'],array($a_cat_id));
409  }
Create styles array
The data for the language used.

◆ getTargetRefId()

ilCalendarCategories::getTargetRefId ( )

Definition at line 249 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 262 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().

263  {
264  $this->setMode($a_mode);
265  if($a_use_cache)
266  {
267  // Read categories from cache
268  if($cats = ilCalendarCache::getInstance()->getEntry($this->user_id.':'.$a_mode.':categories:'.(int) $a_source_ref_id))
269  {
270  if($this->getMode() != self::MODE_CONSULTATION &&
271  $this->getMode() != self::MODE_PORTFOLIO_CONSULTATION)
272  {
273  $this->wakeup($cats);
274  return;
275  }
276  }
277  }
278 
279 
280  switch($this->getMode())
281  {
282  case self::MODE_REMOTE_ACCESS:
283  include_once('./Services/Calendar/classes/class.ilCalendarUserSettings.php');
285  {
286  $this->readPDCalendars();
287  }
288  else
289  {
290  $this->readSelectedItemCalendars();
291  }
292  break;
293 
294  case self::MODE_REMOTE_SELECTED:
295  $this->readSelectedCalendar($a_source_ref_id);
296  break;
297 
298  case self::MODE_PERSONAL_DESKTOP_MEMBERSHIP:
299  $this->readPDCalendars();
300  break;
301 
302  case self::MODE_PERSONAL_DESKTOP_ITEMS:
303  $this->readSelectedItemCalendars();
304  break;
305 
306  case self::MODE_REPOSITORY:
307  $this->root_ref_id = $a_source_ref_id;
308  $this->root_obj_id = ilObject::_lookupObjId($this->root_ref_id);
309  $this->readReposCalendars();
310  break;
311 
312  case self::MODE_MANAGE:
313  $this->readPDCalendars();
314  $this->readSelectedItemCalendars();
315  break;
316 
317  case self::MODE_CONSULTATION:
318  #$this->readPrivateCalendars();
319  $this->setTargetRefId($a_source_ref_id);
320  $this->readConsultationHoursCalendar($a_source_ref_id);
321  break;
322 
323  case self::MODE_PORTFOLIO_CONSULTATION:
325  break;
326  }
327 
328  if($a_use_cache)
329  {
330  // Store in cache
331  ilCalendarCache::getInstance()->storeEntry(
332  $this->user_id.':'.$a_mode.':categories:'.(int) $a_source_ref_id,
333  $this->sleep(),
335  $a_mode,
336  'categories'
337  );
338  }
339  }
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 476 of file class.ilCalendarCategories.php.

477  {
478  return isset($this->categories_info[$a_cat_id]['editable']) and $this->categories_info[$a_cat_id]['editable'];
479  }

◆ isVisible()

ilCalendarCategories::isVisible (   $a_cat_id)

check if category is visible

public

Parameters
int$a_cat_idcategory id
Returns

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

References array.

489  {
490  return in_array($a_cat_id,$this->categories) or
491  in_array($a_cat_id,(array) $this->subitem_categories);
492  }
Create styles array
The data for the language used.

◆ lookupPrivateCategories()

static ilCalendarCategories::lookupPrivateCategories (   $a_user_id)
static

Lookup private categories of user.

Parameters

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

References $ilDB, array, and ilCalendarCategory\TYPE_USR.

Referenced by ilUserExporter\getXmlExportTailDependencies().

996  {
997  global $ilDB;
998 
999  // First read private calendars of user
1000  $set = $ilDB->query("SELECT * FROM cal_categories ".
1001  "WHERE type = ".$ilDB->quote(ilCalendarCategory::TYPE_USR ,'integer')." ".
1002  "AND obj_id = ".$ilDB->quote($a_user_id,'integer'));
1003  $cats = array();
1004  while ($rec = $ilDB->fetchAssoc($set))
1005  {
1006  $cats[] = $rec;
1007  }
1008  return $cats;
1009  }
Create styles array
The data for the language used.
global $ilDB
+ 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 419 of file class.ilCalendarCategories.php.

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

420  {
421  global $lng;
422 
423  $has_personal_calendar = false;
424  foreach($this->categories_info as $info)
425  {
426  if($info['obj_type'] == 'sess' || $info['obj_type'] == 'exc')
427  {
428  continue;
429  }
430  if($info['type'] == ilCalendarCategory::TYPE_USR and $info['editable'])
431  {
432  $has_personal_calendar = true;
433  }
434 
435  if($info['editable'])
436  {
437  $cats[$info['cat_id']] = $info['title'];
438  }
439  }
440  // If there
441  if(!$has_personal_calendar)
442  {
443  $cats[0] = $lng->txt('cal_default_calendar');
444  }
445  return $cats ? $cats : array();
446  }
$info
Definition: example_052.php:80
Create styles array
The data for the language used.
global $lng
Definition: privfeed.php:17

◆ readBookingCalendar()

ilCalendarCategories::readBookingCalendar (   $user_id = NULL)

Read booking manager calendar.

Parameters
int$user_id
Returns

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

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

Referenced by readPDCalendars(), and readSelectedItemCalendars().

832  {
833  global $ilDB;
834 
835  if(!$user_id)
836  {
838  }
839 
840  $query = "SELECT * FROM cal_categories ".
841  "WHERE type = ".$ilDB->quote(ilCalendarCategory::TYPE_BOOK,'integer').' '.
842  "AND obj_id = ".$ilDB->quote($user_id,'integer');
843  $res = $ilDB->query($query);
844  while($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT))
845  {
846  $this->categories[] = $row->cat_id;
847  $this->categories_info[$row->cat_id]['obj_id'] = $row->obj_id;
848  $this->categories_info[$row->cat_id]['cat_id'] = $row->cat_id;
849  $this->categories_info[$row->cat_id]['title'] = $row->title;
850  $this->categories_info[$row->cat_id]['color'] = $row->color;
851  $this->categories_info[$row->cat_id]['type'] = $row->type;
852  $this->categories_info[$row->cat_id]['editable'] = false;
853  $this->categories_info[$row->cat_id]['accepted'] = false;
854  $this->categories_info[$row->cat_id]['remote'] = false;
855  }
856  }
global $ilDB
+ 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 756 of file class.ilCalendarCategories.php.

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

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

757  {
758  global $ilDB;
759 
760  if(!$this->getCHUserId())
761  {
762  $this->setCHUserId($this->user_id);
763  }
764 
765  if($a_target_ref_id)
766  {
767  $target_obj_id = ilObject::_lookupObjId($a_target_ref_id);
768 
769  $query = 'SELECT DISTINCT(cc.cat_id) FROM booking_entry be '.
770  'LEFT JOIN booking_obj_assignment bo ON be.booking_id = bo.booking_id '.
771  'JOIN cal_entries ce ON be.booking_id = ce.context_id '.
772  'JOIN cal_cat_assignments ca ON ce.cal_id = ca.cal_id '.
773  'JOIN cal_categories cc ON ca.cat_id = cc.cat_id '.
774  'WHERE ((bo.target_obj_id IS NULL) OR bo.target_obj_id = '.$ilDB->quote($target_obj_id,'integer').' ) '.
775  'AND cc.obj_id = '.$ilDB->quote($this->getCHUserId(),'integer');
776 
777 
778  $res = $ilDB->query($query);
779  $categories = array();
780  while($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT))
781  {
782  $categories[] = $row->cat_id;
783  }
784 
785  if($categories)
786  {
787  $query = 'SELECT * FROM cal_categories '.
788  'WHERE '.$ilDB->in('cat_id',$categories,false,'integer');
789  $res = $ilDB->query($query);
790  while($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT))
791  {
792  $this->categories[] = $row->cat_id;
793  $this->categories_info[$row->cat_id]['obj_id'] = $row->obj_id;
794  $this->categories_info[$row->cat_id]['cat_id'] = $row->cat_id;
795  $this->categories_info[$row->cat_id]['title'] = $row->title;
796  $this->categories_info[$row->cat_id]['color'] = $row->color;
797  $this->categories_info[$row->cat_id]['type'] = $row->type;
798  $this->categories_info[$row->cat_id]['editable'] = false;
799  $this->categories_info[$row->cat_id]['accepted'] = false;
800  $this->categories_info[$row->cat_id]['remote'] = false;
801  }
802  }
803  }
804  else // no category given
805  {
806  $query = "SELECT * FROM cal_categories cc ".
807  "WHERE type = ".$ilDB->quote(ilCalendarCategory::TYPE_CH,'integer').' '.
808  "AND obj_id = ".$ilDB->quote($this->getCHUserId(),'integer');
809  $res = $ilDB->query($query);
810  while($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT))
811  {
812  $this->categories[] = $row->cat_id;
813  $this->categories_info[$row->cat_id]['obj_id'] = $row->obj_id;
814  $this->categories_info[$row->cat_id]['cat_id'] = $row->cat_id;
815  $this->categories_info[$row->cat_id]['title'] = $row->title;
816  $this->categories_info[$row->cat_id]['color'] = $row->color;
817  $this->categories_info[$row->cat_id]['type'] = $row->type;
818  $this->categories_info[$row->cat_id]['editable'] = false;
819  $this->categories_info[$row->cat_id]['accepted'] = false;
820  $this->categories_info[$row->cat_id]['remote'] = false;
821  }
822  }
823  return true;
824  }
setCHUserId($a_user_id)
Set ch user id.
static _lookupObjId($a_id)
Create styles array
The data for the language used.
global $ilDB
+ 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 504 of file class.ilCalendarCategories.php.

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

Referenced by initialize().

505  {
506  global $rbacsystem;
507 
508 
509  $this->readPublicCalendars();
510  $this->readPrivateCalendars();
512  $this->readBookingCalendar();
513 
514  include_once('./Services/Membership/classes/class.ilParticipants.php');
515  $this->readSelectedCategories(ilParticipants::_getMembershipByType($this->user_id,'crs'));
516  $this->readSelectedCategories(ilParticipants::_getMembershipByType($this->user_id,'grp'));
517 
518  $this->addSubitemCalendars();
519  }
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 688 of file class.ilCalendarCategories.php.

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

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

689  {
690  global $ilUser;
691  global $ilDB;
692 
693  // First read private calendars of user
694  $query = "SELECT cat_id FROM cal_categories ".
695  "WHERE type = ".$this->db->quote(ilCalendarCategory::TYPE_USR ,'integer')." ".
696  "AND obj_id = ".$this->db->quote($ilUser->getId(),'integer')." ";
697  $res = $this->db->query($query);
698  while($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT))
699  {
700  $cat_ids[] = $row->cat_id;
701  }
702 
703  // Read shared calendars
704  include_once('./Services/Calendar/classes/class.ilCalendarSharedStatus.php');
705  $accepted_ids = ilCalendarSharedStatus::getAcceptedCalendars($ilUser->getId());
706  if(!$cat_ids = array_merge((array) $cat_ids, $accepted_ids))
707  {
708  return true;
709  }
710 
711 
712  // user categories
713  $query = "SELECT * FROM cal_categories ".
714  "WHERE type = ".$this->db->quote(ilCalendarCategory::TYPE_USR ,'integer')." ".
715  "AND ".$ilDB->in('cat_id',$cat_ids,false,'integer')." ".
716  "ORDER BY title ";
717 
718  $res = $this->db->query($query);
719  while($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT))
720  {
721  $this->categories[] = $row->cat_id;
722  $this->categories_info[$row->cat_id]['obj_id'] = $row->obj_id;
723  $this->categories_info[$row->cat_id]['cat_id'] = $row->cat_id;
724  $this->categories_info[$row->cat_id]['title'] = $row->title;
725  $this->categories_info[$row->cat_id]['color'] = $row->color;
726  $this->categories_info[$row->cat_id]['type'] = $row->type;
727 
728  include_once './Services/Calendar/classes/class.ilCalendarShared.php';
729  if(in_array($row->cat_id, $accepted_ids))
730  {
731  $shared = new ilCalendarShared($row->cat_id);
732  if($shared->isEditableForUser($ilUser->getId()))
733  {
734  $this->categories_info[$row->cat_id]['editable'] = true;
735  }
736  else
737  {
738  $this->categories_info[$row->cat_id]['editable'] = false;
739  }
740  }
741  else
742  {
743  $this->categories_info[$row->cat_id]['editable'] = true;
744  }
745 
746  $this->categories_info[$row->cat_id]['accepted'] = in_array($row->cat_id, $accepted_ids);
747  $this->categories_info[$row->cat_id]['remote'] = ($row->loc_type == ilCalendarCategory::LTYPE_REMOTE);
748  }
749  }
static getAcceptedCalendars($a_usr_id)
get accepted shared calendars
Handles shared calendars.
$ilUser
Definition: imgupload.php:18
Create styles array
The data for the language used.
global $ilDB
+ 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 656 of file class.ilCalendarCategories.php.

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

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

657  {
658  global $rbacsystem,$ilAccess;
659 
660  // global categories
661  $query = "SELECT * FROM cal_categories ".
662  "WHERE type = ".$this->db->quote(ilCalendarCategory::TYPE_GLOBAL ,'integer')." ".
663  "ORDER BY title ";
664 
665  $res = $this->db->query($query);
666  while($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT))
667  {
668  $this->categories[] = $row->cat_id;
669  $this->categories_info[$row->cat_id]['obj_id'] = $row->obj_id;
670  $this->categories_info[$row->cat_id]['cat_id'] = $row->cat_id;
671  $this->categories_info[$row->cat_id]['title'] = $row->title;
672  $this->categories_info[$row->cat_id]['color'] = $row->color;
673  $this->categories_info[$row->cat_id]['type'] = $row->type;
674  $this->categories_info[$row->cat_id]['editable'] = $rbacsystem->checkAccess('edit_event',ilCalendarSettings::_getInstance()->getCalendarSettingsId());
675  $this->categories_info[$row->cat_id]['accepted'] = false;
676  $this->categories_info[$row->cat_id]['remote'] = ($row->loc_type == ilCalendarCategory::LTYPE_REMOTE);
677  }
678 
679  return true;
680  }
static _getInstance()
get singleton instance
+ 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 601 of file class.ilCalendarCategories.php.

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

Referenced by initialize().

602  {
603  global $ilAccess,$tree;
604  global $ilDB;
605 
606  $this->readPublicCalendars();
607  $this->readPrivateCalendars();
609 
610  #$query = "SELECT ref_id,obd.obj_id obj_id FROM tree t1 ".
611  # "JOIN object_reference obr ON t1.child = obr.ref_id ".
612  # "JOIN object_data obd ON obd.obj_id = obr.obj_id ".
613  # "WHERE t1.lft >= (SELECT lft FROM tree WHERE child = ".$this->db->quote($this->root_ref_id,'integer')." ) ".
614  # "AND t1.lft <= (SELECT rgt FROM tree WHERE child = ".$this->db->quote($this->root_ref_id,'integer')." ) ".
615  # "AND ".$ilDB->in('type',array('crs','grp','sess'),false,'text')." ".
616  # "AND tree = 1";
617 
618  $subtree_query = $GLOBALS['tree']->getSubTreeQuery(
619  $this->root_ref_id,
620  array('object_reference.ref_id','object_data.obj_id'),
621  array('crs','grp','sess','exc')
622  );
623 
624  $res = $ilDB->query($subtree_query);
625  $obj_ids = array();
626  while($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT))
627  {
628  if($tree->isDeleted($row->ref_id))
629  {
630  continue;
631  }
632 
633  $obj_type = ilObject::_lookupType($row->obj_id);
634  if($obj_type == 'crs' or $obj_type == 'grp')
635  {
636  // Check for global/local activation
637  if(!ilCalendarSettings::_getInstance()->lookupCalendarActivated($row->obj_id))
638  {
639  continue;
640  }
641  }
642  if($ilAccess->checkAccess('read','',$row->ref_id))
643  {
644  $obj_ids[] = $row->obj_id;
645  }
646  }
647  $this->readSelectedCategories($obj_ids);
648  }
static _getInstance()
get singleton instance
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
readConsultationHoursCalendar($a_target_ref_id=NULL)
Read personal consultation hours calendar.
readPublicCalendars()
Read public calendars.
readSelectedCategories($a_obj_ids)
read selected categories
Create styles array
The data for the language used.
static _lookupType($a_id, $a_reference=false)
lookup object type
global $ilDB
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 525 of file class.ilCalendarCategories.php.

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

Referenced by initialize().

526  {
527  include_once './Services/Calendar/classes/class.ilCalendarCategory.php';
528  $cat = new ilCalendarCategory($a_cal_id);
529  if($cat->getType() == ilCalendarCategory::TYPE_OBJ)
530  {
531  $this->readSelectedCategories(array($cat->getObjId()));
532  $this->addSubitemCalendars();
533  }
534  else
535  {
536  $this->categories[] = $a_cal_id;
537  }
538  }
addSubitemCalendars()
Add subitem calendars E.g.
Stores calendar categories.
readSelectedCategories($a_obj_ids)
read selected categories
Create styles array
The data for the language used.
+ 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 864 of file class.ilCalendarCategories.php.

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

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

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

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

Referenced by initialize().

547  {
548  global $ilUser,$ilAccess;
549 
550  $this->readPublicCalendars();
551  $this->readPrivateCalendars();
553  $this->readBookingCalendar();
554 
555  $obj_ids = array();
556 
557  $courses = array();
558  $groups = array();
559  $sessions = array();
560  $exercises = array();
561  foreach(ilObjUser::_lookupDesktopItems($ilUser->getId(),array('crs','grp','sess','exc')) as $item)
562  {
563  if($ilAccess->checkAccess('read','',$item['ref_id']))
564  {
565  switch($item['type'])
566  {
567  case 'crs':
568  $courses[] = $item['obj_id'];
569  break;
570 
571  case 'sess':
572  $sessions[] = $item['obj_id'];
573  break;
574 
575  case 'grp':
576  $groups[] = $item['obj_id'];
577  break;
578 
579  case 'exc':
580  $exercises[] = $item['obj_id'];
581  break;
582  }
583  }
584  }
585  $this->readSelectedCategories($courses);
586  $this->readSelectedCategories($sessions);
587  $this->readSelectedCategories($groups);
588  $this->readSelectedCategories($exercises);
589 
590  $this->addSubitemCalendars();
591 
592  }
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.
$ilUser
Definition: imgupload.php:18
Create styles array
The data for the language used.
static _lookupDesktopItems($user_id, $a_types="")
get all desktop items of user and specified type
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 219 of file class.ilCalendarCategories.php.

Referenced by readConsultationHoursCalendar().

220  {
221  $this->ch_user_id = $a_user_id;
222  }
+ Here is the caller graph for this function:

◆ setMode()

ilCalendarCategories::setMode (   $a_mode)
protected

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

Referenced by initialize().

235  {
236  $this->mode = $a_mode;
237  }
+ Here is the caller graph for this function:

◆ setTargetRefId()

ilCalendarCategories::setTargetRefId (   $a_ref_id)
protected

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

Referenced by initialize().

245  {
246  $this->target_ref_id = $a_ref_id;
247  }
+ Here is the caller graph for this function:

◆ sleep()

ilCalendarCategories::sleep ( )
protected

Serialize categories.

Returns

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

References array.

191  {
192  return serialize(
193  array(
194  'categories' => $this->categories,
195  'categories_info' => $this->categories_info,
196  'subitem_categories'=> $this->subitem_categories
197  )
198  );
199  }
Create styles array
The data for the language used.

◆ wakeup()

ilCalendarCategories::wakeup (   $a_ser)
protected

Load from serialize string.

Parameters
stringserialize categories
Returns

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

References $info.

Referenced by initialize().

207  {
208  $info = unserialize($a_ser);
209 
210  $this->categories = $info['categories'];
211  $this->categories_info = $info['categories_info'];
212  $this->subitem_categories = $info['subitem_categories'];
213  }
$info
Definition: example_052.php:80
+ 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.

◆ $logger

ilCalendarCategories::$logger = null
protected

ilLogger

Definition at line 70 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: