ILIAS  release_4-4 Revision
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)
 Add custom course fields. More...
 
static saveCourseDefinedFields (ilPropertyFormGUI $form, $a_obj_id)
 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, $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
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 168 of file class.ilMemberAgreementGUI.php.

References $agreement, and $lng.

Referenced by ilRegistrationGUI\fillAgreement().

169  {
170  global $lng;
171 
172  $agreement = new ilCheckboxInputGUI($lng->txt($a_type.'_agree'),'agreement');
173  $agreement->setRequired(true);
174  $agreement->setOptionTitle($lng->txt($a_type.'_info_agree'));
175  $agreement->setValue(1);
176  $form->addItem($agreement);
177 
178  return $form;
179  }
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 
)
static

Add custom course fields.

Parameters
type$form
type$a_obj_id
type$a_type

Definition at line 187 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().

188  {
189  global $lng;
190 
191  include_once('Modules/Course/classes/Export/class.ilCourseDefinedFieldDefinition.php');
192  include_once('Modules/Course/classes/Export/class.ilCourseUserData.php');
193 
194  if(!count($cdf_fields = ilCourseDefinedFieldDefinition::_getFields($a_obj_id)))
195  {
196  return $form;
197  }
198 
199  $cdf = new ilNonEditableValueGUI($lng->txt('ps_crs_user_fields'));
200  $cdf->setValue($lng->txt($a_type.'_ps_cdf_info'));
201  $cdf->setRequired(true);
202 
203  foreach($cdf_fields as $field_obj)
204  {
205  switch($field_obj->getType())
206  {
207  case IL_CDF_TYPE_SELECT:
208 
209  if($field_obj->getValueOptions())
210  {
211  // Show as radio group
212  $option_radios = new ilRadioGroupInputGUI($field_obj->getName(), 'cdf_'.$field_obj->getId());
213  if($field_obj->isRequired())
214  {
215  $option_radios->setRequired(true);
216  }
217 
218  $open_answer_indexes = (array) $field_obj->getValueOptions();
219  foreach($field_obj->getValues() as $key => $val)
220  {
221  $option_radio = new ilRadioOption($val,$field_obj->getId().'_'.$key);
222 
223  // open answers
224  if(in_array($key, $open_answer_indexes))
225  {
226  $open_answer = new ilTextInputGUI('Sonstiges', 'cdf_oa_'.$field_obj->getId());
227  $open_answer->setRequired(true);
228  $option_radio->addSubItem($open_answer);
229  }
230 
231  $option_radios->addOption($option_radio);
232  }
233  $cdf->addSubItem($option_radios);
234  }
235  else
236  {
237  $select = new ilSelectInputGUI($field_obj->getName(),'cdf_'.$field_obj->getId());
238  #$select->setValue(ilUtil::stripSlashes($_POST['cdf'][$field_obj->getId()]));
239  $select->setOptions($field_obj->prepareSelectBox());
240  if($field_obj->isRequired())
241  {
242  $select->setRequired(true);
243  }
244  $cdf->addSubItem($select);
245  }
246  break;
247 
248  case IL_CDF_TYPE_TEXT:
249  $text = new ilTextInputGUI($field_obj->getName(),'cdf_'.$field_obj->getId());
250  #$text->setValue(ilUtil::stripSlashes($_POST['cdf'][$field_obj->getId()]));
251  $text->setSize(32);
252  $text->setMaxLength(255);
253  if($field_obj->isRequired())
254  {
255  $text->setRequired(true);
256  }
257  $cdf->addSubItem($text);
258  break;
259  }
260  }
261  $form->addItem($cdf);
262  return $form;
263 
264  }
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 140 of file class.ilMemberAgreementGUI.php.

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

Referenced by ilRegistrationGUI\fillAgreement().

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

References $_POST, and $ilUser.

Referenced by save().

353  {
354  global $ilUser;
355 
356  if($_POST['agreement'])
357  {
358  return true;
359  }
360  if($this->privacy->confirmationRequired($this->type))
361  {
362  return false;
363  }
364  return true;
365  }
$_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 375 of file class.ilMemberAgreementGUI.php.

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

Referenced by __construct().

376  {
377  global $ilUser;
378 
379  $this->required_fullfilled = ilCourseUserData::_checkRequired($ilUser->getId(),$this->obj_id);
380  $this->agreement_required = $this->getAgreement()->agreementRequired();
381  }
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 113 of file class.ilMemberAgreementGUI.php.

References $GLOBALS, and getPrivacy().

Referenced by save(), and showAgreement().

114  {
115  include_once './Services/Form/classes/class.ilPropertyFormGUI.php';
116  $form = new ilPropertyFormGUI();
117  $form->setTitle($this->lng->txt($this->type.'_agreement_header'));
118  $form->setFormAction($GLOBALS['ilCtrl']->getFormAction($this));
119  $form->addCommandButton('save', $this->lng->txt('save'));
120 
121  $form = self::addExportFieldInfo($form, $this->obj_id, $this->type);
122  $form = self::addCustomFields($form, $this->obj_id, $this->type);
123 
124  if($this->getPrivacy()->confirmationRequired($this->type))
125  {
126  $form = self::addAgreement($form, $this->obj_id, $this->type);
127  }
128 
129  return $form;
130  }
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 275 of file class.ilMemberAgreementGUI.php.

References checkAgreement(), getAgreement(), initFormAgreement(), ilUtil\sendFailure(), and showAgreement().

276  {
277  $form = $this->initFormAgreement();
278 
279  // #14715 - checkInput() does not work for checkboxes
280  if($this->checkAgreement() &&
281  $form->checkInput())
282  {
283  self::saveCourseDefinedFields($form, $this->obj_id);
284 
285  $this->getAgreement()->setAccepted(true);
286  $this->getAgreement()->setAcceptanceTime(time());
287  $this->getAgreement()->save();
288  $this->ctrl->returnToParent($this);
289  }
290  elseif(!$this->checkAgreement())
291  {
292  ilUtil::sendFailure($this->lng->txt($this->type.'_agreement_required'));
293  $form->setValuesByPost();
294  $this->showAgreement($form);
295  return false;
296  }
297  else
298  {
299  ilUtil::sendFailure($this->lng->txt('fill_out_all_required_fields'));
300  $form->setValuesByPost();
301  $this->showAgreement($form);
302  return false;
303  }
304  }
showAgreement(ilPropertyFormGUI $form=null)
Show agreement form.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
+ Here is the call graph for this function:

◆ saveCourseDefinedFields()

static ilMemberAgreementGUI::saveCourseDefinedFields ( ilPropertyFormGUI  $form,
  $a_obj_id 
)
static

Save course defined fields.

Parameters
ilPropertyFormGUI$form

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

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

312  {
313  global $ilUser;
314 
315  foreach(ilCourseDefinedFieldDefinition::_getFields($a_obj_id) as $field_obj)
316  {
317  switch($field_obj->getType())
318  {
319  case IL_CDF_TYPE_SELECT:
320 
321  // Split value id from post
322  list($field_id,$option_id) = explode('_', $form->getInput('cdf_'.$field_obj->getId()));
323  $open_answer_indexes = (array) $field_obj->getValueOptions();
324  if(in_array($option_id, $open_answer_indexes))
325  {
326  $value = $form->getInput('cdf_oa_'.$field_obj->getId());
327  }
328  else
329  {
330  $value = $field_obj->getValueById($option_id);
331  }
332  break;
333 
334  case IL_CDF_TYPE_TEXT:
335  $value = $form->getInput('cdf_'.$field_obj->getId());
336  break;
337  }
338 
339  $course_user_data = new ilCourseUserData($ilUser->getId(),$field_obj->getId());
340  $course_user_data->setValue($value);
341  $course_user_data->update();
342  }
343  }
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:

◆ sendInfoMessage()

ilMemberAgreementGUI::sendInfoMessage ( )
private

Send info message.

private

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

References ilUtil\sendFailure().

389  {
390  $message = '';
391  if($this->agreement_required)
392  {
393  $message = $this->lng->txt($this->type.'_ps_agreement_req_info');
394  }
395  if(!$this->required_fullfilled)
396  {
397  if(strlen($message))
398  {
399  $message .= '<br />';
400  }
401  $message .= $this->lng->txt($this->type.'_ps_required_info');
402  }
403 
404  if(strlen($message))
405  {
406  ilUtil::sendFailure($message);
407  }
408  }
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
+ Here is the call 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 initFormAgreement().

Referenced by save().

104  {
105  $form = $this->initFormAgreement($form);
106 
107  $this->tpl->setContent($form->getHTML());
108  return true;
109  }
+ 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: