ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ilChatroomAuthInputGUI Class Reference

Class ilChatroomAuthInputGUI. More...

+ Inheritance diagram for ilChatroomAuthInputGUI:
+ Collaboration diagram for ilChatroomAuthInputGUI:

Public Member Functions

 __construct (string $title, string $httpPostVariableName, protected \ILIAS\HTTP\Services $http)
 
 setIsReadOnly (bool $isReadOnly)
 
 setCtrlPath (array $ctrl_path)
 
 setValueByArray (array $a_values)
 
 checkInput ()
 Check input, strip slashes etc. More...
 
 getInput ()
 
 insert (ilTemplate $a_tpl)
 
 render ()
 
 getSize ()
 
 setSize (int $size)
 
- Public Member Functions inherited from ilSubEnabledFormPropertyGUI
 addSubItem (ilFormPropertyGUI $a_item)
 
 getSubItems ()
 
 getSubInputItemsRecursive ()
 returns a flat array of possibly existing subitems recursively More...
 
 checkSubItemsInput ()
 Check SubItems. More...
 
 getSubForm ()
 
 getItemByPostVar (string $a_post_var)
 Get item by post var. More...
 
- Public Member Functions inherited from ilFormPropertyGUI
 __construct (string $a_title="", string $a_postvar="")
 
 executeCommand ()
 
 getType ()
 
 setTitle (string $a_title)
 
 getTitle ()
 
 setPostVar (string $a_postvar)
 
 getPostVar ()
 
 getFieldId ()
 
 setInfo (string $a_info)
 
 getInfo ()
 
 setAlert (string $a_alert)
 
 getAlert ()
 
 setRequired (bool $a_required)
 
 getRequired ()
 
 setDisabled (bool $a_disabled)
 
 getDisabled ()
 
 checkInput ()
 Check input, strip slashes etc. More...
 
 setParentForm (ilPropertyFormGUI $a_parentform)
 
 getParentForm ()
 
 setParent (ilFormPropertyGUI $a_val)
 
 getParent ()
 
 getSubForm ()
 
 hideSubForm ()
 
 setHiddenTitle (string $a_val)
 
 getHiddenTitle ()
 
 getItemByPostVar (string $a_post_var)
 Get item by post var. More...
 
 serializeData ()
 
 unserializeData (string $a_data)
 
 setParentTable ($a_val)
 Set parent table. More...
 
 getParentTable ()
 Get parent table. More...
 
 writeToSession ()
 
 clearFromSession ()
 
 readFromSession ()
 
 getHiddenTag (string $a_post_var, string $a_value)
 
 setMulti (bool $a_multi, bool $a_sortable=false, bool $a_addremove=true)
 
 getMulti ()
 
 setMultiValues (array $a_values)
 
 getMultiValues ()
 
 getContentOutsideFormTag ()
 Get content that has to reside outside of the parent form tag, e.g. More...
 
 stripSlashesAddSpaceFallback (string $a_str)
 Strip slashes with add space fallback, see https://www.ilias.de/mantis/view.php?id=19727. More...
 
 getTableFilterLabelFor ()
 Get label "for" attribute value for filter. More...
 
 getFormLabelFor ()
 Get label "for" attribute value for form. More...
 
 setRequestParam (string $key, $val)
 This writes the request (aka post) values. More...
 

Protected Member Functions

 getRandomValues ()
 
- Protected Member Functions inherited from ilFormPropertyGUI
 symbol ()
 
 setType (string $a_type)
 
 checkParentFormTable ()
 
 getSessionKey ()
 
 getMultiIconsHTML ()
 
 int ($key)
 
 intArray ($key)
 
 str ($key)
 
 raw ($key)
 
 strArray ($key)
 
 arrayArray ($key)
 
 isRequestParamArray (string $key)
 
 getRequestParam (string $key, Refinery\Transformation $t)
 

Protected Attributes

array $ctrl_path = []
 
int $size = 10
 
array $values = self::DEFAULT_SHAPE
 
bool $isReadOnly = false
 
- Protected Attributes inherited from ilSubEnabledFormPropertyGUI
array $sub_items = array()
 
- Protected Attributes inherited from ilFormPropertyGUI
array $set_params = []
 
ilTable2GUI $parent_table = null
 
ilFormPropertyGUI $parent_gui = null
 
ilCtrl $ctrl
 
ilLanguage $lng
 
string $type = ""
 
string $title = ""
 
string $postvar = ""
 
string $info = ""
 
string $alert = ""
 
bool $required = false
 
ilPropertyFormGUI $parentform = null
 
string $hidden_title = ""
 
bool $multi = false
 
bool $multi_sortable = false
 
bool $multi_addremove = true
 
array $multi_values = []
 
RequestInterface $request
 
HTTP Services $http
 
Refinery Factory $refinery = null
 
bool $disabled = false
 
ilGlobalTemplateInterface $global_tpl = null
 

Private Member Functions

 uuidV4 ()
 

Private Attributes

const string NAME_AUTH_PROP_1 = 'key'
 
const string NAME_AUTH_PROP_2 = 'secret'
 
const array DEFAULT_SHAPE
 

Additional Inherited Members

- Static Public Member Functions inherited from ilFormPropertyGUI
static removeProhibitedCharacters (string $a_text)
 Remove prohibited characters see #19159. More...
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilChatroomAuthInputGUI::__construct ( string  $title,
string  $httpPostVariableName,
protected \ILIAS\HTTP\Services  $http 
)

Definition at line 44 of file class.ilChatroomAuthInputGUI.php.

45 {
46 parent::__construct($title, $httpPostVariableName);
47 }
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc

References ilFormPropertyGUI\$title, and ILIAS\GlobalScreen\Provider\__construct().

+ Here is the call graph for this function:

Member Function Documentation

◆ checkInput()

ilChatroomAuthInputGUI::checkInput ( )

Check input, strip slashes etc.

set alert, if input is not ok.

Reimplemented from ilFormPropertyGUI.

Definition at line 114 of file class.ilChatroomAuthInputGUI.php.

114 : bool
115 {
116 $post = $this->http->request()->getParsedBody()[$this->getPostVar()] ?? [];
117
118 if ($this->getRequired() && 2 > count(array_filter(array_map('trim', $post)))) {
119 $this->setAlert($this->lng->txt('msg_input_is_required'));
120 return false;
121 }
122
123 return $this->checkSubItemsInput();
124 }
$post
Definition: ltitoken.php:46
static http()
Fetches the global http state from ILIAS.

References $post, ILIAS\FileDelivery\http(), and ILIAS\Repository\lng().

+ Here is the call graph for this function:

◆ getInput()

ilChatroomAuthInputGUI::getInput ( )
Returns
array{key: string, secret: string}

Definition at line 129 of file class.ilChatroomAuthInputGUI.php.

129 : array
130 {
131 $input = self::DEFAULT_SHAPE;
132
133 $as_sanizited_string = $this->refinery->custom()->transformation(function (string $value): string {
134 return $this->stripSlashesAddSpaceFallback($value);
135 });
136
137 $null_to_empty_string = $this->refinery->custom()->transformation(static function ($value): string {
138 if ($value === null) {
139 return '';
140 }
141
142 throw new ilException('Expected null in transformation');
143 });
144
145 $sanizite_as_string = $this->refinery->in()->series([
146 $this->refinery->byTrying([
147 $this->refinery->kindlyTo()->string(),
148 $null_to_empty_string
149 ]),
150 $as_sanizited_string
151 ]);
152
153 if ($this->http->wrapper()->post()->has($this->getPostVar())) {
154 $input = $this->http->wrapper()->post()->retrieve(
155 $this->getPostVar(),
156 $this->refinery->kindlyTo()->recordOf([
157 self::NAME_AUTH_PROP_1 => $sanizite_as_string,
158 self::NAME_AUTH_PROP_2 => $sanizite_as_string
159 ])
160 );
161 }
162
163 return $input;
164 }
Base class for ILIAS Exception handling.
stripSlashesAddSpaceFallback(string $a_str)
Strip slashes with add space fallback, see https://www.ilias.de/mantis/view.php?id=19727.

References ILIAS\FileDelivery\http(), and ILIAS\Repository\refinery().

+ Here is the call graph for this function:

◆ getRandomValues()

ilChatroomAuthInputGUI::getRandomValues ( )
protected

Definition at line 54 of file class.ilChatroomAuthInputGUI.php.

54 : void
55 {
56 $response = new stdClass();
57
58 $response->{self::NAME_AUTH_PROP_1} = $this->uuidV4();
59 $response->{self::NAME_AUTH_PROP_2} = $this->uuidV4();
60
61 $responseStream = \ILIAS\Filesystem\Stream\Streams::ofString(json_encode($response, JSON_THROW_ON_ERROR));
62 $this->http->saveResponse(
63 $this->http->response()
64 ->withBody($responseStream)
65 ->withHeader(ResponseHeader::CONTENT_TYPE, 'application/json')
66 );
67 $this->http->sendResponse();
68 $this->http->close();
69 }
static ofString(string $string)
Creates a new stream with an initial value.
Definition: Streams.php:41
$response
Definition: xapitoken.php:93

References $response.

◆ getSize()

ilChatroomAuthInputGUI::getSize ( )

Definition at line 216 of file class.ilChatroomAuthInputGUI.php.

216 : int
217 {
218 return $this->size;
219 }

◆ insert()

ilChatroomAuthInputGUI::insert ( ilTemplate  $a_tpl)

Definition at line 166 of file class.ilChatroomAuthInputGUI.php.

166 : void
167 {
168 $a_tpl->setCurrentBlock('prop_generic');
169 $a_tpl->setVariable('PROP_GENERIC', $this->render());
170 $a_tpl->parseCurrentBlock();
171 }
setVariable($variable, $value='')
Sets a variable value.
Definition: IT.php:544
setCurrentBlock(string $part=ilGlobalTemplateInterface::DEFAULT_BLOCK)
parseCurrentBlock(string $part=ilGlobalTemplateInterface::DEFAULT_BLOCK)

References ilTemplate\parseCurrentBlock(), ilTemplate\setCurrentBlock(), and HTML_Template_IT\setVariable().

+ Here is the call graph for this function:

◆ render()

ilChatroomAuthInputGUI::render ( )

Definition at line 173 of file class.ilChatroomAuthInputGUI.php.

173 : string
174 {
175 global $DIC;
176
177 $tpl = new ilTemplate('tpl.chatroom_auth_input.html', true, true, 'components/ILIAS/Chatroom');
178
179 for ($i = 1, $iMax = count($this->values); $i <= $iMax; $i++) {
180 $const = 'NAME_AUTH_PROP_' . $i;
181 $const_val = constant('self::' . $const);
182
183 $tpl->setVariable('TXT_AUTH_PROP_' . $i, $DIC->language()->txt('chatroom_auth_' . $const_val));
184 $tpl->setVariable('ID_AUTH_PROP_' . $i, $const_val);
185 $tpl->setVariable('NAME_AUTH_PROP_' . $i, $const_val);
186 $tpl->setVariable('VALUE_AUTH_PROP_' . $i, $this->values[$const_val]);
187 }
188
189 if (!$this->isReadOnly && !$this->getDisabled()) {
190 for ($i = 1, $iMax = count($this->values); $i <= $iMax; $i++) {
191 $const = 'NAME_AUTH_PROP_' . $i;
192 $const_val = constant('self::' . $const);
193
194 $tpl->setVariable('ID_AUTH_PROP_' . $i . '_BTN', $const_val);
195 }
196
197 $DIC->ctrl()->setParameterByClass('ilformpropertydispatchgui', 'postvar', $this->getPostVar());
198 $tpl->setVariable(
199 'URL',
200 $DIC->ctrl()->getLinkTargetByClass($this->ctrl_path, 'getRandomValues', '', true)
201 );
202 $tpl->setVariable('ID_BTN', $this->getFieldId() . '_btn');
203 $tpl->setVariable('TXT_BTN', $DIC->language()->txt('chatroom_auth_btn_txt'));
204 }
205
206 $tpl->setVariable('POST_VAR', $this->getPostVar());
207 $tpl->setVariable('SIZE', $this->getSize());
208
209 if ($this->getDisabled()) {
210 $tpl->setVariable('DISABLED', ' disabled="disabled"');
211 }
212
213 return $tpl->get();
214 }
special template class to simplify handling of ITX/PEAR
global $DIC
Definition: shib_login.php:26

References $DIC.

◆ setCtrlPath()

ilChatroomAuthInputGUI::setCtrlPath ( array  $ctrl_path)
Parameters
string[]$ctrl_path

Definition at line 97 of file class.ilChatroomAuthInputGUI.php.

97 : void
98 {
99 $this->ctrl_path = $ctrl_path;
100 }

◆ setIsReadOnly()

ilChatroomAuthInputGUI::setIsReadOnly ( bool  $isReadOnly)

Definition at line 49 of file class.ilChatroomAuthInputGUI.php.

49 : void
50 {
51 $this->isReadOnly = $isReadOnly;
52 }

References $isReadOnly.

◆ setSize()

ilChatroomAuthInputGUI::setSize ( int  $size)

Definition at line 221 of file class.ilChatroomAuthInputGUI.php.

221 : void
222 {
223 $this->size = $size;
224 }

◆ setValueByArray()

ilChatroomAuthInputGUI::setValueByArray ( array  $a_values)

Definition at line 102 of file class.ilChatroomAuthInputGUI.php.

102 : void
103 {
104 $this->values = [
105 self::NAME_AUTH_PROP_1 => $a_values[$this->getPostVar()][self::NAME_AUTH_PROP_1] ?? '',
106 self::NAME_AUTH_PROP_2 => $a_values[$this->getPostVar()][self::NAME_AUTH_PROP_2] ?? ''
107 ];
108
109 foreach ($this->getSubItems() as $item) {
110 $item->setValueByArray($a_values);
111 }
112 }

◆ uuidV4()

ilChatroomAuthInputGUI::uuidV4 ( )
private

Definition at line 71 of file class.ilChatroomAuthInputGUI.php.

71 : string
72 {
73 return sprintf(
74 '%04x%04x-%04x-%04x-%04x-%04x%04x%04x',
75 // 32 bits for "time_low"
76 random_int(0, 0xffff),
77 random_int(0, 0xffff),
78 // 16 bits for "time_mid"
79 random_int(0, 0xffff),
80 // 16 bits for "time_high_and_version",
81 // four most significant bits holds version number 4
82 random_int(0, 0x0fff) | 0x4000,
83 // 16 bits, 8 bits for "clk_seq_hi_res",
84 // 8 bits for "clk_seq_low",
85 // two most significant bits holds zero and one for variant DCE1.1
86 random_int(0, 0x3fff) | 0x8000,
87 // 48 bits for "node"
88 random_int(0, 0xffff),
89 random_int(0, 0xffff),
90 random_int(0, 0xffff)
91 );
92 }

Field Documentation

◆ $ctrl_path

array ilChatroomAuthInputGUI::$ctrl_path = []
protected

Definition at line 38 of file class.ilChatroomAuthInputGUI.php.

◆ $isReadOnly

bool ilChatroomAuthInputGUI::$isReadOnly = false
protected

Definition at line 42 of file class.ilChatroomAuthInputGUI.php.

Referenced by setIsReadOnly().

◆ $size

int ilChatroomAuthInputGUI::$size = 10
protected

Definition at line 39 of file class.ilChatroomAuthInputGUI.php.

◆ $values

array ilChatroomAuthInputGUI::$values = self::DEFAULT_SHAPE
protected

Definition at line 41 of file class.ilChatroomAuthInputGUI.php.

◆ DEFAULT_SHAPE

const array ilChatroomAuthInputGUI::DEFAULT_SHAPE
private
Initial value:
= [
self::NAME_AUTH_PROP_1 => '',
self::NAME_AUTH_PROP_2 => ''
]

Definition at line 33 of file class.ilChatroomAuthInputGUI.php.

◆ NAME_AUTH_PROP_1

const string ilChatroomAuthInputGUI::NAME_AUTH_PROP_1 = 'key'
private

Definition at line 31 of file class.ilChatroomAuthInputGUI.php.

◆ NAME_AUTH_PROP_2

const string ilChatroomAuthInputGUI::NAME_AUTH_PROP_2 = 'secret'
private

Definition at line 32 of file class.ilChatroomAuthInputGUI.php.


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