/** * Fill row * @param type $a_set */ public function fillRow($row) { global $ilCtrl; $this->tpl->setVariable('START', $row['start_str']); $this->tpl->setVariable('NAME', $row['name']); $this->tpl->setVariable('COMMENT', $row['comment']); $this->tpl->setVariable('TITLE', $row['title']); $this->tpl->setVariable('VAL_ID', $row['id']); include_once './Services/UIComponent/AdvancedSelectionList/classes/class.ilAdvancedSelectionListGUI.php'; $list = new ilAdvancedSelectionListGUI(); $list->setId('act_chboo_' . $row['id']); $list->setListTitle($this->lng->txt('actions')); $ilCtrl->setParameter($this->getParentObject(), 'bookuser', $row['id']); $start = new ilDateTime($row['start'], IL_CAL_UNIX); if (ilDateTime::_after($start, $this->today, IL_CAL_DAY)) { $list->addItem($this->lng->txt('cal_ch_reject_booking'), '', $ilCtrl->getLinkTarget($this->getParentObject(), 'confirmRejectBooking')); } $list->addItem($this->lng->txt('cal_ch_delete_booking'), '', $ilCtrl->getLinkTarget($this->getParentObject(), 'confirmDeleteBooking')); $this->tpl->setVariable('ACTIONS', $list->getHTML()); }
/** * Get subitems of container * @param bool $a_admin_panel_enabled[optional] * @param bool $a_include_side_block[optional] * @return array */ public function getSubItems($a_admin_panel_enabled = false, $a_include_side_block = false) { global $ilUser; // Caching if (is_array($this->items[(int) $a_admin_panel_enabled][(int) $a_include_side_block])) { return $this->items[(int) $a_admin_panel_enabled][(int) $a_include_side_block]; } // Results are stored in $this->items parent::getSubItems($a_admin_panel_enabled, $a_include_side_block); $limit_sess = false; if (!$a_admin_panel_enabled && !$a_include_side_block && $this->items['sess'] && is_array($this->items['sess']) && $this->isSessionLimitEnabled() && $this->getViewMode() == ilContainer::VIEW_SESSIONS) { $limit_sess = true; } if (!$limit_sess) { return $this->items[(int) $a_admin_panel_enabled][(int) $a_include_side_block]; } // do session limit // @todo move to gui class if (isset($_GET['crs_prev_sess'])) { $ilUser->writePref('crs_sess_show_prev_' . $this->getId(), (string) (int) $_GET['crs_prev_sess']); } if (isset($_GET['crs_next_sess'])) { $ilUser->writePref('crs_sess_show_next_' . $this->getId(), (string) (int) $_GET['crs_next_sess']); } $sessions = ilUtil::sortArray($this->items['sess'], 'start', 'ASC', true, false); $today = new ilDate(date('Ymd', time()), IL_CAL_DATE); $previous = $current = $next = array(); foreach ($sessions as $key => $item) { $start = new ilDateTime($item['start'], IL_CAL_UNIX); $end = new ilDateTime($item['end'], IL_CAL_UNIX); if (ilDateTime::_within($today, $start, $end, IL_CAL_DAY)) { $current[] = $item; } elseif (ilDateTime::_before($start, $today, IL_CAL_DAY)) { $previous[] = $item; } elseif (ilDateTime::_after($start, $today, IL_CAL_DAY)) { $next[] = $item; } } $num_previous_remove = max(count($previous) - $this->getNumberOfPreviousSessions(), 0); while ($num_previous_remove--) { if (!$ilUser->getPref('crs_sess_show_prev_' . $this->getId())) { array_shift($previous); } $this->items['sess_link']['prev']['value'] = 1; } $num_next_remove = max(count($next) - $this->getNumberOfNextSessions(), 0); while ($num_next_remove--) { if (!$ilUser->getPref('crs_sess_show_next_' . $this->getId())) { array_pop($next); } // @fixme $this->items['sess_link']['next']['value'] = 1; } $sessions = array_merge($previous, $current, $next); $this->items['sess'] = $sessions; // #15389 - see ilContainer::getSubItems() include_once 'Services/Container/classes/class.ilContainerSorting.php'; $sort = ilContainerSorting::_getInstance($this->getId()); $this->items[(int) $a_admin_panel_enabled][(int) $a_include_side_block] = $sort->sortItems($this->items); return $this->items[(int) $a_admin_panel_enabled][(int) $a_include_side_block]; }
/** * Check whether an date is within a date duration given by start and end * @param ilDateTime $dt * @param ilDateTime $start * @param ilDateTime $end * @param type $a_compare_field * @param type $a_tz */ public static function _within(ilDateTime $dt, ilDateTime $start, ilDateTime $end, $a_compare_field = '', $a_tz = '') { return (ilDateTime::_after($dt, $start, $a_compare_field, $a_tz) or ilDateTime::_equals($dt, $start, $a_compare_field, $a_tz)) && (ilDateTime::_before($dt, $end, $a_compare_field, $a_tz) or ilDateTime::_equals($dt, $end, $a_compare_field, $a_tz)); }
public static function getOpenRoomBooking($a_group_id) { $now = new ilDateTime(time(), IL_CAL_UNIX); $earlier = clone $now; $later = clone $now; $later->increment(IL_CAL_DAY, 5); $booking = self::lookupNextBooking($earlier, $later, $a_group_id); if (!$booking['open'] instanceof ilDateTime) { return 0; } if (ilDateTime::_before($booking['open'], $now) and ilDateTime::_after($booking['closed'], $now)) { return $booking['id']; } return 0; }
/** * get activation * * @return boolean true/false for active or not */ function getActive($a_check_scheduled_activation = false) { if ($a_check_scheduled_activation && !$this->active) { include_once "./Services/Calendar/classes/class.ilDateTime.php"; $start = new ilDateTime($this->getActivationStart(), IL_CAL_DATETIME); $end = new ilDateTime($this->getActivationEnd(), IL_CAL_DATETIME); $now = new ilDateTime(time(), IL_CAL_UNIX); if (!ilDateTime::_before($now, $start) && !ilDateTime::_after($now, $end)) { return true; } } return $this->active; }
/** * Check if value matches * @param mixed $a_value Econtent value * @param int $a_type Parameter type * @return */ protected function matchesValue($a_value, $a_type) { global $ilLog; switch ($a_type) { case self::ATTR_ARRAY: $values = explode(',', $a_value); $ilLog->write(__METHOD__ . ': Checking for value: ' . $a_value); $ilLog->write(__METHOD__ . ': Checking against attribute values: ' . $this->getMappingValue()); break; case self::ATTR_INT: $ilLog->write(__METHOD__ . ': Checking for value: ' . $a_value); $ilLog->write(__METHOD__ . ': Checking against attribute values: ' . $this->getMappingValue()); $values = array($a_value); break; case self::ATTR_STRING: $values = array($a_value); break; } $values = explode(',', $a_value); foreach ($values as $value) { $value = trim($value); switch ($this->getMappingType()) { case self::TYPE_FIXED: foreach ($this->getMappingAsArray() as $attribute_value) { $attribute_value = trim($attribute_value); if (strcasecmp($attribute_value, $value) == 0) { return true; } } break; case self::TYPE_DURATION: include_once './Services/Calendar/classes/class.ilDateTime.php'; $tmp_date = new ilDate($a_value, IL_CAL_UNIX); return ilDateTime::_after($tmp_date, $this->getDateRangeStart()) and ilDateTime::_before($tmp_date, $this->getDateRangeEnd()); } } return false; }
/** * get HTML * * @access public * @param * @return */ public function getHTML($a_app) { global $tree, $lng, $ilUser; self::$counter++; $this->tpl = new ilTemplate('tpl.appointment_panel.html', true, true, 'Services/Calendar'); // Panel variables $this->tpl->setVariable('PANEL_NUM', self::$counter); $this->tpl->setVariable('PANEL_TITLE', str_replace(' ()', '', $a_app['event']->getPresentationTitle(false))); if ($a_app["event"]->isMilestone()) { $this->tpl->setVariable('PANEL_DETAILS', $this->lng->txt('cal_ms_details')); } else { $this->tpl->setVariable('PANEL_DETAILS', $this->lng->txt('cal_details')); } $this->tpl->setVariable('PANEL_TXT_DATE', $this->lng->txt('date')); if ($a_app['fullday']) { $this->tpl->setVariable('PANEL_DATE', ilDatePresentation::formatPeriod(new ilDate($a_app['dstart'], IL_CAL_UNIX), new ilDate($a_app['dend'], IL_CAL_UNIX))); } else { $this->tpl->setVariable('PANEL_DATE', ilDatePresentation::formatPeriod(new ilDateTime($a_app['dstart'], IL_CAL_UNIX), new ilDateTime($a_app['dend'], IL_CAL_UNIX))); } if ($a_app['event']->getLocation()) { $this->tpl->setVariable('PANEL_TXT_WHERE', $this->lng->txt('cal_where')); $this->tpl->setVariable('PANEL_WHERE', ilUtil::makeClickable($a_app['event']->getLocation()), true); } if ($a_app['event']->getDescription()) { $this->tpl->setVariable('PANEL_TXT_DESC', $this->lng->txt('description')); $this->tpl->setVariable('PANEL_DESC', ilUtil::makeClickable(nl2br($a_app['event']->getDescription()))); } if ($a_app['event']->isMilestone() && $a_app['event']->getCompletion() > 0) { $this->tpl->setVariable('PANEL_TXT_COMPL', $this->lng->txt('cal_task_completion')); $this->tpl->setVariable('PANEL_COMPL', $a_app['event']->getCompletion() . " %"); } if ($a_app['event']->isMilestone()) { // users responsible $users = $a_app['event']->readResponsibleUsers(); $delim = ""; foreach ($users as $r) { $value .= $delim . $r["lastname"] . ", " . $r["firstname"] . " [" . $r["login"] . "]"; $delim = "<br />"; } if (count($users) > 0) { $this->tpl->setVariable('PANEL_TXT_RESP', $this->lng->txt('cal_responsible')); $this->tpl->setVariable('PANEL_RESP', $value); } } include_once './Services/Calendar/classes/class.ilCalendarCategoryAssignments.php'; $cat_id = ilCalendarCategoryAssignments::_lookupCategory($a_app['event']->getEntryId()); $cat_info = ilCalendarCategories::_getInstance()->getCategoryInfo($cat_id); $entry_obj_id = isset($cat_info['subitem_obj_ids'][$cat_id]) ? $cat_info['subitem_obj_ids'][$cat_id] : $cat_info['obj_id']; $this->tpl->setVariable('PANEL_TXT_CAL_TYPE', $this->lng->txt('cal_cal_type')); switch ($cat_info['type']) { case ilCalendarCategory::TYPE_GLOBAL: $this->tpl->setVariable('PANEL_CAL_TYPE', $this->lng->txt('cal_type_system')); break; case ilCalendarCategory::TYPE_USR: $this->tpl->setVariable('PANEL_CAL_TYPE', $this->lng->txt('cal_type_personal')); break; case ilCalendarCategory::TYPE_OBJ: $type = ilObject::_lookupType($cat_info['obj_id']); $this->tpl->setVariable('PANEL_CAL_TYPE', $this->lng->txt('cal_type_' . $type)); // Course group appointment registration if ($this->settings->isCGRegistrationEnabled() and $type == 'crs' or type == 'grp') { if (!$a_app['event']->isAutoGenerated()) { include_once './Services/Calendar/classes/class.ilCalendarRegistration.php'; $reg = new ilCalendarRegistration($a_app['event']->getEntryId()); if ($reg->isRegistered($ilUser->getId(), new ilDateTime($a_app['dstart'], IL_CAL_UNIX), new ilDateTime($a_app['dend'], IL_CAL_UNIX))) { $this->tpl->setCurrentBlock('panel_cancel_book_link'); $this->ctrl->setParameterByClass('ilcalendarappointmentgui', 'seed', $this->getSeed()->get(IL_CAL_DATE)); $this->ctrl->setParameterByClass('ilcalendarappointmentgui', 'app_id', $a_app['event']->getEntryId()); $this->ctrl->setParameterByClass('ilcalendarappointmentgui', 'dstart', $a_app['dstart']); $this->ctrl->setParameterByClass('ilcalendarappointmentgui', 'dend', $a_app['dend']); $this->tpl->setVariable('TXT_PANEL_CANCELBOOK', $this->lng->txt('cal_reg_unregister')); $this->tpl->setVariable('PANEL_CANCELBOOK_HREF', $this->ctrl->getLinkTargetByClass('ilcalendarappointmentgui', 'confirmUnregister')); $this->tpl->parseCurrentBlock(); } else { $this->tpl->setCurrentBlock('panel_book_link'); $this->ctrl->setParameterByClass('ilcalendarappointmentgui', 'seed', $this->getSeed()->get(IL_CAL_DATE)); $this->ctrl->setParameterByClass('ilcalendarappointmentgui', 'app_id', $a_app['event']->getEntryId()); $this->ctrl->setParameterByClass('ilcalendarappointmentgui', 'dstart', $a_app['dstart']); $this->ctrl->setParameterByClass('ilcalendarappointmentgui', 'dend', $a_app['dend']); $this->tpl->setVariable('TXT_PANEL_BOOK', $this->lng->txt('cal_reg_register')); $this->tpl->setVariable('PANEL_BOOK_HREF', $this->ctrl->getLinkTargetByClass('ilcalendarappointmentgui', 'confirmRegister')); $this->tpl->parseCurrentBlock(); } include_once './Services/Link/classes/class.ilLink.php'; $registrations = array(); foreach ($reg->getRegisteredUsers(new ilDateTime($a_app['dstart'], IL_CAL_UNIX), new ilDateTime($a_app['dend'], IL_CAL_UNIX)) as $usr_data) { $usr_id = $usr_data['usr_id']; $this->ctrl->setParameterByClass('ilconsultationhoursgui', 'user', $usr_id); $registrations[] = '<a href="' . $this->ctrl->getLinkTargetByClass('ilconsultationhoursgui', 'showprofile') . '">' . ilObjUser::_lookupFullname($usr_id); $this->ctrl->setParameterByClass('ilconsultationhoursgui', 'user', ''); } if (count($registrations)) { $this->tpl->setCurrentBlock('panel_current_booking'); $this->tpl->setVariable('PANEL_TXT_CURRENT_BOOKING', $this->lng->txt('cal_reg_registered_users')); $this->tpl->setVariable('PANEL_CURRENT_BOOKING', implode('<br />', $registrations)); $this->tpl->parseCurrentBlock(); } } } break; case ilCalendarCategory::TYPE_CH: $this->tpl->setVariable('PANEL_CAL_TYPE', $this->lng->txt('cal_ch_ch')); include_once 'Services/Booking/classes/class.ilBookingEntry.php'; $entry = new ilBookingEntry($a_app['event']->getContextId()); $is_owner = $entry->isOwner(); $user_entry = $cat_info['obj_id'] == $ilUser->getId(); if ($user_entry && !$is_owner) { // find source calendar entry in owner calendar include_once 'Services/Calendar/classes/ConsultationHours/class.ilConsultationHourAppointments.php'; $apps = ilConsultationHourAppointments::getAppointmentIds($entry->getObjId(), $a_app['event']->getContextId(), $a_app['event']->getStart()); $ref_event = $apps[0]; } else { $ref_event = $a_app['event']->getEntryId(); } $this->tpl->setCurrentBlock('panel_booking_owner'); $this->tpl->setVariable('PANEL_TXT_BOOKING_OWNER', $this->lng->txt('cal_ch_booking_owner')); $this->tpl->setVariable('PANEL_BOOKING_OWNER', ilObjUser::_lookupFullname($entry->getObjId())); $this->tpl->parseCurrentBlock(); $this->tpl->setCurrentBlock('panel_max_booking'); $this->tpl->setVariable('PANEL_TXT_MAX_BOOKING', $this->lng->txt('cal_ch_num_bookings')); $this->tpl->setVariable('PANEL_MAX_BOOKING', $entry->getNumberOfBookings()); $this->tpl->parseCurrentBlock(); if (!$is_owner) { if ($entry->hasBooked($ref_event)) { if (ilDateTime::_after($a_app['event']->getStart(), new ilDateTime(time(), IL_CAL_UNIX))) { $this->tpl->setCurrentBlock('panel_cancel_book_link'); $this->ctrl->setParameterByClass('ilcalendarappointmentgui', 'app_id', $ref_event); $this->ctrl->setParameterByClass('ilcalendarappointmentgui', 'seed', $this->getSeed()->get(IL_CAL_DATE)); $this->tpl->setVariable('TXT_PANEL_CANCELBOOK', $this->lng->txt('cal_ch_cancel_booking')); $this->tpl->setVariable('PANEL_CANCELBOOK_HREF', $this->ctrl->getLinkTargetByClass('ilcalendarappointmentgui', 'cancelBooking')); $this->tpl->parseCurrentBlock(); } } elseif ($entry->isAppointmentBookableForUser($ref_event, $GLOBALS['ilUser']->getId())) { $this->tpl->setCurrentBlock('panel_book_link'); $this->ctrl->setParameterByClass('ilcalendarappointmentgui', 'app_id', $ref_event); $this->ctrl->setParameterByClass('ilcalendarappointmentgui', 'seed', $this->getSeed()->get(IL_CAL_DATE)); $this->tpl->setVariable('TXT_PANEL_BOOK', $this->lng->txt('cal_ch_book')); $this->tpl->setVariable('PANEL_BOOK_HREF', $this->ctrl->getLinkTargetByClass('ilcalendarappointmentgui', 'book')); $this->tpl->parseCurrentBlock(); } $this->tpl->setCurrentBlock('panel_current_booking'); $this->tpl->setVariable('PANEL_TXT_CURRENT_BOOKING', $this->lng->txt('cal_ch_current_bookings')); $this->tpl->setVariable('PANEL_CURRENT_BOOKING', $entry->getCurrentNumberOfBookings($ref_event)); $this->tpl->parseCurrentBlock(); } else { $obj_ids = $entry->getTargetObjIds(); foreach ($obj_ids as $obj_id) { $title = ilObject::_lookupTitle($obj_id); $refs = ilObject::_getAllReferences($obj_id); include_once './Services/Link/classes/class.ilLink.php'; $this->tpl->setCurrentBlock('panel_booking_target_row'); $this->tpl->setVariable('PANEL_BOOKING_TARGET_TITLE', $title); $this->tpl->setVariable('PANEL_BOOKING_TARGET', ilLink::_getLink(end($refs))); $this->tpl->parseCurrentBlock(); } if ($obj_ids) { $this->tpl->setCurrentBlock('panel_booking_target'); $this->tpl->setVariable('PANEL_TXT_BOOKING_TARGET', $this->lng->txt('cal_ch_target_object')); $this->tpl->parseCurrentBlock(); } $link_users = true; if (ilCalendarCategories::_getInstance()->getMode() == ilCalendarCategories::MODE_PORTFOLIO_CONSULTATION) { $link_users = false; } include_once './Services/Link/classes/class.ilLink.php'; $bookings = array(); $this->ctrl->setParameterByClass('ilconsultationhoursgui', 'panel', 1); foreach ($entry->getCurrentBookings($a_app['event']->getEntryId()) as $user_id) { if ($link_users) { $this->ctrl->setParameterByClass('ilconsultationhoursgui', 'user', $user_id); $bookings[] = '<a href="' . $this->ctrl->getLinkTargetByClass('ilconsultationhoursgui', 'showprofile') . '">' . ilObjUser::_lookupFullname($user_id) . '</a>'; $this->ctrl->setParameterByClass('ilconsultationhoursgui', 'user', ''); } else { $bookings[] = ilObjUser::_lookupFullname($user_id); } } $this->ctrl->setParameterByClass('ilconsultationhoursgui', 'panel', ''); $this->tpl->setCurrentBlock('panel_current_booking'); $this->tpl->setVariable('PANEL_TXT_CURRENT_BOOKING', $this->lng->txt('cal_ch_current_bookings')); $this->tpl->setVariable('PANEL_CURRENT_BOOKING', implode('<br />', $bookings)); $this->tpl->parseCurrentBlock(); } break; case ilCalendarCategory::TYPE_BOOK: $this->tpl->setVariable('PANEL_CAL_TYPE', $this->lng->txt('cal_ch_booking')); $this->tpl->setCurrentBlock('panel_cancel_book_link'); $this->ctrl->setParameterByClass('ilcalendarappointmentgui', 'app_id', $a_app['event']->getEntryId()); $this->ctrl->setParameterByClass('ilcalendarappointmentgui', 'seed', $this->getSeed()->get(IL_CAL_DATE)); $this->tpl->setVariable('TXT_PANEL_CANCELBOOK', $this->lng->txt('cal_ch_cancel_booking')); $this->tpl->setVariable('PANEL_CANCELBOOK_HREF', $this->ctrl->getLinkTargetByClass('ilcalendarappointmentgui', 'cancelBooking')); $this->tpl->parseCurrentBlock(); break; } $this->tpl->setVariable('PANEL_TXT_CAL_NAME', $this->lng->txt('cal_calendar_name')); $this->tpl->setVariable('PANEL_CAL_NAME', $cat_info['title']); if ($cat_info['editable'] and !$a_app['event']->isAutoGenerated()) { $this->tpl->setCurrentBlock('panel_edit_link'); $this->tpl->setVariable('TXT_PANEL_EDIT', $this->lng->txt('edit')); $this->ctrl->clearParametersByClass('ilcalendarappointmentgui'); $this->ctrl->setParameterByClass('ilcalendarappointmentgui', 'seed', $this->getSeed()->get(IL_CAL_DATE)); $this->ctrl->setParameterByClass('ilcalendarappointmentgui', 'app_id', $a_app['event']->getEntryId()); $this->ctrl->setParameterByClass('ilcalendarappointmentgui', 'dt', $a_app['dstart']); $this->tpl->setVariable('PANEL_EDIT_HREF', $this->ctrl->getLinkTargetByClass('ilcalendarappointmentgui', 'askEdit')); $this->tpl->setCurrentBlock('panel_delete_link'); $this->tpl->setVariable('TXT_PANEL_DELETE', $this->lng->txt('delete')); $this->ctrl->clearParametersByClass('ilcalendarappointmentgui'); $this->ctrl->setParameterByClass('ilcalendarappointmentgui', 'seed', $this->getSeed()->get(IL_CAL_DATE)); $this->ctrl->setParameterByClass('ilcalendarappointmentgui', 'app_id', $a_app['event']->getEntryId()); $this->ctrl->setParameterByClass('ilcalendarappointmentgui', 'dt', $a_app['dstart']); $this->tpl->setVariable('PANEL_DELETE_HREF', $this->ctrl->getLinkTargetByClass('ilcalendarappointmentgui', 'askdelete')); $this->tpl->parseCurrentBlock(); } include_once './Services/Calendar/classes/class.ilCalendarCategory.php'; if ($cat_info['type'] == ilCalendarCategory::TYPE_OBJ) { $refs = ilObject::_getAllReferences($entry_obj_id); $type = ilObject::_lookupType($entry_obj_id); $title = ilObject::_lookupTitle($entry_obj_id) ? ilObject::_lookupTitle($entry_obj_id) : $lng->txt('obj_' . $type); include_once './Services/Link/classes/class.ilLink.php'; $href = ilLink::_getStaticLink(current($refs), ilObject::_lookupType($entry_obj_id)); $parent = $tree->getParentId(current($refs)); $parent_title = ilObject::_lookupTitle(ilObject::_lookupObjId($parent)); $this->tpl->setVariable('PANEL_TXT_LINK', $this->lng->txt('ext_link')); $this->tpl->setVariable('PANEL_LINK_HREF', $href); $this->tpl->setVariable('PANEL_LINK_NAME', $title); $this->tpl->setVariable('PANEL_PARENT', $parent_title); } return $this->tpl->get(); }
/** * * @return * @param object $a_obj_id */ public static function _registrationEnabled($a_obj_id) { global $ilDB; $query = "SELECT * FROM grp_settings " . "WHERE obj_id = " . $ilDB->quote($a_obj_id, 'integer') . " "; $res = $ilDB->query($query); $enabled = $unlimited = false; while ($row = $res->fetchRow(DB_FETCHMODE_OBJECT)) { $enabled = $row->registration_enabled; $unlimited = $row->registration_unlimited; $start = $row->registration_start; $end = $row->registration_end; } if (!$enabled) { return false; } if ($unlimited) { return true; } if (!$unlimited) { $start = new ilDateTime($start, IL_CAL_DATETIME, 'UTC'); $end = new ilDateTime($end, IL_CAL_DATETIME, 'UTC'); $time = new ilDateTime(time(), IL_CAL_UNIX); return ilDateTime::_after($time, $start) and ilDateTime::_before($time, $end); } return false; }
/** * Apply limits (count or until) * * @access protected * @param object ilDateList * */ protected function applyLimits(ilDateList $list) { $list->sort(); #echo "list: "; #echo $list; #echo '<br />'; // Check valid dates before starting time foreach ($list->get() as $check_date) { if (ilDateTime::_before($check_date, $this->event->getStart(), IL_CAL_DAY)) { #echo 'Removed: '.$check_date.'<br/>'; $list->remove($check_date); } } #echo 'Until date '.$this->recurrence->getFrequenceUntilDate(); // Check count if given if ($this->recurrence->getFrequenceUntilCount()) { foreach ($list->get() as $res) { // check smaller than since the start time counts as one if (count($this->valid_dates->get()) < $this->recurrence->getFrequenceUntilCount()) { $this->valid_dates->add($res); } else { $this->limit_reached = true; return false; } } return true; } elseif ($this->recurrence->getFrequenceUntilDate()) { #echo 'Until date '.$this->recurrence->getFrequenceUntilDate(); $date = $this->recurrence->getFrequenceUntilDate(); foreach ($list->get() as $res) { #echo 'Check date '.$res; if (ilDateTime::_after($res, $date, IL_CAL_DAY)) { #echo 'Limit reached'; $this->limit_reached = true; return false; } $this->valid_dates->add($res); } return true; } $this->valid_dates->merge($list); return true; }
/** * Get subitems of container * @param bool $a_admin_panel_enabled[optional] * @param bool $a_include_side_block[optional] * @return array */ public function getSubItems($a_admin_panel_enabled = false, $a_include_side_block = false) { global $ilUser; // Caching if (is_array($this->items[(int) $a_admin_panel_enabled][(int) $a_include_side_block])) { return $this->items[(int) $a_admin_panel_enabled][(int) $a_include_side_block]; } // Results are stored in $this->items parent::getSubItems($a_admin_panel_enabled, $a_include_side_block); // No sessions if (!is_array($this->items['sess']) or !$this->items['sess']) { return $this->items[(int) $a_admin_panel_enabled][(int) $a_include_side_block]; } // No session limit if (!$this->isSessionLimitEnabled() or $a_admin_panel_enabled) { return $this->items[(int) $a_admin_panel_enabled][(int) $a_include_side_block]; } if ($a_include_side_block) { return $this->items[(int) $a_admin_panel_enabled][(int) $a_include_side_block]; } // @todo move to gui class if (isset($_GET['crs_prev_sess'])) { $ilUser->writePref('crs_sess_show_prev_' . $this->getId(), (string) (int) $_GET['crs_prev_sess']); } if (isset($_GET['crs_next_sess'])) { $ilUser->writePref('crs_sess_show_next_' . $this->getId(), (string) (int) $_GET['crs_next_sess']); } $sessions = ilUtil::sortArray($this->items['sess'], 'start', 'ASC', true, false); $today = new ilDate(date('Ymd', time()), IL_CAL_DATE); $previous = $current = $next = array(); foreach ($sessions as $key => $item) { $start = new ilDateTime($item['start'], IL_CAL_UNIX); $end = new ilDateTime($item['end'], IL_CAL_UNIX); if (ilDateTime::_within($today, $start, $end, IL_CAL_DAY)) { $current[] = $item; } elseif (ilDateTime::_before($start, $today, IL_CAL_DAY)) { $previous[] = $item; } elseif (ilDateTime::_after($start, $today, IL_CAL_DAY)) { $next[] = $item; } } $num_previous_remove = max(count($previous) - $this->getNumberOfPreviousSessions(), 0); while ($num_previous_remove--) { if (!$ilUser->getPref('crs_sess_show_prev_' . $this->getId())) { array_shift($previous); } $this->items['sess_link']['prev']['value'] = 1; } $num_next_remove = max(count($next) - $this->getNumberOfNextSessions(), 0); while ($num_next_remove--) { if (!$ilUser->getPref('crs_sess_show_next_' . $this->getId())) { array_pop($next); } // @fixme $this->items['sess_link']['next']['value'] = 1; } $sessions = array_merge($previous, $current, $next); $this->items['sess'] = $sessions; $this->items[(int) $a_admin_panel_enabled][(int) $a_include_side_block] = $this->items; return $this->items[(int) $a_admin_panel_enabled][(int) $a_include_side_block]; }
/** * show informations about the registration period * * @access protected */ protected function fillRegistrationPeriod() { include_once './Services/Calendar/classes/class.ilDateTime.php'; $now = new ilDateTime(time(), IL_CAL_UNIX, 'UTC'); if ($this->container->getSubscriptionUnlimitedStatus()) { $reg = new ilNonEditableValueGUI($this->lng->txt('mem_reg_period')); $reg->setValue($this->lng->txt('mem_unlimited')); $this->form->addItem($reg); return true; } elseif ($this->container->getSubscriptionLimitationType() == IL_CRS_SUBSCRIPTION_DEACTIVATED) { return true; } $start = new ilDateTime($this->container->getSubscriptionStart(), IL_CAL_UNIX, 'UTC'); $end = new ilDateTime($this->container->getSubscriptionEnd(), IL_CAL_UNIX, 'UTC'); if (ilDateTime::_before($now, $start)) { $tpl = new ilTemplate('tpl.registration_period_form.html', true, true, 'Services/Membership'); $tpl->setVariable('TXT_FIRST', $this->lng->txt('mem_start')); $tpl->setVariable('FIRST', ilDatePresentation::formatDate($start)); $tpl->setVariable('TXT_END', $this->lng->txt('mem_end')); $tpl->setVariable('END', ilDatePresentation::formatDate($end)); $warning = $this->lng->txt('mem_reg_not_started'); } elseif (ilDateTime::_after($now, $end)) { $tpl = new ilTemplate('tpl.registration_period_form.html', true, true, 'Services/Membership'); $tpl->setVariable('TXT_FIRST', $this->lng->txt('mem_start')); $tpl->setVariable('FIRST', ilDatePresentation::formatDate($start)); $tpl->setVariable('TXT_END', $this->lng->txt('mem_end')); $tpl->setVariable('END', ilDatePresentation::formatDate($end)); $warning = $this->lng->txt('mem_reg_expired'); } else { $tpl = new ilTemplate('tpl.registration_period_form.html', true, true, 'Services/Membership'); $tpl->setVariable('TXT_FIRST', $this->lng->txt('mem_end')); $tpl->setVariable('FIRST', ilDatePresentation::formatDate($end)); } $reg = new ilCustomInputGUI($this->lng->txt('mem_reg_period')); $reg->setHtml($tpl->get()); if (strlen($warning)) { // Disable registration $this->enableRegistration(false); ilUtil::sendFailure($warning); #$reg->setAlert($warning); } $this->form->addItem($reg); return true; }
/** * @see ilMembershipRegistrationCodes::register() * @param int user_id * @param int role * @param bool force registration and do not check registration constraints. */ public function register($a_user_id, $a_role = IL_GRP_MEMBER, $a_force_registration = false) { include_once './Services/Membership/exceptions/class.ilMembershipRegistrationException.php'; include_once "./Modules/Group/classes/class.ilGroupParticipants.php"; $part = ilGroupParticipants::_getInstanceByObjId($this->getId()); if ($part->isAssigned($a_user_id)) { return true; } if (!$a_force_registration) { // Availability if (!$this->isRegistrationEnabled()) { include_once './Modules/Group/classes/class.ilObjGroupAccess.php'; if (!ilObjGroupAccess::_usingRegistrationCode()) { throw new ilMembershipRegistrationException('Cant registrate to group ' . $this->getId() . ', group subscription is deactivated.', '456'); } } // Time Limitation if (!$this->isRegistrationUnlimited()) { $start = $this->getRegistrationStart(); $end = $this->getRegistrationEnd(); $time = new ilDateTime(time(), IL_CAL_UNIX); if (!(ilDateTime::_after($time, $start) and ilDateTime::_before($time, $end))) { throw new ilMembershipRegistrationException('Cant registrate to group ' . $this->getId() . ', group is out of registration time.', '789'); } } // Max members if ($this->isMembershipLimited()) { $free = max(0, $this->getMaxMembers() - $part->getCountMembers()); include_once './Modules/Group/classes/class.ilGroupWaitingList.php'; $waiting_list = new ilGroupWaitingList($this->getId()); if ($this->isWaitingListEnabled() and (!$free or $waiting_list->getCountUsers())) { $this->lng->loadLanguageModule("grp"); $waiting_list->addToList($a_user_id); $info = sprintf($this->lng->txt('grp_added_to_list'), $this->getTitle(), $waiting_list->getPosition($a_user_id)); include_once './Modules/Group/classes/class.ilGroupParticipants.php'; include_once './Modules/Group/classes/class.ilGroupMembershipMailNotification.php'; $participants = ilGroupParticipants::_getInstanceByObjId($this->getId()); $participants->sendNotification(ilGroupMembershipMailNotification::TYPE_WAITING_LIST_MEMBER, $a_user_id); throw new ilMembershipRegistrationException($info, '124'); } if (!$free or $waiting_list->getCountUsers()) { throw new ilMembershipRegistrationException('Cant registrate to group ' . $this->getId() . ', membership is limited.', '123'); } } } $part->add($a_user_id, $a_role); $part->sendNotification($part->TYPE_NOTIFICATION_REGISTRATION, $a_user_id); return true; }
/** * Check if a calendar appointment is bookable for a specific user * @param type $a_cal_entry_id * @param type $a_user_id * @return bool */ public function isAppointmentBookableForUser($a_app_id, $a_user_id) { // #12025 if ($a_user_id == ANONYMOUS_USER_ID) { return false; } // Check max bookings if ($this->getNumberOfBookings() <= $this->getCurrentNumberOfBookings($a_app_id)) { #$GLOBALS['ilLog']->write(__METHOD__.': Number of bookings exceeded'); return false; } // Check deadline $dead_limit = new ilDateTime(time(), IL_CAL_UNIX); $dead_limit->increment(IL_CAL_HOUR, $this->getDeadlineHours()); include_once 'Services/Calendar/classes/class.ilCalendarEntry.php'; $entry = new ilCalendarEntry($a_app_id); if (ilDateTime::_after($dead_limit, $entry->getStart())) { #$GLOBALS['ilLog']->write(__METHOD__.': Deadline reached'); return false; } // Check group restrictions if (!$this->getBookingGroup()) { #$GLOBALS['ilLog']->write(__METHOD__.': No booking group'); return true; } include_once './Services/Calendar/classes/ConsultationHours/class.ilConsultationHourAppointments.php'; $group_apps = ilConsultationHourAppointments::getAppointmentIdsByGroup($this->getObjId(), $this->getBookingGroup()); // Number of bookings in group $bookings = self::lookupBookingsOfUser($group_apps, $a_user_id); include_once './Services/Calendar/classes/ConsultationHours/class.ilConsultationHourGroups.php'; #$GLOBALS['ilLog']->write(__METHOD__.': '.ilConsultationHourGroups::lookupMaxBookings($this->getBookingGroup())); if (count($bookings) >= ilConsultationHourGroups::lookupMaxBookings($this->getBookingGroup())) { #$GLOBALS['ilLog']->write(__METHOD__.': Personal booking limit reached'); return false; } #$GLOBALS['ilLog']->write(__METHOD__.': Is bookable!'); return true; }