/**
  * Is ECS (for current object) active?
  * 
  * @return boolean 
  */
 protected function isActive()
 {
     include_once './Services/WebServices/ECS/classes/class.ilECSServerSettings.php';
     if (ilECSServerSettings::getInstance()->activeServerExists()) {
         // imported objects cannot be exported
         include_once './Services/WebServices/ECS/classes/class.ilECSImport.php';
         if (!ilECSImport::lookupServerId($this->content_obj->getId())) {
             return true;
         }
     }
     return false;
 }
 /**
  * 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;
     }
 }
 /**
  * Parse
  *
  * @access public
  * @param array array of remote course ids
  * 
  */
 public function parse($a_rcrs)
 {
     global $ilObjDataCache;
     // Preload object data
     $ilObjDataCache->preloadReferenceCache($a_rcrs);
     // Read participants
     include_once './Modules/RemoteCourse/classes/class.ilObjRemoteCourse.php';
     include_once './Services/WebServices/ECS/classes/class.ilECSCommunityReader.php';
     include_once './Services/WebServices/ECS/classes/class.ilECSImport.php';
     // read obj_ids
     $obj_ids = array();
     foreach ($a_rcrs as $rcrs_ref_id) {
         $obj_id = $ilObjDataCache->lookupObjId($rcrs_ref_id);
         $obj_ids[$obj_id] = $ilObjDataCache->lookupObjId($rcrs_ref_id);
     }
     foreach ($obj_ids as $obj_id => $obj_id) {
         $tmp_arr['obj_id'] = $obj_id;
         $tmp_arr['sid'] = ilECSImport::lookupServerId($obj_id);
         $tmp_arr['title'] = $ilObjDataCache->lookupTitle($obj_id);
         $tmp_arr['desc'] = $ilObjDataCache->lookupDescription($obj_id);
         $tmp_arr['md'] = '';
         $mid = ilObjRemoteCourse::_lookupMID($obj_id);
         if ($tmp_arr['sid']) {
             try {
                 $reader = ilECSCommunityReader::getInstanceByServerId($tmp_arr['sid']);
             } catch (ilECSConnectorException $e) {
                 $reader = null;
             }
             if ($reader and $participant = $reader->getParticipantByMID($mid)) {
                 $tmp_arr['from'] = $participant->getParticipantName();
                 $tmp_arr['from_info'] = $participant->getDescription();
             }
         } else {
             $tmp_arr['from'] = $this->lng->txt("ecs_server_deleted");
         }
         $tmp_arr['last_update'] = $ilObjDataCache->lookupLastUpdate($obj_id);
         $content[] = $tmp_arr;
     }
     $this->setData($content ? $content : array());
 }
 /**
  * get command frame
  *
  * @access public
  * @param
  * @return
  */
 public function getCommandFrame($a_cmd)
 {
     switch ($a_cmd) {
         case 'show':
             include_once './Services/WebServices/ECS/classes/class.ilECSExport.php';
             include_once './Services/WebServices/ECS/classes/class.ilECSImport.php';
             if (ilECSExport::_isRemote(ilECSImport::lookupServerId($this->obj_id), ilECSImport::_lookupEContentId($this->obj_id))) {
                 return '_blank';
             }
         default:
             return parent::getCommandFrame($a_cmd);
     }
 }
 /**
  * Is remote object from same installation?
  * 
  * @return boolean 
  */
 public function isLocalObject()
 {
     include_once './Services/WebServices/ECS/classes/class.ilECSExport.php';
     include_once './Services/WebServices/ECS/classes/class.ilECSImport.php';
     if (ilECSExport::_isRemote(ilECSImport::lookupServerId($this->getId()), ilECSImport::_lookupEContentId($this->getId()))) {
         return false;
     }
     return true;
 }
 /**
  * Init server settings
  * @param type $a_usr_id
  */
 protected static function initServer($a_usr_id)
 {
     include_once './Services/WebServices/ECS/classes/class.ilECSImport.php';
     $server_id = ilECSImport::lookupServerId($a_usr_id);
     include_once 'Services/WebServices/ECS/classes/class.ilECSSetting.php';
     $settings = ilECSSetting::getInstanceByServerId($server_id);
     return $settings;
 }