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");
91 $ilAccess =
$DIC[
'ilAccess'];
92 $ilToolbar =
$DIC[
'ilToolbar'];
93 $ilLocator =
$DIC[
'ilLocator'];
100 $this->ref_id = $a_ref_id;
103 $this->access = $ilAccess;
104 $this->locator = $ilLocator;
106 $this->toolbar = $ilToolbar;
111 $this->modal_id =
"tree_modal";
116 $lng->loadLanguageModule(
"prg");
127 $js_url = rawurldecode($this->ctrl->getLinkTarget($this,
'saveTreeOrder',
'',
true,
false));
128 $this->tree->addJsConf(
'save_tree_url', $js_url);
129 $this->tree->addJsConf(
'save_button_id',
'save_order_button');
130 $this->tree->addJsConf(
'cancel_button_id',
'cancel_order_button');
141 $cmd = $this->ctrl->getCmd();
150 if($this->tree->handleCommand()) {
160 case "confirmedDelete":
162 case "getContainerSelectionExplorer":
163 case "saveTreeOrder":
164 case "createNewLeaf":
166 $content = $this->
$cmd();
169 throw new ilException(
"ilObjStudyProgrammeTreeGUI: ".
170 "Command not supported: $cmd");
184 $output = $this->tree->getHTML();
211 if(!isset(
$_POST[
'tree']) || is_null(json_decode(stripslashes(
$_POST[
'tree'])))) {
229 protected function storeTreeOrder($nodes, $container_sorting =
null, $parent_ref_id =
null) {
230 $sorting_position = array();
231 $position_count = 10;
236 foreach($nodes as $node) {
238 $id = $node->attr->id;
239 $id = substr($id, strrpos($id,
"_")+1);
241 $sorting_position[$id] = $position_count;
242 $position_count+= 10;
246 $node_obj->moveTo($parent_node);
251 $rbacadmin =
$DIC[
'rbacadmin'];
253 $tree->moveTree($node_obj->getRefId(), $parent_node->getRefId());
254 $rbacadmin->adjustMovedObjectPermissions($node_obj->getRefId(), $parent_node->getRefId());
258 if(isset($node->children)) {
262 $container_sorting->savePost($sorting_position);
278 $parent_id = (int)
$_POST[
'parent_id'];
285 $course_ref->create();
286 $course_ref->createReference();
288 $course_ref->putInTree($parent_id);
292 $course_ref->update();
308 $create_leaf_form->setId(
"select_course_explorer");
310 $ref_expand = ROOT_FOLDER_ID;
311 if(isset(
$_GET[
'ref_repexpand'])) {
312 $ref_expand = (int)
$_GET[
'ref_repexpand'];
315 $create_leaf_form->setExpand($ref_expand);
316 $create_leaf_form->setExpandTarget($this->ctrl->getLinkTarget($this,
'getContainerSelectionExplorer'));
317 $create_leaf_form->setAsynchExpanding(
true);
318 $create_leaf_form->setTargetGet(
'target_id');
319 $create_leaf_form->setFrameTarget(
"_self");
320 $create_leaf_form->setClickable(
'crs',
true);
321 $create_leaf_form->setTargetType(
'crs');
322 $create_leaf_form->setOutput(0);
324 if($convert_to_string)
325 return $create_leaf_form->getOutput();
327 return $create_leaf_form;
339 $create_node_form = $tmp_obj->getAsyncCreationForm();
340 $create_node_form->setTitle(
"");
341 $this->ctrl->setParameterByClass(
"ilobjstudyprogrammegui",
"new_type",
"prg");
342 $create_node_form->setFormAction($this->ctrl->getFormActionByClass(
"ilobjstudyprogrammegui",
"save"));
344 return $create_node_form;
355 $parent_id = (isset(
$_GET[
'ref_id']))? (
int)
$_GET[
'ref_id'] :
null;
364 if(!$parent->hasLPChildren()) {
366 $accordion->addItem($this->lng->txt(
'prg_create_new_node'), $content_new_node);
373 if(!$parent->hasChildren() && $this->ilSetting->get(
"obj_dis_creation_crsr") ===
"") {
374 $content_new_leaf = $this->tpl->getMessageHTML($this->lng->txt(
'prg_please_select_a_course_for_creating_a_leaf'));
377 $accordion->addItem($this->lng->txt(
'prg_create_new_leaf'), $content_new_leaf);
381 if($added_slides == 1) {
385 $content = $accordion->getHTML();
389 $this->async_output_handler->setHeading($this->lng->txt(
"prg_async_".$this->ctrl->getCmd()));
390 $this->async_output_handler->setContent($content);
391 $this->async_output_handler->terminate();
400 protected function delete() {
406 if(!isset(
$_GET[
'ref_id'],
$_GET[
'item_ref_id'])) {
410 $element_ref_id = (int)
$_GET[
'ref_id'];
414 $msg = $this->lng->txt(
"info_delete_sure");
418 $msg .=
"<br/>".$this->lng->txt(
"info_delete_warning_no_trash");
420 $cgui->setFormAction($this->ctrl->getFormAction($this,
'confirmedDelete',
'',
true));
421 $cgui->setCancel($this->lng->txt(
"cancel"),
"cancelDelete");
422 $cgui->setConfirm($this->lng->txt(
"confirm"),
"confirmedDelete");
423 $cgui->setFormName(
'async_form');
428 $alt = $this->lng->txt(
"icon").
" ".$this->lng->txt(
"obj_".$type);
430 $cgui->addItem(
"id[]", $element_ref_id,
$title,
433 $cgui->addHiddenItem(
'item_ref_id',
$_GET[
'item_ref_id']);
435 $content = $cgui->getHTML();
438 $this->async_output_handler->setHeading($msg);
439 $this->async_output_handler->setContent($content);
440 $this->async_output_handler->terminate();
454 throw new ilException(
"No item select for deletion!");
458 $current_node = (int)
$_POST[
'item_ref_id'];
461 foreach($ids as $id) {
464 $not_parent_of_current =
true;
472 $get_ref_ids =
function ($obj) {
return $obj->getRefId(); };
474 $children_ref_ids = array_map($get_ref_ids, $children_of_node);
475 $not_parent_of_current = (!in_array($current_node, $children_ref_ids));
477 $not_root = ($obj->getRoot() !=
null);
480 if($current_node != $id && $not_root && $not_parent_of_current && $this->
checkAccess(
'delete', $obj->getRefId())) {
485 if(isset($children_of_node)) {
486 $this->tree->closeCertainNode($id);
487 foreach($children_of_node as $child) {
488 $this->tree->closeCertainNode($child->getRefId());
492 $msg = $this->lng->txt(
"prg_deleted_safely");
495 $msg = $this->lng->txt(
"prg_not_allowed_node_to_delete");
529 $settings_modal->setId($this->modal_id);
531 $this->tpl->addOnLoadCode(
'$("#'.$this->modal_id.
'").study_programme_modal();');
533 $content = $settings_modal->getHTML();
537 $notifications->addJsConfig(
'events', array(
'success'=>array(
'study_programme-show_success')));
538 $notifications->initJs();
542 $async_explorer->initJs();
553 $save_order_btn->setId(
'save_order_button');
554 $save_order_btn->setUrl(
"javascript:void(0);");
555 $save_order_btn->setOnClick(
"$('body').trigger('study_programme-save_order');");
556 $save_order_btn->setCaption(
'prg_save_tree_order');
559 $cancel_order_btn->setId(
'cancel_order_button');
560 $cancel_order_btn->setUrl(
"javascript:void(0);");
561 $cancel_order_btn->setOnClick(
"$('body').trigger('study_programme-cancel_order');");
562 $cancel_order_btn->setCaption(
'prg_cancel_tree_order');
564 $this->toolbar->addButtonInstance($save_order_btn);
565 $this->toolbar->addButtonInstance($cancel_order_btn);
579 $checker = $this->access->checkAccess($permission,
'',
$ref_id);
595 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()
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.
Confirmation screen class.
static _getInstance($a_obj_id)
get instance by obj_id
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.
storeTreeOrder($nodes, $container_sorting=null, $parent_ref_id=null)
Recursive function for saving the tree order.
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.
initTree()
Initialize Tree Creates tree instance and set tree configuration.
Class ilObjStudyProgramme.
static getAllChildren($a_ref_id)
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 _getIcon($a_obj_id="", $a_size="big", $a_type="", $a_offline=false)
Get icon for repository item.
static _lookupType($a_id, $a_reference=false)
lookup object type
static deleteObjects($a_cur_ref_id, $a_ids)
Delete objects.
Exception is thrown when invariants on the program tree would be violated by manipulation of tree.
if(!is_dir( $entity_dir)) exit("Fatal Error ([A-Za-z0-9]+)\s+" &#(? foreach( $entity_files as $file) $output
redirection script todo: (a better solution should control the processing via a xml file)