ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
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 }
static _lookupType(int $id, bool $reference=false)
static _lookupObjId(int $ref_id)
static http()
Fetches the global http state from ILIAS.
global $DIC
Definition: shib_login.php:26

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 155 of file class.ilMemberAgreementGUI.php.

156 {
157 global $DIC;
158
159 $lng = $DIC['lng'];
160
161 $agreement = new ilCheckboxInputGUI($lng->txt($a_type . '_agree'), 'agreement');
162 $agreement->setRequired(true);
163 $agreement->setOptionTitle($lng->txt($a_type . '_info_agree'));
164 $agreement->setValue('1');
165 $form->addItem($agreement);
166
167 return $form;
168 }
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 170 of file class.ilMemberAgreementGUI.php.

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

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 $profile = $DIC['user']->getProfile();
130
131 $type = ilObject::_lookupType($a_obj_id);
133
134 $fields = new ilCustomInputGUI($lng->txt($a_type . '_user_agreement'), '');
135 $tpl = new ilTemplate('tpl.agreement_form.html', true, true, 'components/ILIAS/Membership');
136 $tpl->setVariable('TXT_INFO_AGREEMENT', $lng->txt($a_type . '_info_agreement'));
137 foreach ($fields_info->getExportableFields() as $field) {
138 $tpl->setCurrentBlock('field_item');
139 $tpl->setVariable('FIELD_NAME', $lng->txt($field));
141 }
142
143 // #17609 - not part of ilExportFieldsInfo::getExportableFields()
144 // see ilExportFieldsInfo::getSelectableFieldsInfo()
145 foreach ($profile->getVisibleUserDefinedFields(Context::buildFromObjectType($type)) as $field) {
146 $tpl->setCurrentBlock('field_item');
147 $tpl->setVariable('FIELD_NAME', $field->getLabel($lng));
149 }
150 $fields->setHtml($tpl->get());
151 $form->addItem($fields);
152 return $form;
153 }
This class represents a custom property in a property form.
static _getInstanceByType(string $a_type)
Get Singleton Instance.
ilGlobalTemplateInterface $tpl
special template class to simplify handling of ITX/PEAR
setVariable(string $variable, $value='')
Sets the given variable to the given value.
parseCurrentBlock(string $block_name=self::DEFAULT_BLOCK)
Parses the given block.
setCurrentBlock(string $part=self::DEFAULT_BLOCK)
Sets the template to the given block.
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 374 of file class.ilMemberAgreementGUI.php.

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

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 392 of file class.ilMemberAgreementGUI.php.

392 : void
393 {
394 $this->required_fullfilled = ilCourseUserData::_checkRequired($this->user->getId(), $this->obj_id);
395 $this->agreement_required = $this->getAgreement()->agreementRequired();
396 }
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 257 of file class.ilMemberAgreementGUI.php.

257 : bool
258 {
259 $form = $this->initFormAgreement();
260
261 // #14715 - checkInput() does not work for checkboxes
262 if ($this->checkAgreement() && $form->checkInput()) {
263 self::saveCourseDefinedFields($form, $this->obj_id);
264
265 $this->getAgreement()->setAccepted(true);
266 $this->getAgreement()->setAcceptanceTime(time());
267 $this->getAgreement()->save();
268
269 $history = new ilObjectCustomUserFieldHistory($this->obj_id, $this->user->getId());
270 $history->setUpdateUser($this->user->getId());
271 $history->setEditingTime(new ilDateTime(time(), IL_CAL_UNIX));
272 $history->save();
273
274 $this->ctrl->returnToParent($this);
275 } elseif (!$this->checkAgreement()) {
276 $this->tpl->setOnScreenMessage('failure', $this->lng->txt($this->type . '_agreement_required'));
277 $form->setValuesByPost();
278 $this->showAgreement($form);
279 return false;
280 } else {
281 $this->tpl->setOnScreenMessage('failure', $this->lng->txt('fill_out_all_required_fields'));
282 $form->setValuesByPost();
283 $this->showAgreement($form);
284 return false;
285 }
286 return true;
287 }
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)
Editing history for object custom user fields.

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 339 of file class.ilMemberAgreementGUI.php.

339 : void
340 {
341 global $DIC;
342
343 $ilUser = $DIC['ilUser'];
344 if (!$a_usr_id) {
345 $a_usr_id = $ilUser->getId();
346 }
347 foreach (ilCourseDefinedFieldDefinition::_getFields($a_obj_id) as $field_obj) {
348 $value = '';
349 switch ($field_obj->getType()) {
351 // Split value id from post
352 $exp = explode('_', $form->getInput('cdf_' . $field_obj->getId()));
353 $field_id = $exp[0];
354 $option_id = $exp[1] ?? null;
355 $open_answer_indexes = $field_obj->getValueOptions();
356 if (in_array($option_id, $open_answer_indexes)) {
357 $value = $form->getInput('cdf_oa_' . $field_obj->getId() . '_' . $option_id);
358 } else {
359 $value = $field_obj->getValueById((int) $option_id);
360 }
361 break;
362
364 $value = $form->getInput('cdf_' . $field_obj->getId());
365 break;
366 }
367
368 $course_user_data = new ilCourseUserData($a_usr_id, $field_obj->getId());
369 $course_user_data->setValue($value);
370 $course_user_data->update();
371 }
372 }
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-...

References $DIC, 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 398 of file class.ilMemberAgreementGUI.php.

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

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 289 of file class.ilMemberAgreementGUI.php.

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

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: