ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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 88 of file class.ilObjStudyProgrammeTreeGUI.php.

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

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

Member Function Documentation

◆ cancel()

ilObjStudyProgrammeTreeGUI::cancel ( )
protected

Cancel operation.

Returns
string

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

References ilAsyncOutputHandler\encodeAsyncResponse().

201  {
203  }
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 527 of file class.ilObjStudyProgrammeTreeGUI.php.

References ilAsyncOutputHandler\encodeAsyncResponse().

528  {
530  }
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 597 of file class.ilObjStudyProgrammeTreeGUI.php.

References $ref_id.

Referenced by checkAccessOrFail(), and confirmedDelete().

598  {
599  $ref_id = ($ref_id === null)? $this->ref_id : $ref_id;
600  $checker = $this->access->checkAccess($permission, '', $ref_id);
601 
602  return $checker;
603  }
+ 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 614 of file class.ilObjStudyProgrammeTreeGUI.php.

References $ref_id, and checkAccess().

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

615  {
616  if (!$this->checkAccess($permission, $ref_id)) {
617  throw new ilException("You have no permission for " . $permission . " Object with ref_id " . $ref_id . "!");
618  }
619  }
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 466 of file class.ilObjStudyProgrammeTreeGUI.php.

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

467  {
468  $this->checkAccessOrFail("delete");
469 
470  if (!isset($_POST['id'], $_POST['item_ref_id']) && is_array($_POST['id'])) {
471  throw new ilException("No item select for deletion!");
472  }
473 
474  $ids = $_POST['id'];
475  $current_node = (int) $_POST['item_ref_id'];
476  $result = true;
477 
478  foreach ($ids as $id) {
479  $obj = ilObjectFactoryWrapper::singleton()->getInstanceByRefId($id);
480 
481  $not_parent_of_current = true;
482  $not_root = true;
483 
484  // do some additional validation if it is a StudyProgramme
485  if ($obj instanceof ilObjStudyProgramme) {
486 
487  //check if you are not deleting a parent element of the current element
488  $children_of_node = ilObjStudyProgramme::getAllChildren($obj->getRefId());
489  $get_ref_ids = function ($obj) {
490  return $obj->getRefId();
491  };
492 
493  $children_ref_ids = array_map($get_ref_ids, $children_of_node);
494  $not_parent_of_current = (!in_array($current_node, $children_ref_ids));
495 
496  $not_root = ($obj->getRoot() != null);
497  }
498 
499  if ($current_node != $id && $not_root && $not_parent_of_current && $this->checkAccess('delete', $obj->getRefId())) {
500  ilRepUtil::deleteObjects(null, $id);
501 
502  // deletes the tree-open-node-session storage
503  if (isset($children_of_node)) {
504  $this->tree->closeCertainNode($id);
505  foreach ($children_of_node as $child) {
506  $this->tree->closeCertainNode($child->getRefId());
507  }
508  }
509 
510  $msg = $this->lng->txt("prg_deleted_safely");
511  } else {
512  $msg = $this->lng->txt("prg_not_allowed_node_to_delete");
513  $result = false;
514  }
515  }
516 
517  return ilAsyncOutputHandler::encodeAsyncResponse(array('success'=>$result, 'message'=>$msg));
518  }
static getAllChildren($a_ref_id)
Get a list of all ilObjStudyProgrammes in the subtree starting at $a_ref_id.
$result
if(!array_key_exists('StateId', $_REQUEST)) $id
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 365 of file class.ilObjStudyProgrammeTreeGUI.php.

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

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

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

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

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

413  {
414  global $DIC;
415  $ilSetting = $DIC['ilSetting'];
416 
417  $this->checkAccessOrFail("delete");
418 
419  if (!isset($_GET['ref_id'], $_GET['item_ref_id'])) {
420  throw new ilException("Nothing to delete!");
421  }
422 
423  $element_ref_id = (int) $_GET['ref_id'];
424 
425  $cgui = new ilConfirmationGUI();
426 
427  $msg = $this->lng->txt("info_delete_sure");
428 
429  if (!$ilSetting->get('enable_trash')) {
430  $msg .= "<br/>" . $this->lng->txt("info_delete_warning_no_trash");
431  }
432  $cgui->setFormAction($this->ctrl->getFormAction($this, 'confirmedDelete', '', true));
433  $cgui->setCancel($this->lng->txt("cancel"), "cancelDelete");
434  $cgui->setConfirm($this->lng->txt("confirm"), "confirmedDelete");
435  $cgui->setFormName('async_form');
436 
437  $obj_id = ilObject::_lookupObjectId($element_ref_id);
438  $type = ilObject::_lookupType($obj_id);
439  $title = call_user_func(array(ilObjectFactory::getClassByType($type),'_lookupTitle'), $obj_id);
440  $alt = $this->lng->txt("icon") . " " . $this->lng->txt("obj_" . $type);
441 
442  $cgui->addItem(
443  "id[]",
444  $element_ref_id,
445  $title,
446  ilObject::_getIcon($obj_id, "small", $type),
447  $alt
448  );
449  $cgui->addHiddenItem('item_ref_id', $_GET['item_ref_id']);
450 
451  $content = $cgui->getHTML();
452 
453  // creating the modal window output
454  $this->async_output_handler->setHeading($msg);
455  $this->async_output_handler->setContent($content);
456  $this->async_output_handler->terminate();
457  }
static _getIcon( $a_obj_id="", $a_size="big", $a_type="", $a_offline=false)
Get icon for repository item.
static getClassByType($a_obj_type)
Get class by type.
$type
global $DIC
Definition: saml.php:7
$_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
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 143 of file class.ilObjStudyProgrammeTreeGUI.php.

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

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

References $_GET.

Referenced by create().

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

Referenced by create().

347  {
348  $tmp_obj = new ilObjStudyProgrammeGUI();
349 
350  $create_node_form = $tmp_obj->getAsyncCreationForm();
351  $create_node_form->setTitle("");
352  $this->ctrl->setParameterByClass("ilobjstudyprogrammegui", "new_type", "prg");
353  $create_node_form->setFormAction($this->ctrl->getFormActionByClass("ilobjstudyprogrammegui", "save"));
354 
355  return $create_node_form;
356  }
Class ilObjStudyProgrammeGUI class.
+ Here is the caller graph for this function:

◆ getToolbar()

ilObjStudyProgrammeTreeGUI::getToolbar ( )
protected

Setup the toolbar.

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

References ilLinkButton\getInstance().

Referenced by executeCommand().

571  {
572  $save_order_btn = ilLinkButton::getInstance();
573  $save_order_btn->setId('save_order_button');
574  $save_order_btn->setUrl("javascript:void(0);");
575  $save_order_btn->setOnClick("$('body').trigger('study_programme-save_order');");
576  $save_order_btn->setCaption('prg_save_tree_order');
577 
578  $cancel_order_btn = ilLinkButton::getInstance();
579  $cancel_order_btn->setId('cancel_order_button');
580  $cancel_order_btn->setUrl("javascript:void(0);");
581  $cancel_order_btn->setOnClick("$('body').trigger('study_programme-cancel_order');");
582  $cancel_order_btn->setCaption('prg_cancel_tree_order');
583 
584  $this->toolbar->addButtonInstance($save_order_btn);
585  $this->toolbar->addButtonInstance($cancel_order_btn);
586  }
+ 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 539 of file class.ilObjStudyProgrammeTreeGUI.php.

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

Referenced by view().

540  {
541  // add js files
545 
546  // add bootstrap modal
547  $settings_modal = ilModalGUI::getInstance();
548  $settings_modal->setId($this->modal_id);
549  $settings_modal->setType(ilModalGUI::TYPE_LARGE);
550  $this->tpl->addOnLoadCode('$("#' . $this->modal_id . '").study_programme_modal();');
551 
552  $content = $settings_modal->getHTML();
553 
554  // init js notifications
555  $notifications = new ilAsyncNotifications();
556  $notifications->addJsConfig('events', array('success'=>array('study_programme-show_success')));
557  $notifications->initJs();
558 
559  // init tree selection explorer
560  $async_explorer = new ilAsyncContainerSelectionExplorer(rawurldecode($this->ctrl->getLinkTarget($this, 'createNewLeaf', '', true, false)));
561  $async_explorer->initJs();
562 
563  return $content;
564  }
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 addJavaScript(ilTemplate $main_tpl=null)
Add javascript files that are necessary to run accordion.
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 126 of file class.ilObjStudyProgrammeTreeGUI.php.

Referenced by __construct().

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

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

214  {
215  $this->checkAccessOrFail('write');
216 
217  if (!isset($_POST['tree']) || is_null(json_decode(stripslashes($_POST['tree'])))) {
218  throw new ilStudyProgrammeTreeException("There is no tree data to save!");
219  }
220 
221  // saves order recursive
222  $this->storeTreeOrder(json_decode(stripslashes($_POST['tree'])));
223 
224  return ilAsyncOutputHandler::encodeAsyncResponse(array('success'=>true, 'message'=>$this->lng->txt('prg_saved_order_successful')));
225  }
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 235 of file class.ilObjStudyProgrammeTreeGUI.php.

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

Referenced by saveTreeOrder().

236  {
237  $sorting_position = array();
238  $position_count = 10;
239 
240  $parent_node = ($parent_ref_id === null)? ilObjectFactoryWrapper::singleton()->getInstanceByRefId($this->ref_id) : ilObjectFactoryWrapper::singleton()->getInstanceByRefId($parent_ref_id);
241  $container_sorting = ($container_sorting === null) ? ilContainerSorting::_getInstance(ilObject::_lookupObjectId($this->ref_id)) : $container_sorting;
242 
243  foreach ($nodes as $node) {
244  // get ref_id from json
245  $id = $node->attr->id;
246  $id = substr($id, strrpos($id, "_")+1);
247 
248  $sorting_position[$id] = $position_count;
249  $position_count+= 10;
250 
251  $node_obj = ilObjectFactoryWrapper::singleton()->getInstanceByRefId($id);
252  if ($node_obj instanceof ilObjStudyProgramme) {
253  $node_obj->moveTo($parent_node);
254  } else {
255  // TODO: implement a method on ilObjStudyProgramme to move leafs
256  global $DIC;
257  $tree = $DIC['tree'];
258  $rbacadmin = $DIC['rbacadmin'];
259 
260  $tree->moveTree($node_obj->getRefId(), $parent_node->getRefId());
261  $rbacadmin->adjustMovedObjectPermissions($node_obj->getRefId(), $parent_node->getRefId());
262  }
263 
264  // recursion if there are children
265  if (isset($node->children)) {
267  }
268  }
269  $container_sorting->savePost($sorting_position);
270  }
global $DIC
Definition: saml.php:7
if(!array_key_exists('StateId', $_REQUEST)) $id
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.
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 186 of file class.ilObjStudyProgrammeTreeGUI.php.

References $output, and initAsyncUIElements().

187  {
188  $output = $this->tree->getHTML();
189  $output .= $this->initAsyncUIElements();
190 
191  return $output;
192  }
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 35 of file class.ilObjStudyProgrammeTreeGUI.php.

◆ $async_output_handler

ilObjStudyProgrammeTreeGUI::$async_output_handler
protected

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

◆ $ctrl

ilObjStudyProgrammeTreeGUI::$ctrl

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

◆ $ilias

ilObjStudyProgrammeTreeGUI::$ilias

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

Referenced by __construct().

◆ $lng

ilObjStudyProgrammeTreeGUI::$lng

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

Referenced by __construct().

◆ $locator

ilObjStudyProgrammeTreeGUI::$locator
protected

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

◆ $log

ilObjStudyProgrammeTreeGUI::$log
protected

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

◆ $modal_id

ilObjStudyProgrammeTreeGUI::$modal_id
protected

Definition at line 76 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 65 of file class.ilObjStudyProgrammeTreeGUI.php.

Referenced by checkAccess(), and checkAccessOrFail().

◆ $toolbar

ilObjStudyProgrammeTreeGUI::$toolbar

Definition at line 86 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 70 of file class.ilObjStudyProgrammeTreeGUI.php.

Referenced by __construct(), and storeTreeOrder().


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