ILIAS  trunk Revision v11.0_alpha-2638-g80c1d007f79
class.ilObjFolderGUI.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
23 
37 {
38  protected ilHelpGUI $help;
41 
42  public function __construct(
43  $a_data,
44  int $a_id = 0,
45  bool $a_call_by_reference = true,
46  bool $a_prepare_output = false
47  ) {
48  global $DIC;
49 
50  $this->tree = $DIC->repositoryTree();
51  $this->tabs = $DIC->tabs();
52  $this->user = $DIC->user();
53  $this->ctrl = $DIC->ctrl();
54  $this->lng = $DIC->language();
55  $this->access = $DIC->access();
56  $this->rbacsystem = $DIC->rbac()->system();
57  $this->help = $DIC["ilHelp"];
58  $this->error = $DIC["ilErr"];
59  $this->tpl = $DIC["tpl"];
60  $this->settings = $DIC->settings();
61  $this->type = "fold";
62  parent::__construct($a_data, $a_id, $a_call_by_reference, $a_prepare_output);
63  $this->lng->loadLanguageModule("obj");
64  $this->folder_request = $DIC
65  ->folder()
66  ->internal()
67  ->gui()
68  ->standardRequest();
69  }
70 
71 
72  public function viewObject(): void
73  {
74  $this->checkPermission('read');
75  if (strtolower($this->folder_request->getBaseClass()) === "iladministrationgui") {
76  parent::viewObject();
77  return;
78  }
79 
80  // Trac access - see ilObjCourseGUI
82  $GLOBALS["ilUser"]->getId(),
83  $this->object->getId(),
84  $this->object->getRefId(),
85  'fold'
86  );
87 
88  $this->renderObject();
89  $this->tabs_gui->setTabActive('view_content');
90  }
91 
92  public function renderObject(): void
93  {
94  $ilTabs = $this->tabs;
95 
96  $this->checkPermission('read');
97 
98  $ilTabs->activateTab("view_content");
99  parent::renderObject();
100  }
101 
102  public function executeCommand(): void
103  {
104  $ilUser = $this->user;
105  $next_class = $this->ctrl->getNextClass($this);
106  $cmd = $this->ctrl->getCmd();
107 
108  $header_action = true;
109  switch ($next_class) {
110  case strtolower(ilRepositoryTrashGUI::class):
111  $ru = new ilRepositoryTrashGUI($this);
112  $this->ctrl->setReturn($this, 'trash');
113  $this->ctrl->forwardCommand($ru);
114  break;
115 
116  case 'ilpermissiongui':
117  $this->prepareOutput();
118  $this->tabs_gui->activateTab('perm_settings');
119  $perm_gui = new ilPermissionGUI($this);
120  $ret = $this->ctrl->forwardCommand($perm_gui);
121  break;
122 
123 
124  case 'ilcoursecontentgui':
125  $this->prepareOutput();
126  $course_content_obj = new ilCourseContentGUI($this);
127  $this->ctrl->forwardCommand($course_content_obj);
128  break;
129 
130  case "illearningprogressgui":
131  $this->prepareOutput();
132 
133  $new_gui = new ilLearningProgressGUI(
135  $this->object->getRefId(),
136  $this->folder_request->getUserId() ?: $ilUser->getId()
137  );
138  $this->ctrl->forwardCommand($new_gui);
139  $this->tabs_gui->setTabActive('learning_progress');
140  break;
141 
142  // container page editing
143  case "ilcontainerpagegui":
144  $this->prepareOutput(false);
145  $ret = $this->forwardToPageObject();
146  if ($ret !== "") {
147  $this->tpl->setContent($ret);
148  }
149  $header_action = false;
150  break;
151 
152  case 'ilinfoscreengui':
153  $this->prepareOutput();
154  $this->infoScreen();
155  break;
156 
157  case 'ilobjectcopygui':
158  $this->prepareOutput();
159 
160  $cp = new ilObjectCopyGUI($this);
161  $cp->setType('fold');
162  $this->ctrl->forwardCommand($cp);
163  break;
164 
165  case "ilobjectcontentstylesettingsgui":
166  $this->checkPermission("write");
167  $this->setTitleAndDescription();
168  $this->showContainerPageTabs();
169  $settings_gui = $this->content_style_gui
170  ->objectSettingsGUIForRefId(
171  null,
172  $this->object->getRefId()
173  );
174  $this->ctrl->forwardCommand($settings_gui);
175  break;
176 
177  case 'ilexportgui':
178  $this->prepareOutput();
179 
180  $this->tabs_gui->setTabActive('export');
181  $exp = new ilExportGUI($this);
182  $exp->addFormat('xml');
183  $this->ctrl->forwardCommand($exp);
184  break;
185 
186  case "ilcommonactiondispatchergui":
187  $this->prepareOutput();
189  $this->ctrl->forwardCommand($gui);
190  break;
191 
192  case 'ildidactictemplategui':
193  $this->ctrl->setReturn($this, 'edit');
194  $did = new ilDidacticTemplateGUI($this);
195  $this->ctrl->forwardCommand($did);
196  break;
197  case 'ilcolumngui':
198  $this->tabs_gui->setTabActive('none');
199  $this->checkPermission("read");
200  $this->viewObject();
201  break;
202 
203  case strtolower(TranslationGUI::class):
204  $this->checkPermissionBool("write");
205  $this->prepareOutput();
206  $this->setSubTabs("settings_trans");
207  $transgui = new TranslationGUI(
208  $this->getObject(),
209  $this->lng,
210  $this->access,
211  $this->user,
212  $this->ctrl,
213  $this->tpl,
214  $this->ui_factory,
215  $this->ui_renderer,
216  $this->http,
217  $this->refinery,
218  $this->toolbar
219  );
220  $this->ctrl->forwardCommand($transgui);
221  break;
222 
223  default:
224 
225  $this->prepareOutput();
226  // cognos-blu-patch: begin
227  // removed timings forward
228  // cognos-blu-patch: end
229 
230  if (empty($cmd)) {
231  $cmd = "view";
232  }
233  $cmd .= "Object";
234  $this->$cmd();
235  break;
236  }
237 
238  if ($header_action) {
239  $this->addHeaderAction();
240  }
241  }
242 
243  public function setFolderTree(ilTree $a_tree): void
244  {
245  $this->folder_tree = $a_tree;
246  }
247 
248  protected function initEditForm(): ilPropertyFormGUI
249  {
250  $lng = $this->lng;
251  $obj_service = $this->getObjectService();
252 
253  $lng->loadLanguageModule($this->object->getType());
254 
255  $form = new ilPropertyFormGUI();
256  $form->setFormAction($this->ctrl->getFormAction($this, "update"));
257  $form->setTitle($this->lng->txt($this->object->getType() . "_edit"));
258 
259  // title
260  $ti = new ilTextInputGUI($this->lng->txt("title"), "title");
261  $ti->setSize(min(40, ilObject::TITLE_LENGTH));
262  $ti->setMaxLength(ilObject::TITLE_LENGTH);
263  $ti->setRequired(true);
264  $form->addItem($ti);
265 
266  // description
267  $ta = new ilTextAreaInputGUI($this->lng->txt("description"), "desc");
268  $ta->setCols(40);
269  $ta->setRows(2);
270  $form->addItem($ta);
271 
272  // Show didactic template type
273  $this->initDidacticTemplate($form);
274 
275  $pres = new ilFormSectionHeaderGUI();
276  $pres->setTitle($this->lng->txt('fold_presentation'));
277  $form->addItem($pres);
278 
279  // title and icon visibility
280  $form = $obj_service->commonSettings()->legacyForm($form, $this->object)->addTitleIconVisibility();
281 
282  // top actions visibility
283  $form = $obj_service->commonSettings()->legacyForm($form, $this->object)->addTopActionsVisibility();
284 
285  // custom icon
286  $form = $obj_service->commonSettings()->legacyForm($form, $this->object)->addIcon();
287 
288  // tile image
289  $form = $obj_service->commonSettings()->legacyForm($form, $this->object)->addTileImage();
290 
291  // list presentation
293 
294  $this->initSortingForm(
295  $form,
296  [
301  ]
302  );
303 
304  $form->addCommandButton("update", $this->lng->txt("save"));
305  //$this->form->addCommandButton("cancelUpdate", $lng->txt("cancel"));
306 
307  return $form;
308  }
309 
310  protected function getEditFormCustomValues(array &$a_values): void
311  {
312  // we cannot use $this->object->getOrderType()
313  // if set to inherit it will be translated to parent setting
314  $sort = new ilContainerSortingSettings($this->object->getId());
315  $a_values["sor"] = $sort->getSortMode();
316  }
317 
318  protected function updateCustom(ilPropertyFormGUI $form): void
319  {
320  $obj_service = $this->getObjectService();
321 
322  // title icon visibility
323  $obj_service->commonSettings()->legacyForm($form, $this->object)->saveTitleIconVisibility();
324 
325  // top actions visibility
326  $obj_service->commonSettings()->legacyForm($form, $this->object)->saveTopActionsVisibility();
327 
328  // custom icon
329  $obj_service->commonSettings()->legacyForm($form, $this->object)->saveIcon();
330 
331  // tile image
332  $obj_service->commonSettings()->legacyForm($form, $this->object)->saveTileImage();
333 
334  // list presentation
335  $this->saveListPresentation($form);
336 
337  $this->saveSortingSettings($form);
338  }
339 
345  public function showSummaryObject(): void
346  {
347  $this->ctrl->redirectByClass(ilInfoScreenGUI::class, "showSummary");
348  }
349 
350  protected function afterSave(ilObject $new_object): void
351  {
352  $sort = new ilContainerSortingSettings($new_object->getId());
354  $sort->update();
355 
356  // always send a message
357  $this->tpl->setOnScreenMessage('success', $this->lng->txt("fold_added"), true);
358  $this->ctrl->setParameter($this, "ref_id", $new_object->getRefId());
359  $this->redirectToRefId($new_object->getRefId(), "");
360  }
361 
367  public function infoScreenObject(): void
368  {
369  $this->ctrl->redirectByClass(ilInfoScreenGUI::class, "showSummary");
370  }
371 
375  public function infoScreen(): void
376  {
377  $ilAccess = $this->access;
378 
379  if (!$ilAccess->checkAccess("visible", "", $this->ref_id)) {
380  throw new ilPermissionException($this->lng->txt("msg_no_perm_read"));
381  }
382 
383  $info = new ilInfoScreenGUI($this);
384 
385  $GLOBALS['ilTabs']->activateTab('info_short');
386 
387  $info->enablePrivateNotes();
388 
389  if ($ilAccess->checkAccess("read", "", $this->requested_ref_id)) {
390  $info->enableNews();
391  }
392 
393  // no news editing for files, just notifications
394  $info->enableNewsEditing(false);
395  if ($ilAccess->checkAccess("write", "", $this->requested_ref_id)) {
396  $news_set = new ilSetting("news");
397  $enable_internal_rss = $news_set->get("enable_rss_for_internal");
398 
399  if ($enable_internal_rss) {
400  $info->setBlockProperty("news", "settings", '1');
401  $info->setBlockProperty("news", "public_notifications_option", '1');
402  }
403  }
404 
405 
406  // standard meta data
407  $info->addMetaDataSections($this->object->getId(), 0, $this->object->getType());
408 
409  // forward the command
410  $this->ctrl->forwardCommand($info);
411  }
412 
413  protected function getTabs(): void
414  {
416  $lng = $this->lng;
417  $ilCtrl = $this->ctrl;
418  $ilAccess = $this->access;
419  $ilHelp = $this->help;
420 
421  $this->ctrl->setParameter($this, "ref_id", $this->ref_id);
422 
423  $ilHelp->setScreenIdComponent("fold");
424 
425  $this->tabs_gui->setTabActive("");
426  if ($ilAccess->checkAccess('read', '', $this->ref_id)) {
427  $this->tabs_gui->addTab(
428  "view_content",
429  $lng->txt("content"),
430  $this->ctrl->getLinkTarget($this, "")
431  );
432 
433  //BEGIN ChangeEvent add info tab to category object
434  $force_active = $this->ctrl->getNextClass() === "ilinfoscreengui"
435  || strtolower($this->ctrl->getCmdClass()) === "ilnotegui";
436  $this->tabs_gui->addTarget(
437  "info_short",
438  $this->ctrl->getLinkTargetByClass(
439  ["ilobjfoldergui", "ilinfoscreengui"],
440  "showSummary"
441  ),
442  ["showSummary", "", "infoScreen"],
443  "",
444  "",
445  $force_active
446  );
447  //END ChangeEvent add info tab to category object
448  }
449 
450  if ($rbacsystem->checkAccess('write', $this->ref_id)) {
451  $this->tabs_gui->addTarget(
452  "settings",
453  $this->ctrl->getLinkTarget($this, "edit"),
454  "edit",
455  "",
456  "",
457  ($ilCtrl->getCmd() === "edit")
458  );
459  }
460 
461  // learning progress
462  if (ilLearningProgressAccess::checkAccess($this->object->getRefId())) {
463  $this->tabs_gui->addTarget(
464  'learning_progress',
465  $this->ctrl->getLinkTargetByClass(['ilobjfoldergui', 'illearningprogressgui'], ''),
466  '',
467  ['illplistofobjectsgui', 'illplistofsettingsgui', 'illearningprogressgui', 'illplistofprogressgui']
468  );
469  }
470 
471  if ($ilAccess->checkAccess('write', '', $this->object->getRefId())) {
472  $this->tabs_gui->addTarget(
473  'export',
474  $this->ctrl->getLinkTargetByClass('ilexportgui', ''),
475  'export',
476  'ilexportgui'
477  );
478  }
479 
480 
481  if ($rbacsystem->checkAccess('edit_permission', $this->ref_id)) {
482  $this->tabs_gui->addTarget(
483  "perm_settings",
484  $this->ctrl->getLinkTargetByClass([get_class($this), 'ilpermissiongui'], "perm"),
485  ["perm", "info", "owner"],
486  'ilpermissiongui'
487  );
488  }
489  }
490 
494  public static function _goto($a_target): void
495  {
496  global $DIC;
497 
498  $ilAccess = $DIC->access();
499  $ilErr = $DIC["ilErr"];
500  $lng = $DIC->language();
501 
502  $a_target = (int) $a_target;
503 
504  if ($ilAccess->checkAccess("read", "", $a_target)) {
506  }
507  if ($ilAccess->checkAccess("visible", "", $a_target)) {
508  ilObjectGUI::_gotoRepositoryNode($a_target, "infoScreen");
509  }
510  $ilErr->raiseError($lng->txt("msg_no_perm_read"), $ilErr->FATAL);
511  }
512 
513  public function modifyItemGUI(ilObjectListGUI $a_item_list_gui, array $a_item_data): void
514  {
515  $tree = $this->tree;
516 
517  // if folder is in a course, modify item list gui according to course requirements
518  if ($course_ref_id = $tree->checkForParentType($this->object->getRefId(), 'crs')) {
519  $course_obj_id = ilObject::_lookupObjId($course_ref_id);
521  $a_item_list_gui,
522  'ilcoursecontentgui',
523  $a_item_data,
524  ilObjCourse::_lookupAboStatus($course_obj_id),
525  $course_ref_id,
526  $course_obj_id,
527  $this->object->getRefId()
528  );
529  }
530  }
531 
535  protected function showPossibleSubObjects(): void
536  {
539  $this->getCreatableObjectTypes()
540  )
541  );
542  $gui->render();
543  }
544 
545 
546  protected function forwardToTimingsView(): void
547  {
548  $tree = $this->tree;
549 
550  if (!$crs_ref = $tree->checkForParentType($this->ref_id, 'crs')) {
551  return;
552  }
553  if (!$this->ctrl->getCmd() && ilObjCourse::_lookupViewMode(ilObject::_lookupObjId($crs_ref)) === ilContainer::VIEW_TIMING) {
554  if (!ilSession::has('crs_timings')) {
555  ilSession::set('crs_timings', true);
556  }
557 
558  if (ilSession::get('crs_timings')) {
559  $this->ctrl->redirectByClass(ilCourseContentGUI::class, 'editUserTimings');
560  return;
561  }
562  }
563  ilSession::set('crs_timings', false);
564  }
565 
566  public function editObject(): void
567  {
568  $ilTabs = $this->tabs;
570 
571  $this->setSubTabs("settings");
572  $ilTabs->activateTab("settings");
573 
574  if (!$this->checkPermissionBool("write")) {
575  $ilErr->raiseError($this->lng->txt("msg_no_perm_write"), $ilErr->MESSAGE);
576  }
577 
578  $form = $this->initEditForm();
579  $values = $this->getEditFormValues();
580  if ($values) {
581  $form->setValuesByArray($values, true);
582  }
583  $GLOBALS['tpl']->setContent($form->getHTML());
584  }
585 
586  public function setSubTabs(string $a_tab): void
587  {
588  $ilTabs = $this->tabs;
589  $lng = $this->lng;
590 
591  $ilTabs->addSubTab(
592  "settings",
593  $lng->txt("fold_settings"),
594  $this->ctrl->getLinkTarget($this, 'edit')
595  );
596 
597  $this->tabs_gui->addSubTab(
598  "settings_trans",
599  $this->lng->txt("obj_multilinguality"),
600  $this->ctrl->getLinkTargetByClass(TranslationGUI::class, "")
601  );
602 
603  $ilTabs->activateSubTab($a_tab);
604  $ilTabs->activateTab("settings");
605  }
606 
607  public function deleteObject(bool $error = false): void
608  {
609  $this->tabs_gui->activateTab('view_content');
610  parent::deleteObject($error);
611  }
612 }
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:33
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='')
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
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...
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...
static http()
Fetches the global http state from ILIAS.
$GLOBALS["DIC"]
Definition: wac.php:53
modifyItemGUI(ilObjectListGUI $a_item_list_gui, array $a_item_data)
setFormAction(string $a_formaction)
initDidacticTemplate(ilPropertyFormGUI $form)
global $DIC
Definition: shib_login.php:26
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
$info
Definition: entry_point.php:21
static _lookupAboStatus(int $a_id)
static _goto($a_target)
goto target group
addHeaderAction()
Add header action menu.
deleteObject(bool $error=false)
Class ilObjUserTrackingGUI.
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