/** * Constructor * * @access public * @param ilDate seed date * @param int type of schedule (TYPE_DAY,TYPE_WEEK or TYPE_MONTH) * @param int user_id * */ public function __construct(ilDate $seed, $a_type, $a_user_id = 0, $filter_bookings = false) { global $ilUser, $ilDB; $this->db = $ilDB; $this->type = $a_type; $this->initPeriod($seed); if (!$a_user_id || $a_user_id == $ilUser->getId()) { $this->user = $ilUser; } else { $this->user = new ilObjUser($a_user_id); } $this->filter_bookings = $filter_bookings; $this->user_settings = ilCalendarUserSettings::_getInstanceByUserId($this->user->getId()); $this->weekstart = $this->user_settings->getWeekStart(); $this->timezone = $this->user->getTimeZone(); $this->hidden_cat = ilCalendarHidden::_getInstanceByUserId($this->user->getId()); }
/** * save selection of categories * * @access public * @param * @return */ public function saveSelection() { global $ilUser; include_once './Services/Calendar/classes/class.ilCalendarCategories.php'; include_once './Services/Calendar/classes/class.ilCalendarHidden.php'; $selected_cat_ids = $_POST['selected_cat_ids'] ? $_POST['selected_cat_ids'] : array(); $shown_cat_ids = $_POST['shown_cat_ids'] ? $_POST['shown_cat_ids'] : array(); $cats = ilCalendarCategories::_getInstance($ilUser->getId()); $cat_ids = $cats->getCategories(); $hidden_cats = ilCalendarHidden::_getInstanceByUserId($ilUser->getId()); $hidden_cat_ids = $hidden_cats->getHidden(); $hidden = array(); foreach ($hidden_cat_ids as $hidden_cat_id) { if (!in_array($hidden_cat_id, $shown_cat_ids)) { $hidden[] = $hidden_cat_id; } } foreach ($shown_cat_ids as $shown_cat_id) { $shown_cat_id = (int) $shown_cat_id; if (!in_array($shown_cat_id, $selected_cat_ids)) { $hidden[] = $shown_cat_id; } } $hidden_categories = ilCalendarHidden::_getInstanceByUserId($this->user_id); $hidden_categories->hideSelected($hidden); $hidden_categories->save(); ilUtil::sendSuccess($this->lng->txt('settings_saved'), true); $this->ctrl->returnToParent($this); }
/** * 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; }
public function __construct($a_user_id) { $this->user_id = $a_user_id; $this->hidden_cat = ilCalendarHidden::_getInstanceByUserId($this->user_id); }
/** * delete * * @access public * @return */ public function delete() { global $ilDB; $query = "DELETE FROM cal_categories " . "WHERE cat_id = " . $this->db->quote($this->cat_id, 'integer') . " "; $res = $ilDB->manipulate($query); include_once './Services/Calendar/classes/class.ilCalendarHidden.php'; ilCalendarHidden::_deleteCategories($this->cat_id); include_once './Services/Calendar/classes/class.ilCalendarCategoryAssignments.php'; foreach (ilCalendarCategoryAssignments::_getAssignedAppointments(array($this->cat_id)) as $app_id) { include_once './Services/Calendar/classes/class.ilCalendarEntry.php'; ilCalendarEntry::_delete($app_id); } ilCalendarCategoryAssignments::_deleteByCategoryId($this->cat_id); }