ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
ilECSCmsTreeCommandQueueHandler Class Reference

Description of class. More...

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

Public Member Functions

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

Protected Attributes

 $log
 

Private Member Functions

 init ()
 init handler More...
 

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

◆ __construct()

ilECSCmsTreeCommandQueueHandler::__construct ( ilECSSetting  $server)

Constructor.

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

References $GLOBALS, $server, and init().

27  {
28  $this->log = $GLOBALS['DIC']->logger()->wsrv();
29 
30  $this->server = $server;
31  $this->init();
32  }
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
+ Here is the call graph for this function:

Member Function Documentation

◆ getServer()

ilECSCmsTreeCommandQueueHandler::getServer ( )

Get server.

Returns
ilECSServerSetting

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

References $server.

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

+ Here is the caller graph for this function:

◆ handleCreate()

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

Handle create.

Parameters
ilECSSetting$server
type$a_content_id

Implements ilECSCommandQueueHandler.

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

References $data, $res, array, ilLogLevel\DEBUG, getServer(), ilECSSetting\getServerId(), and ilECSCmsData\lookupObjId().

50  {
51  include_once './Services/WebServices/ECS/classes/Tree/class.ilECSCmsData.php';
52  include_once './Services/WebServices/ECS/classes/Tree/class.ilECSCmsTree.php';
53  include_once './Services/WebServices/ECS/classes/Tree/class.ilECSDirectoryTreeConnector.php';
54 
55  $this->log->debug('ECS cms tree create');
56 
57 
58  try {
59  $dir_reader = new ilECSDirectoryTreeConnector($this->getServer());
60  $res = $dir_reader->getDirectoryTree($a_content_id);
61  $nodes = $res->getResult();
62 
63  if ($this->log->isHandling(ilLogLevel::DEBUG)) {
64  $this->log->dump($nodes, ilLogLevel::DEBUG);
65  }
66  } catch (ilECSConnectorException $e) {
67  $this->log->error('Tree creation failed with mesage ' . $e->getMessage());
68  return false;
69  }
70 
71  $cms_tree = $nodes;
72  $data = new ilECSCmsData();
73  $data->setServerId($server->getServerId());
74  $data->setMid($this->mid);
75  $data->setCmsId($cms_tree->rootID);
76  $data->setTreeId($a_content_id);
77  $data->setTitle($cms_tree->directoryTreeTitle);
78  $data->setTerm($cms_tree->term);
79  $data->save();
80 
81  $tree = new ilECSCmsTree($a_content_id);
82  $tree->insertRootNode($a_content_id, $data->getObjId());
83  $tree->setRootId($data->getObjId());
84 
85 
86  foreach ((array) $cms_tree->nodes as $node) {
87  // Add data entry
88  $data = new ilECSCmsData();
89  $data->setServerId($this->getServer()->getServerId());
90  $data->setMid($this->mid);
91  $data->setCmsId($node->id);
92  $data->setTreeId($a_content_id);
93  $data->setTitle($node->title);
94  $data->setTerm($node->term);
95  $data->save();
96 
97  // add to tree
98  if ($node->parent->id) {
99  $parent_id = ilECSCmsData::lookupObjId(
100  $this->getServer()->getServerId(),
101  $this->mid,
102  $a_content_id,
103  $node->parent->id
104  );
105  $tree->insertNode($data->getObjId(), $parent_id);
106  }
107  }
108  return true;
109  }
static lookupObjId($a_server_id, $a_mid, $a_tree_id, $cms_id)
getServerId()
Get current server id.
foreach($_POST as $key=> $value) $res
Create styles array
The data for the language used.
+ Here is the call graph for this function:

◆ handleDelete()

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

Handle delete.

Parameters
ilECSSetting$server
type$a_content_id

Implements ilECSCommandQueueHandler.

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

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

117  {
118  $this->log->debug('ECS cms tree delete');
119 
120  include_once './Services/WebServices/ECS/classes/Tree/class.ilECSCmsData.php';
121  $data = new ilECSCmsData();
122  $data->setServerId($this->getServer()->getServerId());
123  $data->setMid($this->mid);
124  $data->setTreeId($a_content_id);
125  $data->deleteTree();
126 
127  include_once './Services/WebServices/ECS/classes/Tree/class.ilECSCmsTree.php';
128  $tree = new ilECSCmsTree($a_content_id);
129  $tree->deleteTree($tree->getNodeData(ilECSCmsTree::lookupRootId($a_content_id)));
130 
131  include_once './Services/WebServices/ECS/classes/Mapping/class.ilECSNodeMappingAssignments.php';
133  $this->getServer()->getServerId(),
134  $this->mid,
135  $a_content_id
136  );
137  return true;
138  }
static lookupRootId($a_tree_id)
lookup root id
static deleteMappings($a_server_id, $a_mid, $a_tree_id)
Delete mappings $ilDB $ilDB.
+ Here is the call graph for this function:

◆ handleUpdate()

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

Handle update.

Parameters
ilECSSetting$server
type$a_content_id

Implements ilECSCommandQueueHandler.

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

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

146  {
147  $this->log->debug('ECS cms tree update');
148 
149 
150  // 1) Mark all nodes as deleted
151  // 2a) Delete cms tree
152  // 2) Add cms tree table entries
153  // 2) Replace the cms data table entries
154  // 3) Insert deleted tree nodes in tree
155  // 4) Sync tree
156 
157  try {
158  include_once './Services/WebServices/ECS/classes/Tree/class.ilECSDirectoryTreeConnector.php';
159  $dir_reader = new ilECSDirectoryTreeConnector($this->getServer());
160  $res = $dir_reader->getDirectoryTree($a_content_id);
161  $nodes = $res->getResult();
162  if ($this->log->isHandling(ilLogLevel::DEBUG)) {
163  $this->log->dump($nodes, ilLogLevel::DEBUG);
164  }
165  } catch (ilECSConnectorException $e) {
166  $GLOBALS['ilLog']->write(__METHOD__ . ': Tree creation failed with mesage ' . $e->getMessage());
167  return false;
168  }
169 
170  // read old tree structure
171  include_once './Services/WebServices/ECS/classes/Tree/class.ilECSCmsTree.php';
172  $tree = new ilECSCmsTree($a_content_id);
173 
174  $root_node = $tree->getNodeData(ilECSCmsTree::lookupRootId($a_content_id));
175 
176  $old_nodes = array();
177  if ($root_node['child']) {
178  $old_nodes = $tree->getSubTree($root_node, true);
179  }
180 
181  if ($this->log->isHandling(ilLogLevel::DEBUG)) {
182  $this->log->debug('Old tree data... ');
183  $this->log->dump($old_nodes, ilLogLevel::DEBUG);
184  }
185 
186  // Delete old cms tree
187  ilECSCmsTree::deleteByTreeId($a_content_id);
188 
189  // Mark all nodes in cms data as deleted
190  include_once './Services/WebServices/ECS/classes/Tree/class.ilECSCmsData.php';
192  $this->getServer()->getServerId(),
193  $this->mid,
194  $a_content_id,
195  true
196  );
197 
198  // Check for update or new entry
199  $cms_tree = $nodes;
200 
201  $data_obj_id = ilECSCmsData::lookupObjId(
202  $this->getServer()->getServerId(),
203  $this->mid,
204  $a_content_id,
205  $cms_tree->rootID
206  );
207 
208  $data = new ilECSCmsData($data_obj_id);
209  $data->setServerId($server->getServerId());
210  $data->setMid($this->mid);
211  $data->setCmsId($cms_tree->rootID);
212  $data->setTreeId($a_content_id);
213  $data->setTitle($cms_tree->directoryTreeTitle);
214  $data->setTerm($cms_tree->term);
215 
216  if ($data_obj_id) {
217  $data->setDeleted(false);
218  $data->update();
219  } else {
220  $data->save();
221  }
222 
223  $tree->insertRootNode($a_content_id, $data->getObjId());
224  $tree->setRootId($data->getObjId());
225 
226 
227  foreach ((array) $cms_tree->nodes as $node) {
228  $data_obj_id = ilECSCmsData::lookupObjId(
229  $this->getServer()->getServerId(),
230  $this->mid,
231  $a_content_id,
232  $node->id
233  );
234 
235  // update data entry
236  $data = new ilECSCmsData($data_obj_id);
237  $data->setTitle($node->title);
238  $data->setTerm($node->term);
239  $data->setDeleted(false);
240 
241  if ($data_obj_id) {
242  $data->update();
243  } else {
244  $data->setCmsId($node->id);
245  $data->setMid($this->mid);
246  $data->setServerId($this->getServer()->getServerId());
247  $data->setTreeId($a_content_id);
248  $data->setDeleted(false);
249  $data->save();
250 
251  $data_obj_id = $data->getObjId();
252  }
253 
254  // add to tree
255  $parent_id = ilECSCmsData::lookupObjId(
256  $this->getServer()->getServerId(),
257  $this->mid,
258  $a_content_id,
259  $node->parent->id
260  );
261  $tree->insertNode($data->getObjId(), $parent_id);
262  }
263 
264  // Insert deleted nodes in tree
266  $this->getServer()->getServerId(),
267  $this->mid,
268  $a_content_id
269  );
270 
271  foreach ((array) $deleted as $obj_id) {
272  $parent = 0;
273  foreach ((array) $old_nodes as $tmp_id => $node) {
274  if ($node['child'] == $obj_id) {
275  $parent = $node['parent'];
276  break;
277  }
278  }
279 
280  if ($tree->isInTree($parent) and $parent) {
281  $tree->insertNode($obj_id, $parent);
282  }
283  }
284 
285  // Sync tree
286  include_once './Services/WebServices/ECS/classes/Tree/class.ilECSCmsTreeSynchronizer.php';
288  $this->getServer(),
289  $this->mid,
290  $a_content_id
291  );
292  $sync->sync();
293 
294  return true;
295  }
static writeAllDeleted($a_server_id, $a_mid, $a_tree_id, $a_deleted_flag)
Write deleted status.
static lookupObjId($a_server_id, $a_mid, $a_tree_id, $cms_id)
getServerId()
Get current server id.
static lookupRootId($a_tree_id)
lookup root id
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
foreach($_POST as $key=> $value) $res
$sync
Create styles array
The data for the language used.
static findDeletedNodes($a_server_id, $a_mid, $a_tree_id)
Find deleted nodes Uses a left join since this is more robust.
static deleteByTreeId($a_tree_id)
Delete tree by tree_id.
+ Here is the call graph for this function:

◆ init()

ilECSCmsTreeCommandQueueHandler::init ( )
private

init handler

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

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

Referenced by __construct().

301  {
302  include_once './Services/WebServices/ECS/classes/class.ilECSParticipantSettings.php';
303  $this->mid = ilECSParticipantSettings::loookupCmsMid($this->getServer()->getServerId());
304  }
static loookupCmsMid($a_server_id)
Lookup mid of current cms participant $ilDB.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $log

ilECSCmsTreeCommandQueueHandler::$log
protected

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

◆ $mid

ilECSCmsTreeCommandQueueHandler::$mid = 0
private

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

◆ $server

ilECSCmsTreeCommandQueueHandler::$server = null
private

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

Referenced by __construct(), and getServer().


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