ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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 $DIC, $ilCtrl, $ilias, $ilLog, $ilSetting, $lng, $tpl, $tree, and initTree().

87  {
88  global $DIC;
89  $tpl = $DIC['tpl'];
90  $ilCtrl = $DIC['ilCtrl'];
91  $ilAccess = $DIC['ilAccess'];
92  $ilToolbar = $DIC['ilToolbar'];
93  $ilLocator = $DIC['ilLocator'];
94  $tree = $DIC['tree'];
95  $lng = $DIC['lng'];
96  $ilLog = $DIC['ilLog'];
97  $ilias = $DIC['ilias'];
98  $ilSetting = $DIC['ilSetting'];
99 
100  $this->ref_id = $a_ref_id;
101  $this->tpl = $tpl;
102  $this->ctrl = $ilCtrl;
103  $this->access = $ilAccess;
104  $this->locator = $ilLocator;
105  $this->tree = $tree;
106  $this->toolbar = $ilToolbar;
107  $this->log = $ilLog;
108  $this->ilias = $ilias;
109  $this->lng = $lng;
110  $this->ilSetting = $ilSetting;
111  $this->modal_id = "tree_modal";
112  $this->async_output_handler = new ilAsyncOutputHandler();
113 
114  $this->initTree();
115 
116  $lng->loadLanguageModule("prg");
117  }
Class ilAsyncOutputHandler Handles the output for async-requests.
ILIAS Setting Class.
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) ...
global $ilSetting
Definition: privfeed.php:17
global $DIC
+ Here is the call graph for this function:

Member Function Documentation

◆ cancel()

ilObjStudyProgrammeTreeGUI::cancel ( )
protected

Cancel operation.

Returns
string

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

References ilAsyncOutputHandler\encodeAsyncResponse().

196  {
198  }
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 510 of file class.ilObjStudyProgrammeTreeGUI.php.

References ilAsyncOutputHandler\encodeAsyncResponse().

510  {
512  }
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 577 of file class.ilObjStudyProgrammeTreeGUI.php.

References $ref_id.

Referenced by checkAccessOrFail(), and confirmedDelete().

577  {
578  $ref_id = ($ref_id === null)? $this->ref_id : $ref_id;
579  $checker = $this->access->checkAccess($permission, '', $ref_id);
580 
581  return $checker;
582  }
+ 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 593 of file class.ilObjStudyProgrammeTreeGUI.php.

References $ref_id, and checkAccess().

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

593  {
594  if(!$this->checkAccess($permission, $ref_id)) {
595  throw new ilException("You have no permission for ".$permission." Object with ref_id ".$ref_id."!");
596  }
597  }
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 450 of file class.ilObjStudyProgrammeTreeGUI.php.

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

450  {
451  $this->checkAccessOrFail("delete");
452 
453  if(!isset($_POST['id'], $_POST['item_ref_id']) && is_array($_POST['id'])) {
454  throw new ilException("No item select for deletion!");
455  }
456 
457  $ids = $_POST['id'];
458  $current_node = (int) $_POST['item_ref_id'];
459  $result = true;
460 
461  foreach($ids as $id) {
462  $obj = ilObjectFactoryWrapper::singleton()->getInstanceByRefId($id);
463 
464  $not_parent_of_current = true;
465  $not_root = true;
466 
467  // do some additional validation if it is a StudyProgramme
468  if($obj instanceof ilObjStudyProgramme) {
469 
470  //check if you are not deleting a parent element of the current element
471  $children_of_node = ilObjStudyProgramme::getAllChildren($obj->getRefId());
472  $get_ref_ids = function ($obj) { return $obj->getRefId(); };
473 
474  $children_ref_ids = array_map($get_ref_ids, $children_of_node);
475  $not_parent_of_current = (!in_array($current_node, $children_ref_ids));
476 
477  $not_root = ($obj->getRoot() != null);
478  }
479 
480  if($current_node != $id && $not_root && $not_parent_of_current && $this->checkAccess('delete', $obj->getRefId())) {
481 
482  ilRepUtil::deleteObjects(null, $id);
483 
484  // deletes the tree-open-node-session storage
485  if(isset($children_of_node)) {
486  $this->tree->closeCertainNode($id);
487  foreach($children_of_node as $child) {
488  $this->tree->closeCertainNode($child->getRefId());
489  }
490  }
491 
492  $msg = $this->lng->txt("prg_deleted_safely");
493 
494  } else {
495  $msg = $this->lng->txt("prg_not_allowed_node_to_delete");
496  $result = false;
497  }
498  }
499 
500  return ilAsyncOutputHandler::encodeAsyncResponse(array('success'=>$result, 'message'=>$msg));
501  }
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.
$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.
Create styles array
The data for the language used.
$_POST["username"]
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 354 of file class.ilObjStudyProgrammeTreeGUI.php.

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

354  {
355  $parent_id = (isset($_GET['ref_id']))? (int) $_GET['ref_id'] : null;
356  $this->checkAccessOrFail('create', $parent_id);
357 
358  $parent = ilObjectFactoryWrapper::singleton()->getInstanceByRefId($parent_id);
359  $accordion = new ilAccordionGUI();
360 
361  $added_slides = 0;
362  if($parent instanceof ilObjStudyProgramme) {
363  // only allow adding new StudyProgramme-Node if there are no lp-children
364  if(!$parent->hasLPChildren()) {
365  $content_new_node = $this->getCreationForm()->getHTML();
366  $accordion->addItem($this->lng->txt('prg_create_new_node'), $content_new_node);
367  $added_slides++;
368  }
369 
370  /* only allow adding new LP-Children if there are no other StudyProgrammes
371  * AND creating crs references is activated in administration
372  */
373  if(!$parent->hasChildren() && $this->ilSetting->get("obj_dis_creation_crsr") === "") {
374  $content_new_leaf = $this->tpl->getMessageHTML($this->lng->txt('prg_please_select_a_course_for_creating_a_leaf'));
375  $content_new_leaf .= $this->getContainerSelectionExplorer();
376 
377  $accordion->addItem($this->lng->txt('prg_create_new_leaf'), $content_new_leaf);
378  $added_slides++;
379  }
380 
381  if($added_slides == 1) {
382  $accordion->setBehaviour(ilAccordionGUI::FIRST_OPEN);
383  }
384 
385  $content = $accordion->getHTML();
386  }
387 
388  // creating modal window output
389  $this->async_output_handler->setHeading($this->lng->txt("prg_async_".$this->ctrl->getCmd()));
390  $this->async_output_handler->setContent($content);
391  $this->async_output_handler->terminate();
392  }
ILIAS Setting Class.
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.
get($a_keyword, $a_default_value=false)
get setting
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 273 of file class.ilObjStudyProgrammeTreeGUI.php.

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

273  {
274  $this->checkAccessOrFail('create', (int) $_POST['parent_id']);
275 
276  if(isset($_POST['target_id'], $_POST['type'], $_POST['parent_id'])) {
277  $target_id = (int) $_POST['target_id'];
278  $parent_id = (int) $_POST['parent_id'];
279 
280  // TODO: more generic way for implementing different type of leafs
281  $course_ref = new ilObjCourseReference();
282  $course_ref->setTitleType(ilObjCourseReference::TITLE_TYPE_REUSE);
283  $course_ref->setTargetRefId($target_id);
284 
285  $course_ref->create();
286  $course_ref->createReference();
287 
288  $course_ref->putInTree($parent_id);
289 
290  // This is how its done in ILIAS. If you set the target ID before the creation, it won't work
291  $course_ref->setTargetId(ilObject::_lookupObjectId($target_id));
292  $course_ref->update();
293  }
294 
295  return ilAsyncOutputHandler::encodeAsyncResponse(array('success'=>true, 'message'=>$this->lng->txt('prg_added_course_ref_successful')));
296  }
$target_id
Definition: goto.php:51
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.
Create styles array
The data for the language used.
$_POST["username"]
+ 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 400 of file class.ilObjStudyProgrammeTreeGUI.php.

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

400  {
401  global $DIC;
402  $ilSetting = $DIC['ilSetting'];
403 
404  $this->checkAccessOrFail("delete");
405 
406  if(!isset($_GET['ref_id'], $_GET['item_ref_id'])) {
407  throw new ilException("Nothing to delete!");
408  }
409 
410  $element_ref_id = (int) $_GET['ref_id'];
411 
412  $cgui = new ilConfirmationGUI();
413 
414  $msg = $this->lng->txt("info_delete_sure");
415 
416  if (!$ilSetting->get('enable_trash'))
417  {
418  $msg .= "<br/>".$this->lng->txt("info_delete_warning_no_trash");
419  }
420  $cgui->setFormAction($this->ctrl->getFormAction($this, 'confirmedDelete', '', true));
421  $cgui->setCancel($this->lng->txt("cancel"), "cancelDelete");
422  $cgui->setConfirm($this->lng->txt("confirm"), "confirmedDelete");
423  $cgui->setFormName('async_form');
424 
425  $obj_id = ilObject::_lookupObjectId($element_ref_id);
426  $type = ilObject::_lookupType($obj_id);
427  $title = call_user_func(array(ilObjectFactory::getClassByType($type),'_lookupTitle'),$obj_id);
428  $alt = $this->lng->txt("icon")." ".$this->lng->txt("obj_".$type);
429 
430  $cgui->addItem("id[]", $element_ref_id, $title,
431  ilObject::_getIcon($obj_id, "small", $type),
432  $alt);
433  $cgui->addHiddenItem('item_ref_id', $_GET['item_ref_id']);
434 
435  $content = $cgui->getHTML();
436 
437  // creating the modal window output
438  $this->async_output_handler->setHeading($msg);
439  $this->async_output_handler->setContent($content);
440  $this->async_output_handler->terminate();
441  }
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.
Create styles array
The data for the language used.
static _lookupType($a_id, $a_reference=false)
lookup object type
global $ilSetting
Definition: privfeed.php:17
global $DIC
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 140 of file class.ilObjStudyProgrammeTreeGUI.php.

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

140  {
141  $cmd = $this->ctrl->getCmd();
142 
143  $this->getToolbar();
144 
145  if ($cmd == "") {
146  $cmd = "view";
147  }
148 
149  // handles tree commands ("openNode", "closeNode", "getNodeAsync")
150  if($this->tree->handleCommand()) {
151  exit();
152  }
153 
154  switch ($cmd) {
155  case "view":
156  case "create":
157  case "save":
158  case "cancel":
159  case "delete":
160  case "confirmedDelete":
161  case "cancelDelete":
162  case "getContainerSelectionExplorer":
163  case "saveTreeOrder":
164  case "createNewLeaf":
165 
166  $content = $this->$cmd();
167  break;
168  default:
169  throw new ilException("ilObjStudyProgrammeTreeGUI: ".
170  "Command not supported: $cmd");
171  }
172 
174  }
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 306 of file class.ilObjStudyProgrammeTreeGUI.php.

References $_GET.

Referenced by create().

306  {
307  $create_leaf_form = new ilAsyncContainerSelectionExplorer(rawurldecode($this->ctrl->getLinkTarget($this, 'createNewLeaf', '', true, false)));
308  $create_leaf_form->setId("select_course_explorer");
309 
310  $ref_expand = ROOT_FOLDER_ID;
311  if(isset($_GET['ref_repexpand'])) {
312  $ref_expand = (int) $_GET['ref_repexpand'];
313  }
314 
315  $create_leaf_form->setExpand($ref_expand);
316  $create_leaf_form->setExpandTarget($this->ctrl->getLinkTarget($this,'getContainerSelectionExplorer'));
317  $create_leaf_form->setAsynchExpanding(true);
318  $create_leaf_form->setTargetGet('target_id');
319  $create_leaf_form->setFrameTarget("_self");
320  $create_leaf_form->setClickable('crs', true);
321  $create_leaf_form->setTargetType('crs');
322  $create_leaf_form->setOutput(0);
323 
324  if($convert_to_string)
325  return $create_leaf_form->getOutput();
326  else
327  return $create_leaf_form;
328  }
$_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 336 of file class.ilObjStudyProgrammeTreeGUI.php.

Referenced by create().

336  {
337  $tmp_obj = new ilObjStudyProgrammeGUI();
338 
339  $create_node_form = $tmp_obj->getAsyncCreationForm();
340  $create_node_form->setTitle("");
341  $this->ctrl->setParameterByClass("ilobjstudyprogrammegui", "new_type", "prg");
342  $create_node_form->setFormAction($this->ctrl->getFormActionByClass("ilobjstudyprogrammegui", "save"));
343 
344  return $create_node_form;
345  }
Class ilObjStudyProgrammeGUI class.
+ Here is the caller graph for this function:

◆ getToolbar()

ilObjStudyProgrammeTreeGUI::getToolbar ( )
protected

Setup the toolbar.

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

References ilLinkButton\getInstance().

Referenced by executeCommand().

551  {
552  $save_order_btn = ilLinkButton::getInstance();
553  $save_order_btn->setId('save_order_button');
554  $save_order_btn->setUrl("javascript:void(0);");
555  $save_order_btn->setOnClick("$('body').trigger('study_programme-save_order');");
556  $save_order_btn->setCaption('prg_save_tree_order');
557 
558  $cancel_order_btn = ilLinkButton::getInstance();
559  $cancel_order_btn->setId('cancel_order_button');
560  $cancel_order_btn->setUrl("javascript:void(0);");
561  $cancel_order_btn->setOnClick("$('body').trigger('study_programme-cancel_order');");
562  $cancel_order_btn->setCaption('prg_cancel_tree_order');
563 
564  $this->toolbar->addButtonInstance($save_order_btn);
565  $this->toolbar->addButtonInstance($cancel_order_btn);
566  }
+ 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 521 of file class.ilObjStudyProgrammeTreeGUI.php.

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

