ILIAS  release_10 Revision v10.1-43-ga1241a92c2f
class.ilObjFolderGUI.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
19 
33 {
34  protected ilHelpGUI $help;
37 
38  public function __construct(
39  $a_data,
40  int $a_id = 0,
41  bool $a_call_by_reference = true,
42  bool $a_prepare_output = false
43  ) {
44  global $DIC;
45 
46  $this->tree = $DIC->repositoryTree();
47  $this->tabs = $DIC->tabs();
48  $this->user = $DIC->user();
49  $this->ctrl = $DIC->ctrl();
50  $this->lng = $DIC->language();
51  $this->access = $DIC->access();
52  $this->rbacsystem = $DIC->rbac()->system();
53  $this->help = $DIC["ilHelp"];
54  $this->error = $DIC["ilErr"];
55  $this->tpl = $DIC["tpl"];
56  $this->settings = $DIC->settings();
57  $this->type = "fold";
58  parent::__construct($a_data, $a_id, $a_call_by_reference, $a_prepare_output);
59  $this->lng->loadLanguageModule("obj");
60  $this->folder_request = $DIC
61  ->folder()
62  ->internal()
63  ->gui()
64  ->standardRequest();
65  }
66 
67 
68  public function viewObject(): void
69  {
70  $this->checkPermission('read');
71  if (strtolower($this->folder_request->getBaseClass()) === "iladministrationgui") {
72  parent::viewObject();
73  return;
74  }
75 
76  // Trac access - see ilObjCourseGUI
78  $GLOBALS["ilUser"]->getId(),
79  $this->object->getId(),
80  $this->object->getRefId(),
81  'fold'
82  );
83 
84  $this->renderObject();
85  $this->tabs_gui->setTabActive('view_content');
86  }
87 
88  public function renderObject(): void
89  {
90  $ilTabs = $this->tabs;
91 
92  $this->checkPermission('read');
93 
94  $ilTabs->activateTab("view_content");
95  parent::renderObject();
96  }
97 
98  public function executeCommand(): void
99  {
100  $ilUser = $this->user;
101  $next_class = $this->ctrl->getNextClass($this);
102  $cmd = $this->ctrl->getCmd();
103 
104  $header_action = true;
105  switch ($next_class) {
106  case strtolower(ilRepositoryTrashGUI::class):
107  $ru = new ilRepositoryTrashGUI($this);
108  $this->ctrl->setReturn($this, 'trash');
109  $this->ctrl->forwardCommand($ru);
110  break;
111 
112  case 'ilpermissiongui':
113  $this->prepareOutput();
114  $this->tabs_gui->activateTab('perm_settings');
115  $perm_gui = new ilPermissionGUI($this);
116  $ret = $this->ctrl->forwardCommand($perm_gui);
117  break;
118 
119 
120  case 'ilcoursecontentgui':
121  $this->prepareOutput();
122  $course_content_obj = new ilCourseContentGUI($this);
123  $this->ctrl->forwardCommand($course_content_obj);
124  break;
125 
126  case "illearningprogressgui":
127  $this->prepareOutput();
128 
129  $new_gui = new ilLearningProgressGUI(
131  $this->object->getRefId(),
132  $this->folder_request->getUserId() ?: $ilUser->getId()
133  );
134  $this->ctrl->forwardCommand($new_gui);
135  $this->tabs_gui->setTabActive('learning_progress');
136  break;
137 
138  // container page editing
139  case "ilcontainerpagegui":
140  $this->prepareOutput(false);
141  $ret = $this->forwardToPageObject();
142  if ($ret !== "") {
143  $this->tpl->setContent($ret);
144  }
145  $header_action = false;
146  break;
147 
148  case 'ilinfoscreengui':
149  $this->prepareOutput();
150  $this->infoScreen();
151  break;
152 
153  case 'ilobjectcopygui':
154  $this->prepareOutput();
155 
156  $cp = new ilObjectCopyGUI($this);
157  $cp->setType('fold');
158  $this->ctrl->forwardCommand($cp);
159  break;
160 
161  case "ilobjectcontentstylesettingsgui":
162  $this->checkPermission("write");
163  $this->setTitleAndDescription();
164  $this->showContainerPageTabs();
165  $settings_gui = $this->content_style_gui
166  ->objectSettingsGUIForRefId(
167  null,
168  $this->object->getRefId()
169  );
170  $this->ctrl->forwardCommand($settings_gui);
171  break;
172 
173  case 'ilexportgui':
174  $this->prepareOutput();
175 
176  $this->tabs_gui->setTabActive('export');
177  $exp = new ilExportGUI($this);
178  $exp->addFormat('xml');
179  $this->ctrl->forwardCommand($exp);
180  break;
181 
182  case "ilcommonactiondispatchergui":
183  $this->prepareOutput();
185  $this->ctrl->forwardCommand($gui);
186  break;
187 
188  case 'ildidactictemplategui':
189  $this->ctrl->setReturn($this, 'edit');
190  $did = new ilDidacticTemplateGUI($this);
191  $this->ctrl->forwardCommand($did);
192  break;
193  case 'ilcolumngui':
194  $this->tabs_gui->setTabActive('none');
195  $this->checkPermission("read");
196  $this->viewObject();
197  break;
198 
199  case 'ilobjecttranslationgui':
200  $this->checkPermissionBool("write");
201  $this->prepareOutput();
202  $this->setSubTabs("settings_trans");
203  $transgui = new ilObjectTranslationGUI($this);
204  $this->ctrl->forwardCommand($transgui);
205  break;
206 
207  default:
208 
209  $this->prepareOutput();
210  // cognos-blu-patch: begin
211  // removed timings forward
212  // cognos-blu-patch: end
213 
214  if (empty($cmd)) {
215  $cmd = "view";
216  }
217  $cmd .= "Object";
218  $this->$cmd();
219  break;
220  }
221 
222  if ($header_action) {
223  $this->addHeaderAction();
224  }
225  }
226 
227  public function setFolderTree(ilTree $a_tree): void
228  {
229  $this->folder_tree = $a_tree;
230  }
231 
232  protected function initEditForm(): ilPropertyFormGUI
233  {
234  $lng = $this->lng;
235  $obj_service = $this->getObjectService();
236 
237  $lng->loadLanguageModule($this->object->getType());
238 
239  $form = new ilPropertyFormGUI();
240  $form->setFormAction($this->ctrl->getFormAction($this, "update"));
241  $form->setTitle($this->lng->txt($this->object->getType() . "_edit"));
242 
243  // title
244  $ti = new ilTextInputGUI($this->lng->txt("title"), "title");
245  $ti->setSize(min(40, ilObject::TITLE_LENGTH));
246  $ti->setMaxLength(ilObject::TITLE_LENGTH);
247  $ti->setRequired(true);
248  $form->addItem($ti);
249 
250  // description
251  $ta = new ilTextAreaInputGUI($this->lng->txt("description"), "desc");
252  $ta->setCols(40);
253  $ta->setRows(2);
254  $form->addItem($ta);
255 
256  // Show didactic template type
257  $this->initDidacticTemplate($form);
258 
259  $pres = new ilFormSectionHeaderGUI();
260  $pres->setTitle($this->lng->txt('fold_presentation'));
261  $form->addItem($pres);
262 
263  // title and icon visibility
264  $form = $obj_service->commonSettings()->legacyForm($form, $this->object)->addTitleIconVisibility();
265 
266  // top actions visibility
267  $form = $obj_service->commonSettings()->legacyForm($form, $this->object)->addTopActionsVisibility();
268 
269  // custom icon
270  $form = $obj_service->commonSettings()->legacyForm($form, $this->object)->addIcon();
271 
272  // tile image
273  $form = $obj_service->commonSettings()->legacyForm($form, $this->object)->addTileImage();
274 
275  // list presentation
277 
278  $this->initSortingForm(
279  $form,
280  [
285  ]
286  );
287 
288  $form->addCommandButton("update", $this->lng->txt("save"));
289  //$this->form->addCommandButton("cancelUpdate", $lng->txt("cancel"));
290 
291  return $form;
292  }
293 
294  protected function getEditFormCustomValues(array &$a_values): void
295  {
296  // we cannot use $this->object->getOrderType()
297  // if set to inherit it will be translated to parent setting
298  $sort = new ilContainerSortingSettings($this->object->getId());
299  $a_values["sor"] = $sort->getSortMode();
300  }
301 
302  protected function updateCustom(ilPropertyFormGUI $form): void
303  {
304  $obj_service = $this->getObjectService();
305 
306  // title icon visibility
307  $obj_service->commonSettings()->legacyForm($form, $this->object)->saveTitleIconVisibility();
308 
309  // top actions visibility
310  $obj_service->commonSettings()->legacyForm($form, $this->object)->saveTopActionsVisibility();
311 
312  // custom icon
313  $obj_service->commonSettings()->legacyForm($form, $this->object)->saveIcon();
314 
315  // tile image
316  $obj_service->commonSettings()->legacyForm($form, $this->object)->saveTileImage();
317 
318  // list presentation
319  $this->saveListPresentation($form);
320 
321  $this->saveSortingSettings($form);
322  }
323 
329  public function showSummaryObject(): void
330  {
331  $this->ctrl->redirectByClass(ilInfoScreenGUI::class, "showSummary");
332  }
333 
334  protected function afterSave(ilObject $new_object): void
335  {
336  $sort = new ilContainerSortingSettings($new_object->getId());
338  $sort->update();
339 
340  // always send a message
341  $this->tpl->setOnScreenMessage('success', $this->lng->txt("fold_added"), true);
342  $this->ctrl->setParameter($this, "ref_id", $new_object->getRefId());
343  $this->redirectToRefId($new_object->getRefId(), "");
344  }
345 
351  public function infoScreenObject(): void
352  {
353  $this->ctrl->redirectByClass(ilInfoScreenGUI::class, "showSummary");
354  }
355 
359  public function infoScreen(): void
360  {
361  $ilAccess = $this->access;
362 
363  if (!$ilAccess->checkAccess("visible", "", $this->ref_id)) {
364  throw new ilPermissionException($this->lng->txt("msg_no_perm_read"));
365  }
366 
367  $info = new ilInfoScreenGUI($this);
368 
369  $GLOBALS['ilTabs']->activateTab('info_short');
370 
371  $info->enablePrivateNotes();
372 
373  if ($ilAccess->checkAccess("read", "", $this->requested_ref_id)) {
374  $info->enableNews();
375  }
376 
377  // no news editing for files, just notifications
378  $info->enableNewsEditing(false);
379  if ($ilAccess->checkAccess("write", "", $this->requested_ref_id)) {
380  $news_set = new ilSetting("news");
381  $enable_internal_rss = $news_set->get("enable_rss_for_internal");
382 
383  if ($enable_internal_rss) {
384  $info->setBlockProperty("news", "settings", '1');
385  $info->setBlockProperty("news", "public_notifications_option", '1');
386  }
387  }
388 
389 
390  // standard meta data
391  $info->addMetaDataSections($this->object->getId(), 0, $this->object->getType());
392 
393  // forward the command
394  $this->ctrl->forwardCommand($info);
395  }
396 
397  protected function getTabs(): void
398  {
400  $lng = $this->lng;
401  $ilCtrl = $this->ctrl;
402  $ilAccess = $this->access;
403  $ilHelp = $this->help;
404 
405  $this->ctrl->setParameter($this, "ref_id", $this->ref_id);
406 
407  $ilHelp->setScreenIdComponent("fold");
408 
409  $this->tabs_gui->setTabActive("");
410  if ($ilAccess->checkAccess('read', '', $this->ref_id)) {
411  $this->tabs_gui->addTab(
412  "view_content",
413  $lng->txt("content"),
414  $this->ctrl->getLinkTarget($this, "")
415  );
416 
417  //BEGIN ChangeEvent add info tab to category object
418  $force_active = $this->ctrl->getNextClass() === "ilinfoscreengui"
419  || strtolower($this->ctrl->getCmdClass()) === "ilnotegui";
420  $this->tabs_gui->addTarget(
421  "info_short",
422  $this->ctrl->getLinkTargetByClass(
423  ["ilobjfoldergui", "ilinfoscreengui"],
424  "showSummary"
425  ),
426  ["showSummary", "", "infoScreen"],
427  "",
428  "",
429  $force_active
430  );
431  //END ChangeEvent add info tab to category object
432  }
433 
434  if ($rbacsystem->checkAccess('write', $this->ref_id)) {
435  $this->tabs_gui->addTarget(
436  "settings",
437  $this->ctrl->getLinkTarget($this, "edit"),
438  "edit",
439  "",
440  "",
441  ($ilCtrl->getCmd() === "edit")
442  );
443  }
444 
445  // learning progress
446  if (ilLearningProgressAccess::checkAccess($this->object->getRefId())) {
447  $this->tabs_gui->addTarget(
448  'learning_progress',
449  $this->ctrl->getLinkTargetByClass(['ilobjfoldergui', 'illearningprogressgui'], ''),
450  '',
451  ['illplistofobjectsgui', 'illplistofsettingsgui', 'illearningprogressgui', 'illplistofprogressgui']
452  );
453  }
454 
455  if ($ilAccess->checkAccess('write', '', $this->object->getRefId())) {
456  $this->tabs_gui->addTarget(
457  'export',
458  $this->ctrl->getLinkTargetByClass('ilexportgui', ''),
459  'export',
460  'ilexportgui'
461  );
462  }
463 
464 
465  if ($rbacsystem->checkAccess('edit_permission', $this->ref_id)) {
466  $this->tabs_gui->addTarget(
467  "perm_settings",
468  $this->ctrl->getLinkTargetByClass([get_class($this), 'ilpermissiongui'], "perm"),
469  ["perm", "info", "owner"],
470  'ilpermissiongui'
471  );
472  }
473  }
474 
478  public static function _goto($a_target): void
479  {
480  global $DIC;
481 
482  $ilAccess = $DIC->access();
483  $ilErr = $DIC["ilErr"];
484  $lng = $DIC->language();
485 
486  $a_target = (int) $a_target;
487 
488  if ($ilAccess->checkAccess("read", "", $a_target)) {
490  }
491  if ($ilAccess->checkAccess("visible", "", $a_target)) {
492  ilObjectGUI::_gotoRepositoryNode($a_target, "infoScreen");
493  }
494  $ilErr->raiseError($lng->txt("msg_no_perm_read"), $ilErr->FATAL);
495  }
496 
497  public function modifyItemGUI(ilObjectListGUI $a_item_list_gui, array $a_item_data): void
498  {
499  $tree = $this->tree;
500 
501  // if folder is in a course, modify item list gui according to course requirements
502  if ($course_ref_id = $tree->checkForParentType($this->object->getRefId(), 'crs')) {
503  $course_obj_id = ilObject::_lookupObjId($course_ref_id);
505  $a_item_list_gui,
506  'ilcoursecontentgui',
507  $a_item_data,
508  ilObjCourse::_lookupAboStatus($course_obj_id),
509  $course_ref_id,
510  $course_obj_id,
511  $this->object->getRefId()
512  );
513  }
514  }
515 
519  protected function showPossibleSubObjects(): void
520  {
523  $this->getCreatableObjectTypes()
524  )
525  );
526  $gui->render();
527  }
528 
529 
530  protected function forwardToTimingsView(): void
531  {
532  $tree = $this->tree;
533 
534  if (!$crs_ref = $tree->checkForParentType($this->ref_id, 'crs')) {
535  return;
536  }
537  if (!$this->ctrl->getCmd() && ilObjCourse::_lookupViewMode(ilObject::_lookupObjId($crs_ref)) === ilContainer::VIEW_TIMING) {
538  if (!ilSession::has('crs_timings')) {
539  ilSession::set('crs_timings', true);
540  }
541 
542  if (ilSession::get('crs_timings')) {
543  $this->ctrl->redirectByClass(ilCourseContentGUI::class, 'editUserTimings');
544  return;
545  }
546  }
547  ilSession::set('crs_timings', false);
548  }
549 
550  public function editObject(): void
551  {
552  $ilTabs = $this->tabs;
554 
555  $this->setSubTabs("settings");
556  $ilTabs->activateTab("settings");
557 
558  if (!$this->checkPermissionBool("write")) {
559  $ilErr->raiseError($this->lng->txt("msg_no_perm_write"), $ilErr->MESSAGE);
560  }
561 
562  $form = $this->initEditForm();
563  $values = $this->getEditFormValues();
564  if ($values) {
565  $form->setValuesByArray($values, true);
566  }
567  $GLOBALS['tpl']->setContent($form->getHTML());
568  }
569 
570  public function setSubTabs(string $a_tab): void
571  {
572  $ilTabs = $this->tabs;
573  $lng = $this->lng;
574 
575  $ilTabs->addSubTab(
576  "settings",
577  $lng->txt("fold_settings"),
578  $this->ctrl->getLinkTarget($this, 'edit')
579  );
580 
581  $this->tabs_gui->addSubTab(
582  "settings_trans",
583  $this->lng->txt("obj_multilinguality"),
584  $this->ctrl->getLinkTargetByClass("ilobjecttranslationgui", "")
585  );
586 
587  $ilTabs->activateSubTab($a_tab);
588  $ilTabs->activateTab("settings");
589  }
590 
591  public function deleteObject(bool $error = false): void
592  {
593  $this->tabs_gui->activateTab('view_content');
594  parent::deleteObject($error);
595  }
596 }
static get(string $a_var)
ilRbacSystem $rbacsystem
StandardGUIRequest $folder_request
Class ilObjFolderGUI.
afterSave(ilObject $new_object)
showPossibleSubObjects()
show possible sub objects selection list
saveSortingSettings(ilPropertyFormGUI $form)
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
GUI class for the workflow of copying objects.
const TITLE_LENGTH
prepareOutput(bool $show_sub_objects=true)
setFolderTree(ilTree $a_tree)
Help GUI class.
redirectToRefId(int $ref_id, string $cmd="")
redirects to (repository) view per ref id usually to a container and usually used at the end of a sav...
showSummaryObject()
this one is called from the info button in the repository not very nice to set cmdClass/Cmd manually...
static _gotoRepositoryNode(int $ref_id, string $cmd="")
loadLanguageModule(string $a_module)
Load language module.
static checkAccess(int $a_ref_id, bool $a_allow_only_read=true)
check access to learning progress
$ilErr
Definition: raiseError.php:17
static _lookupViewMode(int $a_id)
static _lookupObjId(int $ref_id)
static _tracProgress(int $a_user_id, int $a_obj_id, int $a_ref_id, string $a_obj_type='')
setSubTabs(string $a_tab)
checkAccess(string $a_operations, int $a_ref_id, string $a_type="")
checkAccess represents the main method of the RBAC-system in ILIAS3 developers want to use With this ...
ilLanguage $lng
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...
checkForParentType(int $a_ref_id, string $a_type, bool $a_exclude_source_check=false)
Check for parent type e.g check if a folder (ref_id 3) is in a parent course obj => checkForParentTyp...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
$GLOBALS["DIC"]
Definition: wac.php:30
modifyItemGUI(ilObjectListGUI $a_item_list_gui, array $a_item_data)
setFormAction(string $a_formaction)
initDidacticTemplate(ilPropertyFormGUI $form)
global $DIC
Definition: shib_login.php:25
Repository GUI Utilities.
static has($a_var)
static _modifyItemGUI(ilObjectListGUI $a_item_list_gui, string $a_cmd_class, array $a_item_data, bool $a_abo_status, int $a_course_ref_id, int $a_course_obj_id, int $a_parent_ref_id=0)
setValuesByArray(array $a_values, bool $a_restrict_to_value_keys=false)
addCommandButton(string $a_cmd, string $a_text, string $a_id="")
ilErrorHandling $error
saveListPresentation(ilPropertyFormGUI $form)
checkPermissionBool(string $perm, string $cmd="", string $type="", ?int $ref_id=null)
ilPropertyFormGUI $form
buildAddNewItemElements(array $subtypes, string $create_target_class=ilRepositoryGUI::class, ?int $redirect_target_ref_id=null,)
updateCustom(ilPropertyFormGUI $form)
Render add new item selector.
infoScreenObject()
this one is called from the info button in the repository not very nice to set cmdClass/Cmd manually...
initListPresentationForm(ilPropertyFormGUI $form)
Add list presentation settings to form.
initSortingForm(ilPropertyFormGUI $form, array $a_sorting_settings)
Append sorting settings to property form.
__construct(Container $dic, ilPlugin $plugin)
This class represents a text area property in a property form.
ilAccessHandler $access
Class ilCourseContentGUI.
getEditFormCustomValues(array &$a_values)
__construct( $a_data, int $a_id=0, bool $a_call_by_reference=true, bool $a_prepare_output=false)
ILIAS Container InternalGUIService $gui
Class ilContainerGUI This is a base GUI class for all container objects in ILIAS: root folder...
static _lookupAboStatus(int $a_id)
static _goto($a_target)
goto target group
addHeaderAction()
Add header action menu.
deleteObject(bool $error=false)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
checkPermission(string $perm, string $cmd="", string $type="", ?int $ref_id=null)
static set(string $a_var, $a_val)
Set a value.
static getInstanceFromAjaxCall()
(Re-)Build instance from ajax call
GUI class for object translation handling.