Remove CourseFieldOption, CourseFieldValue, SessionFieldOption, SessionField - refs BT#9070

1.10.x
Angel Fernando Quiroz Campos 10 years ago
parent b50178e607
commit c32175ee0e
  1. 2
      main/admin/course_edit.php
  2. 2
      main/admin/resume_session.php
  3. 30
      main/inc/lib/CourseField.class.php
  4. 8
      main/inc/lib/CourseFieldOption.class.php
  5. 11
      main/inc/lib/CourseFieldValue.class.php
  6. 105
      main/inc/lib/SessionField.class.php
  7. 8
      main/inc/lib/SessionFieldOption.class.php
  8. 2
      main/inc/lib/course.lib.php

@ -233,7 +233,7 @@ $specialCourseField = new CourseField();
$specialCourseFieldInfo = $specialCourseField->get_handler_field_info_by_field_variable('special_course');
if (!empty($specialCourseFieldInfo)) {
$specialCourseValue = new CourseFieldValue();
$specialCourseValue = new ExtraFieldValue('course');
$specialCourseValueInfo = $specialCourseValue->get_values_by_handler_and_field_variable($course_code, 'special_course');
$specialCourseAttributes = array();

@ -217,7 +217,7 @@ echo Display::page_subheader(get_lang('GeneralProperties').$url);
</tr>
<?php
$sessionField = new SessionField();
$sessionField = new ExtraField('session');
$sessionFields = $sessionField->get_all();
foreach ($sessionFields as $field) {

@ -1,15 +1,25 @@
<?php
/* For licensing terms, see /license.txt */
/**
* Manage the course extra fields
*/
class CourseField extends ExtraField {
/**
* Special Course extra field
*/
const SPECIAL_COURSE_FIELD = 'special_course';
/**
* Class constructor
*/
public function __construct() {
parent::__construct('course');
}
/**
* Show the course extra fields
*/
function display() {
// action links
echo '<div class="actions">';
@ -20,6 +30,12 @@ class CourseField extends ExtraField {
echo Display::grid_html('course_fields');
}
/**
* Generate a form
* @param string $url the The form action param
* @param string $action The action. Add or edit
* @return FormValidator The form
*/
public function return_form($url, $action) {
$form = new FormValidator('course_field', 'post', $url);
$id = isset($_GET['id']) ? intval($_GET['id']) : null;
@ -76,7 +92,7 @@ class CourseField extends ExtraField {
$form->addElement('text', 'field_order', get_lang('FieldOrder'), array('class' => 'span1'));
if ($action == 'edit') {
$option = new CourseFieldOption('course');
$option = new ExtraFieldOption('course');
if ($defaults['field_type'] == ExtraField::FIELD_TYPE_DOUBLE_SELECT) {
$form->freeze('field_options');
}
@ -107,11 +123,9 @@ class CourseField extends ExtraField {
/**
* Add elements to a form
*
* @param FormValidator $form
* @param int $courseCode
*
* @return array|bool
* @param FormValidator $form the form
* @param string $courseCode The course code
* @return array The extra data. Otherwise return false
*/
public function addElements($form, $courseCode = null)
{

@ -1,8 +0,0 @@
<?php
/* For licensing terms, see /license.txt */
class CourseFieldOption extends ExtraFieldOption {
public function __construct() {
parent::__construct('course');
}
}

@ -1,11 +0,0 @@
<?php
class CourseFieldValue extends ExtraFieldValue
{
public function __construct()
{
parent::__construct('course');
}
}

@ -1,105 +0,0 @@
<?php
/* For licensing terms, see /license.txt */
class SessionField extends ExtraField {
public function __construct() {
parent::__construct('session');
}
function display() {
// action links
echo '<div class="actions">';
echo '<a href="../admin/index.php">' . Display::return_icon('back.png', get_lang('BackTo') . ' ' . get_lang('PlatformAdmin'), '', ICON_SIZE_MEDIUM) . '</a>';
echo '<a href="' . api_get_self() . '?action=add">' . Display::return_icon('add_user_fields.png', get_lang('Add'), '', ICON_SIZE_MEDIUM) . '</a>';
echo '</div>';
echo Display::grid_html('session_fields');
}
public function return_form($url, $action) {
$form = new FormValidator('session_field', 'post', $url);
$id = isset($_GET['id']) ? intval($_GET['id']) : null;
$form->addElement('hidden', 'id', $id);
// Settting the form elements
$header = get_lang('Add');
$defaults = array();
if ($action == 'edit') {
$header = get_lang('Modify');
// Setting the defaults
$defaults = $this->get($id);
}
$form->addElement('header', $header);
$form->addElement('text', 'field_display_text', get_lang('Name'), array('class' => 'span5'));
// Field type
$types = self::get_field_types();
$form->addElement('select', 'field_type', get_lang('FieldType'), $types, array('id' => 'field_type', 'class' => 'chzn-select', 'data-placeholder' => get_lang('Select')));
$form->addElement('label', get_lang('Example'), '<div id="example">-</div>');
//$form->addElement('advanced_settings','<a class="btn btn-show" id="advanced_parameters" href="javascript://">'.get_lang('AdvancedParameters').'</a>');
//$form->addElement('html','<div id="options" style="display:none">');
$form->addElement('text', 'field_variable', get_lang('FieldLabel'), array('class' => 'span5'));
$form->addElement('text', 'field_options', get_lang('FieldPossibleValues'), array('id' => 'field_options', 'class' => 'span6'));
if ($action == 'edit') {
if (in_array($defaults['field_type'], array(ExtraField::FIELD_TYPE_SELECT, ExtraField::FIELD_TYPE_DOUBLE_SELECT))) {
$url = Display::url(get_lang('EditExtraFieldOptions'), 'extra_field_options.php?type=session&field_id=' . $id);
$form->addElement('label', null, $url);
$form->freeze('field_options');
}
}
$form->addElement('text', 'field_default_value', get_lang('FieldDefaultValue'), array('id' => 'field_default_value', 'class' => 'span5'));
$group = array();
$group[] = $form->createElement('radio', 'field_visible', null, get_lang('Yes'), 1);
$group[] = $form->createElement('radio', 'field_visible', null, get_lang('No'), 0);
$form->addGroup($group, '', get_lang('Visible'), '', false);
$group = array();
$group[] = $form->createElement('radio', 'field_changeable', null, get_lang('Yes'), 1);
$group[] = $form->createElement('radio', 'field_changeable', null, get_lang('No'), 0);
$form->addGroup($group, '', get_lang('FieldChangeability'), '', false);
$group = array();
$group[] = $form->createElement('radio', 'field_filter', null, get_lang('Yes'), 1);
$group[] = $form->createElement('radio', 'field_filter', null, get_lang('No'), 0);
$form->addGroup($group, '', get_lang('FieldFilter'), '', false);
$form->addElement('text', 'field_order', get_lang('FieldOrder'), array('class' => 'span1'));
if ($action == 'edit') {
$option = new SessionFieldOption('session');
if ($defaults['field_type'] == ExtraField::FIELD_TYPE_DOUBLE_SELECT) {
$form->freeze('field_options');
}
$defaults['field_options'] = $option->get_field_options_by_field_to_string($id);
$form->addElement('button', 'submit', get_lang('Modify'), 'class="save"');
} else {
$defaults['field_visible'] = 0;
$defaults['field_changeable'] = 0;
$defaults['field_filter'] = 0;
$form->addElement('button', 'submit', get_lang('Add'), 'class="save"');
}
/*if (!empty($defaults['created_at'])) {
$defaults['created_at'] = api_convert_and_format_date($defaults['created_at']);
}
if (!empty($defaults['updated_at'])) {
$defaults['updated_at'] = api_convert_and_format_date($defaults['updated_at']);
}*/
$form->setDefaults($defaults);
// Setting the rules
$form->addRule('field_display_text', get_lang('ThisFieldIsRequired'), 'required');
//$form->addRule('field_variable', get_lang('ThisFieldIsRequired'), 'required');
$form->addRule('field_type', get_lang('ThisFieldIsRequired'), 'required');
return $form;
}
}

@ -1,8 +0,0 @@
<?php
/* For licensing terms, see /license.txt */
class SessionFieldOption extends ExtraFieldOption {
public function __construct() {
parent::__construct('session');
}
}

@ -132,7 +132,7 @@ class CourseManager
$params['course_code'] = $course_info['code'];
$courseFieldValue = new CourseFieldValue();
$courseFieldValue = new ExtraFieldValue('course');
$courseFieldValue->save_field_values($params);
return $course_info;

Loading…
Cancel
Save