ILIAS  release_7 Revision v7.30-3-g800a261c036
ilMemberAgreementGUI Class Reference
+ Collaboration diagram for ilMemberAgreementGUI:

Public Member Functions

 __construct ($a_ref_id)
 Constructor. More...
 
 executeCommand ()
 Execute Command. More...
 
 getPrivacy ()
 Get privycy settings. More...
 
 getAgreement ()
 

Static Public Member Functions

static addExportFieldInfo ($form, $a_obj_id, $a_type)
 Add export field info to form @global type $lng. More...
 
static addAgreement ($form, $a_obj_id, $a_type)
 Add agreement to form. More...
 
static addCustomFields ($form, $a_obj_id, $a_type, $a_mode='user')
 Add custom course fields. More...
 
static setCourseDefinedFieldValues (ilPropertyFormGUI $form, $a_obj_id, $a_usr_id=0)
 
static saveCourseDefinedFields (ilPropertyFormGUI $form, $a_obj_id, $a_usr_id=0)
 Save course defined fields. More...
 

Protected Member Functions

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

Private Member Functions

 save ()
 Save. More...
 
 checkAgreement ()
 Check Agreement. More...
 
 init ()
 Read setting. More...
 
 sendInfoMessage ()
 Send info message. More...
 

Private Attributes

 $ref_id
 
 $obj_id
 
 $type
 
 $db
 
 $ctrl
 
 $lng
 
 $tpl
 
 $privacy
 
 $agreement
 
 $required_fullfilled = false
 
 $agrement_required = false
 

Detailed Description

Author
Stefan Meyer meyer.nosp@m.@lei.nosp@m.fos.c.nosp@m.om
Version
$Id$

@ilCtrl_Calls ilMemberAgreementGUI:

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

Constructor & Destructor Documentation

◆ __construct()

ilMemberAgreementGUI::__construct (   $a_ref_id)

Constructor.

@access public

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

42 {
43 global $DIC;
44
45 $ilDB = $DIC['ilDB'];
46 $ilCtrl = $DIC['ilCtrl'];
47 $lng = $DIC['lng'];
48 $tpl = $DIC['tpl'];
49 $ilUser = $DIC['ilUser'];
50 $ilObjDataCache = $DIC['ilObjDataCache'];
51
52 $this->ref_id = $a_ref_id;
53 $this->obj_id = $ilObjDataCache->lookupObjId($this->ref_id);
54 $this->type = ilObject::_lookupType($this->obj_id);
55 $this->ctrl = $ilCtrl;
56 $this->tpl = $tpl;
57 $this->lng = $lng;
58 $this->lng->loadLanguageModule('ps');
59
60 $this->privacy = ilPrivacySettings::_getInstance();
61 $this->agreement = new ilMemberAgreement($ilUser->getId(), $this->obj_id);
62 $this->init();
63 }
static _lookupType($a_id, $a_reference=false)
lookup object type
static _getInstance()
Get instance of ilPrivacySettings.
global $DIC
Definition: goto.php:24
$ilUser
Definition: imgupload.php:18
global $ilDB

References $DIC, $ilDB, $ilUser, $lng, $tpl, ilPrivacySettings\_getInstance(), ilObject\_lookupType(), and init().

+ Here is the call graph for this function:

Member Function Documentation

◆ addAgreement()

static ilMemberAgreementGUI::addAgreement (   $form,
  $a_obj_id,
  $a_type 
)
static

Add agreement to form.

Parameters
type$form
type$a_obj_id
type$a_type

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

191 {
192 global $DIC;
193
194 $lng = $DIC['lng'];
195
196 $agreement = new ilCheckboxInputGUI($lng->txt($a_type . '_agree'), 'agreement');
197 $agreement->setRequired(true);
198 $agreement->setOptionTitle($lng->txt($a_type . '_info_agree'));
199 $agreement->setValue(1);
200 $form->addItem($agreement);
201
202 return $form;
203 }
This class represents a checkbox property in a property form.

References $agreement, $DIC, and $lng.

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

+ Here is the caller graph for this function:

◆ addCustomFields()

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

Add custom course fields.

Parameters
type$form
type$a_obj_id
type$a_type

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

212 {
213 global $DIC;
214
215 $lng = $DIC['lng'];
216
217 include_once('Modules/Course/classes/Export/class.ilCourseDefinedFieldDefinition.php');
218 include_once('Modules/Course/classes/Export/class.ilCourseUserData.php');
219
220 if (!count($cdf_fields = ilCourseDefinedFieldDefinition::_getFields($a_obj_id))) {
221 return $form;
222 }
223
224 if ($a_mode == 'user') {
225 $cdf = new ilNonEditableValueGUI($lng->txt('ps_' . $a_type . '_user_fields'));
226 $cdf->setValue($lng->txt($a_type . '_ps_cdf_info'));
227 $cdf->setRequired(true);
228 }
229
230 foreach ($cdf_fields as $field_obj) {
231 switch ($field_obj->getType()) {
233
234 if ($field_obj->getValueOptions()) {
235 // Show as radio group
236 $option_radios = new ilRadioGroupInputGUI($field_obj->getName(), 'cdf_' . $field_obj->getId());
237 if ($field_obj->isRequired()) {
238 $option_radios->setRequired(true);
239 }
240
241 $open_answer_indexes = (array) $field_obj->getValueOptions();
242 foreach ($field_obj->getValues() as $key => $val) {
243 $option_radio = new ilRadioOption($val, $field_obj->getId() . '_' . $key);
244
245 // open answers
246 if (in_array($key, $open_answer_indexes)) {
247 $open_answer = new ilTextInputGUI($lng->txt("form_open_answer"), 'cdf_oa_' . $field_obj->getId() . '_' . $key);
248 $open_answer->setRequired(true);
249 $option_radio->addSubItem($open_answer);
250 }
251
252 $option_radios->addOption($option_radio);
253 }
254 if ($a_mode == 'user') {
255 $cdf->addSubItem($option_radios);
256 } else {
257 $form->addItem($option_radios);
258 }
259 } else {
260 $select = new ilSelectInputGUI($field_obj->getName(), 'cdf_' . $field_obj->getId());
261 #$select->setValue(ilUtil::stripSlashes($_POST['cdf'][$field_obj->getId()]));
262 $select->setOptions($field_obj->prepareSelectBox());
263 if ($field_obj->isRequired()) {
264 $select->setRequired(true);
265 }
266 if ($a_mode == 'user') {
267 $cdf->addSubItem($select);
268 } else {
269 $form->addItem($select);
270 }
271 }
272 break;
273
274 case IL_CDF_TYPE_TEXT:
275 $text = new ilTextInputGUI($field_obj->getName(), 'cdf_' . $field_obj->getId());
276 #$text->setValue(ilUtil::stripSlashes($_POST['cdf'][$field_obj->getId()]));
277 $text->setSize(32);
278 $text->setMaxLength(255);
279 if ($field_obj->isRequired()) {
280 $text->setRequired(true);
281 }
282 if ($a_mode == 'user') {
283 $cdf->addSubItem($text);
284 } else {
285 $form->addItem($text);
286 }
287 break;
288 }
289 }
290 if ($a_mode == 'user') {
291 $form->addItem($cdf);
292 }
293 return $form;
294 }
static _getFields($a_container_id, $a_sort=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.

References $DIC, $lng, ilCourseDefinedFieldDefinition\_getFields(), IL_CDF_TYPE_SELECT, and IL_CDF_TYPE_TEXT.

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

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

◆ addExportFieldInfo()

static ilMemberAgreementGUI::addExportFieldInfo (   $form,
  $a_obj_id,
  $a_type 
)
static

Add export field info to form @global type $lng.

Parameters
type$form
type$a_obj_id
type$a_type
Returns
type

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

152 {
153 global $DIC;
154
155 $lng = $DIC['lng'];
156
157 include_once('Services/PrivacySecurity/classes/class.ilExportFieldsInfo.php');
159
160 $fields = new ilCustomInputGUI($lng->txt($a_type . '_user_agreement'), '');
161 $tpl = new ilTemplate('tpl.agreement_form.html', true, true, 'Services/Membership');
162 $tpl->setVariable('TXT_INFO_AGREEMENT', $lng->txt($a_type . '_info_agreement'));
163 foreach ($fields_info->getExportableFields() as $field) {
164 $tpl->setCurrentBlock('field_item');
165 $tpl->setVariable('FIELD_NAME', $lng->txt($field));
166 $tpl->parseCurrentBlock();
167 }
168
169 // #17609 - not part of ilExportFieldsInfo::getExportableFields()
170 // see ilExportFieldsInfo::getSelectableFieldsInfo()
171 include_once('Services/User/classes/class.ilUserDefinedFields.php');
172 foreach (ilUserDefinedFields::_getInstance()->getExportableFields($a_obj_id) as $field) {
173 $tpl->setCurrentBlock('field_item');
174 $tpl->setVariable('FIELD_NAME', $field['field_name']);
175 $tpl->parseCurrentBlock();
176 }
177
178 $fields->setHtml($tpl->get());
179 $form->addItem($fields);
180
181 return $form;
182 }
This class represents a custom property in a property form.
static _getInstanceByType($a_type)
Get Singleton Instance.
special template class to simplify handling of ITX/PEAR
static _getInstance()
Get instance.

References $DIC, $lng, $tpl, ilUserDefinedFields\_getInstance(), ilExportFieldsInfo\_getInstanceByType(), and ilObject\_lookupType().

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

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

◆ checkAgreement()

ilMemberAgreementGUI::checkAgreement ( )
private

Check Agreement.

@access private

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

436 {
437 global $DIC;
438
439 $ilUser = $DIC['ilUser'];
440
441 if ($_POST['agreement']) {
442 return true;
443 }
444 if ($this->privacy->confirmationRequired($this->type)) {
445 return false;
446 }
447 return true;
448 }
$_POST["username"]

References $_POST, $DIC, and $ilUser.

Referenced by save().

+ Here is the caller graph for this function:

◆ executeCommand()

ilMemberAgreementGUI::executeCommand ( )

Execute Command.

@access public

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

72 {
73 $next_class = $this->ctrl->getNextClass($this);
74 $cmd = $this->ctrl->getCmd();
75
76 switch ($next_class) {
77 default:
78 if (!$cmd or $cmd == 'view') {
79 $cmd = 'showAgreement';
80 }
81 $this->$cmd();
82 break;
83 }
84 }

◆ getAgreement()

ilMemberAgreementGUI::getAgreement ( )
Returns
ilMemberAgreement

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

99 {
100 return $this->agreement;
101 }

References $agreement.

Referenced by init(), and save().

+ Here is the caller graph for this function:

◆ getPrivacy()

ilMemberAgreementGUI::getPrivacy ( )

Get privycy settings.

Returns
ilPrivacySettings

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

References $privacy.

Referenced by initFormAgreement().

+ Here is the caller graph for this function:

◆ init()

ilMemberAgreementGUI::init ( )
private

Read setting.

@access private

Returns
void

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

459 {
460 global $DIC;
461
462 $ilUser = $DIC['ilUser'];
463
464 $this->required_fullfilled = ilCourseUserData::_checkRequired($ilUser->getId(), $this->obj_id);
465 $this->agreement_required = $this->getAgreement()->agreementRequired();
466 }
static _checkRequired($a_usr_id, $a_obj_id)
Check required fields.

References $DIC, $ilUser, ilCourseUserData\_checkRequired(), and getAgreement().

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

126 {
127 include_once './Services/Form/classes/class.ilPropertyFormGUI.php';
128 $form = new ilPropertyFormGUI();
129 $form->setTitle($this->lng->txt($this->type . '_agreement_header'));
130 $form->setFormAction($GLOBALS['DIC']['ilCtrl']->getFormAction($this));
131 $form->addCommandButton('save', $this->lng->txt('save'));
132
133 $form = self::addExportFieldInfo($form, $this->obj_id, $this->type);
134 $form = self::addCustomFields($form, $this->obj_id, $this->type);
135
136 if ($this->getPrivacy()->confirmationRequired($this->type)) {
137 $form = self::addAgreement($form, $this->obj_id, $this->type);
138 }
139
140 return $form;
141 }
if(!defined('PATH_SEPARATOR')) $GLOBALS['_PEAR_default_error_mode']
Definition: PEAR.php:64
static addExportFieldInfo($form, $a_obj_id, $a_type)
Add export field info to form @global type $lng.
static addCustomFields($form, $a_obj_id, $a_type, $a_mode='user')
Add custom course fields.
static addAgreement($form, $a_obj_id, $a_type)
Add agreement to form.
getPrivacy()
Get privycy settings.
This class represents a property form user interface.

References $GLOBALS, addAgreement(), addCustomFields(), addExportFieldInfo(), and getPrivacy().

Referenced by save(), and showAgreement().

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

◆ save()

ilMemberAgreementGUI::save ( )
private

Save.

@access private

Parameters

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

306 {
307 global $DIC;
308
309 $ilUser = $DIC['ilUser'];
310
311 $form = $this->initFormAgreement();
312
313 // #14715 - checkInput() does not work for checkboxes
314 if ($this->checkAgreement() && $form->checkInput()) {
315 self::saveCourseDefinedFields($form, $this->obj_id);
316
317 $this->getAgreement()->setAccepted(true);
318 $this->getAgreement()->setAcceptanceTime(time());
319 $this->getAgreement()->save();
320
321 include_once './Services/Membership/classes/class.ilObjectCustomUserFieldHistory.php';
322 $history = new ilObjectCustomUserFieldHistory($this->obj_id, $ilUser->getId());
323 $history->setUpdateUser($ilUser->getId());
324 $history->setEditingTime(new ilDateTime(time(), IL_CAL_UNIX));
325 $history->save();
326
327 $this->ctrl->returnToParent($this);
328 } elseif (!$this->checkAgreement()) {
329 ilUtil::sendFailure($this->lng->txt($this->type . '_agreement_required'));
330 $form->setValuesByPost();
331 $this->showAgreement($form);
332 return false;
333 } else {
334 ilUtil::sendFailure($this->lng->txt('fill_out_all_required_fields'));
335 $form->setValuesByPost();
336 $this->showAgreement($form);
337 return false;
338 }
339 }
const IL_CAL_UNIX
@classDescription Date and time handling
showAgreement(ilPropertyFormGUI $form=null)
Show agreement form.
static saveCourseDefinedFields(ilPropertyFormGUI $form, $a_obj_id, $a_usr_id=0)
Save course defined fields.
Editing history for object custom user fields.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.

References $DIC, $ilUser, checkAgreement(), getAgreement(), IL_CAL_UNIX, initFormAgreement(), saveCourseDefinedFields(), ilUtil\sendFailure(), and showAgreement().

+ Here is the call graph for this function:

◆ saveCourseDefinedFields()

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

Save course defined fields.

Parameters
ilPropertyFormGUI$form

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

394 {
395 global $DIC;
396
397 $ilUser = $DIC['ilUser'];
398
399 if (!$a_usr_id) {
400 $a_usr_id = $ilUser->getId();
401 }
402
403 foreach (ilCourseDefinedFieldDefinition::_getFields($a_obj_id) as $field_obj) {
404 switch ($field_obj->getType()) {
406
407 // Split value id from post
408 list($field_id, $option_id) = explode('_', $form->getInput('cdf_' . $field_obj->getId()));
409 $open_answer_indexes = (array) $field_obj->getValueOptions();
410 if (in_array($option_id, $open_answer_indexes)) {
411 $value = $form->getInput('cdf_oa_' . $field_obj->getId() . '_' . $option_id);
412 } else {
413 $value = $field_obj->getValueById($option_id);
414 }
415 break;
416
417 case IL_CDF_TYPE_TEXT:
418 $value = $form->getInput('cdf_' . $field_obj->getId());
419 break;
420 }
421
422 $course_user_data = new ilCourseUserData($a_usr_id, $field_obj->getId());
423 $course_user_data->setValue($value);
424 $course_user_data->update();
425 }
426 }
getInput($a_post_var, $ensureValidation=true)
Returns the value of a HTTP-POST variable, identified by the passed id.

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

Referenced by save(), and ilObjectCustomUserFieldsGUI\saveMember().

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

◆ sendInfoMessage()

ilMemberAgreementGUI::sendInfoMessage ( )
private

Send info message.

@access private

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

474 {
475 $message = '';
476 if ($this->agreement_required) {
477 $message = $this->lng->txt($this->type . '_ps_agreement_req_info');
478 }
479 if (!$this->required_fullfilled) {
480 if (strlen($message)) {
481 $message .= '<br />';
482 }
483 $message .= $this->lng->txt($this->type . '_ps_required_info');
484 }
485
486 if (strlen($message)) {
488 }
489 }
$message
Definition: xapiexit.php:14

References $message, and ilUtil\sendFailure().

+ Here is the call graph for this function:

◆ setCourseDefinedFieldValues()

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

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

342 {
343 global $DIC;
344
345 $ilUser = $DIC['ilUser'];
346
347 if (!$a_usr_id) {
348 $a_usr_id = $ilUser->getId();
349 }
350
352
353 foreach (ilCourseDefinedFieldDefinition::_getFields($a_obj_id) as $field_obj) {
354 $current_value = $ud[$a_usr_id][$field_obj->getId()];
355 if (!$current_value) {
356 continue;
357 }
358
359 switch ($field_obj->getType()) {
361
362 $id = $field_obj->getIdByValue($current_value);
363
364 if ($id >= 0) {
365 $item = $form->getItemByPostVar('cdf_' . $field_obj->getId());
366 $item->setValue($field_obj->getId() . '_' . $id);
367 } else {
368 // open answer
369 $open_answer_indexes = $field_obj->getValueOptions();
370 $open_answer_index = end($open_answer_indexes);
371 $item = $form->getItemByPostVar('cdf_' . $field_obj->getId());
372 $item->setValue($field_obj->getId() . '_' . $open_answer_index);
373 $item_txt = $form->getItemByPostVar('cdf_oa_' . $field_obj->getId() . '_' . $open_answer_index);
374 if ($item_txt) {
375 $item_txt->setValue($current_value);
376 }
377 }
378 break;
379
380 case IL_CDF_TYPE_TEXT:
381 $item = $form->getItemByPostVar('cdf_' . $field_obj->getId());
382 $item->setValue($current_value);
383 break;
384 }
385 }
386 }
static _getValuesByObjId($a_obj_id)
Get values by obj_id (for all users)
getItemByPostVar($a_post_var)
Get Item by POST variable.

References $DIC, $ilUser, ilCourseDefinedFieldDefinition\_getFields(), ilCourseUserData\_getValuesByObjId(), ilPropertyFormGUI\getItemByPostVar(), IL_CDF_TYPE_SELECT, and IL_CDF_TYPE_TEXT.

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

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

◆ showAgreement()

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

Show agreement form.

Parameters
ilPropertyFormGUI$form
Returns
bool

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

109 {
110 global $DIC;
111
112 $ilUser = $DIC['ilUser'];
113
114 if (!$form instanceof ilPropertyFormGUI) {
115 $form = $this->initFormAgreement($form);
116 self::setCourseDefinedFieldValues($form, $this->obj_id, $ilUser->getId());
117 }
118
119 $this->tpl->setContent($form->getHTML());
120 return true;
121 }
static setCourseDefinedFieldValues(ilPropertyFormGUI $form, $a_obj_id, $a_usr_id=0)

References $DIC, $ilUser, initFormAgreement(), and setCourseDefinedFieldValues().

Referenced by save().

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

Field Documentation

◆ $agreement

ilMemberAgreementGUI::$agreement
private

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

Referenced by addAgreement(), and getAgreement().

◆ $agrement_required

ilMemberAgreementGUI::$agrement_required = false
private

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

◆ $ctrl

ilMemberAgreementGUI::$ctrl
private

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

◆ $db

ilMemberAgreementGUI::$db
private

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

◆ $lng

ilMemberAgreementGUI::$lng
private

◆ $obj_id

ilMemberAgreementGUI::$obj_id
private

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

◆ $privacy

ilMemberAgreementGUI::$privacy
private

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

Referenced by getPrivacy().

◆ $ref_id

ilMemberAgreementGUI::$ref_id
private

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

◆ $required_fullfilled

ilMemberAgreementGUI::$required_fullfilled = false
private

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

◆ $tpl

ilMemberAgreementGUI::$tpl
private

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

Referenced by __construct(), and addExportFieldInfo().

◆ $type

ilMemberAgreementGUI::$type
private

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


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