コード例 #1
0
 /**
  * Get calendars
  */
 public function getCalendars()
 {
     global $ilUser, $tree;
     include_once './Services/Calendar/classes/class.ilCalendarCategories.php';
     include_once './Services/Calendar/classes/class.ilCalendarHidden.php';
     $hidden_obj = ilCalendarHidden::_getInstanceByUserId($ilUser->getId());
     $hidden = $hidden_obj->getHidden();
     $cats = ilCalendarCategories::_getInstance($ilUser->getId());
     $all = $cats->getCategoriesInfo();
     $tmp_title_counter = array();
     $categories = array();
     foreach ($all as $category) {
         $tmp_arr['obj_id'] = $category['obj_id'];
         $tmp_arr['id'] = $category['cat_id'];
         $tmp_arr['hidden'] = (bool) in_array($category['cat_id'], $hidden);
         $tmp_arr['title'] = $category['title'];
         $tmp_arr['type'] = $category['type'];
         // Append object type to make type sortable
         $tmp_arr['type_sortable'] = ilCalendarCategory::lookupCategorySortIndex($category['type']);
         if ($category['type'] == ilCalendarCategory::TYPE_OBJ) {
             $tmp_arr['type_sortable'] .= '_' . ilObject::_lookupType($category['obj_id']);
         }
         $tmp_arr['color'] = $category['color'];
         $tmp_arr['editable'] = $category['editable'];
         $categories[] = $tmp_arr;
         // count title for appending the parent container if there is more than one entry.
         $tmp_title_counter[$category['type'] . '_' . $category['title']]++;
     }
     $path_categories = array();
     foreach ($categories as $cat) {
         if ($cat['type'] == ilCalendarCategory::TYPE_OBJ) {
             if ($tmp_title_counter[$cat['type'] . '_' . $cat['title']] > 1) {
                 foreach (ilObject::_getAllReferences($cat['obj_id']) as $ref_id) {
                     $cat['path'] = $this->buildPath($ref_id);
                     break;
                 }
             }
         }
         $path_categories[] = $cat;
     }
     $path_categories = ilUtil::sortArray($path_categories, 'title', "asc");
     $this->calendars = $path_categories;
 }
コード例 #2
0
 /**
  * parse
  *
  * @access public
  * @return
  */
 public function parse()
 {
     global $ilUser, $tree;
     include_once './Services/Calendar/classes/class.ilCalendarCategories.php';
     $cats = ilCalendarCategories::_getInstance($ilUser->getId());
     $cats->initialize(ilCalendarCategories::MODE_MANAGE);
     $tmp_title_counter = array();
     $categories = array();
     foreach ($cats->getCategoriesInfo() as $category) {
         $tmp_arr['obj_id'] = $category['obj_id'];
         $tmp_arr['id'] = $category['cat_id'];
         $tmp_arr['title'] = $category['title'];
         $tmp_arr['type'] = $category['type'];
         // Append object type to make type sortable
         $tmp_arr['type_sortable'] = ilCalendarCategory::lookupCategorySortIndex($category['type']);
         if ($category['type'] == ilCalendarCategory::TYPE_OBJ) {
             $tmp_arr['type_sortable'] .= '_' . ilObject::_lookupType($category['obj_id']);
         }
         $tmp_arr['color'] = $category['color'];
         $tmp_arr['editable'] = $category['editable'];
         $tmp_arr['accepted'] = $category['accepted'];
         $tmp_arr['remote'] = $category['remote'];
         $categories[] = $tmp_arr;
         // count title for appending the parent container if there is more than one entry.
         $tmp_title_counter[$category['type'] . '_' . $category['title']]++;
     }
     $path_categories = array();
     foreach ($categories as $cat) {
         if ($cat['type'] == ilCalendarCategory::TYPE_OBJ) {
             if ($tmp_title_counter[$cat['type'] . '_' . $cat['title']] > 1) {
                 foreach (ilObject::_getAllReferences($cat['obj_id']) as $ref_id) {
                     include_once './Services/Tree/classes/class.ilPathGUI.php';
                     $path = new ilPathGUI();
                     $path->setUseImages(false);
                     $path->enableTextOnly(false);
                     $cat['path'] = $path->getPath(ROOT_FOLDER_ID, $ref_id);
                     break;
                 }
             }
         }
         $path_categories[] = $cat;
     }
     $this->setData($path_categories);
 }