/** * update * * @access protected * @return */ protected function update() { if (!$_GET['category_id']) { ilUtil::sendFailure($this->lng->txt('select_one'), true); $this->ctrl->returnToParent($this); } $this->readPermissions(); if (!$this->isEditable()) { ilUtil::sendFailure($this->lng->txt('permission_denied')); $this->edit(); return false; } include_once './Services/Calendar/classes/class.ilCalendarCategory.php'; $category = new ilCalendarCategory((int) $_GET['category_id']); $category->setTitle(ilUtil::stripSlashes($_POST['title'])); $category->setColor('#' . ilUtil::stripSlashes($_POST['color'])); $category->update(); ilUtil::sendSuccess($this->lng->txt('settings_saved'), true); // $this->ctrl->returnToParent($this); $this->manage(); }
/** * 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; } } } }