ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
ilObjStudyProgrammeTreeGUI Class Reference

Class ilObjStudyProgrammeTreeGUI Generates the manage view for ilTrainingProgramme-Repository objects. More...

+ Collaboration diagram for ilObjStudyProgrammeTreeGUI:

Public Member Functions

 __construct (\ilGlobalTemplateInterface $tpl, \ilCtrl $ilCtrl, \ilAccess $ilAccess, \ilToolbarGUI $ilToolbar, \ilLanguage $lng, \ilComponentLogger $ilLog, \ILIAS $ilias, \ilSetting $ilSetting)
 
 setRefId ($a_ref_id)
 
 executeCommand ()
 Execute GUI-commands If there is a async request the response is sent as a json string. More...
 

Data Fields

 $ctrl
 
 $tpl
 
 $object
 
 $ilias
 
 $lng
 
 $toolbar
 

Protected Member Functions

 initTree ()
 Initialize Tree Creates tree instance and set tree configuration. More...
 
 view ()
 Display the tree view. More...
 
 cancel ()
 Cancel operation. More...
 
 saveTreeOrder ()
 Saves tree node order Data is json encoded from the jstree component. More...
 
 storeTreeOrder (array $nodes, $container_sorting=null, int $parent_ref_id=null)
 Recursive function for saving the tree order. More...
 
 createNewLeaf ()
 Creates a new leaf Currently only course references can be created. More...
 
 getContainerSelectionExplorer ($convert_to_string=true)
 Initialize the Course Explorer for creating a leaf. More...
 
 getCreationForm ()
 Returns the async creation form for StudyProgrammes. More...
 
 create ()
 Generates the modal window content for the creation form of nodes or leafs If there are already StudyProgramme-nodes in the parent, leaf creation is disabled and if there are already leafs, nodes can't be created. More...
 
 delete ()
 Show the delete confirmation dialog for objects in the tree. More...
 
 confirmedDelete ()
 Deletes a node or a leaf in the tree. More...
 
 cancelDelete ()
 Cancel deletion Return a json string for the async handling. More...
 
 initAsyncUIElements ()
 Initializes all elements used for async-interaction Adds HTML-skeleton for the bootstrap modal dialog, the notification mechanism and the Selection container. More...
 
 getToolbar ()
 Setup the toolbar. More...
 
 checkAccess ($permission, $ref_id=null)
 Checks permission of current tree or certain child of it. More...
 
 checkAccessOrFail ($permission, $ref_id=null)
 Checks permission of a object and throws an exception if they are not granted. More...
 

Protected Attributes

 $access
 
 $log
 
 $ref_id
 
 $tree
 
 $modal_id
 
 $async_output_handler
 

Detailed Description

Class ilObjStudyProgrammeTreeGUI Generates the manage view for ilTrainingProgramme-Repository objects.

Handles all the async requests.

Author
Michael Herren mh@st.nosp@m.uder.nosp@m.-raim.nosp@m.ann..nosp@m.ch
Version
1.0.0

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

Constructor & Destructor Documentation

◆ __construct()

ilObjStudyProgrammeTreeGUI::__construct ( \ilGlobalTemplateInterface  $tpl,
\ilCtrl  $ilCtrl,
\ilAccess  $ilAccess,
\ilToolbarGUI  $ilToolbar,
\ilLanguage  $lng,
\ilComponentLogger  $ilLog,
\ILIAS  $ilias,
\ilSetting  $ilSetting 
)

Definition at line 84 of file class.ilObjStudyProgrammeTreeGUI.php.

93 {
94 $this->tpl = $tpl;
95 $this->ctrl = $ilCtrl;
96 $this->access = $ilAccess;
97 $this->toolbar = $ilToolbar;
98 $this->log = $ilLog;
99 $this->ilias = $ilias;
100 $this->lng = $lng;
101 $this->ilSetting = $ilSetting;
102
103 $this->modal_id = "tree_modal";
104 $this->async_output_handler = new ilAsyncOutputHandler();
105
106 $lng->loadLanguageModule("prg");
107 }
Class ilAsyncOutputHandler Handles the output for async-requests.
ILIAS Setting Class.
global $ilCtrl
Definition: ilias.php:18
redirection script todo: (a better solution should control the processing via a xml file)
global $ilSetting
Definition: privfeed.php:17

References $ilCtrl, $ilias, $ilLog, $ilSetting, $lng, and $tpl.

Member Function Documentation

◆ cancel()

ilObjStudyProgrammeTreeGUI::cancel ( )
protected

Cancel operation.

Returns
string

Definition at line 194 of file class.ilObjStudyProgrammeTreeGUI.php.

195 {
197 }
static encodeAsyncResponse(array $data=array())
Encode data as json for async output.

References ilAsyncOutputHandler\encodeAsyncResponse().

+ Here is the call graph for this function:

◆ cancelDelete()

ilObjStudyProgrammeTreeGUI::cancelDelete ( )
protected

Cancel deletion Return a json string for the async handling.

Returns
string

Definition at line 521 of file class.ilObjStudyProgrammeTreeGUI.php.

522 {
524 }

References ilAsyncOutputHandler\encodeAsyncResponse().

+ Here is the call graph for this function:

◆ checkAccess()

ilObjStudyProgrammeTreeGUI::checkAccess (   $permission,
  $ref_id = null 
)
protected

Checks permission of current tree or certain child of it.

Parameters
string$permission
null$ref_id
Returns
bool

Definition at line 591 of file class.ilObjStudyProgrammeTreeGUI.php.

592 {
593 $ref_id = ($ref_id === null)? $this->ref_id : $ref_id;
594 $checker = $this->access->checkAccess($permission, '', $ref_id);
595
596 return $checker;
597 }

References $ref_id.

Referenced by checkAccessOrFail(), and confirmedDelete().

+ Here is the caller graph for this function:

◆ checkAccessOrFail()

ilObjStudyProgrammeTreeGUI::checkAccessOrFail (   $permission,
  $ref_id = null 
)
protected

Checks permission of a object and throws an exception if they are not granted.

Parameters
string$permission
null$ref_id
Exceptions
ilException

Definition at line 608 of file class.ilObjStudyProgrammeTreeGUI.php.

609 {
610 if (!$this->checkAccess($permission, $ref_id)) {
611 throw new ilException("You have no permission for " . $permission . " Object with ref_id " . $ref_id . "!");
612 }
613 }
Base class for ILIAS Exception handling.
checkAccess($permission, $ref_id=null)
Checks permission of current tree or certain child of it.

References $ref_id, and checkAccess().

Referenced by confirmedDelete(), create(), createNewLeaf(), delete(), and saveTreeOrder().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ confirmedDelete()

ilObjStudyProgrammeTreeGUI::confirmedDelete ( )
protected

Deletes a node or a leaf in the tree.

Returns
string
Exceptions
ilException

Definition at line 460 of file class.ilObjStudyProgrammeTreeGUI.php.

461 {
462 $this->checkAccessOrFail("delete");
463
464 if (!isset($_POST['id'], $_POST['item_ref_id']) && is_array($_POST['id'])) {
465 throw new ilException("No item select for deletion!");
466 }
467
468 $ids = $_POST['id'];
469 $current_node = (int) $_POST['item_ref_id'];
470 $result = true;
471
472 foreach ($ids as $id) {
473 $obj = ilObjectFactoryWrapper::singleton()->getInstanceByRefId($id);
474
475 $not_parent_of_current = true;
476 $not_root = true;
477
478 // do some additional validation if it is a StudyProgramme
479 if ($obj instanceof ilObjStudyProgramme) {
480
481 //check if you are not deleting a parent element of the current element
482 $children_of_node = ilObjStudyProgramme::getAllChildren($obj->getRefId());
483 $get_ref_ids = function ($obj) {
484 return $obj->getRefId();
485 };
486
487 $children_ref_ids = array_map($get_ref_ids, $children_of_node);
488 $not_parent_of_current = (!in_array($current_node, $children_ref_ids));
489
490 $not_root = ($obj->getRoot() != null);
491 }
492
493 if ($current_node != $id && $not_root && $not_parent_of_current && $this->checkAccess('delete', $obj->getRefId())) {
494 ilRepUtil::deleteObjects(null, $id);
495
496 // deletes the tree-open-node-session storage
497 if (isset($children_of_node)) {
498 $this->tree->closeCertainNode($id);
499 foreach ($children_of_node as $child) {
500 $this->tree->closeCertainNode($child->getRefId());
501 }
502 }
503
504 $msg = $this->lng->txt("prg_deleted_safely");
505 } else {
506 $msg = $this->lng->txt("prg_not_allowed_node_to_delete");
507 $result = false;
508 }
509 }
510
511 return ilAsyncOutputHandler::encodeAsyncResponse(array('success' => $result, 'message' => $msg));
512 }
$result
$_POST["username"]
checkAccessOrFail($permission, $ref_id=null)
Checks permission of a object and throws an exception if they are not granted.
static getAllChildren(int $a_ref_id, bool $include_references=false)
Get a list of all ilObjStudyProgrammes in the subtree starting at $a_ref_id.
static deleteObjects($a_cur_ref_id, $a_ids)
Delete objects.

References $_POST, $result, checkAccess(), checkAccessOrFail(), ilRepUtil\deleteObjects(), ilAsyncOutputHandler\encodeAsyncResponse(), ilObjStudyProgramme\getAllChildren(), and ilObjectFactoryWrapper\singleton().

+ Here is the call graph for this function:

◆ create()

ilObjStudyProgrammeTreeGUI::create ( )
protected

Generates the modal window content for the creation form of nodes or leafs If there are already StudyProgramme-nodes in the parent, leaf creation is disabled and if there are already leafs, nodes can't be created.

Exceptions
ilException

Definition at line 362 of file class.ilObjStudyProgrammeTreeGUI.php.

363 {
364 $parent_id = (isset($_GET['ref_id']))? (int) $_GET['ref_id'] : null;
365 $this->checkAccessOrFail('create', $parent_id);
366
367 $parent = ilObjectFactoryWrapper::singleton()->getInstanceByRefId($parent_id);
368 $accordion = new ilAccordionGUI();
369
370 $added_slides = 0;
371 if ($parent instanceof ilObjStudyProgramme) {
372 // only allow adding new StudyProgramme-Node if there are no lp-children
373 if (!$parent->hasLPChildren()) {
374 $content_new_node = $this->getCreationForm()->getHTML();
375 $accordion->addItem($this->lng->txt('prg_create_new_node'), $content_new_node);
376 $added_slides++;
377 }
378
379 /* only allow adding new LP-Children if there are no other StudyProgrammes
380 * AND creating crs references is activated in administration
381 */
382 if (!$parent->hasChildren() && $this->ilSetting->get("obj_dis_creation_crsr") === "") {
383 $content_new_leaf = ilUtil::getSystemMessageHTML($this->lng->txt('prg_please_select_a_course_for_creating_a_leaf'));
384 $content_new_leaf .= $this->getContainerSelectionExplorer();
385
386 $accordion->addItem($this->lng->txt('prg_create_new_leaf'), $content_new_leaf);
387 $added_slides++;
388 }
389
390 if ($added_slides == 1) {
391 $accordion->setBehaviour(ilAccordionGUI::FIRST_OPEN);
392 }
393
394 $content = $accordion->getHTML();
395 }
396
397 // creating modal window output
398 $this->async_output_handler->setHeading($this->lng->txt("prg_async_" . $this->ctrl->getCmd()));
399 $this->async_output_handler->setContent($content);
400 $this->async_output_handler->terminate();
401 }
$_GET["client_id"]
Accordion user interface class.
getCreationForm()
Returns the async creation form for StudyProgrammes.
getContainerSelectionExplorer($convert_to_string=true)
Initialize the Course Explorer for creating a leaf.
static getSystemMessageHTML($a_txt, $a_type="info")
Get HTML for a system message.

References $_GET, checkAccessOrFail(), ilAccordionGUI\FIRST_OPEN, getContainerSelectionExplorer(), getCreationForm(), ilUtil\getSystemMessageHTML(), and ilObjectFactoryWrapper\singleton().

+ Here is the call graph for this function:

◆ createNewLeaf()

ilObjStudyProgrammeTreeGUI::createNewLeaf ( )
protected

Creates a new leaf Currently only course references can be created.

Returns
string
Exceptions
ilException

Definition at line 277 of file class.ilObjStudyProgrammeTreeGUI.php.

278 {
279 $this->checkAccessOrFail('create', (int) $_POST['parent_id']);
280
281 if (isset($_POST['target_id'], $_POST['type'], $_POST['parent_id'])) {
282 $target_id = (int) $_POST['target_id'];
283 $parent_id = (int) $_POST['parent_id'];
284
285 // TODO: more generic way for implementing different type of leafs
286 $course_ref = new ilObjCourseReference();
287 $course_ref->setTitleType(ilObjCourseReference::TITLE_TYPE_REUSE);
288 $course_ref->setTargetRefId($target_id);
289
290 $course_ref->create();
291 $course_ref->createReference();
292
293 $course_ref->putInTree($parent_id);
294
295 // This is how its done in ILIAS. If you set the target ID before the creation, it won't work
296 $course_ref->setTargetId(ilObject::_lookupObjectId($target_id));
297 $course_ref->update();
298 }
299
300 return ilAsyncOutputHandler::encodeAsyncResponse(array('success' => true, 'message' => $this->lng->txt('prg_added_course_ref_successful')));
301 }
static _lookupObjectId($a_ref_id)
lookup object id
$target_id
Definition: goto.php:49

References $_POST, $target_id, ilObject\_lookupObjectId(), checkAccessOrFail(), ilAsyncOutputHandler\encodeAsyncResponse(), and ilContainerReference\TITLE_TYPE_REUSE.

+ Here is the call graph for this function:

◆ delete()

ilObjStudyProgrammeTreeGUI::delete ( )
protected

Show the delete confirmation dialog for objects in the tree.

Exceptions
ilException

Definition at line 409 of file class.ilObjStudyProgrammeTreeGUI.php.

410 {
411 $this->checkAccessOrFail("delete");
412
413 if (!isset($_GET['ref_id'], $_GET['item_ref_id'])) {
414 throw new ilException("Nothing to delete!");
415 }
416
417 $element_ref_id = (int) $_GET['ref_id'];
418
419 $cgui = new ilConfirmationGUI();
420
421 $msg = $this->lng->txt("info_delete_sure");
422
423 if (!$this->ilSetting->get('enable_trash')) {
424 $msg .= "<br/>" . $this->lng->txt("info_delete_warning_no_trash");
425 }
426 $cgui->setFormAction($this->ctrl->getFormAction($this, 'confirmedDelete', '', true));
427 $cgui->setCancel($this->lng->txt("cancel"), "cancelDelete");
428 $cgui->setConfirm($this->lng->txt("confirm"), "confirmedDelete");
429 $cgui->setFormName('async_form');
430
431 $obj_id = ilObject::_lookupObjectId($element_ref_id);
432 $type = ilObject::_lookupType($obj_id);
433 $title = call_user_func(array(ilObjectFactory::getClassByType($type),'_lookupTitle'), $obj_id);
434 $alt = $this->lng->txt("icon") . " " . $this->lng->txt("obj_" . $type);
435
436 $cgui->addItem(
437 "id[]",
438 $element_ref_id,
439 $title,
440 ilObject::_getIcon($obj_id, "small", $type),
441 $alt
442 );
443 $cgui->addHiddenItem('item_ref_id', $_GET['item_ref_id']);
444
445 $content = $cgui->getHTML();
446
447 // creating the modal window output
448 $this->async_output_handler->setHeading($msg);
449 $this->async_output_handler->setContent($content);
450 $this->async_output_handler->terminate();
451 }
Confirmation screen class.
static getClassByType($a_obj_type)
Get class by type.
static _lookupType($a_id, $a_reference=false)
lookup object type
get($a_keyword, $a_default_value=false)
get setting
$type

References $_GET, $type, ilObject\_lookupObjectId(), ilObject\_lookupType(), checkAccessOrFail(), ilSetting\get(), and ilObjectFactory\getClassByType().

+ Here is the call graph for this function:

◆ executeCommand()

ilObjStudyProgrammeTreeGUI::executeCommand ( )

Execute GUI-commands If there is a async request the response is sent as a json string.

Exceptions
ilException

Definition at line 136 of file class.ilObjStudyProgrammeTreeGUI.php.

137 {
138 $this->initTree();
139 $cmd = $this->ctrl->getCmd();
140
141 $this->getToolbar();
142
143 if ($cmd == "") {
144 $cmd = "view";
145 }
146
147 // handles tree commands ("openNode", "closeNode", "getNodeAsync")
148 if ($this->tree->handleCommand()) {
149 exit();
150 }
151
152 switch ($cmd) {
153 case "view":
154 case "create":
155 case "save":
156 case "cancel":
157 case "delete":
158 case "confirmedDelete":
159 case "cancelDelete":
160 case "getContainerSelectionExplorer":
161 case "saveTreeOrder":
162 case "createNewLeaf":
163
164 $content = $this->$cmd();
165 break;
166 default:
167 throw new ilException("ilObjStudyProgrammeTreeGUI: " .
168 "Command not supported: $cmd");
169 }
170
172 }
static handleAsyncOutput($normal_content, $async_content=null, $apply_to_tpl=true)
Handles async output.
initTree()
Initialize Tree Creates tree instance and set tree configuration.
exit
Definition: login.php:29

References exit, getToolbar(), ilAsyncOutputHandler\handleAsyncOutput(), and initTree().

+ Here is the call graph for this function:

◆ getContainerSelectionExplorer()

ilObjStudyProgrammeTreeGUI::getContainerSelectionExplorer (   $convert_to_string = true)
protected

Initialize the Course Explorer for creating a leaf.

Parameters
bool$convert_to_stringIf set to true, the getOutput function is already called
Returns
ilAsyncContainerSelectionExplorer|string

Definition at line 311 of file class.ilObjStudyProgrammeTreeGUI.php.

312 {
313 $create_leaf_form = new ilAsyncContainerSelectionExplorer(rawurldecode($this->ctrl->getLinkTarget($this, 'createNewLeaf', '', true, false)));
314 $create_leaf_form->setId("select_course_explorer");
315
316 $ref_expand = ROOT_FOLDER_ID;
317 if (isset($_GET['ref_repexpand'])) {
318 $ref_expand = (int) $_GET['ref_repexpand'];
319 }
320
321 $create_leaf_form->setExpand($ref_expand);
322 $create_leaf_form->setExpandTarget($this->ctrl->getLinkTarget($this, 'getContainerSelectionExplorer'));
323 $create_leaf_form->setAsynchExpanding(true);
324 $create_leaf_form->setTargetGet('target_id');
325 $create_leaf_form->setFrameTarget("_self");
326 $create_leaf_form->setClickable('crs', true);
327 $create_leaf_form->setTargetType('crs');
328 $create_leaf_form->setOutput(0);
329
330 if ($convert_to_string) {
331 return $create_leaf_form->getOutput();
332 } else {
333 return $create_leaf_form;
334 }
335 }
Class ilAsyncContainerSelectionExplorer A class for a async ilContainerSelectionExplorer which trigge...

References $_GET.

Referenced by create().

+ Here is the caller graph for this function:

◆ getCreationForm()

ilObjStudyProgrammeTreeGUI::getCreationForm ( )
protected

Returns the async creation form for StudyProgrammes.

Returns
ilAsyncPropertyFormGUI

Definition at line 343 of file class.ilObjStudyProgrammeTreeGUI.php.

344 {
345 $tmp_obj = new ilObjStudyProgrammeGUI();
346
347 $create_node_form = $tmp_obj->getAsyncCreationForm();
348 $create_node_form->setTitle("");
349 $this->ctrl->setParameterByClass("ilobjstudyprogrammegui", "new_type", "prg");
350 $create_node_form->setFormAction($this->ctrl->getFormActionByClass("ilobjstudyprogrammegui", "save"));
351
352 return $create_node_form;
353 }
Class ilObjStudyProgrammeGUI class.

Referenced by create().

+ Here is the caller graph for this function:

◆ getToolbar()

ilObjStudyProgrammeTreeGUI::getToolbar ( )
protected

Setup the toolbar.

Definition at line 564 of file class.ilObjStudyProgrammeTreeGUI.php.

565 {
566 $save_order_btn = ilLinkButton::getInstance();
567 $save_order_btn->setId('save_order_button');
568 $save_order_btn->setUrl("javascript:void(0);");
569 $save_order_btn->setOnClick("$('body').trigger('study_programme-save_order');");
570 $save_order_btn->setCaption('prg_save_tree_order');
571
572 $cancel_order_btn = ilLinkButton::getInstance();
573 $cancel_order_btn->setId('cancel_order_button');
574 $cancel_order_btn->setUrl("javascript:void(0);");
575 $cancel_order_btn->setOnClick("$('body').trigger('study_programme-cancel_order');");
576 $cancel_order_btn->setCaption('prg_cancel_tree_order');
577
578 $this->toolbar->addButtonInstance($save_order_btn);
579 $this->toolbar->addButtonInstance($cancel_order_btn);
580 }
static getInstance()
Factory.

References ilLinkButton\getInstance().

Referenced by executeCommand().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ initAsyncUIElements()

ilObjStudyProgrammeTreeGUI::initAsyncUIElements ( )
protected

Initializes all elements used for async-interaction Adds HTML-skeleton for the bootstrap modal dialog, the notification mechanism and the Selection container.

Returns
string

Definition at line 533 of file class.ilObjStudyProgrammeTreeGUI.php.

534 {
535 // add js files
539
540 // add bootstrap modal
541 $settings_modal = ilModalGUI::getInstance();
542 $settings_modal->setId($this->modal_id);
543 $settings_modal->setType(ilModalGUI::TYPE_LARGE);
544 $this->tpl->addOnLoadCode('$("#' . $this->modal_id . '").study_programme_modal();');
545
546 $content = $settings_modal->getHTML();
547
548 // init js notifications
549 $notifications = new ilAsyncNotifications();
550 $notifications->addJsConfig('events', array('success' => array('study_programme-show_success')));
551 $notifications->initJs();
552
553 // init tree selection explorer
554 $async_explorer = new ilAsyncContainerSelectionExplorer(rawurldecode($this->ctrl->getLinkTarget($this, 'createNewLeaf', '', true, false)));
555 $async_explorer->initJs();
556
557 return $content;
558 }
static addJavaScript(ilGlobalTemplate $main_tpl=null)
Add javascript files that are necessary to run accordion.
static addJavascript()
Adds the javascript to template.
Class ilAsyncNotifications Allows to display async notifications on a page.
static addJavaScript($add_form_loader=false, $js_base_path=null)
Adds all needed js By default is called by ilAsyncPropertyFormGUI::getHTML()
static getInstance()
Get instance.

References ilAsyncPropertyFormGUI\addJavaScript(), ilAsyncContainerSelectionExplorer\addJavascript(), ilAccordionGUI\addJavaScript(), ilModalGUI\getInstance(), and ilModalGUI\TYPE_LARGE.

Referenced by view().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ initTree()

ilObjStudyProgrammeTreeGUI::initTree ( )
protected

Initialize Tree Creates tree instance and set tree configuration.

Definition at line 119 of file class.ilObjStudyProgrammeTreeGUI.php.

120 {
121 $this->tree = new ilObjStudyProgrammeTreeExplorerGUI($this->ref_id, $this->modal_id, "prg_tree", $this, 'view');
122
123 $js_url = rawurldecode($this->ctrl->getLinkTarget($this, 'saveTreeOrder', '', true, false));
124 $this->tree->addJsConf('save_tree_url', $js_url);
125 $this->tree->addJsConf('save_button_id', 'save_order_button');
126 $this->tree->addJsConf('cancel_button_id', 'cancel_order_button');
127 }
Class ilStudyProgrammeTreeGUI ilObjStudyProgrammeTreeExplorerGUI generates the tree output for StudyP...

Referenced by executeCommand().

+ Here is the caller graph for this function:

◆ saveTreeOrder()

ilObjStudyProgrammeTreeGUI::saveTreeOrder ( )
protected

Saves tree node order Data is json encoded from the jstree component.

Returns
string json string
Exceptions
ilException

Definition at line 207 of file class.ilObjStudyProgrammeTreeGUI.php.

208 {
209 $this->checkAccessOrFail('write');
210
211 $treeAsJson = ilUtil::stripSlashes($_POST['tree'] ?? '');
212 $treeData = json_decode($treeAsJson);
213
214 if (!is_array($treeData) || [] === $treeData) {
215 throw new ilStudyProgrammeTreeException("There is no tree data to save!");
216 }
217
218 // saves order recursive
219 $this->storeTreeOrder($treeData);
220
221 return ilAsyncOutputHandler::encodeAsyncResponse(array('success' => true, 'message' => $this->lng->txt('prg_saved_order_successful')));
222 }
storeTreeOrder(array $nodes, $container_sorting=null, int $parent_ref_id=null)
Recursive function for saving the tree order.
Exception is thrown when invariants on the program tree would be violated by manipulation of tree.
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled

References $_POST, checkAccessOrFail(), ilAsyncOutputHandler\encodeAsyncResponse(), storeTreeOrder(), and ilUtil\stripSlashes().

+ Here is the call graph for this function:

◆ setRefId()

ilObjStudyProgrammeTreeGUI::setRefId (   $a_ref_id)

Definition at line 110 of file class.ilObjStudyProgrammeTreeGUI.php.

111 {
112 $this->ref_id = $a_ref_id;
113 }

◆ storeTreeOrder()

ilObjStudyProgrammeTreeGUI::storeTreeOrder ( array  $nodes,
  $container_sorting = null,
int  $parent_ref_id = null 
)
protected

Recursive function for saving the tree order.

Parameters
array$nodes
ilContainerSorting | null$container_sorting
int | null$parent_ref_id

Definition at line 232 of file class.ilObjStudyProgrammeTreeGUI.php.

233 {
234 $sorting_position = array();
235 $position_count = 10;
236
237 $parent_node = ($parent_ref_id === null)? ilObjectFactoryWrapper::singleton()->getInstanceByRefId($this->ref_id) : ilObjectFactoryWrapper::singleton()->getInstanceByRefId($parent_ref_id);
238 $container_sorting = ($container_sorting === null) ? ilContainerSorting::_getInstance(ilObject::_lookupObjectId($this->ref_id)) : $container_sorting;
239
240 foreach ($nodes as $node) {
241 // get ref_id from json
242 $id = $node->id;
243 $id = substr($id, strrpos($id, "_") + 1);
244
245 $sorting_position[$id] = $position_count;
246 $position_count += 10;
247
248 $node_obj = ilObjectFactoryWrapper::singleton()->getInstanceByRefId($id);
249 if ($node_obj instanceof ilObjStudyProgramme) {
250 $node_obj->moveTo($parent_node);
251 } else {
252 // TODO: implement a method on ilObjStudyProgramme to move leafs
253 global $DIC;
254 $tree = $DIC['tree'];
255 $rbacadmin = $DIC['rbacadmin'];
256
257 $tree->moveTree($node_obj->getRefId(), $parent_node->getRefId());
258 $rbacadmin->adjustMovedObjectPermissions($node_obj->getRefId(), $parent_node->getRefId());
259 }
260
261 // recursion if there are children
262 if (isset($node->children)) {
264 }
265 }
266 $container_sorting->savePost($sorting_position);
267 }
static _getInstance($a_obj_id)
get instance by obj_id
$DIC
Definition: xapitoken.php:46

References $DIC, $tree, ilContainerSorting\_getInstance(), ilObject\_lookupObjectId(), ilObjectFactoryWrapper\singleton(), and storeTreeOrder().

Referenced by saveTreeOrder(), and storeTreeOrder().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ view()

ilObjStudyProgrammeTreeGUI::view ( )
protected

Display the tree view.

Returns
string

Definition at line 180 of file class.ilObjStudyProgrammeTreeGUI.php.

181 {
182 $output = $this->tree->getHTML();
183 $output .= $this->initAsyncUIElements();
184
185 return $output;
186 }
initAsyncUIElements()
Initializes all elements used for async-interaction Adds HTML-skeleton for the bootstrap modal dialog...

References initAsyncUIElements().

+ Here is the call graph for this function:

Field Documentation

◆ $access

ilObjStudyProgrammeTreeGUI::$access
protected

Definition at line 35 of file class.ilObjStudyProgrammeTreeGUI.php.

◆ $async_output_handler

ilObjStudyProgrammeTreeGUI::$async_output_handler
protected

Definition at line 77 of file class.ilObjStudyProgrammeTreeGUI.php.

◆ $ctrl

ilObjStudyProgrammeTreeGUI::$ctrl

Definition at line 25 of file class.ilObjStudyProgrammeTreeGUI.php.

◆ $ilias

ilObjStudyProgrammeTreeGUI::$ilias

Definition at line 50 of file class.ilObjStudyProgrammeTreeGUI.php.

Referenced by __construct().

◆ $lng

ilObjStudyProgrammeTreeGUI::$lng

Definition at line 55 of file class.ilObjStudyProgrammeTreeGUI.php.

Referenced by __construct().

◆ $log

ilObjStudyProgrammeTreeGUI::$log
protected

Definition at line 45 of file class.ilObjStudyProgrammeTreeGUI.php.

◆ $modal_id

ilObjStudyProgrammeTreeGUI::$modal_id
protected

Definition at line 72 of file class.ilObjStudyProgrammeTreeGUI.php.

◆ $object

ilObjStudyProgrammeTreeGUI::$object

Definition at line 40 of file class.ilObjStudyProgrammeTreeGUI.php.

◆ $ref_id

ilObjStudyProgrammeTreeGUI::$ref_id
protected

Definition at line 61 of file class.ilObjStudyProgrammeTreeGUI.php.

Referenced by checkAccess(), and checkAccessOrFail().

◆ $toolbar

ilObjStudyProgrammeTreeGUI::$toolbar

Definition at line 82 of file class.ilObjStudyProgrammeTreeGUI.php.

◆ $tpl

ilObjStudyProgrammeTreeGUI::$tpl

Definition at line 30 of file class.ilObjStudyProgrammeTreeGUI.php.

Referenced by __construct().

◆ $tree

ilObjStudyProgrammeTreeGUI::$tree
protected

Definition at line 66 of file class.ilObjStudyProgrammeTreeGUI.php.

Referenced by storeTreeOrder().


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