Extra fields - Rename extra_field field_type and extra_field_type to item_type and value_type, "value" in exta_field_values.value to field_value - refs CT#2008 (#4373)

Co-authored-by: Christian <christian1827@gmail.com>
Co-authored-by: Yannick Warnier <ywarnier@users.noreply.github.com>
pull/4393/head
christianbeeznest 3 years ago committed by GitHub
parent a5ded25a39
commit a6857b0c30
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      public/main/admin/legal_add.php
  2. 4
      public/main/admin/sub_language_ajax.inc.php
  3. 2
      public/main/admin/user_list.php
  4. 2
      public/main/auth/inscription.php
  5. 10
      public/main/cron/import_csv.php
  6. 10
      public/main/exercise/question_pool.php
  7. 2
      public/main/extrafield/translate.php
  8. 2
      public/main/extrafield/translate_option.php
  9. 4
      public/main/inc/ajax/model.ajax.php
  10. 2
      public/main/inc/ajax/session.ajax.php
  11. 6
      public/main/inc/lib/CoursesAndSessionsCatalog.class.php
  12. 2
      public/main/inc/lib/SmsPlugin.php
  13. 10
      public/main/inc/lib/course.lib.php
  14. 2
      public/main/inc/lib/display.lib.php
  15. 86
      public/main/inc/lib/extra_field.lib.php
  16. 30
      public/main/inc/lib/extra_field_option.lib.php
  17. 156
      public/main/inc/lib/extra_field_value.lib.php
  18. 12
      public/main/inc/lib/myspace.lib.php
  19. 22
      public/main/inc/lib/sessionmanager.lib.php
  20. 4
      public/main/inc/lib/social.lib.php
  21. 46
      public/main/inc/lib/tracking.lib.php
  22. 26
      public/main/inc/lib/usermanager.lib.php
  23. 4
      public/main/inc/lib/webservices/Rest.php
  24. 38
      public/main/install/data.sql
  25. 2
      public/main/mySpace/session_filter.php
  26. 2
      public/main/search/load_search.php
  27. 2
      public/main/search/search.php
  28. 12
      public/main/session/session_add.php
  29. 2
      public/main/survey/survey.lib.php
  30. 4
      public/main/template/default/social/user_block.html.twig
  31. 2
      public/main/tracking/lp_report.php
  32. 4
      public/main/user/subscribe_user.php
  33. 4
      public/main/webservices/api/tests/CreateSessionFromModelTest.php
  34. 4
      public/main/webservices/api/tests/GetSessionFromExtraFieldTest.php
  35. 2
      public/main/webservices/api/tests/UpdateUserFromUsernameTest.php
  36. 6
      public/main/webservices/registration.soap.php
  37. 6
      public/main/work/work.lib.php
  38. 4
      public/plugin/advanced_subscription/src/AdvancedSubscriptionPlugin.php
  39. 38
      public/plugin/advanced_subscription/src/scripts/insert_session_fields.php
  40. 14
      public/plugin/bbb/README.md
  41. 4
      public/plugin/buycourses/database.php
  42. 2
      public/plugin/createdrupaluser/src/CreateDrupalUser.php
  43. 2
      public/plugin/customcertificate/src/export_pdf_all_in_one.php
  44. 6
      public/plugin/exercise_signature/lib/ExerciseSignature.php
  45. 2
      public/plugin/google_maps/src/map_coordinates.php
  46. 8
      public/plugin/grading_electronic/src/GradingElectronicPlugin.php
  47. 64
      public/plugin/learning_calendar/LearningCalendarPlugin.php
  48. 2
      public/plugin/questionoptionsevaluation/QuestionOptionsEvaluationPlugin.php
  49. 10
      public/plugin/whispeakauth/WhispeakAuthPlugin.php
  50. 2
      src/CoreBundle/Controller/CourseController.php
  51. 2
      src/CoreBundle/Controller/SessionController.php
  52. 84
      src/CoreBundle/DataFixtures/ExtraFieldFixtures.php
  53. 26
      src/CoreBundle/Entity/ExtraField.php
  54. 12
      src/CoreBundle/Entity/ExtraFieldValues.php
  55. 6
      src/CoreBundle/Filter/UserExtraFieldFilter.php
  56. 16
      src/CoreBundle/Form/ExtraFieldType.php
  57. 5
      src/CoreBundle/Migrations/Schema/V200/Version20.php
  58. 4
      src/CoreBundle/Migrations/Schema/V200/Version20180319145700.php
  59. 2
      src/CoreBundle/Migrations/Schema/V200/Version20181025064351.php
  60. 4
      src/CoreBundle/Migrations/Schema/V200/Version20191206150030.php
  61. 2
      src/CoreBundle/Migrations/Schema/V200/Version20201212195011.php
  62. 2
      src/CoreBundle/Repository/ExtraFieldRepository.php
  63. 6
      src/CoreBundle/Repository/ExtraFieldValuesRepository.php
  64. 4
      tests/CoreBundle/Repository/ExtraFieldOptionsRepositoryTest.php
  65. 14
      tests/CoreBundle/Repository/ExtraFieldRepositoryTest.php
  66. 12
      tests/CoreBundle/Repository/ExtraFieldValuesRepositoryTest.php
  67. 16
      tests/CoreBundle/Repository/TagRepositoryTest.php
  68. 2
      tests/behat/features/extraFieldUser.feature
  69. 38
      tests/scripts/check_extra_fields.php
  70. 38
      tests/scripts/insert_session_fields.php
  71. 4
      tests/scripts/userfields_to_groups.php

@ -33,7 +33,7 @@ foreach ($types as $variable => $name) {
$params = [
'variable' => $variable,
'display_text' => $label,
'field_type' => ExtraField::FIELD_TYPE_TEXTAREA,
'value_type' => ExtraField::FIELD_TYPE_TEXTAREA,
'default_value' => '',
'visible' => true,
'changeable' => true,

@ -61,10 +61,10 @@ if (isset($new_language) && isset($language_variable) && isset($file_id)) {
Display::addFlash($message);
if (isset($_REQUEST['extra_field_type'])) {
if (isset($_REQUEST['item_type'])) {
$redirectUrl = api_get_path(WEB_CODE_PATH).'admin/extra_fields.php';
switch ($_REQUEST['extra_field_type']) {
switch ($_REQUEST['item_type']) {
case ExtraField::USER_FIELD_TYPE:
header("Location: {$redirectUrl}?type=user");
exit;

@ -366,7 +366,7 @@ function prepare_user_sql_query($getCount)
if (empty($value)) {
continue;
}
if (ExtraField::FIELD_TYPE_TAG == $info['field_type']) {
if (ExtraField::FIELD_TYPE_TAG == $info['value_type']) {
$result = $extraField->getAllUserPerTag($info['id'], $value);
$result = empty($result) ? [] : array_column($result, 'user_id');
} else {

@ -121,7 +121,7 @@ if ($extraConditions && isset($extraConditions['conditions'])) {
$exists = $userExtraField->get_handler_field_info_by_field_variable($condition['variable']);
if (false == $exists) {
$params = [
'field_type' => ExtraField::FIELD_TYPE_CHECKBOX,
'value_type' => ExtraField::FIELD_TYPE_CHECKBOX,
'variable' => $condition['variable'],
'display_text' => $condition['display_text'],
'default_value' => '',

@ -488,7 +488,7 @@ class ImportCsv
$extraField = new ExtraField('calendar_event');
$extraField->save(
[
'field_type' => ExtraField::FIELD_TYPE_TEXT,
'value_type' => ExtraField::FIELD_TYPE_TEXT,
'variable' => $this->extraFieldIdNameList['calendar_event'],
'display_text' => 'External calendar event id',
]
@ -498,7 +498,7 @@ class ImportCsv
$extraField->save(
[
'visible_to_self' => 1,
'field_type' => ExtraField::FIELD_TYPE_TEXT,
'value_type' => ExtraField::FIELD_TYPE_TEXT,
'variable' => $this->extraFieldIdNameList['career'],
'display_text' => 'External career id',
]
@ -507,7 +507,7 @@ class ImportCsv
$extraField->save(
[
'visible_to_self' => 1,
'field_type' => ExtraField::FIELD_TYPE_TEXTAREA,
'value_type' => ExtraField::FIELD_TYPE_TEXTAREA,
'variable' => $this->extraFieldIdNameList['career_diagram'],
'display_text' => 'Career diagram',
]
@ -516,7 +516,7 @@ class ImportCsv
$extraField->save(
[
'visible_to_self' => 1,
'field_type' => ExtraField::FIELD_TYPE_TEXTAREA,
'value_type' => ExtraField::FIELD_TYPE_TEXTAREA,
'variable' => $this->extraFieldIdNameList['career_urls'],
'display_text' => 'Career urls',
]
@ -1667,7 +1667,7 @@ class ImportCsv
if (!empty($eventId)) {
$extraFieldValue->save(
[
'value' => $externalEventId,
'field_value' => $externalEventId,
'field_id' => $extraFieldInfo['id'],
'item_id' => $eventId,
]

@ -524,7 +524,7 @@ function getExtraFieldConditions(array $formValues, $queryType = 'from')
$value = $formValues["extra_$variable"];
switch ($field['field_type']) {
switch ($field['value_type']) {
case ExtraField::FIELD_TYPE_CHECKBOX:
$value = $value["extra_$variable"];
break;
@ -547,17 +547,17 @@ function getExtraFieldConditions(array $formValues, $queryType = 'from')
$where .= "AND (
qu.iid = efv_$variable.item_id
AND efv_$variable.field_id = ef_$variable.id
AND ef_$variable.extra_field_type = ".ExtraFieldEntity::QUESTION_FIELD_TYPE."
AND ef_$variable.item_type = ".ExtraFieldEntity::QUESTION_FIELD_TYPE."
AND ef_$variable.variable = '$variable'
AND efv_$variable.value = '$value'
AND efv_$variable.field_value = '$value'
)";
} elseif ('join' === $queryType) {
$from .= " INNER JOIN extra_field_values efv_$variable ON qu.iid = efv_$variable.item_id
INNER JOIN extra_field ef_$variable ON efv_$variable.field_id = ef_$variable.id";
$where .= "AND (
ef_$variable.extra_field_type = ".ExtraFieldEntity::QUESTION_FIELD_TYPE."
ef_$variable.item_type = ".ExtraFieldEntity::QUESTION_FIELD_TYPE."
AND ef_$variable.variable = '$variable'
AND efv_$variable.value = '$value'
AND efv_$variable.field_value = '$value'
)";
}
}

@ -55,7 +55,7 @@ $form->addButtonSave(get_lang('Save'));
$interbreadcrumb[] = ['url' => api_get_path(WEB_CODE_PATH).'admin', 'name' => get_lang('Administration')];
$type = \ExtraField::getExtraFieldTypeFromInt($extraField->getExtraFieldType());
$type = \ExtraField::getExtraFieldTypeFromInt($extraField->getItemType());
$interbreadcrumb[] = [
'url' => api_get_path(WEB_CODE_PATH).'admin/extra_fields.php?type='.$type,

@ -56,7 +56,7 @@ $form->addButtonSave(get_lang('Save'));
$interbreadcrumb[] = ['url' => api_get_path(WEB_CODE_PATH).'admin', 'name' => get_lang('Administration')];
$type = \ExtraField::getExtraFieldTypeFromInt($extraField->getExtraFieldType());
$type = \ExtraField::getExtraFieldTypeFromInt($extraField->getItemType());
$interbreadcrumb[] = [
'url' => api_get_path(WEB_CODE_PATH).'admin/extra_fields.php?type='.$type,

@ -2347,7 +2347,7 @@ switch ($action) {
$columns = [
'display_text',
'variable',
'field_type',
'value_type',
'changeable',
'visible_to_self',
'visible_to_others',
@ -2368,7 +2368,7 @@ switch ($action) {
);
foreach ($result as $item) {
$item['display_text'] = $item['displayText'];
$item['field_type'] = $obj->get_field_type_by_id($item['fieldType']);
$item['value_type'] = $obj->get_field_type_by_id($item['valueType']);
$item['changeable'] = $item['changeable'] ? $checkIcon : $timesIcon;
$item['visible_to_self'] = $item['visibleToSelf'] ? $checkIcon : $timesIcon;
$item['visible_to_others'] = $item['visibleToOthers'] ? $checkIcon : $timesIcon;

@ -150,7 +150,7 @@ switch ($action) {
'id' => $extra['id'],
'variable' => $extra['variable'],
'value' => '',
'field_type' => $extra['field_type'],
'value_type' => $extra['value_type'],
];
}
}

@ -85,7 +85,7 @@ class CoursesAndSessionsCatalog
INNER JOIN $TABLE_COURSE_FIELD tcf
ON tcfv.field_id = tcf.id
WHERE
tcf.extra_field_type = $extraFieldType AND
tcf.item_type = $extraFieldType AND
tcf.variable = 'hide_from_catalog' AND
tcfv.value = 1
";
@ -875,7 +875,7 @@ class CoursesAndSessionsCatalog
$qb->expr()->like('t.tag', ':tag')
)
->andWhere(
$qb->expr()->eq('f.extraFieldType', ExtraField::COURSE_FIELD_TYPE)
$qb->expr()->eq('f.itemType', ExtraField::COURSE_FIELD_TYPE)
)
->andWhere($qb->expr()->gt('s.nbrCourses', 0))
->andWhere($qb->expr()->eq('url.accessUrlId', $urlId))
@ -1569,7 +1569,7 @@ class CoursesAndSessionsCatalog
$tagRepo = \Chamilo\CoreBundle\Framework\Container::getTagRepository();
$tagsField = $extraFieldRepo->findOneBy([
'extraFieldType' => Chamilo\CoreBundle\Entity\ExtraField::COURSE_FIELD_TYPE,
'itemType' => Chamilo\CoreBundle\Entity\ExtraField::COURSE_FIELD_TYPE,
'variable' => 'tags',
]);

@ -129,7 +129,7 @@ class SmsPlugin extends Plugin
if (empty($extraFieldInfo)) {
$extraField->save([
'field_type' => 1,
'value_type' => 1,
'variable' => 'mobile_phone_number',
'display_text' => $this->get_lang('mobile_phone_number'),
'default_value' => null,

@ -898,7 +898,7 @@ class CourseManager
WHERE
variable = '$original_course_id_name' AND
value = '$original_course_id_value' AND
cf.extra_field_type = $extraFieldType
cf.item_type = $extraFieldType
";
$res = Database::query($sql);
$row = Database::fetch_object($res);
@ -2687,7 +2687,7 @@ class CourseManager
// get course list auto-register
$sql = "SELECT id FROM $tbl_course_field
WHERE extra_field_type = $extraFieldType AND
WHERE item_type = $extraFieldType AND
variable = 'special_course'";
$result = Database::query($sql);
$courseList = [];
@ -3000,7 +3000,7 @@ class CourseManager
$extraField = new ExtraField('course');
$params = [
'variable' => $variable,
'field_type' => $fieldType,
'value_type' => $fieldType,
'display_text' => $displayText,
'default_value' => $default,
];
@ -4735,7 +4735,7 @@ class CourseManager
INNER JOIN $courseTable c
ON (c.id = tcfv.item_id)
WHERE
tcf.extra_field_type = $extraFieldType AND
tcf.item_type = $extraFieldType AND
tcf.variable = 'popular_courses' AND
tcfv.value = 1 AND
visibility <> ".Course::CLOSED." AND
@ -6305,7 +6305,7 @@ class CourseManager
FROM $tableUserFieldValues v
INNER JOIN $tableExtraFields f
ON (f.id = v.field_id)
WHERE value = '$name' AND extra_field_type = $extraFieldType";
WHERE value = '$name' AND item_type = $extraFieldType";
$result_count = Database::query($sql);
if (Database::num_rows($result_count)) {
$row_count = Database::fetch_array($result_count);

@ -1472,7 +1472,7 @@ class Display
'variable' => $value->getField()->getVariable(),
'display_text' => $value->getField()->getDisplayText(),
],
'value' => $value->getValue(),
'value' => $value->getFieldValue(),
];
}

@ -40,7 +40,7 @@ class ExtraField extends Model
public $columns = [
'id',
'field_type',
'value_type',
'variable',
'description',
'display_text',
@ -50,7 +50,7 @@ class ExtraField extends Model
'visible_to_others',
'changeable',
'filter',
'extra_field_type',
'item_type',
//Enable this when field_loggeable is introduced as a table field (2.0)
//'field_loggeable',
'created_at',
@ -76,7 +76,7 @@ class ExtraField extends Model
public $type = 'user';
public $pageName;
public $pageUrl;
public $extraFieldType = 0;
public $itemType = 0;
public $table_field_options;
public $table_field_values;
public $table_field_tag;
@ -98,7 +98,7 @@ class ExtraField extends Model
$this->table_field_tag = Database::get_main_table(TABLE_MAIN_TAG);
$this->table_field_rel_tag = Database::get_main_table(TABLE_MAIN_EXTRA_FIELD_REL_TAG);
$this->handler_id = 'item_id';
$this->extraFieldType = self::getExtraFieldTypeFromString($this->type);
$this->itemType = self::getExtraFieldTypeFromString($this->type);
switch ($this->type) {
case 'session':
@ -549,8 +549,8 @@ class ExtraField extends Model
$em = Database::getManager();
$query = $em->getRepository(EntityExtraField::class)->createQueryBuilder('e');
$query->select('count(e.id)');
$query->where('e.extraFieldType = :type');
$query->setParameter('type', $this->getExtraFieldType());
$query->where('e.itemType = :type');
$query->setParameter('type', $this->getItemType());
return $query->getQuery()->getSingleScalarResult();
}
@ -558,9 +558,9 @@ class ExtraField extends Model
/**
* @return int
*/
public function getExtraFieldType()
public function getItemType()
{
return (int) $this->extraFieldType;
return (int) $this->itemType;
}
/**
@ -599,8 +599,8 @@ class ExtraField extends Model
$em = Database::getManager();
$query = $em->getRepository(EntityExtraField::class)->createQueryBuilder('e');
$query->select('e')
->where('e.extraFieldType = :type')
->setParameter('type', $this->getExtraFieldType())
->where('e.itemType = :type')
->setParameter('type', $this->getItemType())
->orderBy($sidx, $sord)
->setFirstResult($start)
->setMaxResults($limit);
@ -621,7 +621,7 @@ class ExtraField extends Model
$sql = "SELECT * FROM {$this->table}
WHERE
variable = '$variable' AND
extra_field_type = $this->extraFieldType";
item_type = $this->itemType";
$result = Database::query($sql);
$extraFieldRepo = Container::getExtraFieldRepository();
if (Database::num_rows($result)) {
@ -657,7 +657,7 @@ class ExtraField extends Model
$sql = "SELECT * FROM {$this->table}
WHERE
id = '$fieldId' AND
extra_field_type = $this->extraFieldType";
item_type = $this->itemType";
$result = Database::query($sql);
if (Database::num_rows($result)) {
$row = Database::fetch_array($result, 'ASSOC');
@ -809,7 +809,7 @@ class ExtraField extends Model
$field['id']
);
if (self::FIELD_TYPE_TAG == $field['field_type']) {
if (self::FIELD_TYPE_TAG == $field['value_type']) {
$tags = UserManager::get_user_tags_to_string(
$itemId,
$field['id'],
@ -822,8 +822,8 @@ class ExtraField extends Model
if ($field_value) {
$variable = $field['variable'];
$field_value = $field_value['value'];
switch ($field['field_type']) {
$field_value = $field_value['field_value'];
switch ($field['value_type']) {
case self::FIELD_TYPE_FILE_IMAGE:
case self::FIELD_TYPE_FILE:
// Get asset id
@ -894,9 +894,9 @@ class ExtraField extends Model
$options = Database::parse_conditions(['where' => $options]);
if (empty($options)) {
$options .= ' WHERE extra_field_type = '.$this->extraFieldType;
$options .= ' WHERE item_type = '.$this->itemType;
} else {
$options .= ' AND extra_field_type = '.$this->extraFieldType;
$options .= ' AND item_type = '.$this->itemType;
}
$sql = "SELECT * FROM $this->table
@ -1049,7 +1049,7 @@ class ExtraField extends Model
}
}
switch ($field_details['field_type']) {
switch ($field_details['value_type']) {
case self::FIELD_TYPE_TEXT:
$form->addElement(
'text',
@ -1856,8 +1856,8 @@ class ExtraField extends Model
// all the information of the field
$sql = "SELECT * FROM {$this->table}
WHERE
field_type = '".Database::escape_string($type)."' AND
extra_field_type = $this->extraFieldType
value_type = '".Database::escape_string($type)."' AND
item_type = $this->itemType
";
$result = Database::query($sql);
@ -1947,7 +1947,7 @@ class ExtraField extends Model
{
$fieldInfo = self::get_handler_field_info_by_field_variable($params['variable']);
$params = $this->clean_parameters($params);
$params['extra_field_type'] = $this->extraFieldType;
$params['item_type'] = $this->itemType;
if ($fieldInfo) {
return $fieldInfo['id'];
@ -1974,7 +1974,7 @@ class ExtraField extends Model
$sql = "SELECT * FROM {$this->table}
WHERE
variable = '$variable' AND
extra_field_type = $this->extraFieldType";
item_type = $this->itemType";
$result = Database::query($sql);
if (Database::num_rows($result)) {
$extraFieldRepo = Container::getExtraFieldRepository();
@ -2032,7 +2032,7 @@ class ExtraField extends Model
$sql = "SELECT MAX(field_order)
FROM {$this->table}
WHERE
extra_field_type = '.$this->extraFieldType.'";
item_type = '.$this->itemType.'";
$res = Database::query($sql);
$order = 0;
@ -2053,8 +2053,8 @@ class ExtraField extends Model
if (isset($params['id'])) {
$fieldOption = new ExtraFieldOption($this->type);
$params['field_id'] = $params['id'];
if (empty($params['field_type'])) {
$params['field_type'] = $this->type;
if (empty($params['value_type'])) {
$params['value_type'] = $this->type;
}
$fieldOption->save($params, $showQuery);
}
@ -2167,8 +2167,8 @@ class ExtraField extends Model
'sortable' => 'true',
],
[
'name' => 'field_type',
'index' => 'field_type',
'name' => 'value_type',
'index' => 'value_type',
'width' => '70',
'align' => 'left',
'sortable' => 'true',
@ -2268,7 +2268,7 @@ class ExtraField extends Model
$types = self::get_field_types();
$form->addSelect(
'field_type',
'value_type',
get_lang('Field type'),
$types,
['id' => 'field_type']
@ -2293,7 +2293,7 @@ class ExtraField extends Model
];
if ('edit' === $action) {
if (in_array($defaults['field_type'], $fieldWithOptions)) {
if (in_array($defaults['value_type'], $fieldWithOptions)) {
$url = Display::url(
get_lang('Edit extra field options'),
'extra_field_options.php?type='.$this->type.'&field_id='.$id,
@ -2301,7 +2301,7 @@ class ExtraField extends Model
);
$form->addElement('label', null, $url);
if (self::FIELD_TYPE_SELECT == $defaults['field_type']) {
if (self::FIELD_TYPE_SELECT == $defaults['value_type']) {
$urlWorkFlow = Display::url(
get_lang('Edit this field\'s workflow'),
'extra_field_workflow.php?type='.$this->type.'&field_id='.$id,
@ -2371,7 +2371,7 @@ class ExtraField extends Model
// Setting the rules
$form->addRule('display_text', get_lang('Required field'), 'required');
$form->addRule('field_type', get_lang('Required field'), 'required');
$form->addRule('value_type', get_lang('Required field'), 'required');
return $form;
}
@ -2453,7 +2453,7 @@ JAVASCRIPT;
foreach ($fields as $field) {
$search_options = [];
$type = 'text';
if (in_array($field['field_type'], [self::FIELD_TYPE_SELECT, self::FIELD_TYPE_DOUBLE_SELECT])) {
if (in_array($field['value_type'], [self::FIELD_TYPE_SELECT, self::FIELD_TYPE_DOUBLE_SELECT])) {
$type = 'select';
$search_options['sopt'] = ['eq', 'ne']; //equal not equal
} else {
@ -2465,7 +2465,7 @@ JAVASCRIPT;
? $search_options['field_default_value']
: null;
if (self::FIELD_TYPE_DOUBLE_SELECT == $field['field_type']) {
if (self::FIELD_TYPE_DOUBLE_SELECT == $field['value_type']) {
// Add 2 selects
$options = $extraFieldOption->get_field_options_by_field($field['id']);
$options = self::extra_field_double_select_convert_array_to_ordered_array($options);
@ -2561,7 +2561,7 @@ JAVASCRIPT;
}
$extraFieldsAll = $this->get_all(['visible_to_self = ? AND filter = ?' => [1, 1]], 'option_order');
$extraFieldsType = array_column($extraFieldsAll, 'field_type', 'variable');
$extraFieldsType = array_column($extraFieldsAll, 'value_type', 'variable');
$extraFields = array_column($extraFieldsAll, 'variable');
$filter = new stdClass();
$defaults = [];
@ -2672,7 +2672,7 @@ JAVASCRIPT;
$original_field = str_replace($stringToSearch, '', $rule->field);
$field_option = $this->get_handler_field_info_by_field_variable($original_field);
switch ($field_option['field_type']) {
switch ($field_option['value_type']) {
case self::FIELD_TYPE_DOUBLE_SELECT:
if (isset($double_select[$rule->field])) {
$data = explode('#', $rule->data);
@ -2811,7 +2811,7 @@ JAVASCRIPT;
}
$extra['extra_field_info'] = $extra_field_info;
switch ($extra_field_info['field_type']) {
switch ($extra_field_info['value_type']) {
case self::FIELD_TYPE_SELECT:
case self::FIELD_TYPE_DOUBLE_SELECT:
$inject_extra_fields .= " fvo$counter.display_text as {$extra['field']}, ";
@ -2843,7 +2843,7 @@ JAVASCRIPT;
$info = $this->get($extra['id']);
$extra_fields_info[$extra['id']] = $info;
}
if (isset($info['field_type']) && self::FIELD_TYPE_DOUBLE_SELECT == $info['field_type']) {
if (isset($info['value_type']) && self::FIELD_TYPE_DOUBLE_SELECT == $info['value_type']) {
$double_fields[$info['id']] = $info;
}
$counter++;
@ -2877,7 +2877,7 @@ JAVASCRIPT;
$inject_joins .= " INNER JOIN $this->table_field_values fv$counter
ON ($alias.".$this->primaryKey." = fv$counter.".$this->handler_id.') ';
// Add options
switch ($extra_field_info['field_type']) {
switch ($extra_field_info['value_type']) {
case self::FIELD_TYPE_SELECT:
case self::FIELD_TYPE_DOUBLE_SELECT:
$options['where'] = str_replace(
@ -2988,7 +2988,7 @@ JAVASCRIPT;
$fieldValue = new ExtraFieldValue($this->type);
$valueData = $fieldValue->get_values_by_handler_and_field_id($itemId, $field['id'], true);
$fieldType = (int) $field['field_type'];
$fieldType = (int) $field['value_type'];
if (self::FIELD_TYPE_TAG === $fieldType) {
$tags = $repoTag->findBy(['field' => $field['id'], 'itemId' => $itemId]);
if ($tags) {
@ -3010,13 +3010,13 @@ JAVASCRIPT;
switch ($fieldType) {
case self::FIELD_TYPE_CHECKBOX:
$displayedValue = get_lang('No');
if (false !== $valueData && '1' == $valueData['value']) {
if (false !== $valueData && '1' == $valueData['field_value']) {
$displayedValue = get_lang('Yes');
}
break;
case self::FIELD_TYPE_DATE:
if (false !== $valueData && !empty($valueData['value'])) {
$displayedValue = api_format_date($valueData['value'], DATE_FORMAT_LONG_NO_DAY);
if (false !== $valueData && !empty($valueData['field_value'])) {
$displayedValue = api_format_date($valueData['field_value'], DATE_FORMAT_LONG_NO_DAY);
}
break;
case self::FIELD_TYPE_TAG:
@ -3065,7 +3065,7 @@ JAVASCRIPT;
}
break;
default:
$displayedValue = $valueData['value'];
$displayedValue = $valueData['field_value'];
break;
}

@ -62,7 +62,7 @@ class ExtraFieldOption extends Model
if (empty($fieldId)) {
return false;
}
$extraFieldType = $this->getExtraField()->getExtraFieldType();
$extraFieldType = $this->getExtraField()->getItemType();
$fieldId = (int) $fieldId;
$sql = "SELECT count(*) as count
@ -71,7 +71,7 @@ class ExtraFieldOption extends Model
ON o.field_id = e.id
WHERE
o.field_id = $fieldId AND
e.extra_field_type = $extraFieldType ";
e.item_type = $extraFieldType ";
$result = Database::query($sql);
$result = Database::fetch_array($result);
@ -167,7 +167,7 @@ class ExtraFieldOption extends Model
}
$parseOptions = in_array(
$params['field_type'],
$params['value_type'],
[
ExtraField::FIELD_TYPE_RADIO,
ExtraField::FIELD_TYPE_SELECT,
@ -182,7 +182,7 @@ class ExtraFieldOption extends Model
return true;
}
switch ($params['field_type']) {
switch ($params['value_type']) {
case ExtraField::FIELD_TYPE_DOUBLE_SELECT:
//$params['field_options'] = France:Paris;Bretagne;Marseilles;Lyon|Belgique:Bruxelles;Namur;Liège;Bruges|Peru:Lima;Piura;
case ExtraField::FIELD_TYPE_SELECT_WITH_TEXT_FIELD:
@ -216,7 +216,7 @@ class ExtraFieldOption extends Model
parent::update($new_params, $showQuery);
}
if (ExtraField::FIELD_TYPE_SELECT_WITH_TEXT_FIELD == $params['field_type']) {
if (ExtraField::FIELD_TYPE_SELECT_WITH_TEXT_FIELD == $params['value_type']) {
continue;
}
@ -410,7 +410,7 @@ class ExtraFieldOption extends Model
{
$field_id = (int) $field_id;
$option_value = Database::escape_string($option_value);
$extraFieldType = $this->getExtraField()->getExtraFieldType();
$extraFieldType = $this->getExtraField()->getItemType();
$sql = "SELECT s.* FROM {$this->table} s
INNER JOIN {$this->tableExtraField} sf
@ -418,7 +418,7 @@ class ExtraFieldOption extends Model
WHERE
field_id = $field_id AND
option_value = '".$option_value."' AND
sf.extra_field_type = $extraFieldType
sf.item_type = $extraFieldType
";
$result = Database::query($sql);
if (Database::num_rows($result) > 0) {
@ -441,7 +441,7 @@ class ExtraFieldOption extends Model
{
$field_id = (int) $field_id;
$option_display_text = Database::escape_string($option_display_text);
$extraFieldType = $this->getExtraField()->getExtraFieldType();
$extraFieldType = $this->getExtraField()->getItemType();
$sql = "SELECT s.* FROM {$this->table} s
INNER JOIN {$this->tableExtraField} sf
@ -449,7 +449,7 @@ class ExtraFieldOption extends Model
WHERE
field_id = $field_id AND
s.display_text = '".$option_display_text."' AND
sf.extra_field_type = $extraFieldType
sf.item_type = $extraFieldType
";
$result = Database::query($sql);
if (Database::num_rows($result) > 0) {
@ -477,7 +477,7 @@ class ExtraFieldOption extends Model
$field_id = (int) $field_id;
$option_display_text = Database::escape_string($option_display_text);
$option_value = Database::escape_string($option_value);
$extraFieldType = $this->getExtraField()->getExtraFieldType();
$extraFieldType = $this->getExtraField()->getItemType();
$sql = "SELECT s.* FROM {$this->table} s
INNER JOIN {$this->tableExtraField} sf
@ -486,7 +486,7 @@ class ExtraFieldOption extends Model
field_id = $field_id AND
sf.display_text = '".$option_display_text."' AND
option_value = '$option_value' AND
sf.extra_field_type = ".$extraFieldType."
sf.item_type = ".$extraFieldType."
";
$result = Database::query($sql);
if (Database::num_rows($result) > 0) {
@ -626,7 +626,7 @@ class ExtraFieldOption extends Model
$options = self::get_field_options_by_field($field_id, false, $ordered_by);
$elements = [];
if (!empty($options)) {
switch ($field_info['field_type']) {
switch ($field_info['value_type']) {
case ExtraField::FIELD_TYPE_DOUBLE_SELECT:
$html = ExtraField::extra_field_double_select_convert_array_to_string($options);
break;
@ -887,16 +887,16 @@ class ExtraFieldOption extends Model
*/
public function getOptionsByFieldVariable($variable)
{
$extraFieldType = $this->getExtraField()->getExtraFieldType();
$extraFieldType = $this->getExtraField()->getItemType();
$dql = "SELECT o FROM ChamiloCoreBundle:ExtraFieldOptions o
INNER JOIN ChamiloCoreBundle:ExtraField f WITH o.field = f.id
WHERE f.variable = :variable AND f.extraFieldType = :extra_field_type
WHERE f.variable = :variable AND f.itemType = :item_type
ORDER BY o.value ASC";
$result = Database::getManager()
->createQuery($dql)
->setParameters(['variable' => $variable, 'extra_field_type' => $extraFieldType])
->setParameters(['variable' => $variable, 'item_type' => $extraFieldType])
->getResult();
return $result;

@ -22,7 +22,7 @@ class ExtraFieldValue extends Model
public $columns = [
'id',
'field_id',
'value',
'field_value',
'comment',
'item_id',
'asset_id',
@ -70,8 +70,8 @@ class ExtraFieldValue extends Model
$em = Database::getManager();
$query = $em->getRepository(ExtraFieldValues::class)->createQueryBuilder('e');
$query->select('count(e.id)');
$query->where('e.extraFieldType = :type');
$query->setParameter('type', $this->getExtraField()->getExtraFieldType());
$query->where('e.itemType = :type');
$query->setParameter('type', $this->getExtraField()->getItemType());
return $query->getQuery()->getSingleScalarResult();
}
@ -116,7 +116,7 @@ class ExtraFieldValue extends Model
return false;
}
$type = $this->getExtraField()->getExtraFieldType();
$type = $this->getExtraField()->getItemType();
$extraField = new ExtraField($this->type);
$extraFields = $extraField->get_all([], 'option_order');
@ -171,7 +171,7 @@ class ExtraFieldValue extends Model
$commentVariable = 'extra_'.$field_variable.'_comment';
$comment = $params[$commentVariable] ?? null;
switch ($extraFieldInfo['field_type']) {
switch ($extraFieldInfo['value_type']) {
case ExtraField::FIELD_TYPE_GEOLOCALIZATION_COORDINATES:
case ExtraField::FIELD_TYPE_GEOLOCALIZATION:
if (!empty($value)) {
@ -181,7 +181,7 @@ class ExtraFieldValue extends Model
$newParams = [
'item_id' => $params['item_id'],
'field_id' => $extraFieldInfo['id'],
'value' => $value,
'field_value' => $value,
'comment' => $comment,
];
self::save($newParams, $showQuery);
@ -281,7 +281,7 @@ class ExtraFieldValue extends Model
$extraFieldValues = (new ExtraFieldValues())
->setItemId((int) $params['item_id'])
->setField($field)
->setValue(1)
->setFieldValue(1)
->setAsset($asset)
->setComment($comment ?? '')
;
@ -317,7 +317,7 @@ class ExtraFieldValue extends Model
$extraFieldValues = (new ExtraFieldValues())
->setItemId((int) $params['item_id'])
->setField($field)
->setValue(1)
->setFieldValue(1)
->setAsset($asset)
->setComment($comment ?? '')
;
@ -338,7 +338,7 @@ class ExtraFieldValue extends Model
$newParams = [
'item_id' => $params['item_id'],
'field_id' => $extraFieldInfo['id'],
'value' => $fieldToSave,
'field_value' => $fieldToSave,
'comment' => $comment,
];
$this->save($newParams);
@ -351,7 +351,7 @@ class ExtraFieldValue extends Model
$newParams = [
'item_id' => $params['item_id'],
'field_id' => $extraFieldInfo['id'],
'value' => $value,
'field_value' => $value,
'comment' => $comment,
];
$this->save($newParams, $showQuery);
@ -364,7 +364,7 @@ class ExtraFieldValue extends Model
$newParams = [
'item_id' => $params['item_id'],
'field_id' => $extraFieldInfo['id'],
'value' => $value,
'field_value' => $value,
'comment' => $comment,
];
$this->save($newParams, $showQuery);
@ -374,7 +374,7 @@ class ExtraFieldValue extends Model
$newParams = [
'item_id' => $params['item_id'],
'field_id' => $extraFieldInfo['id'],
'value' => $value,
'field_value' => $value,
'comment' => $comment,
];
$this->save($newParams, $showQuery);
@ -427,7 +427,7 @@ class ExtraFieldValue extends Model
$extra_field = $this->getExtraField();
// Setting value to insert.
$value = $params['value'];
$value = $params['field_value'];
$value_to_insert = null;
if (is_array($value)) {
@ -436,7 +436,7 @@ class ExtraFieldValue extends Model
$value_to_insert = $value;
}
$params['value'] = $value_to_insert;
$params['field_value'] = $value_to_insert;
// If field id exists
if (isset($params['field_id'])) {
@ -452,7 +452,7 @@ class ExtraFieldValue extends Model
}
if ($extraFieldInfo) {
switch ($extraFieldInfo['field_type']) {
switch ($extraFieldInfo['value_type']) {
case ExtraField::FIELD_TYPE_RADIO:
case ExtraField::FIELD_TYPE_SELECT:
break;
@ -493,7 +493,7 @@ class ExtraFieldValue extends Model
break;
}
if (ExtraField::FIELD_TYPE_TAG == $extraFieldInfo['field_type']) {
if (ExtraField::FIELD_TYPE_TAG == $extraFieldInfo['value_type']) {
$field_values = self::getAllValuesByItemAndFieldAndValue(
$params['item_id'],
$params['field_id'],
@ -506,7 +506,7 @@ class ExtraFieldValue extends Model
);
}
$params['value'] = $value_to_insert;
$params['field_value'] = $value_to_insert;
//$params['author_id'] = api_get_user_id();
// Insert
@ -514,20 +514,20 @@ class ExtraFieldValue extends Model
/* Enable this when field_loggeable is introduced as a table field (2.0)
if ($extraFieldInfo['field_loggeable'] == 1) {
*/
if (ExtraField::FIELD_TYPE_TAG == $extraFieldInfo['field_type']) {
if (ExtraField::FIELD_TYPE_TAG == $extraFieldInfo['value_type']) {
$option = new ExtraFieldOption($this->type);
$optionExists = $option->get($params['value']);
if (empty($optionExists)) {
$optionParams = [
'field_id' => $params['field_id'],
'option_value' => $params['value'],
'option_value' => $params['field_value'],
];
$optionId = $option->saveOptions($optionParams);
} else {
$optionId = $optionExists['id'];
}
$params['value'] = $optionId;
$params['field_value'] = $optionId;
if ($optionId) {
return parent::save($params, $showQuery);
}
@ -561,23 +561,23 @@ class ExtraFieldValue extends Model
$field_id = (int) $field_id;
$item_id = Database::escape_string($item_id);
$sql = "SELECT s.*, field_type FROM {$this->table} s
$sql = "SELECT s.*, value_type FROM {$this->table} s
INNER JOIN {$this->table_handler_field} sf
ON (s.field_id = sf.id)
WHERE
item_id = '$item_id' AND
field_id = $field_id AND
sf.extra_field_type = ".$this->getExtraField()->getExtraFieldType()."
sf.item_type = ".$this->getExtraField()->getItemType()."
ORDER BY id";
$result = Database::query($sql);
if (Database::num_rows($result)) {
$result = Database::fetch_array($result, 'ASSOC');
if ($transform) {
if (!empty($result['value'])) {
switch ($result['field_type']) {
if (!empty($result['field_value'])) {
switch ($result['value_type']) {
case ExtraField::FIELD_TYPE_DOUBLE_SELECT:
$field_option = new ExtraFieldOption($this->type);
$options = explode('::', $result['value']);
$options = explode('::', $result['field_value']);
// only available for PHP 5.4 :( $result['field_value'] = $field_option->get($options[0])['id'].' -> ';
$result = $field_option->get($options[0]);
$result_second = $field_option->get($options[1]);
@ -587,7 +587,7 @@ class ExtraFieldValue extends Model
}
break;
case ExtraField::FIELD_TYPE_SELECT_MULTIPLE:
$optionIds = explode(';', $result['value']);
$optionIds = explode(';', $result['field_value']);
$optionValues = [];
$objEfOption = new ExtraFieldOption($this->type);
$options = $objEfOption->get_field_options_by_field($result['field_id']);
@ -608,7 +608,7 @@ class ExtraFieldValue extends Model
$field_option = new ExtraFieldOption($this->type);
$extra_field_option_result = $field_option->get_field_option_by_field_and_option(
$result['field_id'],
$result['value']
$result['field_value']
);
if (isset($extra_field_option_result[0])) {
@ -617,7 +617,7 @@ class ExtraFieldValue extends Model
break;
case ExtraField::FIELD_TYPE_SELECT_WITH_TEXT_FIELD:
$options = explode('::', $result['value']);
$options = explode('::', $result['field_value']);
$field_option = new ExtraFieldOption($this->type);
$result = $field_option->get($options[0]);
@ -626,7 +626,7 @@ class ExtraFieldValue extends Model
}
break;
case ExtraField::FIELD_TYPE_TRIPLE_SELECT:
$optionIds = explode(';', $result['value']);
$optionIds = explode(';', $result['field_value']);
$optionValues = [];
foreach ($optionIds as $optionId) {
$objEfOption = new ExtraFieldOption($this->type);
@ -659,17 +659,17 @@ class ExtraFieldValue extends Model
$limit = (int) $limit;
$tag = Database::escape_string($tag);
$extraFieldType = $this->getExtraField()->getExtraFieldType();
$extraFieldType = $this->getExtraField()->getItemType();
$sql = "SELECT DISTINCT s.value, s.field_id
$sql = "SELECT DISTINCT s.field_value, s.field_id
FROM {$this->table} s
INNER JOIN {$this->table_handler_field} sf
ON (s.field_id = sf.id)
WHERE
field_id = $field_id AND
value LIKE '%$tag%' AND
sf.extra_field_type = ".$extraFieldType."
ORDER BY value
field_value LIKE '%$tag%' AND
sf.item_type = ".$extraFieldType."
ORDER BY field_value
LIMIT 0, $limit
";
$result = Database::query($sql);
@ -703,16 +703,16 @@ class ExtraFieldValue extends Model
) {
$item_id = (int) $item_id;
$field_variable = Database::escape_string($field_variable);
$extraFieldType = $this->getExtraField()->getExtraFieldType();
$extraFieldType = $this->getExtraField()->getItemType();
$sql = "SELECT s.*, field_type
$sql = "SELECT s.*, value_type
FROM {$this->table} s
INNER JOIN {$this->table_handler_field} sf
ON (s.field_id = sf.id)
WHERE
item_id = '$item_id' AND
variable = '".$field_variable."' AND
sf.extra_field_type = $extraFieldType
sf.item_type = $extraFieldType
";
if ($filterByVisibility) {
$visibility = (int) $visibility;
@ -726,11 +726,11 @@ class ExtraFieldValue extends Model
if (Database::num_rows($result)) {
$result = Database::fetch_array($result, 'ASSOC');
if ($transform) {
$fieldType = $result['field_type'];
$fieldType = $result['value_type'];
if (ExtraField::FIELD_TYPE_DOUBLE_SELECT == $fieldType) {
if (!empty($result['value'])) {
if (!empty($result['field_value'])) {
$field_option = new ExtraFieldOption($this->type);
$options = explode('::', $result['value']);
$options = explode('::', $result['field_value']);
$result = $field_option->get($options[0]);
$result_second = $field_option->get($options[1]);
if (!empty($result)) {
@ -740,8 +740,8 @@ class ExtraFieldValue extends Model
}
}
if (ExtraField::FIELD_TYPE_SELECT_WITH_TEXT_FIELD == $fieldType) {
if (!empty($result['value'])) {
$options = explode('::', $result['value']);
if (!empty($result['field_value'])) {
$options = explode('::', $result['field_value']);
$field_option = new ExtraFieldOption($this->type);
$result = $field_option->get($options[0]);
if (!empty($result)) {
@ -752,8 +752,8 @@ class ExtraFieldValue extends Model
}
}
if (ExtraField::FIELD_TYPE_TRIPLE_SELECT == $fieldType) {
if (!empty($result['value'])) {
$optionIds = explode(';', $result['value']);
if (!empty($result['field_value'])) {
$optionIds = explode(';', $result['field_value']);
$optionValues = [];
foreach ($optionIds as $optionId) {
$objEfOption = new ExtraFieldOption('user');
@ -766,7 +766,7 @@ class ExtraFieldValue extends Model
}
}
if (in_array($result['field_type'], ExtraField::getExtraFieldTypesWithFiles())) {
if (in_array($result['value_type'], ExtraField::getExtraFieldTypesWithFiles())) {
$result['url'] = '';
if (!empty($result['asset_id'])) {
$asset = $repo->find($result['asset_id']);
@ -808,11 +808,11 @@ class ExtraFieldValue extends Model
$value = Database::escape_string($value);
$variable = Database::escape_string($variable);
$valueCondition = " value = '$value' AND ";
$valueCondition = " field_value = '$value' AND ";
if ($useLike) {
$valueCondition = " value LIKE '%".$value."%' AND ";
$valueCondition = " field_value LIKE '%".$value."%' AND ";
}
$extraFieldType = $this->getExtraField()->getExtraFieldType();
$extraFieldType = $this->getExtraField()->getItemType();
$sql = "SELECT item_id FROM {$this->table} s
INNER JOIN {$this->table_handler_field} sf
@ -820,7 +820,7 @@ class ExtraFieldValue extends Model
WHERE
$valueCondition
variable = '".$variable."' AND
sf.extra_field_type = $extraFieldType
sf.item_type = $extraFieldType
ORDER BY item_id
";
@ -854,15 +854,15 @@ class ExtraFieldValue extends Model
public function getValuesByFieldId($fieldId)
{
$fieldId = (int) $fieldId;
$extraFieldType = $this->getExtraField()->getExtraFieldType();
$extraFieldType = $this->getExtraField()->getItemType();
$sql = "SELECT s.* FROM {$this->table} s
INNER JOIN {$this->table_handler_field} sf
ON (s.field_id = sf.id)
WHERE
field_id = '".$fieldId."' AND
sf.extra_field_type = $extraFieldType
ORDER BY s.value";
sf.item_type = $extraFieldType
ORDER BY s.field_value";
$result = Database::query($sql);
if (Database::num_rows($result)) {
@ -882,7 +882,7 @@ class ExtraFieldValue extends Model
{
$fieldId = (int) $fieldId;
$itemId = (int) $itemId;
$extraFieldType = $this->getExtraField()->getExtraFieldType();
$extraFieldType = $this->getExtraField()->getItemType();
$sql = "SELECT s.* FROM {$this->table} s
INNER JOIN {$this->table_handler_field} sf
@ -890,8 +890,8 @@ class ExtraFieldValue extends Model
WHERE
field_id = $fieldId AND
item_id = $itemId AND
sf.extra_field_type = $extraFieldType
ORDER BY s.value";
sf.item_type = $extraFieldType
ORDER BY s.field_value";
$result = Database::query($sql);
if (Database::num_rows($result)) {
@ -909,16 +909,16 @@ class ExtraFieldValue extends Model
public function getAllValuesByItem($itemId)
{
$itemId = (int) $itemId;
$extraFieldType = $this->getExtraField()->getExtraFieldType();
$extraFieldType = $this->getExtraField()->getItemType();
$sql = "SELECT s.value, sf.variable, sf.field_type, sf.id, sf.display_text
$sql = "SELECT s.field_value, sf.variable, sf.value_type, sf.id, sf.display_text
FROM {$this->table} s
INNER JOIN {$this->table_handler_field} sf
ON (s.field_id = sf.id)
WHERE
item_id = '$itemId' AND
sf.extra_field_type = $extraFieldType
ORDER BY s.value";
sf.item_type = $extraFieldType
ORDER BY s.field_value";
$result = Database::query($sql);
$idList = [];
@ -928,7 +928,7 @@ class ExtraFieldValue extends Model
$repo = Container::getAssetRepository();
foreach ($result as $item) {
$fieldType = (int) $item['field_type'];
$fieldType = (int) $item['value_type'];
$item['url'] = '';
if (!empty($item['asset_id']) &&
in_array($fieldType, ExtraField::getExtraFieldTypesWithFiles(), true)
@ -950,7 +950,7 @@ class ExtraFieldValue extends Model
$allData = $extraField->get_all(['filter = ?' => 1]);
$allResults = [];
foreach ($allData as $field) {
$fieldType = (int) $field['field_type'];
$fieldType = (int) $field['value_type'];
if (in_array($field['id'], $idList)) {
$allResults[] = $finalResult[$field['id']];
} else {
@ -976,7 +976,7 @@ class ExtraFieldValue extends Model
$allResults[] = [
'value' => $tagResult,
'variable' => $field['variable'],
'field_type' => $field['field_type'],
'value_type' => $field['value_type'],
'id' => $field['id'],
];
}
@ -997,7 +997,7 @@ class ExtraFieldValue extends Model
{
$fieldId = (int) $fieldId;
$itemId = (int) $itemId;
$extraFieldType = $this->getExtraField()->getExtraFieldType();
$extraFieldType = $this->getExtraField()->getItemType();
$fieldValue = Database::escape_string($fieldValue);
$sql = "SELECT s.* FROM {$this->table} s
@ -1006,9 +1006,9 @@ class ExtraFieldValue extends Model
WHERE
field_id = '$fieldId' AND
item_id = '$itemId' AND
value = '$fieldValue' AND
sf.extra_field_type = $extraFieldType
ORDER BY value";
field_value = '$fieldValue' AND
sf.item_type = $extraFieldType
ORDER BY field_value";
$result = Database::query($sql);
if (Database::num_rows($result)) {
@ -1043,19 +1043,19 @@ class ExtraFieldValue extends Model
public function deleteValuesByItem($itemId)
{
$itemId = (int) $itemId;
$extraFieldType = $this->getExtraField()->getExtraFieldType();
$sql = "SELECT DISTINCT fv.id, value, field_type FROM {$this->table} fv
$extraFieldType = $this->getExtraField()->getItemType();
$sql = "SELECT DISTINCT fv.id, field_value, value_type FROM {$this->table} fv
INNER JOIN {$this->table_handler_field} f
ON (fv.field_id = f.id)
WHERE extra_field_type = $extraFieldType AND item_id = $itemId";
WHERE item_type = $extraFieldType AND item_id = $itemId";
$result = Database::query($sql);
$result = Database::store_result($result, 'ASSOC');
$em = Database::getManager();
$repo = Container::getAssetRepository();
foreach ($result as $item) {
$fieldType = (int) $item['field_type'];
$valueType = (int) $item['value_type'];
if (!empty($item['asset_id']) &&
in_array($fieldType, ExtraField::getExtraFieldTypesWithFiles(), true)
in_array($valueType, ExtraField::getExtraFieldTypesWithFiles(), true)
) {
$asset = $repo->find($item['asset_id']);
if ($asset) {
@ -1070,7 +1070,7 @@ class ExtraFieldValue extends Model
item_id = '$itemId' AND
field_id IN (
SELECT id FROM {$this->table_handler_field}
WHERE extra_field_type = $extraFieldType
WHERE item_type = $extraFieldType
)
";
Database::query($sql);
@ -1095,13 +1095,13 @@ class ExtraFieldValue extends Model
WHERE
item_id = '$itemId' AND
field_id = '$fieldId' AND
value = '$fieldValue'
field_value = '$fieldValue'
";
Database::query($sql);
// Delete file from uploads.
if (isset($fieldData['asset_id']) &&
in_array($fieldData['field_type'], ExtraField::getExtraFieldTypesWithFiles())
in_array($fieldData['value_type'], ExtraField::getExtraFieldTypesWithFiles())
) {
$repo = Container::getAssetRepository();
$asset = $repo->find($fieldData['asset_id']);
@ -1136,7 +1136,7 @@ class ExtraFieldValue extends Model
$qb->expr()->eq('fv.itemId', ':item')
)
->andWhere(
$qb->expr()->eq('f.extraFieldType', ':extra_field_type')
$qb->expr()->eq('f.itemType', ':item_type')
);
if (is_bool($visibleToSelf)) {
@ -1153,7 +1153,7 @@ class ExtraFieldValue extends Model
$fieldValues = $qb
->setParameter('item', $itemId)
->setParameter('extra_field_type', $this->getExtraField()->getExtraFieldType())
->setParameter('item_type', $this->getExtraField()->getItemType())
->getQuery()
->getResult();
@ -1163,11 +1163,11 @@ class ExtraFieldValue extends Model
/** @var ExtraFieldValues $fieldValue */
foreach ($fieldValues as $fieldValue) {
$item = ['value' => $fieldValue];
switch ($fieldValue->getField()->getFieldType()) {
switch ($fieldValue->getField()->getValueType()) {
case ExtraField::FIELD_TYPE_SELECT:
$item['option'] = $fieldOptionsRepo->findOneBy([
'field' => $fieldValue->getField(),
'value' => $fieldValue->getValue(),
'value' => $fieldValue->getFieldValue(),
]);
break;
}

@ -565,9 +565,9 @@ class MySpace
$sql_session_coach = "SELECT u.id AS user_id, u.lastname, u.firstname, MAX(tel.login_date) AS login_date
FROM $tbl_user u
INNER JOIN $tbl_track_login tel
INNER JOIN $tbl_track_login tel
ON tel.login_user_id = u.id
INNER JOIN $tblSessionRelUser sru
INNER JOIN $tblSessionRelUser sru
ON (u.id = sru.user_id AND sru.relation_type = ".SessionEntity::GENERAL_COACH.")
GROUP BY u.id
ORDER BY login_date $tracking_direction";
@ -578,11 +578,11 @@ class MySpace
if (-1 != $access_url_id) {
$sql_session_coach = "SELECT u.id AS user_id, u.lastname, u.firstname, MAX(tel.login_date) AS login_date
FROM $tbl_user u
INNER JOIN $tbl_track_login tel
INNER JOIN $tbl_track_login tel
ON tel.login_user_id = u.id
INNER JOIN $tblSessionRelUser sru
INNER JOIN $tblSessionRelUser sru
ON (u.id = sru.user_id AND sru.relation_type = ".SessionEntity::GENERAL_COACH.")
INNER JOIN $tbl_session_rel_access_url aurs
INNER JOIN $tbl_session_rel_access_url aurs
ON sru.session_id = aurs.session_id
WHERE aurs.access_url_id = $access_url_id
GROUP BY u.id
@ -959,7 +959,7 @@ class MySpace
WHERE
variable = 'authors'
)
AND sf.extra_field_type = ".ExtraField::FIELD_TYPE_DATE."
AND sf.item_type = ".ExtraField::FIELD_TYPE_DATE."
AND (s.value != '' OR s.value IS NOT NULL)
";
$queryResult = Database::query($query);

@ -2910,14 +2910,14 @@ class SessionManager
*/
public static function create_session_extra_field(
$variable,
$fieldType,
$valueType,
$displayText,
$default = ''
) {
$extraField = new ExtraFieldModel('session');
$params = [
'variable' => $variable,
'field_type' => $fieldType,
'value_type' => $valueType,
'display_text' => $displayText,
'default_value' => $default,
];
@ -7283,9 +7283,9 @@ class SessionManager
$wherePublication = " AND id NOT IN (
SELECT sfv.item_id FROM $joinTable
WHERE
sf.extra_field_type = $extraFieldType AND
((sf.variable = 'publication_start_date' AND sfv.value > '$publicationDateString' and sfv.value != '') OR
(sf.variable = 'publication_end_date' AND sfv.value < '$publicationDateString' and sfv.value != ''))
sf.item_type = $extraFieldType AND
((sf.variable = 'publication_start_date' AND sfv.field_value > '$publicationDateString' and sfv.field_value != '') OR
(sf.variable = 'publication_end_date' AND sfv.field_value < '$publicationDateString' and sfv.field_value != ''))
)";
}
// Get the session list from session category and target
@ -7297,10 +7297,10 @@ class SessionManager
"session_category_id = ? AND id IN (
SELECT sfv.item_id FROM $joinTable
WHERE
sf.extra_field_type = $extraFieldType AND
sf.item_type = $extraFieldType AND
sfv.item_id = session.id AND
sf.variable = 'target' AND
sfv.value = ?
sfv.field_value = ?
) $wherePublication" => [$categoryId, $target],
],
]
@ -7452,7 +7452,7 @@ class SessionManager
$sessionFieldList = Database::select(
'id, variable',
$sessionFieldTable,
['extra_field_type = ? ' => [$extraFieldType]]
['item_type = ? ' => [$extraFieldType]]
);
// Get all field values
@ -7461,7 +7461,7 @@ class SessionManager
ON (f.id = v.field_id)
WHERE
item_id IN $sessionIdsString AND
extra_field_type = $extraFieldType
item_type = $extraFieldType
";
$result = Database::query($sql);
$sessionFieldValueList = Database::store_result($result, 'ASSOC');
@ -7600,7 +7600,7 @@ class SessionManager
SELECT item_id
FROM $sfvTable v INNER JOIN $extraFieldTable e
ON (v.field_id = e.id)
WHERE value LIKE %?% AND extra_field_type = $extraFieldType
WHERE field_value LIKE %?% AND item_type = $extraFieldType
) " => $term,
],
]);
@ -8845,7 +8845,7 @@ class SessionManager
$extra_fields_info[$extra['id']] = $info;
}
if (ExtraFieldModel::FIELD_TYPE_DOUBLE_SELECT == $info['field_type']) {
if (ExtraFieldModel::FIELD_TYPE_DOUBLE_SELECT == $info['value_type']) {
$double_fields[$info['id']] = $info;
}
}

@ -1375,7 +1375,7 @@ class SocialManager extends UserManager
}
if (is_array($data)) {
switch ($extraFieldInfo['field_type']) {
switch ($extraFieldInfo['value_type']) {
case ExtraField::FIELD_TYPE_RADIO:
$objEfOption = new ExtraFieldOption('user');
$value = $data['extra_'.$extraFieldInfo['variable']];
@ -1411,7 +1411,7 @@ class SocialManager extends UserManager
break;
}
} else {
switch ($extraFieldInfo['field_type']) {
switch ($extraFieldInfo['value_type']) {
case ExtraField::FIELD_TYPE_RADIO:
$objEfOption = new ExtraFieldOption('user');
$optionInfo = $objEfOption->get_field_option_by_field_and_option($extraFieldInfo['id'], $extraFieldInfo['value']);

@ -3576,31 +3576,31 @@ class Tracking
// Then, courses where $coach_id is coach of the session
$sql = "SELECT srcru.user_id
FROM $tbl_session_course_user srcru
INNER JOIN $tbl_session_course src
INNER JOIN $tbl_session_course src
ON (srcru.c_id = src.c_id AND srcru.session_id = src.session_id)
INNER JOIN $tbl_session s
INNER JOIN $tbl_session s
ON srcru.session_id = s.id AND src.session_id = s.id
INNER JOIN $tbl_session_user sru on s.id = sru.session_id
WHERE
srcru.status = ".SessionEntity::STUDENT." AND
WHERE
srcru.status = ".SessionEntity::STUDENT." AND
sru.relation_type = ".SessionEntity::GENERAL_COACH." AND
sru.user_id = $coach_id";
if (-1 != $access_url_id) {
$sql = "SELECT srcru.user_id
FROM $tbl_session_course_user srcru
INNER JOIN $tbl_session_course src
INNER JOIN $tbl_session_course src
ON (srcru.c_id = src.c_id AND srcru.session_id = src.session_id)
INNER JOIN $tbl_session s
INNER JOIN $tbl_session s
ON srcru.session_id = s.id AND src.session_id = s.id
INNER JOIN $tbl_session_user sru
INNER JOIN $tbl_session_user sru
ON s.id = sru.session_id
INNER JOIN $tbl_session_rel_access_url aurs
INNER JOIN $tbl_session_rel_access_url aurs
ON s.id = aurs.session_id
WHERE
WHERE
srcru.status = ".SessionEntity::STUDENT." AND
sru.relation_type = ".SessionEntity::GENERAL_COACH." AND
sru.user_id = $coach_id AND
sru.user_id = $coach_id AND
aurs.access_url_id = $access_url_id";
}
@ -3641,13 +3641,13 @@ class Tracking
// Then, courses where $coach_id is coach of the session
$sql = "SELECT srcru.user_id
FROM $tbl_session_course_user srcru
INNER JOIN $tbl_session_course src
INNER JOIN $tbl_session_course src
ON (srcru.c_id = src.c_id AND srcru.session_id = src.session_id)
INNER JOIN $tbl_session s
INNER JOIN $tbl_session s
ON srcru.session_id = s.id AND src.session_id = s.id
INNER JOIN $tblSessionRelUser sru
INNER JOIN $tblSessionRelUser sru
ON s.id = sru.session_id
WHERE
WHERE
(srcru.status = ".SessionEntity::STUDENT." AND srcru.user_id = $student_id) AND
(sru.relation_type = ".SessionEntity::GENERAL_COACH." AND sru.user_id = $coach_id)";
$result = Database::query($sql);
@ -8049,13 +8049,13 @@ class TrackingCourseLog
$sql = "SELECT s.id, s.name, u.name
FROM $tbl_thematic t
INNER JOIN $tblSessionRelUser sru
INNER JOIN $tblSessionRelUser sru
ON t.session_id = sru.session_id
INNER JOIN $table_session s
INNER JOIN $table_session s
ON sru.session_id = s.id
INNER JOIN $table_user u
INNER JOIN $table_user u
ON sru.user_id = u.id
WHERE
WHERE
t.c_id = $course_id AND
t.id = $thematic_id AND
sru.relation_type = ".SessionEntity::GENERAL_COACH;
@ -8366,7 +8366,7 @@ class TrackingCourseLog
$result_extra_field = UserManager::get_extra_field_information($field_id);
$return = [];
if (!empty($users)) {
if (UserManager::USER_FIELD_TYPE_TAG == $result_extra_field['field_type']) {
if (UserManager::USER_FIELD_TYPE_TAG == $result_extra_field['value_type']) {
foreach ($users as $user_id) {
$user_result = UserManager::get_user_tags($user_id, $field_id);
$tag_list = [];
@ -8390,7 +8390,7 @@ class TrackingCourseLog
INNER JOIN $extraField f
ON (f.id = v.field_id)
WHERE
f.extra_field_type = $extraFieldType AND
f.item_type = $extraFieldType AND
v.field_id=".intval($field_id)." AND
user.id IN ($users)";
@ -8399,7 +8399,7 @@ class TrackingCourseLog
// get option value for field type double select by id
if (!empty($row['value'])) {
if (ExtraField::FIELD_TYPE_DOUBLE_SELECT ==
$result_extra_field['field_type']
$result_extra_field['value_type']
) {
$id_double_select = explode(';', $row['value']);
if (is_array($id_double_select)) {
@ -8409,7 +8409,7 @@ class TrackingCourseLog
}
}
if (ExtraField::FIELD_TYPE_SELECT_WITH_TEXT_FIELD == $result_extra_field['field_type']) {
if (ExtraField::FIELD_TYPE_SELECT_WITH_TEXT_FIELD == $result_extra_field['value_type']) {
$parsedValue = explode('::', $row['value']);
if ($parsedValue) {
@ -8420,7 +8420,7 @@ class TrackingCourseLog
}
}
if (ExtraField::FIELD_TYPE_TRIPLE_SELECT == $result_extra_field['field_type']) {
if (ExtraField::FIELD_TYPE_TRIPLE_SELECT == $result_extra_field['value_type']) {
[$level1, $level2, $level3] = explode(';', $row['value']);
$row['value'] = $result_extra_field['options'][$level1]['display_text'].' / ';

@ -1249,8 +1249,8 @@ class UserManager
ON ufv.field_id = uf.id
WHERE
variable = '$original_user_id_name' AND
value = '$original_user_id_value' AND
extra_field_type = $extraFieldType
field_value = '$original_user_id_value' AND
item_type = $extraFieldType
";
$res = Database::query($sql);
$row = Database::fetch_object($res);
@ -2061,7 +2061,7 @@ class UserManager
$columns = [
'id',
'variable',
'field_type',
'value_type',
'display_text',
'default_value',
'field_order',
@ -2073,7 +2073,7 @@ class UserManager
$sort_direction = strtoupper($direction);
}
$extraFieldType = EntityExtraField::USER_FIELD_TYPE;
$sqlf = "SELECT * FROM $t_uf WHERE extra_field_type = $extraFieldType ";
$sqlf = "SELECT * FROM $t_uf WHERE item_type = $extraFieldType ";
if (!$all_visibility) {
$sqlf .= " AND visible_to_self = 1 ";
}
@ -2091,7 +2091,7 @@ class UserManager
$fields[$rowf['id']] = [
0 => $rowf['id'],
1 => $rowf['variable'],
2 => $rowf['field_type'],
2 => $rowf['value_type'],
3 => empty($rowf['display_text']) ? '' : $rowf['display_text'],
4 => $rowf['default_value'],
5 => $rowf['field_order'],
@ -2134,14 +2134,14 @@ class UserManager
*/
public static function create_extra_field(
$variable,
$fieldType,
$valueType,
$displayText,
$default
) {
$extraField = new ExtraField('user');
$params = [
'variable' => $variable,
'field_type' => $fieldType,
'value_type' => $valueType,
'display_text' => $displayText,
'default_value' => $default,
];
@ -2190,10 +2190,10 @@ class UserManager
$extra_data = [];
$t_uf = Database::get_main_table(TABLE_EXTRA_FIELD);
$t_ufv = Database::get_main_table(TABLE_EXTRA_FIELD_VALUES);
$sql = "SELECT f.id as id, f.variable as fvar, f.field_type as type
$sql = "SELECT f.id as id, f.variable as fvar, f.value_type as type
FROM $t_uf f
WHERE
extra_field_type = ".EntityExtraField::USER_FIELD_TYPE."
item_type = ".EntityExtraField::USER_FIELD_TYPE."
";
$filter_cond = '';
@ -2283,7 +2283,7 @@ class UserManager
$t_uf = Database::get_main_table(TABLE_EXTRA_FIELD);
$t_ufv = Database::get_main_table(TABLE_EXTRA_FIELD_VALUES);
$sql = "SELECT f.id as id, f.variable as fvar, f.field_type as type
$sql = "SELECT f.id as id, f.variable as fvar, f.value_type as type
FROM $t_uf f
WHERE f.variable = '$field_variable' ";
@ -2291,17 +2291,17 @@ class UserManager
$sql .= " AND f.visible_to_self = 1 ";
}
$sql .= " AND extra_field_type = ".EntityExtraField::USER_FIELD_TYPE;
$sql .= " AND item_type = ".EntityExtraField::USER_FIELD_TYPE;
$sql .= " ORDER BY f.field_order ";
$res = Database::query($sql);
if (Database::num_rows($res) > 0) {
while ($row = Database::fetch_array($res)) {
$sqlu = "SELECT value as fval FROM $t_ufv v
$sqlu = "SELECT field_value as fval FROM $t_ufv v
INNER JOIN $t_uf f
ON (v.field_id = f.id)
WHERE
extra_field_type = ".EntityExtraField::USER_FIELD_TYPE." AND
item_type = ".EntityExtraField::USER_FIELD_TYPE." AND
field_id = ".$row['id']." AND
item_id = ".$user_id;
$resu = Database::query($sqlu);

@ -127,7 +127,7 @@ class Rest extends WebService
$extraField->save(
[
'variable' => self::EXTRA_FIELD_GCM_REGISTRATION,
'field_type' => ExtraField::FIELD_TYPE_TEXT,
'value_type' => ExtraField::FIELD_TYPE_TEXT,
'display_text' => self::EXTRA_FIELD_GCM_REGISTRATION,
]
);
@ -788,7 +788,7 @@ class Rest extends WebService
$extraValue = $extra['value'];
$result['extra'][] = [
'title' => $extraValue->getField()->getDisplayText(),
'value' => $extraValue->getValue(),
'value' => $extraValue->getFieldValue(),
];
}

@ -79,23 +79,23 @@ UPDATE language SET parent_id = 45 WHERE english_name = 'trad_chinese';
-- ('PC Skills','PC',NULL,2,0,'TRUE','TRUE'),
-- ('Projects','PROJ',NULL,3,0,'TRUE','TRUE');
INSERT INTO extra_field (extra_field_type, field_type, variable, display_text, visible_to_self, changeable, created_at) VALUES (1, 1, 'legal_accept','Legal',0,0, NOW());
INSERT INTO extra_field (extra_field_type, field_type, variable, display_text, visible_to_self, changeable, created_at) VALUES (1, 1, 'already_logged_in','Already logged in',0,0, NOW());
INSERT INTO extra_field (extra_field_type, field_type, variable, display_text, visible_to_self, changeable, created_at) VALUES (1, 1, 'update_type','Update script type',0,0, NOW());
INSERT INTO extra_field (extra_field_type, field_type, variable, display_text, visible_to_self, changeable, created_at) VALUES (1, 10, 'tags','tags',0,0, NOW());
INSERT INTO extra_field (extra_field_type, field_type, variable, display_text, visible_to_self, changeable, created_at) VALUES (1, 1, 'rssfeeds','RSS',0,0, NOW());
INSERT INTO extra_field (extra_field_type, field_type, variable, display_text, visible_to_self, changeable, created_at) VALUES (1, 1, 'dashboard', 'Dashboard', 0, 0, NOW());
INSERT INTO extra_field (extra_field_type, field_type, variable, display_text, visible_to_self, changeable, created_at) VALUES (1, 11, 'timezone', 'Timezone', 0, 0, NOW());
INSERT INTO extra_field (extra_field_type, field_type, variable, display_text, visible_to_self, changeable, default_value, created_at) values (1, 4, 'mail_notify_invitation', 'MailNotifyInvitation',0,1,'1', NOW());
INSERT INTO extra_field (extra_field_type, field_type, variable, display_text, visible_to_self, changeable, default_value, created_at) values (1, 4, 'mail_notify_message', 'MailNotifyMessage',0,1,'1', NOW());
INSERT INTO extra_field (extra_field_type, field_type, variable, display_text, visible_to_self, changeable, default_value, created_at) values (1, 4, 'mail_notify_group_message','MailNotifyGroupMessage',0,1,'1', NOW());
INSERT INTO extra_field (extra_field_type, field_type, variable, display_text, visible_to_self, changeable, created_at) VALUES (1, 1, 'user_chat_status','User chat status',0,0, NOW());
INSERT INTO extra_field (extra_field_type, field_type, variable, display_text, visible_to_self, changeable, created_at) VALUES (1, 1, 'google_calendar_url','Google Calendar URL',0,0, NOW());
INSERT INTO extra_field (extra_field_type, field_type, variable, display_text, visible_to_self, changeable, default_value, created_at) VALUES (2, 13, 'special_course', 'Special course', 1 , 1, '', NOW());
INSERT INTO extra_field (extra_field_type, field_type, variable, display_text, visible_to_self, changeable, created_at) VALUES (2, 10, 'tags', 'Tags', 1, 1, NOW());
INSERT INTO extra_field (extra_field_type, field_type, variable, display_text, visible_to_self, changeable, created_at) VALUES (2, 19, 'video_url', 'VideoUrl', 1, 1, NOW());
INSERT INTO extra_field (extra_field_type, field_type, variable, display_text, visible_to_self, changeable, created_at) VALUES (3, 16, 'image', 'Image', 1, 1, NOW());
INSERT INTO extra_field (extra_field_type, field_type, variable, display_text, visible_to_self, changeable, created_at) VALUES (1, 1, 'captcha_blocked_until_date', 'Account locked until', 0, 0, NOW());
INSERT INTO extra_field (item_type, value_type, variable, display_text, visible_to_self, changeable, created_at) VALUES (1, 1, 'legal_accept','Legal',0,0, NOW());
INSERT INTO extra_field (item_type, value_type, variable, display_text, visible_to_self, changeable, created_at) VALUES (1, 1, 'already_logged_in','Already logged in',0,0, NOW());
INSERT INTO extra_field (item_type, value_type, variable, display_text, visible_to_self, changeable, created_at) VALUES (1, 1, 'update_type','Update script type',0,0, NOW());
INSERT INTO extra_field (item_type, value_type, variable, display_text, visible_to_self, changeable, created_at) VALUES (1, 10, 'tags','tags',0,0, NOW());
INSERT INTO extra_field (item_type, value_type, variable, display_text, visible_to_self, changeable, created_at) VALUES (1, 1, 'rssfeeds','RSS',0,0, NOW());
INSERT INTO extra_field (item_type, value_type, variable, display_text, visible_to_self, changeable, created_at) VALUES (1, 1, 'dashboard', 'Dashboard', 0, 0, NOW());
INSERT INTO extra_field (item_type, value_type, variable, display_text, visible_to_self, changeable, created_at) VALUES (1, 11, 'timezone', 'Timezone', 0, 0, NOW());
INSERT INTO extra_field (item_type, value_type, variable, display_text, visible_to_self, changeable, default_value, created_at) values (1, 4, 'mail_notify_invitation', 'MailNotifyInvitation',0,1,'1', NOW());
INSERT INTO extra_field (item_type, value_type, variable, display_text, visible_to_self, changeable, default_value, created_at) values (1, 4, 'mail_notify_message', 'MailNotifyMessage',0,1,'1', NOW());
INSERT INTO extra_field (item_type, value_type, variable, display_text, visible_to_self, changeable, default_value, created_at) values (1, 4, 'mail_notify_group_message','MailNotifyGroupMessage',0,1,'1', NOW());
INSERT INTO extra_field (item_type, value_type, variable, display_text, visible_to_self, changeable, created_at) VALUES (1, 1, 'user_chat_status','User chat status',0,0, NOW());
INSERT INTO extra_field (item_type, value_type, variable, display_text, visible_to_self, changeable, created_at) VALUES (1, 1, 'google_calendar_url','Google Calendar URL',0,0, NOW());
INSERT INTO extra_field (item_type, value_type, variable, display_text, visible_to_self, changeable, default_value, created_at) VALUES (2, 13, 'special_course', 'Special course', 1 , 1, '', NOW());
INSERT INTO extra_field (item_type, value_type, variable, display_text, visible_to_self, changeable, created_at) VALUES (2, 10, 'tags', 'Tags', 1, 1, NOW());
INSERT INTO extra_field (item_type, value_type, variable, display_text, visible_to_self, changeable, created_at) VALUES (2, 19, 'video_url', 'VideoUrl', 1, 1, NOW());
INSERT INTO extra_field (item_type, value_type, variable, display_text, visible_to_self, changeable, created_at) VALUES (3, 16, 'image', 'Image', 1, 1, NOW());
INSERT INTO extra_field (item_type, value_type, variable, display_text, visible_to_self, changeable, created_at) VALUES (1, 1, 'captcha_blocked_until_date', 'Account locked until', 0, 0, NOW());
INSERT INTO extra_field_options (field_id, option_value, display_text, option_order) VALUES (8, '1', 'AtOnce',1);
INSERT INTO extra_field_options (field_id, option_value, display_text, option_order) VALUES (8, '8', 'Daily',2);
@ -829,7 +829,7 @@ INSERT INTO sequence_type_entity VALUES
UPDATE user SET username_canonical = username;
INSERT INTO extra_field (extra_field_type, field_type, variable, display_text, visible_to_self, changeable, created_at)
INSERT INTO extra_field (item_type, value_type, variable, display_text, visible_to_self, changeable, created_at)
VALUES
(1, 1, 'skype', 'Skype', 1, 1, now()),
(1, 1, 'linkedin_url', 'LinkedInUrl', 1, 1, now());
@ -838,6 +838,6 @@ INSERT INTO access_url_rel_course_category (access_url_id, course_category_id) V
INSERT INTO access_url_rel_course_category (access_url_id, course_category_id) VALUES (1, 2);
INSERT INTO access_url_rel_course_category (access_url_id, course_category_id) VALUES (1, 3);
INSERT INTO extra_field (extra_field_type, field_type, variable, display_text, visible_to_self, changeable, created_at) VALUES (8, 10, 'tags', 'Tags', 1, 1, NOW());
INSERT INTO extra_field (item_type, value_type, variable, display_text, visible_to_self, changeable, created_at) VALUES (8, 10, 'tags', 'Tags', 1, 1, NOW());
INSERT INTO branch_sync (access_url_id, branch_name, unique_id, ssl_pub_key) VALUES (1, 'localhost', SHA1(UUID()), SHA1(UUID()));

@ -197,7 +197,7 @@ if ($form->validate()) {
break;
}
switch ($field['field_type']) {
switch ($field['value_type']) {
case ExtraField::FIELD_TYPE_TEXT:
case ExtraField::FIELD_TYPE_ALPHANUMERIC:
$pos = stripos($extraFieldValueData['value'], $_REQUEST['extra_'.$field['variable']]);

@ -126,7 +126,7 @@ if (!empty($items)) {
/** @var ExtraFieldSavedSearch $item */
foreach ($items as $item) {
$variable = 'extra_'.$item->getField()->getVariable();
if (ExtraField::FIELD_TYPE_TAG === $item->getField()->getFieldType()) {
if (ExtraField::FIELD_TYPE_TAG === $item->getField()->getValueType()) {
$tagsData[$variable] = $item->getValue();
}
$defaults[$variable] = $item->getValue();

@ -200,7 +200,7 @@ if (!empty($items)) {
/** @var ExtraFieldSavedSearch $item */
foreach ($items as $item) {
$variable = 'extra_'.$item->getField()->getVariable();
if (Extrafield::FIELD_TYPE_TAG === $item->getField()->getFieldType()) {
if (Extrafield::FIELD_TYPE_TAG === $item->getField()->getValueType()) {
$tagsData[$variable] = $item->getValue();
}
$defaults[$variable] = $item->getValue();

@ -156,10 +156,10 @@ $(function() {
$('#session_category').val(0);
$('#session_category').selectpicker('render');
}*/
$('#session_category').val(data.session_category_id);
$('#session_category').trigger('change');
setContentFromEditor('description', data.description);
if (data.duration > 0) {
@ -184,10 +184,10 @@ $(function() {
var variableName = variable + '_to_local_time';
if (data[variableName]) {
console.log(data[variableName]);
let parsedDate = data[variableName];
let parsedDate = data[variableName];
if (parsedDate) {
var item = $('#'+variable);
flatpickr = item[0]._flatpickr;
flatpickr = item[0]._flatpickr;
flatpickr.setDate(parsedDate);
}
}
@ -230,7 +230,7 @@ $(function() {
const FIELD_TYPE_ALPHANUMERIC = 21;
const FIELD_TYPE_LETTERS_SPACE = 22;
const FIELD_TYPE_ALPHANUMERIC_SPACE = 23;*/
switch (item.field_type) {
switch (item.value_type) {
case '1': // text
case '6': // date
case '7': // datetime
@ -240,7 +240,7 @@ $(function() {
case '21': // alphanum
$('input[name='+fieldName+']').val(item.value);
break;
case '2': // textarea
case '2': // textarea
setContentFromEditor(fieldName, item.value);
break;
case '3': // radio

@ -1575,7 +1575,7 @@ class SurveyManager
i.sessionId = :session AND
:now BETWEEN s.availFrom AND s.availTill AND
ef.variable = :variable AND
efv.value = 1 AND
efv.field_value = 1 AND
s.surveyType != 3
ORDER BY s.availTill ASC
")

@ -94,14 +94,14 @@
{% for extra in user.extra %}
{% if extra.value.getField().getVariable() == 'skype' %}
{% set skype_account %}
<a href="skype:{{ extra.value.getValue() }}?chat">
<a href="skype:{{ extra.value.getFieldValue() }}?chat">
<span class="fa fa-skype fa-fw" aria-hidden="true"></span> {{ 'Skype'|get_lang }}
</a>
{% endset %}
{% endif %}
{% if extra.value.getField().getVariable() == 'linkedin_url' %}
{% set linkedin_url %}
<a href="{{ extra.value.getValue() }}" target="_blank">
<a href="{{ extra.value.getFieldValue() }}" target="_blank">
<span class="fa fa-linkedin fa-fw" aria-hidden="true"></span> {{ 'LinkedIn'|get_lang }}
</a>
{% endset %}

@ -180,7 +180,7 @@ function prepare_user_sql_query($getCount)
if (empty($value)) {
continue;
}
if (ExtraField::FIELD_TYPE_TAG == $info['field_type']) {
if (ExtraField::FIELD_TYPE_TAG == $info['value_type']) {
$result = $extraField->getAllUserPerTag(
$info['id'],
$value

@ -841,8 +841,8 @@ function search_additional_profile_fields($keyword)
WHERE
user.id = user_values.item_id AND
user_values.field_id = e.id AND
e.extra_field_type = $extraFieldType AND
(value LIKE '%".$keyword."%'".$profiling_field_options_exact_values_sql.")";
e.item_type = $extraFieldType AND
(field_value LIKE '%".$keyword."%'".$profiling_field_options_exact_values_sql.")";
$result = Database::query($sql);
$additional_users = [];
while ($profiled_users = Database::fetch_array($result)) {

@ -254,7 +254,7 @@ class CreateSessionFromModelTest extends V2TestCase
$firstExtraFieldNameForNewSession = 'extra field value for new session';
$firstExtraFieldId = $extraFieldModel->save(
[
'field_type' => ExtraField::FIELD_TYPE_TEXT,
'value_type' => ExtraField::FIELD_TYPE_TEXT,
'variable' => $firstExtraFieldName,
'display_text' => $firstExtraFieldName,
'visible_to_self' => 1,
@ -275,7 +275,7 @@ class CreateSessionFromModelTest extends V2TestCase
$secondExtraFieldValue = 'second extra field value';
$secondExtraFieldId = $extraFieldModel->save(
[
'field_type' => ExtraField::FIELD_TYPE_TEXT,
'value_type' => ExtraField::FIELD_TYPE_TEXT,
'variable' => $secondExtraFieldName,
'display_text' => $secondExtraFieldName,
'visible_to_self' => 1,

@ -29,7 +29,7 @@ class GetSessionFromExtraFieldTest extends V2TestCase
$firstExtraFieldName = 'firstExtraField'.time();
$firstExtraFieldId = $extraFieldModel->save(
[
'field_type' => ExtraField::FIELD_TYPE_TEXT,
'value_type' => ExtraField::FIELD_TYPE_TEXT,
'variable' => $firstExtraFieldName,
'display_text' => $firstExtraFieldName,
'visible_to_self' => 1,
@ -41,7 +41,7 @@ class GetSessionFromExtraFieldTest extends V2TestCase
$secondExtraFieldName = 'secondExtraField'.time();
$secondExtraFieldId = $extraFieldModel->save(
[
'field_type' => ExtraField::FIELD_TYPE_TEXT,
'value_type' => ExtraField::FIELD_TYPE_TEXT,
'variable' => $secondExtraFieldName,
'display_text' => $secondExtraFieldName,
'visible_to_self' => 1,

@ -41,7 +41,7 @@ class UpdateUserFromUsernameTest extends V2TestCase
$extraFieldName = 'extraUserField'.time();
$extraFieldId = $extraFieldModel->save(
[
'field_type' => ExtraField::FIELD_TYPE_TEXT,
'value_type' => ExtraField::FIELD_TYPE_TEXT,
'variable' => $extraFieldName,
'display_text' => $extraFieldName,
'visible_to_self' => 1,

@ -843,13 +843,13 @@ function WSCreateUsersPasswordCrypted($params)
$extraFieldType = EntityExtraField::USER_FIELD_TYPE;
// Check whether x_user_id exists into user_field_values table.
$sql = "SELECT value as field_value,item_id as user_id
$sql = "SELECT field_value, item_id as user_id
FROM $t_uf uf, $t_ufv ufv
WHERE
uf.extra_field_type = $extraFieldType AND
uf.item_type = $extraFieldType AND
ufv.field_id=uf.id AND
variable='$original_user_id_name' AND
value ='$original_user_id_value'";
field_value ='$original_user_id_value'";
$res = Database::query($sql);
$row = Database::fetch_row($res);
$count_row = Database::num_rows($res);

@ -798,7 +798,7 @@ function deleteDirWork($id)
foreach ($resultExtra as $field) {
$field = $field['value'];
if ($consideredWorkingTime == $field->getField()->getVariable()) {
$workingTime = $field->getValue();
$workingTime = $field->getFieldValue();
break;
}
@ -4833,7 +4833,7 @@ function processWorkForm(
foreach ($resultExtra as $field) {
$field = $field['value'];
if ($consideredWorkingTime == $field->getField()->getVariable()) {
$workingTime = $field->getValue();
$workingTime = $field->getFieldValue();
}
}
@ -5357,7 +5357,7 @@ function deleteWorkItem($item_id, Course $course)
$field = $field['value'];
if ($consideredWorkingTime == $field->getField()->getVariable()) {
$workingTime = $field->getValue();
$workingTime = $field->getFieldValue();
}
}
// If no time was defined, or a time of "0" was set, do nothing

@ -1448,7 +1448,7 @@ class AdvancedSubscriptionPlugin extends Plugin implements HookPluginInterface
if (!$areaExists) {
$extraField = new ExtraField('user');
$extraField->save([
'field_type' => 1,
'value_type' => 1,
'variable' => 'area',
'display_text' => get_plugin_lang('Area', 'AdvancedSubscriptionPlugin'),
'default_value' => null,
@ -1514,7 +1514,7 @@ class AdvancedSubscriptionPlugin extends Plugin implements HookPluginInterface
INNER JOIN $tSessionField AS sf ON sfv.field_id = sf.id
INNER JOIN $tSessionUser AS su ON s.id = su.session_id
WHERE
sf.extra_field_type = $extraFieldType AND
sf.item_type = $extraFieldType AND
sf.variable = 'is_induction_session' AND
su.relation_type = ".Session::STUDENT." AND
su.user_id = ".(int) $userId;

@ -13,7 +13,7 @@ api_protect_admin_script();
$teachingHours = new ExtraField('session');
$teachingHours->save([
'field_type' => ExtraField::FIELD_TYPE_INTEGER,
'value_type' => ExtraField::FIELD_TYPE_INTEGER,
'variable' => 'teaching_hours',
'display_text' => get_lang('Lecture hours'),
'visible_to_self' => 1,
@ -22,7 +22,7 @@ $teachingHours->save([
$cost = new ExtraField('session');
$cost->save([
'field_type' => ExtraField::FIELD_TYPE_FLOAT,
'value_type' => ExtraField::FIELD_TYPE_FLOAT,
'variable' => 'cost',
'display_text' => get_lang('Cost'),
'visible_to_self' => 1,
@ -31,7 +31,7 @@ $cost->save([
$vacancies = new ExtraField('session');
$vacancies->save([
'field_type' => ExtraField::FIELD_TYPE_INTEGER,
'value_type' => ExtraField::FIELD_TYPE_INTEGER,
'variable' => 'vacancies',
'display_text' => get_lang('Vacancies'),
'visible_to_self' => 1,
@ -40,7 +40,7 @@ $vacancies->save([
$recommendedNumberOfParticipants = new ExtraField('session');
$recommendedNumberOfParticipants->save([
'field_type' => ExtraField::FIELD_TYPE_INTEGER,
'value_type' => ExtraField::FIELD_TYPE_INTEGER,
'variable' => 'recommended_number_of_participants',
'display_text' => get_lang('Recommended number of participants'),
'visible_to_self' => 1,
@ -49,7 +49,7 @@ $recommendedNumberOfParticipants->save([
$place = new ExtraField('session');
$place->save([
'field_type' => ExtraField::FIELD_TYPE_TEXT,
'value_type' => ExtraField::FIELD_TYPE_TEXT,
'variable' => 'place',
'display_text' => get_lang('Place/Location'),
'visible_to_self' => 1,
@ -58,7 +58,7 @@ $place->save([
$schedule = new ExtraField('session');
$schedule->save([
'field_type' => ExtraField::FIELD_TYPE_TEXT,
'value_type' => ExtraField::FIELD_TYPE_TEXT,
'variable' => 'schedule',
'display_text' => get_lang('Schedule'),
'visible_to_self' => 1,
@ -67,7 +67,7 @@ $schedule->save([
$allowVisitors = new ExtraField('session');
$allowVisitors->save([
'field_type' => ExtraField::FIELD_TYPE_CHECKBOX,
'value_type' => ExtraField::FIELD_TYPE_CHECKBOX,
'variable' => 'allow_visitors',
'display_text' => get_lang('Allow visitors'),
'visible_to_self' => 1,
@ -82,7 +82,7 @@ $modeOptions = [
$mode = new ExtraField('session');
$mode->save([
'field_type' => ExtraField::FIELD_TYPE_SELECT,
'value_type' => ExtraField::FIELD_TYPE_SELECT,
'variable' => 'mode',
'display_text' => get_lang('Mode'),
'visible_to_self' => 1,
@ -92,7 +92,7 @@ $mode->save([
$isInductionSession = new ExtraField('session');
$isInductionSession->save([
'field_type' => ExtraField::FIELD_TYPE_CHECKBOX,
'value_type' => ExtraField::FIELD_TYPE_CHECKBOX,
'variable' => 'is_induction_session',
'display_text' => get_lang('Induction-type session'),
'visible_to_self' => 1,
@ -101,7 +101,7 @@ $isInductionSession->save([
$isOpenSession = new ExtraField('session');
$isOpenSession->save([
'field_type' => ExtraField::FIELD_TYPE_CHECKBOX,
'value_type' => ExtraField::FIELD_TYPE_CHECKBOX,
'variable' => 'is_open_session',
'display_text' => get_lang('Open session'),
'visible_to_self' => 1,
@ -110,7 +110,7 @@ $isOpenSession->save([
$duration = new ExtraField('session');
$duration->save([
'field_type' => ExtraField::FIELD_TYPE_TEXT,
'value_type' => ExtraField::FIELD_TYPE_TEXT,
'variable' => 'human_text_duration',
'display_text' => get_lang('Duration in words'),
'visible_to_self' => 1,
@ -125,7 +125,7 @@ $showStatusOptions = [
$showStatus = new ExtraField('session');
$showStatus->save([
'field_type' => ExtraField::FIELD_TYPE_SELECT,
'value_type' => ExtraField::FIELD_TYPE_SELECT,
'variable' => 'show_status',
'display_text' => get_lang('Show status'),
'visible_to_self' => 1,
@ -135,7 +135,7 @@ $showStatus->save([
$publicationStartDate = new ExtraField('session');
$publicationStartDate->save([
'field_type' => ExtraField::FIELD_TYPE_DATE,
'value_type' => ExtraField::FIELD_TYPE_DATE,
'variable' => 'publication_start_date',
'display_text' => get_lang('Published start date'),
'visible_to_self' => 1,
@ -144,7 +144,7 @@ $publicationStartDate->save([
$publicationEndDate = new ExtraField('session');
$publicationEndDate->save([
'field_type' => ExtraField::FIELD_TYPE_DATE,
'value_type' => ExtraField::FIELD_TYPE_DATE,
'variable' => 'publication_end_date',
'display_text' => get_lang('Published end date'),
'visible_to_self' => 1,
@ -153,7 +153,7 @@ $publicationEndDate->save([
$banner = new ExtraField('session');
$banner->save([
'field_type' => ExtraField::FIELD_TYPE_FILE_IMAGE,
'value_type' => ExtraField::FIELD_TYPE_FILE_IMAGE,
'variable' => 'banner',
'display_text' => get_lang('Session banner'),
'visible_to_self' => 1,
@ -162,7 +162,7 @@ $banner->save([
$brochure = new ExtraField('session');
$brochure->save([
'field_type' => ExtraField::FIELD_TYPE_FILE,
'value_type' => ExtraField::FIELD_TYPE_FILE,
'variable' => 'brochure',
'display_text' => get_lang('Brochure'),
'visible_to_self' => 1,
@ -176,7 +176,7 @@ $targetOptions = [
$target = new ExtraField('session');
$target->save([
'field_type' => ExtraField::FIELD_TYPE_SELECT,
'value_type' => ExtraField::FIELD_TYPE_SELECT,
'variable' => 'target',
'display_text' => get_lang('Target audience'),
'visible_to_self' => 1,
@ -186,7 +186,7 @@ $target->save([
$shortDescription = new ExtraField('session');
$shortDescription->save([
'field_type' => ExtraField::FIELD_TYPE_TEXT,
'value_type' => ExtraField::FIELD_TYPE_TEXT,
'variable' => 'short_description',
'display_text' => get_lang('Short description'),
'visible_to_self' => 1,
@ -195,7 +195,7 @@ $shortDescription->save([
$id = new ExtraField('session');
$id->save([
'field_type' => ExtraField::FIELD_TYPE_TEXT,
'value_type' => ExtraField::FIELD_TYPE_TEXT,
'variable' => 'code',
'display_text' => get_lang('Course code'),
'visible_to_self' => 1,

@ -5,7 +5,7 @@ It requires you to have a BigBlueButton videoconference server installed on anot
Check www.bigbluebutton.org for more about BigBlueButton.
## Migrating to Chamilo LMS 1.10.x
For Chamilo 1.10.x, the Videoconference plugin has two new settings options:
For Chamilo 1.10.x, the Videoconference plugin has two new settings options:
*Enable global conference* and *Enable conference in course groups*.
##### Database changes
@ -16,8 +16,8 @@ ALTER TABLE plugin_bbb_meeting ADD voice_bridge int NOT NULL DEFAULT 1;
ALTER TABLE plugin_bbb_meeting ADD group_id int unsigned NOT NULL DEFAULT 0;
```
## Migrating to Chamilo LMS 1.11.x
For Chamilo 1.11.x, Videoconference plugin has one new setting option:
*Disable Course Settings*.
For Chamilo 1.11.x, Videoconference plugin has one new setting option:
*Disable Course Settings*.
##### Database changes
You need execute this SQL query in your database after making the Chamilo migration process from 1.10.x.
@ -47,8 +47,8 @@ ALTER TABLE plugin_bbb_meeting ADD COLUMN session_id INT DEFAULT 0;
For version 2.6 (adding limits) you need execute these SQL queries
```sql
INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url, access_url_changeable, access_url_locked) VALUES ('bbb_max_users_limit', 'bbb', 'setting', 'Plugins', '3', 'bbb', null, null, null, 1, 1, 0);
INSERT INTO extra_field (extra_field_type, field_type, variable, display_text, default_value, field_order, visible_to_self, visible_to_others, changeable, filter, created_at) VALUES (2, 15, 'plugin_bbb_course_users_limit', 'MaxUsersInConferenceRoom', '0', 1, 1, 0, 1, null, '2017-05-28 01:19:32');
INSERT INTO extra_field (extra_field_type, field_type, variable, display_text, default_value, field_order, visible_to_self, visible_to_others, changeable, filter, created_at) VALUES (3, 15, 'plugin_bbb_session_users_limit', 'MaxUsersInConferenceRoom', null, 1, 1, 0, 1, null, '2017-05-28 01:19:32');
INSERT INTO extra_field (item_type, value_type, variable, display_text, default_value, field_order, visible_to_self, visible_to_others, changeable, filter, created_at) VALUES (2, 15, 'plugin_bbb_course_users_limit', 'MaxUsersInConferenceRoom', '0', 1, 1, 0, 1, null, '2017-05-28 01:19:32');
INSERT INTO extra_field (item_type, value_type, variable, display_text, default_value, field_order, visible_to_self, visible_to_others, changeable, filter, created_at) VALUES (3, 15, 'plugin_bbb_session_users_limit', 'MaxUsersInConferenceRoom', null, 1, 1, 0, 1, null, '2017-05-28 01:19:32');
```
For version 2.7
@ -78,7 +78,7 @@ You need to configure the cron using the *cron_close_meeting.php* file.
# Digital ocean VM
In order to use DigitalOceanVM classes a new package is required:
```
composer requires toin0u/digitalocean
```
```

@ -418,8 +418,8 @@ if (!$paypalExtraField) {
Database::insert(
$extraFieldTable,
[
'extra_field_type' => 1,
'field_type' => 1,
'item_type' => 1,
'value_type' => 1,
'variable' => 'paypal',
'display_text' => 'Paypal',
'default_value' => '',

@ -110,7 +110,7 @@ class CreateDrupalUser extends Plugin implements HookPluginInterface
$extraField = new ExtraField('user');
$extraField->save(
[
'field_type' => ExtraField::FIELD_TYPE_INTEGER,
'value_type' => ExtraField::FIELD_TYPE_INTEGER,
'variable' => self::EXTRAFIELD_VARIABLE_NAME,
'display_text' => get_plugin_lang('DrupalUserId', 'CreateDrupalUser'),
'default_value' => null,

@ -151,7 +151,7 @@ foreach ($result as $value) {
break;
}
switch ($field['field_type']) {
switch ($field['value_type']) {
case ExtraField::FIELD_TYPE_TEXT:
case ExtraField::FIELD_TYPE_ALPHANUMERIC:
$pos = stripos($extraFieldValueData['value'], $_GET['extra_'.$field['variable']]);

@ -130,7 +130,7 @@ class ExerciseSignaturePlugin extends Plugin
if (!$exists) {
$extraField->save(
[
'field_type' => 13, // checkbox yes/no
'value_type' => 13, // checkbox yes/no
'variable' => 'signature_activated',
'display_text' => get_plugin_lang('SignatureActivated', 'ExerciseSignaturePlugin'),
'default_value' => null,
@ -148,7 +148,7 @@ class ExerciseSignaturePlugin extends Plugin
if (!$exists) {
$extraField->save(
[
'field_type' => 13, // checkbox yes/no
'value_type' => 13, // checkbox yes/no
'variable' => 'signature_mandatory',
'display_text' => get_plugin_lang('SignatureMandatory', 'ExerciseSignaturePlugin'),
'default_value' => null,
@ -167,7 +167,7 @@ class ExerciseSignaturePlugin extends Plugin
if (!$exists) {
$extraField->save(
[
'field_type' => 2, // textarea
'value_type' => 2, // textarea
'variable' => 'signature',
'display_text' => get_plugin_lang('Signature', 'ExerciseSignaturePlugin'),
'default_value' => null,

@ -52,7 +52,7 @@ $formattedExtraFieldValues = [];
foreach ($extraFieldValues as $index => $extra) {
foreach ($extra as $yandex => $field) {
$thisUserExtraField = api_get_user_info($field->getItemId());
$formattedExtraFieldValues[$index][$yandex]['address'] = $field->getValue();
$formattedExtraFieldValues[$index][$yandex]['address'] = $field->getFieldValue();
$formattedExtraFieldValues[$index][$yandex]['user_complete_name'] = $thisUserExtraField['complete_name'];
}
}

@ -130,7 +130,7 @@ class GradingElectronicPlugin extends Plugin
)) {
$uExtraField->save([
'variable' => self::EXTRAFIELD_STUDENT_ID,
'field_type' => ExtraField::FIELD_TYPE_TEXT,
'value_type' => ExtraField::FIELD_TYPE_TEXT,
'display_text' => $this->get_lang('StudentId'),
'visible_to_self' => true,
'changeable' => true,
@ -144,7 +144,7 @@ class GradingElectronicPlugin extends Plugin
)) {
$cExtraField->save([
'variable' => self::EXTRAFIELD_COURSE_PROVIDER_ID,
'field_type' => ExtraField::FIELD_TYPE_TEXT,
'value_type' => ExtraField::FIELD_TYPE_TEXT,
'display_text' => $this->get_lang('ProviderId'),
'visible_to_self' => true,
'changeable' => true,
@ -156,7 +156,7 @@ class GradingElectronicPlugin extends Plugin
)) {
$cExtraField->save([
'variable' => self::EXTRAFIELD_COURSE_ID,
'field_type' => ExtraField::FIELD_TYPE_TEXT,
'value_type' => ExtraField::FIELD_TYPE_TEXT,
'display_text' => $this->get_lang('CourseId'),
'visible_to_self' => true,
'changeable' => true,
@ -168,7 +168,7 @@ class GradingElectronicPlugin extends Plugin
)) {
$cExtraField->save([
'variable' => self::EXTRAFIELD_COURSE_HOURS,
'field_type' => ExtraField::FIELD_TYPE_TEXT,
'value_type' => ExtraField::FIELD_TYPE_TEXT,
'display_text' => $this->get_lang('CourseHours'),
'visible_to_self' => true,
'changeable' => true,

@ -128,7 +128,7 @@ class LearningCalendarPlugin extends Plugin
'visible_to_self' => 1,
'changeable' => 1,
'visible_to_others' => 1,
'field_type' => ExtraField::FIELD_TYPE_CHECKBOX,
'value_type' => ExtraField::FIELD_TYPE_CHECKBOX,
];
$extraField->save($params);
@ -140,7 +140,7 @@ class LearningCalendarPlugin extends Plugin
'visible_to_self' => 1,
'changeable' => 1,
'visible_to_others' => 1,
'field_type' => ExtraField::FIELD_TYPE_TEXT,
'value_type' => ExtraField::FIELD_TYPE_TEXT,
];
$extraField->save($params);
@ -288,7 +288,7 @@ class LearningCalendarPlugin extends Plugin
$select = 'count(id) count ';
}
$sql = "SELECT $select FROM learning_calendar_events
$sql = "SELECT $select FROM learning_calendar_events
WHERE calendar_id = $calendarId $startCondition $endCondition $typeCondition";
$result = Database::query($sql);
@ -324,7 +324,7 @@ class LearningCalendarPlugin extends Plugin
$typeCondition = " AND type = $type ";
}*/
$sql = "SELECT start_date FROM learning_calendar_events
$sql = "SELECT start_date FROM learning_calendar_events
WHERE calendar_id = $calendarId ORDER BY start_date LIMIT 1";
$result = Database::query($sql);
$row = Database::fetch_array($result, 'ASSOC');
@ -357,7 +357,7 @@ class LearningCalendarPlugin extends Plugin
public function getUsersPerCalendar($calendarId)
{
$calendarId = (int) $calendarId;
$sql = "SELECT * FROM learning_calendar_user
$sql = "SELECT * FROM learning_calendar_user
WHERE calendar_id = $calendarId";
$result = Database::query($sql);
$list = [];
@ -378,7 +378,7 @@ class LearningCalendarPlugin extends Plugin
public function getUsersPerCalendarCount($calendarId)
{
$calendarId = (int) $calendarId;
$sql = "SELECT count(id) as count FROM learning_calendar_user
$sql = "SELECT count(id) as count FROM learning_calendar_user
WHERE calendar_id = $calendarId";
$result = Database::query($sql);
$row = Database::fetch_array($result, 'ASSOC');
@ -557,7 +557,7 @@ class LearningCalendarPlugin extends Plugin
{
$calendarId = (int) $calendarId;
$userId = (int) $userId;
$sql = "DELETE FROM learning_calendar_user
$sql = "DELETE FROM learning_calendar_user
WHERE user_id = $userId AND calendar_id = $calendarId";
Database::query($sql);
@ -698,16 +698,16 @@ class LearningCalendarPlugin extends Plugin
$tableCourse = Database::get_main_table(TABLE_MAIN_COURSE);
$tableResult = Database::get_main_table(TABLE_MAIN_GRADEBOOK_RESULT);
$sql = "SELECT DISTINCT e.name, e.id
FROM $tableEvaluation e
FROM $tableEvaluation e
INNER JOIN $tableCourse c
ON (course_code = c.code)
INNER JOIN $tableResult r
ON (r.evaluation_id = e.id)
WHERE
WHERE
e.type = 'evaluation' AND
r.score >= 2 AND
r.user_id = $userId
$courseSessionConditionToString
r.user_id = $userId
$courseSessionConditionToString
";
$result = Database::query($sql);
$list = [];
@ -758,9 +758,9 @@ class LearningCalendarPlugin extends Plugin
$courseAndSessionCondition[] =
" ((l.session_id = 0 OR l.session_id is NULL) AND i.c_id IN ('$courseListToString'))";
} else {
$courseAndSessionCondition[] = "
$courseAndSessionCondition[] = "
(
((l.session_id = 0 OR l.session_id is NULL) OR l.session_id = $sessionId) AND
((l.session_id = 0 OR l.session_id is NULL) OR l.session_id = $sessionId) AND
i.c_id IN ('$courseListToString')
)";
}
@ -771,18 +771,18 @@ class LearningCalendarPlugin extends Plugin
}
$courseSessionConditionToString = 'AND ('.implode(' OR ', $courseAndSessionCondition).') ';
$sql = "SELECT count(*) as count
$sql = "SELECT count(*) as count
FROM $tableItem i INNER JOIN $tableLp l
ON (i.c_id = l.c_id AND i.lp_id = l.iid)
ON (i.c_id = l.c_id AND i.lp_id = l.iid)
INNER JOIN $tableLpItemView iv
ON (iv.c_id = l.c_id AND i.iid = iv.lp_item_id)
ON (iv.c_id = l.c_id AND i.iid = iv.lp_item_id)
INNER JOIN $tableLpView v
ON (v.c_id = l.c_id AND v.lp_id = l.iid AND iv.lp_view_id = v.iid)
INNER JOIN extra_field_values e
INNER JOIN extra_field_values e
ON (e.item_id = i.iid AND value = 1 AND field_id = ".$fieldInfo['id'].")
WHERE
v.user_id = $userId AND
status = 'completed'
WHERE
v.user_id = $userId AND
status = 'completed'
$courseSessionConditionToString
GROUP BY iv.view_count
";
@ -840,8 +840,8 @@ class LearningCalendarPlugin extends Plugin
$html .= '<script>
$(document).ready(function(){
var cosPoints = '.$listToString.';
var plot1 = $.jqplot(\'control_point_chart\', [cosPoints], {
//animate: !$.jqplot.use_excanvas,
var plot1 = $.jqplot(\'control_point_chart\', [cosPoints], {
//animate: !$.jqplot.use_excanvas,
series:[{
showMarker:true,
pointLabels: { show:true },
@ -851,12 +851,12 @@ class LearningCalendarPlugin extends Plugin
label: "'.$date.'",
renderer: $.jqplot.DateAxisRenderer,
tickOptions:{formatString: "%Y-%m-%d"},
tickInterval: \'30 day\',
tickInterval: \'30 day\',
},
yaxis:{
label: "'.$controlPoint.'",
max: 20,
min: -20,
min: -20,
}
},
canvasOverlay: {
@ -870,7 +870,7 @@ class LearningCalendarPlugin extends Plugin
shadow: false
}
}]
},
},
});
});
</script>';
@ -985,7 +985,7 @@ class LearningCalendarPlugin extends Plugin
// Remove the free type to loop correctly when toogle days.
unset($eventTypeList[self::EVENT_TYPE_FREE]);
$sql = "SELECT * FROM learning_calendar_events
$sql = "SELECT * FROM learning_calendar_events
WHERE start_date = '$startDate' AND calendar_id = $calendarId ";
$result = Database::query($sql);
@ -1030,7 +1030,7 @@ class LearningCalendarPlugin extends Plugin
$calendarId = (int) $calendarId;
$eventTypeList = $this->getEventTypeColorList();
$sql = "SELECT * FROM learning_calendar_events
$sql = "SELECT * FROM learning_calendar_events
WHERE calendar_id = $calendarId ";
$result = Database::query($sql);
@ -1071,9 +1071,9 @@ class LearningCalendarPlugin extends Plugin
public function getControlPoints($userId)
{
$userId = (int) $userId;
$sql = "SELECT control_date, control_value
FROM learning_calendar_control_point
WHERE user_id = $userId
$sql = "SELECT control_date, control_value
FROM learning_calendar_control_point
WHERE user_id = $userId
ORDER BY control_date";
$result = Database::query($sql);
@ -1107,8 +1107,8 @@ class LearningCalendarPlugin extends Plugin
$local = api_get_local_time();
$date = substr($local, 0, 10);
$sql = "SELECT id
FROM learning_calendar_control_point
$sql = "SELECT id
FROM learning_calendar_control_point
WHERE user_id = $userId AND control_date = '$date'";
$result = Database::query($sql);

@ -256,7 +256,7 @@ class QuestionOptionsEvaluationPlugin extends Plugin
->save(
[
'variable' => self::EXTRAFIELD_FORMULA,
'field_type' => ExtraField::FIELD_TYPE_TEXT,
'value_type' => ExtraField::FIELD_TYPE_TEXT,
'display_text' => $this->get_lang('EvaluationFormula'),
'visible_to_self' => false,
'changeable' => false,

@ -105,7 +105,7 @@ class WhispeakAuthPlugin extends Plugin implements \Chamilo\CoreBundle\Hook\Inte
$extraField = $efRepo->findOneBy(
[
'variable' => self::EXTRAFIELD_AUTH_UID,
'extraFieldType' => ExtraField::USER_FIELD_TYPE,
'itemType' => ExtraField::USER_FIELD_TYPE,
]
);
@ -123,7 +123,7 @@ class WhispeakAuthPlugin extends Plugin implements \Chamilo\CoreBundle\Hook\Inte
$extraField = $efRepo->findOneBy(
[
'variable' => self::EXTRAFIELD_LP_ITEM,
'extraFieldType' => ExtraField::LP_ITEM_FIELD_TYPE,
'itemType' => ExtraField::LP_ITEM_FIELD_TYPE,
]
);
@ -141,7 +141,7 @@ class WhispeakAuthPlugin extends Plugin implements \Chamilo\CoreBundle\Hook\Inte
$extraField = $efRepo->findOneBy(
[
'variable' => self::EXTRAFIELD_QUIZ_QUESTION,
'extraFieldType' => ExtraField::QUESTION_FIELD_TYPE,
'itemType' => ExtraField::QUESTION_FIELD_TYPE,
]
);
@ -302,7 +302,7 @@ class WhispeakAuthPlugin extends Plugin implements \Chamilo\CoreBundle\Hook\Inte
->setUpdatedAt($now);
}
$extraFieldValue->setValue($uid);
$extraFieldValue->setFieldValue($uid);
$em->persist($extraFieldValue);
$em->flush();
@ -713,7 +713,7 @@ class WhispeakAuthPlugin extends Plugin implements \Chamilo\CoreBundle\Hook\Inte
$extraField = new \ExtraField('question');
$params = [
'variable' => self::EXTRAFIELD_QUIZ_QUESTION,
'field_type' => \ExtraField::FIELD_TYPE_CHECKBOX,
'value_type' => \ExtraField::FIELD_TYPE_CHECKBOX,
'display_text' => $this->get_lang('MarkForSpeechAuthentication'),
'default_value' => '0',
'changeable' => true,

@ -451,7 +451,7 @@ class CourseController extends ToolBaseController
}
/** @var ExtraField $tagField */
$tagField = $fieldsRepo->findOneBy([
'extraFieldType' => ExtraField::COURSE_FIELD_TYPE,
'itemType' => ExtraField::COURSE_FIELD_TYPE,
'variable' => 'tags',
]);

@ -64,7 +64,7 @@ class SessionController extends AbstractController
/** @var ExtraField $tagField */
$tagField = $fieldsRepo->findOneBy([
'extraFieldType' => ExtraField::COURSE_FIELD_TYPE,
'itemType' => ExtraField::COURSE_FIELD_TYPE,
'variable' => 'tags',
]);

@ -19,92 +19,92 @@ class ExtraFieldFixtures extends Fixture
[
'variable' => 'legal_accept',
'display_text' => 'Legal',
'extra_field_type' => ExtraField::USER_FIELD_TYPE,
'field_type' => \ExtraField::FIELD_TYPE_TEXT,
'item_type' => ExtraField::USER_FIELD_TYPE,
'value_type' => \ExtraField::FIELD_TYPE_TEXT,
],
[
'variable' => 'already_logged_in',
'display_text' => 'Already logged in',
'extra_field_type' => ExtraField::USER_FIELD_TYPE,
'field_type' => \ExtraField::FIELD_TYPE_TEXT,
'item_type' => ExtraField::USER_FIELD_TYPE,
'value_type' => \ExtraField::FIELD_TYPE_TEXT,
],
[
'variable' => 'update_type',
'display_text' => 'Update script type',
'extra_field_type' => ExtraField::USER_FIELD_TYPE,
'field_type' => \ExtraField::FIELD_TYPE_TEXT,
'item_type' => ExtraField::USER_FIELD_TYPE,
'value_type' => \ExtraField::FIELD_TYPE_TEXT,
],
[
'variable' => 'tags',
'display_text' => 'tags',
'extra_field_type' => ExtraField::USER_FIELD_TYPE,
'field_type' => \ExtraField::FIELD_TYPE_TAG,
'item_type' => ExtraField::USER_FIELD_TYPE,
'value_type' => \ExtraField::FIELD_TYPE_TAG,
],
[
'variable' => 'rssfeeds',
'display_text' => 'RSS',
'extra_field_type' => ExtraField::USER_FIELD_TYPE,
'field_type' => \ExtraField::FIELD_TYPE_TEXT,
'item_type' => ExtraField::USER_FIELD_TYPE,
'value_type' => \ExtraField::FIELD_TYPE_TEXT,
],
[
'variable' => 'dashboard',
'display_text' => 'Dashboard',
'extra_field_type' => ExtraField::USER_FIELD_TYPE,
'field_type' => \ExtraField::FIELD_TYPE_TEXT,
'item_type' => ExtraField::USER_FIELD_TYPE,
'value_type' => \ExtraField::FIELD_TYPE_TEXT,
],
/*[
'variable' => 'timezone',
'display_text' => 'Timezone',
'extra_field_type' => ExtraField::USER_FIELD_TYPE,
'field_type' => \ExtraField::FIELD_TYPE_TEXT,
'item_type' => ExtraField::USER_FIELD_TYPE,
'value_type' => \ExtraField::FIELD_TYPE_TEXT,
],*/
[
'variable' => 'user_chat_status',
'display_text' => 'User chat status',
'extra_field_type' => ExtraField::USER_FIELD_TYPE,
'field_type' => \ExtraField::FIELD_TYPE_TEXT,
'item_type' => ExtraField::USER_FIELD_TYPE,
'value_type' => \ExtraField::FIELD_TYPE_TEXT,
],
[
'variable' => 'google_calendar_url',
'display_text' => 'Google Calendar URL',
'extra_field_type' => ExtraField::USER_FIELD_TYPE,
'field_type' => \ExtraField::FIELD_TYPE_TEXT,
'item_type' => ExtraField::USER_FIELD_TYPE,
'value_type' => \ExtraField::FIELD_TYPE_TEXT,
],
[
'variable' => 'captcha_blocked_until_date',
'display_text' => 'Account locked until',
'extra_field_type' => ExtraField::USER_FIELD_TYPE,
'field_type' => \ExtraField::FIELD_TYPE_TEXT,
'item_type' => ExtraField::USER_FIELD_TYPE,
'value_type' => \ExtraField::FIELD_TYPE_TEXT,
],
[
'variable' => 'special_course',
'display_text' => 'Special course',
'extra_field_type' => ExtraField::COURSE_FIELD_TYPE,
'field_type' => \ExtraField::FIELD_TYPE_CHECKBOX,
'item_type' => ExtraField::COURSE_FIELD_TYPE,
'value_type' => \ExtraField::FIELD_TYPE_CHECKBOX,
'visible_to_self' => true,
'changeable' => true,
],
[
'variable' => 'tags',
'display_text' => 'Tags',
'extra_field_type' => ExtraField::COURSE_FIELD_TYPE,
'field_type' => \ExtraField::FIELD_TYPE_TAG,
'item_type' => ExtraField::COURSE_FIELD_TYPE,
'value_type' => \ExtraField::FIELD_TYPE_TAG,
'visible_to_self' => true,
'changeable' => true,
],
[
'variable' => 'video_url',
'display_text' => 'VideoUrl',
'extra_field_type' => ExtraField::COURSE_FIELD_TYPE,
'field_type' => \ExtraField::FIELD_TYPE_VIDEO_URL,
'item_type' => ExtraField::COURSE_FIELD_TYPE,
'value_type' => \ExtraField::FIELD_TYPE_VIDEO_URL,
'visible_to_self' => true,
'changeable' => true,
],
[
'variable' => 'image',
'display_text' => 'Image',
'extra_field_type' => ExtraField::SESSION_FIELD_TYPE,
'field_type' => \ExtraField::FIELD_TYPE_FILE_IMAGE,
'item_type' => ExtraField::SESSION_FIELD_TYPE,
'value_type' => \ExtraField::FIELD_TYPE_FILE_IMAGE,
'visible_to_self' => true,
'changeable' => true,
],
@ -112,8 +112,8 @@ class ExtraFieldFixtures extends Fixture
[
'variable' => 'mail_notify_invitation',
'display_text' => 'MailNotifyInvitation',
'extra_field_type' => ExtraField::USER_FIELD_TYPE,
'field_type' => \ExtraField::FIELD_TYPE_SELECT,
'item_type' => ExtraField::USER_FIELD_TYPE,
'value_type' => \ExtraField::FIELD_TYPE_SELECT,
'visible_to_self' => true,
'default_value' => 1,
'add_options' => true,
@ -121,8 +121,8 @@ class ExtraFieldFixtures extends Fixture
[
'variable' => 'mail_notify_message',
'display_text' => 'MailNotifyMessage',
'extra_field_type' => ExtraField::USER_FIELD_TYPE,
'field_type' => \ExtraField::FIELD_TYPE_SELECT,
'item_type' => ExtraField::USER_FIELD_TYPE,
'value_type' => \ExtraField::FIELD_TYPE_SELECT,
'visible_to_self' => true,
'default_value' => 1,
'add_options' => true,
@ -130,8 +130,8 @@ class ExtraFieldFixtures extends Fixture
[
'variable' => 'mail_notify_group_message',
'display_text' => 'MailNotifyGroupMessage',
'extra_field_type' => ExtraField::USER_FIELD_TYPE,
'field_type' => \ExtraField::FIELD_TYPE_SELECT,
'item_type' => ExtraField::USER_FIELD_TYPE,
'value_type' => \ExtraField::FIELD_TYPE_SELECT,
'visible_to_self' => true,
'default_value' => 1,
'add_options' => true,
@ -139,24 +139,24 @@ class ExtraFieldFixtures extends Fixture
[
'variable' => 'skype',
'display_text' => 'Skype',
'extra_field_type' => ExtraField::USER_FIELD_TYPE,
'field_type' => \ExtraField::FIELD_TYPE_TEXT,
'item_type' => ExtraField::USER_FIELD_TYPE,
'value_type' => \ExtraField::FIELD_TYPE_TEXT,
'visible_to_self' => true,
'changeable' => true,
],
[
'variable' => 'linkedin_url',
'display_text' => 'LinkedInUrl',
'extra_field_type' => ExtraField::USER_FIELD_TYPE,
'field_type' => \ExtraField::FIELD_TYPE_TEXT,
'item_type' => ExtraField::USER_FIELD_TYPE,
'value_type' => \ExtraField::FIELD_TYPE_TEXT,
'visible_to_self' => true,
'changeable' => true,
],
[
'variable' => 'tags',
'display_text' => 'Tags',
'extra_field_type' => ExtraField::SKILL_FIELD_TYPE,
'field_type' => \ExtraField::FIELD_TYPE_TAG,
'item_type' => ExtraField::SKILL_FIELD_TYPE,
'value_type' => \ExtraField::FIELD_TYPE_TAG,
'visible_to_self' => true,
'changeable' => true,
],
@ -172,8 +172,8 @@ class ExtraFieldFixtures extends Fixture
$extraField = (new ExtraField())
->setVariable($data['variable'])
->setDisplayText($data['display_text'])
->setExtraFieldType($data['extra_field_type'])
->setFieldType($data['field_type'])
->setItemType($data['item_type'])
->setValueType($data['value_type'])
->setChangeable($data['changeable'] ?? false)
->setVisibleToSelf($data['visible_to_self'] ?? false)
;

@ -83,16 +83,16 @@ class ExtraField
protected ?int $id = null;
/**
* @ORM\Column(name="extra_field_type", type="integer")
* @ORM\Column(name="item_type", type="integer")
*/
#[Groups(['extra_field:read', 'extra_field:write'])]
protected int $extraFieldType;
protected int $itemType;
/**
* @ORM\Column(name="field_type", type="integer")
* @ORM\Column(name="value_type", type="integer")
*/
#[Groups(['extra_field:read', 'extra_field:write'])]
protected int $fieldType;
protected int $valueType;
/**
* @ORM\Column(name="variable", type="string", length=255)
@ -197,26 +197,26 @@ class ExtraField
return $this->id;
}
public function getExtraFieldType(): int
public function getItemType(): int
{
return $this->extraFieldType;
return $this->itemType;
}
public function setExtraFieldType(int $extraFieldType): self
public function setItemType(int $itemType): self
{
$this->extraFieldType = $extraFieldType;
$this->itemType = $itemType;
return $this;
}
public function getFieldType(): int
public function getValueType(): int
{
return $this->fieldType;
return $this->valueType;
}
public function setFieldType(int $fieldType): self
public function setValueType(int $valueType): self
{
$this->fieldType = $fieldType;
$this->valueType = $valueType;
return $this;
}
@ -387,7 +387,7 @@ class ExtraField
public function getTypeToString(): string
{
switch ($this->getExtraFieldType()) {
switch ($this->getItemType()) {
case \ExtraField::FIELD_TYPE_RADIO:
case \ExtraField::FIELD_TYPE_SELECT:
return 'choice';

@ -66,10 +66,10 @@ class ExtraFieldValues
protected ?int $id = null;
/**
* @ORM\Column(name="value", type="text", nullable=true, unique=false)
* @ORM\Column(name="field_value", type="text", nullable=true, unique=false)
*/
#[Groups(['extra_field_values:read', 'extra_field_values:write'])]
protected ?string $value = null;
protected ?string $fieldValue = null;
/**
* @ORM\ManyToOne(targetEntity="Chamilo\CoreBundle\Entity\ExtraField")
@ -151,14 +151,14 @@ class ExtraFieldValues
return $this->id;
}
public function getValue(): ?string
public function getFieldValue(): ?string
{
return $this->value;
return $this->fieldValue;
}
public function setValue(?string $value): self
public function setFieldValue(?string $fieldValue): self
{
$this->value = $value;
$this->fieldValue = $fieldValue;
return $this;
}

@ -64,18 +64,18 @@ class UserExtraFieldFilter extends AbstractContextAwareFilter
"$alias.user = efv.itemId"
)
->innerJoin(ExtraField::class, 'ef', Join::WITH, 'efv.field = ef.id')
->andWhere('ef.extraFieldType = :extraFieldType')
->andWhere('ef.itemType = :itemType')
->andWhere('ef.variable = :variable')
;
$queryBuilder
->setParameter('extraFieldType', ExtraField::USER_FIELD_TYPE)
->setParameter('itemType', ExtraField::USER_FIELD_TYPE)
->setParameter('variable', $value)
;
break;
case 'userExtraFieldValue':
$queryBuilder->andWhere('efv.value = :value');
$queryBuilder->andWhere('efv.field_value = :value');
$queryBuilder->setParameter('value', $value);

@ -65,7 +65,7 @@ class ExtraFieldType extends AbstractType
$data = [];
foreach ($values as $value) {
$data[$value->getField()->getVariable()] = $value->getValue();
$data[$value->getField()->getVariable()] = $value->getFieldValue();
}
$gMapsPlugin = GoogleMapsPlugin::create();
@ -85,7 +85,7 @@ class ExtraFieldType extends AbstractType
];
// @todo validate data.
switch ($extraField->getFieldType()) {
switch ($extraField->getValueType()) {
case \ExtraField::FIELD_TYPE_DOUBLE_SELECT:
case \ExtraField::FIELD_TYPE_DIVIDER:
case \ExtraField::FIELD_TYPE_TIMEZONE:
@ -209,22 +209,22 @@ class ExtraFieldType extends AbstractType
case \ExtraField::FIELD_TYPE_SELECT_MULTIPLE:
if (empty($value)) {
$defaultOptions['data'] = null;
if (\ExtraField::FIELD_TYPE_CHECKBOX === $extraField->getFieldType()) {
if (\ExtraField::FIELD_TYPE_CHECKBOX === $extraField->getValueType()) {
$defaultOptions['data'] = [];
}
}
$options = $extraField->getOptions();
$choices = [];
foreach ($options as $option) {
$choices[$option->getDisplayText()] = $option->getValue();
$choices[$option->getDisplayText()] = $option->getFieldValue();
}
$defaultOptions['choices'] = $choices;
if (\ExtraField::FIELD_TYPE_SELECT === $extraField->getFieldType()) {
if (\ExtraField::FIELD_TYPE_SELECT === $extraField->getValueType()) {
$defaultOptions['expanded'] = false;
$defaultOptions['multiple'] = false;
}
if (\ExtraField::FIELD_TYPE_SELECT_MULTIPLE === $extraField->getFieldType()) {
if (\ExtraField::FIELD_TYPE_SELECT_MULTIPLE === $extraField->getValueType()) {
$defaultOptions['expanded'] = false;
$defaultOptions['multiple'] = true;
}
@ -241,7 +241,7 @@ class ExtraFieldType extends AbstractType
foreach ($extraFields as $extraField) {
$newValue = $data[$extraField->getVariable()] ?? null;
if (!empty($newValue)) {
if (\ExtraField::FIELD_TYPE_TAG === $extraField->getFieldType()) {
if (\ExtraField::FIELD_TYPE_TAG === $extraField->getValueType()) {
$formItem = $event->getForm()->get($extraField->getVariable());
$formItem->setData($newValue);
}
@ -256,7 +256,7 @@ class ExtraFieldType extends AbstractType
foreach ($extraFields as $extraField) {
$newValue = $data[$extraField->getVariable()] ?? null;
switch ($extraField->getFieldType()) {
switch ($extraField->getValueType()) {
case \ExtraField::FIELD_TYPE_GEOLOCALIZATION_COORDINATES:
case \ExtraField::FIELD_TYPE_GEOLOCALIZATION:
if (!empty($newValue)) {

@ -372,6 +372,11 @@ class Version20 extends AbstractMigrationChamilo
$this->addSql('CREATE TABLE IF NOT EXISTS ext_translations (id INT AUTO_INCREMENT NOT NULL, locale VARCHAR(8) NOT NULL, object_class VARCHAR(191) NOT NULL, field VARCHAR(32) NOT NULL, foreign_key VARCHAR(64) NOT NULL, content LONGTEXT DEFAULT NULL, INDEX translations_lookup_idx (locale, object_class, foreign_key), UNIQUE INDEX lookup_unique_idx (locale, object_class, field, foreign_key), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB ROW_FORMAT = DYNAMIC;');
// Rename extra_field field_type and extra_field_type to item_type and value_type, also, the term "value" in exta_field_values.value renamed to field_value
$this->addSql('ALTER TABLE extra_field CHANGE extra_field_type item_type INT NOT NULL');
$this->addSql('ALTER TABLE extra_field CHANGE field_type value_type INT NOT NULL');
$this->addSql('ALTER TABLE extra_field_values CHANGE `value` field_value LONGTEXT DEFAULT NULL');
// Drop unused columns
$dropColumnsAndIndex = [
'track_e_uploads' => [

@ -281,8 +281,8 @@ class Version20180319145700 extends AbstractMigrationChamilo
ON efv.field_id = ef.id
WHERE
ef.variable = "is_mandatory" AND
ef.extra_field_type = '.ExtraField::SURVEY_FIELD_TYPE.' AND
efv.value = 1
ef.item_type = '.ExtraField::SURVEY_FIELD_TYPE.' AND
efv.field_value = 1
';
$result = $em->getConnection()->executeQuery($sql);

@ -293,7 +293,7 @@ class Version20181025064351 extends AbstractMigrationChamilo
'UPDATE gradebook_certificate gc SET downloaded_at = (
SELECT value from extra_field e
INNER JOIN extra_field_values v on v.field_id = e.id
WHERE variable = "downloaded_at" and extra_field_type = 11 and item_id = gc.id
WHERE variable = "downloaded_at" and item_type = 11 and item_id = gc.id
)'
);
}

@ -37,8 +37,8 @@ class Version20191206150030 extends AbstractMigrationChamilo
/** @var ExtraFieldValues $item */
foreach ($q->toIterable() as $item) {
if (\in_array($item->getField()->getFieldType(), $fieldWithFiles, true)) {
$path = $item->getValue();
if (\in_array($item->getField()->getValueType(), $fieldWithFiles, true)) {
$path = $item->getFieldValue();
if (empty($path)) {
continue;
}

@ -79,7 +79,7 @@ final class Version20201212195011 extends AbstractMigrationChamilo
// Special course.
$extraFieldType = ExtraField::COURSE_FIELD_TYPE;
$sql = "SELECT id FROM extra_field
WHERE extra_field_type = $extraFieldType AND variable = 'special_course'";
WHERE item_type = $extraFieldType AND variable = 'special_course'";
$result = $connection->executeQuery($sql);
$extraFieldId = $result->fetchOne();

@ -27,7 +27,7 @@ class ExtraFieldRepository extends ServiceEntityRepository
->where(
$qb->expr()->andX(
$qb->expr()->eq('f.visibleToSelf', true),
$qb->expr()->eq('f.extraFieldType', $type)
$qb->expr()->eq('f.itemType', $type)
)
)
;

@ -45,7 +45,7 @@ class ExtraFieldValuesRepository extends ServiceEntityRepository
)
->where(
$qb->expr()->andX(
$qb->expr()->eq('f.extraFieldType', $extraFieldType),
$qb->expr()->eq('f.itemType', $extraFieldType),
$qb->expr()->eq('fv.itemId', $itemId),
$qb->expr()->eq('f.visibleToSelf', true)
)
@ -68,7 +68,7 @@ class ExtraFieldValuesRepository extends ServiceEntityRepository
->andWhere('v.itemId = :id')
->andWhere(
$qb->expr()->eq('f.visibleToSelf', true),
$qb->expr()->eq('f.extraFieldType', $type)
$qb->expr()->eq('f.itemType', $type)
)
->setParameter(
'id',
@ -98,7 +98,7 @@ class ExtraFieldValuesRepository extends ServiceEntityRepository
$extraFieldValues = (new ExtraFieldValues())
->setItemId($itemId)
->setField($extraField)
->setValue($data)
->setFieldValue($data)
;
$em->persist($extraFieldValues);
$em->flush();

@ -32,8 +32,8 @@ class ExtraFieldOptionsRepositoryTest extends AbstractApiTest
->setVariable('test')
->setDescription('desc')
->setHelperText('help')
->setExtraFieldType(ExtraField::USER_FIELD_TYPE)
->setFieldType(\ExtraField::FIELD_TYPE_TEXT)
->setItemType(ExtraField::USER_FIELD_TYPE)
->setValueType(\ExtraField::FIELD_TYPE_TEXT)
;
$em->persist($extraField);

@ -29,8 +29,8 @@ class ExtraFieldRepositoryTest extends AbstractApiTest
->setVariable('test')
->setDescription('desc')
->setHelperText('help')
->setExtraFieldType(ExtraField::USER_FIELD_TYPE)
->setFieldType(\ExtraField::FIELD_TYPE_TEXT)
->setItemType(ExtraField::USER_FIELD_TYPE)
->setValueType(\ExtraField::FIELD_TYPE_TEXT)
->setDefaultValue('')
->setFieldOrder(1)
;
@ -39,7 +39,7 @@ class ExtraFieldRepositoryTest extends AbstractApiTest
$em->flush();
$this->assertSame($defaultCount + 1, $repo->count([]));
$this->assertSame(ExtraField::USER_FIELD_TYPE, $extraField->getExtraFieldType());
$this->assertSame(ExtraField::USER_FIELD_TYPE, $extraField->getItemType());
$this->assertSame('', $extraField->getDefaultValue());
$this->assertSame('desc', $extraField->getDescription());
$this->assertSame('text', $extraField->getTypeToString());
@ -72,8 +72,8 @@ class ExtraFieldRepositoryTest extends AbstractApiTest
$extraField = (new ExtraField())
->setDisplayText('test in ENGLISH')
->setVariable('test in en')
->setExtraFieldType(ExtraField::USER_FIELD_TYPE)
->setFieldType(\ExtraField::FIELD_TYPE_TEXT)
->setItemType(ExtraField::USER_FIELD_TYPE)
->setValueType(\ExtraField::FIELD_TYPE_TEXT)
;
$this->assertHasNoEntityViolations($extraField);
$em->persist($extraField);
@ -142,8 +142,8 @@ class ExtraFieldRepositoryTest extends AbstractApiTest
$item = (new ExtraField())
->setDisplayText('test')
->setVariable('test')
->setExtraFieldType(ExtraField::USER_FIELD_TYPE)
->setFieldType(\ExtraField::FIELD_TYPE_TEXT)
->setItemType(ExtraField::USER_FIELD_TYPE)
->setValueType(\ExtraField::FIELD_TYPE_TEXT)
;
$em->persist($item);

@ -34,8 +34,8 @@ class ExtraFieldValuesRepositoryTest extends AbstractApiTest
->setVisibleToSelf(true)
->setDisplayText('test')
->setVariable('test')
->setExtraFieldType(ExtraField::USER_FIELD_TYPE)
->setFieldType(\ExtraField::FIELD_TYPE_TEXT)
->setItemType(ExtraField::USER_FIELD_TYPE)
->setValueType(\ExtraField::FIELD_TYPE_TEXT)
;
$em->persist($field);
$em->flush();
@ -91,8 +91,8 @@ class ExtraFieldValuesRepositoryTest extends AbstractApiTest
->setDisplayText('test')
->setVariable('test')
->setVisibleToSelf(true)
->setExtraFieldType(ExtraField::USER_FIELD_TYPE)
->setFieldType(\ExtraField::FIELD_TYPE_TEXT)
->setItemType(ExtraField::USER_FIELD_TYPE)
->setValueType(\ExtraField::FIELD_TYPE_TEXT)
;
$em->persist($field);
$em->flush();
@ -113,8 +113,8 @@ class ExtraFieldValuesRepositoryTest extends AbstractApiTest
->setDisplayText('test2')
->setVariable('test2')
->setVisibleToSelf(true)
->setExtraFieldType(ExtraField::COURSE_FIELD_TYPE)
->setFieldType(\ExtraField::FIELD_TYPE_TEXT)
->setItemType(ExtraField::COURSE_FIELD_TYPE)
->setValueType(\ExtraField::FIELD_TYPE_TEXT)
;
$em->persist($field);
$em->flush();

@ -29,8 +29,8 @@ class TagRepositoryTest extends AbstractApiTest
$extraField = (new ExtraField())
->setDisplayText('test')
->setVariable('test')
->setExtraFieldType(ExtraField::USER_FIELD_TYPE)
->setFieldType(\ExtraField::FIELD_TYPE_TAG)
->setItemType(ExtraField::USER_FIELD_TYPE)
->setValueType(\ExtraField::FIELD_TYPE_TAG)
;
$em->persist($extraField);
$em->flush();
@ -63,8 +63,8 @@ class TagRepositoryTest extends AbstractApiTest
$extraField = (new ExtraField())
->setDisplayText('test')
->setVariable('test')
->setExtraFieldType(ExtraField::USER_FIELD_TYPE)
->setFieldType(\ExtraField::FIELD_TYPE_TAG)
->setItemType(ExtraField::USER_FIELD_TYPE)
->setValueType(\ExtraField::FIELD_TYPE_TAG)
;
$em->persist($extraField);
$em->flush();
@ -115,8 +115,8 @@ class TagRepositoryTest extends AbstractApiTest
$extraField = (new ExtraField())
->setDisplayText('test')
->setVariable('test')
->setExtraFieldType(ExtraField::USER_FIELD_TYPE)
->setFieldType(\ExtraField::FIELD_TYPE_TAG)
->setItemType(ExtraField::USER_FIELD_TYPE)
->setValueType(\ExtraField::FIELD_TYPE_TAG)
;
$em->persist($extraField);
@ -156,8 +156,8 @@ class TagRepositoryTest extends AbstractApiTest
$extraField = (new ExtraField())
->setDisplayText('test')
->setVariable('test')
->setExtraFieldType(ExtraField::USER_FIELD_TYPE)
->setFieldType(\ExtraField::FIELD_TYPE_TAG)
->setItemType(ExtraField::USER_FIELD_TYPE)
->setValueType(\ExtraField::FIELD_TYPE_TAG)
;
$em->persist($extraField);
$em->flush();

@ -9,7 +9,7 @@ Feature: User extra fields
When I fill in the following:
| display_text | Behat extra field |
| variable | behat_extra_field |
And I fill in select bootstrap static input "#field_type" select "1"
And I fill in select bootstrap static input "#value_type" select "1"
And I press "submit"
And wait the page to be loaded when ready
Then I should see "Item added"

@ -16,18 +16,18 @@ $repo = $em->getRepository('ChamiloCoreBundle:ExtraField');
$extraFields = $repo->findAll();
$list = [
'legal_accept' => "INSERT INTO extra_field (extra_field_type, field_type, variable, display_text, visible_to_self, changeable, created_at) VALUES (1, 1, 'legal_accept','Legal',0,0, NOW());",
'already_logged_in' => "INSERT INTO extra_field (extra_field_type, field_type, variable, display_text, visible_to_self, changeable, created_at) VALUES (1, 1, 'already_logged_in','Already logged in',0,0, NOW());",
'update_type' => "INSERT INTO extra_field (extra_field_type, field_type, variable, display_text, visible_to_self, changeable, created_at) VALUES (1, 1, 'update_type','Update script type',0,0, NOW())",
'rssfeeds' => "INSERT INTO extra_field (extra_field_type, field_type, variable, display_text, visible_to_self, changeable, created_at) VALUES (1, 1, 'rssfeeds','RSS',0,0, NOW())",
'dashboard' => "INSERT INTO extra_field (extra_field_type, field_type, variable, display_text, visible_to_self, changeable, created_at) VALUES (1, 1, 'dashboard', 'Dashboard', 0, 0, NOW())",
'timezone' => "INSERT INTO extra_field (extra_field_type, field_type, variable, display_text, visible_to_self, changeable, created_at) VALUES (1, 11, 'timezone', 'Timezone', 0, 0, NOW())",
'user_chat_status' => "INSERT INTO extra_field (extra_field_type, field_type, variable, display_text, visible_to_self, changeable, created_at) VALUES (1, 1, 'user_chat_status','User chat status',0,0, NOW())",
'google_calendar_url' => "INSERT INTO extra_field (extra_field_type, field_type, variable, display_text, visible_to_self, changeable, created_at) VALUES (1, 1, 'google_calendar_url','Google Calendar URL',0,0, NOW())",
'special_course' => "INSERT INTO extra_field (extra_field_type, field_type, variable, display_text, visible_to_self, changeable, default_value, created_at) VALUES (2, 13, 'special_course', 'Special course', 1 , 1, '', NOW())",
'video_url' => "INSERT INTO extra_field (extra_field_type, field_type, variable, display_text, visible_to_self, changeable, created_at) VALUES (2, 19, 'video_url', 'VideoUrl', 1, 1, NOW())",
'image' => "INSERT INTO extra_field (extra_field_type, field_type, variable, display_text, visible_to_self, changeable, created_at) VALUES (3, 16, 'image', 'Image', 1, 1, NOW())",
'captcha_blocked_until_date' => "INSERT INTO extra_field (extra_field_type, field_type, variable, display_text, visible_to_self, changeable, created_at) VALUES (1, 1, 'captcha_blocked_until_date', 'Account locked until', 0, 0, NOW())",
'legal_accept' => "INSERT INTO extra_field (item_type, value_type, variable, display_text, visible_to_self, changeable, created_at) VALUES (1, 1, 'legal_accept','Legal',0,0, NOW());",
'already_logged_in' => "INSERT INTO extra_field (item_type, value_type, variable, display_text, visible_to_self, changeable, created_at) VALUES (1, 1, 'already_logged_in','Already logged in',0,0, NOW());",
'update_type' => "INSERT INTO extra_field (item_type, value_type, variable, display_text, visible_to_self, changeable, created_at) VALUES (1, 1, 'update_type','Update script type',0,0, NOW())",
'rssfeeds' => "INSERT INTO extra_field (item_type, value_type, variable, display_text, visible_to_self, changeable, created_at) VALUES (1, 1, 'rssfeeds','RSS',0,0, NOW())",
'dashboard' => "INSERT INTO extra_field (item_type, value_type, variable, display_text, visible_to_self, changeable, created_at) VALUES (1, 1, 'dashboard', 'Dashboard', 0, 0, NOW())",
'timezone' => "INSERT INTO extra_field (item_type, value_type, variable, display_text, visible_to_self, changeable, created_at) VALUES (1, 11, 'timezone', 'Timezone', 0, 0, NOW())",
'user_chat_status' => "INSERT INTO extra_field (item_type, value_type, variable, display_text, visible_to_self, changeable, created_at) VALUES (1, 1, 'user_chat_status','User chat status',0,0, NOW())",
'google_calendar_url' => "INSERT INTO extra_field (item_type, value_type, variable, display_text, visible_to_self, changeable, created_at) VALUES (1, 1, 'google_calendar_url','Google Calendar URL',0,0, NOW())",
'special_course' => "INSERT INTO extra_field (item_type, value_type, variable, display_text, visible_to_self, changeable, default_value, created_at) VALUES (2, 13, 'special_course', 'Special course', 1 , 1, '', NOW())",
'video_url' => "INSERT INTO extra_field (item_type, value_type, variable, display_text, visible_to_self, changeable, created_at) VALUES (2, 19, 'video_url', 'VideoUrl', 1, 1, NOW())",
'image' => "INSERT INTO extra_field (item_type, value_type, variable, display_text, visible_to_self, changeable, created_at) VALUES (3, 16, 'image', 'Image', 1, 1, NOW())",
'captcha_blocked_until_date' => "INSERT INTO extra_field (item_type, value_type, variable, display_text, visible_to_self, changeable, created_at) VALUES (1, 1, 'captcha_blocked_until_date', 'Account locked until', 0, 0, NOW())",
];
$extraFieldList = [];
@ -46,7 +46,7 @@ foreach ($list as $variable => $sql) {
}
if (!isset($extraFieldList['mail_notify_invitation'])) {
$sql = "INSERT INTO extra_field (extra_field_type, field_type, variable, display_text, visible_to_self, changeable, default_value, created_at) values (1, 4, 'mail_notify_invitation', 'MailNotifyInvitation',0,1,'1', NOW())";
$sql = "INSERT INTO extra_field (item_type, value_type, variable, display_text, visible_to_self, changeable, default_value, created_at) values (1, 4, 'mail_notify_invitation', 'MailNotifyInvitation',0,1,'1', NOW())";
Database::query($sql);
$queriesExecuted[] = $sql;
$id = Database::insert_id();
@ -62,7 +62,7 @@ if (!isset($extraFieldList['mail_notify_invitation'])) {
}
if (!isset($extraFieldList['mail_notify_message'])) {
$sql = "INSERT INTO extra_field (extra_field_type, field_type, variable, display_text, visible_to_self, changeable, default_value, created_at) values (1, 4, 'mail_notify_message', 'MailNotifyMessage',0,1,'1', NOW())";
$sql = "INSERT INTO extra_field (item_type, value_type, variable, display_text, visible_to_self, changeable, default_value, created_at) values (1, 4, 'mail_notify_message', 'MailNotifyMessage',0,1,'1', NOW())";
Database::query($sql);
$queriesExecuted[] = $sql;
@ -83,7 +83,7 @@ if (!isset($extraFieldList['mail_notify_message'])) {
}
if (!isset($extraFieldList['mail_notify_group_message'])) {
$sql = "INSERT INTO extra_field (extra_field_type, field_type, variable, display_text, visible_to_self, changeable, default_value, created_at) values (1, 4, 'mail_notify_group_message','MailNotifyGroupMessage',0,1,'1', NOW())";
$sql = "INSERT INTO extra_field (item_type, value_type, variable, display_text, visible_to_self, changeable, default_value, created_at) values (1, 4, 'mail_notify_group_message','MailNotifyGroupMessage',0,1,'1', NOW())";
Database::query($sql);
$queriesExecuted[] = $sql;
$id = Database::insert_id();
@ -104,22 +104,22 @@ $tag1Exists = false;
$tag2Exists = false;
foreach ($extraFields as $extraField) {
if ($extraField->getVariable() === 'tags' && $extraField->getExtraFieldType() == 1) {
if ($extraField->getVariable() === 'tags' && $extraField->getItemType() == 1) {
$tag1Exists = true;
}
if ($extraField->getVariable() === 'tags' && $extraField->getExtraFieldType() == 2) {
if ($extraField->getVariable() === 'tags' && $extraField->getItemType() == 2) {
$tag2Exists = true;
}
}
if ($tag1Exists === false) {
$sql = "INSERT INTO extra_field (extra_field_type, field_type, variable, display_text, visible_to_self, changeable, created_at) VALUES (1, 10, 'tags','tags',0,0, NOW())";
$sql = "INSERT INTO extra_field (item_type, value_type, variable, display_text, visible_to_self, changeable, created_at) VALUES (1, 10, 'tags','tags',0,0, NOW())";
Database::query($sql);
$queriesExecuted[] = $sql;
}
if ($tag2Exists === false) {
$sql = "INSERT INTO extra_field (extra_field_type, field_type, variable, display_text, visible_to_self, changeable, created_at) VALUES (2, 10, 'tags', 'Tags', 1, 1, NOW())";
$sql = "INSERT INTO extra_field (item_type, value_type, variable, display_text, visible_to_self, changeable, created_at) VALUES (2, 10, 'tags', 'Tags', 1, 1, NOW())";
Database::query($sql);
$queriesExecuted[] = $sql;
}

@ -11,7 +11,7 @@ api_protect_admin_script();
$teachingHours = new ExtraField('session');
$teachingHours->save(array(
'field_type' => ExtraField::FIELD_TYPE_INTEGER,
'value_type' => ExtraField::FIELD_TYPE_INTEGER,
'variable' => 'teaching_hours',
'display_text' => get_lang('TeachingHours'),
'visible' => 1,
@ -20,7 +20,7 @@ $teachingHours->save(array(
$cost = new ExtraField('session');
$cost->save(array(
'field_type' => ExtraField::FIELD_TYPE_FLOAT,
'value_type' => ExtraField::FIELD_TYPE_FLOAT,
'variable' => 'cost',
'display_text' => get_lang('Cost'),
'visible' => 1,
@ -29,7 +29,7 @@ $cost->save(array(
$vacancies = new ExtraField('session');
$vacancies->save(array(
'field_type' => ExtraField::FIELD_TYPE_INTEGER,
'value_type' => ExtraField::FIELD_TYPE_INTEGER,
'variable' => 'vacancies',
'display_text' => get_lang('Vacancies'),
'visible' => 1,
@ -38,7 +38,7 @@ $vacancies->save(array(
$recommendedNumberOfParticipants = new ExtraField('session');
$recommendedNumberOfParticipants->save(array(
'field_type' => ExtraField::FIELD_TYPE_INTEGER,
'value_type' => ExtraField::FIELD_TYPE_INTEGER,
'variable' => 'recommended_number_of_participants',
'display_text' => get_lang('RecommendedNumberOfParticipants'),
'visible' => 1,
@ -47,7 +47,7 @@ $recommendedNumberOfParticipants->save(array(
$place = new ExtraField('session');
$place->save(array(
'field_type' => ExtraField::FIELD_TYPE_ALPHANUMERIC,
'value_type' => ExtraField::FIELD_TYPE_ALPHANUMERIC,
'variable' => 'place',
'display_text' => get_lang('Place'),
'visible' => 1,
@ -56,7 +56,7 @@ $place->save(array(
$schedule = new ExtraField('session');
$schedule->save(array(
'field_type' => ExtraField::FIELD_TYPE_TEXT,
'value_type' => ExtraField::FIELD_TYPE_TEXT,
'variable' => 'schedule',
'display_text' => get_lang('Schedule'),
'visible' => 1,
@ -65,7 +65,7 @@ $schedule->save(array(
$allowVisitors = new ExtraField('session');
$allowVisitors->save(array(
'field_type' => ExtraField::FIELD_TYPE_CHECKBOX,
'value_type' => ExtraField::FIELD_TYPE_CHECKBOX,
'variable' => 'allow_visitors',
'display_text' => get_lang('AllowVisitors'),
'visible' => 1,
@ -80,7 +80,7 @@ $modeOptions = array(
$mode = new ExtraField('session');
$mode->save(array(
'field_type' => ExtraField::FIELD_TYPE_SELECT,
'value_type' => ExtraField::FIELD_TYPE_SELECT,
'variable' => 'mode',
'display_text' => get_lang('Mode'),
'visible' => 1,
@ -90,7 +90,7 @@ $mode->save(array(
$isInductionSession = new ExtraField('session');
$isInductionSession->save(array(
'field_type' => ExtraField::FIELD_TYPE_CHECKBOX,
'value_type' => ExtraField::FIELD_TYPE_CHECKBOX,
'variable' => 'is_induccion_session',
'display_text' => get_lang('IsInductionSession'),
'visible' => 1,
@ -99,7 +99,7 @@ $isInductionSession->save(array(
$isOpenSession = new ExtraField('session');
$isOpenSession->save(array(
'field_type' => ExtraField::FIELD_TYPE_CHECKBOX,
'value_type' => ExtraField::FIELD_TYPE_CHECKBOX,
'variable' => 'is_open_session',
'display_text' => get_lang('IsOpenSession'),
'visible' => 1,
@ -108,7 +108,7 @@ $isOpenSession->save(array(
$duration = new ExtraField('session');
$duration->save(array(
'field_type' => ExtraField::FIELD_TYPE_LETTERS_ONLY,
'value_type' => ExtraField::FIELD_TYPE_LETTERS_ONLY,
'variable' => 'human_text_duration',
'display_text' => get_lang('DurationInWords'),
'visible' => 1,
@ -123,7 +123,7 @@ $showStatusOptions = array(
$showStatus = new ExtraField('session');
$showStatus->save(array(
'field_type' => ExtraField::FIELD_TYPE_SELECT,
'value_type' => ExtraField::FIELD_TYPE_SELECT,
'variable' => 'show_status',
'display_text' => get_lang('ShowStatus'),
'visible' => 1,
@ -133,7 +133,7 @@ $showStatus->save(array(
$publicationStartDate = new ExtraField('session');
$publicationStartDate->save(array(
'field_type' => ExtraField::FIELD_TYPE_DATE,
'value_type' => ExtraField::FIELD_TYPE_DATE,
'variable' => 'publication_start_date',
'display_text' => get_lang('PublicationStartDate'),
'visible' => 1,
@ -142,7 +142,7 @@ $publicationStartDate->save(array(
$publicationEndDate = new ExtraField('session');
$publicationEndDate->save(array(
'field_type' => ExtraField::FIELD_TYPE_DATE,
'value_type' => ExtraField::FIELD_TYPE_DATE,
'variable' => 'publication_end_date',
'display_text' => get_lang('PublicationEndDate'),
'visible' => 1,
@ -151,7 +151,7 @@ $publicationEndDate->save(array(
$banner = new ExtraField('session');
$banner->save(array(
'field_type' => ExtraField::FIELD_TYPE_FILE_IMAGE,
'value_type' => ExtraField::FIELD_TYPE_FILE_IMAGE,
'variable' => 'banner',
'display_text' => get_lang('SessionBanner'),
'visible' => 1,
@ -160,7 +160,7 @@ $banner->save(array(
$brochure = new ExtraField('session');
$brochure->save(array(
'field_type' => ExtraField::FIELD_TYPE_FILE,
'value_type' => ExtraField::FIELD_TYPE_FILE,
'variable' => 'brochure',
'display_text' => get_lang('Brochure'),
'visible' => 1,
@ -174,7 +174,7 @@ $targetOptions = array(
$target = new ExtraField('session');
$target->save(array(
'field_type' => ExtraField::FIELD_TYPE_SELECT,
'value_type' => ExtraField::FIELD_TYPE_SELECT,
'variable' => 'target',
'display_text' => get_lang('Target'),
'visible' => 1,
@ -184,7 +184,7 @@ $target->save(array(
$shortDescription = new ExtraField('session');
$shortDescription->save(array(
'field_type' => ExtraField::FIELD_TYPE_TEXT,
'value_type' => ExtraField::FIELD_TYPE_TEXT,
'variable' => 'short_description',
'display_text' => get_lang('ShortDescription'),
'visible' => 1,
@ -193,7 +193,7 @@ $shortDescription->save(array(
$id = new ExtraField('session');
$id->save(array(
'field_type' => ExtraField::FIELD_TYPE_TEXT,
'value_type' => ExtraField::FIELD_TYPE_TEXT,
'variable' => 'code',
'display_text' => get_lang('Code'),
'visible' => 1,

@ -18,12 +18,12 @@ $tUserFieldValue = Database::get_main_table(TABLE_EXTRA_FIELD_VALUES);
$tUser = Database::get_main_table(TABLE_MAIN_USER);
// First get the IDs of the selected fields
$sql = "SELECT id, field_type, variable FROM $tUserField";
$sql = "SELECT id, value_type, variable FROM $tUserField";
$result = Database::query($sql);
$foundFields = array();
$fieldsNames = array();
while ($row = Database::fetch_assoc($result)) {
if ($row['field_type'] == 1 && in_array($row['variable'], $referenceFields)) {
if ($row['value_type'] == 1 && in_array($row['variable'], $referenceFields)) {
$foundFields[$row['variable']] = array('id' => $row['id']);
$fieldsNames[$row['id']] = $row['variable'];
}

Loading…
Cancel
Save