/**
  * 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;
 }
 /**
  * Delete tree
  */
 protected function dDeleteTree()
 {
     include_once './Services/WebServices/ECS/classes/Tree/class.ilECSCmsData.php';
     include_once './Services/WebServices/ECS/classes/Tree/class.ilECSCmsTree.php';
     $GLOBALS['ilLog']->write('Deleting tree');
     $tree = new ilECSCmsTree((int) $_REQUEST['tid']);
     $tree->deleteTree($tree->getNodeData(ilECSCmsTree::lookupRootId((int) $_REQUEST['tid'])));
     // also delete import information
     include_once './Services/WebServices/ECS/classes/class.ilECSImport.php';
     ilECSImport::deleteRessources($this->getServer()->getServerId(), $this->getMid(), ilECSCmsData::lookupCmsIdsOfTree($this->getServer()->getServerId(), $this->getMid(), (int) $_REQUEST['tid']));
     $data = new ilECSCmsData();
     $data->setServerId($this->getServer()->getServerId());
     $data->setMid($this->getMid());
     $data->setTreeId((int) $_REQUEST['tid']);
     $data->deleteTree();
     include_once './Services/WebServices/ECS/classes/Mapping/class.ilECSNodeMappingAssignments.php';
     ilECSNodeMappingAssignments::deleteMappings($this->getServer()->getServerId(), $this->getMid(), (int) $_REQUEST['tid']);
     ilUtil::sendSuccess($this->lng->txt('ecs_cms_tree_deleted'), true);
     $this->ctrl->redirect($this, 'dTrees');
 }
 /**
  * Set new course object imported
  * @param int $a_content_id
  * @param ilObjCourse $crs
  */
 protected function setImported($a_content_id, $object, $a_ecs_id = 0, $a_sub_id = 0)
 {
     include_once './Services/WebServices/ECS/classes/class.ilECSImport.php';
     $import = new ilECSImport($this->getServer()->getServerId(), is_object($object) ? $object->getId() : 0);
     $GLOBALS['ilLog']->write(__METHOD__ . ': Imported with ecs id ' . $a_ecs_id);
     $import->setSubId($a_sub_id);
     $import->setMID($this->getMid());
     $import->setEContentId($a_ecs_id);
     $import->setContentId($a_content_id);
     $import->setImported(true);
     $import->save();
     return true;
 }
 /**
  * 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());
 }
 /**
  * check if econtent is imported for a specific mid
  *
  * @access public
  * @static
  *
  * @param int econtent id
  * @param int mid
  */
 public static function _isImported($a_server_id, $a_econtent_id, $a_mid, $a_sub_id = 0)
 {
     return ilECSImport::_lookupObjId($a_server_id, $a_econtent_id, $a_mid, $a_sub_id);
 }
 /**
  * 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);
     }
 }
 /**
  * Perform update
  * @param type $a_content_id
  * @param type $course
  */
 protected function doUpdate($a_usr_id, ilECSEnrolmentStatus $status)
 {
     include_once './Services/WebServices/ECS/classes/class.ilECSImport.php';
     $obj_ids = ilECSImport::lookupObjIdsByContentId($status->getId());
     $obj_id = end($obj_ids);
     $ref_ids = ilObject::_getAllReferences($obj_id);
     $ref_id = end($ref_ids);
     if (!$ref_id) {
         // Remote object not found
         return TRUE;
     }
     switch ($status->getStatus()) {
         case ilECSEnrolmentStatus::STATUS_PENDING:
             // nothing todo in the moment: maybe send mail
             break;
         case ilECSEnrolmentStatus::STATUS_ACTIVE:
             $GLOBALS['ilLog']->write(__METHOD__ . ': Add desktop item: ' . $a_usr_id . ' ' . $ref_id . ' ' . $obj_id);
             ilObjUser::_addDesktopItem($a_usr_id, $ref_id, ilObject::_lookupType($obj_id));
             break;
         case ilECSEnrolmentStatus::STATUS_ACCOUNT_DEACTIVATED:
         case ilECSEnrolmentStatus::STATUS_DENIED:
         case ilECSEnrolmentStatus::STATUS_REJECTED:
         case ilECSEnrolmentStatus::STATUS_UNSUBSCRIBED:
             $GLOBALS['ilLog']->write(__METHOD__ . ': Remove desktop item: ' . $a_usr_id . ' ' . $ref_id . ' ' . $obj_id);
             ilObjUser::_dropDesktopItem($a_usr_id, $ref_id, ilObject::_lookupType($obj_id));
             break;
     }
     return TRUE;
 }
 /**
  * Do delete
  */
 protected function doDelete()
 {
     $this->initSettings($_REQUEST['server_id']);
     $this->settings->delete();
     // Delete communities
     include_once './Services/WebServices/ECS/classes/class.ilECSCommunitiesCache.php';
     ilECSCommunitiesCache::delete((int) $_REQUEST['server_id']);
     include_once './Services/WebServices/ECS/classes/class.ilECSDataMappingSettings.php';
     ilECSDataMappingSettings::delete((int) $_REQUEST['server_id']);
     include_once './Services/WebServices/ECS/classes/class.ilECSEventQueueReader.php';
     ilECSEventQueueReader::deleteServer((int) $_REQUEST['server_id']);
     include_once './Services/WebServices/ECS/classes/class.ilECSExport.php';
     ilECSExport::deleteByServer((int) $_REQUEST['server_id']);
     include_once './Services/WebServices/ECS/classes/class.ilECSImport.php';
     ilECSImport::deleteByServer((int) $_REQUEST['server_id']);
     include_once './Services/WebServices/ECS/classes/class.ilECSParticipantSettings.php';
     ilECSParticipantSettings::deleteByServer((int) $_REQUEST['server_id']);
     ilUtil::sendSuccess($this->lng->txt('ecs_setting_deleted'), true);
     $this->ctrl->redirect($this, 'overview');
 }
 /**
  * delete object or referenced object
  * (in the case of a referenced object, object data is only deleted
  * if last reference is deleted)
  * This function removes an object entirely from system!!
  *
  * @access	public
  * @return	boolean	true if object was removed completely; false if only a references was removed
  */
 function delete()
 {
     global $rbacadmin, $log, $ilDB;
     $remove = false;
     // delete object_data entry
     if (!$this->referenced || $this->countReferences() == 1) {
         // check type match
         $db_type = ilObject::_lookupType($this->getId());
         if ($this->type != $db_type) {
             $message = "ilObject::delete(): Type mismatch. Object with obj_id: " . $this->id . " " . "was instantiated by type '" . $this->type . "'. DB type is: " . $db_type;
             // write log entry
             $log->write($message);
             // raise error
             $this->ilias->raiseError("ilObject::delete(): Type mismatch. (" . $this->type . "/" . $this->id . ")", $this->ilias->error_obj->WARNING);
         }
         // delete entry in object_data
         $q = "DELETE FROM object_data " . "WHERE obj_id = " . $ilDB->quote($this->getId(), "integer");
         $ilDB->manipulate($q);
         // delete long description
         $query = "DELETE FROM object_description WHERE obj_id = " . $ilDB->quote($this->getId(), "integer");
         $ilDB->manipulate($query);
         // write log entry
         $log->write("ilObject::delete(), deleted object, obj_id: " . $this->getId() . ", type: " . $this->getType() . ", title: " . $this->getTitle());
         // remove news
         include_once "./Services/News/classes/class.ilNewsItem.php";
         $news_item = new ilNewsItem();
         $news_item->deleteNewsOfContext($this->getId(), $this->getType());
         include_once "./Services/Block/classes/class.ilBlockSetting.php";
         ilBlockSetting::_deleteSettingsOfBlock($this->getId(), "news");
         include_once './Services/DidacticTemplate/classes/class.ilDidacticTemplateObjSettings.php';
         ilDidacticTemplateObjSettings::deleteByObjId($this->getId());
         /* remove notes (see infoscreen gui)
         			   as they can be seen as personal data we are keeping them for now
         			include_once("Services/Notes/classes/class.ilNote.php");
         			foreach(array(IL_NOTE_PRIVATE, IL_NOTE_PUBLIC) as $note_type)
         			{
         				foreach(ilNote::_getNotesOfObject($this->id, 0, $this->type, $note_type) as $note)
         				{
         					$note->delete();
         				}
         			}
         		    */
         // BEGIN WebDAV: Delete WebDAV properties
         $query = "DELETE FROM dav_property " . "WHERE obj_id = " . $ilDB->quote($this->getId(), 'integer');
         $res = $ilDB->manipulate($query);
         // END WebDAV: Delete WebDAV properties
         include_once './Services/Tracking/classes/class.ilChangeEvent.php';
         ilChangeEvent::_delete($this->getId());
         include_once './Services/Tracking/classes/class.ilLPCollections.php';
         ilLPCollections::_deleteAll($this->getId());
         include_once './Services/WebServices/ECS/classes/class.ilECSImport.php';
         ilECSImport::_deleteByObjId($this->getId());
         $remove = true;
     } else {
         // write log entry
         $log->write("ilObject::delete(), object not deleted, number of references: " . $this->countReferences() . ", obj_id: " . $this->getId() . ", type: " . $this->getType() . ", title: " . $this->getTitle());
     }
     // delete object_reference entry
     if ($this->referenced) {
         include_once "Services/Object/classes/class.ilObjectActivation.php";
         ilObjectActivation::deleteAllEntries($this->getRefId());
         // delete entry in object_reference
         $query = "DELETE FROM object_reference " . "WHERE ref_id = " . $ilDB->quote($this->getRefId(), 'integer');
         $res = $ilDB->manipulate($query);
         // write log entry
         $log->write("ilObject::delete(), reference deleted, ref_id: " . $this->getRefId() . ", obj_id: " . $this->getId() . ", type: " . $this->getType() . ", title: " . $this->getTitle());
         // DELETE PERMISSION ENTRIES IN RBAC_PA
         // DONE: method overwritten in ilObjRole & ilObjUser.
         // this call only applies for objects in rbac (not usr,role,rolt)
         // TODO: Do this for role templates too
         $rbacadmin->revokePermission($this->getRefId(), 0, false);
         include_once "Services/AccessControl/classes/class.ilRbacLog.php";
         ilRbacLog::delete($this->getRefId());
         // Remove applied didactic template setting
         include_once './Services/DidacticTemplate/classes/class.ilDidacticTemplateObjSettings.php';
         ilDidacticTemplateObjSettings::deleteByRefId($this->getRefId());
         // Remove desktop items
         ilUtil::removeItemFromDesktops($this->getRefId());
     }
     // remove conditions
     if ($this->referenced) {
         $ch =& new ilConditionHandler();
         $ch->delete($this->getRefId());
         unset($ch);
     }
     return $remove;
 }
Esempio n. 10
0
 /**
  * Delete
  */
 public function delete()
 {
     global $ilDB;
     // --- cascading delete
     include_once 'Services/WebServices/ECS/classes/Tree/class.ilECSCmsData.php';
     ilECSCmsData::deleteByServerId($this->getServerId());
     include_once 'Services/WebServices/ECS/classes/class.ilECSCommunityCache.php';
     ilECSCommunityCache::deleteByServerId($this->getServerId());
     include_once 'Services/WebServices/ECS/classes/class.ilECSDataMappingSetting.php';
     ilECSDataMappingSetting::deleteByServerId($this->getServerId());
     include_once 'Services/WebServices/ECS/classes/class.ilECSEventQueueReader.php';
     ilECSEventQueueReader::deleteByServerId($this->getServerId());
     include_once 'Services/WebServices/ECS/classes/Mapping/class.ilECSNodeMappingAssignment.php';
     ilECSNodeMappingAssignment::deleteByServerId($this->getServerId());
     include_once 'Services/WebServices/ECS/classes/class.ilECSParticipantSetting.php';
     ilECSParticipantSetting::deleteByServerId($this->getServerId());
     include_once 'Services/WebServices/ECS/classes/class.ilECSExport.php';
     ilECSExport::deleteByServerId($this->getServerId());
     // resetting server id to flag items in imported list
     include_once 'Services/WebServices/ECS/classes/class.ilECSImport.php';
     ilECSImport::resetServerId($this->getServerId());
     $ilDB->manipulate('DELETE FROM ecs_server ' . 'WHERE server_id = ' . $ilDB->quote($this->getServerId(), 'integer'));
     $this->server_id = NULL;
     return true;
 }
