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

Public Member Functions

 __construct ($a_obj_id)
 Constructor.
 executeCommand ()
 Execute Command.
 getObjId ()
 Get obj_id of container.

Data Fields

const MODE_CREATE = 1
const MODE_UPDATE = 2

Protected Member Functions

 show ()
 Show list of custom fields.
 listFields ()
 List existing custom fields.
 saveFields ()
 Save Field settings (currently only required status)
 confirmDeleteFields ()
 Show delete confirmation screen.
 deleteFields ()
 Delete selected fields.
 addField ()
 Show field creation form.
 saveField ()
 Save field.
 editField ()
 Edit one field.
 updateField ()
 Update field definition.
 initFieldForm ($a_mode)
 Init/create property form for fields.
 editMember (ilPropertyFormGUI $form=null)
 Edit Member.
 cancelEditMember ()
 Cancel editing.
 initMemberForm ()
 Init member form.
 saveMember ()

Private Attributes

 $form = null
 $lng
 $tpl
 $ctrl
 $tabs_gui
 $obj_id
 $ref_id
 $cdf

Detailed Description

Constructor & Destructor Documentation

ilObjectCustomUserFieldsGUI::__construct (   $a_obj_id)

Constructor.

public

Parameters

Definition at line 59 of file class.ilObjectCustomUserFieldsGUI.php.

References $ilCtrl, $lng, $tpl, ilObject\_getAllReferences(), and ilObject\_lookupType().

{
global $lng,$tpl,$ilCtrl,$ilTabs;
$this->lng = $lng;
$this->lng->loadLanguageModule('ps');
$this->lng->loadLanguageModule(ilObject::_lookupType($a_obj_id));
$this->tpl = $tpl;
$this->ctrl = $ilCtrl;
$this->tabs_gui = $ilTabs;
$this->obj_id = $a_obj_id;
// Currently only supported for container objects
$refs = ilObject::_getAllReferences($this->obj_id);
$this->ref_id = end($refs);
}

+ Here is the call graph for this function:

Member Function Documentation

ilObjectCustomUserFieldsGUI::addField ( )
protected

Show field creation form.

Returns

Definition at line 219 of file class.ilObjectCustomUserFieldsGUI.php.

References initFieldForm().

{
$this->initFieldForm(self::MODE_CREATE);
$this->form->getItemByPostVar('va')->setValues(array(''));
$this->tpl->setContent($this->form->getHTML());
}

+ Here is the call graph for this function:

ilObjectCustomUserFieldsGUI::cancelEditMember ( )
protected

Cancel editing.

Definition at line 418 of file class.ilObjectCustomUserFieldsGUI.php.

References $GLOBALS.

{
$GLOBALS['ilCtrl']->returnToParent($this);
}
ilObjectCustomUserFieldsGUI::confirmDeleteFields ( )
protected

Show delete confirmation screen.

Returns

Definition at line 171 of file class.ilObjectCustomUserFieldsGUI.php.

References $_POST, getObjId(), listFields(), and ilUtil\sendFailure().

{
if(!count($_POST['field_ids']))
{
ilUtil::sendFailure($this->lng->txt('ps_cdf_select_one'));
$this->listFields();
return false;
}
include_once './Services/Utilities/classes/class.ilConfirmationGUI.php';
$confirm = new ilConfirmationGUI();
$confirm->setFormAction($this->ctrl->getFormAction($this));
$confirm->setHeaderText($this->lng->txt('ps_cdf_delete_sure'));
foreach($_POST['field_ids'] as $field_id)
{
$tmp_field = new ilCourseDefinedFieldDefinition($this->getObjId(),$field_id);
$confirm->addItem('field_ids[]', $field_id, $tmp_field->getName());
}
$confirm->setConfirm($this->lng->txt('delete'), 'deleteFields');
$confirm->setCancel($this->lng->txt('cancel'), 'listFields');
$this->tpl->setContent($confirm->getHTML());
}

+ Here is the call graph for this function:

ilObjectCustomUserFieldsGUI::deleteFields ( )
protected

Delete selected fields.

Returns

Definition at line 200 of file class.ilObjectCustomUserFieldsGUI.php.

References $_POST, ilMemberAgreement\_deleteByObjId(), listFields(), and ilUtil\sendSuccess().

{
foreach((array) $_POST['field_ids'] as $field_id)
{
$tmp_field = new ilCourseDefinedFieldDefinition($this->obj_id,$field_id);
$tmp_field->delete();
}
ilUtil::sendSuccess($this->lng->txt('ps_cdf_deleted'));
$this->listFields();
return true;
}

+ Here is the call graph for this function:

ilObjectCustomUserFieldsGUI::editField ( )
protected

Edit one field.

Parameters
object$a_mode
Returns

Definition at line 263 of file class.ilObjectCustomUserFieldsGUI.php.

References $_REQUEST, getObjId(), initFieldForm(), and listFields().

{
if(!$_REQUEST['field_id'])
{
$this->listFields();
return false;
}
$this->initFieldForm(self::MODE_UPDATE);
$udf = new ilCourseDefinedFieldDefinition($this->getObjId(),(int) $_REQUEST['field_id']);
$this->form->getItemByPostVar('na')->setValue($udf->getName());
$this->form->getItemByPostVar('ty')->setValue($udf->getType());
$this->form->getItemByPostVar('re')->setChecked($udf->isRequired());
$this->form->getItemByPostVar('va')->setValues($udf->getValues());
$this->form->getItemByPostVar('va')->setOpenAnswerIndexes($udf->getValueOptions());
$this->tpl->setContent($this->form->getHTML());
}

+ Here is the call graph for this function:

ilObjectCustomUserFieldsGUI::editMember ( ilPropertyFormGUI  $form = null)
protected

Edit Member.

Parameters
ilPropertyFormGUI$form

Definition at line 392 of file class.ilObjectCustomUserFieldsGUI.php.

References $_REQUEST, $form, $GLOBALS, getObjId(), initMemberForm(), and ilMemberAgreementGUI\setCourseDefinedFieldValues().

Referenced by saveMember().

{
$GLOBALS['ilCtrl']->saveParameter($this,'member_id');
$GLOBALS['ilTabs']->clearTargets();
$GLOBALS['ilTabs']->clearSubTabs();
$GLOBALS['ilTabs']->setBackTarget($this->lng->txt('back'),$this->ctrl->getLinkTarget($this,'cancelEditMember'));
if($form instanceof ilPropertyFormGUI)
{
$GLOBALS['tpl']->setContent($form->getHTML());
}
else
{
$form = $this->initMemberForm();
}
$GLOBALS['tpl']->setContent($form->getHTML());
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilObjectCustomUserFieldsGUI::executeCommand ( )

Execute Command.

public

Definition at line 84 of file class.ilObjectCustomUserFieldsGUI.php.

References $cmd, $ilErr, and $lng.

{
global $ilErr, $ilAccess, $lng;
if(!$ilAccess->checkAccess('write','',$this->ref_id))
{
$ilErr->raiseError($lng->txt('permission_denied'),$ilErr->WARNING);
}
$cmd = $this->ctrl->getCmd();
switch($next_class = $this->ctrl->getNextClass($this))
{
default:
if(!$cmd)
{
$cmd = 'show';
}
$this->$cmd();
break;
}
}
ilObjectCustomUserFieldsGUI::getObjId ( )

Get obj_id of container.

Returns

Definition at line 111 of file class.ilObjectCustomUserFieldsGUI.php.

References $obj_id.

Referenced by confirmDeleteFields(), editField(), editMember(), initMemberForm(), listFields(), saveField(), saveFields(), saveMember(), show(), and updateField().

{
return $this->obj_id;
}

+ Here is the caller graph for this function:

ilObjectCustomUserFieldsGUI::initFieldForm (   $a_mode)
protected

Init/create property form for fields.

Returns

Definition at line 321 of file class.ilObjectCustomUserFieldsGUI.php.

References $_REQUEST, IL_CDF_TYPE_SELECT, IL_CDF_TYPE_TEXT, ilTextWizardInputGUI\setAllowMove(), ilFormPropertyGUI\setRequired(), ilTextInputGUI\setSize(), and ilCheckboxInputGUI\setValue().

Referenced by addField(), editField(), saveField(), and updateField().

{
if($this->form instanceof ilPropertyFormGUI)
{
return true;
}
include_once './Services/Form/classes/class.ilPropertyFormGUI.php';
$this->form = new ilPropertyFormGUI();
switch($a_mode)
{
case self::MODE_CREATE:
$this->form->setFormAction($this->ctrl->getFormAction($this));
$this->form->setTitle($this->lng->txt('ps_cdf_add_field'));
$this->form->addCommandButton('saveField', $this->lng->txt('save'));
$this->form->addCommandButton('listFields', $this->lng->txt('cancel'));
break;
case self::MODE_UPDATE:
$this->ctrl->setParameter($this,'field_id',(int) $_REQUEST['field_id']);
$this->form->setFormAction($this->ctrl->getFormAction($this));
$this->form->setTitle($this->lng->txt('ps_cdf_edit_field'));
$this->form->addCommandButton('updateField', $this->lng->txt('save'));
$this->form->addCommandButton('listFields', $this->lng->txt('cancel'));
break;
}
// Name
$na = new ilTextInputGUI($this->lng->txt('ps_cdf_name'),'na');
$na->setSize(32);
$na->setMaxLength(255);
$na->setRequired(true);
$this->form->addItem($na);
// Type
$ty = new ilRadioGroupInputGUI($this->lng->txt('ps_field_type'),'ty');
$ty->setRequired(true);
$this->form->addItem($ty);
if($a_mode == self::MODE_UPDATE)
{
$ty->setDisabled(true); // #14888
}
// Text type
$ty_te = new ilRadioOption($this->lng->txt('ps_type_txt_long'),IL_CDF_TYPE_TEXT);
$ty->addOption($ty_te);
// Select Type
$ty_se = new ilRadioOption($this->lng->txt('ps_type_select_long'),IL_CDF_TYPE_SELECT);
$ty->addOption($ty_se);
// Select Type Values
include_once './Services/Form/classes/class.ilSelectBuilderInputGUI.php';
$ty_se_mu = new ilSelectBuilderInputGUI($this->lng->txt('ps_cdf_value'),'va');
$ty_se_mu->setAllowMove(true);
$ty_se_mu->setRequired(true);
$ty_se_mu->setSize(32);
$ty_se_mu->setMaxLength(128);
$ty_se->addSubItem($ty_se_mu);
// Required
$re = new ilCheckboxInputGUI($this->lng->txt('ps_cdf_required'),'re');
$re->setValue(1);
$this->form->addItem($re);
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilObjectCustomUserFieldsGUI::initMemberForm ( )
protected

Init member form.

Returns

Definition at line 427 of file class.ilObjectCustomUserFieldsGUI.php.

References $_REQUEST, $form, $GLOBALS, ilObjUser\_lookupName(), ilObject\_lookupType(), ilMemberAgreementGUI\addCustomFields(), and getObjId().

Referenced by editMember(), and saveMember().

{
include_once './Services/Form/classes/class.ilPropertyFormGUI.php';
$form->setFormAction($GLOBALS['ilCtrl']->getFormAction($this));
$title = $this->lng->txt(ilObject::_lookupType($this->getObjId()).'_cdf_edit_member');
$name = ilObjUser::_lookupName((int) $_REQUEST['member_id']);
$title .= (': '.$name['lastname'].', '.$name['firstname']);
$form->setTitle($title);
include_once './Services/Membership/classes/class.ilMemberAgreementGUI.php';
$form->addCommandButton('saveMember', $this->lng->txt('save'));
$form->addCommandButton('cancelEditMember', $this->lng->txt('cancel'));
return $form;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilObjectCustomUserFieldsGUI::listFields ( )
protected

List existing custom fields.

Returns

Definition at line 133 of file class.ilObjectCustomUserFieldsGUI.php.

References ilCourseDefinedFieldDefinition\_getFields(), and getObjId().

Referenced by confirmDeleteFields(), deleteFields(), editField(), saveField(), saveFields(), show(), and updateField().

{
global $ilToolbar;
$ilToolbar->addButton(
$this->lng->txt('ps_cdf_add_field'),
$this->ctrl->getLinkTarget($this,'addField')
);
include_once './Services/Membership/classes/class.ilObjectCustomUserFieldsTableGUI.php';
$table = new ilObjectCustomUserFieldsTableGUI($this,'listFields');
$this->tpl->setContent($table->getHTML());
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilObjectCustomUserFieldsGUI::saveField ( )
protected

Save field.

Returns

Definition at line 232 of file class.ilObjectCustomUserFieldsGUI.php.

References $_POST, $GLOBALS, getObjId(), initFieldForm(), listFields(), ilUtil\sendFailure(), and ilUtil\sendSuccess().

{
$GLOBALS['ilLog']->write(__METHOD__.': '.print_r($_POST,true));
$this->initFieldForm(self::MODE_CREATE);
if($this->form->checkInput())
{
$udf->setName($this->form->getInput('na'));
$udf->setType($this->form->getInput('ty'));
$udf->setValues($udf->prepareValues($this->form->getInput('va')));
$udf->setValueOptions($this->form->getItemByPostVar('va')->getOpenAnswerIndexes()); // #14720
$udf->enableRequired($this->form->getInput('re'));
$udf->save();
ilUtil::sendSuccess($this->lng->txt('ps_cdf_added_field'));
$this->listFields();
return true;
}
// not valid
ilUtil::sendFailure($this->lng->txt('err_check_input'));
$this->form->setValuesByPost();
$this->tpl->setContent($this->form->getHTML());
return false;
}

+ Here is the call graph for this function:

ilObjectCustomUserFieldsGUI::saveFields ( )
protected

Save Field settings (currently only required status)

Returns

Definition at line 152 of file class.ilObjectCustomUserFieldsGUI.php.

References $_POST, ilMemberAgreement\_deleteByObjId(), ilCourseDefinedFieldDefinition\_getFields(), getObjId(), listFields(), and ilUtil\sendSuccess().

{
foreach($fields as $field_obj)
{
$field_obj->enableRequired((bool) isset($_POST['required'][$field_obj->getId()]));
$field_obj->update();
}
ilUtil::sendSuccess($this->lng->txt('settings_saved'));
$this->listFields();
return true;
}

+ Here is the call graph for this function:

ilObjectCustomUserFieldsGUI::saveMember ( )
protected

Definition at line 446 of file class.ilObjectCustomUserFieldsGUI.php.

References $_REQUEST, $form, $GLOBALS, $ilUser, editMember(), getObjId(), IL_CAL_UNIX, initMemberForm(), ilMemberAgreementGUI\saveCourseDefinedFields(), ilUtil\sendFailure(), and ilUtil\sendSuccess().

{
global $ilUser;
$GLOBALS['ilCtrl']->saveParameter($this,'member_id');
$form = $this->initMemberForm();
if($form->checkInput())
{
// save history
include_once './Services/Membership/classes/class.ilObjectCustomUserFieldHistory.php';
$history = new ilObjectCustomUserFieldHistory($this->getObjId(), (int) $_REQUEST['member_id']);
$history->setEditingTime(new ilDateTime(time(),IL_CAL_UNIX));
$history->setUpdateUser($ilUser->getId());
$history->save();
ilUtil::sendSuccess($this->lng->txt('settings_saved'),TRUE);
$GLOBALS['ilCtrl']->returnToParent($this);
return TRUE;
}
$form->setValuesByPost();
ilUtil::sendFailure($this->lng->txt('err_check_input'));
return $this->editMember($form);
}

+ Here is the call graph for this function:

ilObjectCustomUserFieldsGUI::show ( )
protected

Show list of custom fields.

Returns

Definition at line 120 of file class.ilObjectCustomUserFieldsGUI.php.

References ilMemberAgreement\_hasAgreementsByObjId(), getObjId(), listFields(), and ilUtil\sendInfo().

{
{
ilUtil::sendInfo($this->lng->txt('ps_cdf_warning_modify'));
}
$this->listFields();
}

+ Here is the call graph for this function:

ilObjectCustomUserFieldsGUI::updateField ( )
protected

Update field definition.

Returns

Definition at line 287 of file class.ilObjectCustomUserFieldsGUI.php.

References $_POST, $_REQUEST, $GLOBALS, ilMemberAgreement\_deleteByObjId(), getObjId(), initFieldForm(), listFields(), ilUtil\sendFailure(), and ilUtil\sendSuccess().

{
$GLOBALS['ilLog']->write(__METHOD__.': '.print_r($_POST,true));
$this->initFieldForm(self::MODE_UPDATE);
if($this->form->checkInput())
{
$udf = new ilCourseDefinedFieldDefinition($this->getObjId(),(int) $_REQUEST['field_id']);
$udf->setName($this->form->getInput('na'));
$udf->setType($this->form->getInput('ty'));
$prepared = $udf->prepareValues($this->form->getInput('va'));
$udf->setValues($prepared);
$udf->setValueOptions($this->form->getItemByPostVar('va')->getOpenAnswerIndexes());
$udf->enableRequired($this->form->getInput('re'));
$udf->update();
// Finally reset member agreements
ilUtil::sendSuccess($this->lng->txt('settings_saved'));
$this->listFields();
return true;
}
ilUtil::sendFailure($this->lng->txt('err_check_input'));
$this->form->setValuesByPost();
$this->tpl->setContent($this->form->getHTML());
return false;
}

+ Here is the call graph for this function:

Field Documentation

ilObjectCustomUserFieldsGUI::$cdf
private

Definition at line 50 of file class.ilObjectCustomUserFieldsGUI.php.

ilObjectCustomUserFieldsGUI::$ctrl
private

Definition at line 44 of file class.ilObjectCustomUserFieldsGUI.php.

ilObjectCustomUserFieldsGUI::$form = null
private

Definition at line 40 of file class.ilObjectCustomUserFieldsGUI.php.

Referenced by editMember(), initMemberForm(), and saveMember().

ilObjectCustomUserFieldsGUI::$lng
private

Definition at line 42 of file class.ilObjectCustomUserFieldsGUI.php.

Referenced by __construct(), and executeCommand().

ilObjectCustomUserFieldsGUI::$obj_id
private

Definition at line 47 of file class.ilObjectCustomUserFieldsGUI.php.

Referenced by getObjId().

ilObjectCustomUserFieldsGUI::$ref_id
private

Definition at line 48 of file class.ilObjectCustomUserFieldsGUI.php.

ilObjectCustomUserFieldsGUI::$tabs_gui
private

Definition at line 45 of file class.ilObjectCustomUserFieldsGUI.php.

ilObjectCustomUserFieldsGUI::$tpl
private

Definition at line 43 of file class.ilObjectCustomUserFieldsGUI.php.

Referenced by __construct().

const ilObjectCustomUserFieldsGUI::MODE_CREATE = 1

Definition at line 37 of file class.ilObjectCustomUserFieldsGUI.php.

const ilObjectCustomUserFieldsGUI::MODE_UPDATE = 2

Definition at line 38 of file class.ilObjectCustomUserFieldsGUI.php.


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