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");
90 $this->ref_id = $a_ref_id;
93 $this->access = $ilAccess;
94 $this->locator = $ilLocator;
96 $this->toolbar = $ilToolbar;
100 $this->modal_id =
"tree_modal";
105 $lng->loadLanguageModule(
"prg");
116 $js_url = rawurldecode($this->ctrl->getLinkTarget($this,
'saveTreeOrder',
'',
true,
false));
117 $this->tree->addJsConf(
'save_tree_url', $js_url);
118 $this->tree->addJsConf(
'save_button_id',
'save_order_button');
119 $this->tree->addJsConf(
'cancel_button_id',
'cancel_order_button');
130 $cmd = $this->ctrl->getCmd();
139 if($this->tree->handleCommand()) {
149 case "confirmedDelete":
151 case "getContainerSelectionExplorer":
152 case "saveTreeOrder":
153 case "createNewLeaf":
155 $content = $this->
$cmd();
158 throw new ilException(
"ilObjStudyProgrammeTreeGUI: ".
159 "Command not supported: $cmd");
173 $output = $this->tree->getHTML();
200 if(!isset(
$_POST[
'tree']) || is_null(json_decode(stripslashes(
$_POST[
'tree'])))) {
218 protected function storeTreeOrder($nodes, $container_sorting = null, $parent_ref_id = null) {
219 $sorting_position = array();
220 $position_count = 10;
225 foreach($nodes as $node) {
227 $id = $node->attr->id;
228 $id = substr($id, strrpos($id,
"_")+1);
230 $sorting_position[$id] = $position_count;
231 $position_count+= 10;
235 $node_obj->moveTo($parent_node);
238 global
$tree, $rbacadmin;
240 $tree->moveTree($node_obj->getRefId(), $parent_node->getRefId());
241 $rbacadmin->adjustMovedObjectPermissions($node_obj->getRefId(), $parent_node->getRefId());
245 if(isset($node->children)) {
249 $container_sorting->savePost($sorting_position);
263 if(isset($_POST[
'target_id'], $_POST[
'type'], $_POST[
'parent_id'])) {
265 $parent_id = (int) $_POST[
'parent_id'];
272 $course_ref->create();
273 $course_ref->createReference();
275 $course_ref->putInTree($parent_id);
279 $course_ref->update();
295 $create_leaf_form->setId(
"select_course_explorer");
297 $ref_expand = ROOT_FOLDER_ID;
298 if(isset(
$_GET[
'ref_repexpand'])) {
299 $ref_expand = (int)
$_GET[
'ref_repexpand'];
302 $create_leaf_form->setExpand($ref_expand);
303 $create_leaf_form->setExpandTarget($this->ctrl->getLinkTarget($this,
'getContainerSelectionExplorer'));
304 $create_leaf_form->setAsynchExpanding(
true);
305 $create_leaf_form->setTargetGet(
'target_id');
306 $create_leaf_form->setFrameTarget(
"_self");
307 $create_leaf_form->setClickable(
'crs',
true);
308 $create_leaf_form->setTargetType(
'crs');
309 $create_leaf_form->setOutput(0);
311 if($convert_to_string)
312 return $create_leaf_form->getOutput();
314 return $create_leaf_form;
326 $create_node_form = $tmp_obj->getAsyncCreationForm();
327 $create_node_form->setTitle(
"");
328 $this->ctrl->setParameterByClass(
"ilobjstudyprogrammegui",
"new_type",
"prg");
329 $create_node_form->setFormAction($this->ctrl->getFormActionByClass(
"ilobjstudyprogrammegui",
"save"));
331 return $create_node_form;
342 $parent_id = (isset(
$_GET[
'ref_id']))? (
int)
$_GET[
'ref_id'] : null;
351 if(!$parent->hasLPChildren()) {
353 $accordion->addItem($this->lng->txt(
'prg_create_new_node'), $content_new_node);
358 if(!$parent->hasChildren()) {
359 $content_new_leaf = $this->tpl->getMessageHTML($this->lng->txt(
'prg_please_select_a_course_for_creating_a_leaf'));
362 $accordion->addItem($this->lng->txt(
'prg_create_new_leaf'), $content_new_leaf);
366 if($added_slides == 1) {
370 $content = $accordion->getHTML();
374 $this->async_output_handler->setHeading($this->lng->txt(
"prg_async_".$this->ctrl->getCmd()));
375 $this->async_output_handler->setContent($content);
376 $this->async_output_handler->terminate();
385 protected function delete() {
390 if(!isset(
$_GET[
'ref_id'],
$_GET[
'item_ref_id'])) {
394 $element_ref_id = (int)
$_GET[
'ref_id'];
398 $msg = $this->lng->txt(
"info_delete_sure");
400 if (!$ilSetting->get(
'enable_trash'))
402 $msg .=
"<br/>".$this->lng->txt(
"info_delete_warning_no_trash");
404 $cgui->setFormAction($this->ctrl->getFormAction($this,
'confirmedDelete',
'',
true));
405 $cgui->setCancel($this->lng->txt(
"cancel"),
"cancelDelete");
406 $cgui->setConfirm($this->lng->txt(
"confirm"),
"confirmedDelete");
407 $cgui->setFormName(
'async_form');
412 $alt = $this->lng->txt(
"icon").
" ".$this->lng->txt(
"obj_".$type);
414 $cgui->addItem(
"id[]", $element_ref_id, $title,
417 $cgui->addHiddenItem(
'item_ref_id',
$_GET[
'item_ref_id']);
419 $content = $cgui->getHTML();
422 $this->async_output_handler->setHeading($msg);
423 $this->async_output_handler->setContent($content);
424 $this->async_output_handler->terminate();
438 throw new ilException(
"No item select for deletion!");
442 $current_node = (int)
$_POST[
'item_ref_id'];
445 foreach($ids as $id) {
448 $not_parent_of_current =
true;
456 $get_ref_ids =
function ($obj) {
return $obj->getRefId(); };
458 $children_ref_ids = array_map($get_ref_ids, $children_of_node);
459 $not_parent_of_current = (!in_array($current_node, $children_ref_ids));
461 $not_root = ($obj->getRoot() != null);
464 if($current_node != $id && $not_root && $not_parent_of_current && $this->
checkAccess(
'delete', $obj->getRefId())) {
469 if(isset($children_of_node)) {
470 $this->tree->closeCertainNode($id);
471 foreach($children_of_node as $child) {
472 $this->tree->closeCertainNode($child->getRefId());
476 $msg = $this->lng->txt(
"prg_deleted_safely");
479 $msg = $this->lng->txt(
"prg_not_allowed_node_to_delete");
513 $settings_modal->setId($this->modal_id);
515 $this->tpl->addOnLoadCode(
'$("#'.$this->modal_id.
'").study_programme_modal();');
517 $content = $settings_modal->getHTML();
521 $notifications->addJsConfig(
'events', array(
'success'=>array(
'study_programme-show_success')));
522 $notifications->initJs();
526 $async_explorer->initJs();
537 $save_order_btn->setId(
'save_order_button');
538 $save_order_btn->setUrl(
"javascript:void(0);");
539 $save_order_btn->setOnClick(
"$('body').trigger('study_programme-save_order');");
540 $save_order_btn->setCaption(
'prg_save_tree_order');
543 $cancel_order_btn->setId(
'cancel_order_button');
544 $cancel_order_btn->setUrl(
"javascript:void(0);");
545 $cancel_order_btn->setOnClick(
"$('body').trigger('study_programme-cancel_order');");
546 $cancel_order_btn->setCaption(
'prg_cancel_tree_order');
548 $this->toolbar->addButtonInstance($save_order_btn);
549 $this->toolbar->addButtonInstance($cancel_order_btn);
563 $checker = $this->access->checkAccess($permission,
'',
$ref_id);
579 throw new ilException(
"You have no permission for ".$permission.
" Object with ref_id ".
$ref_id.
"!");
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 _getIcon($a_obj_id="", $a_size="big", $a_type="", $a_offline=false)
Get icon for repository item.
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.
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.
checkAccess($permission, $ref_id=null)
Checks permission of current tree or certain child of it.
static addJavaScript()
Add javascript files that are necessary to run accordion.
initTree()
Initialize Tree Creates tree instance and set tree configuration.
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.
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.
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...
getInstanceByRefId($a_ref_id, $stop_on_error=true)
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.