Referenced by view().

521  {
522  // add js files
526 
527  // add bootstrap modal
528  $settings_modal = ilModalGUI::getInstance();
529  $settings_modal->setId($this->modal_id);
530  $settings_modal->setType(ilModalGUI::TYPE_LARGE);
531  $this->tpl->addOnLoadCode('$("#'.$this->modal_id.'").study_programme_modal();');
532 
533  $content = $settings_modal->getHTML();
534 
535  // init js notifications
536  $notifications = new ilAsyncNotifications();
537  $notifications->addJsConfig('events', array('success'=>array('study_programme-show_success')));
538  $notifications->initJs();
539 
540  // init tree selection explorer
541  $async_explorer = new ilAsyncContainerSelectionExplorer(rawurldecode($this->ctrl->getLinkTarget($this, 'createNewLeaf', '', true, false)));
542  $async_explorer->initJs();
543 
544  return $content;
545  }
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.
Create styles array
The data for the language used.
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 124 of file class.ilObjStudyProgrammeTreeGUI.php.

Referenced by __construct().

124  {
125  $this->tree = new ilObjStudyProgrammeTreeExplorerGUI($this->ref_id, $this->modal_id, "prg_tree", $this, 'view');
126 
127  $js_url = rawurldecode($this->ctrl->getLinkTarget($this, 'saveTreeOrder', '', true, false));
128  $this->tree->addJsConf('save_tree_url', $js_url);
129  $this->tree->addJsConf('save_button_id', 'save_order_button');
130  $this->tree->addJsConf('cancel_button_id', 'cancel_order_button');
131  }
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 208 of file class.ilObjStudyProgrammeTreeGUI.php.

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

208  {
209  $this->checkAccessOrFail('write');
210 
211  if(!isset($_POST['tree']) || is_null(json_decode(stripslashes($_POST['tree'])))) {
212  throw new ilStudyProgrammeTreeException("There is no tree data to save!");
213  }
214 
215  // saves order recursive
216  $this->storeTreeOrder(json_decode(stripslashes($_POST['tree'])));
217 
218  return ilAsyncOutputHandler::encodeAsyncResponse(array('success'=>true, 'message'=>$this->lng->txt('prg_saved_order_successful')));
219  }
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.
Create styles array
The data for the language used.
Exception is thrown when invariants on the program tree would be violated by manipulation of tree...
$_POST["username"]
+ 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 229 of file class.ilObjStudyProgrammeTreeGUI.php.

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

Referenced by saveTreeOrder().

229  {
230  $sorting_position = array();
231  $position_count = 10;
232 
233  $parent_node = ($parent_ref_id === null)? ilObjectFactoryWrapper::singleton()->getInstanceByRefId($this->ref_id) : ilObjectFactoryWrapper::singleton()->getInstanceByRefId($parent_ref_id);
234  $container_sorting = ($container_sorting === null) ? ilContainerSorting::_getInstance(ilObject::_lookupObjectId($this->ref_id)) : $container_sorting;
235 
236  foreach($nodes as $node) {
237  // get ref_id from json
238  $id = $node->attr->id;
239  $id = substr($id, strrpos($id, "_")+1);
240 
241  $sorting_position[$id] = $position_count;
242  $position_count+= 10;
243 
244  $node_obj = ilObjectFactoryWrapper::singleton()->getInstanceByRefId($id);
245  if($node_obj instanceof ilObjStudyProgramme) {
246  $node_obj->moveTo($parent_node);
247  } else {
248  // TODO: implement a method on ilObjStudyProgramme to move leafs
249  global $DIC;
250  $tree = $DIC['tree'];
251  $rbacadmin = $DIC['rbacadmin'];
252 
253  $tree->moveTree($node_obj->getRefId(), $parent_node->getRefId());
254  $rbacadmin->adjustMovedObjectPermissions($node_obj->getRefId(), $parent_node->getRefId());
255  }
256 
257  // recursion if there are children
258  if(isset($node->children)) {
260  }
261  }
262  $container_sorting->savePost($sorting_position);
263  }
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.
Create styles array
The data for the language used.
global $DIC
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 182 of file class.ilObjStudyProgrammeTreeGUI.php.

References $output, and initAsyncUIElements().

182  {
183 
184  $output = $this->tree->getHTML();
185  $output .= $this->initAsyncUIElements();
186 
187  return $output;
188  }
if(!is_dir( $entity_dir)) exit("Fatal Error ([A-Za-z0-9]+)\+" &#(? foreach( $entity_files as $file) $output
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: