3declare(strict_types=1);
71 $this->
ctrl = $ilCtrl;
83 $this->modal_id =
"tree_modal";
102 $js_url = rawurldecode($this->
ctrl->getLinkTarget($this,
'saveTreeOrder',
'',
true));
103 $this->tree->addJsConf(
'save_tree_url', $js_url);
104 $this->tree->addJsConf(
'save_button_id',
'save_order_button');
105 $this->tree->addJsConf(
'cancel_button_id',
'cancel_order_button');
117 $cmd = $this->
ctrl->getCmd();
121 if ($cmd ===
"" || $cmd ===
null) {
126 if ($this->tree->handleCommand()) {
136 case "confirmedDelete":
138 case "getContainerSelectionExplorer":
139 case "saveTreeOrder":
140 case "createNewLeaf":
142 $content = $this->$cmd();
145 throw new ilException(
"ilObjStudyProgrammeTreeGUI: " .
146 "Command not supported: $cmd");
155 protected function view(): string
157 $output = $this->tree->getHTML();
182 if ($this->http_wrapper->post()->has(
"tree")) {
183 $tree = $this->http_wrapper->post()->retrieve(
"tree", $this->
refinery->kindlyTo()->string());
186 $treeData = json_decode($treeAsJson,
false, 512, JSON_THROW_ON_ERROR);
188 if (!is_array($treeData) || [] === $treeData) {
193 $this->storeTreeOrder($treeData);
196 [
'success' =>
true,
'message' => $this->
lng->txt(
'prg_saved_order_successful')]
203 protected function storeTreeOrder(
206 int $parent_ref_id =
null
208 $sorting_position = array();
209 $position_count = 10;
219 if (is_null($container_sorting)) {
223 foreach ($nodes as $node) {
226 $id = substr(
$id, strrpos(
$id,
"_") + 1);
228 $sorting_position[
$id] = $position_count;
229 $position_count += 10;
233 $node_obj->moveTo($parent_node);
236 $this->
ilTree->
moveTree($node_obj->getRefId(), $parent_node->getRefId());
237 $this->rbacadmin->adjustMovedObjectPermissions($node_obj->getRefId(), $parent_node->getRefId());
241 if (isset($node->children)) {
242 $this->storeTreeOrder(
249 $container_sorting->savePost($sorting_position);
260 $this->checkAccessOrFail(
'create', $this->http_wrapper->post()->retrieve(
"parent_id", $this->refinery->kindlyTo()->int()));
263 $this->http_wrapper->post()->has(
"target_id") &&
264 $this->http_wrapper->post()->has(
"type") &&
265 $this->http_wrapper->post()->has(
"parent_id")
267 $target_id = $this->http_wrapper->post()->retrieve(
"target_id", $this->
refinery->kindlyTo()->int());
268 $parent_id = $this->http_wrapper->post()->retrieve(
"parent_id", $this->
refinery->kindlyTo()->int());
275 $course_ref->create();
276 $course_ref->createReference();
278 $course_ref->putInTree($parent_id);
282 $course_ref->update();
286 [
'success' =>
true,
'message' => $this->
lng->txt(
'prg_added_course_ref_successful')]
300 rawurldecode($this->
ctrl->getLinkTarget($this,
'createNewLeaf',
'',
true)),
302 $this->http_wrapper->query()
304 $create_leaf_form->setId(
"select_course_explorer");
307 if ($this->http_wrapper->query()->has(
"ref_repexpand")) {
308 $ref_expand = $this->http_wrapper->query()->retrieve(
"ref_repexpand", $this->
refinery->kindlyTo()->int());
311 $create_leaf_form->setExpand($ref_expand);
312 $create_leaf_form->setExpandTarget($this->
ctrl->getLinkTarget($this,
'getContainerSelectionExplorer'));
313 $create_leaf_form->setAsynchExpanding(
true);
314 $create_leaf_form->setTargetGet(
'target_id');
315 $create_leaf_form->setFrameTarget(
"_self");
316 $create_leaf_form->setClickable(
'crs',
true);
317 $create_leaf_form->setTargetType(
'crs');
318 $create_leaf_form->setOutput(0);
320 if ($convert_to_string) {
321 return $create_leaf_form->getOutput();
324 return $create_leaf_form;
334 $create_node_form = $tmp_obj->getAsyncCreationForm();
335 $create_node_form->setTitle(
"");
336 $this->
ctrl->setParameterByClass(
"ilobjstudyprogrammegui",
"new_type",
"prg");
337 $create_node_form->setFormAction($this->
ctrl->getFormActionByClass(
"ilobjstudyprogrammegui",
"save"));
339 return $create_node_form;
351 if ($this->http_wrapper->query()->has(
"ref_id")) {
352 $parent_id = $this->http_wrapper->query()->retrieve(
"ref_id", $this->
refinery->kindlyTo()->int());
354 $this->checkAccessOrFail(
'create', $parent_id);
363 if (!$parent->hasLPChildren()) {
364 $content_new_node = $this->getCreationForm()->getHTML();
365 $accordion->addItem($this->
lng->txt(
'prg_create_new_node'), $content_new_node);
372 if (!$parent->hasChildren() && $this->ilSetting->get(
"obj_dis_creation_crsr") ===
"") {
374 $this->
lng->txt(
'prg_please_select_a_course_for_creating_a_leaf')
376 $content_new_leaf .= $this->getContainerSelectionExplorer();
378 $accordion->addItem($this->
lng->txt(
'prg_create_new_leaf'), $content_new_leaf);
382 if ($added_slides === 1) {
386 $content = $accordion->getHTML(
true);
390 $this->async_output_handler->setHeading($this->
lng->txt(
"prg_async_" . $this->ctrl->getCmd()));
391 $this->async_output_handler->setContent($content);
392 $this->async_output_handler->terminate();
400 protected function delete():
void
402 $this->checkAccessOrFail(
"delete");
404 if (!$this->http_wrapper->query()->has(
"ref_id") || !$this->http_wrapper->query()->has(
"item_ref_id")) {
408 $element_ref_id = $this->http_wrapper->query()->retrieve(
"ref_id", $this->
refinery->kindlyTo()->int());
412 $msg = $this->
lng->txt(
"info_delete_sure");
414 $msg .=
"<br/>" . $this->
lng->txt(
"info_delete_warning_no_trash");
416 $cgui->setHeaderText($msg);
417 $cgui->setFormAction($this->
ctrl->getFormAction($this,
'confirmedDelete',
'',
true));
418 $cgui->setCancel($this->
lng->txt(
"cancel"),
"cancelDelete");
419 $cgui->setConfirm($this->
lng->txt(
"confirm"),
"confirmedDelete");
420 $cgui->setFormName(
'async_form');
425 $alt = $this->
lng->txt(
"icon") .
" " . $this->
lng->txt(
"obj_" .
$type);
429 (
string)$element_ref_id,
434 $cgui->addHiddenItem(
436 $this->http_wrapper->query()->retrieve(
"item_ref_id", $this->refinery->kindlyTo()->string())
439 $content = $cgui->getHTML();
442 $this->async_output_handler->setHeading($msg);
443 $this->async_output_handler->setContent($content);
444 $this->async_output_handler->terminate();
454 $this->checkAccessOrFail(
"delete");
457 (!$this->http_wrapper->post()->has(
"id") || !$this->http_wrapper->post()->has(
"item_ref_id")) &&
458 is_array($this->http_wrapper->post()->retrieve(
460 $this->refinery->kindlyTo()->listOf($this->refinery->kindlyTo()->int())
463 throw new ilException(
"No item select for deletion!");
466 $ids = $this->http_wrapper->post()->retrieve(
468 $this->
refinery->kindlyTo()->listOf($this->refinery->kindlyTo()->int())
470 $current_node = $this->http_wrapper->post()->retrieve(
"item_ref_id", $this->
refinery->kindlyTo()->int());
474 foreach ($ids as
$id) {
477 $not_parent_of_current =
true;
486 return $obj->getRefId();
489 $children_ref_ids = array_map($get_ref_ids, $children_of_node);
490 $not_parent_of_current = (!in_array($current_node, $children_ref_ids));
492 $not_root = ($obj->getRoot() !=
null);
496 $current_node !=
$id &&
498 $not_parent_of_current &&
499 $this->checkAccess(
'delete', $obj->getRefId())
504 if (isset($children_of_node)) {
505 $this->tree->closeCertainNode(
$id);
506 foreach ($children_of_node as $child) {
507 $this->tree->closeCertainNode($child->getRefId());
511 $msg = $this->
lng->txt(
"prg_deleted_safely");
513 $msg = $this->
lng->txt(
"prg_not_allowed_node_to_delete");
543 $settings_modal->setId($this->modal_id);
545 $this->tpl->addOnLoadCode(
'$("#' . $this->modal_id .
'").study_programme_modal();');
547 $content = $settings_modal->getHTML();
551 $notifications->addJsConfig(
'events', array(
'success' => array(
'study_programme-show_success')));
552 $notifications->initJs();
556 rawurldecode($this->
ctrl->getLinkTarget($this,
'createNewLeaf',
'',
true)),
558 $this->http_wrapper->query()
560 $async_explorer->initJs();
571 $save_order_btn->setId(
'save_order_button');
572 $save_order_btn->setUrl(
"javascript:void(0);");
573 $save_order_btn->setOnClick(
"$('body').trigger('study_programme-save_order');");
574 $save_order_btn->setCaption(
'prg_save_tree_order');
577 $cancel_order_btn->setId(
'cancel_order_button');
578 $cancel_order_btn->setUrl(
"javascript:void(0);");
579 $cancel_order_btn->setOnClick(
"$('body').trigger('study_programme-cancel_order');");
580 $cancel_order_btn->setCaption(
'prg_cancel_tree_order');
582 $this->
toolbar->addButtonInstance($save_order_btn);
583 $this->
toolbar->addButtonInstance($cancel_order_btn);
604 if (!$this->checkAccess($permission,
$ref_id)) {
605 throw new ilException(
"You have no permission for " . $permission .
" Object with ref_id " .
$ref_id .
"!");
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static addJavaScript(ilGlobalTemplate $main_tpl=null)
Add javascript files that are necessary to run accordion.
Class ilAsyncContainerSelectionExplorer A class for async ilContainerSelectionExplorer which triggers...
static addJavascript()
Adds the javascript to template.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Class ilAsyncOutputHandler Handles the output for async-requests.
static handleAsyncOutput(string $normal_content, string $async_content=null, bool $apply_to_tpl=true)
Handles async output.
static encodeAsyncResponse(array $data=array())
Encode data as json for async output.
Component logger with individual log levels by component id.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static _getInstance(int $a_obj_id)
Class ilCtrl provides processing control methods.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
loadLanguageModule(string $a_module)
Load language module.
Class ilObjStudyProgrammeGUI class @ilCtrl_Calls ilObjStudyProgrammeGUI: ilPermissionGUI @ilCtrl_Call...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
createNewLeaf()
Creates a new leaf Currently only course references can be created.
ilObjStudyProgramme $object
saveTreeOrder()
Saves tree node order Data is json encoded from the jstree component.
getContainerSelectionExplorer(bool $convert_to_string=true)
Initialize the Course Explorer for creating a leaf.
getToolbar()
Setup the toolbar.
__construct(ilGlobalTemplateInterface $tpl, ilCtrl $ilCtrl, ilAccess $ilAccess, ilToolbarGUI $ilToolbar, ilLanguage $lng, ilComponentLogger $ilLog, ILIAS $ilias, ilSetting $ilSetting, ilTree $ilTree, ilRbacAdmin $rbacadmin, ILIAS\HTTP\Wrapper\WrapperFactory $http_wrapper, ILIAS\Refinery\Factory $refinery)
initAsyncUIElements()
Initializes all elements used for async-interaction Adds HTML-skeleton for the bootstrap modal dialog...
ILIAS Refinery Factory $refinery
getCreationForm()
Returns the async creation form for StudyProgrammes.
view()
Display the tree view.
ilGlobalTemplateInterface $tpl
ILIAS HTTP Wrapper WrapperFactory $http_wrapper
ilAsyncOutputHandler $async_output_handler
executeCommand()
Execute GUI-commands If there is a async request the response is sent as a json string.
create()
Generates the modal window content for the creation form of nodes or leafs If there are already Study...
int $ref_id
Ref-ID of the object.
cancelDelete()
Cancel deletion Return a json string for the async handling.
confirmedDelete()
Deletes a node or a leaf in the tree.
checkAccessOrFail(string $permission, int $ref_id=null)
Checks permission of a object and throws an exception if they are not granted.
ilObjStudyProgrammeTreeExplorerGUI $tree
cancel()
Cancel operation.
initTree()
Initialize Tree Creates tree instance and set tree configuration.
string $modal_id
CSS-ID of the modal windows.
checkAccess(string $permission, int $ref_id=null)
Checks permission of current tree or certain child of it.
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 getClassByType(string $obj_type)
static _lookupObjectId(int $ref_id)
static _lookupType(int $id, bool $reference=false)
static _getIcon(int $obj_id=0, string $size="big", string $type="", bool $offline=false)
Get icon for repository item.
Class ilRbacAdmin Core functions for role based access control.
static deleteObjects(int $a_cur_ref_id, array $a_ids, bool $throw_error_on_already_deleted=true)
Delete objects.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
get(string $a_keyword, ?string $a_default_value=null)
get setting
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
moveTree(int $a_source_id, int $a_target_id, int $a_location=self::POS_LAST_NODE)
Move Tree Implementation @access public.
static stripSlashes(string $a_str, bool $a_strip_html=true, string $a_allow="")
static getSystemMessageHTML(string $a_txt, string $a_type="info")
Get HTML for a system message.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Class ChatMainBarProvider \MainMenu\Provider.
header include for all ilias files.