ILIAS  release_8 Revision v8.24
ilMemberAgreementGUI Class Reference
+ Collaboration diagram for ilMemberAgreementGUI:

Public Member Functions

 __construct (int $a_ref_id)
 
 executeCommand ()
 
 getPrivacy ()
 
 getAgreement ()
 

Static Public Member Functions

static addExportFieldInfo (ilPropertyFormGUI $form, int $a_obj_id, string $a_type)
 
static addAgreement (ilPropertyFormGUI $form, int $a_obj_id, string $a_type)
 
static addCustomFields (ilPropertyFormGUI $form, int $a_obj_id, string $a_type, string $a_mode='user')
 
static setCourseDefinedFieldValues (ilPropertyFormGUI $form, int $a_obj_id, int $a_usr_id=0)
 
static saveCourseDefinedFields (ilPropertyFormGUI $form, int $a_obj_id, int $a_usr_id=0)
 

Protected Member Functions

 showAgreement (?ilPropertyFormGUI $form=null)
 Show agreement form. More...
 
 initFormAgreement ()
 

Protected Attributes

GlobalHttpState $http
 
Factory $refinery
 

Private Member Functions

 save ()
 
 checkAgreement ()
 
 init ()
 
 sendInfoMessage ()
 

Private Attributes

int $ref_id
 
int $obj_id
 
string $type
 
ilCtrlInterface $ctrl
 
ilLanguage $lng
 
ilGlobalTemplateInterface $tpl
 
ilObjUser $user
 
ilPrivacySettings $privacy
 
ilMemberAgreement $agreement
 
bool $required_fullfilled = false
 
bool $agreement_required = false
 

Detailed Description

Author
Stefan Meyer meyer.nosp@m.@lei.nosp@m.fos.c.nosp@m.om @ilCtrl_Calls ilMemberAgreementGUI:

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

Constructor & Destructor Documentation

◆ __construct()

ilMemberAgreementGUI::__construct ( int  $a_ref_id)

Definition at line 47 of file class.ilMemberAgreementGUI.php.

48 {
49 global $DIC;
50
51 $this->http = $DIC->http();
52 $this->refinery = $DIC->refinery();
53
54 $this->ref_id = $a_ref_id;
55 $this->obj_id = ilObject::_lookupObjId($this->ref_id);
56 $this->type = ilObject::_lookupType($this->obj_id);
57 $this->ctrl = $DIC->ctrl();
58 $this->tpl = $DIC->ui()->mainTemplate();
59 $this->lng = $DIC->language();
60 $this->lng->loadLanguageModule('ps');
61 $this->user = $DIC->user();
62
63 $this->privacy = ilPrivacySettings::getInstance();
64 $this->agreement = new ilMemberAgreement($DIC->user()->getId(), $this->obj_id);
65 $this->init();
66 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static _lookupType(int $id, bool $reference=false)
static _lookupObjId(int $ref_id)
global $DIC
Definition: feed.php:28
static http()
Fetches the global http state from ILIAS.

References $DIC, ilObject\_lookupObjId(), ilObject\_lookupType(), ILIAS\Repository\ctrl(), ilPrivacySettings\getInstance(), ILIAS\FileDelivery\http(), init(), ILIAS\Repository\lng(), ILIAS\Repository\refinery(), and ILIAS\Repository\user().

+ Here is the call graph for this function:

Member Function Documentation

◆ addAgreement()

static ilMemberAgreementGUI::addAgreement ( ilPropertyFormGUI  $form,
int  $a_obj_id,
string  $a_type 
)
static

Definition at line 153 of file class.ilMemberAgreementGUI.php.

154 {
155 global $DIC;
156
157 $lng = $DIC['lng'];
158
159 $agreement = new ilCheckboxInputGUI($lng->txt($a_type . '_agree'), 'agreement');
160 $agreement->setRequired(true);
161 $agreement->setOptionTitle($lng->txt($a_type . '_info_agree'));
162 $agreement->setValue('1');
163 $form->addItem($agreement);
164
165 return $form;
166 }
This class represents a checkbox property in a property 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...
This class represents a property form user interface.

References $DIC, $lng, and ilPropertyFormGUI\addItem().

Referenced by ilRegistrationGUI\fillAgreement(), and initFormAgreement().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ addCustomFields()

static ilMemberAgreementGUI::addCustomFields ( ilPropertyFormGUI  $form,
int  $a_obj_id,
string  $a_type,
string  $a_mode = 'user' 
)
static

Definition at line 168 of file class.ilMemberAgreementGUI.php.

174 global $DIC;
175
176 $lng = $DIC['lng'];
177
178 if (!count($cdf_fields = ilCourseDefinedFieldDefinition::_getFields($a_obj_id))) {
179 return $form;
180 }
181
182 if ($a_mode === 'user') {
183 $cdf = new ilNonEditableValueGUI($lng->txt('ps_' . $a_type . '_user_fields'));
184 $cdf->setValue($lng->txt($a_type . '_ps_cdf_info'));
185 $cdf->setRequired(true);
186 }
187
188 foreach ($cdf_fields as $field_obj) {
189 switch ($field_obj->getType()) {
191
192 if ($field_obj->getValueOptions()) {
193 // Show as radio group
194 $option_radios = new ilRadioGroupInputGUI($field_obj->getName(), 'cdf_' . $field_obj->getId());
195 if ($field_obj->isRequired()) {
196 $option_radios->setRequired(true);
197 }
198
199 $open_answer_indexes = $field_obj->getValueOptions();
200 foreach ($field_obj->getValues() as $key => $val) {
201 $option_radio = new ilRadioOption($val, $field_obj->getId() . '_' . $key);
202
203 // open answers
204 if (in_array($key, $open_answer_indexes)) {
205 $open_answer = new ilTextInputGUI(
206 $lng->txt("form_open_answer"),
207 'cdf_oa_' . $field_obj->getId() . '_' . $key
208 );
209 $open_answer->setRequired(true);
210 $option_radio->addSubItem($open_answer);
211 }
212
213 $option_radios->addOption($option_radio);
214 }
215 if ($a_mode === 'user') {
216 $cdf->addSubItem($option_radios);
217 } else {
218 $form->addItem($option_radios);
219 }
220 } else {
221 $select = new ilSelectInputGUI($field_obj->getName(), 'cdf_' . $field_obj->getId());
222 $select->setOptions($field_obj->prepareSelectBox());
223 if ($field_obj->isRequired()) {
224 $select->setRequired(true);
225 }
226 if ($a_mode === 'user') {
227 $cdf->addSubItem($select);
228 } else {
229 $form->addItem($select);
230 }
231 }
232 break;
233
235 $text = new ilTextInputGUI($field_obj->getName(), 'cdf_' . $field_obj->getId());
236 $text->setSize(32);
237 $text->setMaxLength(255);
238 if ($field_obj->isRequired()) {
239 $text->setRequired(true);
240 }
241 if ($a_mode === 'user') {
242 $cdf->addSubItem($text);
243 } else {
244 $form->addItem($text);
245 }
246 break;
247 }
248 }
249 if ($a_mode === 'user') {
250 $form->addItem($cdf);
251 }
252 return $form;
253 }
static _getFields(int $a_container_id, $a_sort=self::IL_CDF_SORT_NAME)
Get all fields of a container.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This class represents a property in a property form.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This class represents a selection list property in a property form.
This class represents a text property in a property form.
string $key
Consumer key/client ID value.
Definition: System.php:193

Referenced by ilRegistrationGUI\fillAgreement(), initFormAgreement(), and ilObjectCustomUserFieldsGUI\initMemberForm().

+ Here is the caller graph for this function:

◆ addExportFieldInfo()

static ilMemberAgreementGUI::addExportFieldInfo ( ilPropertyFormGUI  $form,
int  $a_obj_id,
string  $a_type 
)
static

Definition at line 121 of file class.ilMemberAgreementGUI.php.

126 global $DIC;
127
128 $lng = $DIC->language();
129
131
132 $fields = new ilCustomInputGUI($lng->txt($a_type . '_user_agreement'), '');
133 $tpl = new ilTemplate('tpl.agreement_form.html', true, true, 'Services/Membership');
134 $tpl->setVariable('TXT_INFO_AGREEMENT', $lng->txt($a_type . '_info_agreement'));
135 foreach ($fields_info->getExportableFields() as $field) {
136 $tpl->setCurrentBlock('field_item');
137 $tpl->setVariable('FIELD_NAME', $lng->txt($field));
139 }
140
141 // #17609 - not part of ilExportFieldsInfo::getExportableFields()
142 // see ilExportFieldsInfo::getSelectableFieldsInfo()
143 foreach (ilUserDefinedFields::_getInstance()->getExportableFields($a_obj_id) as $field) {
144 $tpl->setCurrentBlock('field_item');
145 $tpl->setVariable('FIELD_NAME', $field['field_name']);
147 }
148 $fields->setHtml($tpl->get());
149 $form->addItem($fields);
150 return $form;
151 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static _getInstanceByType(string $a_type)
Get Singleton Instance.
ilGlobalTemplateInterface $tpl
special template class to simplify handling of ITX/PEAR
setCurrentBlock(string $part=self::DEFAULT_BLOCK)
Sets the template to the given block.
parseCurrentBlock(string $block_name=self::DEFAULT_BLOCK)
Parses the given block.
setVariable(string $variable, $value='')
Sets the given variable to the given value.
get(string $part=self::DEFAULT_BLOCK)
Renders the given block and returns the html string.

