/**
  * Lookup mapping status
  * @param int $a_server_id
  * @param int $a_tree_id
  * @return int
  */
 public static function lookupMappingStatus($a_server_id, $a_mid, $a_tree_id)
 {
     include_once './Services/WebServices/ECS/classes/Mapping/class.ilECSNodeMappingAssignments.php';
     if (ilECSNodeMappingAssignments::hasAssignments($a_server_id, $a_mid, $a_tree_id)) {
         if (ilECSNodeMappingAssignments::isWholeTreeMapped($a_server_id, $a_mid, $a_tree_id)) {
             return self::MAPPED_WHOLE_TREE;
         }
         return self::MAPPED_MANUAL;
     }
     return self::MAPPED_UNMAPPED;
 }
 /**
  * Synchronize tree
  * 
  * @return boolean
  */
 public function sync()
 {
     include_once './Services/WebServices/ECS/classes/Mapping/class.ilECSNodeMappingAssignments.php';
     $this->default_settings = ilECSNodeMappingAssignments::lookupSettings($this->getServer()->getServerId(), $this->mid, $this->tree_id, 0);
     // return if setting is false => no configuration done
     if (!$this->getDefaultSettings()) {
         $GLOBALS['ilLog']->write(__METHOD__ . ': No directory allocation settings. Aborting');
         return true;
     }
     // lookup obj id of root node
     include_once './Services/WebServices/ECS/classes/Tree/class.ilECSCmsData.php';
     $root_obj_id = ilECSCmsTree::lookupRootId($this->tree_id);
     $this->syncNode($root_obj_id, 0);
     // Tree structure is up to date, now check node movements
     $this->checkTreeUpdates($root_obj_id);
     return true;
 }
Exemplo n.º 3
0
 public static function updateStatus($a_server_id, $a_mid, $a_tree_id)
 {
     // Set all status to pending unmapped
     self::writeAllStatus($a_server_id, $a_mid, $a_tree_id, self::MAPPING_UNMAPPED);
     // Set mapped for mapped and their descendent
     include_once './Services/WebServices/ECS/classes/Mapping/class.ilECSNodeMappingAssignments.php';
     include_once './Services/WebServices/ECS/classes/Tree/class.ilECSCmsTree.php';
     foreach (ilECSNodeMappingAssignments::lookupAssignmentIds($a_server_id, $a_mid, $a_tree_id) as $assignment) {
         $cmsTree = new ilECSCmsTree($a_tree_id);
         $subIds = self::lookupCmsIds(array_merge($cmsTree->getSubTreeIds($assignment), array($assignment)));
         self::writeStatus($a_server_id, $a_mid, $a_tree_id, $subIds, self::MAPPING_MAPPED);
     }
 }
 /**
  * Do mapping
  */
 protected function dMap()
 {
     if (!$_POST['lnodes']) {
         ilUtil::sendFailure($this->lng->txt('select_one'), true);
         $this->ctrl->redirect($this, 'dEditTree');
     }
     $ref_id = end($_POST['lnodes']);
     include_once './Services/WebServices/ECS/classes/Mapping/class.ilECSNodeMappingAssignments.php';
     ilECSNodeMappingAssignments::deleteDisconnectableMappings($this->getServer()->getServerId(), $this->getMid(), (int) $_REQUEST['tid'], $ref_id);
     $nodes = (array) $_POST['rnodes'];
     $nodes = (array) array_reverse($nodes);
     include_once './Services/WebServices/ECS/classes/Mapping/class.ilECSNodeMappingAssignment.php';
     include_once './Services/WebServices/ECS/classes/Mapping/class.ilECSNodeMappingAssignments.php';
     include_once './Services/WebServices/ECS/classes/Tree/class.ilECSCmsTree.php';
     foreach ($nodes as $cms_id) {
         $assignment = new ilECSNodeMappingAssignment($this->getServer()->getServerId(), $this->getMid(), (int) $_REQUEST['tid'], (int) $cms_id);
         $assignment->setRefId($ref_id);
         $assignment->setObjId(ilObject::_lookupObjId($ref_id));
         $assignment->enablePositionUpdate(false);
         $assignment->enableTreeUpdate(false);
         $assignment->enableTitleUpdate(ilECSNodeMappingAssignments::lookupDefaultTitleUpdate($this->getServer()->getServerId(), $this->getMid(), (int) $_REQUEST['tid']));
         $assignment->update();
         // Delete subitems mappings for cms subtree
         $cmsTree = new ilECSCmsTree((int) $_REQUEST['tid']);
         $childs = $cmsTree->getSubTreeIds($cms_id);
         ilECSNodeMappingAssignments::deleteMappingsByCsId($this->getServer()->getServerId(), $this->getMid(), (int) $_REQUEST['tid'], $childs);
     }
     ilECSCmsData::updateStatus($this->getServer()->getServerId(), $this->getMid(), (int) $_REQUEST['tid']);
     // Save parameter cid
     $this->ctrl->setParameter($this, 'lid', (int) $ref_id);
     ilUtil::sendSuccess($this->lng->txt('settings_saved'), true);
     $this->ctrl->redirect($this, 'dEditTree');
 }
 /**
  * Handle delete
  * @param ilECSSetting $server
  * @param type $a_content_id
  */
 public function handleDelete(ilECSSetting $server, $a_content_id)
 {
     include_once './Services/WebServices/ECS/classes/Tree/class.ilECSCmsData.php';
     $data = new ilECSCmsData();
     $data->setServerId($this->getServer()->getServerId());
     $data->setMid($this->mid);
     $data->setTreeId($a_content_id);
     $data->deleteTree();
     include_once './Services/WebServices/ECS/classes/Tree/class.ilECSCmsTree.php';
     $tree = new ilECSCmsTree($a_content_id);
     $tree->deleteTree($tree->getNodeData(ilECSCmsTree::lookupRootId($a_content_id)));
     include_once './Services/WebServices/ECS/classes/Mapping/class.ilECSNodeMappingAssignments.php';
     ilECSNodeMappingAssignments::deleteMappings($this->getServer()->getServerId(), $this->mid, $a_content_id);
     return true;
 }