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 = [ $params = [
'variable' => $variable, 'variable' => $variable,
'display_text' => $label, 'display_text' => $label,
'field_type' => ExtraField::FIELD_TYPE_TEXTAREA, 'value_type' => ExtraField::FIELD_TYPE_TEXTAREA,
'default_value' => '', 'default_value' => '',
'visible' => true, 'visible' => true,
'changeable' => true, 'changeable' => true,

@ -61,10 +61,10 @@ if (isset($new_language) && isset($language_variable) && isset($file_id)) {
Display::addFlash($message); 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'; $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: case ExtraField::USER_FIELD_TYPE:
header("Location: {$redirectUrl}?type=user"); header("Location: {$redirectUrl}?type=user");
exit; exit;

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

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

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

@ -524,7 +524,7 @@ function getExtraFieldConditions(array $formValues, $queryType = 'from')
$value = $formValues["extra_$variable"]; $value = $formValues["extra_$variable"];
switch ($field['field_type']) { switch ($field['value_type']) {
case ExtraField::FIELD_TYPE_CHECKBOX: case ExtraField::FIELD_TYPE_CHECKBOX:
$value = $value["extra_$variable"]; $value = $value["extra_$variable"];
break; break;
@ -547,17 +547,17 @@ function getExtraFieldConditions(array $formValues, $queryType = 'from')
$where .= "AND ( $where .= "AND (
qu.iid = efv_$variable.item_id qu.iid = efv_$variable.item_id
AND efv_$variable.field_id = ef_$variable.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 ef_$variable.variable = '$variable'
AND efv_$variable.value = '$value' AND efv_$variable.field_value = '$value'
)"; )";
} elseif ('join' === $queryType) { } elseif ('join' === $queryType) {
$from .= " INNER JOIN extra_field_values efv_$variable ON qu.iid = efv_$variable.item_id $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"; INNER JOIN extra_field ef_$variable ON efv_$variable.field_id = ef_$variable.id";
$where .= "AND ( $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 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')]; $interbreadcrumb[] = ['url' => api_get_path(WEB_CODE_PATH).'admin', 'name' => get_lang('Administration')];
$type = \ExtraField::getExtraFieldTypeFromInt($extraField->getExtraFieldType()); $type = \ExtraField::getExtraFieldTypeFromInt($extraField->getItemType());
$interbreadcrumb[] = [ $interbreadcrumb[] = [
'url' => api_get_path(WEB_CODE_PATH).'admin/extra_fields.php?type='.$type, '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')]; $interbreadcrumb[] = ['url' => api_get_path(WEB_CODE_PATH).'admin', 'name' => get_lang('Administration')];
$type = \ExtraField::getExtraFieldTypeFromInt($extraField->getExtraFieldType()); $type = \ExtraField::getExtraFieldTypeFromInt($extraField->getItemType());
$interbreadcrumb[] = [ $interbreadcrumb[] = [
'url' => api_get_path(WEB_CODE_PATH).'admin/extra_fields.php?type='.$type, 'url' => api_get_path(WEB_CODE_PATH).'admin/extra_fields.php?type='.$type,

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

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

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

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

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

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

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

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

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

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

@ -1375,7 +1375,7 @@ class SocialManager extends UserManager
} }
if (is_array($data)) { if (is_array($data)) {
switch ($extraFieldInfo['field_type']) { switch ($extraFieldInfo['value_type']) {
case ExtraField::FIELD_TYPE_RADIO: case ExtraField::FIELD_TYPE_RADIO:
$objEfOption = new ExtraFieldOption('user'); $objEfOption = new ExtraFieldOption('user');
$value = $data['extra_'.$extraFieldInfo['variable']]; $value = $data['extra_'.$extraFieldInfo['variable']];
@ -1411,7 +1411,7 @@ class SocialManager extends UserManager
break; break;
} }
} else { } else {
switch ($extraFieldInfo['field_type']) { switch ($extraFieldInfo['value_type']) {
case ExtraField::FIELD_TYPE_RADIO: case ExtraField::FIELD_TYPE_RADIO:
$objEfOption = new ExtraFieldOption('user'); $objEfOption = new ExtraFieldOption('user');
$optionInfo = $objEfOption->get_field_option_by_field_and_option($extraFieldInfo['id'], $extraFieldInfo['value']); $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 // Then, courses where $coach_id is coach of the session
$sql = "SELECT srcru.user_id $sql = "SELECT srcru.user_id
FROM $tbl_session_course_user srcru 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) 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 ON srcru.session_id = s.id AND src.session_id = s.id
INNER JOIN $tbl_session_user sru on s.id = sru.session_id INNER JOIN $tbl_session_user sru on s.id = sru.session_id
WHERE WHERE
srcru.status = ".SessionEntity::STUDENT." AND srcru.status = ".SessionEntity::STUDENT." AND
sru.relation_type = ".SessionEntity::GENERAL_COACH." AND sru.relation_type = ".SessionEntity::GENERAL_COACH." AND
sru.user_id = $coach_id"; sru.user_id = $coach_id";
if (-1 != $access_url_id) { if (-1 != $access_url_id) {
$sql = "SELECT srcru.user_id $sql = "SELECT srcru.user_id
FROM $tbl_session_course_user srcru 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) 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 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 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 ON s.id = aurs.session_id
WHERE WHERE
srcru.status = ".SessionEntity::STUDENT." AND srcru.status = ".SessionEntity::STUDENT." AND
sru.relation_type = ".SessionEntity::GENERAL_COACH." 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"; aurs.access_url_id = $access_url_id";
} }
@ -3641,13 +3641,13 @@ class Tracking
// Then, courses where $coach_id is coach of the session // Then, courses where $coach_id is coach of the session
$sql = "SELECT srcru.user_id $sql = "SELECT srcru.user_id
FROM $tbl_session_course_user srcru 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) 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 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 ON s.id = sru.session_id
WHERE WHERE
(srcru.status = ".SessionEntity::STUDENT." AND srcru.user_id = $student_id) AND (srcru.status = ".SessionEntity::STUDENT." AND srcru.user_id = $student_id) AND
(sru.relation_type = ".SessionEntity::GENERAL_COACH." AND sru.user_id = $coach_id)"; (sru.relation_type = ".SessionEntity::GENERAL_COACH." AND sru.user_id = $coach_id)";
$result = Database::query($sql); $result = Database::query($sql);
@ -8049,13 +8049,13 @@ class TrackingCourseLog
$sql = "SELECT s.id, s.name, u.name $sql = "SELECT s.id, s.name, u.name
FROM $tbl_thematic t FROM $tbl_thematic t
INNER JOIN $tblSessionRelUser sru INNER JOIN $tblSessionRelUser sru
ON t.session_id = sru.session_id ON t.session_id = sru.session_id
INNER JOIN $table_session s INNER JOIN $table_session s
ON sru.session_id = s.id ON sru.session_id = s.id
INNER JOIN $table_user u INNER JOIN $table_user u
ON sru.user_id = u.id ON sru.user_id = u.id
WHERE WHERE
t.c_id = $course_id AND t.c_id = $course_id AND
t.id = $thematic_id AND t.id = $thematic_id AND
sru.relation_type = ".SessionEntity::GENERAL_COACH; sru.relation_type = ".SessionEntity::GENERAL_COACH;
@ -8366,7 +8366,7 @@ class TrackingCourseLog
$result_extra_field = UserManager::get_extra_field_information($field_id); $result_extra_field = UserManager::get_extra_field_information($field_id);
$return = []; $return = [];
if (!empty($users)) { 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) { foreach ($users as $user_id) {
$user_result = UserManager::get_user_tags($user_id, $field_id); $user_result = UserManager::get_user_tags($user_id, $field_id);
$tag_list = []; $tag_list = [];
@ -8390,7 +8390,7 @@ class TrackingCourseLog
INNER JOIN $extraField f INNER JOIN $extraField f
ON (f.id = v.field_id) ON (f.id = v.field_id)
WHERE WHERE
f.extra_field_type = $extraFieldType AND f.item_type = $extraFieldType AND
v.field_id=".intval($field_id)." AND v.field_id=".intval($field_id)." AND
user.id IN ($users)"; user.id IN ($users)";
@ -8399,7 +8399,7 @@ class TrackingCourseLog
// get option value for field type double select by id // get option value for field type double select by id
if (!empty($row['value'])) { if (!empty($row['value'])) {
if (ExtraField::FIELD_TYPE_DOUBLE_SELECT == if (ExtraField::FIELD_TYPE_DOUBLE_SELECT ==
$result_extra_field['field_type'] $result_extra_field['value_type']
) { ) {
$id_double_select = explode(';', $row['value']); $id_double_select = explode(';', $row['value']);
if (is_array($id_double_select)) { 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']); $parsedValue = explode('::', $row['value']);
if ($parsedValue) { 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']); [$level1, $level2, $level3] = explode(';', $row['value']);
$row['value'] = $result_extra_field['options'][$level1]['display_text'].' / '; $row['value'] = $result_extra_field['options'][$level1]['display_text'].' / ';

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

@ -127,7 +127,7 @@ class Rest extends WebService
$extraField->save( $extraField->save(
[ [
'variable' => self::EXTRA_FIELD_GCM_REGISTRATION, '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, 'display_text' => self::EXTRA_FIELD_GCM_REGISTRATION,
] ]
); );
@ -788,7 +788,7 @@ class Rest extends WebService
$extraValue = $extra['value']; $extraValue = $extra['value'];
$result['extra'][] = [ $result['extra'][] = [
'title' => $extraValue->getField()->getDisplayText(), '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'), -- ('PC Skills','PC',NULL,2,0,'TRUE','TRUE'),
-- ('Projects','PROJ',NULL,3,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 (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 (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 (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 (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 (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 (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 (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 (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 (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 (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 (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 (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 (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 (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 (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 (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 (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 (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 (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 (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 (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 (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 (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 (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 (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 (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 (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 (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 (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 (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 (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 (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, '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, '1', 'AtOnce',1);
INSERT INTO extra_field_options (field_id, option_value, display_text, option_order) VALUES (8, '8', 'Daily',2); 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; 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 VALUES
(1, 1, 'skype', 'Skype', 1, 1, now()), (1, 1, 'skype', 'Skype', 1, 1, now()),
(1, 1, 'linkedin_url', 'LinkedInUrl', 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, 2);
INSERT INTO access_url_rel_course_category (access_url_id, course_category_id) VALUES (1, 3); 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())); 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; break;
} }
switch ($field['field_type']) { switch ($field['value_type']) {
case ExtraField::FIELD_TYPE_TEXT: case ExtraField::FIELD_TYPE_TEXT:
case ExtraField::FIELD_TYPE_ALPHANUMERIC: case ExtraField::FIELD_TYPE_ALPHANUMERIC:
$pos = stripos($extraFieldValueData['value'], $_REQUEST['extra_'.$field['variable']]); $pos = stripos($extraFieldValueData['value'], $_REQUEST['extra_'.$field['variable']]);

@ -126,7 +126,7 @@ if (!empty($items)) {
/** @var ExtraFieldSavedSearch $item */ /** @var ExtraFieldSavedSearch $item */
foreach ($items as $item) { foreach ($items as $item) {
$variable = 'extra_'.$item->getField()->getVariable(); $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(); $tagsData[$variable] = $item->getValue();
} }
$defaults[$variable] = $item->getValue(); $defaults[$variable] = $item->getValue();

@ -200,7 +200,7 @@ if (!empty($items)) {
/** @var ExtraFieldSavedSearch $item */ /** @var ExtraFieldSavedSearch $item */
foreach ($items as $item) { foreach ($items as $item) {
$variable = 'extra_'.$item->getField()->getVariable(); $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(); $tagsData[$variable] = $item->getValue();
} }
$defaults[$variable] = $item->getValue(); $defaults[$variable] = $item->getValue();

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

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

@ -94,14 +94,14 @@
{% for extra in user.extra %} {% for extra in user.extra %}
{% if extra.value.getField().getVariable() == 'skype' %} {% if extra.value.getField().getVariable() == 'skype' %}
{% set skype_account %} {% 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 }} <span class="fa fa-skype fa-fw" aria-hidden="true"></span> {{ 'Skype'|get_lang }}
</a> </a>
{% endset %} {% endset %}
{% endif %} {% endif %}
{% if extra.value.getField().getVariable() == 'linkedin_url' %} {% if extra.value.getField().getVariable() == 'linkedin_url' %}
{% set 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 }} <span class="fa fa-linkedin fa-fw" aria-hidden="true"></span> {{ 'LinkedIn'|get_lang }}
</a> </a>
{% endset %} {% endset %}

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

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

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

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

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

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

@ -798,7 +798,7 @@ function deleteDirWork($id)
foreach ($resultExtra as $field) { foreach ($resultExtra as $field) {
$field = $field['value']; $field = $field['value'];
if ($consideredWorkingTime == $field->getField()->getVariable()) { if ($consideredWorkingTime == $field->getField()->getVariable()) {
$workingTime = $field->getValue(); $workingTime = $field->getFieldValue();
break; break;
} }
@ -4833,7 +4833,7 @@ function processWorkForm(
foreach ($resultExtra as $field) { foreach ($resultExtra as $field) {
$field = $field['value']; $field = $field['value'];
if ($consideredWorkingTime == $field->getField()->getVariable()) { if ($consideredWorkingTime == $field->getField()->getVariable()) {
$workingTime = $field->getValue(); $workingTime = $field->getFieldValue();
} }
} }
@ -5357,7 +5357,7 @@ function deleteWorkItem($item_id, Course $course)
$field = $field['value']; $field = $field['value'];
if ($consideredWorkingTime == $field->getField()->getVariable()) { 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 // 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) { if (!$areaExists) {
$extraField = new ExtraField('user'); $extraField = new ExtraField('user');
$extraField->save([ $extraField->save([
'field_type' => 1, 'value_type' => 1,
'variable' => 'area', 'variable' => 'area',
'display_text' => get_plugin_lang('Area', 'AdvancedSubscriptionPlugin'), 'display_text' => get_plugin_lang('Area', 'AdvancedSubscriptionPlugin'),
'default_value' => null, '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 $tSessionField AS sf ON sfv.field_id = sf.id
INNER JOIN $tSessionUser AS su ON s.id = su.session_id INNER JOIN $tSessionUser AS su ON s.id = su.session_id
WHERE WHERE
sf.extra_field_type = $extraFieldType AND sf.item_type = $extraFieldType AND
sf.variable = 'is_induction_session' AND sf.variable = 'is_induction_session' AND
su.relation_type = ".Session::STUDENT." AND su.relation_type = ".Session::STUDENT." AND
su.user_id = ".(int) $userId; su.user_id = ".(int) $userId;

@ -13,7 +13,7 @@ api_protect_admin_script();
$teachingHours = new ExtraField('session'); $teachingHours = new ExtraField('session');
$teachingHours->save([ $teachingHours->save([
'field_type' => ExtraField::FIELD_TYPE_INTEGER, 'value_type' => ExtraField::FIELD_TYPE_INTEGER,
'variable' => 'teaching_hours', 'variable' => 'teaching_hours',
'display_text' => get_lang('Lecture hours'), 'display_text' => get_lang('Lecture hours'),
'visible_to_self' => 1, 'visible_to_self' => 1,
@ -22,7 +22,7 @@ $teachingHours->save([
$cost = new ExtraField('session'); $cost = new ExtraField('session');
$cost->save([ $cost->save([
'field_type' => ExtraField::FIELD_TYPE_FLOAT, 'value_type' => ExtraField::FIELD_TYPE_FLOAT,
'variable' => 'cost', 'variable' => 'cost',
'display_text' => get_lang('Cost'), 'display_text' => get_lang('Cost'),
'visible_to_self' => 1, 'visible_to_self' => 1,
@ -31,7 +31,7 @@ $cost->save([
$vacancies = new ExtraField('session'); $vacancies = new ExtraField('session');
$vacancies->save([ $vacancies->save([
'field_type' => ExtraField::FIELD_TYPE_INTEGER, 'value_type' => ExtraField::FIELD_TYPE_INTEGER,
'variable' => 'vacancies', 'variable' => 'vacancies',
'display_text' => get_lang('Vacancies'), 'display_text' => get_lang('Vacancies'),
'visible_to_self' => 1, 'visible_to_self' => 1,
@ -40,7 +40,7 @@ $vacancies->save([
$recommendedNumberOfParticipants = new ExtraField('session'); $recommendedNumberOfParticipants = new ExtraField('session');
$recommendedNumberOfParticipants->save([ $recommendedNumberOfParticipants->save([
'field_type' => ExtraField::FIELD_TYPE_INTEGER, 'value_type' => ExtraField::FIELD_TYPE_INTEGER,
'variable' => 'recommended_number_of_participants', 'variable' => 'recommended_number_of_participants',
'display_text' => get_lang('Recommended number of participants'), 'display_text' => get_lang('Recommended number of participants'),
'visible_to_self' => 1, 'visible_to_self' => 1,
@ -49,7 +49,7 @@ $recommendedNumberOfParticipants->save([
$place = new ExtraField('session'); $place = new ExtraField('session');
$place->save([ $place->save([
'field_type' => ExtraField::FIELD_TYPE_TEXT, 'value_type' => ExtraField::FIELD_TYPE_TEXT,
'variable' => 'place', 'variable' => 'place',
'display_text' => get_lang('Place/Location'), 'display_text' => get_lang('Place/Location'),
'visible_to_self' => 1, 'visible_to_self' => 1,
@ -58,7 +58,7 @@ $place->save([
$schedule = new ExtraField('session'); $schedule = new ExtraField('session');
$schedule->save([ $schedule->save([
'field_type' => ExtraField::FIELD_TYPE_TEXT, 'value_type' => ExtraField::FIELD_TYPE_TEXT,
'variable' => 'schedule', 'variable' => 'schedule',
'display_text' => get_lang('Schedule'), 'display_text' => get_lang('Schedule'),
'visible_to_self' => 1, 'visible_to_self' => 1,
@ -67,7 +67,7 @@ $schedule->save([
$allowVisitors = new ExtraField('session'); $allowVisitors = new ExtraField('session');
$allowVisitors->save([ $allowVisitors->save([
'field_type' => ExtraField::FIELD_TYPE_CHECKBOX, 'value_type' => ExtraField::FIELD_TYPE_CHECKBOX,
'variable' => 'allow_visitors', 'variable' => 'allow_visitors',
'display_text' => get_lang('Allow visitors'), 'display_text' => get_lang('Allow visitors'),
'visible_to_self' => 1, 'visible_to_self' => 1,
@ -82,7 +82,7 @@ $modeOptions = [
$mode = new ExtraField('session'); $mode = new ExtraField('session');
$mode->save([ $mode->save([
'field_type' => ExtraField::FIELD_TYPE_SELECT, 'value_type' => ExtraField::FIELD_TYPE_SELECT,
'variable' => 'mode', 'variable' => 'mode',
'display_text' => get_lang('Mode'), 'display_text' => get_lang('Mode'),
'visible_to_self' => 1, 'visible_to_self' => 1,
@ -92,7 +92,7 @@ $mode->save([
$isInductionSession = new ExtraField('session'); $isInductionSession = new ExtraField('session');
$isInductionSession->save([ $isInductionSession->save([
'field_type' => ExtraField::FIELD_TYPE_CHECKBOX, 'value_type' => ExtraField::FIELD_TYPE_CHECKBOX,
'variable' => 'is_induction_session', 'variable' => 'is_induction_session',
'display_text' => get_lang('Induction-type session'), 'display_text' => get_lang('Induction-type session'),
'visible_to_self' => 1, 'visible_to_self' => 1,
@ -101,7 +101,7 @@ $isInductionSession->save([
$isOpenSession = new ExtraField('session'); $isOpenSession = new ExtraField('session');
$isOpenSession->save([ $isOpenSession->save([
'field_type' => ExtraField::FIELD_TYPE_CHECKBOX, 'value_type' => ExtraField::FIELD_TYPE_CHECKBOX,
'variable' => 'is_open_session', 'variable' => 'is_open_session',
'display_text' => get_lang('Open session'), 'display_text' => get_lang('Open session'),
'visible_to_self' => 1, 'visible_to_self' => 1,
@ -110,7 +110,7 @@ $isOpenSession->save([
$duration = new ExtraField('session'); $duration = new ExtraField('session');
$duration->save([ $duration->save([
'field_type' => ExtraField::FIELD_TYPE_TEXT, 'value_type' => ExtraField::FIELD_TYPE_TEXT,
'variable' => 'human_text_duration', 'variable' => 'human_text_duration',
'display_text' => get_lang('Duration in words'), 'display_text' => get_lang('Duration in words'),
'visible_to_self' => 1, 'visible_to_self' => 1,
@ -125,7 +125,7 @@ $showStatusOptions = [
$showStatus = new ExtraField('session'); $showStatus = new ExtraField('session');
$showStatus->save([ $showStatus->save([
'field_type' => ExtraField::FIELD_TYPE_SELECT, 'value_type' => ExtraField::FIELD_TYPE_SELECT,
'variable' => 'show_status', 'variable' => 'show_status',
'display_text' => get_lang('Show status'), 'display_text' => get_lang('Show status'),
'visible_to_self' => 1, 'visible_to_self' => 1,
@ -135,7 +135,7 @@ $showStatus->save([
$publicationStartDate = new ExtraField('session'); $publicationStartDate = new ExtraField('session');
$publicationStartDate->save([ $publicationStartDate->save([
'field_type' => ExtraField::FIELD_TYPE_DATE, 'value_type' => ExtraField::FIELD_TYPE_DATE,
'variable' => 'publication_start_date', 'variable' => 'publication_start_date',
'display_text' => get_lang('Published start date'), 'display_text' => get_lang('Published start date'),
'visible_to_self' => 1, 'visible_to_self' => 1,
@ -144,7 +144,7 @@ $publicationStartDate->save([
$publicationEndDate = new ExtraField('session'); $publicationEndDate = new ExtraField('session');
$publicationEndDate->save([ $publicationEndDate->save([
'field_type' => ExtraField::FIELD_TYPE_DATE, 'value_type' => ExtraField::FIELD_TYPE_DATE,
'variable' => 'publication_end_date', 'variable' => 'publication_end_date',
'display_text' => get_lang('Published end date'), 'display_text' => get_lang('Published end date'),
'visible_to_self' => 1, 'visible_to_self' => 1,
@ -153,7 +153,7 @@ $publicationEndDate->save([
$banner = new ExtraField('session'); $banner = new ExtraField('session');
$banner->save([ $banner->save([
'field_type' => ExtraField::FIELD_TYPE_FILE_IMAGE, 'value_type' => ExtraField::FIELD_TYPE_FILE_IMAGE,
'variable' => 'banner', 'variable' => 'banner',
'display_text' => get_lang('Session banner'), 'display_text' => get_lang('Session banner'),
'visible_to_self' => 1, 'visible_to_self' => 1,
@ -162,7 +162,7 @@ $banner->save([
$brochure = new ExtraField('session'); $brochure = new ExtraField('session');
$brochure->save([ $brochure->save([
'field_type' => ExtraField::FIELD_TYPE_FILE, 'value_type' => ExtraField::FIELD_TYPE_FILE,
'variable' => 'brochure', 'variable' => 'brochure',
'display_text' => get_lang('Brochure'), 'display_text' => get_lang('Brochure'),
'visible_to_self' => 1, 'visible_to_self' => 1,
@ -176,7 +176,7 @@ $targetOptions = [
$target = new ExtraField('session'); $target = new ExtraField('session');
$target->save([ $target->save([
'field_type' => ExtraField::FIELD_TYPE_SELECT, 'value_type' => ExtraField::FIELD_TYPE_SELECT,
'variable' => 'target', 'variable' => 'target',
'display_text' => get_lang('Target audience'), 'display_text' => get_lang('Target audience'),
'visible_to_self' => 1, 'visible_to_self' => 1,
@ -186,7 +186,7 @@ $target->save([
$shortDescription = new ExtraField('session'); $shortDescription = new ExtraField('session');
$shortDescription->save([ $shortDescription->save([
'field_type' => ExtraField::FIELD_TYPE_TEXT, 'value_type' => ExtraField::FIELD_TYPE_TEXT,
'variable' => 'short_description', 'variable' => 'short_description',
'display_text' => get_lang('Short description'), 'display_text' => get_lang('Short description'),
'visible_to_self' => 1, 'visible_to_self' => 1,
@ -195,7 +195,7 @@ $shortDescription->save([
$id = new ExtraField('session'); $id = new ExtraField('session');
$id->save([ $id->save([
'field_type' => ExtraField::FIELD_TYPE_TEXT, 'value_type' => ExtraField::FIELD_TYPE_TEXT,
'variable' => 'code', 'variable' => 'code',
'display_text' => get_lang('Course code'), 'display_text' => get_lang('Course code'),
'visible_to_self' => 1, '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. Check www.bigbluebutton.org for more about BigBlueButton.
## Migrating to Chamilo LMS 1.10.x ## 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*. *Enable global conference* and *Enable conference in course groups*.
##### Database changes ##### 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; ALTER TABLE plugin_bbb_meeting ADD group_id int unsigned NOT NULL DEFAULT 0;
``` ```
## Migrating to Chamilo LMS 1.11.x ## Migrating to Chamilo LMS 1.11.x
For Chamilo 1.11.x, Videoconference plugin has one new setting option: For Chamilo 1.11.x, Videoconference plugin has one new setting option:
*Disable Course Settings*. *Disable Course Settings*.
##### Database changes ##### Database changes
You need execute this SQL query in your database after making the Chamilo migration process from 1.10.x. 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 For version 2.6 (adding limits) you need execute these SQL queries
```sql ```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 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 (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 (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 (3, 15, 'plugin_bbb_session_users_limit', 'MaxUsersInConferenceRoom', null, 1, 1, 0, 1, null, '2017-05-28 01:19:32');
``` ```
For version 2.7 For version 2.7
@ -78,7 +78,7 @@ You need to configure the cron using the *cron_close_meeting.php* file.
# Digital ocean VM # Digital ocean VM
In order to use DigitalOceanVM classes a new package is required: In order to use DigitalOceanVM classes a new package is required:
``` ```
composer requires toin0u/digitalocean composer requires toin0u/digitalocean
``` ```

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

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

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

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

@ -52,7 +52,7 @@ $formattedExtraFieldValues = [];
foreach ($extraFieldValues as $index => $extra) { foreach ($extraFieldValues as $index => $extra) {
foreach ($extra as $yandex => $field) { foreach ($extra as $yandex => $field) {
$thisUserExtraField = api_get_user_info($field->getItemId()); $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']; $formattedExtraFieldValues[$index][$yandex]['user_complete_name'] = $thisUserExtraField['complete_name'];
} }
} }

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

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

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

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

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

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

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

@ -83,16 +83,16 @@ class ExtraField
protected ?int $id = null; 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'])] #[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'])] #[Groups(['extra_field:read', 'extra_field:write'])]
protected int $fieldType; protected int $valueType;
/** /**
* @ORM\Column(name="variable", type="string", length=255) * @ORM\Column(name="variable", type="string", length=255)
@ -197,26 +197,26 @@ class ExtraField
return $this->id; 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; 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; return $this;
} }
@ -387,7 +387,7 @@ class ExtraField
public function getTypeToString(): string public function getTypeToString(): string
{ {
switch ($this->getExtraFieldType()) { switch ($this->getItemType()) {
case \ExtraField::FIELD_TYPE_RADIO: case \ExtraField::FIELD_TYPE_RADIO:
case \ExtraField::FIELD_TYPE_SELECT: case \ExtraField::FIELD_TYPE_SELECT:
return 'choice'; return 'choice';

@ -66,10 +66,10 @@ class ExtraFieldValues
protected ?int $id = null; 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'])] #[Groups(['extra_field_values:read', 'extra_field_values:write'])]
protected ?string $value = null; protected ?string $fieldValue = null;
/** /**
* @ORM\ManyToOne(targetEntity="Chamilo\CoreBundle\Entity\ExtraField") * @ORM\ManyToOne(targetEntity="Chamilo\CoreBundle\Entity\ExtraField")
@ -151,14 +151,14 @@ class ExtraFieldValues
return $this->id; 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; return $this;
} }

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

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

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

@ -293,7 +293,7 @@ class Version20181025064351 extends AbstractMigrationChamilo
'UPDATE gradebook_certificate gc SET downloaded_at = ( 'UPDATE gradebook_certificate gc SET downloaded_at = (
SELECT value from extra_field e SELECT value from extra_field e
INNER JOIN extra_field_values v on v.field_id = e.id 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 */ /** @var ExtraFieldValues $item */
foreach ($q->toIterable() as $item) { foreach ($q->toIterable() as $item) {
if (\in_array($item->getField()->getFieldType(), $fieldWithFiles, true)) { if (\in_array($item->getField()->getValueType(), $fieldWithFiles, true)) {
$path = $item->getValue(); $path = $item->getFieldValue();
if (empty($path)) { if (empty($path)) {
continue; continue;
} }

@ -79,7 +79,7 @@ final class Version20201212195011 extends AbstractMigrationChamilo
// Special course. // Special course.
$extraFieldType = ExtraField::COURSE_FIELD_TYPE; $extraFieldType = ExtraField::COURSE_FIELD_TYPE;
$sql = "SELECT id FROM extra_field $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); $result = $connection->executeQuery($sql);
$extraFieldId = $result->fetchOne(); $extraFieldId = $result->fetchOne();

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

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

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

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

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

@ -9,7 +9,7 @@ Feature: User extra fields
When I fill in the following: When I fill in the following:
| display_text | Behat extra field | | display_text | Behat extra field |
| variable | 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 I press "submit"
And wait the page to be loaded when ready And wait the page to be loaded when ready
Then I should see "Item added" Then I should see "Item added"

@ -16,18 +16,18 @@ $repo = $em->getRepository('ChamiloCoreBundle:ExtraField');
$extraFields = $repo->findAll(); $extraFields = $repo->findAll();
$list = [ $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());", '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 (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());", '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 (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())", '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 (extra_field_type, field_type, variable, display_text, visible_to_self, changeable, created_at) VALUES (1, 1, 'rssfeeds','RSS',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 (extra_field_type, field_type, variable, display_text, visible_to_self, changeable, created_at) VALUES (1, 1, 'dashboard', 'Dashboard', 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 (extra_field_type, field_type, variable, display_text, visible_to_self, changeable, created_at) VALUES (1, 11, 'timezone', 'Timezone', 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 (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())", '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 (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())", '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 (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())", '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 (extra_field_type, field_type, variable, display_text, visible_to_self, changeable, created_at) VALUES (2, 19, 'video_url', 'VideoUrl', 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 (extra_field_type, field_type, variable, display_text, visible_to_self, changeable, created_at) VALUES (3, 16, 'image', 'Image', 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 (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())", '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 = []; $extraFieldList = [];
@ -46,7 +46,7 @@ foreach ($list as $variable => $sql) {
} }
if (!isset($extraFieldList['mail_notify_invitation'])) { 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); Database::query($sql);
$queriesExecuted[] = $sql; $queriesExecuted[] = $sql;
$id = Database::insert_id(); $id = Database::insert_id();
@ -62,7 +62,7 @@ if (!isset($extraFieldList['mail_notify_invitation'])) {
} }
if (!isset($extraFieldList['mail_notify_message'])) { 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); Database::query($sql);
$queriesExecuted[] = $sql; $queriesExecuted[] = $sql;
@ -83,7 +83,7 @@ if (!isset($extraFieldList['mail_notify_message'])) {
} }
if (!isset($extraFieldList['mail_notify_group_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); Database::query($sql);
$queriesExecuted[] = $sql; $queriesExecuted[] = $sql;
$id = Database::insert_id(); $id = Database::insert_id();
@ -104,22 +104,22 @@ $tag1Exists = false;
$tag2Exists = false; $tag2Exists = false;
foreach ($extraFields as $extraField) { foreach ($extraFields as $extraField) {
if ($extraField->getVariable() === 'tags' && $extraField->getExtraFieldType() == 1) { if ($extraField->getVariable() === 'tags' && $extraField->getItemType() == 1) {
$tag1Exists = true; $tag1Exists = true;
} }
if ($extraField->getVariable() === 'tags' && $extraField->getExtraFieldType() == 2) { if ($extraField->getVariable() === 'tags' && $extraField->getItemType() == 2) {
$tag2Exists = true; $tag2Exists = true;
} }
} }
if ($tag1Exists === false) { 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); Database::query($sql);
$queriesExecuted[] = $sql; $queriesExecuted[] = $sql;
} }
if ($tag2Exists === false) { 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); Database::query($sql);
$queriesExecuted[] = $sql; $queriesExecuted[] = $sql;
} }

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

@ -18,12 +18,12 @@ $tUserFieldValue = Database::get_main_table(TABLE_EXTRA_FIELD_VALUES);
$tUser = Database::get_main_table(TABLE_MAIN_USER); $tUser = Database::get_main_table(TABLE_MAIN_USER);
// First get the IDs of the selected fields // 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); $result = Database::query($sql);
$foundFields = array(); $foundFields = array();
$fieldsNames = array(); $fieldsNames = array();
while ($row = Database::fetch_assoc($result)) { 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']); $foundFields[$row['variable']] = array('id' => $row['id']);
$fieldsNames[$row['id']] = $row['variable']; $fieldsNames[$row['id']] = $row['variable'];
} }

Loading…
Cancel
Save