Referenced by ilRegistrationGUI\fillAgreement(), and initFormAgreement().

+ Here is the caller graph for this function:

◆ checkAgreement()

ilMemberAgreementGUI::checkAgreement ( )
private

Definition at line 372 of file class.ilMemberAgreementGUI.php.

372 : bool
373 {
374 $agreement = false;
375 if ($this->http->wrapper()->post()->has('agreement')) {
376 $agreement = $this->http->wrapper()->post()->retrieve(
377 'agreement',
378 $this->refinery->kindlyTo()->bool()
379 );
380 }
381 if ($agreement) {
382 return true;
383 }
384 if ($this->privacy->confirmationRequired($this->type)) {
385 return false;
386 }
387 return true;
388 }

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

+ Here is the call graph for this function:

◆ executeCommand()

ilMemberAgreementGUI::executeCommand ( )

Definition at line 68 of file class.ilMemberAgreementGUI.php.

68 : void
69 {
70 $next_class = $this->ctrl->getNextClass($this);
71 $cmd = $this->ctrl->getCmd();
72
73 switch ($next_class) {
74 default:
75 if (!$cmd || $cmd === 'view') {
76 $cmd = 'showAgreement';
77 }
78 $this->$cmd();
79 break;
80 }
81 }

References ILIAS\Repository\ctrl().

+ Here is the call graph for this function:

◆ getAgreement()

ilMemberAgreementGUI::getAgreement ( )

Definition at line 88 of file class.ilMemberAgreementGUI.php.

89 {
90 return $this->agreement;
91 }

References $agreement.

◆ getPrivacy()

ilMemberAgreementGUI::getPrivacy ( )

Definition at line 83 of file class.ilMemberAgreementGUI.php.

84 {
85 return $this->privacy;
86 }
Singleton class that stores all privacy settings.

References $privacy.

Referenced by initFormAgreement().

+ Here is the caller graph for this function:

◆ init()

ilMemberAgreementGUI::init ( )
private

Definition at line 390 of file class.ilMemberAgreementGUI.php.

390 : void
391 {
392 $this->required_fullfilled = ilCourseUserData::_checkRequired($this->user->getId(), $this->obj_id);
393 $this->agreement_required = $this->getAgreement()->agreementRequired();
394 }
static _checkRequired(int $a_usr_id, int $a_obj_id)

References ilCourseUserData\_checkRequired(), and ILIAS\Repository\user().

Referenced by __construct().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ initFormAgreement()

ilMemberAgreementGUI::initFormAgreement ( )
protected

Definition at line 105 of file class.ilMemberAgreementGUI.php.

106 {
107 $form = new ilPropertyFormGUI();
108 $form->setTitle($this->lng->txt($this->type . '_agreement_header'));
109 $form->setFormAction($this->ctrl->getFormAction($this));
110 $form->addCommandButton('save', $this->lng->txt('save'));
111
112 $form = self::addExportFieldInfo($form, $this->obj_id, $this->type);
113 $form = self::addCustomFields($form, $this->obj_id, $this->type);
114
115 if ($this->getPrivacy()->confirmationRequired($this->type)) {
116 $form = self::addAgreement($form, $this->obj_id, $this->type);
117 }
118 return $form;
119 }
static addCustomFields(ilPropertyFormGUI $form, int $a_obj_id, string $a_type, string $a_mode='user')
static addAgreement(ilPropertyFormGUI $form, int $a_obj_id, string $a_type)
static addExportFieldInfo(ilPropertyFormGUI $form, int $a_obj_id, string $a_type)

References addAgreement(), addCustomFields(), addExportFieldInfo(), ILIAS\Repository\ctrl(), getPrivacy(), and ILIAS\Repository\lng().

Referenced by showAgreement().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ save()

ilMemberAgreementGUI::save ( )
private

Definition at line 255 of file class.ilMemberAgreementGUI.php.

