コード例 #1
0
 /**
  * get singleton instance
  * Private access use
  * ilECSTaskScheduler::start() or
  * ilECSTaskScheduler::startTaskExecution
  *
  * @access private
  * @static
  *
  * @return ilECSTaskScheduler
  *
  */
 public static function _getInstanceByServerId($a_server_id)
 {
     if (self::$instances[$a_server_id]) {
         return self::$instances[$a_server_id];
     }
     include_once './Services/WebServices/ECS/classes/class.ilECSSetting.php';
     return self::$instances[$a_server_id] = new ilECSTaskScheduler(ilECSSetting::getInstanceByServerId($a_server_id));
 }
コード例 #2
0
 /**
  * Constructor
  * @param ilObjectGUI $settingsContainer
  */
 public function __construct($settingsContainer, $server_id, $mid)
 {
     global $lng, $ilCtrl;
     $this->container = $settingsContainer;
     $this->server = ilECSSetting::getInstanceByServerId($server_id);
     $this->mid = $mid;
     $this->lng = $lng;
     $this->lng->loadLanguageModule('ecs');
     $this->ctrl = $ilCtrl;
 }
コード例 #3
0
 /**
  * constructor
  *
  * @access public
  * @param
  * 
  */
 public function __construct(ilECSSetting $set, $a_parent_obj, $a_parent_cmd, $cid)
 {
     global $lng, $ilCtrl;
     $this->lng = $lng;
     $this->ctrl = $ilCtrl;
     // TODO: set id
     $this->setId($set->getServerId() . '_' . $cid . '_' . 'community_table');
     parent::__construct($a_parent_obj, $a_parent_cmd);
     $this->addColumn($this->lng->txt('ecs_participants'), 'participants', "35%");
     $this->addColumn($this->lng->txt('ecs_participants_infos'), 'infos', "35%");
     $this->addColumn($this->lng->txt('ecs_tbl_export'), 'export', '5%');
     $this->addColumn($this->lng->txt('ecs_tbl_import'), 'import', '5%');
     $this->addColumn($this->lng->txt('ecs_tbl_import_type'), 'type', '10%');
     $this->addColumn('', 'actions', '10%');
     $this->disable('form');
     $this->setRowTemplate("tpl.participant_row.html", "Services/WebServices/ECS");
     $this->setDefaultOrderField('participants');
     $this->setDefaultOrderDirection("desc");
     $this->cid = $cid;
     $this->server = $set;
 }
コード例 #4
0
 /**
  * Fill row
  * @staticvar int $counter
  * @param array $set 
  */
 public function fillRow($set)
 {
     global $ilCtrl;
     $ilCtrl->setParameter($this->getParentObject(), 'server_id', $set['server_id']);
     $ilCtrl->setParameterByClass('ilecsmappingsettingsgui', 'server_id', $set['server_id']);
     if ($set['active']) {
         $this->tpl->setVariable('IMAGE_OK', ilUtil::getImagePath('icon_ok.svg'));
         $this->tpl->setVariable('TXT_OK', $this->lng->txt('ecs_activated'));
     } else {
         $this->tpl->setVariable('IMAGE_OK', ilUtil::getImagePath('icon_not_ok.svg'));
         $this->tpl->setVariable('TXT_OK', $this->lng->txt('ecs_inactivated'));
     }
     $this->tpl->setVariable('VAL_TITLE', ilECSSetting::getInstanceByServerId($set['server_id'])->getTitle());
     $this->tpl->setVariable('LINK_EDIT', $ilCtrl->getLinkTarget($this->getParentObject(), 'edit'));
     $this->tpl->setVariable('TXT_SRV_ADDR', $this->lng->txt('ecs_server_addr'));
     if (ilECSSetting::getInstanceByServerId($set['server_id'])->getServer()) {
         $this->tpl->setVariable('VAL_DESC', ilECSSetting::getInstanceByServerId($set['server_id'])->getServer());
     } else {
         $this->tpl->setVariable('VAL_DESC', $this->lng->txt('ecs_not_configured'));
     }
     $dt = ilECSSetting::getInstanceByServerId($set['server_id'])->fetchCertificateExpiration();
     if ($dt != NULL) {
         $this->tpl->setVariable('TXT_CERT_VALID', $this->lng->txt('ecs_cert_valid_until'));
         $now = new ilDateTime(time(), IL_CAL_UNIX);
         $now->increment(IL_CAL_MONTH, 2);
         if (ilDateTime::_before($dt, $now)) {
             $this->tpl->setCurrentBlock('invalid');
             $this->tpl->setVariable('VAL_ICERT', ilDatePresentation::formatDate($dt));
             $this->tpl->parseCurrentBlock();
         } else {
             $this->tpl->setCurrentBlock('valid');
             $this->tpl->setVariable('VAL_VCERT', ilDatePresentation::formatDate($dt));
             $this->tpl->parseCurrentBlock();
         }
     }
     // Actions
     include_once './Services/UIComponent/AdvancedSelectionList/classes/class.ilAdvancedSelectionListGUI.php';
     $list = new ilAdvancedSelectionListGUI();
     $list->setSelectionHeaderClass('small');
     $list->setItemLinkClass('small');
     $list->setId('actl_' . $set['server_id']);
     $list->setListTitle($this->lng->txt('actions'));
     if (ilECSSetting::getInstanceByServerId($set['server_id'])->isEnabled()) {
         $list->addItem($this->lng->txt('ecs_deactivate'), '', $ilCtrl->getLinkTarget($this->getParentObject(), 'deactivate'));
     } else {
         $list->addItem($this->lng->txt('ecs_activate'), '', $ilCtrl->getLinkTarget($this->getParentObject(), 'activate'));
     }
     $list->addItem($this->lng->txt('edit'), '', $ilCtrl->getLinkTarget($this->getParentObject(), 'edit'));
     $list->addItem($this->lng->txt('copy'), '', $ilCtrl->getLinkTarget($this->getParentObject(), 'cp'));
     $list->addItem($this->lng->txt('delete'), '', $ilCtrl->getLinkTarget($this->getParentObject(), 'delete'));
     $this->tpl->setVariable('ACTIONS', $list->getHTML());
     $ilCtrl->clearParameters($this->getParentObject());
 }
コード例 #5
0
 /**
  * get matching category
  *
  * @param object	$econtent	ilECSEcontent
  * @return
  * @static
  */
 public static function getMatchingCategory($a_server_id, $a_matchable_content)
 {
     global $ilLog;
     if (is_null(self::$cached_active_rules)) {
         self::$cached_active_rules = self::getActiveRules();
     }
     foreach (self::$cached_active_rules as $rule) {
         if ($rule->matches($a_matchable_content)) {
             $ilLog->write(__METHOD__ . ': Found assignment for field type: ' . $rule->getFieldName());
             return $rule->getContainerId();
         }
         $ilLog->write(__METHOD__ . ': Category assignment failed for field: ' . $rule->getFieldName());
     }
     // Return default container
     $ilLog->write(__METHOD__ . ': Using default container');
     return ilECSSetting::getInstanceByServerId($a_server_id)->getImportId();
 }
コード例 #6
0
 /**
  * Read trees from ecs
  *
  * @throws ilECSConnectorException
  */
 public function read()
 {
     $GLOBALS['ilLog']->write(__METHOD__ . ': Begin read');
     try {
         include_once './Services/WebServices/ECS/classes/Tree/class.ilECSDirectoryTreeConnector.php';
         $dir_reader = new ilECSDirectoryTreeConnector(ilECSSetting::getInstanceByServerId($this->server_id));
         $trees = $dir_reader->getDirectoryTrees();
         $GLOBALS['ilLog']->write(__METHOD__ . ' ' . print_r($trees, true));
         if ($trees instanceof ilECSUriList) {
             foreach ((array) $trees->getLinkIds() as $tree_id) {
                 include_once './Services/WebServices/ECS/classes/Tree/class.ilECSCmsData.php';
                 include_once './Services/WebServices/ECS/classes/Tree/class.ilECSCmsTree.php';
                 if (!ilECSCmsData::treeExists($this->server_id, $this->mid, $tree_id)) {
                     $result = $dir_reader->getDirectoryTree($tree_id);
                     $this->storeTree($tree_id, $result->getResult());
                 }
             }
         }
     } catch (ilECSConnectorException $e) {
         throw $e;
     }
 }
コード例 #7
0
 /**
  * Get data from server
  * 
  * @param int $a_server_id
  * @param int $a_econtent_id
  * @param string $a_resource_type
  * @return ilECSEContentDetails
  */
 public static function getInstance($a_server_id, $a_econtent_id, $a_resource_type)
 {
     global $ilLog;
     try {
         include_once './Services/WebServices/ECS/classes/class.ilECSSetting.php';
         include_once './Services/WebServices/ECS/classes/class.ilECSConnector.php';
         $connector = new ilECSConnector(ilECSSetting::getInstanceByServerId($a_server_id));
         $res = $connector->getResource($a_resource_type, $a_econtent_id, true);
         if ($res->getHTTPCode() == ilECSConnector::HTTP_CODE_NOT_FOUND) {
             return;
         }
         if (!is_object($res->getResult())) {
             $ilLog->write(__METHOD__ . ': Error parsing result. Expected result of type array.');
             $ilLog->logStack();
             throw new ilECSConnectorException('error parsing json');
         }
     } catch (ilECSConnectorException $exc) {
         return;
     }
     include_once './Services/WebServices/ECS/classes/class.ilECSEContentDetails.php';
     $details = new self();
     $details->loadFromJSON($res->getResult());
     return $details;
 }
コード例 #8
0
 /**
  * Get instance by server id
  * @param int $a_server_id
  * @return ilECSCommunityReader
  */
 public static function getInstanceByServerId($a_server_id)
 {
     if (isset(self::$instances[$a_server_id])) {
         return self::$instances[$a_server_id];
     }
     return self::$instances[$a_server_id] = new ilECSCommunityReader(ilECSSetting::getInstanceByServerId($a_server_id));
 }
コード例 #9
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;
 }
コード例 #10
0
 /**
  * Read all actice servers
  * @global ilDB $ilDB 
  */
 private function readActiveServers()
 {
     global $ilDB;
     $query = 'SELECT server_id FROM ecs_server ' . 'WHERE active =  ' . $ilDB->quote(1, 'integer') . ' ' . 'ORDER BY title ';
     $res = $ilDB->query($query);
     $this->servers = array();
     while ($row = $res->fetchRow(DB_FETCHMODE_OBJECT)) {
         $this->servers[$row->server_id] = ilECSSetting::getInstanceByServerId($row->server_id);
     }
 }
 /**
  * Refresh status of course member assignments
  * @param object $course_member
  * @param int $obj_id
  */
 protected function refreshAssignmentStatus($course_member, $obj_id, $sub_id, $assigned)
 {
     include_once './Services/WebServices/ECS/classes/Course/class.ilECSCourseMemberAssignment.php';
     $type = ilObject::_lookupType($obj_id);
     if ($type == 'crs') {
         include_once './Modules/Course/classes/class.ilCourseParticipants.php';
         $part = ilCourseParticipants::_getInstanceByObjId($obj_id);
     } else {
         include_once './Modules/Group/classes/class.ilGroupParticipants.php';
         $part = ilGroupParticipants::_getInstanceByObjId($obj_id);
     }
     $course_id = (int) $course_member->lectureID;
     $usr_ids = ilECSCourseMemberAssignment::lookupUserIds($course_id, $sub_id, $obj_id);
     // Delete remote deleted
     foreach ((array) $usr_ids as $usr_id) {
         if (!isset($assigned[$usr_id])) {
             $ass = ilECSCourseMemberAssignment::lookupAssignment($course_id, $sub_id, $obj_id, $usr_id);
             if ($ass instanceof ilECSCourseMemberAssignment) {
                 $acc = ilObjUser::_checkExternalAuthAccount(ilECSSetting::lookupAuthMode(), (string) $usr_id);
                 if ($il_usr_id = ilObjUser::_lookupId($acc)) {
                     // this removes also admin, tutor roles
                     $part->delete($il_usr_id);
                     $GLOBALS['ilLog']->write(__METHOD__ . ': Deassigning user ' . $usr_id . ' ' . 'from course ' . ilObject::_lookupTitle($obj_id));
                 } else {
                     $GLOBALS['ilLog']->write(__METHOD__ . ': Deassigning unknown ILIAS user ' . $usr_id . ' ' . 'from course ' . ilObject::_lookupTitle($obj_id));
                 }
                 $ass->delete();
             }
         }
     }
     // Assign new participants
     foreach ((array) $assigned as $person_id => $person) {
         $role = $this->lookupRole($person['role']);
         $role_info = ilECSMappingUtils::getRoleMappingInfo($role);
         $acc = ilObjUser::_checkExternalAuthAccount(ilECSSetting::lookupAuthMode(), (string) $person_id);
         $GLOBALS['ilLog']->write(__METHOD__ . ': Handling user ' . (string) $person_id);
         if (in_array($person_id, $usr_ids)) {
             if ($il_usr_id = ilObjUser::_lookupId($acc)) {
                 $GLOBALS['ilLog']->write(__METHOD__ . ': ' . print_r($role, true));
                 $part->updateRoleAssignments($il_usr_id, array($role));
                 // Nothing to do, user is member or is locally deleted
             }
         } else {
             if ($il_usr_id = ilObjUser::_lookupId($acc)) {
                 if ($role) {
                     // Add user
                     $GLOBALS['ilLog']->write(__METHOD__ . ': Assigning new user ' . $person_id . ' ' . 'to ' . ilObject::_lookupTitle($obj_id));
                     $part->add($il_usr_id, $role);
                 }
             } else {
                 if ($role_info['create']) {
                     $this->createMember($person_id);
                     $GLOBALS['ilLog']->write(__METHOD__ . ': Added new user ' . $person_id);
                 }
             }
             $assignment = new ilECSCourseMemberAssignment();
             $assignment->setServer($this->getServer()->getServerId());
             $assignment->setMid($this->mid);
             $assignment->setCmsId($course_id);
             $assignment->setCmsSubId($sub_id);
             $assignment->setObjId($obj_id);
             $assignment->setUid($person_id);
             $assignment->save();
         }
     }
     return true;
 }
コード例 #12
0
 /**
  * Init settings
  *
  * @access protected
  */
 protected function initSettings($a_server_id = 1)
 {
     include_once 'Services/WebServices/ECS/classes/class.ilECSSetting.php';
     $this->settings = ilECSSetting::getInstanceByServerId($a_server_id);
 }
コード例 #13
0
 /**
  * Handle export reset.
  * Delete exported econtent and create it again 
  *
  * @return bool
  * @static
  * throws ilException, ilECSConnectorException
  */
 public static function handleExportReset(ilECSSetting $server)
 {
     include_once './Services/WebServices/ECS/classes/class.ilECSExport.php';
     // Delete all export events
     $queue = new ilECSEventQueueReader($server->getServerId());
     $queue->deleteAllExportedEvents();
     // Read all local export info
     $local_econtent_ids = ilECSExport::_getAllEContentIds($server->getServerId());
     $types = self::getAllEContentTypes();
     $list = self::getAllResourceIds($server, $types, true);
     // merge in one array
     $all_remote_ids = array();
     foreach ($list as $resource_type => $remote_ids) {
         $all_remote_ids = array_merge($all_remote_ids, (array) $remote_ids);
     }
     $all_remote_ids = array_unique($all_remote_ids);
     $GLOBALS['ilLog']->write(__METHOD__ . ': Resources = ' . print_r($all_remote_ids, true));
     $GLOBALS['ilLog']->write(__METHOD__ . ': Local = ' . print_r($local_econtent_ids, true));
     foreach ($local_econtent_ids as $local_econtent_id => $local_obj_id) {
         if (!in_array($local_econtent_id, $all_remote_ids)) {
             // Delete this deprecated info
             $GLOBALS['ilLog']->write(__METHOD__ . ': Deleting deprecated econtent id ' . $local_econtent_id);
             ilECSExport::_deleteEContentIds($server->getServerId(), array($local_econtent_id));
         }
     }
     return true;
 }
コード例 #14
0
 /**
  * Get setting
  * @return ilECSSetting
  */
 public function getServer()
 {
     return ilECSSetting::getInstanceByServerId($this->server_id);
 }
コード例 #15
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';
     // 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;
 }
コード例 #16
0
 /**
  * Assign mmissing course/groups to new user accounts
  * @param ilObjUser $user
  */
 protected function handleMembership(ilObjUser $user)
 {
     if ($user->getAuthMode() != ilECSSetting::lookupAuthMode()) {
         return true;
     }
 }
コード例 #17
0
 /**
  * Add advanced metadata to json (export)
  * 
  * @param object $a_json
  * @param ilECSSetting $a_server
  * @param array $a_definition
  */
 protected function addMetadataToJson(&$a_json, ilECSSetting $a_server, array $a_definition)
 {
     include_once './Services/WebServices/ECS/classes/class.ilECSDataMappingSettings.php';
     include_once './Services/AdvancedMetaData/classes/class.ilAdvancedMDValues.php';
     include_once './Services/AdvancedMetaData/classes/class.ilAdvancedMDFieldDefinition.php';
     $mappings = ilECSDataMappingSettings::getInstanceByServerId($a_server->getServerId());
     $values = ilAdvancedMDValues::_getValuesByObjId($this->content_obj->getId());
     foreach ($a_definition as $id => $type) {
         if (is_array($type)) {
             $target = $type[1];
             $type = $type[0];
         } else {
             $target = $id;
         }
         if ($field = $mappings->getMappingByECSName(ilECSDataMappingSetting::MAPPING_EXPORT, $id)) {
             $value = isset($values[$field]) ? $values[$field] : '';
             switch ($type) {
                 case ilECSUtils::TYPE_ARRAY:
                     $a_json->{$target} = explode(',', $value);
                     break;
                 case ilECSUtils::TYPE_INT:
                     $a_json->{$target} = (int) $value;
                     break;
                 case ilECSUtils::TYPE_STRING:
                     $a_json->{$target} = (string) $value;
                     break;
                 case ilECSUtils::TYPE_TIMEPLACE:
                     if (!isset($a_json->{$target})) {
                         include_once './Services/WebServices/ECS/classes/class.ilECSTimePlace.php';
                         $a_json->{$target} = new ilECSTimePlace();
                     }
                     $a_json->{$target}->{'set' . ucfirst($id)}($value);
                     break;
             }
         }
     }
 }
コード例 #18
0
 /**
  * Singleton Constructor
  *
  * @access private
  * 
  */
 private function __construct($a_server_id)
 {
     $this->settings = ilECSSetting::getInstanceByServerId($a_server_id);
     $this->read();
 }
コード例 #19
0
 /**
  * Update enrolment status
  * @param type $a_obj_id
  * @param ilObjUser $user
  * @param type $a_status
  * @return boolean
  */
 protected static function updateEnrolmentStatus($a_obj_id, ilObjUser $user, $a_status)
 {
     include_once './Services/WebServices/ECS/classes/class.ilECSRemoteUser.php';
     $remote = ilECSRemoteUser::factory($user->getId());
     if (!$remote instanceof ilECSRemoteUser) {
         return FALSE;
     }
     include_once './Services/WebServices/ECS/classes/Connectors/class.ilECSEnrolmentStatus.php';
     $enrol = new ilECSEnrolmentStatus();
     $enrol->setId('il_' . $GLOBALS['ilSetting']->get('inst_id', 0) . '_' . ilObject::_lookupType($a_obj_id) . '_' . $a_obj_id);
     $enrol->setPersonId($remote->getRemoteUserId());
     $enrol->setPersonIdType(ilECSEnrolmentStatus::ID_UID);
     $enrol->setStatus($a_status);
     try {
         include_once './Services/WebServices/ECS/classes/Connectors/class.ilECSEnrolmentStatusConnector.php';
         $con = new ilECSEnrolmentStatusConnector(ilECSSetting::getInstanceByServerId(1));
         $con->addEnrolmentStatus($enrol, $remote->getMid());
     } catch (ilECSConnectorException $e) {
         $GLOBALS['ilLog']->write(__METHOD__ . ': update enrolment status faild with message: ' . $e->getMessage());
         return false;
     }
 }
コード例 #20
0
 /**
  * Handle export reset.
  * Delete exported econtent and create it again 
  *
  * @return bool
  * @static
  * throws ilException, ilECSConnectorException
  */
 public static function handleExportReset(ilECSSetting $server)
 {
     include_once './Services/WebServices/ECS/classes/class.ilECSExport.php';
     // Delete all export events
     $queue = new ilECSEventQueueReader($server->getServerId());
     $queue->deleteAllExportedEvents();
     // Read all local export info
     $local_econtent_ids = ilECSExport::_getAllEContentIds($server->getServerId());
     $types = self::getAllEContentTypes();
     $list = self::getAllResourceIds($server, $types, true);
     // Delete all deprecated local export info
     foreach ($list as $resource_type => $remote_econtent_ids) {
         if ($remote_econtent_ids) {
             foreach ($local_econtent_ids as $econtent_id => $obj_id) {
                 if (!in_array($econtent_id, $remote_econtent_ids)) {
                     ilECSExport::_deleteEContentIds($server->getServerId(), array($econtent_id));
                 }
             }
             // Delete all with deprecated remote info
             foreach ($remote_econtent_ids as $econtent_id) {
                 if (!isset($local_econtent_ids[$econtent_id])) {
                     ilECSExport::_deleteEContentIds($server->getServerId(), array($econtent_id));
                 }
             }
         }
     }
     return true;
 }
