/** * Fill row * @staticvar int $counter * @param array $set */ public function fillRow($set) { global $ilCtrl; $ilCtrl->setParameter($this->getParentObject(), 'server_id', $set['server_id']); $ilCtrl->setParameterByClass('ilecsmappingsettingsgui', 'server_id', $set['server_id']); if ($set['active']) { $this->tpl->setVariable('IMAGE_OK', ilUtil::getImagePath('icon_ok.svg')); $this->tpl->setVariable('TXT_OK', $this->lng->txt('ecs_activated')); } else { $this->tpl->setVariable('IMAGE_OK', ilUtil::getImagePath('icon_not_ok.svg')); $this->tpl->setVariable('TXT_OK', $this->lng->txt('ecs_inactivated')); } $this->tpl->setVariable('VAL_TITLE', ilECSSetting::getInstanceByServerId($set['server_id'])->getTitle()); $this->tpl->setVariable('LINK_EDIT', $ilCtrl->getLinkTarget($this->getParentObject(), 'edit')); $this->tpl->setVariable('TXT_SRV_ADDR', $this->lng->txt('ecs_server_addr')); if (ilECSSetting::getInstanceByServerId($set['server_id'])->getServer()) { $this->tpl->setVariable('VAL_DESC', ilECSSetting::getInstanceByServerId($set['server_id'])->getServer()); } else { $this->tpl->setVariable('VAL_DESC', $this->lng->txt('ecs_not_configured')); } $dt = ilECSSetting::getInstanceByServerId($set['server_id'])->fetchCertificateExpiration(); if ($dt != NULL) { $this->tpl->setVariable('TXT_CERT_VALID', $this->lng->txt('ecs_cert_valid_until')); $now = new ilDateTime(time(), IL_CAL_UNIX); $now->increment(IL_CAL_MONTH, 2); if (ilDateTime::_before($dt, $now)) { $this->tpl->setCurrentBlock('invalid'); $this->tpl->setVariable('VAL_ICERT', ilDatePresentation::formatDate($dt)); $this->tpl->parseCurrentBlock(); } else { $this->tpl->setCurrentBlock('valid'); $this->tpl->setVariable('VAL_VCERT', ilDatePresentation::formatDate($dt)); $this->tpl->parseCurrentBlock(); } } // Actions include_once './Services/UIComponent/AdvancedSelectionList/classes/class.ilAdvancedSelectionListGUI.php'; $list = new ilAdvancedSelectionListGUI(); $list->setSelectionHeaderClass('small'); $list->setItemLinkClass('small'); $list->setId('actl_' . $set['server_id']); $list->setListTitle($this->lng->txt('actions')); if (ilECSSetting::getInstanceByServerId($set['server_id'])->isEnabled()) { $list->addItem($this->lng->txt('ecs_deactivate'), '', $ilCtrl->getLinkTarget($this->getParentObject(), 'deactivate')); } else { $list->addItem($this->lng->txt('ecs_activate'), '', $ilCtrl->getLinkTarget($this->getParentObject(), 'activate')); } $list->addItem($this->lng->txt('edit'), '', $ilCtrl->getLinkTarget($this->getParentObject(), 'edit')); $list->addItem($this->lng->txt('copy'), '', $ilCtrl->getLinkTarget($this->getParentObject(), 'cp')); $list->addItem($this->lng->txt('delete'), '', $ilCtrl->getLinkTarget($this->getParentObject(), 'delete')); $this->tpl->setVariable('ACTIONS', $list->getHTML()); $ilCtrl->clearParameters($this->getParentObject()); }
/** * Handle an event in a listener. * * @param string $a_component component, e.g. "Modules/Forum" or "Services/User" * @param string $a_event event e.g. "createUser", "updateUser", "deleteUser", ... * @param array $a_parameter parameter array (assoc), array("name" => ..., "phone_office" => ...) */ static function handleEvent($a_component, $a_event, $a_parameter) { global $ilLog; $ilLog->write(__METHOD__ . ': Listening to event from: ' . $a_component); switch ($a_component) { case 'Services/User': switch ($a_event) { case 'afterCreation': $user = $a_parameter['user_obj']; $this->handleMembership($user); break; } break; case 'Modules/Course': switch ($a_event) { case 'addSubscriber': case 'addParticipant': if (ilObjUser::_lookupAuthMode($a_parameter['usr_id']) == 'ecs') { if (!($user = ilObjectFactory::getInstanceByObjId($a_parameter['usr_id']))) { $GLOBALS['ilLog']->write(__METHOD__ . ': No valid user found for usr_id ' . $a_parameter['usr_id']); return true; } include_once './Services/WebServices/ECS/classes/class.ilECSImport.php'; $server_id = ilECSImport::lookupServerId($a_parameter['usr_id']); $GLOBALS['ilLog']->write(__METHOD__ . ': Found server id: ' . $server_id); include_once 'Services/WebServices/ECS/classes/class.ilECSSetting.php'; $settings = ilECSSetting::getInstanceByServerId($server_id); $end = new ilDateTime(time(), IL_CAL_UNIX); $end->increment(IL_CAL_MONTH, $settings->getDuration()); if ($user->getTimeLimitUntil() < $end->get(IL_CAL_UNIX)) { $user->setTimeLimitUntil($end->get(IL_CAL_UNIX)); $user->update(); } self::_sendNotification($settings, $user); unset($user); } break; } break; } }
/** * * @param array $usr_ids * @param type $type */ public function assignUsersToGroup(array $usr_ids) { global $ilCtrl; $group_id = (int) $_REQUEST['grp_id']; $tomorrow = new ilDateTime(time(), IL_CAL_UNIX); $tomorrow->increment(IL_CAL_DAY, 1); // Get all future consultation hours include_once './Services/Calendar/classes/ConsultationHours/class.ilConsultationHourAppointments.php'; include_once './Services/Booking/classes/class.ilBookingEntry.php'; $apps = ilConsultationHourAppointments::getAppointmentIdsByGroup($this->user_id, $group_id, $tomorrow); $users = $usr_ids; $assigned_users = array(); foreach ($apps as $app) { $booking = ilBookingEntry::getInstanceByCalendarEntryId($app); foreach ($users as $user) { if ($booking->getCurrentNumberOfBookings($app) >= $booking->getNumberOfBookings()) { break; } if (!ilBookingEntry::lookupBookingsOfUser($apps, $user)) { include_once './Services/Calendar/classes/ConsultationHours/class.ilConsultationHourUtils.php'; ilConsultationHourUtils::bookAppointment($user, $app); $assigned_users[] = $user; } } } $this->sendInfoAboutUnassignedUsers(array_diff($users, $assigned_users)); $ilCtrl->redirect($this, 'bookingList'); }
public static function applyAccessLimits(ilObjUser $user, $code) { include_once './Services/Registration/classes/class.ilRegistrationCode.php'; $code_data = ilRegistrationCode::getCodeData($code); if ($code_data["alimit"]) { switch ($code_data["alimit"]) { case "absolute": $end = new ilDateTime($code_data['alimitdt'], IL_CAL_DATE); //$user->setTimeLimitFrom(time()); $user->setTimeLimitUntil($end->get(IL_CAL_UNIX)); $user->setTimeLimitUnlimited(0); break; case "relative": $rel = unserialize($code_data["alimitdt"]); include_once './Services/Calendar/classes/class.ilDateTime.php'; $end = new ilDateTime(time(), IL_CAL_UNIX); if ($rel['y'] > 0) { $end->increment(IL_CAL_YEAR, $rel['y']); } if ($rel['m'] > 0) { $end->increment(IL_CAL_MONTH, $rel['m']); } if ($rel['d'] > 0) { $end->increment(IL_CAL_DAY, $rel['d']); } //$user->setTimeLimitFrom(time()); $user->setTimeLimitUntil($end->get(IL_CAL_UNIX)); $user->setTimeLimitUnlimited(0); break; case 'unlimited': $user->setTimeLimitUnlimited(1); break; } } else { $user->setTimeLimitUnlimited(1); } }
/** * Verify Token * * @return boolean valid t/f */ private function verifyToken() { global $ilDB, $ilUser; if (is_object($ilUser) && is_object($ilDB) && $ilUser->getId() > 0 && $ilUser->getId() != ANONYMOUS_USER_ID) { if ($_GET["rtoken"] == "") { #echo "ilCtrl::No Request Token Given!"; // for debugging, maybe changed later return false; } $set = $ilDB->query("SELECT * FROM il_request_token WHERE " . " user_id = " . $ilDB->quote($ilUser->getId(), "integer") . " AND " . " token = " . $ilDB->quote($_GET[self::IL_RTOKEN_NAME]), "text"); if ($ilDB->numRows($set) > 0) { // remove used token /* $ilDB->query("DELETE FROM il_request_token WHERE ". " user_id = ".$ilDB->quote($ilUser->getId())." AND ". " token = ".$ilDB->quote($_GET[self::IL_RTOKEN_NAME])); */ // remove tokens from older sessions // if we do this immediately, working with multiple windows does not work: // - window one: open form (with token a) // - window two: open form (with token b) // - submit window one: a is verified, but b must not be deleted immediately, otherwise // - window two: submit results in invalid token // see also bug #13551 $dt = new ilDateTime(time(), IL_CAL_UNIX); $dt->increment(IL_CAL_DAY, -1); $dt->increment(IL_CAL_HOUR, -12); $ilDB->manipulate("DELETE FROM il_request_token WHERE " . " user_id = " . $ilDB->quote($ilUser->getId(), "integer") . " AND " . " session_id != " . $ilDB->quote(session_id(), "text") . " AND " . " stamp < " . $ilDB->quote($dt->get(IL_CAL_DATETIME), "timestamp")); return true; } else { return false; } if ($_SESSION["rtokens"][$_GET[self::IL_RTOKEN_NAME]] != "") { // remove used token unset($_SESSION["rtokens"][$_GET[self::IL_RTOKEN_NAME]]); // remove old tokens if (count($_SESSION["rtokens"]) > 100) { $to_remove = array(); $sec = 7200; // two hours foreach ($_SESSION["rtokens"] as $tok => $time) { if (time() - $time > $sec) { $to_remove[] = $tok; } } foreach ($to_remove as $tok) { unset($_SESSION["rtokens"][$tok]); } } return true; } return false; } else { return true; // do not verify, if user or db object is missing } return false; }
/** * Sync external calendars */ protected function synchroniseExternalCalendars() { global $ilUser; if (!ilCalendarSettings::_getInstance()->isWebCalSyncEnabled()) { return false; } // @todo make this thread safe $limit = new ilDateTime(time(), IL_CAL_UNIX); $limit->increment(IL_CAL_HOUR, -1 * ilCalendarSettings::_getInstance()->getWebCalSyncHours()); $cats = ilCalendarCategories::_getInstance($ilUser->getId()); foreach ($cats->getCategoriesInfo() as $cat_id => $info) { if ($info['remote']) { // Check for execution $category = new ilCalendarCategory($cat_id); if (ilDateTime::_before($category->getRemoteSyncLastExecution(), $limit)) { // update in any case to avoid multiple updates of invalid calendar sources. $category->setRemoteSyncLastExecution(new ilDateTime(time(), IL_CAL_UNIX)); $category->update(); include_once './Services/Calendar/classes/class.ilCalendarRemoteReader.php'; $remote = new ilCalendarRemoteReader($category->getRemoteUrl()); $remote->setUser($category->getRemoteUser()); $remote->setPass($category->getRemotePass()); $remote->read(); $remote->import($category); break; } } } }
/** * Returns meeting end date * @return ilDateTime */ public function getEndDate() { $end_date = new ilDateTime($this->start_date->getUnixTime(), IL_CAL_UNIX); $end_date->increment(ilDateTime::HOUR, $this->duration["hours"]); $end_date->increment(ilDateTime::MINUTE, $this->duration["minutes"]); return $end_date; }
/** * start session * @global <type> $ilDB */ public function startSession() { global $ilDB, $ilUser, $ilCtrl, $ilAccess; // Handle deleted accounts ilObjVitero::handleDeletedUsers(); try { // Create update user $map = new ilViteroUserMapping(); $vuid = $map->getVUserId($ilUser->getId()); $ucon = new ilViteroUserSoapConnector(); if (!$vuid) { $vuid = $ucon->createUser($ilUser); $map->map($ilUser->getId(), $vuid); } else { try { $ucon->updateUser($vuid, $ilUser); } catch (ilViteroConnectorException $e) { if ($e->getCode() == 53) { $map->unmap($ilUser->getId()); $vuid = $ucon->createUser($ilUser); $map->map($ilUser->getId(), $vuid); } } } // Store update image if (ilViteroSettings::getInstance()->isAvatarEnabled()) { $usr_image_path = ilUtil::getWebspaceDir() . '/usr_images/usr_' . $ilUser->getId() . '.jpg'; if (@file_exists($usr_image_path)) { $ucon->storeAvatarUsingBase64($vuid, array('name' => 'usr_image.jpg', 'type' => ilViteroAvatarSoapConnector::FILE_TYPE_NORMAL, 'file' => $usr_image_path)); } } /* if(ilViteroSettings::getInstance()->isAvatarEnabled() and 0) { try { $avatar_service = new ilViteroAvatarSoapConnector(); $usr_image_path = ilUtil::getWebspaceDir().'/usr_images/usr_'.$ilUser->getId().'.jpg'; if(@file_exists($usr_image_path)) { $avatar_service->storeAvatar( $vuid, array( 'name' => 'usr_image.jpg', 'type' => ilViteroAvatarSoapConnector::FILE_TYPE_NORMAL, 'file' => $usr_image_path ) ); } } catch(ilViteroConnectorException $e) { // continue } } */ // Assign user to vitero group $grp = new ilViteroGroupSoapConnector(); $grp->addUserToGroup($this->object->getVGroupId(), $vuid); $grp->changeGroupRole($this->object->getVGroupId(), $vuid, $ilAccess->checkAccess('write', '', $this->object->getRefId()) ? ilViteroGroupSoapConnector::ADMIN_ROLE : ilViteroGroupSoapConnector::MEMBER_ROLE); $sc = new ilViteroSessionCodeSoapConnector(); $dur = new ilDateTime(time(), IL_CAL_UNIX); $dur->increment(IL_CAL_HOUR, 2); $code = $sc->createPersonalBookingSessionCode($vuid, (int) $_GET['bid'], $dur); $GLOBALS['ilLog']->write(__METHOD__ . ': ' . ilViteroSettings::getInstance()->getWebstartUrl() . '?code=' . $code); ilUtil::redirect(ilViteroSettings::getInstance()->getWebstartUrl() . '?sessionCode=' . $code); } catch (ilViteroConnectorException $e) { ilUtil::sendFailure($e->getViteroMessage(), true); $ilCtrl->redirect($this, 'infoScreen'); } }
/** * Extend account * @param ilECSSetting $server * @param ilObjUser $user */ protected static function extendAccount(ilECSSetting $settings, ilObjUser $user) { $end = new ilDateTime(time(), IL_CAL_UNIX); $end->increment(IL_CAL_MONTH, $settings->getDuration()); $GLOBALS['ilLog']->write(__METHOD__ . ': account extension ' . (string) $end); if ($user->getTimeLimitUntil() < $end->get(IL_CAL_UNIX)) { $user->setTimeLimitUntil($end->get(IL_CAL_UNIX)); $user->update(); } }
/** * Init filter */ function initFilter() { global $lng, $rbacreview, $ilUser, $ilCtrl; // Show context filter if ($this->getMode() == self::MODE_LOCAL_USER) { include_once './Services/User/classes/class.ilLocalUser.php'; $parent_ids = ilLocalUser::_getFolderIds(); if (count($parent_ids) > 1) { include_once "./Services/Form/classes/class.ilSelectInputGUI.php"; $co = new ilSelectInputGUI($lng->txt('context'), 'time_limit_owner'); $ref_id = $this->getUserFolderId(); $opt[0] = $this->lng->txt('all_users'); $opt[$this->getUserFolderId()] = $lng->txt('users') . ' (' . ilObject::_lookupTitle(ilObject::_lookupObjId($this->getUserFolderId())) . ')'; foreach ($parent_ids as $parent_id) { if ($parent_id == $this->getUserFolderId()) { continue; } switch ($parent_id) { case USER_FOLDER_ID: $opt[USER_FOLDER_ID] = $lng->txt('global_user'); break; default: $opt[$parent_id] = $lng->txt('users') . ' (' . ilObject::_lookupTitle(ilObject::_lookupObjId($parent_id)) . ')'; break; } } $co->setOptions($opt); $this->addFilterItem($co); $co->readFromSession(); $this->filter['time_limit_owner'] = $co->getValue(); } } // User name, login, email filter include_once "./Services/Form/classes/class.ilTextInputGUI.php"; $ul = new ilTextInputGUI($lng->txt("login") . "/" . $lng->txt("email") . "/" . $lng->txt("name"), "query"); $ul->setDataSource($ilCtrl->getLinkTarget($this->getParentObject(), "addUserAutoComplete", "", true)); $ul->setSize(20); $ul->setSubmitFormOnEnter(true); $this->addFilterItem($ul); $ul->readFromSession(); $this->filter["query"] = $ul->getValue(); /* include_once("./Services/Form/classes/class.ilTextInputGUI.php"); $ti = new ilTextInputGUI($lng->txt("login")."/".$lng->txt("email")."/".$lng->txt("name"), "query"); $ti->setMaxLength(64); $ti->setSize(20); $ti->setSubmitFormOnEnter(true); $this->addFilterItem($ti); $ti->readFromSession(); $this->filter["query"] = $ti->getValue(); */ // activation include_once "./Services/Form/classes/class.ilSelectInputGUI.php"; $options = array("" => $lng->txt("user_all"), "active" => $lng->txt("active"), "inactive" => $lng->txt("inactive")); $si = new ilSelectInputGUI($this->lng->txt("user_activation"), "activation"); $si->setOptions($options); $this->addFilterItem($si); $si->readFromSession(); $this->filter["activation"] = $si->getValue(); // limited access include_once "./Services/Form/classes/class.ilCheckboxInputGUI.php"; $cb = new ilCheckboxInputGUI($this->lng->txt("user_limited_access"), "limited_access"); $this->addFilterItem($cb); $cb->readFromSession(); $this->filter["limited_access"] = $cb->getChecked(); // last login include_once "./Services/Form/classes/class.ilDateTimeInputGUI.php"; $di = new ilDateTimeInputGUI($this->lng->txt("user_last_login_before"), "last_login"); $default_date = new ilDateTime(time(), IL_CAL_UNIX); $default_date->increment(IL_CAL_DAY, 1); $di->setDate($default_date); $this->addFilterItem($di); $di->readFromSession(); $this->filter["last_login"] = $di->getDate(); if ($this->getMode() == self::MODE_USER_FOLDER) { // no assigned courses include_once "./Services/Form/classes/class.ilCheckboxInputGUI.php"; $cb = new ilCheckboxInputGUI($this->lng->txt("user_no_courses"), "no_courses"); $this->addFilterItem($cb); $cb->readFromSession(); $this->filter["no_courses"] = $cb->getChecked(); // no assigned groups include_once "./Services/Form/classes/class.ilCheckboxInputGUI.php"; $ng = new ilCheckboxInputGUI($this->lng->txt("user_no_groups"), "no_groups"); $this->addFilterItem($ng); $ng->readFromSession(); $this->filter['no_groups'] = $ng->getChecked(); // course/group members include_once "./Services/Form/classes/class.ilRepositorySelectorInputGUI.php"; $rs = new ilRepositorySelectorInputGUI($lng->txt("user_member_of_course_group"), "course_group"); $rs->setSelectText($lng->txt("user_select_course_group")); $rs->setHeaderMessage($lng->txt("user_please_select_course_group")); $rs->setClickableTypes(array("crs", "grp")); $this->addFilterItem($rs); $rs->readFromSession(); $this->filter["course_group"] = $rs->getValue(); } // global roles $options = array("" => $lng->txt("user_any")); $roles = $rbacreview->getRolesByFilter(2, $ilUser->getId()); foreach ($roles as $role) { $options[$role["rol_id"]] = $role["title"]; } $si = new ilSelectInputGUI($this->lng->txt("user_global_role"), "global_role"); $si->setOptions($options); $this->addFilterItem($si); $si->readFromSession(); $this->filter["global_role"] = $si->getValue(); }
protected function listAppointments() { global $ilTabs, $tpl; $ilTabs->activateTab('appointments'); $table = new ilViteroBookingTableGUI($this, 'listAppointments'); $table->setAdminTable(true); $table->setEditable(false); $table->init(); $start = new ilDateTime(time(), IL_CAL_UNIX); $start->increment(ilDateTime::HOUR, -1); $end = clone $start; $end->increment(IL_CAL_YEAR, 2); try { $table->parseAdminTable($start, $end); } catch (ilViteroConnectorException $e) { ilUtil::sendFailure($e->getViteroMessage(), true); return false; } $tpl->setContent($table->getHTML()); }
/** * Get request token. * * @return string request token for user and session */ public function getRequestToken() { global $ilDB, $ilUser; if ($this->rtoken != "") { return $this->rtoken; } else { if (is_object($ilDB) && is_object($ilUser) && $ilUser->getId() > 0 && $ilUser->getId() != ANONYMOUS_USER_ID) { $res = $ilDB->query("SELECT token FROM il_request_token WHERE user_id = " . $ilDB->quote($ilUser->getId(), "integer") . " AND session_id = " . $ilDB->quote(session_id(), "text")); $rec = $ilDB->fetchAssoc($res); if ($rec["token"] != "") { $this->rtoken = $rec["token"]; return $rec["token"]; } $this->rtoken = md5(uniqid(rand(), true)); // delete entries older than one and a half days if (rand(1, 200) == 2) { $dt = new ilDateTime(time(), IL_CAL_UNIX); $dt->increment(IL_CAL_DAY, -1); $dt->increment(IL_CAL_HOUR, -12); $dq = "DELETE FROM il_request_token WHERE " . " stamp < " . $ilDB->quote($dt->get(IL_CAL_DATETIME), "timestamp"); $ilDB->manipulate($dq); } // IMPORTANT: Please do NOT try to move this implementation to a // session basis. This will fail due to framesets that are used // occasionally in ILIAS, e.g. in the chat, where multiple // forms are loaded in different frames. $ilDB->manipulate("INSERT INTO il_request_token (user_id, token, stamp, session_id) VALUES " . "(" . $ilDB->quote($ilUser->getId(), "integer") . "," . $ilDB->quote($this->rtoken, "text") . "," . $ilDB->now() . "," . $ilDB->quote(session_id(), "text") . ")"); return $this->rtoken; } //$this->rtoken = md5(uniqid(rand(), true)); } return ""; }
/** * Create calendar appointments * @param ilBookingEntry $booking * @return */ protected function createAppointments(ilBookingEntry $booking) { include_once './Services/Calendar/classes/class.ilDateList.php'; $concurrent_dates = new ilDateList(ilDateList::TYPE_DATETIME); $start = clone $this->form->getItemByPostVar('st')->getDate(); for ($i = 0; $i < $this->form->getItemByPostVar('ap')->getValue(); $i++) { $concurrent_dates->add($start); $start = new ilDateTime($start->increment(ilDateTime::MINUTE, $this->form->getItemByPostVar('du')->getMinutes()), IL_CAL_UNIX); } include_once './Services/Calendar/classes/class.ilCalendarUtil.php'; $def_cat = ilCalendarUtil::initDefaultCalendarByType(ilCalendarCategory::TYPE_CH, $this->getUserId(), $this->lng->txt('cal_ch_personal_ch'), true); // Add calendar appointment for each include_once './Services/Calendar/classes/class.ilCalendarCategoryAssignments.php'; include_once './Services/Calendar/classes/class.ilCalendarEntry.php'; include_once './Services/Calendar/classes/class.ilCalendarRecurrenceCalculator.php'; include_once './Services/Booking/classes/class.ilBookingPeriod.php'; foreach ($concurrent_dates as $dt) { $end = clone $dt; $end->increment(ilDateTime::MINUTE, $this->form->getItemByPostVar('du')->getMinutes()); $calc = new ilCalendarRecurrenceCalculator(new ilBookingPeriod($dt, $end), $this->form->getItemByPostVar('frequence')->getRecurrence()); // Calculate with one year limit $limit = clone $dt; $limit->increment(ilDAteTime::YEAR, 1); $date_list = $calc->calculateDateList($dt, $limit); foreach ($date_list as $app_start) { $app_end = clone $app_start; $app_end->increment(ilDateTime::MINUTE, $this->form->getItemByPostVar('du')->getMinutes()); $entry = new ilCalendarEntry(); $entry->setContextId($booking->getId()); $entry->setTitle($this->form->getInput('ti')); $entry->setDescription($this->form->getInput('de')); $entry->setLocation($this->form->getInput('lo')); $entry->setStart($app_start); $entry->setEnd($app_end); $entry->setTranslationType(IL_CAL_TRANSLATION_SYSTEM); $entry->save(); $cat_assign = new ilCalendarCategoryAssignments($entry->getEntryId()); $cat_assign->addAssignment($def_cat->getCategoryID()); } } }
/** * get byday * * @access public * @param ilDate start * */ public function getByDay(ilDate $a_start, $a_timezone) { $start = new ilDateTime($a_start->get(IL_CAL_DATETIME), IL_CAL_DATETIME, $this->timezone); $fstart = new ilDate($a_start->get(IL_CAL_UNIX), IL_CAL_UNIX); $fend = clone $fstart; $f_unix_start = $fstart->get(IL_CAL_UNIX); $fend->increment(ilDateTime::DAY, 1); $f_unix_end = $fend->get(IL_CAL_UNIX); $unix_start = $start->get(IL_CAL_UNIX); $start->increment(ilDateTime::DAY, 1); $unix_end = $start->get(IL_CAL_UNIX); $counter = 0; $tmp_date = new ilDateTime($unix_start, IL_CAL_UNIX, $this->timezone); $tmp_schedule = array(); foreach ($this->schedule as $schedule) { if ($schedule['fullday']) { if ($f_unix_start == $schedule['dstart'] or $f_unix_start == $schedule['dend'] or $f_unix_start > $schedule['dstart'] and $f_unix_end <= $schedule['dend']) { $tmp_schedule[] = $schedule; } } elseif ($schedule['dstart'] == $unix_start or $schedule['dstart'] <= $unix_start and $schedule['dend'] > $unix_start or $schedule['dstart'] >= $unix_start and $schedule['dstart'] < $unix_end) { $tmp_schedule[] = $schedule; } } return $tmp_schedule; }
/** * 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; }