255 : bool
256 {
257 $form = $this->initFormAgreement();
258
259 // #14715 - checkInput() does not work for checkboxes
260 if ($this->checkAgreement() && $form->checkInput()) {
261 self::saveCourseDefinedFields($form, $this->obj_id);
262
263 $this->getAgreement()->setAccepted(true);
264 $this->getAgreement()->setAcceptanceTime(time());
265 $this->getAgreement()->save();
266
267 $history = new ilObjectCustomUserFieldHistory($this->obj_id, $this->user->getId());
268 $history->setUpdateUser($this->user->getId());
269 $history->setEditingTime(new ilDateTime(time(), IL_CAL_UNIX));
270 $history->save();
271
272 $this->ctrl->returnToParent($this);
273 } elseif (!$this->checkAgreement()) {
274 $this->tpl->setOnScreenMessage('failure', $this->lng->txt($this->type . '_agreement_required'));
275 $form->setValuesByPost();
276 $this->showAgreement($form);
277 return false;
278 } else {
279 $this->tpl->setOnScreenMessage('failure', $this->lng->txt('fill_out_all_required_fields'));
280 $form->setValuesByPost();
281 $this->showAgreement($form);
282 return false;
283 }
284 return true;
285 }
const IL_CAL_UNIX
@classDescription Date and time handling
showAgreement(?ilPropertyFormGUI $form=null)
Show agreement form.
static saveCourseDefinedFields(ilPropertyFormGUI $form, int $a_obj_id, int $a_usr_id=0)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...

References ilPropertyFormGUI\checkInput(), ILIAS\Repository\ctrl(), IL_CAL_UNIX, ILIAS\Repository\lng(), ilPropertyFormGUI\setValuesByPost(), and ILIAS\Repository\user().

+ Here is the call graph for this function:

◆ saveCourseDefinedFields()

static ilMemberAgreementGUI::saveCourseDefinedFields ( ilPropertyFormGUI  $form,
int  $a_obj_id,
int  $a_usr_id = 0 
)
static

Definition at line 337 of file class.ilMemberAgreementGUI.php.

337 : void
338 {
339 global $DIC;
340
341 $ilUser = $DIC['ilUser'];
342 if (!$a_usr_id) {
343 $a_usr_id = $ilUser->getId();
344 }
345 foreach (ilCourseDefinedFieldDefinition::_getFields($a_obj_id) as $field_obj) {
346 $value = '';
347 switch ($field_obj->getType()) {
349 // Split value id from post
350 $exp = explode('_', $form->getInput('cdf_' . $field_obj->getId()));
351 $field_id = $exp[0];
352 $option_id = $exp[1] ?? null;
353 $open_answer_indexes = $field_obj->getValueOptions();
354 if (in_array($option_id, $open_answer_indexes)) {
355 $value = $form->getInput('cdf_oa_' . $field_obj->getId() . '_' . $option_id);
356 } else {
357 $value = $field_obj->getValueById((int) $option_id);
358 }
359 break;
360
362 $value = $form->getInput('cdf_' . $field_obj->getId());
363 break;
364 }
365
366 $course_user_data = new ilCourseUserData($a_usr_id, $field_obj->getId());
367 $course_user_data->setValue($value);
368 $course_user_data->update();
369 }
370 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
getInput(string $a_post_var, bool $ensureValidation=true)
Returns the input of an item, if item provides getInput method and as fallback the value of the HTTP-...
$ilUser
Definition: imgupload.php:34

References $DIC, $ilUser, ilCourseDefinedFieldDefinition\_getFields(), ilPropertyFormGUI\getInput(), ilCourseDefinedFieldDefinition\IL_CDF_TYPE_SELECT, and ilCourseDefinedFieldDefinition\IL_CDF_TYPE_TEXT.

Referenced by ilObjectCustomUserFieldsGUI\saveMember().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ sendInfoMessage()

ilMemberAgreementGUI::sendInfoMessage ( )
private

Definition at line 396 of file class.ilMemberAgreementGUI.php.

396 : void
397 {
398 $message = '';
399 if ($this->agreement_required) {
400 $message = $this->lng->txt($this->type . '_ps_agreement_req_info');
401 }
402 if (!$this->required_fullfilled) {
403 if ($message !== '') {
404 $message .= '<br />';
405 }
406 $message .= $this->lng->txt($this->type . '_ps_required_info');
407 }
408 if ($message !== '') {
409 $this->tpl->setOnScreenMessage('failure', $message);
410 }
411 }
$message
Definition: xapiexit.php:32

References $message, and ILIAS\Repository\lng().

+ Here is the call graph for this function:

◆ setCourseDefinedFieldValues()

static ilMemberAgreementGUI::setCourseDefinedFieldValues ( ilPropertyFormGUI  $form,
int  $a_obj_id,
int  $a_usr_id = 0 
)
static

Definition at line 287 of file class.ilMemberAgreementGUI.php.

291 : void {
292 global $DIC;
293
294 $ilUser = $DIC['ilUser'];
295
296 if (!$a_usr_id) {
297 $a_usr_id = $ilUser->getId();
298 }
299
301
302 foreach (ilCourseDefinedFieldDefinition::_getFields($a_obj_id) as $field_obj) {
303 $current_value = (string) ($ud[$a_usr_id][$field_obj->getId()] ?? '');
304 if (!$current_value) {
305 continue;
306 }
307
308 switch ($field_obj->getType()) {
310
311 $id = $field_obj->getIdByValue($current_value);
312
313 if ($id >= 0) {
314 $item = $form->getItemByPostVar('cdf_' . $field_obj->getId());
315 $item->setValue($field_obj->getId() . '_' . $id);
316 } else {
317 // open answer
318 $open_answer_indexes = $field_obj->getValueOptions();
319 $open_answer_index = end($open_answer_indexes);
320 $item = $form->getItemByPostVar('cdf_' . $field_obj->getId());
321 $item->setValue($field_obj->getId() . '_' . $open_answer_index);
322 $item_txt = $form->getItemByPostVar('cdf_oa_' . $field_obj->getId() . '_' . $open_answer_index);
323 if ($item_txt) {
324 $item_txt->setValue($current_value);
325 }
326 }
327 break;
328
330 $item = $form->getItemByPostVar('cdf_' . $field_obj->getId());
331 $item->setValue($current_value);
332 break;
333 }
334 }
335 }
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
static _getValuesByObjId(int $a_obj_id)
getItemByPostVar(string $a_post_var)

References $ilUser.

Referenced by ilObjectCustomUserFieldsGUI\editMember(), and showAgreement().

+ Here is the caller graph for this function:

◆ showAgreement()

ilMemberAgreementGUI::showAgreement ( ?ilPropertyFormGUI  $form = null)
protected

Show agreement form.

Definition at line 96 of file class.ilMemberAgreementGUI.php.

96 : void
97 {
98 if ($form === null) {
99 $form = $this->initFormAgreement();
100 self::setCourseDefinedFieldValues($form, $this->obj_id, $this->user->getId());
101 }
102 $this->tpl->setContent($form->getHTML());
103 }
static setCourseDefinedFieldValues(ilPropertyFormGUI $form, int $a_obj_id, int $a_usr_id=0)

References initFormAgreement(), setCourseDefinedFieldValues(), and ILIAS\Repository\user().

+ Here is the call graph for this function:

Field Documentation

◆ $agreement

ilMemberAgreement ilMemberAgreementGUI::$agreement
private

Definition at line 43 of file class.ilMemberAgreementGUI.php.

Referenced by getAgreement().

◆ $agreement_required

bool ilMemberAgreementGUI::$agreement_required = false
private

Definition at line 45 of file class.ilMemberAgreementGUI.php.

◆ $ctrl

ilCtrlInterface ilMemberAgreementGUI::$ctrl
private

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

◆ $http

GlobalHttpState ilMemberAgreementGUI::$http
protected

Definition at line 36 of file class.ilMemberAgreementGUI.php.

◆ $lng

ilLanguage ilMemberAgreementGUI::$lng
private

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

◆ $obj_id

int ilMemberAgreementGUI::$obj_id
private

Definition at line 34 of file class.ilMemberAgreementGUI.php.

◆ $privacy

ilPrivacySettings ilMemberAgreementGUI::$privacy
private

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

Referenced by getPrivacy().

◆ $ref_id

int ilMemberAgreementGUI::$ref_id
private

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

◆ $refinery

Factory ilMemberAgreementGUI::$refinery
protected

Definition at line 37 of file class.ilMemberAgreementGUI.php.

◆ $required_fullfilled

bool ilMemberAgreementGUI::$required_fullfilled = false
private

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

◆ $tpl

ilGlobalTemplateInterface ilMemberAgreementGUI::$tpl
private

Definition at line 40 of file class.ilMemberAgreementGUI.php.

◆ $type

string ilMemberAgreementGUI::$type
private

Definition at line 35 of file class.ilMemberAgreementGUI.php.

◆ $user

ilObjUser ilMemberAgreementGUI::$user
private

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


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