/**
  * get singleton instance
  * @return object ilCalendarCache
  */
 public static function getInstance()
 {
     if (isset(self::$instance) and self::$instance) {
         return self::$instance;
     }
     return self::$instance = new ilCalendarCache();
 }
 /**
  * initialize visible categories
  *
  * @access public
  * @param int mode 
  * @param int ref_id of root node
  * @return
  */
 public function initialize($a_mode, $a_source_ref_id = 0, $a_use_cache = false)
 {
     $this->setMode($a_mode);
     if ($a_use_cache) {
         // Read categories from cache
         if ($cats = ilCalendarCache::getInstance()->getEntry($this->user_id . ':' . $a_mode . ':categories:' . (int) $a_source_ref_id)) {
             if ($this->getMode() != self::MODE_CONSULTATION && $this->getMode() != self::MODE_PORTFOLIO_CONSULTATION) {
                 $this->wakeup($cats);
                 return;
             }
         }
     }
     switch ($this->getMode()) {
         case self::MODE_REMOTE_ACCESS:
             include_once './Services/Calendar/classes/class.ilCalendarUserSettings.php';
             if (ilCalendarUserSettings::_getInstance()->getCalendarSelectionType() == ilCalendarUserSettings::CAL_SELECTION_MEMBERSHIP) {
                 $this->readPDCalendars();
             } else {
                 $this->readSelectedItemCalendars();
             }
             break;
         case self::MODE_REMOTE_SELECTED:
             $this->readSelectedCalendar($a_source_ref_id);
             break;
         case self::MODE_PERSONAL_DESKTOP_MEMBERSHIP:
             $this->readPDCalendars();
             break;
         case self::MODE_PERSONAL_DESKTOP_ITEMS:
             $this->readSelectedItemCalendars();
             break;
         case self::MODE_REPOSITORY:
             $this->root_ref_id = $a_source_ref_id;
             $this->root_obj_id = ilObject::_lookupObjId($this->root_ref_id);
             $this->readReposCalendars();
             break;
         case self::MODE_MANAGE:
             $this->readPDCalendars();
             $this->readSelectedItemCalendars();
             break;
         case self::MODE_CONSULTATION:
             #$this->readPrivateCalendars();
             $this->setTargetRefId($a_source_ref_id);
             $this->readConsultationHoursCalendar($a_source_ref_id);
             break;
         case self::MODE_PORTFOLIO_CONSULTATION:
             $this->readConsultationHoursCalendar();
             break;
     }
     if ($a_use_cache) {
         // Store in cache
         ilCalendarCache::getInstance()->storeEntry($this->user_id . ':' . $a_mode . ':categories:' . (int) $a_source_ref_id, $this->sleep(), $this->user_id, $a_mode, 'categories');
     }
 }