ILIAS  Release_5_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
ilMemberAgreementGUI Class Reference
+ Collaboration diagram for ilMemberAgreementGUI:

Public Member Functions

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

Static Public Member Functions

static addExportFieldInfo ($form, $a_obj_id, $a_type)
 Add export field info to form type $lng.
static addAgreement ($form, $a_obj_id, $a_type)
 Add agreement to form.
static addCustomFields ($form, $a_obj_id, $a_type, $a_mode= 'user')
 Add custom course fields.
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.

Protected Member Functions

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

Private Member Functions

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

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

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().

{
global $ilDB,$ilCtrl,$lng,$tpl,$ilUser,$ilObjDataCache;
$this->ref_id = $a_ref_id;
$this->obj_id = $ilObjDataCache->lookupObjId($this->ref_id);
$this->type = ilObject::_lookupType($this->obj_id);
$this->ctrl = $ilCtrl;
$this->tpl = $tpl;
$this->lng = $lng;
$this->lng->loadLanguageModule('ps');
$this->privacy = ilPrivacySettings::_getInstance();
$this->agreement = new ilMemberAgreement($ilUser->getId(),$this->obj_id);
$this->init();
}

+ Here is the call graph for this function:

Member Function Documentation

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(), and initFormAgreement().

{
global $lng;
$agreement = new ilCheckboxInputGUI($lng->txt($a_type.'_agree'),'agreement');
$agreement->setRequired(true);
$agreement->setOptionTitle($lng->txt($a_type.'_info_agree'));
$agreement->setValue(1);
$form->addItem($agreement);
return $form;
}

+ Here is the caller graph for this function:

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(), initFormAgreement(), and ilObjectCustomUserFieldsGUI\initMemberForm().

{
global $lng;
include_once('Modules/Course/classes/Export/class.ilCourseDefinedFieldDefinition.php');
include_once('Modules/Course/classes/Export/class.ilCourseUserData.php');
if(!count($cdf_fields = ilCourseDefinedFieldDefinition::_getFields($a_obj_id)))
{
return $form;
}
if($a_mode == 'user')
{
$cdf = new ilNonEditableValueGUI($lng->txt('ps_'.$a_type.'_user_fields'));
$cdf->setValue($lng->txt($a_type.'_ps_cdf_info'));
$cdf->setRequired(true);
}
foreach($cdf_fields as $field_obj)
{
switch($field_obj->getType())
{
if($field_obj->getValueOptions())
{
// Show as radio group
$option_radios = new ilRadioGroupInputGUI($field_obj->getName(), 'cdf_'.$field_obj->getId());
if($field_obj->isRequired())
{
$option_radios->setRequired(true);
}
$open_answer_indexes = (array) $field_obj->getValueOptions();
foreach($field_obj->getValues() as $key => $val)
{
$option_radio = new ilRadioOption($val,$field_obj->getId().'_'.$key);
// open answers
if(in_array($key, $open_answer_indexes))
{
$open_answer = new ilTextInputGUI($lng->txt("form_open_answer"), 'cdf_oa_'.$field_obj->getId().'_'.$key);
$open_answer->setRequired(true);
$option_radio->addSubItem($open_answer);
}
$option_radios->addOption($option_radio);
}
if($a_mode == 'user')
{
$cdf->addSubItem($option_radios);
}
else
{
$form->addItem($option_radios);
}
}
else
{
$select = new ilSelectInputGUI($field_obj->getName(),'cdf_'.$field_obj->getId());
#$select->setValue(ilUtil::stripSlashes($_POST['cdf'][$field_obj->getId()]));
$select->setOptions($field_obj->prepareSelectBox());
if($field_obj->isRequired())
{
$select->setRequired(true);
}
if($a_mode == 'user')
{
$cdf->addSubItem($select);
}
else
{
$form->addItem($select);
}
}
break;
$text = new ilTextInputGUI($field_obj->getName(),'cdf_'.$field_obj->getId());
#$text->setValue(ilUtil::stripSlashes($_POST['cdf'][$field_obj->getId()]));
$text->setSize(32);
$text->setMaxLength(255);
if($field_obj->isRequired())
{
$text->setRequired(true);
}
if($a_mode == 'user')
{
$cdf->addSubItem($text);
}
else
{
$form->addItem($text);
}
break;
}
}
if($a_mode == 'user')
{
$form->addItem($cdf);
}
return $form;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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(), and initFormAgreement().

{
global $lng;
include_once('Services/PrivacySecurity/classes/class.ilExportFieldsInfo.php');
$fields = new ilCustomInputGUI($lng->txt($a_type.'_user_agreement'),'');
$tpl = new ilTemplate('tpl.agreement_form.html',true,true,'Services/Membership');
$tpl->setVariable('TXT_INFO_AGREEMENT',$lng->txt($a_type.'_info_agreement'));
foreach($fields_info->getExportableFields() as $field)
{
$tpl->setCurrentBlock('field_item');
$tpl->setVariable('FIELD_NAME',$lng->txt($field));
$tpl->parseCurrentBlock();
}
$fields->setHtml($tpl->get());
$form->addItem($fields);
return $form;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilMemberAgreementGUI::checkAgreement ( )
private

Check Agreement.

private

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

References $_POST, and $ilUser.

Referenced by save().

{
global $ilUser;
if($_POST['agreement'])
{
return true;
}
if($this->privacy->confirmationRequired($this->type))
{
return false;
}
return true;
}

+ Here is the caller graph for this function:

ilMemberAgreementGUI::executeCommand ( )

Execute Command.

public

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

References $cmd.

{
$next_class = $this->ctrl->getNextClass($this);
$cmd = $this->ctrl->getCmd();
switch($next_class)
{
default:
if(!$cmd or $cmd == 'view')
{
$cmd = 'showAgreement';
}
$this->$cmd();
break;
}
}
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:

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:

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().

{
global $ilUser;
$this->required_fullfilled = ilCourseUserData::_checkRequired($ilUser->getId(),$this->obj_id);
$this->agreement_required = $this->getAgreement()->agreementRequired();
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilMemberAgreementGUI::initFormAgreement ( )
protected

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

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

Referenced by save(), and showAgreement().

{
include_once './Services/Form/classes/class.ilPropertyFormGUI.php';
$form = new ilPropertyFormGUI();
$form->setTitle($this->lng->txt($this->type.'_agreement_header'));
$form->setFormAction($GLOBALS['ilCtrl']->getFormAction($this));
$form->addCommandButton('save', $this->lng->txt('save'));
$form = self::addExportFieldInfo($form, $this->obj_id, $this->type);
$form = self::addCustomFields($form, $this->obj_id, $this->type);
if($this->getPrivacy()->confirmationRequired($this->type))
{
$form = self::addAgreement($form, $this->obj_id, $this->type);
}
return $form;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilMemberAgreementGUI::save ( )
private

Save.

private

Parameters

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

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

{
global $ilUser;
$form = $this->initFormAgreement();
// #14715 - checkInput() does not work for checkboxes
if($this->checkAgreement() &&
$form->checkInput())
{
self::saveCourseDefinedFields($form, $this->obj_id);
$this->getAgreement()->setAccepted(true);
$this->getAgreement()->setAcceptanceTime(time());
$this->getAgreement()->save();
include_once './Services/Membership/classes/class.ilObjectCustomUserFieldHistory.php';
$history = new ilObjectCustomUserFieldHistory($this->obj_id,$ilUser->getId());
$history->setUpdateUser($ilUser->getId());
$history->setEditingTime(new ilDateTime(time(),IL_CAL_UNIX));
$history->save();
$this->ctrl->returnToParent($this);
}
elseif(!$this->checkAgreement())
{
ilUtil::sendFailure($this->lng->txt($this->type.'_agreement_required'));
$form->setValuesByPost();
$this->showAgreement($form);
return false;
}
else
{
ilUtil::sendFailure($this->lng->txt('fill_out_all_required_fields'));
$form->setValuesByPost();
$this->showAgreement($form);
return false;
}
}

+ Here is the call graph for this function:

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 save(), and ilObjectCustomUserFieldsGUI\saveMember().

{
global $ilUser;
if(!$a_usr_id)
{
$a_usr_id = $ilUser->getId();
}
foreach(ilCourseDefinedFieldDefinition::_getFields($a_obj_id) as $field_obj)
{
switch($field_obj->getType())
{
// Split value id from post
list($field_id,$option_id) = explode('_', $form->getInput('cdf_'.$field_obj->getId()));
$open_answer_indexes = (array) $field_obj->getValueOptions();
if(in_array($option_id, $open_answer_indexes))
{
$value = $form->getInput('cdf_oa_'.$field_obj->getId().'_'.$option_id);
}
else
{
$value = $field_obj->getValueById($option_id);
}
break;
$value = $form->getInput('cdf_'.$field_obj->getId());
break;
}
$course_user_data = new ilCourseUserData($a_usr_id,$field_obj->getId());
$course_user_data->setValue($value);
$course_user_data->update();
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilMemberAgreementGUI::sendInfoMessage ( )
private

Send info message.

private

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

References ilUtil\sendFailure().

{
$message = '';
if($this->agreement_required)
{
$message = $this->lng->txt($this->type.'_ps_agreement_req_info');
}
if(!$this->required_fullfilled)
{
if(strlen($message))
{
$message .= '<br />';
}
$message .= $this->lng->txt($this->type.'_ps_required_info');
}
if(strlen($message))
{
}
}

+ Here is the call graph for this function:

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(), and showAgreement().

{
global $ilUser;
if(!$a_usr_id)
{
$a_usr_id = $ilUser->getId();
}
foreach(ilCourseDefinedFieldDefinition::_getFields($a_obj_id) as $field_obj)
{
$current_value = $ud[$a_usr_id][$field_obj->getId()];
if(!$current_value)
{
continue;
}
switch($field_obj->getType())
{
$id = $field_obj->getIdByValue($current_value);
if($id >= 0)
{
$item = $form->getItemByPostVar('cdf_'.$field_obj->getId());
$item->setValue($field_obj->getId().'_'.$id);
}
else
{
// open answer
$open_answer_indexes = $field_obj->getValueOptions();
$open_answer_index = end($open_answer_indexes);
$item = $form->getItemByPostVar('cdf_'.$field_obj->getId());
$item->setValue($field_obj->getId().'_'.$open_answer_index);
$item_txt = $form->getItemByPostVar('cdf_oa_'.$field_obj->getId().'_'.$open_answer_index);
if($item_txt)
{
$item_txt->setValue($current_value);
}
}
break;
$item = $form->getItemByPostVar('cdf_'.$field_obj->getId());
$item->setValue($current_value);
break;
}
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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, initFormAgreement(), and setCourseDefinedFieldValues().

Referenced by save().

{
global $ilUser;
$form = $this->initFormAgreement($form);
self::setCourseDefinedFieldValues($form, $this->obj_id, $ilUser->getId());
$this->tpl->setContent($form->getHTML());
return true;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Field Documentation

ilMemberAgreementGUI::$agreement
private

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

Referenced by addAgreement(), and getAgreement().

ilMemberAgreementGUI::$agrement_required = false
private

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

ilMemberAgreementGUI::$ctrl
private

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

ilMemberAgreementGUI::$db
private

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

ilMemberAgreementGUI::$lng
private
ilMemberAgreementGUI::$obj_id
private

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

Referenced by __construct(), and init().

ilMemberAgreementGUI::$privacy
private

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

Referenced by getPrivacy().

ilMemberAgreementGUI::$ref_id
private

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

ilMemberAgreementGUI::$required_fullfilled = false
private

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

ilMemberAgreementGUI::$tpl
private

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

Referenced by __construct(), and addExportFieldInfo().

ilMemberAgreementGUI::$type
private

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


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