ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f870
All Data Structures Namespaces Files Functions Variables Modules Pages
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
static _lookupType($a_id, $a_reference=false)
lookup object type
global $ilUser
Definition: imgupload.php:15
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 171 of file class.ilMemberAgreementGUI.php.

References $agreement, and $lng.

Referenced by ilRegistrationGUI\fillAgreement().

172  {
173  global $lng;
174 
175  $agreement = new ilCheckboxInputGUI($lng->txt($a_type.'_agree'),'agreement');
176  $agreement->setRequired(true);
177  $agreement->setOptionTitle($lng->txt($a_type.'_info_agree'));
178  $agreement->setValue(1);
179  $form->addItem($agreement);
180 
181  return $form;
182  }
This class represents a checkbox property in a property 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 190 of file class.ilMemberAgreementGUI.php.

References $lng, ilCourseDefinedFieldDefinition\_getFields(), IL_CDF_TYPE_SELECT, IL_CDF_TYPE_TEXT, ilSelectInputGUI\setOptions(), ilFormPropertyGUI\setRequired(), ilTextInputGUI\setSize(), and ilNonEditableValueGUI\setValue().

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

191  {
192  global $lng;
193 
194  include_once('Modules/Course/classes/Export/class.ilCourseDefinedFieldDefinition.php');
195  include_once('Modules/Course/classes/Export/class.ilCourseUserData.php');
196 
197  if(!count($cdf_fields = ilCourseDefinedFieldDefinition::_getFields($a_obj_id)))
198  {
199  return $form;
200  }
201 
202  if($a_mode == 'user')
203  {
204  $cdf = new ilNonEditableValueGUI($lng->txt('ps_'.$a_type.'_user_fields'));
205  $cdf->setValue($lng->txt($a_type.'_ps_cdf_info'));
206  $cdf->setRequired(true);
207  }
208 
209  foreach($cdf_fields as $field_obj)
210  {
211  switch($field_obj->getType())
212  {
213  case IL_CDF_TYPE_SELECT:
214 
215  if($field_obj->getValueOptions())
216  {
217  // Show as radio group
218  $option_radios = new ilRadioGroupInputGUI($field_obj->getName(), 'cdf_'.$field_obj->getId());
219  if($field_obj->isRequired())
220  {
221  $option_radios->setRequired(true);
222  }
223 
224  $open_answer_indexes = (array) $field_obj->getValueOptions();
225  foreach($field_obj->getValues() as $key => $val)
226  {
227  $option_radio = new ilRadioOption($val,$field_obj->getId().'_'.$key);
228 
229  // open answers
230  if(in_array($key, $open_answer_indexes))
231  {
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  {
241  $cdf->addSubItem($option_radios);
242  }
243  else
244  {
245  $form->addItem($option_radios);
246  }
247  }
248  else
249  {
250  $select = new ilSelectInputGUI($field_obj->getName(),'cdf_'.$field_obj->getId());
251  #$select->setValue(ilUtil::stripSlashes($_POST['cdf'][$field_obj->getId()]));
252  $select->setOptions($field_obj->prepareSelectBox());
253  if($field_obj->isRequired())
254  {
255  $select->setRequired(true);
256  }
257  if($a_mode == 'user')
258  {
259  $cdf->addSubItem($select);
260  }
261  else
262  {
263  $form->addItem($select);
264  }
265  }
266  break;
267 
268  case IL_CDF_TYPE_TEXT:
269  $text = new ilTextInputGUI($field_obj->getName(),'cdf_'.$field_obj->getId());
270  #$text->setValue(ilUtil::stripSlashes($_POST['cdf'][$field_obj->getId()]));
271  $text->setSize(32);
272  $text->setMaxLength(255);
273  if($field_obj->isRequired())
274  {
275  $text->setRequired(true);
276  }
277  if($a_mode == 'user')
278  {
279  $cdf->addSubItem($text);
280  }
281  else
282  {
283  $form->addItem($text);
284  }
285  break;
286  }
287  }
288  if($a_mode == 'user')
289  {
290  $form->addItem($cdf);
291  }
292  return $form;
293 
294  }
This class represents an option in a radio group.
This class represents a selection list property in a property form.
This class represents a property in a property form.
setSize($a_size)
Set Size.
This class represents a text property in a property form.
setOptions($a_options)
Set Options.
This class represents a non editable value in a property form.
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 143 of file class.ilMemberAgreementGUI.php.

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

Referenced by ilRegistrationGUI\fillAgreement().

144  {
145  global $lng;
146 
147  include_once('Services/PrivacySecurity/classes/class.ilExportFieldsInfo.php');
149 
150  $fields = new ilCustomInputGUI($lng->txt($a_type.'_user_agreement'),'');
151  $tpl = new ilTemplate('tpl.agreement_form.html',true,true,'Services/Membership');
152  $tpl->setVariable('TXT_INFO_AGREEMENT',$lng->txt($a_type.'_info_agreement'));
153  foreach($fields_info->getExportableFields() as $field)
154  {
155  $tpl->setCurrentBlock('field_item');
156  $tpl->setVariable('FIELD_NAME',$lng->txt($field));
157  $tpl->parseCurrentBlock();
158  }
159  $fields->setHtml($tpl->get());
160  $form->addItem($fields);
161 
162  return $form;
163  }
setHtml($a_html)
Set Html.
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 449 of file class.ilMemberAgreementGUI.php.

References $_POST, and $ilUser.

Referenced by save().

450  {
451  global $ilUser;
452 
453  if($_POST['agreement'])
454  {
455  return true;
456  }
457  if($this->privacy->confirmationRequired($this->type))
458  {
459  return false;
460  }
461  return true;
462  }
$_POST['username']
Definition: cron.php:12
global $ilUser
Definition: imgupload.php:15
+ Here is the caller graph for this function:

◆ executeCommand()

ilMemberAgreementGUI::executeCommand ( )

Execute Command.

public

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

References $cmd.

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

◆ getAgreement()

ilMemberAgreementGUI::getAgreement ( )
Returns
ilMemberAgreement

Definition at line 93 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 85 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 472 of file class.ilMemberAgreementGUI.php.

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

Referenced by __construct().

473  {
474  global $ilUser;
475 
476  $this->required_fullfilled = ilCourseUserData::_checkRequired($ilUser->getId(),$this->obj_id);
477  $this->agreement_required = $this->getAgreement()->agreementRequired();
478  }
static _checkRequired($a_usr_id, $a_obj_id)
Check required fields.
global $ilUser
Definition: imgupload.php:15
+ 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 $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  {
129  $form = self::addAgreement($form, $this->obj_id, $this->type);
130  }
131 
132  return $form;
133  }
This class represents a property form user interface.
$GLOBALS['ct_recipient']
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 305 of file class.ilMemberAgreementGUI.php.

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

306  {
307  global $ilUser;
308 
309  $form = $this->initFormAgreement();
310 
311  // #14715 - checkInput() does not work for checkboxes
312  if($this->checkAgreement() &&
313  $form->checkInput())
314  {
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  }
329  elseif(!$this->checkAgreement())
330  {
331  ilUtil::sendFailure($this->lng->txt($this->type.'_agreement_required'));
332  $form->setValuesByPost();
333  $this->showAgreement($form);
334  return false;
335  }
336  else
337  {
338  ilUtil::sendFailure($this->lng->txt('fill_out_all_required_fields'));
339  $form->setValuesByPost();
340  $this->showAgreement($form);
341  return false;
342  }
343  }
Editing history for object custom user fields.
const IL_CAL_UNIX
Date and time handling
showAgreement(ilPropertyFormGUI $form=null)
Show agreement form.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
global $ilUser
Definition: imgupload.php:15
+ 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 403 of file class.ilMemberAgreementGUI.php.

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

Referenced by ilObjectCustomUserFieldsGUI\saveMember().

404  {
405  global $ilUser;
406 
407  if(!$a_usr_id)
408  {
409  $a_usr_id = $ilUser->getId();
410  }
411 
412  foreach(ilCourseDefinedFieldDefinition::_getFields($a_obj_id) as $field_obj)
413  {
414  switch($field_obj->getType())
415  {
416  case IL_CDF_TYPE_SELECT:
417 
418  // Split value id from post
419  list($field_id,$option_id) = explode('_', $form->getInput('cdf_'.$field_obj->getId()));
420  $open_answer_indexes = (array) $field_obj->getValueOptions();
421  if(in_array($option_id, $open_answer_indexes))
422  {
423  $value = $form->getInput('cdf_oa_'.$field_obj->getId().'_'.$option_id);
424  }
425  else
426  {
427  $value = $field_obj->getValueById($option_id);
428  }
429  break;
430 
431  case IL_CDF_TYPE_TEXT:
432  $value = $form->getInput('cdf_'.$field_obj->getId());
433  break;
434  }
435 
436  $course_user_data = new ilCourseUserData($a_usr_id,$field_obj->getId());
437  $course_user_data->setValue($value);
438  $course_user_data->update();
439  }
440  }
getInput($a_post_var, $ensureValidation=true)
Returns the value of a HTTP-POST variable, identified by the passed id.
global $ilUser
Definition: imgupload.php:15
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 485 of file class.ilMemberAgreementGUI.php.

References ilUtil\sendFailure().

486  {
487  $message = '';
488  if($this->agreement_required)
489  {
490  $message = $this->lng->txt($this->type.'_ps_agreement_req_info');
491  }
492  if(!$this->required_fullfilled)
493  {
494  if(strlen($message))
495  {
496  $message .= '<br />';
497  }
498  $message .= $this->lng->txt($this->type.'_ps_required_info');
499  }
500 
501  if(strlen($message))
502  {
503  ilUtil::sendFailure($message);
504  }
505  }
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 345 of file class.ilMemberAgreementGUI.php.

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

Referenced by ilObjectCustomUserFieldsGUI\editMember().

346  {
347  global $ilUser;
348 
349  if(!$a_usr_id)
350  {
351  $a_usr_id = $ilUser->getId();
352  }
353 
354  $ud = ilCourseUserData::_getValuesByObjId($a_obj_id);
355 
356  foreach(ilCourseDefinedFieldDefinition::_getFields($a_obj_id) as $field_obj)
357  {
358  $current_value = $ud[$a_usr_id][$field_obj->getId()];
359  if(!$current_value)
360  {
361  continue;
362  }
363 
364  switch($field_obj->getType())
365  {
366  case IL_CDF_TYPE_SELECT:
367 
368  $id = $field_obj->getIdByValue($current_value);
369 
370  if($id >= 0)
371  {
372  $item = $form->getItemByPostVar('cdf_'.$field_obj->getId());
373  $item->setValue($field_obj->getId().'_'.$id);
374  }
375  else
376  {
377  // open answer
378  $open_answer_indexes = $field_obj->getValueOptions();
379  $open_answer_index = end($open_answer_indexes);
380  $item = $form->getItemByPostVar('cdf_'.$field_obj->getId());
381  $item->setValue($field_obj->getId().'_'.$open_answer_index);
382  $item_txt = $form->getItemByPostVar('cdf_oa_'.$field_obj->getId().'_'.$open_answer_index);
383  if($item_txt)
384  {
385  $item_txt->setValue($current_value);
386  }
387  }
388  break;
389 
390  case IL_CDF_TYPE_TEXT:
391  $item = $form->getItemByPostVar('cdf_'.$field_obj->getId());
392  $item->setValue($current_value);
393  break;
394  }
395  }
396  }
getItemByPostVar($a_post_var)
Get Item by POST variable.
static _getValuesByObjId($a_obj_id)
Get values by obj_id (for all users)
global $ilUser
Definition: imgupload.php:15
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 103 of file class.ilMemberAgreementGUI.php.

References $ilUser, and initFormAgreement().

Referenced by save().

104  {
105  global $ilUser;
106 
107  $form = $this->initFormAgreement($form);
108  self::setCourseDefinedFieldValues($form, $this->obj_id, $ilUser->getId());
109 
110  $this->tpl->setContent($form->getHTML());
111  return true;
112  }
getId()
Get Id.
global $ilUser
Definition: imgupload.php:15
+ 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: