3require_once(
"./Modules/StudyProgramme/classes/class.ilObjStudyProgrammeTreeExplorerGUI.php");
4require_once(
"./Services/UIComponent/Modal/classes/class.ilModalGUI.php");
5require_once(
"./Services/Accordion/classes/class.ilAccordionGUI.php");
6require_once(
"./Modules/StudyProgramme/classes/helpers/class.ilAsyncContainerSelectionExplorer.php");
7require_once(
"./Modules/StudyProgramme/classes/helpers/class.ilAsyncPropertyFormGUI.php");
8require_once(
'./Services/Container/classes/class.ilContainerSorting.php');
9require_once(
"./Services/Utilities/classes/class.ilConfirmationGUI.php");
10require_once(
"./Modules/StudyProgramme/classes/helpers/class.ilAsyncNotifications.php");
11require_once(
"./Modules/CourseReference/classes/class.ilObjCourseReference.php");
96 $this->access = $ilAccess;
97 $this->toolbar = $ilToolbar;
103 $this->modal_id =
"tree_modal";
106 $lng->loadLanguageModule(
"prg");
112 $this->ref_id = $a_ref_id;
123 $js_url = rawurldecode($this->ctrl->getLinkTarget($this,
'saveTreeOrder',
'',
true,
false));
124 $this->tree->addJsConf(
'save_tree_url', $js_url);
125 $this->tree->addJsConf(
'save_button_id',
'save_order_button');
126 $this->tree->addJsConf(
'cancel_button_id',
'cancel_order_button');
139 $cmd = $this->ctrl->getCmd();
148 if ($this->tree->handleCommand()) {
158 case "confirmedDelete":
160 case "getContainerSelectionExplorer":
161 case "saveTreeOrder":
162 case "createNewLeaf":
164 $content = $this->$cmd();
167 throw new ilException(
"ilObjStudyProgrammeTreeGUI: " .
168 "Command not supported: $cmd");
182 $output = $this->tree->getHTML();
212 $treeData = json_decode($treeAsJson);
214 if (!is_array($treeData) || [] === $treeData) {
232 protected function storeTreeOrder(array $nodes, $container_sorting =
null,
int $parent_ref_id =
null)
234 $sorting_position = array();
235 $position_count = 10;
240 foreach ($nodes as $node) {
243 $id = substr($id, strrpos($id,
"_") + 1);
245 $sorting_position[$id] = $position_count;
246 $position_count += 10;
250 $node_obj->moveTo($parent_node);
255 $rbacadmin =
$DIC[
'rbacadmin'];
257 $tree->moveTree($node_obj->getRefId(), $parent_node->getRefId());
258 $rbacadmin->adjustMovedObjectPermissions($node_obj->getRefId(), $parent_node->getRefId());
262 if (isset($node->children)) {
266 $container_sorting->savePost($sorting_position);
283 $parent_id = (int)
$_POST[
'parent_id'];
290 $course_ref->create();
291 $course_ref->createReference();
293 $course_ref->putInTree($parent_id);
297 $course_ref->update();
314 $create_leaf_form->setId(
"select_course_explorer");
316 $ref_expand = ROOT_FOLDER_ID;
317 if (isset(
$_GET[
'ref_repexpand'])) {
318 $ref_expand = (int)
$_GET[
'ref_repexpand'];
321 $create_leaf_form->setExpand($ref_expand);
322 $create_leaf_form->setExpandTarget($this->ctrl->getLinkTarget($this,
'getContainerSelectionExplorer'));
323 $create_leaf_form->setAsynchExpanding(
true);
324 $create_leaf_form->setTargetGet(
'target_id');
325 $create_leaf_form->setFrameTarget(
"_self");
326 $create_leaf_form->setClickable(
'crs',
true);
327 $create_leaf_form->setTargetType(
'crs');
328 $create_leaf_form->setOutput(0);
330 if ($convert_to_string) {
331 return $create_leaf_form->getOutput();
333 return $create_leaf_form;
347 $create_node_form = $tmp_obj->getAsyncCreationForm();
348 $create_node_form->setTitle(
"");
349 $this->ctrl->setParameterByClass(
"ilobjstudyprogrammegui",
"new_type",
"prg");
350 $create_node_form->setFormAction($this->ctrl->getFormActionByClass(
"ilobjstudyprogrammegui",
"save"));
352 return $create_node_form;
364 $parent_id = (isset(
$_GET[
'ref_id']))? (
int)
$_GET[
'ref_id'] :
null;
373 if (!$parent->hasLPChildren()) {
375 $accordion->addItem($this->lng->txt(
'prg_create_new_node'), $content_new_node);
382 if (!$parent->hasChildren() && $this->ilSetting->get(
"obj_dis_creation_crsr") ===
"") {
386 $accordion->addItem($this->lng->txt(
'prg_create_new_leaf'), $content_new_leaf);
390 if ($added_slides == 1) {
394 $content = $accordion->getHTML();
398 $this->async_output_handler->setHeading($this->lng->txt(
"prg_async_" . $this->ctrl->getCmd()));
399 $this->async_output_handler->setContent($content);
400 $this->async_output_handler->terminate();
409 protected function delete()
413 if (!isset(
$_GET[
'ref_id'],
$_GET[
'item_ref_id'])) {
417 $element_ref_id = (int)
$_GET[
'ref_id'];
421 $msg = $this->lng->txt(
"info_delete_sure");
424 $msg .=
"<br/>" . $this->lng->txt(
"info_delete_warning_no_trash");
426 $cgui->setFormAction($this->ctrl->getFormAction($this,
'confirmedDelete',
'',
true));
427 $cgui->setCancel($this->lng->txt(
"cancel"),
"cancelDelete");
428 $cgui->setConfirm($this->lng->txt(
"confirm"),
"confirmedDelete");
429 $cgui->setFormName(
'async_form');
434 $alt = $this->lng->txt(
"icon") .
" " . $this->lng->txt(
"obj_" .
$type);
440 ilObject::_getIcon($obj_id,
"small",
$type),
443 $cgui->addHiddenItem(
'item_ref_id',
$_GET[
'item_ref_id']);
445 $content = $cgui->getHTML();
448 $this->async_output_handler->setHeading($msg);
449 $this->async_output_handler->setContent($content);
450 $this->async_output_handler->terminate();
465 throw new ilException(
"No item select for deletion!");
469 $current_node = (int)
$_POST[
'item_ref_id'];
472 foreach ($ids as $id) {
475 $not_parent_of_current =
true;
483 $get_ref_ids =
function ($obj) {
484 return $obj->getRefId();
487 $children_ref_ids = array_map($get_ref_ids, $children_of_node);
488 $not_parent_of_current = (!in_array($current_node, $children_ref_ids));
490 $not_root = ($obj->getRoot() !=
null);
493 if ($current_node != $id && $not_root && $not_parent_of_current && $this->
checkAccess(
'delete', $obj->getRefId())) {
497 if (isset($children_of_node)) {
498 $this->tree->closeCertainNode($id);
499 foreach ($children_of_node as $child) {
500 $this->tree->closeCertainNode($child->getRefId());
504 $msg = $this->lng->txt(
"prg_deleted_safely");
506 $msg = $this->lng->txt(
"prg_not_allowed_node_to_delete");
542 $settings_modal->setId($this->modal_id);
544 $this->tpl->addOnLoadCode(
'$("#' . $this->modal_id .
'").study_programme_modal();');
546 $content = $settings_modal->getHTML();
550 $notifications->addJsConfig(
'events', array(
'success' => array(
'study_programme-show_success')));
551 $notifications->initJs();
555 $async_explorer->initJs();
567 $save_order_btn->setId(
'save_order_button');
568 $save_order_btn->setUrl(
"javascript:void(0);");
569 $save_order_btn->setOnClick(
"$('body').trigger('study_programme-save_order');");
570 $save_order_btn->setCaption(
'prg_save_tree_order');
573 $cancel_order_btn->setId(
'cancel_order_button');
574 $cancel_order_btn->setUrl(
"javascript:void(0);");
575 $cancel_order_btn->setOnClick(
"$('body').trigger('study_programme-cancel_order');");
576 $cancel_order_btn->setCaption(
'prg_cancel_tree_order');
578 $this->toolbar->addButtonInstance($save_order_btn);
579 $this->toolbar->addButtonInstance($cancel_order_btn);
594 $checker = $this->access->checkAccess($permission,
'',
$ref_id);
611 throw new ilException(
"You have no permission for " . $permission .
" Object with ref_id " .
$ref_id .
"!");
An exception for terminatinating execution or to throw for unit testing.
Accordion user interface class.
static addJavaScript(ilGlobalTemplate $main_tpl=null)
Add javascript files that are necessary to run accordion.
Class ilAsyncContainerSelectionExplorer A class for a async ilContainerSelectionExplorer which trigge...
static addJavascript()
Adds the javascript to template.
Class ilAsyncNotifications Allows to display async notifications on a page.
Class ilAsyncOutputHandler Handles the output for async-requests.
static handleAsyncOutput($normal_content, $async_content=null, $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.
Confirmation screen class.
static _getInstance($a_obj_id)
get instance by obj_id
This class provides processing control methods.
Base class for ILIAS Exception handling.
static getInstance()
Get instance.
Class ilObjStudyProgrammeGUI class.
Class ilStudyProgrammeTreeGUI ilObjStudyProgrammeTreeExplorerGUI generates the tree output for StudyP...
Class ilObjStudyProgrammeTreeGUI Generates the manage view for ilTrainingProgramme-Repository objects...
checkAccessOrFail($permission, $ref_id=null)
Checks permission of a object and throws an exception if they are not granted.
createNewLeaf()
Creates a new leaf Currently only course references can be created.
saveTreeOrder()
Saves tree node order Data is json encoded from the jstree component.
getToolbar()
Setup the toolbar.
initAsyncUIElements()
Initializes all elements used for async-interaction Adds HTML-skeleton for the bootstrap modal dialog...
getCreationForm()
Returns the async creation form for StudyProgrammes.
view()
Display the tree view.
executeCommand()
Execute GUI-commands If there is a async request the response is sent as a json string.
getContainerSelectionExplorer($convert_to_string=true)
Initialize the Course Explorer for creating a leaf.
create()
Generates the modal window content for the creation form of nodes or leafs If there are already Study...
cancelDelete()
Cancel deletion Return a json string for the async handling.
checkAccess($permission, $ref_id=null)
Checks permission of current tree or certain child of it.
confirmedDelete()
Deletes a node or a leaf in the tree.
cancel()
Cancel operation.
storeTreeOrder(array $nodes, $container_sorting=null, int $parent_ref_id=null)
Recursive function for saving the tree order.
initTree()
Initialize Tree Creates tree instance and set tree configuration.
__construct(\ilGlobalTemplateInterface $tpl, \ilCtrl $ilCtrl, \ilAccess $ilAccess, \ilToolbarGUI $ilToolbar, \ilLanguage $lng, \ilComponentLogger $ilLog, \ILIAS $ilias, \ilSetting $ilSetting)
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($a_obj_type)
Get class by type.
static _lookupObjectId($a_ref_id)
lookup object id
static _lookupType($a_id, $a_reference=false)
lookup object type
static deleteObjects($a_cur_ref_id, $a_ids)
Delete objects.
get($a_keyword, $a_default_value=false)
get setting
Exception is thrown when invariants on the program tree would be violated by manipulation of tree.
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
static getSystemMessageHTML($a_txt, $a_type="info")
Get HTML for a system message.
Class ChatMainBarProvider \MainMenu\Provider.
redirection script todo: (a better solution should control the processing via a xml file)