ILIAS  trunk Revision v11.0_alpha-1851-ga8564da6fed
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
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...
 
 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...
 
 sendJSONResponse ($response)
 Sends a json encoded response and exits the php process. More...
 
 sendResponse (string $content, string $type)
 Sends a response and exits the php process. 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

Class ilChatroomSettingsGUI.

Author
Jan Posselt jposs.nosp@m.elt@.nosp@m.datab.nosp@m.ay.d.nosp@m.e
Version
$Id$ \

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

Member Function Documentation

◆ executeDefault()

ilChatroomSettingsGUI::executeDefault ( string  $requestedMethod)

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

References general().

131  : void
132  {
133  $this->general();
134  }
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 93 of file class.ilChatroomSettingsGUI.php.

References ilChatroom\byObjectId(), ilChatroom\checkUserPermissions(), null, and ROOT_FOLDER_ID.

Referenced by executeDefault(), and saveGeneral().

93  : void
94  {
95  if (!ilChatroom::checkUserPermissions(['visible', 'read'], $this->gui->getRefId())) {
96  $this->ilCtrl->setParameterByClass(ilRepositoryGUI::class, 'ref_id', ROOT_FOLDER_ID);
97  $this->ilCtrl->redirectByClass(ilRepositoryGUI::class);
98  }
99 
100  $chatSettings = new ilSetting('chatroom');
101  if (!$chatSettings->get('chat_enabled', '0')) {
102  $this->mainTpl->setOnScreenMessage('info', $this->ilLng->txt('server_disabled'), true);
103  }
104 
105  $this->gui->switchToVisibleMode();
106 
107  $formFactory = new ilChatroomFormFactory();
108 
109  $room = ilChatroom::byObjectId($this->gui->getObject()->getId());
110 
111  if ($settingsForm === null) {
112  $settings = [
113  'title' => $this->gui->getObject()->getTitle(),
114  'desc' => $this->gui->getObject()->getDescription(),
115  ];
116  if ($room) {
117  $settings = array_merge($settings, $room->getSettings());
118  }
119 
120  $settingsForm = $formFactory->getSettingsForm(
121  $this->gui,
122  $this->ilCtrl,
123  $settings,
124  ilChatroom::checkUserPermissions(['write'], $this->gui->getRefId(), false)
125  );
126  }
127 
128  $this->mainTpl->setVariable('ADM_CONTENT', $this->uiRenderer->render($settingsForm));
129  }
static checkUserPermissions($permissions, int $ref_id, bool $send_info=true)
Checks user permissions by given array and ref_id.
const ROOT_FOLDER_ID
Definition: constants.php:32
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
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(), ilChatroom\checkUserPermissions(), general(), ILIAS\FileDelivery\http(), null, ilChatroomFormFactory\PROP_ALLOW_CUSTOM_NAMES, ilChatroomFormFactory\PROP_AUTOGEN_USERNAMES, ilChatroomFormFactory\PROP_ONLINE_STATUS, ilChatroomFormFactory\PROP_TILE_IMAGE, ilChatroomFormFactory\PROP_TITLE_AND_DESC, and ROOT_FOLDER_ID.

29  : void
30  {
31  if (!ilChatroom::checkUserPermissions(['write'], $this->gui->getRefId())) {
32  $this->ilCtrl->setParameterByClass(ilRepositoryGUI::class, 'ref_id', ROOT_FOLDER_ID);
33  $this->ilCtrl->redirectByClass(ilRepositoryGUI::class);
34  }
35 
36  $formFactory = new ilChatroomFormFactory();
37 
38  $settingsForm = $formFactory->getSettingsForm(
39  $this->gui,
40  $this->ilCtrl,
41  null,
42  true
43  );
44 
45  $result = (new \ILIAS\Data\Factory())->error($this->ilLng->txt('form_input_not_valid'));
46  if ($this->http->request()->getMethod() === 'POST') {
47  $settingsForm = $settingsForm->withRequest($this->http->request());
48  $result = $settingsForm->getInputGroup()->getContent();
49  }
50 
51  if (!$result->isOK()) {
52  $this->mainTpl->setOnScreenMessage('failure', $result->error());
53  $this->general($settingsForm);
54  return;
55  }
56 
57  $values = $result->value();
58 
59  $this->gui->getObject()->getObjectProperties()->storePropertyTitleAndDescription(
61  );
62  $this->gui->getObject()->getObjectProperties()->storePropertyIsOnline(
64  );
65  $this->gui->getObject()->getObjectProperties()->storePropertyTileImage(
67  );
68 
69  $room = ilChatroom::byObjectId($this->gui->getObject()->getId());
70  $mutated_settings = $room->getSettings();
71  if (!$room) {
72  $room = new ilChatroom();
73  $mutated_settings['object_id'] = $this->gui->getObject()->getId();
74  }
75 
76  foreach ($mutated_settings as $setting => &$value) {
78  $value = is_array($values[$setting] ?? null);
79  } elseif ($setting === ilChatroomFormFactory::PROP_AUTOGEN_USERNAMES) {
81  } elseif (array_key_exists($setting, $values)) {
82  $value = $values[$setting];
83  }
84  }
85  unset($value);
86 
87  $room->saveSettings($mutated_settings);
88 
89  $this->mainTpl->setOnScreenMessage('success', $this->ilLng->txt('saved_successfully'), true);
90  $this->ilCtrl->redirect($this->gui, 'settings-general');
91  }
static checkUserPermissions($permissions, int $ref_id, bool $send_info=true)
Checks user permissions by given array and ref_id.
const ROOT_FOLDER_ID
Definition: constants.php:32
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
static http()
Fetches the global http state from ILIAS.
general(?\ILIAS\UI\Component\Input\Container\Form\Form $settingsForm=null)
static byObjectId(int $object_id)
+ Here is the call graph for this function:

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