You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
72 lines
1.6 KiB
72 lines
1.6 KiB
![]()
11 years ago
|
<?php
|
||
|
/* For licensing terms, see /license.txt */
|
||
![]()
11 years ago
|
|
||
|
/**
|
||
|
* Manage the course extra fields
|
||
|
* @package chamilo.library
|
||
|
*/
|
||
![]()
11 years ago
|
/**
|
||
|
* Manage the course extra fields
|
||
![]()
11 years ago
|
*
|
||
|
* Add the extra fields to the form excluding the Special Course Field
|
||
![]()
11 years ago
|
*/
|
||
![]()
11 years ago
|
class CourseField extends ExtraField
|
||
|
{
|
||
![]()
11 years ago
|
|
||
![]()
11 years ago
|
/**
|
||
|
* Special Course extra field
|
||
|
*/
|
||
![]()
11 years ago
|
const SPECIAL_COURSE_FIELD = 'special_course';
|
||
|
|
||
![]()
11 years ago
|
/**
|
||
|
* Class constructor
|
||
|
*/
|
||
![]()
11 years ago
|
public function __construct()
|
||
|
{
|
||
![]()
11 years ago
|
parent::__construct('course');
|
||
|
}
|
||
|
|
||
![]()
11 years ago
|
/**
|
||
|
* Add elements to a form
|
||
![]()
11 years ago
|
* @param FormValidator $form the form
|
||
|
* @param string $courseCode The course code
|
||
|
* @return array The extra data. Otherwise return false
|
||
![]()
11 years ago
|
*/
|
||
|
public function addElements($form, $courseCode = null)
|
||
|
{
|
||
|
if (empty($form)) {
|
||
|
return false;
|
||
|
}
|
||
|
|
||
|
$extra_data = false;
|
||
|
if (!empty($courseCode)) {
|
||
|
$extra_data = self::get_handler_extra_data($courseCode);
|
||
|
|
||
|
if ($form) {
|
||
|
$form->setDefaults($extra_data);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
$extra_fields = $this->get_all(null, 'option_order');
|
||
|
|
||
|
$specilCourseFieldId = -1;
|
||
|
|
||
|
foreach ($extra_fields as $id => $extraField) {
|
||
|
if ($extraField['field_variable'] === self::SPECIAL_COURSE_FIELD) {
|
||
|
$specilCourseFieldId = $id;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
if (isset($extra_fields[$specilCourseFieldId])) {
|
||
|
unset($extra_fields[$specilCourseFieldId]);
|
||
|
}
|
||
|
|
||
|
$extra = $this->set_extra_fields_in_form(
|
||
![]()
11 years ago
|
$form, $extra_data, $this->type . '_field', false, false, $extra_fields, $courseCode
|
||
![]()
11 years ago
|
);
|
||
|
|
||
|
return $extra;
|
||
|
}
|
||
![]()
11 years ago
|
|
||
|
}
|