ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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 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$

ilMemberAgreementGUI:

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

Constructor & Destructor Documentation

◆ __construct()

ilMemberAgreementGUI::__construct (   $a_ref_id)

Constructor.

public

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

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

42  {
43  global $ilDB,$ilCtrl,$lng,$tpl,$ilUser,$ilObjDataCache;
44 
45  $this->ref_id = $a_ref_id;
46  $this->obj_id = $ilObjDataCache->lookupObjId($this->ref_id);
47  $this->type = ilObject::_lookupType($this->obj_id);
48  $this->ctrl = $ilCtrl;
49  $this->tpl = $tpl;
50  $this->lng = $lng;
51  $this->lng->loadLanguageModule('ps');
52 
53  $this->privacy = ilPrivacySettings::_getInstance();
54  $this->agreement = new ilMemberAgreement($ilUser->getId(), $this->obj_id);
55  $this->init();
56  }
global $ilCtrl
Definition: ilias.php:18
$ilUser
Definition: imgupload.php:18
static _lookupType($a_id, $a_reference=false)
lookup object type
global $ilDB
static _getInstance()
Get instance of ilPrivacySettings.
+ 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 179 of file class.ilMemberAgreementGUI.php.

References $a_type, $agreement, $form, and $lng.

Referenced by ilRegistrationGUI\fillAgreement().

180  {
181  global $lng;
182 
183  $agreement = new ilCheckboxInputGUI($lng->txt($a_type . '_agree'), 'agreement');
184  $agreement->setRequired(true);
185  $agreement->setOptionTitle($lng->txt($a_type . '_info_agree'));
186  $agreement->setValue(1);
187  $form->addItem($agreement);
188 
189  return $form;
190  }
This class represents a checkbox property in a property form.
$a_type
Definition: workflow.php:92
if(isset($_POST['submit'])) $form
+ 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 198 of file class.ilMemberAgreementGUI.php.

References $a_type, $form, $key, $lng, $text, ilCourseDefinedFieldDefinition\_getFields(), array, IL_CDF_TYPE_SELECT, IL_CDF_TYPE_TEXT, ilSelectInputGUI\setOptions(), ilFormPropertyGUI\setRequired(), and ilNonEditableValueGUI\setValue().

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

199  {
200  global $lng;
201 
202  include_once('Modules/Course/classes/Export/class.ilCourseDefinedFieldDefinition.php');
203  include_once('Modules/Course/classes/Export/class.ilCourseUserData.php');
204 
205  if (!count($cdf_fields = ilCourseDefinedFieldDefinition::_getFields($a_obj_id))) {
206  return $form;
207  }
208 
209  if ($a_mode == 'user') {
210  $cdf = new ilNonEditableValueGUI($lng->txt('ps_' . $a_type . '_user_fields'));
211  $cdf->setValue($lng->txt($a_type . '_ps_cdf_info'));
212  $cdf->setRequired(true);
213  }
214 
215  foreach ($cdf_fields as $field_obj) {
216  switch ($field_obj->getType()) {
217  case IL_CDF_TYPE_SELECT:
218 
219  if ($field_obj->getValueOptions()) {
220  // Show as radio group
221  $option_radios = new ilRadioGroupInputGUI($field_obj->getName(), 'cdf_' . $field_obj->getId());
222  if ($field_obj->isRequired()) {
223  $option_radios->setRequired(true);
224  }
225 
226  $open_answer_indexes = (array) $field_obj->getValueOptions();
227  foreach ($field_obj->getValues() as $key => $val) {
228  $option_radio = new ilRadioOption($val, $field_obj->getId() . '_' . $key);
229 
230  // open answers
231  if (in_array($key, $open_answer_indexes)) {
232  $open_answer = new ilTextInputGUI($lng->txt("form_open_answer"), 'cdf_oa_' . $field_obj->getId() . '_' . $key);
233  $open_answer->setRequired(true);
234  $option_radio->addSubItem($open_answer);
235  }
236 
237  $option_radios->addOption($option_radio);
238  }
239  if ($a_mode == 'user') {
240  $cdf->addSubItem($option_radios);
241  } else {
242  $form->addItem($option_radios);
243  }
244  } else {
245  $select = new ilSelectInputGUI($field_obj->getName(), 'cdf_' . $field_obj->getId());
246  #$select->setValue(ilUtil::stripSlashes($_POST['cdf'][$field_obj->getId()]));
247  $select->setOptions($field_obj->prepareSelectBox());
248  if ($field_obj->isRequired()) {
249  $select->setRequired(true);
250  }
251  if ($a_mode == 'user') {
252  $cdf->addSubItem($select);
253  } else {
254  $form->addItem($select);
255  }
256  }
257  break;
258 
259  case IL_CDF_TYPE_TEXT:
260  $text = new ilTextInputGUI($field_obj->getName(), 'cdf_' . $field_obj->getId());
261  #$text->setValue(ilUtil::stripSlashes($_POST['cdf'][$field_obj->getId()]));
262  $text->setSize(32);
263  $text->setMaxLength(255);
264  if ($field_obj->isRequired()) {
265  $text->setRequired(true);
266  }
267  if ($a_mode == 'user') {
268  $cdf->addSubItem($text);
269  } else {
270  $form->addItem($text);
271  }
272  break;
273  }
274  }
275  if ($a_mode == 'user') {
276  $form->addItem($cdf);
277  }
278  return $form;
279  }
This class represents an option in a radio group.
This class represents a selection list property in a property form.
$a_type
Definition: workflow.php:92
This class represents a property in a property form.
if(isset($_POST['submit'])) $form
$text
Definition: errorreport.php:18
This class represents a text property in a property form.
setOptions($a_options)
Set Options.
Create styles array
The data for the language used.
This class represents a non editable value in a property form.
$key
Definition: croninfo.php:18
setRequired($a_required)
Set Required.
static _getFields($a_container_id, $a_sort=IL_CDF_SORT_NAME)
Get all fields of a container.
+ 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 type $lng.

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

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

References $a_type, $form, $lng, $tpl, ilUserDefinedFields\_getInstance(), ilExportFieldsInfo\_getInstanceByType(), ilObject\_lookupType(), and ilCustomInputGUI\setHtml().

Referenced by ilRegistrationGUI\fillAgreement().

143  {
144  global $lng;
145 
146  include_once('Services/PrivacySecurity/classes/class.ilExportFieldsInfo.php');
148 
149  $fields = new ilCustomInputGUI($lng->txt($a_type . '_user_agreement'), '');
150  $tpl = new ilTemplate('tpl.agreement_form.html', true, true, 'Services/Membership');
151  $tpl->setVariable('TXT_INFO_AGREEMENT', $lng->txt($a_type . '_info_agreement'));
152  foreach ($fields_info->getExportableFields() as $field) {
153  $tpl->setCurrentBlock('field_item');
154  $tpl->setVariable('FIELD_NAME', $lng->txt($field));
155  $tpl->parseCurrentBlock();
156  }
157 
158  // #17609 - not part of ilExportFieldsInfo::getExportableFields()
159  // see ilExportFieldsInfo::getSelectableFieldsInfo()
160  include_once('Services/User/classes/class.ilUserDefinedFields.php');
161  foreach (ilUserDefinedFields::_getInstance()->getExportableFields($a_obj_id) as $field) {
162  $tpl->setCurrentBlock('field_item');
163  $tpl->setVariable('FIELD_NAME', $field['field_name']);
164  $tpl->parseCurrentBlock();
165  }
166 
167  $fields->setHtml($tpl->get());
168  $form->addItem($fields);
169 
170  return $form;
171  }
setHtml($a_html)
Set Html.
static _getInstance()
Get instance.
$a_type
Definition: workflow.php:92
if(isset($_POST['submit'])) $form
static _getInstanceByType($a_type)
Get Singleton Instance.
special template class to simplify handling of ITX/PEAR
static _lookupType($a_id, $a_reference=false)
lookup object type
This class represents a custom property in a property form.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ checkAgreement()

ilMemberAgreementGUI::checkAgreement ( )
private

Check Agreement.

private

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

References $_POST, and $ilUser.

Referenced by save().

415  {
416  global $ilUser;
417 
418  if ($_POST['agreement']) {
419  return true;
420  }
421  if ($this->privacy->confirmationRequired($this->type)) {
422  return false;
423  }
424  return true;
425  }
$ilUser
Definition: imgupload.php:18
$_POST["username"]
+ Here is the caller graph for this function:

◆ executeCommand()

ilMemberAgreementGUI::executeCommand ( )

Execute Command.

public

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

65  {
66  $next_class = $this->ctrl->getNextClass($this);
67  $cmd = $this->ctrl->getCmd();
68 
69  switch ($next_class) {
70  default:
71  if (!$cmd or $cmd == 'view') {
72  $cmd = 'showAgreement';
73  }
74  $this->$cmd();
75  break;
76  }
77  }

◆ getAgreement()

ilMemberAgreementGUI::getAgreement ( )
Returns
ilMemberAgreement

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

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

References $privacy.

Referenced by initFormAgreement().

+ Here is the caller graph for this function:

◆ init()

ilMemberAgreementGUI::init ( )
private

Read setting.

private

Returns
void

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

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

Referenced by __construct().

436  {
437  global $ilUser;
438 
439  $this->required_fullfilled = ilCourseUserData::_checkRequired($ilUser->getId(), $this->obj_id);
440  $this->agreement_required = $this->getAgreement()->agreementRequired();
441  }
$ilUser
Definition: imgupload.php:18
static _checkRequired($a_usr_id, $a_obj_id)
Check required fields.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ initFormAgreement()

ilMemberAgreementGUI::initFormAgreement ( )
protected

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

References $form, $GLOBALS, and getPrivacy().

Referenced by save(), and showAgreement().

117  {
118  include_once './Services/Form/classes/class.ilPropertyFormGUI.php';
119  $form = new ilPropertyFormGUI();
120  $form->setTitle($this->lng->txt($this->type . '_agreement_header'));
121  $form->setFormAction($GLOBALS['ilCtrl']->getFormAction($this));
122  $form->addCommandButton('save', $this->lng->txt('save'));
123 
124  $form = self::addExportFieldInfo($form, $this->obj_id, $this->type);
125  $form = self::addCustomFields($form, $this->obj_id, $this->type);
126 
127  if ($this->getPrivacy()->confirmationRequired($this->type)) {
128  $form = self::addAgreement($form, $this->obj_id, $this->type);
129  }
130 
131  return $form;
132  }
This class represents a property form user interface.
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
if(isset($_POST['submit'])) $form
getPrivacy()
Get privycy settings.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ save()

ilMemberAgreementGUI::save ( )
private

Save.

private

Parameters

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

References $form, $ilUser, checkAgreement(), getAgreement(), IL_CAL_UNIX, initFormAgreement(), ilUtil\sendFailure(), ilObjectCustomUserFieldHistory\setUpdateUser(), showAgreement(), and time.

291  {
292  global $ilUser;
293 
294  $form = $this->initFormAgreement();
295 
296  // #14715 - checkInput() does not work for checkboxes
297  if ($this->checkAgreement() && $form->checkInput()) {
298  self::saveCourseDefinedFields($form, $this->obj_id);
299 
300  $this->getAgreement()->setAccepted(true);
301  $this->getAgreement()->setAcceptanceTime(time());
302  $this->getAgreement()->save();
303 
304  include_once './Services/Membership/classes/class.ilObjectCustomUserFieldHistory.php';
305  $history = new ilObjectCustomUserFieldHistory($this->obj_id, $ilUser->getId());
306  $history->setUpdateUser($ilUser->getId());
307  $history->setEditingTime(new ilDateTime(time(), IL_CAL_UNIX));
308  $history->save();
309 
310  $this->ctrl->returnToParent($this);
311  } elseif (!$this->checkAgreement()) {
312  ilUtil::sendFailure($this->lng->txt($this->type . '_agreement_required'));
313  $form->setValuesByPost();
314  $this->showAgreement($form);
315  return false;
316  } else {
317  ilUtil::sendFailure($this->lng->txt('fill_out_all_required_fields'));
318  $form->setValuesByPost();
319  $this->showAgreement($form);
320  return false;
321  }
322  }
Editing history for object custom user fields.
const IL_CAL_UNIX
if(isset($_POST['submit'])) $form
Date and time handling
$ilUser
Definition: imgupload.php:18
showAgreement(ilPropertyFormGUI $form=null)
Show agreement form.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
Add data(end) time
Method that wraps PHPs time in order to allow simulations with the workflow.
+ 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 374 of file class.ilMemberAgreementGUI.php.

References $ilUser, ilCourseDefinedFieldDefinition\_getFields(), array, ilPropertyFormGUI\getInput(), IL_CDF_TYPE_SELECT, IL_CDF_TYPE_TEXT, and ilCourseUserData\setValue().

Referenced by ilObjectCustomUserFieldsGUI\saveMember().

375  {
376  global $ilUser;
377 
378  if (!$a_usr_id) {
379  $a_usr_id = $ilUser->getId();
380  }
381 
382  foreach (ilCourseDefinedFieldDefinition::_getFields($a_obj_id) as $field_obj) {
383  switch ($field_obj->getType()) {
384  case IL_CDF_TYPE_SELECT:
385 
386  // Split value id from post
387  list($field_id, $option_id) = explode('_', $form->getInput('cdf_' . $field_obj->getId()));
388  $open_answer_indexes = (array) $field_obj->getValueOptions();
389  if (in_array($option_id, $open_answer_indexes)) {
390  $value = $form->getInput('cdf_oa_' . $field_obj->getId() . '_' . $option_id);
391  } else {
392  $value = $field_obj->getValueById($option_id);
393  }
394  break;
395 
396  case IL_CDF_TYPE_TEXT:
397  $value = $form->getInput('cdf_' . $field_obj->getId());
398  break;
399  }
400 
401  $course_user_data = new ilCourseUserData($a_usr_id, $field_obj->getId());
402  $course_user_data->setValue($value);
403  $course_user_data->update();
404  }
405  }
$ilUser
Definition: imgupload.php:18
getInput($a_post_var, $ensureValidation=true)
Returns the value of a HTTP-POST variable, identified by the passed id.
Create styles array
The data for the language used.
static _getFields($a_container_id, $a_sort=IL_CDF_SORT_NAME)
Get all fields of a container.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ sendInfoMessage()

ilMemberAgreementGUI::sendInfoMessage ( )
private

Send info message.

private

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

References $message, and ilUtil\sendFailure().

449  {
450  $message = '';
451  if ($this->agreement_required) {
452  $message = $this->lng->txt($this->type . '_ps_agreement_req_info');
453  }
454  if (!$this->required_fullfilled) {
455  if (strlen($message)) {
456  $message .= '<br />';
457  }
458  $message .= $this->lng->txt($this->type . '_ps_required_info');
459  }
460 
461  if (strlen($message)) {
463  }
464  }
catch(Exception $e) $message
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
+ 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 324 of file class.ilMemberAgreementGUI.php.

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

Referenced by ilObjectCustomUserFieldsGUI\editMember().

325  {
326  global $ilUser;
327 
328  if (!$a_usr_id) {
329  $a_usr_id = $ilUser->getId();
330  }
331 
332  $ud = ilCourseUserData::_getValuesByObjId($a_obj_id);
333 
334  foreach (ilCourseDefinedFieldDefinition::_getFields($a_obj_id) as $field_obj) {
335  $current_value = $ud[$a_usr_id][$field_obj->getId()];
336  if (!$current_value) {
337  continue;
338  }
339 
340  switch ($field_obj->getType()) {
341  case IL_CDF_TYPE_SELECT:
342 
343  $id = $field_obj->getIdByValue($current_value);
344 
345  if ($id >= 0) {
346  $item = $form->getItemByPostVar('cdf_' . $field_obj->getId());
347  $item->setValue($field_obj->getId() . '_' . $id);
348  } else {
349  // open answer
350  $open_answer_indexes = $field_obj->getValueOptions();
351  $open_answer_index = end($open_answer_indexes);
352  $item = $form->getItemByPostVar('cdf_' . $field_obj->getId());
353  $item->setValue($field_obj->getId() . '_' . $open_answer_index);
354  $item_txt = $form->getItemByPostVar('cdf_oa_' . $field_obj->getId() . '_' . $open_answer_index);
355  if ($item_txt) {
356  $item_txt->setValue($current_value);
357  }
358  }
359  break;
360 
361  case IL_CDF_TYPE_TEXT:
362  $item = $form->getItemByPostVar('cdf_' . $field_obj->getId());
363  $item->setValue($current_value);
364  break;
365  }
366  }
367  }
getItemByPostVar($a_post_var)
Get Item by POST variable.
static _getValuesByObjId($a_obj_id)
Get values by obj_id (for all users)
if(!array_key_exists('StateId', $_REQUEST)) $id
$ilUser
Definition: imgupload.php:18
static _getFields($a_container_id, $a_sort=IL_CDF_SORT_NAME)
Get all fields of a container.
+ 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 101 of file class.ilMemberAgreementGUI.php.

References $form, $ilUser, and initFormAgreement().

Referenced by save().

102  {
103  global $ilUser;
104 
105  if (!$form instanceof ilPropertyFormGUI) {
106  $form = $this->initFormAgreement($form);
107  self::setCourseDefinedFieldValues($form, $this->obj_id, $ilUser->getId());
108  }
109 
110  $this->tpl->setContent($form->getHTML());
111  return true;
112  }
This class represents a property form user interface.
$ilUser
Definition: imgupload.php:18
getId()
Get Id.
+ 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.

Referenced by __construct(), and init().

◆ $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: