/**
  * Get singleton instance
  *
  * @return ilECSServerSettings
  */
 public static function getInstance()
 {
     if (self::$instance) {
         return self::$instance;
     }
     return self::$instance = new ilECSServerSettings();
 }
 /**
  * Parse available servers
  * @param ilECSServerSettings $servers
  */
 public function parse(ilECSServerSettings $servers)
 {
     $rows = array();
     foreach ($servers->getServers() as $server_id => $server) {
         $tmp['server_id'] = $server->getServerId();
         $tmp['active'] = $server->isEnabled();
         $rows[] = $tmp;
     }
     $this->setData($rows);
 }
 /**
  * set sub tabs
  *
  * @access protected
  */
 protected function setSubTabs()
 {
     $this->tabs_gui->clearSubTabs();
     $this->tabs_gui->addSubTabTarget("overview", $this->ctrl->getLinkTarget($this, 'overview'), "overview", get_class($this));
     // Disable all other tabs, if server hasn't been configured.
     ilECSServerSettings::getInstance()->readInactiveServers();
     if (!ilECSServerSettings::getInstance()->serverExists()) {
         return true;
     }
     $this->tabs_gui->addSubTabTarget("ecs_communities", $this->ctrl->getLinkTarget($this, 'communities'), "communities", get_class($this));
     $this->tabs_gui->addSubTabTarget('ecs_mappings', $this->ctrl->getLinkTarget($this, 'importMappings'), 'importMappings', get_class($this));
     $this->tabs_gui->addSubTabTarget('ecs_category_mapping', $this->ctrl->getLinkTarget($this, 'categoryMapping'));
     $this->tabs_gui->addSubTabTarget('ecs_import', $this->ctrl->getLinkTarget($this, 'imported'));
     $this->tabs_gui->addSubTabTarget('ecs_released', $this->ctrl->getLinkTarget($this, 'released'));
 }
 /**
  * add standard object section
  */
 function addObjectSections()
 {
     global $lng, $ilCtrl, $ilUser, $ilAccess, $tree, $ilSetting, $ilObjDataCache;
     $this->addSection($lng->txt("additional_info"));
     $a_obj = $this->gui_object->object;
     // links to the object
     if (is_object($a_obj)) {
         // permanent link
         $type = $a_obj->getType();
         $ref_id = $a_obj->getRefId();
         if ($ref_id) {
             include_once './Services/Link/classes/class.ilLink.php';
             $href = ilLink::_getStaticLink($ref_id, $type, true);
             include_once 'Services/WebServices/ECS/classes/class.ilECSServerSettings.php';
             if (ilECSServerSettings::getInstance()->activeServerExists()) {
                 $this->addProperty($lng->txt("object_id"), $a_obj->getId());
             }
             include_once 'Services/PermanentLink/classes/class.ilPermanentLinkGUI.php';
             $pm = new ilPermanentLinkGUI($type, $ref_id);
             $pm->setIncludePermanentLinkText(false);
             $pm->setAlignCenter(false);
             $this->addProperty($lng->txt("perma_link"), $pm->getHTML(), "");
             // bookmarks
             $title = $ilObjDataCache->lookupTitle($a_obj->getId());
             $bms = ilPermanentLinkGUI::_getBookmarksSelectionList($title, $href);
             // links to resource
             if ($ilAccess->checkAccess("write", "", $ref_id) || $ilAccess->checkAccess("edit_permissions", "", $ref_id)) {
                 $obj_id = $a_obj->getId();
                 $rs = ilObject::_getAllReferences($obj_id);
                 $refs = array();
                 foreach ($rs as $r) {
                     if ($tree->isInTree($r)) {
                         $refs[] = $r;
                     }
                 }
                 if (count($refs) > 1) {
                     $links = $sep = "";
                     foreach ($refs as $r) {
                         $cont_loc = new ilLocatorGUI();
                         $cont_loc->addContextItems($r, true);
                         $links .= $sep . $cont_loc->getHTML();
                         $sep = "<br />";
                     }
                     $this->addProperty($lng->txt("res_links"), '<div class="small">' . $links . '</div>');
                 }
             }
         }
     }
     // creation date
     $this->addProperty($lng->txt("create_date"), ilDatePresentation::formatDate(new ilDateTime($a_obj->getCreateDate(), IL_CAL_DATETIME)));
     // owner
     if ($ilUser->getId() != ANONYMOUS_USER_ID and $a_obj->getOwner()) {
         include_once './Services/Object/classes/class.ilObjectFactory.php';
         include_once './Services/User/classes/class.ilObjUser.php';
         if (ilObjUser::userExists(array($a_obj->getOwner()))) {
             $ownerObj = ilObjectFactory::getInstanceByObjId($a_obj->getOwner(), false);
         } else {
             $ownerObj = ilObjectFactory::getInstanceByObjId(6, false);
         }
         if (!is_object($ownerObj) || $ownerObj->getType() != "usr") {
             $this->addProperty($lng->txt("owner"), $lng->txt("no_owner"));
         } else {
             if ($ownerObj->hasPublicProfile()) {
                 $ilCtrl->setParameterByClass("ilpublicuserprofilegui", "user_id", $ownerObj->getId());
                 $this->addProperty($lng->txt("owner"), $ownerObj->getPublicName(), $ilCtrl->getLinkTargetByClass("ilpublicuserprofilegui", "getHTML"));
             } else {
                 $this->addProperty($lng->txt("owner"), $ownerObj->getPublicName());
             }
         }
     }
     // disk usage
     require_once 'Services/WebDAV/classes/class.ilDiskQuotaActivationChecker.php';
     if ($ilUser->getId() != ANONYMOUS_USER_ID && ilDiskQuotaActivationChecker::_isActive()) {
         $size = $a_obj->getDiskUsage();
         if ($size !== null) {
             $this->addProperty($lng->txt("disk_usage"), ilFormat::formatSize($size, 'long'));
         }
     }
     // change event
     require_once 'Services/Tracking/classes/class.ilChangeEvent.php';
     if (ilChangeEvent::_isActive()) {
         if ($ilUser->getId() != ANONYMOUS_USER_ID) {
             $readEvents = ilChangeEvent::_lookupReadEvents($a_obj->getId());
             $count_users = 0;
             $count_members = 0;
             $count_user_reads = 0;
             $count_anonymous_reads = 0;
             foreach ($readEvents as $evt) {
                 if ($evt['usr_id'] == ANONYMOUS_USER_ID) {
                     $count_anonymous_reads += $evt['read_count'];
                 } else {
                     $count_user_reads += $evt['read_count'];
                     $count_users++;
                     /* to do: if ($evt['user_id'] is member of $this->getRefId())
                     			{
                     				$count_members++;
                     			}*/
                 }
             }
             if ($count_anonymous_reads > 0) {
                 $this->addProperty($this->lng->txt("readcount_anonymous_users"), $count_anonymous_reads);
             }
             if ($count_user_reads > 0) {
                 $this->addProperty($this->lng->txt("readcount_users"), $count_user_reads);
             }
             if ($count_users > 0) {
                 $this->addProperty($this->lng->txt("accesscount_registered_users"), $count_users);
             }
         }
     }
     // END ChangeEvent: Display change event info
     // BEGIN WebDAV: Display locking information
     require_once 'Services/WebDAV/classes/class.ilDAVServer.php';
     if (ilDAVServer::_isActive()) {
         global $ilias, $ilUser;
         if ($ilUser->getId() != ANONYMOUS_USER_ID) {
             $davLocks = new ilDAVLocks();
             // Show lock info
             if ($ilias->account->getId() != ANONYMOUS_USER_ID) {
                 $locks =& $davLocks->getLocksOnObjectObj($a_obj->getId());
                 if (count($locks) > 0) {
                     $lockUser = new ilObjUser($locks[0]['ilias_owner']);
                     $this->addProperty($this->lng->txt("in_use_by"), $lockUser->getPublicName(), "./ilias.php?user=" . $locks[0]['ilias_owner'] . '&cmd=showUserProfile&cmdClass=ilpersonaldesktopgui&cmdNode=1&baseClass=ilPersonalDesktopGUI');
                 }
             }
         }
     }
     // END WebDAV: Display locking information
 }
 /**
  * handle delete
  * Objects that are moved to the trash call ECS-Remove
  * 
  * @see ilRepUtil	 
  * @param array $a_subbtree_nodes
  */
 public static function _handleDelete(array $a_subbtree_nodes)
 {
     // active?
     include_once './Services/WebServices/ECS/classes/class.ilECSServerSettings.php';
     if (!ilECSServerSettings::getInstance()->activeServerExists()) {
         return;
     }
     include_once './Services/WebServices/ECS/classes/class.ilECSSetting.php';
     include_once './Services/WebServices/ECS/classes/class.ilECSExport.php';
     $exported = ilECSExport::getExportedIds();
     foreach ($a_subbtree_nodes as $node) {
         if (in_array($node['obj_id'], $exported)) {
             if ($content_obj = ilObjectFactory::getInstanceByRefId($node['child'], false)) {
                 $settings = self::getInstanceByObject($content_obj);
                 // Read export server ids
                 foreach (ilECSExport::getExportServerIds($node['obj_id']) as $sid) {
                     $server = ilECSSetting::getInstanceByServerId($sid);
                     $export_settings = new ilECSExport($sid, $content_obj->getId());
                     $settings->doDelete($server, $export_settings);
                 }
             }
         }
     }
 }
 /**
  * handle ecs definitions
  *
  * @access private
  * @param object ilAdvMDFieldDefinition
  * @return
  */
 private function handleECSDefinitions($a_definition)
 {
     include_once './Services/WebServices/ECS/classes/class.ilECSDataMappingSettings.php';
     include_once './Services/WebServices/ECS/classes/class.ilECSServerSettings.php';
     if (ilECSServerSettings::getInstance()->activeServerExists() or $this->obj_type != 'crs' and $this->obj_type != 'rcrs') {
         return false;
     }
     return false;
     /*
     $mapping = ilECSDataMappingSettings::_getInstance();
     
     if($mapping->getMappingByECSName(ilECSDataMappingSetting::MAPPING_IMPORT_RCRS, 'begin') == $a_definition->getFieldId())
     {
     	$this->showECSStart($a_definition);
     	return true;
     }
     if($mapping->getMappingByECSName(ilECSDataMappingSetting::MAPPING_IMPORT_RCRS, 'end') == $a_definition->getFieldId())
     {
     	return true;
     }
     if($mapping->getMappingByECSName(ilECSDataMappingSetting::MAPPING_IMPORT_RCRS, 'cycle') == $a_definition->getFieldId())
     {
     	return true;
     }
     if($mapping->getMappingByECSName(ilECSDataMappingSetting::MAPPING_IMPORT_RCRS, 'room') == $a_definition->getFieldId())
     {
     	return true;
     }
     */
 }
 /**
  * Init ECS Services
  * @access private
  * @param
  * 
  */
 private function initECSServices()
 {
     include_once './Services/WebServices/ECS/classes/class.ilECSServerSettings.php';
     $this->servers = ilECSServerSettings::getInstance();
 }
 /**
  * Static version iterates over all active instances
  */
 public static function startExecution()
 {
     include_once './Services/WebServices/ECS/classes/class.ilECSServerSettings.php';
     $server = ilECSServerSettings::getInstance();
     foreach ($server->getServers() as $server) {
         $sched = new ilECSTaskScheduler($server);
         $sched->startTaskExecution();
     }
 }
 function _getActiveAuthModes()
 {
     global $ilias, $ilSetting;
     $modes = array('default' => $ilSetting->get("auth_mode"), 'local' => AUTH_LOCAL);
     include_once 'Services/LDAP/classes/class.ilLDAPServer.php';
     if (count(ilLDAPServer::_getActiveServerList())) {
         $modes['ldap'] = AUTH_LDAP;
     }
     if ($ilSetting->get("radius_active")) {
         $modes['radius'] = AUTH_RADIUS;
     }
     if ($ilSetting->get("shib_active")) {
         $modes['shibboleth'] = AUTH_SHIBBOLETH;
     }
     if ($ilSetting->get("script_active")) {
         $modes['script'] = AUTH_SCRIPT;
     }
     if ($ilSetting->get("cas_active")) {
         $modes['cas'] = AUTH_CAS;
     }
     if ($ilSetting->get("soap_auth_active")) {
         $modes['soap'] = AUTH_SOAP;
     }
     if ($ilSetting->get("apache_active")) {
         $modes['apache'] = AUTH_APACHE;
     }
     include_once './Services/WebServices/ECS/classes/class.ilECSServerSettings.php';
     if (ilECSServerSettings::getInstance()->activeServerExists()) {
         $modes['ecs'] = AUTH_ECS;
     }
     include_once './Services/OpenId/classes/class.ilOpenIdSettings.php';
     if (ilOpenIdSettings::getInstance()->isActive()) {
         $modes['openid'] = AUTH_OPENID;
     }
     // begin-path auth_plugin
     foreach (self::getAuthPlugins() as $pl) {
         foreach ($pl->getAuthIds() as $auth_id) {
             if ($pl->isAuthActive($auth_id)) {
                 $modes[$pl->getAuthName($auth_id)] = $auth_id;
             }
         }
     }
     // end-path auth_plugin
     return $modes;
 }