Esempio n. 11
0
 protected function updateCustomFromECSContent(ilECSSetting $a_server, $a_ecs_content)
 {
     // add custom values
     $this->setAvailabilityType($a_ecs_content->status == 'online' ? self::ACTIVATION_UNLIMITED : self::ACTIVATION_OFFLINE);
     // :TODO: ACTIVATION_LIMITED is currently not supported in ECS yet
     // adv. metadata
     include_once './Services/WebServices/ECS/classes/class.ilECSUtils.php';
     include_once './Services/WebServices/ECS/classes/class.ilECSDataMappingSetting.php';
     $definition = ilECSUtils::getEContentDefinition($this->getECSObjectType());
     $this->importMetadataFromJson($a_ecs_content, $a_server, $definition, ilECSDataMappingSetting::MAPPING_IMPORT_RCRS);
     include_once './Services/WebServices/ECS/classes/class.ilECSImport.php';
     $import = new ilECSImport($a_server->getServerId(), $this->getId());
     $import->setContentId($a_ecs_content->courseID);
     $import->save();
 }
 /**
  * send notification about new user accounts
  *
  * @access protected
  */
 protected static function _sendNotification(ilECSSetting $server, ilObjUser $user_obj)
 {
     if (!count($server->getUserRecipients())) {
         return true;
     }
     // If sub id is set => mail was send
     include_once './Services/WebServices/ECS/classes/class.ilECSImport.php';
     $import = new ilECSImport($server->getServerId(), $user_obj->getId());
     if ($import->getSubId()) {
         return false;
     }
     include_once './Services/Language/classes/class.ilLanguageFactory.php';
     $lang = ilLanguageFactory::_getLanguage();
     $lang->loadLanguageModule('ecs');
     include_once './Services/Mail/classes/class.ilMail.php';
     $mail = new ilMail(6);
     $mail->enableSoap(false);
     $subject = $lang->txt('ecs_new_user_subject');
     // build body
     $body = $lang->txt('ecs_new_user_body') . "\n\n";
     $body .= $lang->txt('ecs_new_user_profile') . "\n\n";
     $body .= $user_obj->getProfileAsString($lang) . "\n\n";
     $body .= ilMail::_getAutoGeneratedMessageString($lang);
     $mail->sendMail($server->getUserRecipientsAsString(), "", "", $subject, $body, array(), array("normal"));
     // Store sub_id = 1 in ecs import which means mail is send
     $import->setSubId(1);
     $import->save();
     return true;
 }
 /** 
  * Called from base class after successful login
  *
  * @param string username
  */
 public function loginObserver($a_username, $a_auth)
 {
     include_once './Services/WebServices/ECS/classes/class.ilECSUser.php';
     $user = new ilECSUser($_GET);
     if (!($usr_id = ilObject::_lookupObjIdByImportId($user->getImportId()))) {
         $username = $this->createUser($user);
     } else {
         $username = $this->updateUser($user, $usr_id);
     }
     // set user imported
     include_once './Services/WebServices/ECS/classes/class.ilECSImport.php';
     $import = new ilECSImport($this->getCurrentServer()->getServerId(), $usr_id);
     $import->save();
     $a_auth->setAuth($username);
     $this->log->write(__METHOD__ . ': Login succesesful');
     return true;
 }
 /** 
  * Called from base class after successful login
  *
  * @param string username
  */
 public function loginObserver($a_username, $a_auth)
 {
     include_once './Services/WebServices/ECS/classes/class.ilECSUser.php';
     $user = new ilECSUser($_GET);
     if (!($usr_id = ilObject::_lookupObjIdByImportId($user->getImportId()))) {
         $username = $this->createUser($user);
     } else {
         $username = $this->updateUser($user, $usr_id);
     }
     // set user imported
     include_once './Services/WebServices/ECS/classes/class.ilECSImport.php';
     $import = new ilECSImport($this->getCurrentServer()->getServerId(), $usr_id);
     $import->save();
     // Store remote user data
     include_once './Services/WebServices/ECS/classes/class.ilECSRemoteUser.php';
     $remote = new ilECSRemoteUser();
     $remote->setServerId($this->getCurrentServer()->getServerId());
     $remote->setMid($this->getMID());
     $remote->setRemoteUserId($user->getImportId());
     $remote->setUserId(ilObjUser::_lookupId($username));
     $GLOBALS['ilLog']->write(__METHOD__ . ': Current username ' . $username);
     if (!$remote->exists()) {
         $remote->create();
     }
     $a_auth->setAuth($username);
     $this->log->write(__METHOD__ . ': Login succesesful');
     return true;
 }
 /**
  * Reread all imported econtent.
  *
  * @return bool
  * @static
  * throws ilException, ilECSConnectorException
  */
 public static function handleImportReset(ilECSSetting $server)
 {
     global $ilLog;
     include_once 'Services/WebServices/ECS/classes/class.ilECSConnector.php';
     include_once 'Services/WebServices/ECS/classes/class.ilECSConnectorException.php';
     try {
         include_once './Services/WebServices/ECS/classes/class.ilECSEventQueueReader.php';
         include_once './Services/WebServices/ECS/classes/class.ilECSImport.php';
         include_once './Services/WebServices/ECS/classes/class.ilECSExport.php';
         $types = self::getAllEContentTypes();
         $event_queue = new ilECSEventQueueReader($server->getServerId());
         $event_queue->deleteAllEContentEvents($types);
         $list = self::getAllResourceIds($server, $types);
         $imported = ilECSImport::getAllImportedRemoteObjects($server->getServerId());
         $GLOBALS['ilLog']->write(__METHOD__ . ': Imported = ' . print_r($imported, true));
         $GLOBALS['ilLog']->write(__METHOD__ . ': List = ' . print_r($list, true));
         foreach ($list as $resource_type => $link_ids) {
             if (!in_array($resource_type, ilECSUtils::getPossibleRemoteTypes())) {
                 $GLOBALS['ilLog']->write(__METHOD__ . ': Ignoring resource type ' . $resource_type);
                 continue;
             }
             foreach ((array) $link_ids as $link_id) {
                 if (!isset($imported[$link_id])) {
                     // Add create event for not imported econtent
                     $event_queue->add($resource_type, $link_id, ilECSEvent::CREATED);
                 } else {
                     // Add update event for already existing events
                     $event_queue->add($resource_type, $link_id, ilECSEvent::UPDATED);
                 }
                 if (isset($imported[$link_id])) {
                     unset($imported[$link_id]);
                 }
             }
         }
         if (is_array($imported)) {
             // Delete event for deprecated econtent
             include_once 'Services/WebServices/ECS/classes/class.ilECSObjectSettings.php';
             foreach ($imported as $econtent_id => $obj_id) {
                 $type = self::getEventTypeFromObjectType(ilObject::_lookupType($obj_id));
                 if ($type) {
                     $event_queue->add($type, $econtent_id, ilECSEvent::DESTROYED);
                 }
             }
         }
     } catch (ilECSConnectorException $e1) {
         $ilLog->write('Cannot connect to ECS server: ' . $e1->getMessage());
         throw $e1;
     } catch (ilException $e2) {
         $ilLog->write('Update failed: ' . $e2->getMessage());
         throw $e2;
     }
     return true;
 }
 /**
  * Read course from ecs
  * @return boolean
  */
 private function readCourse($course_member)
 {
     try {
         include_once './Services/WebServices/ECS/classes/class.ilECSImport.php';
         $ecs_id = ilECSImport::lookupEContentIdByContentId($this->getServer()->getServerId(), $this->getMid(), $course_member->lectureID);
         include_once './Services/WebServices/ECS/classes/Course/class.ilECSCourseConnector.php';
         $crs_reader = new ilECSCourseConnector($this->getServer());
         return $crs_reader->getCourse($ecs_id);
     } catch (ilECSConnectorException $e) {
         throw $e;
     }
 }
 /**
  * Handle delete event
  * 
  * called by ilTaskScheduler
  * 
  * @param ilECSSetting $a_server
  * @param int $a_econtent_id
  * @param int $a_mid
  * @return boolean
  */
 public function handleDelete(ilECSSetting $a_server, $a_econtent_id, $a_mid = 0)
 {
     global $tree, $ilLog;
     include_once './Services/WebServices/ECS/classes/class.ilECSImport.php';
     // there is no information about the original mid anymore.
     // Therefor delete any remote objects with given econtent id
     $obj_ids = ilECSImport::_lookupObjIds($a_server->getServerId(), $a_econtent_id);
     $ilLog->write(__METHOD__ . ': Received obj_ids ' . print_r($obj_ids, true));
     foreach ($obj_ids as $obj_id) {
         $references = ilObject::_getAllReferences($obj_id);
         foreach ($references as $ref_id) {
             if ($tmp_obj = ilObjectFactory::getInstanceByRefId($ref_id, false)) {
                 $ilLog->write(__METHOD__ . ': Deleting obsolete remote course: ' . $tmp_obj->getTitle());
                 $tmp_obj->delete();
                 $tree->deleteTree($tree->getNodeData($ref_id));
             }
             unset($tmp_obj);
         }
     }
     return true;
 }
 /**
  * Sync category
  * @param ilECSNodeMappingAssignment $ass
  */
 protected function syncCategory(ilECSNodeMappingAssignment $ass, $parent_id)
 {
     include_once './Services/WebServices/ECS/classes/Tree/class.ilECSCmsData.php';
     $data = new ilECSCmsData($ass->getCSId());
     // Check if node is imported => create
     // perform title update
     // perform position update
     include_once './Services/WebServices/ECS/classes/class.ilECSImport.php';
     $obj_id = ilECSImport::lookupObjIdByContentId($this->getServer()->getServerId(), $this->mid, $data->getCmsId());
     if ($obj_id) {
         $refs = ilObject::_getAllReferences($obj_id);
         $ref_id = end($refs);
         $cat = ilObjectFactory::getInstanceByRefId($ref_id, false);
         if ($cat instanceof ilObject and $this->default_settings['title_update']) {
             $GLOBALS['ilLog']->write(__METHOD__ . ': Updating cms category ');
             $GLOBALS['ilLog']->write(__METHOD__ . ': Title is ' . $data->getTitle());
             $cat->deleteTranslation($GLOBALS['lng']->getDefaultLanguage());
             $cat->addTranslation($data->getTitle(), $cat->getLongDescription(), $GLOBALS['lng']->getDefaultLanguage(), 1);
             $cat->setTitle($data->getTitle());
             $cat->update();
         } else {
             $GLOBALS['ilLog']->write(__METHOD__ . ': Updating cms category -> nothing to do');
         }
         return $ref_id;
     } elseif ($this->getGlobalSettings()->isEmptyContainerCreationEnabled()) {
         $GLOBALS['ilLog']->write(__METHOD__ . ': Creating new cms category');
         // Create category
         include_once './Modules/Category/classes/class.ilObjCategory.php';
         $cat = new ilObjCategory();
         $cat->setTitle($data->getTitle());
         $cat->create();
         // true for upload
         $cat->createReference();
         $cat->putInTree($parent_id);
         $cat->setPermissions($parent_id);
         $cat->deleteTranslation($GLOBALS['lng']->getDEfaultLanguage());
         $cat->addTranslation($data->getTitle(), $cat->getLongDescription(), $GLOBALS['lng']->getDefaultLanguage(), 1);
         // set imported
         $import = new ilECSImport($this->getServer()->getServerId(), $cat->getId());
         $import->setMID($this->mid);
         $import->setContentId($data->getCmsId());
         $import->setImported(true);
         $import->save();
         return $cat->getRefId();
     } else {
         $GLOBALS['ilLog']->write(__METHOD__ . ': Creation of empty containers is disabled.');
         return 0;
     }
 }
 /**
  * Handle delete event
  * 
  * called by ilTaskScheduler
  * 
  * @param ilECSSetting $a_server
  * @param int $a_econtent_id
  * @param int $a_mid
  * @return boolean
  */
 public function handleDelete(ilECSSetting $a_server, $a_econtent_id, $a_mid = 0)
 {
     global $tree, $ilLog;
     include_once './Services/WebServices/ECS/classes/class.ilECSImport.php';
     // if mid is zero delete all obj_ids
     if (!$a_mid) {
         $obj_ids = ilECSImport::_lookupObjIds($a_server->getServerId(), $a_econtent_id);
     } else {
         $obj_ids = (array) ilECSImport::_lookupObjId($a_server->getServerId(), $a_econtent_id, $a_mid);
     }
     $ilLog->write(__METHOD__ . ': Received obj_ids ' . print_r($obj_ids, true));
     foreach ($obj_ids as $obj_id) {
         $references = ilObject::_getAllReferences($obj_id);
         foreach ($references as $ref_id) {
             if ($tmp_obj = ilObjectFactory::getInstanceByRefId($ref_id, false)) {
                 $ilLog->write(__METHOD__ . ': Deleting obsolete remote course: ' . $tmp_obj->getTitle());
                 $tmp_obj->delete();
                 $tree->deleteTree($tree->getNodeData($ref_id));
             }
             unset($tmp_obj);
         }
     }
     return true;
 }