ILIAS  release_4-3 Revision
 All Data Structures Namespaces Files Functions Variables Groups Pages
ilECSCmsTreeCommandQueueHandler Class Reference

Description of class. More...

+ Inheritance diagram for ilECSCmsTreeCommandQueueHandler:
+ Collaboration diagram for ilECSCmsTreeCommandQueueHandler:

Public Member Functions

 __construct (ilECSSetting $server)
 Constructor.
 getServer ()
 Get server.
 handleCreate (ilECSSetting $server, $a_content_id)
 Handle create.
 handleDelete (ilECSSetting $server, $a_content_id)
 Handle delete.
 handleUpdate (ilECSSetting $server, $a_content_id)
 Handle update.

Private Member Functions

 init ()
 init handler

Private Attributes

 $server = null
 $mid = 0

Detailed Description

Description of class.

Author
Stefan Meyer smeye.nosp@m.r.il.nosp@m.ias@g.nosp@m.mx.d.nosp@m.e

Definition at line 12 of file class.ilECSCmsTreeCommandQueueHandler.php.

Constructor & Destructor Documentation

ilECSCmsTreeCommandQueueHandler::__construct ( ilECSSetting  $server)

Constructor.

Definition at line 21 of file class.ilECSCmsTreeCommandQueueHandler.php.

References $server, and init().

{
$this->server = $server;
$this->init();
}

+ Here is the call graph for this function:

Member Function Documentation

ilECSCmsTreeCommandQueueHandler::getServer ( )

Get server.

Returns
ilECSServerSetting

Definition at line 31 of file class.ilECSCmsTreeCommandQueueHandler.php.

References $server.

Referenced by handleCreate(), handleDelete(), handleUpdate(), and init().

{
return $this->server;
}

+ Here is the caller graph for this function:

ilECSCmsTreeCommandQueueHandler::handleCreate ( ilECSSetting  $server,
  $a_content_id 
)

Handle create.

Parameters
ilECSSetting$server
type$a_content_id

Implements ilECSCommandQueueHandler.

Definition at line 42 of file class.ilECSCmsTreeCommandQueueHandler.php.

References $data, $GLOBALS, $res, getServer(), ilECSSetting\getServerId(), and ilECSCmsData\lookupObjId().

{
include_once './Services/WebServices/ECS/classes/Tree/class.ilECSCmsData.php';
include_once './Services/WebServices/ECS/classes/Tree/class.ilECSCmsTree.php';
include_once './Services/WebServices/ECS/classes/Tree/class.ilECSDirectoryTreeConnector.php';
try
{
$dir_reader = new ilECSDirectoryTreeConnector($this->getServer());
$res = $dir_reader->getDirectoryTree($a_content_id);
$nodes = $res->getResult();
}
{
$GLOBALS['ilLog']->write(__METHOD__.': Tree creation failed with mesage ' . $e->getMessage());
return false;
}
$cms_tree = $nodes;
$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);
$data->save();
$tree = new ilECSCmsTree($a_content_id);
$tree->insertRootNode($a_content_id, $data->getObjId());
$tree->setRootId($data->getObjId());
foreach((array) $cms_tree->nodes as $node)
{
// Add data entry
$data->setServerId($this->getServer()->getServerId());
$data->setMid($this->mid);
$data->setCmsId($node->id);
$data->setTreeId($a_content_id);
$data->setTitle($node->title);
$data->setTerm($node->term);
$data->save();
// add to tree
if($node->parent->id)
{
$this->getServer()->getServerId(),
$this->mid,
$a_content_id,
(int) $node->parent->id
);
$tree->insertNode($data->getObjId(), $parent_id);
}
}
return true;
}

+ Here is the call graph for this function:

ilECSCmsTreeCommandQueueHandler::handleDelete ( ilECSSetting  $server,
  $a_content_id 
)

Handle delete.

Parameters
ilECSSetting$server
type$a_content_id

Implements ilECSCommandQueueHandler.

Definition at line 107 of file class.ilECSCmsTreeCommandQueueHandler.php.

References $data, ilECSNodeMappingAssignments\deleteMappings(), getServer(), and ilECSCmsTree\lookupRootId().

{
include_once './Services/WebServices/ECS/classes/Tree/class.ilECSCmsData.php';
$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';
$this->getServer()->getServerId(),
$this->mid,
$a_content_id
);
return true;
}

+ Here is the call graph for this function:

ilECSCmsTreeCommandQueueHandler::handleUpdate ( ilECSSetting  $server,
  $a_content_id 
)

Handle update.

Parameters
ilECSSetting$server
type$a_content_id

Implements ilECSCommandQueueHandler.

Definition at line 134 of file class.ilECSCmsTreeCommandQueueHandler.php.

References $data, $GLOBALS, $res, ilECSCmsTree\deleteByTreeId(), ilECSCmsData\findDeletedNodes(), getServer(), ilECSSetting\getServerId(), ilECSCmsData\lookupObjId(), ilECSCmsTree\lookupRootId(), and ilECSCmsData\writeAllDeleted().

{
// 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();
}
{
$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
// Mark all nodes in cms data as deleted
include_once './Services/WebServices/ECS/classes/Tree/class.ilECSCmsData.php';
$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
$this->getServer()->getServerId(),
$this->mid,
$a_content_id,
(int) $node->parent->id
);
$tree->insertNode($data->getObjId(), $parent_id);
}
// Insert deleted nodes in tree
$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';
$this->getServer(),
$this->mid,
$a_content_id
);
$sync->sync();
return true;
}

+ Here is the call graph for this function:

ilECSCmsTreeCommandQueueHandler::init ( )
private

init handler

Definition at line 296 of file class.ilECSCmsTreeCommandQueueHandler.php.

References getServer(), and ilECSParticipantSettings\loookupCmsMid().

Referenced by __construct().

{
include_once './Services/WebServices/ECS/classes/class.ilECSParticipantSettings.php';
$this->mid = ilECSParticipantSettings::loookupCmsMid($this->getServer()->getServerId());
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Field Documentation

ilECSCmsTreeCommandQueueHandler::$mid = 0
private

Definition at line 15 of file class.ilECSCmsTreeCommandQueueHandler.php.

ilECSCmsTreeCommandQueueHandler::$server = null
private

Definition at line 14 of file class.ilECSCmsTreeCommandQueueHandler.php.

Referenced by __construct(), and getServer().


The documentation for this class was generated from the following file: