ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
ilChatroomSettingsGUI Class Reference

Class ilChatroomSettingsGUI. More...

+ Inheritance diagram for ilChatroomSettingsGUI:
+ Collaboration diagram for ilChatroomSettingsGUI:

Public Member Functions

 saveGeneral ()
 
 general (\ILIAS\UI\Component\Input\Container\Form\Form $settingsForm=null)
 
 executeDefault (string $requestedMethod)
 
- Public Member Functions inherited from ilChatroomGUIHandler
 execute (string $method)
 
 executeDefault (string $requestedMethod)
 
 redirectIfNoPermission ($permission)
 Checks for requested permissions and redirects if the permission check failed. More...
 
 isSuccessful ($response)
 Checks for success param in an json decoded response. More...
 
 sendResponse ($response, bool $isJson=false)
 Sends a json encoded response and exits the php process. More...
 
 hasPermission (string $permission)
 

Additional Inherited Members

- Protected Member Functions inherited from ilChatroomGUIHandler
 getRequestValue (string $key, Transformation $trafo, $default=null)
 
 hasRequestValue (string $key)
 
 getRoomByObjectId (int $objectId)
 
 exitIfNoRoomExists (?ilChatroom $room)
 Checks if a ilChatroom exists. More...
 
- Protected Attributes inherited from ilChatroomGUIHandler
ilObjUser $ilUser
 
ilCtrlInterface $ilCtrl
 
ilLanguage $ilLng
 
Filesystem $webDirectory
 
ilObjectService $obj_service
 
FileUpload $upload
 
ilRbacSystem $rbacsystem
 
ilGlobalTemplateInterface $mainTpl
 
ILIAS $ilias
 
ilNavigationHistory $navigationHistory
 
ilTree $tree
 
ilTabsGUI $tabs
 
UIFactory $uiFactory
 
UIRenderer $uiRenderer
 
GlobalHttpState $http
 
Refinery $refinery
 

Detailed Description

Member Function Documentation

◆ executeDefault()

ilChatroomSettingsGUI::executeDefault ( string  $requestedMethod)

Definition at line 123 of file class.ilChatroomSettingsGUI.php.

References general().

123  : void
124  {
125  $this->general();
126  }
general(\ILIAS\UI\Component\Input\Container\Form\Form $settingsForm=null)
+ Here is the call graph for this function:

◆ general()

ilChatroomSettingsGUI::general ( \ILIAS\UI\Component\Input\Container\Form\Form  $settingsForm = null)

Definition at line 86 of file class.ilChatroomSettingsGUI.php.

References ILIAS\LTI\ToolProvider\$settings, ilChatroom\byObjectId(), ilChatroom\checkUserPermissions(), and ROOT_FOLDER_ID.

Referenced by executeDefault(), and saveGeneral().

86  : void
87  {
88  if (!ilChatroom::checkUserPermissions(['visible', 'read'], $this->gui->getRefId())) {
89  $this->ilCtrl->setParameterByClass(ilRepositoryGUI::class, 'ref_id', ROOT_FOLDER_ID);
90  $this->ilCtrl->redirectByClass(ilRepositoryGUI::class);
91  }
92 
93  $chatSettings = new ilSetting('chatroom');
94  if (!$chatSettings->get('chat_enabled', '0')) {
95  $this->mainTpl->setOnScreenMessage('info', $this->ilLng->txt('server_disabled'), true);
96  }
97 
98  $this->gui->switchToVisibleMode();
99 
100  $formFactory = new ilChatroomFormFactory();
101 
102  $room = ilChatroom::byObjectId($this->gui->getObject()->getId());
103 
104  if ($settingsForm === null) {
105  $settings = [
106  'title' => $this->gui->getObject()->getTitle(),
107  'desc' => $this->gui->getObject()->getDescription(),
108  ];
109  if ($room) {
110  $settings = array_merge($settings, $room->getSettings());
111  }
112 
113  $settingsForm = $formFactory->getSettingsForm(
114  $this->gui,
115  $this->ilCtrl,
116  $settings
117  );
118  }
119 
120  $this->mainTpl->setVariable('ADM_CONTENT', $this->uiRenderer->render($settingsForm));
121  }
static checkUserPermissions($permissions, int $ref_id, bool $send_info=true)
Checks user permissions by given array and ref_id.
array $settings
Setting values (LTI parameters, custom parameters and local parameters).
Definition: System.php:200
const ROOT_FOLDER_ID
Definition: constants.php:32
static byObjectId(int $object_id)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ saveGeneral()

ilChatroomSettingsGUI::saveGeneral ( )

Definition at line 29 of file class.ilChatroomSettingsGUI.php.

References ilChatroom\byObjectId(), general(), ILIAS\FileDelivery\http(), ilChatroomFormFactory\PROP_ALLOW_CUSTOM_NAMES, ilChatroomFormFactory\PROP_AUTOGEN_USERNAMES, ilChatroomFormFactory\PROP_ONLINE_STATUS, ilChatroomFormFactory\PROP_TILE_IMAGE, and ilChatroomFormFactory\PROP_TITLE_AND_DESC.

29  : void
30  {
31  $formFactory = new ilChatroomFormFactory();
32 
33  $settingsForm = $formFactory->getSettingsForm(
34  $this->gui,
35  $this->ilCtrl
36  );
37 
38  $result = (new \ILIAS\Data\Factory())->error($this->ilLng->txt('form_input_not_valid'));
39  if ($this->http->request()->getMethod() === 'POST') {
40  $settingsForm = $settingsForm->withRequest($this->http->request());
41  $result = $settingsForm->getInputGroup()->getContent();
42  }
43 
44  if (!$result->isOK()) {
45  $this->mainTpl->setOnScreenMessage('failure', $result->error());
46  $this->general($settingsForm);
47  return;
48  }
49 
50  $values = $result->value();
51 
52  $this->gui->getObject()->getObjectProperties()->storePropertyTitleAndDescription(
54  );
55  $this->gui->getObject()->getObjectProperties()->storePropertyIsOnline(
57  );
58  $this->gui->getObject()->getObjectProperties()->storePropertyTileImage(
60  );
61 
62  $room = ilChatroom::byObjectId($this->gui->getObject()->getId());
63  $mutated_settings = $room->getSettings();
64  if (!$room) {
65  $room = new ilChatroom();
66  $mutated_settings['object_id'] = $this->gui->getObject()->getId();
67  }
68 
69  foreach ($mutated_settings as $setting => &$value) {
71  $value = is_array($values[$setting] ?? null);
72  } elseif ($setting === ilChatroomFormFactory::PROP_AUTOGEN_USERNAMES) {
74  } elseif (array_key_exists($setting, $values)) {
75  $value = $values[$setting];
76  }
77  }
78  unset($value);
79 
80  $room->saveSettings($mutated_settings);
81 
82  $this->mainTpl->setOnScreenMessage('success', $this->ilLng->txt('saved_successfully'), true);
83  $this->ilCtrl->redirect($this->gui, 'settings-general');
84  }
static http()
Fetches the global http state from ILIAS.
general(\ILIAS\UI\Component\Input\Container\Form\Form $settingsForm=null)
Class ilChatroom.
static byObjectId(int $object_id)
+ Here is the call graph for this function:

The documentation for this class was generated from the following file: