ILIAS  eassessment Revision 61809
 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.

Private Attributes

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

Detailed Description

Constructor & Destructor Documentation

ilObjectCustomUserFieldsGUI::__construct (   $a_obj_id)

Constructor.

public

Parameters

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

References $ilCtrl, $lng, $tpl, 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;
}

+ Here is the call graph for this function:

Member Function Documentation

ilObjectCustomUserFieldsGUI::addField ( )
protected

Show field creation form.

Returns

Definition at line 207 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::confirmDeleteFields ( )
protected

Show delete confirmation screen.

Returns

Definition at line 159 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 188 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 248 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->tpl->setContent($this->form->getHTML());
}

+ Here is the call graph for this function:

ilObjectCustomUserFieldsGUI::executeCommand ( )

Execute Command.

public

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

References $cmd.

{
$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 99 of file class.ilObjectCustomUserFieldsGUI.php.

References $obj_id.

Referenced by confirmDeleteFields(), editField(), listFields(), saveField(), saveFields(), 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 301 of file class.ilObjectCustomUserFieldsGUI.php.

References $_REQUEST, IL_CDF_TYPE_SELECT, IL_CDF_TYPE_TEXT, 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);
// 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
$ty_se_mu = new ilTextWizardInputGUI($this->lng->txt('ps_cdf_value'),'va');
$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::listFields ( )
protected

List existing custom fields.

Returns

Definition at line 121 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 220 of file class.ilObjectCustomUserFieldsGUI.php.

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

{
$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->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 140 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::show ( )
protected

Show list of custom fields.

Returns

Definition at line 108 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 271 of file class.ilObjectCustomUserFieldsGUI.php.

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

{
$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'));
$udf->setValues($udf->prepareValues($this->form->getInput('va')));
$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 49 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.

ilObjectCustomUserFieldsGUI::$lng
private

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

Referenced by __construct().

ilObjectCustomUserFieldsGUI::$obj_id
private

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

Referenced by getObjId().

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: