コード例 #1
0
 /**
  * Read private calendars
  *
  * @access protected
  * @return
  */
 protected function readPrivateCalendars()
 {
     global $ilUser;
     global $ilDB;
     // First read private calendars of user
     $query = "SELECT cat_id FROM cal_categories " . "WHERE type = " . $this->db->quote(ilCalendarCategory::TYPE_USR, 'integer') . " " . "AND obj_id = " . $this->db->quote($ilUser->getId(), 'integer') . " ";
     $res = $this->db->query($query);
     while ($row = $res->fetchRow(DB_FETCHMODE_OBJECT)) {
         $cat_ids[] = $row->cat_id;
     }
     // Read shared calendars
     include_once './Services/Calendar/classes/class.ilCalendarSharedStatus.php';
     $accepted_ids = ilCalendarSharedStatus::getAcceptedCalendars($ilUser->getId());
     if (!($cat_ids = array_merge((array) $cat_ids, $accepted_ids))) {
         return true;
     }
     // user categories
     $query = "SELECT * FROM cal_categories " . "WHERE type = " . $this->db->quote(ilCalendarCategory::TYPE_USR, 'integer') . " " . "AND " . $ilDB->in('cat_id', $cat_ids, false, 'integer') . " " . "ORDER BY title ";
     $res = $this->db->query($query);
     while ($row = $res->fetchRow(DB_FETCHMODE_OBJECT)) {
         $this->categories[] = $row->cat_id;
         $this->categories_info[$row->cat_id]['obj_id'] = $row->obj_id;
         $this->categories_info[$row->cat_id]['cat_id'] = $row->cat_id;
         $this->categories_info[$row->cat_id]['title'] = $row->title;
         $this->categories_info[$row->cat_id]['color'] = $row->color;
         $this->categories_info[$row->cat_id]['type'] = $row->type;
         include_once './Services/Calendar/classes/class.ilCalendarShared.php';
         if (in_array($row->cat_id, $accepted_ids)) {
             $shared = new ilCalendarShared($row->cat_id);
             if ($shared->isEditableForUser($ilUser->getId())) {
                 $this->categories_info[$row->cat_id]['editable'] = true;
             } else {
                 $this->categories_info[$row->cat_id]['editable'] = false;
             }
         } else {
             $this->categories_info[$row->cat_id]['editable'] = true;
         }
         $this->categories_info[$row->cat_id]['accepted'] = in_array($row->cat_id, $accepted_ids);
         $this->categories_info[$row->cat_id]['remote'] = $row->loc_type == ilCalendarCategory::LTYPE_REMOTE;
     }
 }