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

Public Member Functions

 __construct ($a_obj_id)
 Constructor.
 executeCommand ()
 Execute Command.
 show ()
 Show defined fields.
 editField ()
 Edit field.
 deleteField ()
 Delete field.
 addNewValue ()
 Increment values.
 updateField ()
 Update Field.
 confirmDelete ()
 Confirm delete.
 delete ()
 Delete course fields.
 save ()
 Save.
 fieldSelection ()
 Field selection.
 chooseDefinitions ()
 Choose Definitions.
 addSelectField ()
 addValue ()
 Increment values.
 addTextField ()
 public
 saveField ()
 Save New Field.

Private Attributes

 $lng
 $tpl
 $ctrl
 $tabs_gui
 $obj_id
 $cdf

Detailed Description

Constructor & Destructor Documentation

ilCourseUserFieldsGUI::__construct (   $a_obj_id)

Constructor.

public

Parameters

Definition at line 53 of file class.ilCourseUserFieldsGUI.php.

References $ilCtrl, $lng, and $tpl.

{
global $lng,$tpl,$ilCtrl,$ilTabs;
$this->lng = $lng;
$this->lng->loadLanguageModule('ps');
$this->tpl = $tpl;
$this->ctrl = $ilCtrl;
$this->tabs_gui = $ilTabs;
$this->obj_id = $a_obj_id;
}

Member Function Documentation

ilCourseUserFieldsGUI::addNewValue ( )

Increment values.

public

Definition at line 259 of file class.ilCourseUserFieldsGUI.php.

References $_SESSION, and editField().

{
$_SESSION['il_cdf_select_num_values'] += 1;
$this->editField();
return true;
}

+ Here is the call graph for this function:

ilCourseUserFieldsGUI::addSelectField ( )

Definition at line 455 of file class.ilCourseUserFieldsGUI.php.

References $_POST, $_SESSION, and ilUtil\formCheckbox().

Referenced by addValue(), and chooseDefinitions().

{
$_SESSION['il_cdf_select_num_values'] = $_SESSION['il_cdf_select_num_values'] ? $_SESSION['il_cdf_select_num_values'] : 3;
$this->ctrl->setParameter($this,'field_type',(int) $_REQUEST['field_type']);
$this->tpl->addBlockFile('ADM_CONTENT','adm_content','tpl.user_fields_add_select.html','Modules/Course');
$this->tpl->setVariable('FORMACTION',$this->ctrl->getFormAction($this));
$this->tpl->setVariable('TXT_SELECT_TYPE',$this->lng->txt('ps_new_select_field'));
$this->tpl->setVariable('TXT_FIELD_NAME',$this->lng->txt('ps_name_field'));
$this->tpl->setVariable('TXT_REQUIRED',$this->lng->txt('required_field'));
$this->tpl->setVariable('BTN_ADD',$this->lng->txt('save'));
$this->tpl->setVariable('BTN_PREVIOUS',$this->lng->txt('btn_previous'));
$this->tpl->setVariable('BTN_NEW_VALUE',$this->lng->txt('ps_btn_add_value'));
$this->tpl->setVariable('REQUIRED',ilUtil::formCheckbox($_POST['required'] ? 1 : 0,'required',1));
$this->tpl->setVariable('FIELD_NAME_VALUE',$_POST['field_name']);
for($i = 0; $i < $_SESSION['il_cdf_select_num_values'];$i++)
{
$this->tpl->setCurrentBlock("values");
$this->tpl->setVariable('COUNTER',$i);
$this->tpl->setVariable("TXT_VALUES",$this->lng->txt('ps_cdf_value').' '.($i + 1));
$this->tpl->setVariable("FIELD_NAME",$_POST['field_values'][$i]);
$this->tpl->parseCurrentBlock();
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilCourseUserFieldsGUI::addTextField ( )

public

Parameters

Definition at line 505 of file class.ilCourseUserFieldsGUI.php.

References ilUtil\formCheckbox().

Referenced by chooseDefinitions().

{
$this->ctrl->setParameter($this,'field_type',(int) $_REQUEST['field_type']);
$this->tpl->addBlockFile('ADM_CONTENT','adm_content','tpl.user_fields_add_text.html','Modules/Course');
$this->tpl->setVariable('FORMACTION',$this->ctrl->getFormAction($this));
$this->tpl->setVariable('TXT_SELECT_TYPE',$this->lng->txt('ps_new_text_field'));
$this->tpl->setVariable('TXT_FIELD_NAME',$this->lng->txt('ps_name_field'));
$this->tpl->setVariable('TXT_REQUIRED',$this->lng->txt('required_field'));
$this->tpl->setVariable('BTN_ADD',$this->lng->txt('btn_add'));
$this->tpl->setVariable('BTN_PREVIOUS',$this->lng->txt('btn_previous'));
$this->tpl->setVariable('REQUIRED',ilUtil::formCheckbox(0,'required',1));
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilCourseUserFieldsGUI::addValue ( )

Increment values.

public

Definition at line 489 of file class.ilCourseUserFieldsGUI.php.

References $_SESSION, and addSelectField().

{
$_SESSION['il_cdf_select_num_values'] += 1;
$this->addSelectField();
return true;
}

+ Here is the call graph for this function:

ilCourseUserFieldsGUI::chooseDefinitions ( )

Choose Definitions.

public

Definition at line 438 of file class.ilCourseUserFieldsGUI.php.

References addSelectField(), addTextField(), IL_CDF_TYPE_SELECT, and IL_CDF_TYPE_TEXT.

Referenced by saveField().

{
switch($field_type = (int) $_REQUEST['field_type'])
{
$this->addTextField();
break;
$this->addSelectField();
break;
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilCourseUserFieldsGUI::confirmDelete ( )

Confirm delete.

public

Definition at line 320 of file class.ilCourseUserFieldsGUI.php.

References $_POST, $_SESSION, IL_CDF_TYPE_SELECT, ilUtil\sendFailure(), ilUtil\sendQuestion(), show(), and ilUtil\switchColor().

{
if(!count($_POST['field_id']))
{
ilUtil::sendFailure($this->lng->txt('ps_cdf_select_one'));
$this->show();
return false;
}
ilUtil::sendQuestion($this->lng->txt('ps_cdf_delete_sure'));
$this->tpl->addBlockFile('ADM_CONTENT','adm_content','tpl.user_fields_confirm_delete.html','Modules/Course');
$this->tpl->setVariable('FORMACTION',$this->ctrl->getFormAction($this));
$this->tpl->setVariable('TXT_NAME',$this->lng->txt('ps_cdf_name'));
$this->tpl->setVariable('TXT_TYPE',$this->lng->txt('ps_cdf_type'));
$this->tpl->setVariable('DELETE',$this->lng->txt('delete'));
$this->tpl->setVariable('CANCEL',$this->lng->txt('cancel'));
$counter = 0;
foreach($_POST['field_id'] as $field_id)
{
$tmp_field = new ilCourseDefinedFieldDefinition($this->obj_id,$field_id);
$this->tpl->setCurrentBlock('del_row');
$this->tpl->setVariable('CSS_ROW',ilUtil::switchColor(++$counter,'tblrow1','tblrow2'));
$this->tpl->setVariable('DEL_NAME',$tmp_field->getName());
$this->tpl->setVariable('DEL_TYPE',$tmp_field->getType() == IL_CDF_TYPE_SELECT ?
$this->lng->txt('ps_type_select') :
$this->lng->txt('ps_type_text'));
$this->tpl->parseCurrentBlock();
}
$_SESSION['il_cdf_delete'] = $_POST['field_id'];
}

+ Here is the call graph for this function:

ilCourseUserFieldsGUI::delete ( )

Delete course fields.

public

Definition at line 359 of file class.ilCourseUserFieldsGUI.php.

References $_SESSION, ilCourseAgreement\_deleteByObjId(), ilUtil\sendFailure(), ilUtil\sendSuccess(), and show().

{
if(!count($_SESSION['il_cdf_delete']))
{
ilUtil::sendFailure($this->lng->txt('ps_cdf_select_one'));
$this->show();
return false;
}
foreach($_SESSION['il_cdf_delete'] as $field_id)
{
$tmp_field = new ilCourseDefinedFieldDefinition($this->obj_id,$field_id);
$tmp_field->delete();
}
ilUtil::sendSuccess($this->lng->txt('ps_cdf_deleted'));
unset($_SESSION['il_cdf_delete']);
$this->show();
return true;
}

+ Here is the call graph for this function:

ilCourseUserFieldsGUI::deleteField ( )

Delete field.

public

Definition at line 238 of file class.ilCourseUserFieldsGUI.php.

References $_GET, $cdf, editField(), ilUtil\sendFailure(), ilUtil\sendSuccess(), and show().

{
if(!$_GET['field_id'])
{
ilUtil::sendFailure('No field given');
$this->show();
return false;
}
$cdf = new ilCourseDefinedFieldDefinition($this->obj_id,(int) $_GET['field_id']);
$cdf->deleteValue((int) $_GET['del_field']);
ilUtil::sendSuccess($this->lng->txt('ps_cdf_deleted_field'));
$this->editField();
}

+ Here is the call graph for this function:

ilCourseUserFieldsGUI::editField ( )

Edit field.

public

Definition at line 167 of file class.ilCourseUserFieldsGUI.php.

References $_GET, $_POST, $_SESSION, $cdf, $key, $name, ilUtil\formCheckbox(), IL_CDF_TYPE_SELECT, IL_CDF_TYPE_TEXT, ilUtil\prepareFormOutput(), ilUtil\sendFailure(), and show().

Referenced by addNewValue(), deleteField(), and updateField().

{
$_SESSION['il_cdf_select_num_values'] = $_SESSION['il_cdf_select_num_values'] ? $_SESSION['il_cdf_select_num_values'] : 1;
if(!$_GET['field_id'])
{
ilUtil::sendFailure('No field given');
$this->show();
return false;
}
$cdf = new ilCourseDefinedFieldDefinition($this->obj_id,(int) $_GET['field_id']);
$name = isset($_POST['cmd']) ? ilUtil::prepareFormOutput($_POST['field_name'],true) : ilUtil::prepareFormOutput($cdf->getName());
$required = isset($_POST['cmd']) ? $_POST['required'] : $cdf->isRequired();
$this->ctrl->setParameter($this,'field_id',(int) $_GET['field_id']);
$this->tpl->addBlockFile('ADM_CONTENT','adm_content','tpl.user_fields_edit_select_field.html','Modules/Course');
$this->tpl->setVariable('FORMACTION',$this->ctrl->getFormAction($this));
$this->tpl->setVariable('TXT_FIELD_NAME',$this->lng->txt('ps_name_field'));
$this->tpl->setVariable('FIELD_NAME_VALUE',$name);
$this->tpl->setVariable('TXT_REQUIRED',$this->lng->txt('required_field'));
$this->tpl->setVariable('BTN_ADD',$this->lng->txt('save'));
$this->tpl->setVariable('BTN_PREVIOUS',$this->lng->txt('cancel'));
$this->tpl->setVariable('REQUIRED',ilUtil::formCheckbox($required,'required',1));
// Old values
$i = 1;
foreach($cdf->getValues() as $key => $value)
{
$this->ctrl->setParameter($this,'del_field',$i - 1);
$this->tpl->setCurrentBlock('values');
$this->ctrl->setParameter($this,'del_field',$i - 1);
$this->tpl->setVariable('DELETE',$this->lng->txt('delete'));
$this->tpl->setVariable('LINK_DELETE',$this->ctrl->getLinkTarget($this,'deleteField'));
$this->tpl->setVariable('FIELD_NAME',ilUtil::prepareFormOutput($value));
$this->tpl->setVariable("TXT_VALUES",$this->lng->txt('ps_cdf_value').' '.($i++));
$this->tpl->parseCurrentBlock();
}
switch($cdf->getType())
{
$this->tpl->setVariable('TXT_SELECT_TYPE',$this->lng->txt('ps_edit_select_field'));
$this->tpl->setVariable('BTN_NEW_VALUE',$this->lng->txt('ps_btn_add_value'));
// New values
for($j = 0; $j < $_SESSION['il_cdf_select_num_values'];$j++)
{
$this->tpl->setCurrentBlock('new_values');
$this->tpl->setVariable('COUNTER',$j);
$this->tpl->setVariable("TXT_NEW_VALUES",$this->lng->txt('ps_cdf_value').' '.($i + $j));
$this->tpl->setVariable("NEW_FIELD_NAME",$_POST['new_field_values'][$j]);
$this->tpl->parseCurrentBlock();
}
break;
$this->tpl->setVariable('TXT_SELECT_TYPE',$this->lng->txt('ps_edit_text_field'));
break;
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilCourseUserFieldsGUI::executeCommand ( )

Execute Command.

public

Definition at line 73 of file class.ilCourseUserFieldsGUI.php.

References $cmd.

{
$cmd = $this->ctrl->getCmd();
switch($next_class = $this->ctrl->getNextClass($this))
{
default:
if(!$cmd)
{
$cmd = 'show';
}
$this->$cmd();
break;
}
}
ilCourseUserFieldsGUI::fieldSelection ( )

Field selection.

public

Definition at line 412 of file class.ilCourseUserFieldsGUI.php.

References $_SESSION, ilUtil\formRadioButton(), IL_CDF_TYPE_SELECT, and IL_CDF_TYPE_TEXT.

{
// number of values defaults to 3
$_SESSION['il_cdf_select_num_values'] = 3;
$this->tpl->addBlockFile('ADM_CONTENT','adm_content','tpl.user_fields_selection.html','Modules/Course');
$this->tpl->setVariable('FORMACTION',$this->ctrl->getFormAction($this));
$this->tpl->setVariable('TXT_SELECT_TYPE',$this->lng->txt('ps_cdf_add_field'));
$this->tpl->setVariable('FIELD_TYPE',$this->lng->txt('ps_field_type'));
$this->tpl->setVariable('TXT_TEXT',$this->lng->txt('ps_type_txt_long'));
$this->tpl->setVariable('TXT_SELECT',$this->lng->txt('ps_type_select_long'));
$this->tpl->setVariable('BTN_MORE',$this->lng->txt('btn_next'));
$this->tpl->setVariable('BTN_CANCEL',$this->lng->txt('cancel'));
$this->tpl->setVariable("TYPE_TEXT",ilUtil::formRadioButton(1,'field_type',IL_CDF_TYPE_TEXT));
$this->tpl->setVariable("TYPE_SELECT",ilUtil::formRadioButton(0,'field_type',IL_CDF_TYPE_SELECT));
}

+ Here is the call graph for this function:

ilCourseUserFieldsGUI::save ( )

Save.

public

Parameters

Definition at line 391 of file class.ilCourseUserFieldsGUI.php.

References $_POST, ilCourseAgreement\_deleteByObjId(), ilCourseDefinedFieldDefinition\_getFields(), ilUtil\sendSuccess(), and show().

{
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->show();
return true;
}

+ Here is the call graph for this function:

ilCourseUserFieldsGUI::saveField ( )

Save New Field.

public

Definition at line 525 of file class.ilCourseUserFieldsGUI.php.

References $_POST, $cdf, chooseDefinitions(), IL_CDF_TYPE_SELECT, IL_CDF_TYPE_TEXT, ilUtil\sendFailure(), ilUtil\sendSuccess(), show(), and ilUtil\stripSlashes().

{
$cdf = new ilCourseDefinedFieldDefinition($this->obj_id);
if(!strlen($_POST['field_name']))
{
ilUtil::sendFailure($this->lng->txt('ps_cdf_no_name_given'));
return false;
}
if($_REQUEST['field_type'] == IL_CDF_TYPE_TEXT)
{
}
else
{
$values = $cdf->prepareValues($_POST['field_values']);
$cdf->setValues($values);
}
$cdf->setName(ilUtil::stripSlashes($_POST['field_name']));
$cdf->enableRequired((int) $_POST['required']);
$cdf->save();
ilUtil::sendSuccess($this->lng->txt('ps_cdf_added_field'));
$this->show();
return true;
}

+ Here is the call graph for this function:

ilCourseUserFieldsGUI::show ( )

Show defined fields.

public

Definition at line 94 of file class.ilCourseUserFieldsGUI.php.

References $_SESSION, ilCourseDefinedFieldDefinition\_getFields(), ilCourseAgreement\_hasAgreementsByObjId(), ilUtil\formCheckbox(), ilUtil\getImagePath(), IL_CDF_TYPE_SELECT, and ilUtil\switchColor().

Referenced by confirmDelete(), delete(), deleteField(), editField(), save(), saveField(), and updateField().

{
unset($_SESSION['il_cdf_delete']);
unset($_SESSION['il_cdf_select_num_values']);
$this->tpl->addBlockFile('ADM_CONTENT','adm_content','tpl.user_fields_list.html','Modules/Course');
$this->tpl->setVariable('FORMACTION',$this->ctrl->getFormAction($this));
$this->tpl->setVariable('TABLE_TITLE',$this->lng->txt('ps_crs_user_fields'));
$this->tpl->setVariable('HEAD_NAME',$this->lng->txt('ps_cdf_name'));
$this->tpl->setVariable('HEAD_TYPE',$this->lng->txt('ps_cdf_type'));
$this->tpl->setVariable('HEAD_REQUIRED',$this->lng->txt('ps_cdf_required'));
$this->tpl->setVariable('ADD',$this->lng->txt('ps_cdf_add_field'));
$this->tpl->setVariable('LINK_ADD',$this->ctrl->getLinkTarget($this,'fieldSelection'));
if(!count($fields))
{
$this->tpl->setCurrentBlock('table_empty');
$this->tpl->setVariable('EMPTY_TXT',$this->lng->txt('ps_cdf_no_fields'));
$this->tpl->parseCurrentBlock();
}
{
$this->tpl->setCurrentBlock('warning_modify');
$this->tpl->setVariable('TXT_WARNING',$this->lng->txt('ps_cdf_warning_modify'));
$this->tpl->parseCurrentBlock();
}
$counter = 0;
foreach($fields as $field_obj)
{
if($field_obj->getType() == IL_CDF_TYPE_SELECT or 1)
{
$this->tpl->setCurrentBlock('show_edit');
$this->ctrl->setParameter($this,'field_id',$field_obj->getId());
$this->tpl->setVariable('EDIT_LINK',$this->ctrl->getLinkTarget($this,'editField'));
$this->ctrl->clearParameters($this);
$this->tpl->setVariable('EDIT',$this->lng->txt('edit'));
$this->tpl->parseCurrentBlock();
}
$this->tpl->setCurrentBlock('table_content');
$this->tpl->setVariable('ROWCOL',ilUtil::switchColor($counter++,'tblrow1','tblrow2'));
$this->tpl->setVariable('CHECKBOX',ilUtil::formCheckbox(0,'field_id[]',$field_obj->getId()));
$this->tpl->setVariable('NAME',$field_obj->getName());
$this->tpl->setVariable('TYPE',$field_obj->getType() == IL_CDF_TYPE_SELECT ?
$this->lng->txt('ps_type_select') :
$this->lng->txt('ps_type_text'));
$this->tpl->setVariable('REQUIRED',ilUtil::formCheckbox((int) $field_obj->isRequired(),'required['.$field_obj->getId().']',1));
$this->tpl->parseCurrentBlock();
}
$this->tpl->setVariable("DOWNRIGHT",ilUtil::getImagePath('arrow_downright.gif'));
$this->tpl->setVariable('BTN_DELETE',$this->lng->txt('delete'));
if(count($fields))
{
$this->tpl->setCurrentBlock('show_save');
$this->tpl->setVariable('BTN_SAVE',$this->lng->txt('save'));
$this->tpl->parseCurrentBlock();
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilCourseUserFieldsGUI::updateField ( )

Update Field.

public

Definition at line 271 of file class.ilCourseUserFieldsGUI.php.

References $_GET, $_POST, $cdf, ilCourseAgreement\_deleteByObjId(), editField(), IL_CDF_TYPE_SELECT, ilUtil\sendFailure(), ilUtil\sendSuccess(), show(), and ilUtil\stripSlashes().

{
if(!$_GET['field_id'])
{
ilUtil::sendFailure('No field given');
$this->show();
return false;
}
$cdf = new ilCourseDefinedFieldDefinition($this->obj_id,$_GET['field_id']);
if(!strlen($_POST['field_name']))
{
ilUtil::sendFailure($this->lng->txt('ps_cdf_no_name_given'));
$this->editField();
return false;
}
switch($cdf->getType())
{
$values = $cdf->prepareValues($_POST['new_field_values']);
$cdf->appendValues($values);
break;
default:
break;
}
$cdf->setName(ilUtil::stripSlashes($_POST['field_name']));
$cdf->enableRequired((int) $_POST['required']);
$cdf->update();
// Finally reset member agreements
ilUtil::sendSuccess($this->lng->txt('settings_saved'));
$this->show();
return true;
}

+ Here is the call graph for this function:

Field Documentation

ilCourseUserFieldsGUI::$cdf
private

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

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

ilCourseUserFieldsGUI::$ctrl
private

Definition at line 39 of file class.ilCourseUserFieldsGUI.php.

ilCourseUserFieldsGUI::$lng
private

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

Referenced by __construct().

ilCourseUserFieldsGUI::$obj_id
private

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

ilCourseUserFieldsGUI::$tabs_gui
private

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

ilCourseUserFieldsGUI::$tpl
private

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

Referenced by __construct().


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