ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
ilObjStudyProgrammeTreeGUI Class Reference

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

+ Collaboration diagram for ilObjStudyProgrammeTreeGUI:

Public Member Functions

 __construct ($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 ($nodes, $container_sorting=null, $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
 
 $locator
 
 $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 (   $a_ref_id)

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

References $ilCtrl, $ilias, $ilLog, $lng, $tpl, $tree, and initTree().

87  {
88  global $tpl, $ilCtrl, $ilAccess, $ilToolbar, $ilLocator, $tree, $lng, $ilLog, $ilias;
89 
90  $this->ref_id = $a_ref_id;
91  $this->tpl = $tpl;
92  $this->ctrl = $ilCtrl;
93  $this->access = $ilAccess;
94  $this->locator = $ilLocator;
95  $this->tree = $tree;
96  $this->toolbar = $ilToolbar;
97  $this->log = $ilLog;
98  $this->ilias = $ilias;
99  $this->lng = $lng;
100  $this->modal_id = "tree_modal";
101  $this->async_output_handler = new ilAsyncOutputHandler();
102 
103  $this->initTree();
104 
105  $lng->loadLanguageModule("prg");
106  }
Class ilAsyncOutputHandler Handles the output for async-requests.
initTree()
Initialize Tree Creates tree instance and set tree configuration.
global $ilCtrl
Definition: ilias.php:18
redirection script todo: (a better solution should control the processing via a xml file) ...
+ Here is the call graph for this function:

Member Function Documentation

◆ cancel()

ilObjStudyProgrammeTreeGUI::cancel ( )
protected

Cancel operation.

Returns
string

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

References ilAsyncOutputHandler\encodeAsyncResponse().

185  {
187  }
static encodeAsyncResponse(array $data=array())
Encode data as json for async output.
+ 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 494 of file class.ilObjStudyProgrammeTreeGUI.php.

References ilAsyncOutputHandler\encodeAsyncResponse().

494  {
496  }
static encodeAsyncResponse(array $data=array())
Encode data as json for async output.
+ 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 561 of file class.ilObjStudyProgrammeTreeGUI.php.

References $ref_id.

Referenced by checkAccessOrFail(), and confirmedDelete().

561  {
562  $ref_id = ($ref_id === null)? $this->ref_id : $ref_id;
563  $checker = $this->access->checkAccess($permission, '', $ref_id);
564 
565  return $checker;
566  }
+ 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 577 of file class.ilObjStudyProgrammeTreeGUI.php.

References $ref_id, and checkAccess().

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

577  {
578  if(!$this->checkAccess($permission, $ref_id)) {
579  throw new ilException("You have no permission for ".$permission." Object with ref_id ".$ref_id."!");
580  }
581  }
Base class for ILIAS Exception handling.
checkAccess($permission, $ref_id=null)
Checks permission of current tree or certain child of it.
+ 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 434 of file class.ilObjStudyProgrammeTreeGUI.php.

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

434  {
435  $this->checkAccessOrFail("delete");
436 
437  if(!isset($_POST['id'], $_POST['item_ref_id']) && is_array($_POST['id'])) {
438  throw new ilException("No item select for deletion!");
439  }
440 
441  $ids = $_POST['id'];
442  $current_node = (int) $_POST['item_ref_id'];
443  $result = true;
444 
445  foreach($ids as $id) {
447 
448  $not_parent_of_current = true;
449  $not_root = true;
450 
451  // do some additional validation if it is a StudyProgramme
452  if($obj instanceof ilObjStudyProgramme) {
453 
454  //check if you are not deleting a parent element of the current element
455  $children_of_node = ilObjStudyProgramme::getAllChildren($obj->getRefId());
456  $get_ref_ids = function ($obj) { return $obj->getRefId(); };
457 
458  $children_ref_ids = array_map($get_ref_ids, $children_of_node);
459  $not_parent_of_current = (!in_array($current_node, $children_ref_ids));
460 
461  $not_root = ($obj->getRoot() != null);
462  }
463 
464  if($current_node != $id && $not_root && $not_parent_of_current && $this->checkAccess('delete', $obj->getRefId())) {
465 
466  ilRepUtil::deleteObjects(null, $id);
467 
468  // deletes the tree-open-node-session storage
469  if(isset($children_of_node)) {
470  $this->tree->closeCertainNode($id);
471  foreach($children_of_node as $child) {
472  $this->tree->closeCertainNode($child->getRefId());
473  }
474  }
475 
476  $msg = $this->lng->txt("prg_deleted_safely");
477 
478  } else {
479  $msg = $this->lng->txt("prg_not_allowed_node_to_delete");
480  $result = false;
481  }
482  }
483 
484  return ilAsyncOutputHandler::encodeAsyncResponse(array('success'=>$result, 'message'=>$msg));
485  }
static getAllChildren($a_ref_id)
Get a list of all ilObjStudyProgrammes in the subtree starting at $a_ref_id.
Base class for ILIAS Exception handling.
$_POST['username']
Definition: cron.php:12
$result
checkAccess($permission, $ref_id=null)
Checks permission of current tree or certain child of it.
checkAccessOrFail($permission, $ref_id=null)
Checks permission of a object and throws an exception if they are not granted.
static encodeAsyncResponse(array $data=array())
Encode data as json for async output.
Class ilObjStudyProgramme.
getInstanceByRefId($a_ref_id, $stop_on_error=true)
static deleteObjects($a_cur_ref_id, $a_ids)
Delete objects.
+ 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 341 of file class.ilObjStudyProgrammeTreeGUI.php.

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

341  {
342  $parent_id = (isset($_GET['ref_id']))? (int) $_GET['ref_id'] : null;
343  $this->checkAccessOrFail('create', $parent_id);
344 
345  $parent = ilObjectFactoryWrapper::singleton()->getInstanceByRefId($parent_id);
346  $accordion = new ilAccordionGUI();
347 
348  $added_slides = 0;
349  if($parent instanceof ilObjStudyProgramme) {
350  // only allow adding new StudyProgramme-Node if there are no lp-children
351  if(!$parent->hasLPChildren()) {
352  $content_new_node = $this->getCreationForm()->getHTML();
353  $accordion->addItem($this->lng->txt('prg_create_new_node'), $content_new_node);
354  $added_slides++;
355  }
356 
357  // only allow adding new LP-Children if there are no other StudyProgrammes
358  if(!$parent->hasChildren()) {
359  $content_new_leaf = $this->tpl->getMessageHTML($this->lng->txt('prg_please_select_a_course_for_creating_a_leaf'));
360  $content_new_leaf .= $this->getContainerSelectionExplorer();
361 
362  $accordion->addItem($this->lng->txt('prg_create_new_leaf'), $content_new_leaf);
363  $added_slides++;
364  }
365 
366  if($added_slides == 1) {
367  $accordion->setBehaviour(ilAccordionGUI::FIRST_OPEN);
368  }
369 
370  $content = $accordion->getHTML();
371  }
372 
373  // creating modal window output
374  $this->async_output_handler->setHeading($this->lng->txt("prg_async_".$this->ctrl->getCmd()));
375  $this->async_output_handler->setContent($content);
376  $this->async_output_handler->terminate();
377  }
getContainerSelectionExplorer($convert_to_string=true)
Initialize the Course Explorer for creating a leaf.
$_GET["client_id"]
checkAccessOrFail($permission, $ref_id=null)
Checks permission of a object and throws an exception if they are not granted.
Class ilObjStudyProgramme.
getCreationForm()
Returns the async creation form for StudyProgrammes.
Accordion user interface class.
+ 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 260 of file class.ilObjStudyProgrammeTreeGUI.php.

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

260  {
261  $this->checkAccessOrFail('create', (int) $_POST['parent_id']);
262 
263  if(isset($_POST['target_id'], $_POST['type'], $_POST['parent_id'])) {
264  $target_id = (int) $_POST['target_id'];
265  $parent_id = (int) $_POST['parent_id'];
266 
267  // TODO: more generic way for implementing different type of leafs
268  $course_ref = new ilObjCourseReference();
269  $course_ref->setTitleType(ilObjCourseReference::TITLE_TYPE_REUSE);
270  $course_ref->setTargetRefId($target_id);
271 
272  $course_ref->create();
273  $course_ref->createReference();
274 
275  $course_ref->putInTree($parent_id);
276 
277  // This is how its done in ILIAS. If you set the target ID before the creation, it won't work
278  $course_ref->setTargetId(ilObject::_lookupObjectId($target_id));
279  $course_ref->update();
280  }
281 
282  return ilAsyncOutputHandler::encodeAsyncResponse(array('success'=>true, 'message'=>$this->lng->txt('prg_added_course_ref_successful')));
283  }
$_POST['username']
Definition: cron.php:12
$target_id
Definition: goto.php:88
static _lookupObjectId($a_ref_id)
lookup object id
checkAccessOrFail($permission, $ref_id=null)
Checks permission of a object and throws an exception if they are not granted.
static encodeAsyncResponse(array $data=array())
Encode data as json for async output.
+ 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 385 of file class.ilObjStudyProgrammeTreeGUI.php.

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

385  {
386  global $ilSetting;
387 
388  $this->checkAccessOrFail("delete");
389 
390  if(!isset($_GET['ref_id'], $_GET['item_ref_id'])) {
391  throw new ilException("Nothing to delete!");
392  }
393 
394  $element_ref_id = (int) $_GET['ref_id'];
395 
396  $cgui = new ilConfirmationGUI();
397 
398  $msg = $this->lng->txt("info_delete_sure");
399 
400  if (!$ilSetting->get('enable_trash'))
401  {
402  $msg .= "<br/>".$this->lng->txt("info_delete_warning_no_trash");
403  }
404  $cgui->setFormAction($this->ctrl->getFormAction($this, 'confirmedDelete', '', true));
405  $cgui->setCancel($this->lng->txt("cancel"), "cancelDelete");
406  $cgui->setConfirm($this->lng->txt("confirm"), "confirmedDelete");
407  $cgui->setFormName('async_form');
408 
409  $obj_id = ilObject::_lookupObjectId($element_ref_id);
410  $type = ilObject::_lookupType($obj_id);
411  $title = call_user_func(array(ilObjectFactory::getClassByType($type),'_lookupTitle'),$obj_id);
412  $alt = $this->lng->txt("icon")." ".$this->lng->txt("obj_".$type);
413 
414  $cgui->addItem("id[]", $element_ref_id, $title,
415  ilObject::_getIcon($obj_id, "small", $type),
416  $alt);
417  $cgui->addHiddenItem('item_ref_id', $_GET['item_ref_id']);
418 
419  $content = $cgui->getHTML();
420 
421  // creating the modal window output
422  $this->async_output_handler->setHeading($msg);
423  $this->async_output_handler->setContent($content);
424  $this->async_output_handler->terminate();
425  }
static getClassByType($a_obj_type)
Get class by type.
static _getIcon($a_obj_id="", $a_size="big", $a_type="", $a_offline=false)
Get icon for repository item.
Base class for ILIAS Exception handling.
$_GET["client_id"]
static _lookupObjectId($a_ref_id)
lookup object id
checkAccessOrFail($permission, $ref_id=null)
Checks permission of a object and throws an exception if they are not granted.
static _lookupType($a_id, $a_reference=false)
lookup object type
global $ilSetting
Definition: privfeed.php:40
Confirmation screen class.
+ 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 129 of file class.ilObjStudyProgrammeTreeGUI.php.

References $cmd, exit, getToolbar(), and ilAsyncOutputHandler\handleAsyncOutput().

129  {
130  $cmd = $this->ctrl->getCmd();
131 
132  $this->getToolbar();
133 
134  if ($cmd == "") {
135  $cmd = "view";
136  }
137 
138  // handles tree commands ("openNode", "closeNode", "getNodeAsync")
139  if($this->tree->handleCommand()) {
140  exit();
141  }
142 
143  switch ($cmd) {
144  case "view":
145  case "create":
146  case "save":
147  case "cancel":
148  case "delete":
149  case "confirmedDelete":
150  case "cancelDelete":
151  case "getContainerSelectionExplorer":
152  case "saveTreeOrder":
153  case "createNewLeaf":
154 
155  $content = $this->$cmd();
156  break;
157  default:
158  throw new ilException("ilObjStudyProgrammeTreeGUI: ".
159  "Command not supported: $cmd");
160  }
161 
163  }
exit
Definition: login.php:54
Base class for ILIAS Exception handling.
$cmd
Definition: sahs_server.php:35
static handleAsyncOutput($normal_content, $async_content=null, $apply_to_tpl=true)
Handles async output.
+ 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 293 of file class.ilObjStudyProgrammeTreeGUI.php.

References $_GET.

Referenced by create().

293  {
294  $create_leaf_form = new ilAsyncContainerSelectionExplorer(rawurldecode($this->ctrl->getLinkTarget($this, 'createNewLeaf', '', true, false)));
295  $create_leaf_form->setId("select_course_explorer");
296 
297  $ref_expand = ROOT_FOLDER_ID;
298  if(isset($_GET['ref_repexpand'])) {
299  $ref_expand = (int) $_GET['ref_repexpand'];
300  }
301 
302  $create_leaf_form->setExpand($ref_expand);
303  $create_leaf_form->setExpandTarget($this->ctrl->getLinkTarget($this,'getContainerSelectionExplorer'));
304  $create_leaf_form->setAsynchExpanding(true);
305  $create_leaf_form->setTargetGet('target_id');
306  $create_leaf_form->setFrameTarget("_self");
307  $create_leaf_form->setClickable('crs', true);
308  $create_leaf_form->setTargetType('crs');
309  $create_leaf_form->setOutput(0);
310 
311  if($convert_to_string)
312  return $create_leaf_form->getOutput();
313  else
314  return $create_leaf_form;
315  }
$_GET["client_id"]
Class ilAsyncContainerSelectionExplorer A class for a async ilContainerSelectionExplorer which trigge...
+ Here is the caller graph for this function:

◆ getCreationForm()

ilObjStudyProgrammeTreeGUI::getCreationForm ( )
protected

Returns the async creation form for StudyProgrammes.

Returns
ilAsyncPropertyFormGUI

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

Referenced by create().

323  {
324  $tmp_obj = new ilObjStudyProgrammeGUI();
325 
326  $create_node_form = $tmp_obj->getAsyncCreationForm();
327  $create_node_form->setTitle("");
328  $this->ctrl->setParameterByClass("ilobjstudyprogrammegui", "new_type", "prg");
329  $create_node_form->setFormAction($this->ctrl->getFormActionByClass("ilobjstudyprogrammegui", "save"));
330 
331  return $create_node_form;
332  }
Class ilObjStudyProgrammeGUI class.
+ Here is the caller graph for this function:

◆ getToolbar()

ilObjStudyProgrammeTreeGUI::getToolbar ( )
protected

Setup the toolbar.

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

References ilLinkButton\getInstance().

Referenced by executeCommand().

535  {
536  $save_order_btn = ilLinkButton::getInstance();
537  $save_order_btn->setId('save_order_button');
538  $save_order_btn->setUrl("javascript:void(0);");
539  $save_order_btn->setOnClick("$('body').trigger('study_programme-save_order');");
540  $save_order_btn->setCaption('prg_save_tree_order');
541 
542  $cancel_order_btn = ilLinkButton::getInstance();
543  $cancel_order_btn->setId('cancel_order_button');
544  $cancel_order_btn->setUrl("javascript:void(0);");
545  $cancel_order_btn->setOnClick("$('body').trigger('study_programme-cancel_order');");
546  $cancel_order_btn->setCaption('prg_cancel_tree_order');
547 
548  $this->toolbar->addButtonInstance($save_order_btn);
549  $this->toolbar->addButtonInstance($cancel_order_btn);
550  }
+ 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 505 of file class.ilObjStudyProgrammeTreeGUI.php.

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

Referenced by view().

505  {
506  // add js files
510 
511  // add bootstrap modal
512  $settings_modal = ilModalGUI::getInstance();
513  $settings_modal->setId($this->modal_id);
514  $settings_modal->setType(ilModalGUI::TYPE_LARGE);
515  $this->tpl->addOnLoadCode('$("#'.$this->modal_id.'").study_programme_modal();');
516 
517  $content = $settings_modal->getHTML();
518 
519  // init js notifications
520  $notifications = new ilAsyncNotifications();
521  $notifications->addJsConfig('events', array('success'=>array('study_programme-show_success')));
522  $notifications->initJs();
523 
524  // init tree selection explorer
525  $async_explorer = new ilAsyncContainerSelectionExplorer(rawurldecode($this->ctrl->getLinkTarget($this, 'createNewLeaf', '', true, false)));
526  $async_explorer->initJs();
527 
528  return $content;
529  }
Class ilAsyncNotifications Allows to display async notifications on a page.
static addJavaScript()
Add javascript files that are necessary to run accordion.
static addJavaScript($add_form_loader=false, $js_base_path=null)
Adds all needed js By default is called by ilAsyncPropertyFormGUI::getHTML()
static addJavascript()
Adds the javascript to template.
static getInstance()
Get instance.
Class ilAsyncContainerSelectionExplorer A class for a async ilContainerSelectionExplorer which trigge...
+ 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 113 of file class.ilObjStudyProgrammeTreeGUI.php.

Referenced by __construct().

113  {
114  $this->tree = new ilObjStudyProgrammeTreeExplorerGUI($this->ref_id, $this->modal_id, "prg_tree", $this, 'view');
115 
116  $js_url = rawurldecode($this->ctrl->getLinkTarget($this, 'saveTreeOrder', '', true, false));
117  $this->tree->addJsConf('save_tree_url', $js_url);
118  $this->tree->addJsConf('save_button_id', 'save_order_button');
119  $this->tree->addJsConf('cancel_button_id', 'cancel_order_button');
120  }
Class ilStudyProgrammeTreeGUI ilObjStudyProgrammeTreeExplorerGUI generates the tree output for StudyP...
+ 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 197 of file class.ilObjStudyProgrammeTreeGUI.php.

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

197  {
198  $this->checkAccessOrFail('write');
199 
200  if(!isset($_POST['tree']) || is_null(json_decode(stripslashes($_POST['tree'])))) {
201  throw new ilStudyProgrammeTreeException("There is no tree data to save!");
202  }
203 
204  // saves order recursive
205  $this->storeTreeOrder(json_decode(stripslashes($_POST['tree'])));
206 
207  return ilAsyncOutputHandler::encodeAsyncResponse(array('success'=>true, 'message'=>$this->lng->txt('prg_saved_order_successful')));
208  }
$_POST['username']
Definition: cron.php:12
checkAccessOrFail($permission, $ref_id=null)
Checks permission of a object and throws an exception if they are not granted.
static encodeAsyncResponse(array $data=array())
Encode data as json for async output.
storeTreeOrder($nodes, $container_sorting=null, $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...
+ Here is the call graph for this function:

◆ storeTreeOrder()

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

Recursive function for saving the tree order.

Parameters
[ilObjStudyProgramme]$nodes
ilContainerSorting | null$container_sorting
int | null$parent_ref_id

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

References $tree, ilContainerSorting\_getInstance(), ilObject\_lookupObjectId(), and ilObjectFactoryWrapper\getInstanceByRefId().

Referenced by saveTreeOrder().

218  {
219  $sorting_position = array();
220  $position_count = 10;
221 
222  $parent_node = ($parent_ref_id === null)? ilObjectFactoryWrapper::getInstanceByRefId($this->ref_id) : ilObjectFactoryWrapper::getInstanceByRefId($parent_ref_id);
223  $container_sorting = ($container_sorting === null) ? ilContainerSorting::_getInstance(ilObject::_lookupObjectId($this->ref_id)) : $container_sorting;
224 
225  foreach($nodes as $node) {
226  // get ref_id from json
227  $id = $node->attr->id;
228  $id = substr($id, strrpos($id, "_")+1);
229 
230  $sorting_position[$id] = $position_count;
231  $position_count+= 10;
232 
234  if($node_obj instanceof ilObjStudyProgramme) {
235  $node_obj->moveTo($parent_node);
236  } else {
237  // TODO: implement a method on ilObjStudyProgramme to move leafs
238  global $tree, $rbacadmin;
239 
240  $tree->moveTree($node_obj->getRefId(), $parent_node->getRefId());
241  $rbacadmin->adjustMovedObjectPermissions($node_obj->getRefId(), $parent_node->getRefId());
242  }
243 
244  // recursion if there are children
245  if(isset($node->children)) {
247  }
248  }
249  $container_sorting->savePost($sorting_position);
250  }
static _lookupObjectId($a_ref_id)
lookup object id
storeTreeOrder($nodes, $container_sorting=null, $parent_ref_id=null)
Recursive function for saving the tree order.
Class ilObjStudyProgramme.
getInstanceByRefId($a_ref_id, $stop_on_error=true)
static _getInstance($a_obj_id)
get instance by obj_id
+ 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 171 of file class.ilObjStudyProgrammeTreeGUI.php.

References initAsyncUIElements().

171  {
172 
173  $output = $this->tree->getHTML();
174  $output .= $this->initAsyncUIElements();
175 
176  return $output;
177  }
initAsyncUIElements()
Initializes all elements used for async-interaction Adds HTML-skeleton for the bootstrap modal dialog...
+ Here is the call graph for this function:

Field Documentation

◆ $access

ilObjStudyProgrammeTreeGUI::$access
protected

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

◆ $async_output_handler

ilObjStudyProgrammeTreeGUI::$async_output_handler
protected

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

◆ $ctrl

ilObjStudyProgrammeTreeGUI::$ctrl

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

◆ $ilias

ilObjStudyProgrammeTreeGUI::$ilias

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

Referenced by __construct().

◆ $lng

ilObjStudyProgrammeTreeGUI::$lng

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

Referenced by __construct().

◆ $locator

ilObjStudyProgrammeTreeGUI::$locator
protected

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

◆ $log

ilObjStudyProgrammeTreeGUI::$log
protected

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

◆ $modal_id

ilObjStudyProgrammeTreeGUI::$modal_id
protected

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

◆ $object

ilObjStudyProgrammeTreeGUI::$object

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

◆ $ref_id

ilObjStudyProgrammeTreeGUI::$ref_id
protected

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

Referenced by checkAccess(), and checkAccessOrFail().

◆ $toolbar

ilObjStudyProgrammeTreeGUI::$toolbar

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

◆ $tpl

ilObjStudyProgrammeTreeGUI::$tpl

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

Referenced by __construct().

◆ $tree

ilObjStudyProgrammeTreeGUI::$tree
protected

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

Referenced by __construct(), and storeTreeOrder().


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