コード例 #21
0
 /**
  * Handle update
  * @param ilECSSetting $server
  * @param type $a_content_id
  */
 public function handleUpdate(ilECSSetting $server, $a_content_id)
 {
     // 1)  Mark all nodes as deleted
     // 2a) Delete cms tree
     // 2)  Add cms tree table entries
     // 2)  Replace the cms data table entries
     // 3)  Insert deleted tree nodes in tree
     // 4)  Sync tree
     try {
         include_once './Services/WebServices/ECS/classes/Tree/class.ilECSDirectoryTreeConnector.php';
         $dir_reader = new ilECSDirectoryTreeConnector($this->getServer());
         $res = $dir_reader->getDirectoryTree($a_content_id);
         $nodes = $res->getResult();
     } catch (ilECSConnectorException $e) {
         $GLOBALS['ilLog']->write(__METHOD__ . ': Tree creation failed  with mesage ' . $e->getMessage());
         return false;
     }
     // read old tree structure
     include_once './Services/WebServices/ECS/classes/Tree/class.ilECSCmsTree.php';
     $tree = new ilECSCmsTree($a_content_id);
     $root_node = $tree->getNodeData(ilECSCmsTree::lookupRootId($a_content_id));
     $old_nodes = array();
     if ($root_node['child']) {
         $old_nodes = $tree->getSubTree($root_node, true);
     }
     //$GLOBALS['ilLog']->write(__METHOD__.': OLD TREE DATA ........'.print_r($old_nodes,true));
     // Delete old cms tree
     ilECSCmsTree::deleteByTreeId($a_content_id);
     // Mark all nodes in cms data as deleted
     include_once './Services/WebServices/ECS/classes/Tree/class.ilECSCmsData.php';
     ilECSCmsData::writeAllDeleted($this->getServer()->getServerId(), $this->mid, $a_content_id, true);
     // Check for update or new entry
     $cms_tree = $nodes;
     $data_obj_id = ilECSCmsData::lookupObjId($this->getServer()->getServerId(), $this->mid, $a_content_id, $cms_tree->rootID);
     $data = new ilECSCmsData($data_obj_id);
     $data->setServerId($server->getServerId());
     $data->setMid($this->mid);
     $data->setCmsId($cms_tree->rootID);
     $data->setTreeId($a_content_id);
     $data->setTitle($cms_tree->directoryTreeTitle);
     $data->setTerm($cms_tree->term);
     if ($data_obj_id) {
         $data->setDeleted(false);
         $data->update();
     } else {
         $data->save();
     }
     $tree->insertRootNode($a_content_id, $data->getObjId());
     $tree->setRootId($data->getObjId());
     foreach ((array) $cms_tree->nodes as $node) {
         $data_obj_id = ilECSCmsData::lookupObjId($this->getServer()->getServerId(), $this->mid, $a_content_id, $node->id);
         // update data entry
         $data = new ilECSCmsData($data_obj_id);
         $data->setTitle($node->title);
         $data->setTerm($node->term);
         $data->setDeleted(false);
         if ($data_obj_id) {
             $data->update();
         } else {
             $data->setCmsId($node->id);
             $data->setMid($this->mid);
             $data->setServerId($this->getServer()->getServerId());
             $data->setTreeId($a_content_id);
             $data->setDeleted(false);
             $data->save();
             $data_obj_id = $data->getObjId();
         }
         // add to tree
         $parent_id = ilECSCmsData::lookupObjId($this->getServer()->getServerId(), $this->mid, $a_content_id, (int) $node->parent->id);
         $tree->insertNode($data->getObjId(), $parent_id);
     }
     // Insert deleted nodes in tree
     $deleted = ilECSCmsData::findDeletedNodes($this->getServer()->getServerId(), $this->mid, $a_content_id);
     foreach ((array) $deleted as $obj_id) {
         $parent = 0;
         foreach ((array) $old_nodes as $tmp_id => $node) {
             if ($node['child'] == $obj_id) {
                 $parent = $node['parent'];
                 break;
             }
         }
         if ($tree->isInTree($parent) and $parent) {
             $tree->insertNode($obj_id, $parent);
         }
     }
     // Sync tree
     include_once './Services/WebServices/ECS/classes/Tree/class.ilECSCmsTreeSynchronizer.php';
     $sync = new ilECSCmsTreeSynchronizer($this->getServer(), $this->mid, $a_content_id);
     $sync->sync();
     return true;
 }