3 require_once(
"./Modules/StudyProgramme/classes/class.ilObjStudyProgrammeTreeExplorerGUI.php");
4 require_once(
"./Services/UIComponent/Modal/classes/class.ilModalGUI.php");
5 require_once(
"./Services/Accordion/classes/class.ilAccordionGUI.php");
6 require_once(
"./Modules/StudyProgramme/classes/helpers/class.ilAsyncContainerSelectionExplorer.php");
7 require_once(
"./Modules/StudyProgramme/classes/helpers/class.ilAsyncPropertyFormGUI.php");
8 require_once(
'./Services/Container/classes/class.ilContainerSorting.php');
9 require_once(
"./Services/Utilities/classes/class.ilConfirmationGUI.php");
10 require_once(
"./Modules/StudyProgramme/classes/helpers/class.ilAsyncNotifications.php");
11 require_once(
"./Modules/CourseReference/classes/class.ilObjCourseReference.php");
93 $ilAccess = $DIC[
'ilAccess'];
94 $ilToolbar = $DIC[
'ilToolbar'];
95 $ilLocator = $DIC[
'ilLocator'];
102 $this->ref_id = $a_ref_id;
105 $this->access = $ilAccess;
106 $this->locator = $ilLocator;
108 $this->toolbar = $ilToolbar;
113 $this->modal_id =
"tree_modal";
118 $lng->loadLanguageModule(
"prg");
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');
145 $cmd = $this->ctrl->getCmd();
154 if ($this->tree->handleCommand()) {
164 case "confirmedDelete":
166 case "getContainerSelectionExplorer":
167 case "saveTreeOrder":
168 case "createNewLeaf":
170 $content = $this->$cmd();
173 throw new ilException(
"ilObjStudyProgrammeTreeGUI: " .
174 "Command not supported: $cmd");
188 $output = $this->tree->getHTML();
217 if (!isset(
$_POST[
'tree']) || is_null(json_decode(stripslashes(
$_POST[
'tree'])))) {
235 protected function storeTreeOrder($nodes, $container_sorting = null, $parent_ref_id = null)
237 $sorting_position =
array();
238 $position_count = 10;
243 foreach ($nodes as $node) {
245 $id = $node->attr->id;
248 $sorting_position[
$id] = $position_count;
249 $position_count+= 10;
253 $node_obj->moveTo($parent_node);
257 $tree = $DIC[
'tree'];
258 $rbacadmin = $DIC[
'rbacadmin'];
260 $tree->moveTree($node_obj->getRefId(), $parent_node->getRefId());
261 $rbacadmin->adjustMovedObjectPermissions($node_obj->getRefId(), $parent_node->getRefId());
265 if (isset($node->children)) {
269 $container_sorting->savePost($sorting_position);
284 if (isset($_POST[
'target_id'], $_POST[
'type'], $_POST[
'parent_id'])) {
286 $parent_id = (int) $_POST[
'parent_id'];
293 $course_ref->create();
294 $course_ref->createReference();
296 $course_ref->putInTree($parent_id);
300 $course_ref->update();
317 $create_leaf_form->setId(
"select_course_explorer");
319 $ref_expand = ROOT_FOLDER_ID;
320 if (isset(
$_GET[
'ref_repexpand'])) {
321 $ref_expand = (int)
$_GET[
'ref_repexpand'];
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);
333 if ($convert_to_string) {
334 return $create_leaf_form->getOutput();
336 return $create_leaf_form;
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"));
355 return $create_node_form;
367 $parent_id = (isset(
$_GET[
'ref_id']))? (
int)
$_GET[
'ref_id'] : null;
376 if (!$parent->hasLPChildren()) {
378 $accordion->addItem($this->lng->txt(
'prg_create_new_node'), $content_new_node);
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'));
389 $accordion->addItem($this->lng->txt(
'prg_create_new_leaf'), $content_new_leaf);
393 if ($added_slides == 1) {
397 $content = $accordion->getHTML();
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();
412 protected function delete()
419 if (!isset(
$_GET[
'ref_id'],
$_GET[
'item_ref_id'])) {
423 $element_ref_id = (int)
$_GET[
'ref_id'];
427 $msg = $this->lng->txt(
"info_delete_sure");
430 $msg .=
"<br/>" . $this->lng->txt(
"info_delete_warning_no_trash");
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');
440 $alt = $this->lng->txt(
"icon") .
" " . $this->lng->txt(
"obj_" .
$type);
449 $cgui->addHiddenItem(
'item_ref_id',
$_GET[
'item_ref_id']);
451 $content = $cgui->getHTML();
454 $this->async_output_handler->setHeading($msg);
455 $this->async_output_handler->setContent($content);
456 $this->async_output_handler->terminate();
471 throw new ilException(
"No item select for deletion!");
475 $current_node = (int)
$_POST[
'item_ref_id'];
478 foreach ($ids as
$id) {
481 $not_parent_of_current =
true;
489 $get_ref_ids =
function ($obj) {
490 return $obj->getRefId();
493 $children_ref_ids = array_map($get_ref_ids, $children_of_node);
494 $not_parent_of_current = (!in_array($current_node, $children_ref_ids));
496 $not_root = ($obj->getRoot() != null);
499 if ($current_node != $id && $not_root && $not_parent_of_current && $this->
checkAccess(
'delete', $obj->getRefId())) {
503 if (isset($children_of_node)) {
504 $this->tree->closeCertainNode($id);
505 foreach ($children_of_node as $child) {
506 $this->tree->closeCertainNode($child->getRefId());
510 $msg = $this->lng->txt(
"prg_deleted_safely");
512 $msg = $this->lng->txt(
"prg_not_allowed_node_to_delete");
548 $settings_modal->setId($this->modal_id);
550 $this->tpl->addOnLoadCode(
'$("#' . $this->modal_id .
'").study_programme_modal();');
552 $content = $settings_modal->getHTML();
556 $notifications->addJsConfig(
'events',
array(
'success'=>
array(
'study_programme-show_success')));
557 $notifications->initJs();
561 $async_explorer->initJs();
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');
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');
584 $this->toolbar->addButtonInstance($save_order_btn);
585 $this->toolbar->addButtonInstance($cancel_order_btn);
600 $checker = $this->access->checkAccess($permission,
'',
$ref_id);
617 throw new ilException(
"You have no permission for " . $permission .
" Object with ref_id " .
$ref_id .
"!");
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.
createNewLeaf()
Creates a new leaf Currently only course references can be created.
cancel()
Cancel operation.
Class ilAsyncOutputHandler Handles the output for async-requests.
static getAllChildren($a_ref_id)
Get a list of all ilObjStudyProgrammes in the subtree starting at $a_ref_id.
Class ilObjStudyProgrammeGUI class.
confirmedDelete()
Deletes a node or a leaf in the tree.
getContainerSelectionExplorer($convert_to_string=true)
Initialize the Course Explorer for creating a leaf.
Class ilAsyncNotifications Allows to display async notifications on a page.
getToolbar()
Setup the toolbar.
if(!array_key_exists('StateId', $_REQUEST)) $id
checkAccess($permission, $ref_id=null)
Checks permission of current tree or certain child of it.
initTree()
Initialize Tree Creates tree instance and set tree configuration.
static addJavaScript(ilTemplate $main_tpl=null)
Add javascript files that are necessary to run accordion.
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.
if(!is_dir( $entity_dir)) exit("Fatal Error ([A-Za-z0-9]+)\+" &#(? foreach( $entity_files as $file) $output
static encodeAsyncResponse(array $data=array())
Encode data as json for async output.
view()
Display the tree view.
storeTreeOrder($nodes, $container_sorting=null, $parent_ref_id=null)
Recursive function for saving the tree order.
Class ilObjStudyProgramme.
saveTreeOrder()
Saves tree node order Data is json encoded from the jstree component.
redirection script todo: (a better solution should control the processing via a xml file) ...
cancelDelete()
Cancel deletion Return a json string for the async handling.
executeCommand()
Execute GUI-commands If there is a async request the response is sent as a json string.
static addJavascript()
Adds the javascript to template.
Create styles array
The data for the language used.
static _lookupType($a_id, $a_reference=false)
lookup object type
getCreationForm()
Returns the async creation form for StudyProgrammes.
static getInstance()
Get instance.
Class ilStudyProgrammeTreeGUI ilObjStudyProgrammeTreeExplorerGUI generates the tree output for StudyP...
Class ilAsyncContainerSelectionExplorer A class for a async ilContainerSelectionExplorer which trigge...
static _getInstance($a_obj_id)
get instance by obj_id
Exception is thrown when invariants on the program tree would be violated by manipulation of tree...
Accordion user interface class.
initAsyncUIElements()
Initializes all elements used for async-interaction Adds HTML-skeleton for the bootstrap modal dialog...
Class ilObjStudyProgrammeTreeGUI Generates the manage view for ilTrainingProgramme-Repository objects...
create()
Generates the modal window content for the creation form of nodes or leafs If there are already Study...
static handleAsyncOutput($normal_content, $async_content=null, $apply_to_tpl=true)
Handles async output.
Confirmation screen class.
static deleteObjects($a_cur_ref_id, $a_ids)
Delete objects.