/**
  * Init
  */
 function init()
 {
     global $ilSetting, $rbacsystem;
     $prfa_set = new ilSetting("prfa");
     $this->setPreventHTMLUnmasking(!(bool) $prfa_set->get("mask", false));
     $this->setEnableInternalLinks(false);
     $this->setEnablePCType("Profile", true);
     if (!$ilSetting->get('disable_wsp_certificates')) {
         $this->setEnablePCType("Verification", true);
     }
     $skmg_set = new ilSetting("skmg");
     if ($skmg_set->get("enable_skmg")) {
         $this->setEnablePCType("Skills", true);
     }
     include_once './Services/Calendar/classes/class.ilCalendarUserSettings.php';
     $settings = ilCalendarSettings::_getInstance();
     if ($settings->isEnabled() && $rbacsystem->checkAccess('add_consultation_hours', $settings->getCalendarSettingsId()) && $settings->areConsultationHoursEnabled()) {
         $this->setEnablePCType("ConsultationHours", true);
     }
     $prfa_set = new ilSetting("prfa");
     if ($prfa_set->get("mycrs", true)) {
         $this->setEnablePCType("MyCourses", true);
     }
     // patch optes begin (no trunk)
     $mset = new ilSetting("mobs");
     if ($mset->get("mep_activate_pages")) {
         $this->setEnablePCType("ContentInclude", true);
     }
     // patch optes end (no trunk)
 }
 /**
  * Singleton
  *
  * @access public
  * @param
  * @return
  */
 protected function __construct(ilDate $seed = null)
 {
     global $lng, $ilCtrl;
     $this->lng = $lng;
     $this->ctrl = $ilCtrl;
     $this->settings = ilCalendarSettings::_getInstance();
     $this->seed = $seed;
 }
 /**
  * Constructor
  *
  * @access private
  * @param
  * @return
  */
 private function __construct($a_user_id)
 {
     global $ilUser;
     if ($ilUser->getId() == $a_user_id) {
         $this->user = $ilUser;
     } else {
         $this->user = ilObjectFactory::getInstanceByObjId($a_user_id, false);
     }
     $this->settings = ilCalendarSettings::_getInstance();
     $this->read();
 }
 /**
  * Store an entry without an expired time
  * @param object $a_entry_id
  * @param object $a_value
  * @return 
  */
 public function storeUnlimitedEntry($a_entry_id, $a_value, $a_key1 = 0, $a_key2 = 0, $a_key3 = '', $a_key4 = '')
 {
     if (!ilCalendarSettings::_getInstance()->isCacheUsed()) {
         return null;
     }
     // Unlimited is a year
     $this->setExpiresAfter(60 * 60 * 24 * 365);
     parent::storeEntry($a_entry_id, $a_value, $a_key1, $a_key2, $a_key3, $a_key4);
     $this->setExpiresAfter(ilCalendarSettings::_getInstance()->getCacheMinutes());
     return true;
 }
 /**
  * Constructor
  *
  * @access public
  * @param
  * 
  */
 public function __construct()
 {
     global $ilUser, $tpl, $lng, $ilCtrl;
     $this->tpl = $tpl;
     $this->lng = $lng;
     $this->lng->loadLanguageModule('dateplaner');
     $this->lng->loadLanguageModule('jscalendar');
     $this->ctrl = $ilCtrl;
     $this->user = $ilUser;
     $this->settings = ilCalendarSettings::_getInstance();
     $this->user_settings = ilCalendarUserSettings::_getInstanceByUserId($this->user->getId());
 }
 /**
  * GetDropDownHTML
  *
  * @param
  * @return
  */
 function renderDropDown($a_tpl, $a_id)
 {
     global $lng, $ilSetting, $rbacsystem;
     $id = strtolower($a_id);
     $id_up = strtoupper($a_id);
     $a_tpl->setCurrentBlock("entry_" . $id);
     include_once "./Services/UIComponent/AdvancedSelectionList/classes/class.ilAdvancedSelectionListGUI.php";
     $selection = new ilAdvancedSelectionListGUI();
     if ($this->active == $a_id || $this->active == "" && $a_id == "repository") {
         $selection->setSelectionHeaderClass("MMActive");
         $a_tpl->setVariable("SEL", '<span class="ilAccHidden">(' . $lng->txt("stat_selected") . ')</span>');
     } else {
         $selection->setSelectionHeaderClass("MMInactive");
     }
     $selection->setSelectionHeaderSpanClass("MMSpan");
     $selection->setHeaderIcon(ilAdvancedSelectionListGUI::ICON_ARROW);
     $selection->setItemLinkClass("small");
     $selection->setUseImages(false);
     switch ($id) {
         // desktop drop down
         case "desktop":
             $selection->setListTitle($lng->txt("personal_desktop"));
             $selection->setId("dd_pd");
             // overview
             $selection->addItem($lng->txt("overview"), "", "ilias.php?baseClass=ilPersonalDesktopGUI", "", "", "_top");
             if (!$ilSetting->get("disable_personal_workspace")) {
                 // workspace
                 $selection->addItem($lng->txt("personal_workspace"), "", "ilias.php?baseClass=ilPersonalDesktopGUI&amp;cmd=jumpToWorkspace", "", "", "_top");
             }
             // profile
             $selection->addItem($lng->txt("personal_profile"), "", "ilias.php?baseClass=ilPersonalDesktopGUI&amp;cmd=jumpToProfile", "", "", "_top");
             // skills
             $skmg_set = new ilSetting("skmg");
             if ($skmg_set->get("enable_skmg")) {
                 $selection->addItem($lng->txt("skills"), "", "ilias.php?baseClass=ilPersonalDesktopGUI&amp;cmd=jumpToSkills", "", "", "_top");
             }
             // portfolio
             if ($ilSetting->get('user_portfolios')) {
                 $selection->addItem($lng->txt("portfolio"), "", "ilias.php?baseClass=ilPersonalDesktopGUI&amp;cmd=jumpToPortfolio", "", "", "_top");
             }
             // news
             if ($ilSetting->get("block_activated_news")) {
                 $selection->addItem($lng->txt("news"), "", "ilias.php?baseClass=ilPersonalDesktopGUI&amp;cmd=jumpToNews", "", "", "_top");
             }
             // Learning Progress
             include_once "Services/Tracking/classes/class.ilObjUserTracking.php";
             if (ilObjUserTracking::_enabledLearningProgress()) {
                 //$ilTabs->addTarget("learning_progress", $this->ctrl->getLinkTargetByClass("ilLearningProgressGUI"));
                 $selection->addItem($lng->txt("learning_progress"), "", "ilias.php?baseClass=ilPersonalDesktopGUI&amp;cmd=jumpToLP", "", "", "_top");
             }
             // calendar
             include_once './Services/Calendar/classes/class.ilCalendarSettings.php';
             $settings = ilCalendarSettings::_getInstance();
             if ($settings->isEnabled()) {
                 $selection->addItem($lng->txt("calendar"), "", "ilias.php?baseClass=ilPersonalDesktopGUI&amp;cmd=jumpToCalendar", "", "", "_top");
             }
             // mail
             if ($this->mail) {
                 $selection->addItem($lng->txt('mail'), '', 'ilias.php?baseClass=ilMailGUI', '', '', '_top');
             }
             // contacts
             if (!$this->ilias->getSetting('disable_contacts') && ($this->ilias->getSetting('disable_contacts_require_mail') || $rbacsystem->checkAccess('internal_mail', ilMailGlobalServices::getMailObjectRefId()))) {
                 $selection->addItem($lng->txt('mail_addressbook'), '', 'ilias.php?baseClass=ilPersonalDesktopGUI&amp;cmd=jumpToContacts', '', '', '_top');
             }
             // private notes
             if (!$this->ilias->getSetting("disable_notes")) {
                 $selection->addItem($lng->txt("notes_and_comments"), "", "ilias.php?baseClass=ilPersonalDesktopGUI&amp;cmd=jumpToNotes", "", "", "_top");
             }
             // bookmarks
             if (!$this->ilias->getSetting("disable_bookmarks")) {
                 $selection->addItem($lng->txt("bookmarks"), "", "ilias.php?baseClass=ilPersonalDesktopGUI&amp;cmd=jumpToBookmarks", "", "", "_top");
             }
             // settings
             $selection->addItem($lng->txt("personal_settings"), "", "ilias.php?baseClass=ilPersonalDesktopGUI&amp;cmd=jumpToSettings", "", "", "_top");
             break;
             // shop
         // shop
         case 'shop':
             $selection->setListTitle($lng->txt("shop"));
             $selection->setId("dd_shp");
             $selection->addItem($lng->txt("shop"), "", "ilias.php?baseClass=ilShopController&cmd=firstpage", "", "", "_top");
             break;
             // administration
         // administration
         case "administration":
             $selection->setListTitle($lng->txt("administration"));
             $selection->setId("dd_adm");
             $selection->setAsynch(true);
             $selection->setAsynchUrl("ilias.php?baseClass=ilAdministrationGUI&cmd=getDropDown&cmdMode=asynch");
             //$this->renderEntry($a_tpl, "administration",
             //	$lng->txt("administration"),
             //	$this->getScriptTarget("ilias.php?baseClass=ilAdministrationGUI"),
             //	$this->target);
             break;
     }
     //		$selection->setTriggerEvent("mouseover");
     //		$selection->setAutoHide(true);
     // bs-patch start
     global $ilUser;
     $a_tpl->setVariable("TXT_ADMINISTRATION", $lng->txt("administration"));
     $a_tpl->parseCurrentBlock();
     return;
     // bs-patch end
     $html = $selection->getHTML();
     $a_tpl->setVariable($id_up . "_DROP_DOWN", $html);
     $a_tpl->parseCurrentBlock();
 }
 /**
  * read selected categories
  *
  * @access protected
  * @return
  */
 protected function readSelectedCategories($a_obj_ids)
 {
     global $ilAccess, $tree;
     global $ilDB;
     if (!count($a_obj_ids)) {
         return true;
     }
     $query = "SELECT * FROM cal_categories " . "WHERE type = " . $this->db->quote(ilCalendarCategory::TYPE_OBJ, 'integer') . " " . "AND " . $ilDB->in('obj_id', $a_obj_ids, false, 'integer') . " " . "ORDER BY title ";
     $res = $this->db->query($query);
     while ($row = $res->fetchRow(DB_FETCHMODE_OBJECT)) {
         // check activation/deactivation
         $obj_type = ilObject::_lookupType($row->obj_id);
         if ($obj_type == 'crs' or $obj_type == 'grp') {
             if (!ilCalendarSettings::_getInstance()->lookupCalendarActivated($row->obj_id)) {
                 continue;
             }
         }
         $editable = false;
         $exists = false;
         foreach (ilObject::_getAllReferences($row->obj_id) as $ref_id) {
             if ($ilAccess->checkAccess('edit_event', '', $ref_id)) {
                 $exists = true;
                 $editable = true;
                 break;
             } elseif ($ilAccess->checkAccess('read', '', $ref_id)) {
                 $exists = true;
             }
         }
         if (!$exists) {
             continue;
         }
         $this->categories_info[$row->cat_id]['editable'] = $editable;
         $this->categories[] = $row->cat_id;
         $this->categories_info[$row->cat_id]['obj_id'] = $row->obj_id;
         $this->categories_info[$row->cat_id]['cat_id'] = $row->cat_id;
         $this->categories_info[$row->cat_id]['color'] = $row->color;
         #$this->categories_info[$row->cat_id]['title'] = ilObject::_lookupTitle($row->obj_id);
         $this->categories_info[$row->cat_id]['title'] = $row->title;
         $this->categories_info[$row->cat_id]['obj_type'] = ilObject::_lookupType($row->obj_id);
         $this->categories_info[$row->cat_id]['type'] = $row->type;
         $this->categories_info[$row->cat_id]['remote'] = false;
     }
 }
 /**
  * Check whether a block type is globally activated
  */
 protected function isGloballyActivated($a_type)
 {
     global $ilSetting;
     if (isset($this->check_global_activation[$a_type]) && $this->check_global_activation[$a_type]) {
         if ($a_type == 'pdbookm') {
             if (!$ilSetting->get("disable_bookmarks")) {
                 return true;
             }
             return false;
         } else {
             if ($a_type == 'pdnotes') {
                 if (!$ilSetting->get("disable_notes")) {
                     return true;
                 }
                 return false;
             } elseif ($a_type == 'news') {
                 include_once 'Services/Container/classes/class.ilContainer.php';
                 return $ilSetting->get('block_activated_news') && ilContainer::_lookupContainerSetting($GLOBALS['ilCtrl']->getContextObjId(), 'cont_show_news', true);
             } else {
                 if ($ilSetting->get("block_activated_" . $a_type)) {
                     return true;
                 } elseif ($a_type == 'cal') {
                     include_once './Services/Calendar/classes/class.ilCalendarSettings.php';
                     return ilCalendarSettings::lookupCalendarActivated($GLOBALS['ilCtrl']->getContextObjId());
                 } elseif ($a_type == 'pdcal') {
                     include_once './Services/Calendar/classes/class.ilCalendarSettings.php';
                     return ilCalendarSettings::_getInstance()->isEnabled();
                 }
             }
         }
         return false;
     }
     return true;
 }
 /**
  * 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;
             }
         }
     }
 }
 /**
  * Save personal desktop settings
  */
 public function saveSettings()
 {
     global $ilCtrl, $ilSetting;
     $pd_set = new ilSetting("pd");
     ilCalendarSettings::_getInstance()->setEnabled($_POST["enable_calendar"]);
     ilCalendarSettings::_getInstance()->save();
     #$ilSetting->set("enable_calendar", $_POST["enable_calendar"]);
     $ilSetting->set("disable_bookmarks", (int) ($_POST["enable_bookmarks"] ? 0 : 1));
     $ilSetting->set("disable_contacts", (int) ($_POST["enable_contacts"] ? 0 : 1));
     $ilSetting->set("disable_contacts_require_mail", (int) ($_POST["enable_contacts_require_mail"] ? 0 : 1));
     $ilSetting->set("disable_notes", (int) ($_POST["enable_notes"] ? 0 : 1));
     $ilSetting->set("disable_comments", (int) ($_POST["enable_comments"] ? 0 : 1));
     $ilSetting->set("comments_del_user", (int) ($_POST["comm_del_user"] ? 1 : 0));
     $ilSetting->set("comments_del_tutor", (int) ($_POST["comm_del_tutor"] ? 1 : 0));
     $ilSetting->set("block_activated_chatviewer", (int) $_POST["block_activated_chatviewer"]);
     $ilSetting->set("block_activated_pdusers", $_POST["block_activated_pdusers"]);
     $pd_set->set("enable_block_moving", $_POST["enable_block_moving"]);
     $pd_set->set("user_activity_time", (int) $_POST["time_removal"]);
     $pd_set->set("osi_host", $_POST["osi_host"]);
     // Validate personal desktop view
     if (!(int) $_POST['enable_my_offers'] && !(int) $_POST['enable_my_memberships']) {
         ilUtil::sendFailure($this->lng->txt('pd_view_select_at_least_one'), true);
         $ilCtrl->redirect($this, 'view');
     }
     // Enable 'My Offers' (default personal items)
     $ilSetting->set('disable_my_offers', (int) ($_POST['enable_my_offers'] ? 0 : 1));
     // Enable 'My Memberships'
     $ilSetting->set('disable_my_memberships', (int) ($_POST['enable_my_memberships'] ? 0 : 1));
     if ((int) $_POST['enable_my_offers'] && !(int) $_POST['enable_my_memberships']) {
         $_POST['personal_items_default_view'] = 0;
     } else {
         if (!(int) $_POST['enable_my_offers'] && (int) $_POST['enable_my_memberships']) {
             $_POST['personal_items_default_view'] = 1;
         } else {
             if (!isset($_POST['personal_items_default_view'])) {
                 $_POST['personal_items_default_view'] = $ilSetting->get('personal_items_default_view');
             }
         }
     }
     // Default view of personal items
     $ilSetting->set('personal_items_default_view', (int) $_POST['personal_items_default_view']);
     ilUtil::sendSuccess($this->lng->txt("settings_saved"), true);
     $ilCtrl->redirect($this, "view");
 }
 /**
  * Get all valid starting points
  * 
  * @return array
  */
 public static function getPossibleStartingPoints()
 {
     global $ilSetting, $rbacsystem, $lng;
     // for all conditions: see ilMainMenuGUI
     $all = array();
     $all[self::START_PD_OVERVIEW] = 'overview';
     if ($ilSetting->get('disable_my_offers') == 0 && $ilSetting->get('disable_my_memberships') == 0) {
         $all[self::START_PD_SUBSCRIPTION] = 'my_courses_groups';
     }
     /*
     if (!$ilSetting->get("disable_bookmarks"))
     {
     	$all[self::START_PD_BOOKMARKS] = 'bookmarks';
     }
     
     if (!$ilSetting->get("disable_notes"))
     {
     	$all[self::START_PD_NOTES] = 'notes_and_comments';
     }
     
     if ($ilSetting->get("block_activated_news"))
     {
     	$all[self::START_PD_NEWS] = 'news';
     }
     */
     if (!$ilSetting->get("disable_personal_workspace")) {
         $all[self::START_PD_WORKSPACE] = 'personal_workspace';
     }
     /*
     if ($ilSetting->get('user_portfolios'))
     {
     	$all[self::START_PD_PORTFOLIO] = 'portfolio';					
     }
     
     $skmg_set = new ilSetting("skmg");
     if ($skmg_set->get("enable_skmg"))
     {
     	$all[self::START_PD_SKILLS] = 'skills';					
     }
     
     include_once("Services/Tracking/classes/class.ilObjUserTracking.php");
     if (ilObjUserTracking::_enabledLearningProgress() && 
     	ilObjUserTracking::_hasLearningProgressDesktop())
     {
     	$all[self::START_PD_LP] = 'learning_progress';					
     }
     */
     include_once './Services/Calendar/classes/class.ilCalendarSettings.php';
     $settings = ilCalendarSettings::_getInstance();
     if ($settings->isEnabled()) {
         $all[self::START_PD_CALENDAR] = 'calendar';
     }
     /*
     if($rbacsystem->checkAccess('internal_mail', ilMailGlobalServices::getMailObjectRefId()))
     {	
     	$all[self::START_PD_MAIL] = 'mail';	
     }
     			
     if(!$ilSetting->get('disable_contacts') &&
     	($ilSetting->get('disable_contacts_require_mail') ||
     	$rbacsystem->checkAccess('internal_mail', ilMailGlobalServices::getMailObjectRefId())))
     {
     	$all[self::START_PD_CONTACTS] = 'mail_addressbook';					
     }
     
     $all[self::START_PD_PROFILE] = 'personal_profile';		
     $all[self::START_PD_SETTINGS] = 'personal_settings';			 
     */
     $all[self::START_REPOSITORY] = 'repository';
     foreach ($all as $idx => $lang) {
         $all[$idx] = $lng->txt($lang);
     }
     return $all;
 }
 /**
  * update
  *
  * @access protected
  * @return
  */
 protected function update()
 {
     global $ilErr;
     $single_editing = $_REQUEST['rexl'] ? true : false;
     $this->load($this->app->isMilestone());
     if ($this->app->validate() and $this->notification->validate()) {
         if (!(int) $_POST['calendar']) {
             $cat_id = $this->createDefaultCalendar();
         } else {
             $cat_id = (int) $_POST['calendar'];
         }
         if ($single_editing) {
             $this->getAppointment()->save();
             $this->deleteExclude(false);
             $this->rec = new ilCalendarRecurrence();
             $this->rec->setEntryId($this->getAppointment()->getEntryId());
         } else {
             $this->getAppointment()->update();
         }
         $this->notification->save();
         $this->saveRecurrenceSettings();
         include_once './Services/Calendar/classes/class.ilCalendarCategoryAssignments.php';
         $ass = new ilCalendarCategoryAssignments($this->app->getEntryId());
         $GLOBALS['ilLog']->write($this->app->getEntryId());
         $ass->deleteAssignments();
         $ass->addAssignment($cat_id);
         // Send notifications
         include_once './Services/Calendar/classes/class.ilCalendarSettings.php';
         if (ilCalendarSettings::_getInstance()->isNotificationEnabled() and (bool) $_POST['not']) {
             $this->distributeNotifications($cat_id, $this->app->getEntryId(), false);
         }
         if (ilCalendarSettings::_getInstance()->isUserNotificationEnabled()) {
             $this->distributeUserNotifications();
         }
         ilUtil::sendSuccess($this->lng->txt('settings_saved'), true);
         $this->ctrl->returnToParent($this);
     } else {
         ilUtil::sendFailure($ilErr->getMessage());
     }
     $this->edit();
 }
 /**
  * Update settings
  */
 protected function updateToolSettings()
 {
     $form = $this->initSettingsForm();
     if ($form->checkInput()) {
         include_once './Services/Calendar/classes/class.ilCalendarSettings.php';
         if (ilCalendarSettings::_getInstance()->isEnabled()) {
             if ($this->isModeActive(self::CALENDAR_VISIBILITY)) {
                 ilContainer::_writeContainerSetting($this->getObjId(), 'show_calendar', (int) $form->getInput('calendar'));
             }
         }
         ilUtil::sendSuccess($GLOBALS['lng']->txt('settings_saved'), true);
         $GLOBALS['ilCtrl']->redirect($this);
     }
     ilUtil::sendFailure($GLOBALS['lng']->txt('err_check_input'));
     $form->setValuesByPost();
     $this->editSettings($form);
 }
Example #14
0
 /**
  * Get all valid starting points
  * 
  * @return array
  */
 public static function getPossibleStartingPoints($a_force_all = false)
 {
     global $ilSetting, $lng;
     // for all conditions: see ilMainMenuGUI
     $all = array();
     $all[self::START_PD_OVERVIEW] = 'overview';
     if ($a_force_all || $ilSetting->get('disable_my_offers') == 0 && $ilSetting->get('disable_my_memberships') == 0) {
         $all[self::START_PD_SUBSCRIPTION] = 'my_courses_groups';
     }
     if ($a_force_all || !$ilSetting->get("disable_personal_workspace")) {
         $all[self::START_PD_WORKSPACE] = 'personal_workspace';
     }
     include_once './Services/Calendar/classes/class.ilCalendarSettings.php';
     $settings = ilCalendarSettings::_getInstance();
     if ($a_force_all || $settings->isEnabled()) {
         $all[self::START_PD_CALENDAR] = 'calendar';
     }
     $all[self::START_REPOSITORY] = 'repository';
     foreach ($all as $idx => $lang) {
         $all[$idx] = $lng->txt($lang);
     }
     return $all;
 }
 /**
  * fill data section
  *
  * @access public
  * 
  */
 public function show()
 {
     global $ilUser, $lng;
     // config
     $raster = 15;
     if ($this->user_settings->getDayStart()) {
         // push starting point to last "slot" of hour BEFORE morning aggregation
         $morning_aggr = ($this->user_settings->getDayStart() - 1) * 60 + (60 - $raster);
     } else {
         $morning_aggr = 0;
     }
     $evening_aggr = $this->user_settings->getDayEnd() * 60;
     $this->tpl = new ilTemplate('tpl.week_view.html', true, true, 'Services/Calendar');
     include_once './Services/YUI/classes/class.ilYuiUtil.php';
     ilYuiUtil::initDragDrop();
     ilYuiUtil::initPanel();
     $navigation = new ilCalendarHeaderNavigationGUI($this, $this->seed, ilDateTime::WEEK);
     $this->tpl->setVariable('NAVIGATION', $navigation->getHTML());
     if (isset($_GET["bkid"])) {
         $user_id = $_GET["bkid"];
         $disable_empty = true;
         $no_add = true;
     } elseif ($ilUser->getId() == ANONYMOUS_USER_ID) {
         $user_id = $ilUser->getId();
         $disable_empty = false;
         $no_add = true;
     } else {
         $user_id = $ilUser->getId();
         $disable_empty = false;
         $no_add = false;
     }
     include_once 'Services/Calendar/classes/class.ilCalendarSchedule.php';
     $this->scheduler = new ilCalendarSchedule($this->seed, ilCalendarSchedule::TYPE_WEEK, $user_id, $disable_empty);
     $this->scheduler->addSubitemCalendars(true);
     $this->scheduler->calculate();
     $counter = 0;
     $hours = null;
     $all_fullday = array();
     foreach (ilCalendarUtil::_buildWeekDayList($this->seed, $this->user_settings->getWeekStart())->get() as $date) {
         $daily_apps = $this->scheduler->getByDay($date, $this->timezone);
         $hours = $this->parseHourInfo($daily_apps, $date, $counter, $hours, $morning_aggr, $evening_aggr, $raster);
         $this->weekdays[] = $date;
         $num_apps[$date->get(IL_CAL_DATE)] = count($daily_apps);
         $all_fullday[] = $daily_apps;
         $counter++;
     }
     $colspans = $this->calculateColspans($hours);
     include_once 'Services/Calendar/classes/class.ilCalendarSettings.php';
     $settings = ilCalendarSettings::_getInstance();
     include_once "Services/UIComponent/Glyph/classes/class.ilGlyphGUI.php";
     // Table header
     $counter = 0;
     foreach (ilCalendarUtil::_buildWeekDayList($this->seed, $this->user_settings->getWeekStart())->get() as $date) {
         $date_info = $date->get(IL_CAL_FKT_GETDATE, '', 'UTC');
         $this->ctrl->setParameterByClass('ilcalendarappointmentgui', 'seed', $date->get(IL_CAL_DATE));
         $this->ctrl->setParameterByClass('ilcalendarappointmentgui', 'idate', $date->get(IL_CAL_DATE));
         $this->ctrl->setParameterByClass('ilcalendardaygui', 'seed', $date->get(IL_CAL_DATE));
         if (!$no_add) {
             $new_app_url = $this->ctrl->getLinkTargetByClass('ilcalendarappointmentgui', 'add');
             if ($settings->getEnableGroupMilestones()) {
                 $new_ms_url = $this->ctrl->getLinkTargetByClass('ilcalendarappointmentgui', 'addMilestone');
                 $this->tpl->setCurrentBlock("new_ms");
                 $this->tpl->setVariable('DD_ID', $date->get(IL_CAL_UNIX));
                 $this->tpl->setVariable('DD_TRIGGER', ilGlyphGUI::get(ilGlyphGUI::ADD));
                 $this->tpl->setVariable('URL_DD_NEW_APP', $new_app_url);
                 $this->tpl->setVariable('TXT_DD_NEW_APP', $this->lng->txt('cal_new_app'));
                 $this->tpl->setVariable('URL_DD_NEW_MS', $new_ms_url);
                 $this->tpl->setVariable('TXT_DD_NEW_MS', $this->lng->txt('cal_new_ms'));
                 $this->tpl->parseCurrentBlock();
             } else {
                 $this->tpl->setCurrentBlock("new_app");
                 $this->tpl->setVariable('NEW_APP_LINK', $new_app_url);
                 $this->tpl->setVariable('NEW_APP_SRC', ilGlyphGUI::get(ilGlyphGUI::ADD, $this->lng->txt('cal_new_app')));
                 // $this->tpl->setVariable('NEW_APP_ALT',$this->lng->txt('cal_new_app'));
                 $this->tpl->parseCurrentBlock();
             }
             $this->ctrl->clearParametersByClass('ilcalendarappointmentgui');
         }
         $dayname = ilCalendarUtil::_numericDayToString($date->get(IL_CAL_FKT_DATE, 'w'), true);
         $daydate = $date_info['mday'] . ' ' . ilCalendarUtil::_numericMonthToString($date_info['mon'], false);
         if (!$disable_empty || $num_apps[$date->get(IL_CAL_DATE)] > 0) {
             $link = $this->ctrl->getLinkTargetByClass('ilcalendardaygui', '');
             $this->ctrl->clearParametersByClass('ilcalendardaygui');
             $this->tpl->setCurrentBlock("day_view1_link");
             $this->tpl->setVariable('HEADER_DATE', $daydate);
             $this->tpl->setVariable('DAY_VIEW_LINK', $link);
             $this->tpl->parseCurrentBlock();
             $this->tpl->setCurrentBlock("day_view2_link");
             $this->tpl->setVariable('DAYNAME', $dayname);
             $this->tpl->setVariable('DAY_VIEW_LINK', $link);
             $this->tpl->parseCurrentBlock();
         } else {
             $this->tpl->setCurrentBlock("day_view1_no_link");
             $this->tpl->setVariable('HEADER_DATE', $daydate);
             $this->tpl->parseCurrentBlock();
             $this->tpl->setCurrentBlock("day_view2_no_link");
             $this->tpl->setVariable('DAYNAME', $dayname);
             $this->tpl->parseCurrentBlock();
         }
         $this->tpl->setCurrentBlock('day_header_row');
         $this->tpl->setVariable('DAY_COLSPAN', max($colspans[$counter], 1));
         $this->tpl->parseCurrentBlock();
         $counter++;
     }
     // show fullday events
     $counter = 0;
     foreach ($all_fullday as $daily_apps) {
         foreach ($daily_apps as $event) {
             if ($event['fullday']) {
                 $this->showFulldayAppointment($event);
             }
         }
         $this->tpl->setCurrentBlock('f_day_row');
         $this->tpl->setVariable('COLSPAN', max($colspans[$counter], 1));
         $this->tpl->parseCurrentBlock();
         $counter++;
     }
     $this->tpl->setCurrentBlock('fullday_apps');
     $this->tpl->setVariable('TXT_F_DAY', $lng->txt("cal_all_day"));
     $this->tpl->parseCurrentBlock();
     $new_link_counter = 0;
     foreach ($hours as $num_hour => $hours_per_day) {
         $first = true;
         foreach ($hours_per_day as $num_day => $hour) {
             if ($first) {
                 if (!($num_hour % 60) || $num_hour == $morning_aggr && $morning_aggr || $num_hour == $evening_aggr && $evening_aggr) {
                     $first = false;
                     // aggregation rows
                     if ($num_hour == $morning_aggr && $morning_aggr || $num_hour == $evening_aggr && $evening_aggr) {
                         $this->tpl->setVariable('TIME_ROWSPAN', 1);
                     } else {
                         $this->tpl->setVariable('TIME_ROWSPAN', 60 / $raster);
                     }
                     $this->tpl->setCurrentBlock('time_txt');
                     $this->tpl->setVariable('TIME', $hour['txt']);
                     $this->tpl->parseCurrentBlock();
                 }
             }
             foreach ($hour['apps_start'] as $app) {
                 $this->showAppointment($app);
             }
             // screen reader: appointments are divs, now output cell
             if ($ilUser->prefs["screen_reader_optimization"]) {
                 $this->tpl->setCurrentBlock('scrd_day_cell');
                 $this->tpl->setVariable('TD_CLASS', 'calstd');
                 $this->tpl->parseCurrentBlock();
             }
             #echo "NUMDAY: ".$num_day;
             #echo "COLAPANS: ".max($colspans[$num_day],1).'<br />';
             $num_apps = $hour['apps_num'];
             $colspan = max($colspans[$num_day], 1);
             // Show new apointment link
             if (!$hour['apps_num'] && !$ilUser->prefs["screen_reader_optimization"] && !$no_add) {
                 $this->tpl->setCurrentBlock('new_app_link');
                 $this->ctrl->setParameterByClass('ilcalendarappointmentgui', 'idate', $this->weekdays[$num_day]->get(IL_CAL_DATE));
                 $this->ctrl->setParameterByClass('ilcalendarappointmentgui', 'seed', $this->seed->get(IL_CAL_DATE));
                 $this->ctrl->setParameterByClass('ilcalendarappointmentgui', 'hour', floor($num_hour / 60));
                 $this->tpl->setVariable('DAY_NEW_APP_LINK', $this->ctrl->getLinkTargetByClass('ilcalendarappointmentgui', 'add'));
                 $this->ctrl->clearParametersByClass('ilcalendarappointmentgui');
                 $this->tpl->setVariable('DAY_NEW_APP_SRC', ilGlyphGUI::get(ilGlyphGUI::ADD, $this->lng->txt('cal_new_app')));
                 $this->tpl->setVariable('DAY_NEW_APP_ALT', $this->lng->txt('cal_new_app'));
                 $this->tpl->setVariable('DAY_NEW_ID', ++$new_link_counter);
                 $this->tpl->parseCurrentBlock();
             }
             for ($i = $colspan; $i > $hour['apps_num']; $i--) {
                 if ($ilUser->prefs["screen_reader_optimization"]) {
                     continue;
                 }
                 $this->tpl->setCurrentBlock('day_cell');
                 // last "slot" of hour needs border
                 $empty_border = '';
                 if ($num_hour % 60 == 60 - $raster || $num_hour == $morning_aggr && $morning_aggr || $num_hour == $evening_aggr && $evening_aggr) {
                     $empty_border = ' calempty_border';
                 }
                 if ($i == $hour['apps_num'] + 1) {
                     $this->tpl->setVariable('TD_CLASS', 'calempty calrightborder' . $empty_border);
                     #$this->tpl->setVariable('TD_STYLE',$add_style);
                 } else {
                     $this->tpl->setVariable('TD_CLASS', 'calempty' . $empty_border);
                     #$this->tpl->setVariable('TD_STYLE',$add_style);
                 }
                 if (!$hour['apps_num']) {
                     $this->tpl->setVariable('DAY_ID', $new_link_counter);
                 }
                 $this->tpl->setVariable('TD_ROWSPAN', 1);
                 $this->tpl->parseCurrentBlock();
             }
         }
         $this->tpl->touchBlock('time_row');
     }
     $this->tpl->setVariable("TXT_TIME", $lng->txt("time"));
 }
 /**
  * read permissions
  *
  * @access private
  * @param
  * @return
  */
 private function readPermissions()
 {
     global $ilUser, $rbacsystem, $ilAccess;
     $this->editable = false;
     $this->visible = false;
     $this->importable = false;
     include_once './Services/Calendar/classes/class.ilCalendarShared.php';
     $shared = ilCalendarShared::getSharedCalendarsForUser($ilUser->getId());
     $cat = new ilCalendarCategory((int) $_GET['category_id']);
     switch ($cat->getType()) {
         case ilCalendarCategory::TYPE_USR:
             if ($cat->getObjId() == $ilUser->getId()) {
                 $this->visible = true;
                 $this->editable = true;
                 $this->importable = true;
             } elseif (isset($shared[$cat->getCategoryID()])) {
                 $this->visible = true;
             }
             break;
         case ilCalendarCategory::TYPE_GLOBAL:
             $this->importable = $this->editable = $rbacsystem->checkAccess('edit_event', ilCalendarSettings::_getInstance()->getCalendarSettingsId());
             $this->visible = true;
             break;
         case ilCalendarCategory::TYPE_OBJ:
             $this->editable = false;
             $refs = ilObject::_getAllReferences($cat->getObjId());
             foreach ($refs as $ref) {
                 if ($ilAccess->checkAccess('read', '', $ref)) {
                     $this->visible = true;
                 }
                 if ($ilAccess->checkAccess('edit_event', '', $ref)) {
                     $this->importable = true;
                 }
             }
             break;
         case ilCalendarCategory::TYPE_BOOK:
         case ilCalendarCategory::TYPE_CH:
             $this->editable = $ilUser->getId() == $cat->getCategoryID();
             $this->visible = true;
             $this->importable = false;
             break;
     }
 }
 /**
  * fill data section
  *
  * @access public
  * 
  */
 public function show()
 {
     global $tpl, $ilUser;
     $this->tpl = new ilTemplate('tpl.month_view.html', true, true, 'Services/Calendar');
     include_once './Services/YUI/classes/class.ilYuiUtil.php';
     ilYuiUtil::initDragDrop();
     ilYuiUtil::initPanel();
     $navigation = new ilCalendarHeaderNavigationGUI($this, $this->seed, ilDateTime::MONTH);
     $this->tpl->setVariable('NAVIGATION', $navigation->getHTML());
     for ($i = (int) $this->user_settings->getWeekStart(); $i < 7 + (int) $this->user_settings->getWeekStart(); $i++) {
         $this->tpl->setCurrentBlock('month_header_col');
         $this->tpl->setVariable('TXT_WEEKDAY', ilCalendarUtil::_numericDayToString($i, true));
         $this->tpl->parseCurrentBlock();
     }
     if (isset($_GET["bkid"])) {
         $user_id = $_GET["bkid"];
         $disable_empty = true;
         $no_add = true;
     } else {
         if ($ilUser->getId() == ANONYMOUS_USER_ID) {
             $user_id = $ilUser->getId();
             $disable_empty = false;
             $no_add = true;
         } else {
             $user_id = $ilUser->getId();
             $disable_empty = false;
             $no_add = false;
         }
     }
     $is_portfolio_embedded = false;
     if (ilCalendarCategories::_getInstance()->getMode() == ilCalendarCategories::MODE_PORTFOLIO_CONSULTATION) {
         $no_add = true;
         $is_portfolio_embedded = true;
     }
     include_once 'Services/Calendar/classes/class.ilCalendarSchedule.php';
     $this->scheduler = new ilCalendarSchedule($this->seed, ilCalendarSchedule::TYPE_MONTH, $user_id);
     $this->scheduler->addSubitemCalendars(true);
     if (sizeof($this->schedule_filters)) {
         foreach ($this->schedule_filters as $filter) {
             $this->scheduler->addFilter($filter);
         }
     }
     $this->scheduler->calculate();
     include_once 'Services/Calendar/classes/class.ilCalendarSettings.php';
     $settings = ilCalendarSettings::_getInstance();
     $counter = 0;
     foreach (ilCalendarUtil::_buildMonthDayList($this->seed->get(IL_CAL_FKT_DATE, 'm'), $this->seed->get(IL_CAL_FKT_DATE, 'Y'), $this->user_settings->getWeekStart())->get() as $date) {
         $counter++;
         $has_events = (bool) $this->showEvents($date);
         if (!$no_add) {
             include_once "Services/UIComponent/Glyph/classes/class.ilGlyphGUI.php";
             $this->ctrl->clearParametersByClass('ilcalendarappointmentgui');
             $this->ctrl->setParameterByClass('ilcalendarappointmentgui', 'idate', $date->get(IL_CAL_DATE));
             $this->ctrl->setParameterByClass('ilcalendarappointmentgui', 'seed', $this->seed->get(IL_CAL_DATE));
             $new_app_url = $this->ctrl->getLinkTargetByClass('ilcalendarappointmentgui', 'add');
             if ($settings->getEnableGroupMilestones()) {
                 $this->ctrl->clearParametersByClass('ilcalendarappointmentgui');
                 $this->ctrl->setParameterByClass('ilcalendarappointmentgui', 'seed', $this->seed->get(IL_CAL_DATE));
                 $this->ctrl->setParameterByClass('ilcalendarappointmentgui', 'idate', $date->get(IL_CAL_DATE));
                 $new_ms_url = $this->ctrl->getLinkTargetByClass('ilcalendarappointmentgui', 'addMilestone');
                 $this->tpl->setCurrentBlock("new_ms");
                 $this->tpl->setVariable('DD_ID', $date->get(IL_CAL_UNIX));
                 $this->tpl->setVariable('DD_TRIGGER', ilGlyphGUI::get(ilGlyphGUI::ADD));
                 $this->tpl->setVariable('URL_DD_NEW_APP', $new_app_url);
                 $this->tpl->setVariable('TXT_DD_NEW_APP', $this->lng->txt('cal_new_app'));
                 $this->tpl->setVariable('URL_DD_NEW_MS', $new_ms_url);
                 $this->tpl->setVariable('TXT_DD_NEW_MS', $this->lng->txt('cal_new_ms'));
                 $this->tpl->parseCurrentBlock();
             } else {
                 $this->tpl->setCurrentBlock("new_app");
                 $this->tpl->setVariable('ADD_LINK', $new_app_url);
                 $this->tpl->setVariable('NEW_SRC', ilGlyphGUI::get(ilGlyphGUI::ADD, $this->lng->txt('cal_new_app')));
                 $this->tpl->parseCurrentBlock();
             }
         }
         $day = $date->get(IL_CAL_FKT_DATE, 'j');
         $month = $date->get(IL_CAL_FKT_DATE, 'n');
         if ($day == 1) {
             $month_day = '1 ' . ilCalendarUtil::_numericMonthToString($month, false);
         } else {
             $month_day = $day;
         }
         if (!$is_portfolio_embedded && (!$disable_empty || $has_events)) {
             $this->tpl->setCurrentBlock('month_day_link');
             $this->ctrl->clearParametersByClass('ilcalendardaygui');
             $this->ctrl->setParameterByClass('ilcalendardaygui', 'seed', $date->get(IL_CAL_DATE));
             $this->tpl->setVariable('OPEN_DAY_VIEW', $this->ctrl->getLinkTargetByClass('ilcalendardaygui', ''));
             $this->ctrl->clearParametersByClass('ilcalendardaygui');
         } else {
             $this->tpl->setCurrentBlock('month_day_no_link');
         }
         $this->tpl->setVariable('MONTH_DAY', $month_day);
         $this->tpl->parseCurrentBlock();
         $this->tpl->setCurrentBlock('month_col');
         include_once './Services/Calendar/classes/class.ilCalendarUtil.php';
         if (ilCalendarUtil::_isToday($date)) {
             $this->tpl->setVariable('TD_CLASS', 'caltoday');
         } elseif (ilDateTime::_equals($date, $this->seed, IL_CAL_MONTH)) {
             $this->tpl->setVariable('TD_CLASS', 'calstd');
         } elseif (ilDateTime::_before($date, $this->seed, IL_CAL_MONTH)) {
             $this->tpl->setVariable('TD_CLASS', 'calprev');
         } else {
             $this->tpl->setVariable('TD_CLASS', 'calnext');
         }
         $this->tpl->parseCurrentBlock();
         if ($counter and !($counter % 7)) {
             $this->tpl->setCurrentBlock('month_row');
             $this->tpl->parseCurrentBlock();
         }
     }
 }
Example #18
0
 /**
  * get date format
  *
  * @access public
  * @return
  */
 public function getDateFormat()
 {
     if ($format = $this->getPref('date_format')) {
         return $format;
     } else {
         include_once 'Services/Calendar/classes/class.ilCalendarSettings.php';
         $settings = ilCalendarSettings::_getInstance();
         return $settings->getDefaultDateFormat();
     }
 }
 /**
  * Check if cache is disabled or expired
  * @return 
  */
 public function isIcalExpired()
 {
     return true;
     include_once './Services/Calendar/classes/class.ilCalendarSettings.php';
     if (!ilCalendarSettings::_getInstance()->isSynchronisationCacheEnabled()) {
         return true;
     }
     if (!ilCalendarSettings::_getInstance()->getSynchronisationCacheMinutes()) {
         return true;
     }
     return time() > $this->ical_ctime + 60 * ilCalendarSettings::_getInstance()->getSynchronisationCacheMinutes();
 }
 /**
  * fill data section
  *
  * @access protected
  * 
  */
 protected function show()
 {
     global $lng, $ilUser;
     // config
     $raster = 15;
     if ($this->user_settings->getDayStart()) {
         // push starting point to last "slot" of hour BEFORE morning aggregation
         $morning_aggr = ($this->user_settings->getDayStart() - 1) * 60 + (60 - $raster);
     } else {
         $morning_aggr = 0;
     }
     $evening_aggr = $this->user_settings->getDayEnd() * 60;
     $this->tpl = new ilTemplate('tpl.day_view.html', true, true, 'Services/Calendar');
     include_once './Services/YUI/classes/class.ilYuiUtil.php';
     ilYuiUtil::initDragDrop();
     ilYuiUtil::initPanel();
     if (isset($_GET["bkid"])) {
         $user_id = $_GET["bkid"];
         $no_add = true;
     } elseif ($ilUser->getId() == ANONYMOUS_USER_ID) {
         $user_id = $ilUser->getId();
         $no_add = true;
     } else {
         $user_id = $ilUser->getId();
         $no_add = false;
     }
     include_once 'Services/Calendar/classes/class.ilCalendarSchedule.php';
     $this->scheduler = new ilCalendarSchedule($this->seed, ilCalendarSchedule::TYPE_DAY, $user_id);
     $this->scheduler->addSubitemCalendars(true);
     $this->scheduler->calculate();
     $daily_apps = $this->scheduler->getByDay($this->seed, $this->timezone);
     $hours = $this->parseInfoIntoRaster($daily_apps, $morning_aggr, $evening_aggr, $raster);
     $colspan = $this->calculateColspan($hours);
     $navigation = new ilCalendarHeaderNavigationGUI($this, $this->seed, ilDateTime::DAY);
     $this->ctrl->setParameterByClass('ilcalendarappointmentgui', 'seed', $this->seed->get(IL_CAL_DATE));
     // add milestone link
     include_once 'Services/Calendar/classes/class.ilCalendarSettings.php';
     $settings = ilCalendarSettings::_getInstance();
     include_once "Services/UIComponent/Glyph/classes/class.ilGlyphGUI.php";
     if (!$no_add) {
         $this->ctrl->setParameterByClass('ilcalendarappointmentgui', 'seed', $this->seed->get(IL_CAL_DATE));
         $this->ctrl->setParameterByClass('ilcalendarappointmentgui', 'idate', $this->seed->get(IL_CAL_DATE));
         $new_app_url = $this->ctrl->getLinkTargetByClass('ilcalendarappointmentgui', 'add');
         if ($settings->getEnableGroupMilestones()) {
             $this->ctrl->setParameterByClass('ilcalendarappointmentgui', 'seed', $this->seed->get(IL_CAL_DATE));
             $this->ctrl->setParameterByClass('ilcalendarappointmentgui', 'idate', $this->seed->get(IL_CAL_DATE));
             $new_ms_url = $this->ctrl->getLinkTargetByClass('ilcalendarappointmentgui', 'addMilestone');
             $this->tpl->setCurrentBlock("new_ms");
             $this->tpl->setVariable('DD_ID', $this->seed->get(IL_CAL_UNIX));
             $this->tpl->setVariable('DD_TRIGGER', ilGlyphGUI::get(ilGlyphGUI::ADD));
             $this->tpl->setVariable('URL_DD_NEW_APP', $new_app_url);
             $this->tpl->setVariable('TXT_DD_NEW_APP', $this->lng->txt('cal_new_app'));
             $this->tpl->setVariable('URL_DD_NEW_MS', $new_ms_url);
             $this->tpl->setVariable('TXT_DD_NEW_MS', $this->lng->txt('cal_new_ms'));
             $this->tpl->parseCurrentBlock();
         } else {
             $this->tpl->setCurrentBlock("new_app1");
             $this->tpl->setVariable('H_NEW_APP_SRC', ilGlyphGUI::get(ilGlyphGUI::ADD, $this->lng->txt('cal_new_app')));
             $this->tpl->setVariable('NEW_APP_LINK', $new_app_url);
             $this->tpl->parseCurrentBlock();
         }
         $this->ctrl->clearParametersByClass('ilcalendarappointmentgui');
     }
     $this->tpl->setVariable('NAVIGATION', $navigation->getHTML());
     $this->tpl->setVariable('HEADER_DATE', $this->seed_info['mday'] . ' ' . ilCalendarUtil::_numericMonthToString($this->seed_info['mon'], false));
     $this->tpl->setVariable('HEADER_DAY', ilCalendarUtil::_numericDayToString($this->seed_info['wday'], true));
     $this->tpl->setVariable('HCOLSPAN', $colspan - 1);
     $this->tpl->setVariable('TXT_TIME', $lng->txt("time"));
     // show fullday events
     foreach ($daily_apps as $event) {
         if ($event['fullday']) {
             $this->showFulldayAppointment($event);
         }
     }
     $this->tpl->setCurrentBlock('fullday_apps');
     $this->tpl->setVariable('TXT_F_DAY', $lng->txt("cal_all_day"));
     $this->tpl->setVariable('COLSPAN', $colspan - 1);
     $this->tpl->parseCurrentBlock();
     // parse the hour rows
     foreach ($hours as $numeric => $hour) {
         if (!($numeric % 60) || $numeric == $morning_aggr && $morning_aggr || $numeric == $evening_aggr && $evening_aggr) {
             if (!$no_add) {
                 $this->tpl->setCurrentBlock("new_app2");
                 $this->ctrl->clearParametersByClass('ilcalendarappointmentgui');
                 $this->ctrl->setParameterByClass('ilcalendarappointmentgui', 'seed', $this->seed->get(IL_CAL_DATE));
                 $this->ctrl->setParameterByClass('ilcalendarappointmentgui', 'idate', $this->seed->get(IL_CAL_DATE));
                 $this->ctrl->setParameterByClass('ilcalendarappointmentgui', 'hour', floor($numeric / 60));
                 $this->tpl->setVariable('NEW_APP_HOUR_LINK', $this->ctrl->getLinkTargetByClass('ilcalendarappointmentgui', 'add'));
                 $this->tpl->setVariable('NEW_APP_SRC', ilGlyphGUI::get(ilGlyphGUI::ADD, $this->lng->txt('cal_new_app')));
                 $this->tpl->parseCurrentBlock();
             }
             // aggregation rows
             if ($numeric == $morning_aggr && $morning_aggr || $numeric == $evening_aggr && $evening_aggr) {
                 $this->tpl->setVariable('TIME_ROWSPAN', 1);
             } else {
                 $this->tpl->setVariable('TIME_ROWSPAN', 60 / $raster);
             }
             $this->tpl->setCurrentBlock('time_txt');
             $this->tpl->setVariable('TIME', $hour['txt']);
             $this->tpl->parseCurrentBlock();
         }
         foreach ($hour['apps_start'] as $app) {
             $this->showAppointment($app);
         }
         if ($ilUser->prefs["screen_reader_optimization"]) {
             $this->tpl->touchBlock('scrd_app_cell');
         }
         for ($i = $colspan - 1; $i > $hour['apps_num']; $i--) {
             $this->tpl->setCurrentBlock('empty_cell');
             $this->tpl->setVariable('EMPTY_WIDTH', 100 / (int) ($colspan - 1) . '%');
             // last "slot" of hour needs border
             if ($numeric % 60 == 60 - $raster || $numeric == $morning_aggr && $morning_aggr || $numeric == $evening_aggr && $evening_aggr) {
                 $this->tpl->setVariable('EMPTY_STYLE', ' calempty_border');
             }
             $this->tpl->parseCurrentBlock();
         }
         $this->tpl->touchBlock('time_row');
     }
 }
 /**
  * 
  * @param type $a_obj_id
  */
 public static function lookupCalendarActivated($a_obj_id)
 {
     if (!ilCalendarSettings::_getInstance()->isEnabled()) {
         return false;
     }
     $type = ilObject::_lookupType($a_obj_id);
     // lookup global setting
     $gl_activated = false;
     switch ($type) {
         case 'crs':
             $gl_activated = ilCalendarSettings::_getInstance()->isCourseCalendarEnabled();
             break;
         case 'grp':
             $gl_activated = ilCalendarSettings::_getInstance()->isGroupCalendarEnabled();
             break;
         default:
             return false;
     }
     // look individual object setting
     include_once './Services/Container/classes/class.ilContainer.php';
     return ilContainer::_lookupContainerSetting($a_obj_id, 'cont_show_calendar', $gl_activated);
 }
 /**
  * init calendar settings
  *
  * @access protected
  */
 protected function initCalendarSettings()
 {
     include_once 'Services/Calendar/classes/class.ilCalendarSettings.php';
     $this->settings = ilCalendarSettings::_getInstance();
 }
 /**
  * Fills the table with data for whole week.
  */
 public function show($export = false)
 {
     if ($export && isset($_SESSION['weeklySeed'])) {
         $this->seed = $_SESSION['weeklySeed'];
     } else {
         $_SESSION['weeklySeed'] = $this->seed;
     }
     if (!$this->permission->checkPrivilege(PRIVC::SEE_BOOKINGS_OF_ROOMS)) {
         ilUtil::sendFailure($this->lng->txt("rep_robj_xrs_no_permission_for_action"));
         $this->ctrl->redirectByClass('ilinfoscreengui', 'showSummary', 'showSummary');
         return false;
     }
     global $ilUser;
     $this->setSubTabs('weekview');
     //intervalsize
     $raster = 15;
     if ($this->user_settings->getDayStart()) {
         // push starting point to last "slot" of hour BEFORE morning aggregation
         $morning_aggr = ($this->user_settings->getDayStart() - 1) * 60 + (60 - $raster);
     } else {
         $morning_aggr = 0;
     }
     $evening_aggr = $this->user_settings->getDayEnd() * 60;
     $this->tpl = new ilTemplate('tpl.room_week_view.html', true, true, 'Customizing/global/plugins/Services/Repository/RepositoryObject/RoomSharing');
     ilYuiUtil::initDragDrop();
     ilYuiUtil::initPanel();
     $navigation = new ilCalendarHeaderNavigationGUI($this, $this->seed, ilDateTime::WEEK);
     $this->tpl->setVariable('NAVIGATION', $navigation->getHTML());
     if (isset($_GET["bkid"])) {
         $user_id = $_GET["bkid"];
         $disable_empty = true;
         $no_add = true;
     } elseif ($ilUser->getId() == ANONYMOUS_USER_ID) {
         $user_id = $ilUser->getId();
         $disable_empty = false;
         $no_add = true;
     } else {
         $user_id = $ilUser->getId();
         $disable_empty = false;
         $no_add = false;
     }
     $room = new ilRoomSharingRoom($this->pool_id, $this->room_id);
     $this->tpl->setVariable('ROOM', $this->lng->txt('rep_robj_xrs_room_occupation_title') . " " . $room->getName());
     $this->scheduler = new ilRoomSharingCalendarSchedule($this->seed, ilCalendarSchedule::TYPE_WEEK, $user_id, $room);
     $this->scheduler->addSubitemCalendars(true);
     $this->scheduler->calculate();
     $counter = 0;
     $hours = NULL;
     foreach (ilCalendarUtil::_buildWeekDayList($this->seed, $this->user_settings->getWeekStart())->get() as $date) {
         $daily_apps = $this->scheduler->getByDay($date, $this->timezone);
         $hours = $this->parseHourInfo($daily_apps, $date, $counter, $hours, $morning_aggr, $evening_aggr, $raster);
         $this->weekdays[] = $date;
         $num_apps[$date->get(IL_CAL_DATE)] = count($daily_apps);
         $counter++;
     }
     $colspans = $this->calculateColspans($hours);
     $settings = ilCalendarSettings::_getInstance();
     $exportLink = $this->ctrl->getLinkTargetByClass("ilroomsharingcalendarweekgui", "export");
     $this->tpl->setCurrentBlock("export_block");
     $this->tpl->setVariable('EXPORT_LINK', $exportLink);
     $this->tpl->parseCurrentBlock();
     // Table header
     $counter = 0;
     foreach (ilCalendarUtil::_buildWeekDayList($this->seed, $this->user_settings->getWeekStart())->get() as $date) {
         $date_info = $date->get(IL_CAL_FKT_GETDATE, '', 'UTC');
         $this->ctrl->setParameterByClass('ilcalendarappointmentgui', 'seed', $date->get(IL_CAL_DATE));
         $this->ctrl->setParameterByClass('ilcalendarappointmentgui', 'idate', $date->get(IL_CAL_DATE));
         $this->ctrl->setParameterByClass('ilcalendardaygui', 'seed', $date->get(IL_CAL_DATE));
         $dayname = ilCalendarUtil::_numericDayToString($date->get(IL_CAL_FKT_DATE, 'w'), true);
         $this->days[$counter] = $date;
         $daydate = $date_info['mday'] . ' ' . ilCalendarUtil::_numericMonthToString($date_info['mon'], false);
         if (!$disable_empty || $num_apps[$date->get(IL_CAL_DATE)] > 0) {
             $link = $this->ctrl->getLinkTargetByClass('ilcalendardaygui', '');
             $this->ctrl->clearParametersByClass('ilcalendardaygui');
             $this->tpl->setCurrentBlock("day_view1_link");
             $this->tpl->setVariable('HEADER_DATE', $daydate);
             $this->tpl->setVariable('DAY_VIEW_LINK', $link);
             $this->tpl->parseCurrentBlock();
             $this->tpl->setCurrentBlock("day_view2_link");
             $this->tpl->setVariable('DAYNAME', $dayname);
             $this->tpl->setVariable('DAY_VIEW_LINK', $link);
             $this->tpl->parseCurrentBlock();
         } else {
             $this->tpl->setCurrentBlock("day_view1_no_link");
             $this->tpl->setVariable('HEADER_DATE', $daydate);
             $this->tpl->parseCurrentBlock();
             $this->tpl->setCurrentBlock("day_view2_no_link");
             $this->tpl->setVariable('DAYNAME', $dayname);
             $this->tpl->parseCurrentBlock();
         }
         $this->tpl->setCurrentBlock('day_header_row');
         $this->tpl->setVariable('DAY_COLSPAN', max($colspans[$counter], 1));
         $this->tpl->parseCurrentBlock();
         $counter++;
     }
     $new_link_counter = 0;
     foreach ($hours as $num_hour => $hours_per_day) {
         $first = true;
         foreach ($hours_per_day as $num_day => $hour) {
             if ($first) {
                 if (!($num_hour % 60) || $num_hour == $morning_aggr && $morning_aggr || $num_hour == $evening_aggr && $evening_aggr) {
                     $first = false;
                     $this->timeIntervals[] = $hours_per_day[2];
                     // aggregation rows
                     if ($num_hour == $morning_aggr && $morning_aggr || $num_hour == $evening_aggr && $evening_aggr) {
                         $this->tpl->setVariable('TIME_ROWSPAN', 1);
                     } else {
                         $this->tpl->setVariable('TIME_ROWSPAN', 60 / $raster);
                     }
                     $this->tpl->setCurrentBlock('time_txt');
                     $this->tpl->setVariable('TIME', $hour['txt']);
                     $this->tpl->parseCurrentBlock();
                 }
             }
             foreach ($hour['apps_start'] as $app) {
                 $this->showAppointment($app);
             }
             // screen reader: appointments are divs, now output cell
             if ($ilUser->prefs["screen_reader_optimization"]) {
                 $this->tpl->setCurrentBlock('scrd_day_cell');
                 $this->tpl->setVariable('TD_CLASS', 'calstd');
                 $this->tpl->parseCurrentBlock();
             }
             #echo "NUMDAY: ".$num_day;
             #echo "COLAPANS: ".max($colspans[$num_day],1).'<br />';
             $num_apps = $hour['apps_num'];
             $colspan = max($colspans[$num_day], 1);
             // Show new apointment link
             $userCanAddBooking = $this->permission->checkPrivilege(PRIVC::ADD_OWN_BOOKINGS);
             $calStuffAllowed = !$hour['apps_num'] && !$ilUser->prefs["screen_reader_optimization"] && !$no_add;
             if ($userCanAddBooking && $calStuffAllowed) {
                 $this->tpl->setCurrentBlock('new_app_link');
                 $this->tpl->setVariable('DAY_NEW_APP_LINK', $this->lng->txt('rep_robj_xrs_room_book'));
                 $this->ctrl->setParameterByClass('ilobjroomsharinggui', 'room', $room->getName());
                 $this->ctrl->setParameterByClass('ilobjroomsharinggui', 'room_id', $room->getId());
                 $_SESSION['last_cmd'] = 'showroom';
                 $date = $this->weekdays[$num_day]->get(IL_CAL_DATE);
                 //convert time into suitable format (HH:ii:ss)
                 $hr = floor($num_hour / 60);
                 $hr = $hr < 10 ? "0" . $hr : $hr;
                 $hr_end = floor(($num_hour + 60) / 60);
                 $hr_end = $hr_end < 10 ? "0" . $hr_end : $hr_end;
                 $min = floor($num_hour % 60);
                 $min = $min < 10 ? "0" . $min : $min;
                 $min_end = floor(($num_hour + 60) % 60);
                 $min_end = $min_end < 10 ? "0" . $min_end : $min_end;
                 $time_from = $hr . ":" . $min . ":00";
                 $time_to = $hr_end . ":" . $min_end . ":00";
                 $this->ctrl->setParameterByClass('ilobjroomsharinggui', 'date', $date);
                 $this->ctrl->setParameterByClass('ilobjroomsharinggui', 'time_from', $time_from);
                 $this->ctrl->setParameterByClass('ilobjroomsharinggui', 'time_to', $time_to);
                 $this->tpl->setVariable('DAY_NEW_APP_LINK', $this->ctrl->getLinkTargetByClass('ilobjroomsharinggui', 'book'));
                 // free the parameters
                 $this->ctrl->clearParametersByClass('ilobjroomsharinggui');
                 $this->tpl->setVariable('DAY_NEW_APP_SRC', ilUtil::getImagePath('date_add.png'));
                 $this->tpl->setVariable('DAY_NEW_APP_ALT', $this->lng->txt('cal_new_app'));
                 $this->tpl->setVariable('DAY_NEW_ID', ++$new_link_counter);
                 $this->tpl->parseCurrentBlock();
             }
             for ($i = $colspan; $i > $hour['apps_num']; $i--) {
                 if ($ilUser->prefs["screen_reader_optimization"]) {
                     continue;
                 }
                 $this->tpl->setCurrentBlock('day_cell');
                 // last "slot" of hour needs border
                 $empty_border = '';
                 if ($num_hour % 60 == 60 - $raster || $num_hour == $morning_aggr && $morning_aggr || $num_hour == $evening_aggr && $evening_aggr) {
                     $empty_border = ' calempty_border';
                 }
                 if ($i == $hour['apps_num'] + 1) {
                     $this->tpl->setVariable('TD_CLASS', 'calempty calrightborder' . $empty_border);
                     #$this->tpl->setVariable('TD_STYLE',$add_style);
                 } else {
                     $this->tpl->setVariable('TD_CLASS', 'calempty' . $empty_border);
                     #$this->tpl->setVariable('TD_STYLE',$add_style);
                 }
                 if (!$hour['apps_num']) {
                     $this->tpl->setVariable('DAY_ID', $new_link_counter);
                 }
                 $this->tpl->setVariable('TD_ROWSPAN', 1);
                 $this->tpl->parseCurrentBlock();
             }
         }
         $this->tpl->touchBlock('time_row');
     }
     $this->tpl->setVariable("TXT_TIME", $this->lng->txt("time"));
     if ($export) {
         $this->export();
     }
 }
 /**
  * Handles all commmands of this class, centralizes permission checks
  *
  * @param string $cmd Given Command to Execute
  *
  * @return boolean true
  */
 function performCommand($cmd)
 {
     global $ilTabs, $ilCtrl, $tpl, $ilNavigationHistory, $cmd, $rssPermission;
     $tpl->setDescription($this->object->getLongDescription());
     $tpl->setAlertProperties($this->getAlertProperties());
     $next_class = $ilCtrl->getNextClass($this);
     $this->pl_obj = new ilRoomSharingPlugin();
     $this->pl_obj->includeClass("class.ilObjRoomSharing.php");
     // Set pool id
     $this->pool_id = $this->object->getPoolID();
     $cmd = $ilCtrl->getCmd();
     $has_calendar = false;
     if ($cmd === 'edit' || $cmd === 'editSettings' || $cmd === 'updateSettings') {
         $ilTabs->setTabActive('settings');
         // In case the edit button was clicked in the repository
         if ($cmd === 'edit') {
             $cmd = 'editSettings';
         }
         $this->{$cmd}();
         return true;
     } else {
         if ($cmd == 'showBooking' || $cmd == 'editBooking' || $cmd == 'saveEditBooking' || $cmd == 'cancelEdit') {
             $next_class = 'ilroomsharingshowandeditbookgui';
         } else {
             if ($cmd === 'showSearch' || $cmd === 'showBookSearchResults' || $cmd === "showSearchResults") {
                 $next_class = empty($next_class) ? 'ilroomsharingsearchgui' : $next_class;
             } else {
                 if ($cmd === 'addRoom' || $cmd === 'editRoom') {
                     $next_class = 'ilroomsharingroomgui';
                 } else {
                     if ($cmd == 'showBookings') {
                         $next_class = 'ilroomsharingappointmentsgui';
                     }
                 }
             }
         }
     }
     // Extend list of last visited objects by this pool.
     $ilNavigationHistory->addItem($this->ref_id, "./goto.php?target=xrs_" . $this->ref_id, "xrs");
     // Main switch for cmdClass.
     switch ($next_class) {
         // Attributes for rooms and bookings
         case ATTRC::ATTRS_GUI:
             $this->tabs_gui->setTabActive(ATTRC::ATTRS);
             $this->pl_obj->includeClass(ATTRC::ATTRS_GUI_PATH);
             $attributes_gui =& new ilRoomSharingAttributesGUI($this);
             $ret =& $this->ctrl->forwardCommand($attributes_gui);
             break;
             // Appointments
         // Appointments
         case 'ilroomsharingappointmentsgui':
             $this->tabs_gui->setTabActive('appointments');
             $this->pl_obj->includeClass("appointments/class.ilRoomSharingAppointmentsGUI.php");
             $object_gui =& new ilRoomSharingAppointmentsGUI($this);
             $ret =& $this->ctrl->forwardCommand($object_gui);
             $has_calendar = true;
             break;
             // Info
         // Info
         case 'ilinfoscreengui':
             $this->infoScreen();
             break;
             // Search
         // Search
         case 'ilroomsharingsearchgui':
             $this->tabs_gui->setTabActive('search');
             $this->pl_obj->includeClass("search/class.ilRoomSharingSearchGUI.php");
             $object_gui =& new ilRoomSharingSearchGUI($this);
             $ret =& $this->ctrl->forwardCommand($object_gui);
             break;
             // Rooms, Called for a list of rooms
         // Rooms, Called for a list of rooms
         case 'ilroomsharingroomsgui':
             $this->tabs_gui->setTabActive('rooms');
             $this->pl_obj->includeClass("rooms/class.ilRoomSharingRoomsGUI.php");
             $object_gui =& new ilRoomSharingRoomsGUI($this);
             $ret =& $this->ctrl->forwardCommand($object_gui);
             $has_calendar = true;
             break;
             // Room, Called for display a single room
         // Room, Called for display a single room
         case 'ilroomsharingroomgui':
             $this->tabs_gui->setTabActive('rooms');
             $room_id = (int) $_GET['room_id'];
             $this->pl_obj->includeClass("rooms/detail/class.ilRoomSharingRoomGUI.php");
             $object_gui =& new ilRoomSharingRoomGUI($this, $room_id);
             $ret =& $this->ctrl->forwardCommand($object_gui);
             break;
             // CalendarWeek, Called for display a weekly view for a single room
         // CalendarWeek, Called for display a weekly view for a single room
         case 'ilroomsharingcalendarweekgui':
             $this->tabs_gui->setTabActive('rooms');
             $room_id = (int) $_GET['room_id'];
             $this->pl_obj->includeClass("rooms/detail/calendar/class.ilRoomSharingCalendarWeekGUI.php");
             $object_gui =& new ilRoomSharingCalendarWeekGUI($this->seed, $this->pool_id, $room_id);
             $ret =& $this->ctrl->forwardCommand($object_gui);
             break;
             // Book
         // Book
         case 'ilroomsharingbookgui':
             $this->tabs_gui->clearTargets();
             $this->tabs_gui->setBackTarget($this->lng->txt($_SESSION['last_cmd'] != "showRoom" ? "rep_robj_xrs_search_back" : "rep_robj_xrs_room_back"), $this->ctrl->getLinkTarget($this, $_SESSION['last_cmd']));
             $this->pl_obj->includeClass("booking/class.ilRoomSharingBookGUI.php");
             $book_gui =& new ilRoomSharingBookGUI($this);
             $ret =& $this->ctrl->forwardCommand($book_gui);
             break;
             // Show and edit booking
         // Show and edit booking
         case 'ilroomsharingshowandeditbookgui':
             $this->tabs_gui->clearTargets();
             $this->tabs_gui->setBackTarget($this->lng->txt("rep_robj_xrs_booking_back"), $ilCtrl->getLinkTarget($this, "showBookings"));
             $this->pl_obj->includeClass("booking/class.ilRoomSharingShowAndEditBookGUI.php");
             $booking_id = (int) $_GET['booking_id'];
             $room_id = (int) $_GET['room_id'];
             if ($cmd == 'editBooking' || $cmd == 'saveEditBooking') {
                 $mode = 'edit';
             } else {
                 $mode = 'show';
             }
             $showAndEditBook_gui =& new ilRoomSharingShowAndEditBookGUI($this, $booking_id, $room_id, $mode);
             $ret =& $this->ctrl->forwardCommand($showAndEditBook_gui);
             $has_calendar = true;
             break;
             // Floorplans
         // Floorplans
         case 'ilroomsharingfloorplansgui':
             $this->tabs_gui->setTabActive('floor_plans');
             $this->pl_obj->includeClass("floorplans/class.ilRoomSharingFloorPlansGUI.php");
             $schedule_gui =& new ilRoomSharingFloorPlansGUI($this);
             $ret =& $this->ctrl->forwardCommand($schedule_gui);
             break;
             // daVinci import
         // daVinci import
         case 'ilroomsharingdavinciimportgui':
             if ($this->permission->checkPrivilege(PRIVC::ACCESS_IMPORT)) {
                 $this->tabs_gui->setTabActive('daVinci_import');
                 $this->pl_obj->includeClass("import/class.ilRoomSharingDaVinciImportGUI.php");
                 $import_gui =& new ilRoomSharingDaVinciImportGUI($this);
                 $ret =& $this->ctrl->forwardCommand($import_gui);
                 break;
             }
             // Permissions
         // Permissions
         case 'ilpermissiongui':
             $this->tabs_gui->setTabActive('perm_settings');
             include_once "Services/AccessControl/classes/class.ilPermissionGUI.php";
             $perm_gui =& new ilPermissionGUI($this);
             $ret =& $this->ctrl->forwardCommand($perm_gui);
             break;
             // Privileges
         // Privileges
         case 'ilroomsharingprivilegesgui':
             if ($this->permission->checkPrivilege(PRIVC::ACCESS_PRIVILEGES)) {
                 $this->tabs_gui->setTabActive('privileges');
                 $this->pl_obj->includeClass("privileges/class.ilRoomSharingPrivilegesGUI.php");
                 $privileges_gui =& new ilRoomSharingPrivilegesGUI($this);
                 $ret =& $this->ctrl->forwardCommand($privileges_gui);
             } else {
                 ilUtil::sendFailure($this->txt("no_permission"));
             }
             break;
             // Userprofile GUI
         // Userprofile GUI
         case 'ilpublicuserprofilegui':
             $ilTabs->clearTargets();
             $profile = new ilPublicUserProfileGUI((int) $_GET["user_id"]);
             $profile->setBackUrl($this->ctrl->getLinkTarget($this, 'log'));
             $ret = $this->ctrl->forwardCommand($profile);
             $tpl->setContent($ret);
             break;
             // Standard dispatcher GUI
         // Standard dispatcher GUI
         case "ilcommonactiondispatchergui":
             $gui = ilCommonActionDispatcherGUI::getInstanceFromAjaxCall();
             $this->ctrl->forwardCommand($gui);
             break;
             // Copy GUI. Not supported yet.
         // Copy GUI. Not supported yet.
         case "ilobjectcopygui":
             include_once "./Services/Object/classes/class.ilObjectCopyGUI.php";
             $cp = new ilObjectCopyGUI($this);
             $cp->setType("roomsharing");
             $this->ctrl->forwardCommand($cp);
             break;
             // Various CalendarGUIs
         // Various CalendarGUIs
         case "ilcalendardaygui":
             $this->setActiveTabRegardingPrivilege();
             $day = new ilCalendarDayGUI(new ilDate($_GET["seed"], IL_CAL_DATE));
             $this->ctrl->forwardCommand($day);
             break;
         case "ilcalendarmonthgui":
             $this->setActiveTabRegardingPrivilege();
             $month = new ilCalendarMonthGUI(new ilDate($_GET["seed"], IL_CAL_DATE));
             $this->ctrl->forwardCommand($month);
             break;
         case "ilcalendarweekgui":
             $this->setActiveTabRegardingPrivilege();
             $week = new ilCalendarweekGUI(new ilDate($_GET["seed"], IL_CAL_DATE));
             $this->ctrl->forwardCommand($week);
             break;
         case "ilcalendarblockgui":
             $this->setActiveTabRegardingPrivilege();
             $this->ctrl->forwardCommand($this->cal);
             break;
             // Standard cmd handling if cmd is none of the above. In that case, the next page is
             // appointments.
         // Standard cmd handling if cmd is none of the above. In that case, the next page is
         // appointments.
         default:
             $cmd = $ilCtrl->getCmd('render');
             $this->{$cmd}();
             $has_calendar = true;
             break;
     }
     // Action menu (top right corner of the module)
     $this->addHeaderAction();
     if (ilCalendarSettings::_getInstance()->isEnabled() && $has_calendar) {
         //adds Minicalendar to the right if active
         $tpl->setRightContent($this->cal->getHTML());
     }
     $tpl->addCss(ilUtil::getStyleSheetLocation('filesystem', 'delos.css', 'Services/Calendar'));
     return true;
 }
 /**
  * Save news and external webfeeds settings
  */
 public function saveSettings()
 {
     global $ilCtrl, $ilSetting;
     $pd_set = new ilSetting("pd");
     ilCalendarSettings::_getInstance()->setEnabled($_POST["enable_calendar"]);
     ilCalendarSettings::_getInstance()->save();
     #$ilSetting->set("enable_calendar", $_POST["enable_calendar"]);
     $ilSetting->set("disable_bookmarks", (int) ($_POST["enable_bookmarks"] ? 0 : 1));
     $ilSetting->set("disable_contacts", (int) ($_POST["enable_contacts"] ? 0 : 1));
     $ilSetting->set("disable_contacts_require_mail", (int) ($_POST["enable_contacts_require_mail"] ? 0 : 1));
     $ilSetting->set("disable_notes", (int) ($_POST["enable_notes"] ? 0 : 1));
     $ilSetting->set("disable_comments", (int) ($_POST["enable_comments"] ? 0 : 1));
     $ilSetting->set("block_activated_chatviewer", (int) $_POST["block_activated_chatviewer"]);
     $ilSetting->set("block_activated_pdusers", $_POST["block_activated_pdusers"]);
     $pd_set->set("enable_block_moving", $_POST["enable_block_moving"]);
     $pd_set->set("user_activity_time", (int) $_POST["time_removal"]);
     $pd_set->set("osi_host", $_POST["osi_host"]);
     // Validate personal desktop view
     if (!(int) $_POST['enable_my_offers'] && !(int) $_POST['enable_my_memberships']) {
         ilUtil::sendFailure($this->lng->txt('pd_view_select_at_least_one'), true);
         $ilCtrl->redirect($this, 'view');
     }
     // Enable 'My Offers' (default personal items)
     $ilSetting->set('disable_my_offers', (int) ($_POST['enable_my_offers'] ? 0 : 1));
     // Enable 'My Memberships'
     $ilSetting->set('disable_my_memberships', (int) ($_POST['enable_my_memberships'] ? 0 : 1));
     if ((int) $_POST['enable_my_offers'] && !(int) $_POST['enable_my_memberships']) {
         $_POST['personal_items_default_view'] = 0;
     } else {
         if (!(int) $_POST['enable_my_offers'] && (int) $_POST['enable_my_memberships']) {
             $_POST['personal_items_default_view'] = 1;
         } else {
             if (!isset($_POST['personal_items_default_view'])) {
                 $_POST['personal_items_default_view'] = $ilSetting->get('personal_items_default_view');
             }
         }
     }
     // Default view of personal items
     $ilSetting->set('personal_items_default_view', (int) $_POST['personal_items_default_view']);
     // without personal workspace we have to disable to sub-items
     if (!$_POST["wsp"]) {
         $_POST["blog"] = 0;
         $_POST["file"] = 0;
         $_POST["cert"] = 0;
         $_POST["link"] = 0;
     }
     $ilSetting->set('disable_personal_workspace', (int) ($_POST['wsp'] ? 0 : 1));
     $ilSetting->set('disable_wsp_blogs', (int) ($_POST['blog'] ? 0 : 1));
     $ilSetting->set('disable_wsp_files', (int) ($_POST['file'] ? 0 : 1));
     $ilSetting->set('disable_wsp_certificates', (int) ($_POST['cert'] ? 0 : 1));
     $ilSetting->set('disable_wsp_links', (int) ($_POST['link'] ? 0 : 1));
     $ilSetting->set('user_portfolios', (int) ($_POST['prtf'] ? 1 : 0));
     ilUtil::sendSuccess($this->lng->txt("settings_saved"), true);
     $ilCtrl->redirect($this, "view");
 }