|
|
@ -79,13 +79,16 @@ class ExtraFieldValue extends Model |
|
|
|
{ |
|
|
|
{ |
|
|
|
foreach ($params as $key => $value) { |
|
|
|
foreach ($params as $key => $value) { |
|
|
|
$found = strpos($key, '__persist__'); |
|
|
|
$found = strpos($key, '__persist__'); |
|
|
|
if ($found) { |
|
|
|
|
|
|
|
|
|
|
|
if ($found === FALSE) { |
|
|
|
|
|
|
|
continue; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
$tempKey = str_replace('__persist__', '', $key); |
|
|
|
$tempKey = str_replace('__persist__', '', $key); |
|
|
|
if (!isset($params[$tempKey])) { |
|
|
|
if (!isset($params[$tempKey])) { |
|
|
|
$params[$tempKey] = array(); |
|
|
|
$params[$tempKey] = array(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (empty($params['item_id'])) { |
|
|
|
if (empty($params['item_id'])) { |
|
|
|
return false; |
|
|
|
return false; |
|
|
@ -94,22 +97,27 @@ class ExtraFieldValue extends Model |
|
|
|
$type = $this->getExtraField()->getExtraFieldType(); |
|
|
|
$type = $this->getExtraField()->getExtraFieldType(); |
|
|
|
// Parse params. |
|
|
|
// Parse params. |
|
|
|
foreach ($params as $key => $value) { |
|
|
|
foreach ($params as $key => $value) { |
|
|
|
if (substr($key, 0, 6) == 'extra_' || |
|
|
|
if ( |
|
|
|
substr($key, 0, 7) == '_extra_' |
|
|
|
substr($key, 0, 6) != 'extra_' && |
|
|
|
|
|
|
|
substr($key, 0, 7) != '_extra_' |
|
|
|
) { |
|
|
|
) { |
|
|
|
|
|
|
|
continue; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// An extra field. |
|
|
|
// An extra field. |
|
|
|
$field_variable = substr($key, 6); |
|
|
|
$field_variable = substr($key, 6); |
|
|
|
$extraFieldInfo = $this->getExtraField()->get_handler_field_info_by_field_variable($field_variable); |
|
|
|
$extraFieldInfo = $this->getExtraField()->get_handler_field_info_by_field_variable($field_variable); |
|
|
|
|
|
|
|
|
|
|
|
if ($extraFieldInfo) { |
|
|
|
if (!$extraFieldInfo) { |
|
|
|
|
|
|
|
continue; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
$commentVariable = 'extra_'.$field_variable.'_comment'; |
|
|
|
$commentVariable = 'extra_'.$field_variable.'_comment'; |
|
|
|
$comment = isset($params[$commentVariable]) ? $params[$commentVariable] : null; |
|
|
|
$comment = isset($params[$commentVariable]) ? $params[$commentVariable] : null; |
|
|
|
|
|
|
|
|
|
|
|
switch ($extraFieldInfo['field_type']) { |
|
|
|
switch ($extraFieldInfo['field_type']) { |
|
|
|
|
|
|
|
|
|
|
|
case ExtraField::FIELD_TYPE_TAG: |
|
|
|
case ExtraField::FIELD_TYPE_TAG: |
|
|
|
if ($type == EntityExtraField::USER_FIELD_TYPE) { |
|
|
|
if ($type == EntityExtraField::USER_FIELD_TYPE) { |
|
|
|
|
|
|
|
|
|
|
|
UserManager::delete_user_tags( |
|
|
|
UserManager::delete_user_tags( |
|
|
|
$params['item_id'], |
|
|
|
$params['item_id'], |
|
|
|
$extraFieldInfo['id'] |
|
|
|
$extraFieldInfo['id'] |
|
|
@ -120,7 +128,9 @@ class ExtraFieldValue extends Model |
|
|
|
$params['item_id'], |
|
|
|
$params['item_id'], |
|
|
|
$extraFieldInfo['id'] |
|
|
|
$extraFieldInfo['id'] |
|
|
|
); |
|
|
|
); |
|
|
|
} else { |
|
|
|
break; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
$em = Database::getManager(); |
|
|
|
$em = Database::getManager(); |
|
|
|
|
|
|
|
|
|
|
|
$currentTags = $em |
|
|
|
$currentTags = $em |
|
|
@ -138,7 +148,9 @@ class ExtraFieldValue extends Model |
|
|
|
$tags = []; |
|
|
|
$tags = []; |
|
|
|
|
|
|
|
|
|
|
|
foreach ($tagValues as $tagValue) { |
|
|
|
foreach ($tagValues as $tagValue) { |
|
|
|
$tagsResult = $em->getRepository('ChamiloCoreBundle:Tag')->findBy([ |
|
|
|
$tagsResult = $em |
|
|
|
|
|
|
|
->getRepository('ChamiloCoreBundle:Tag') |
|
|
|
|
|
|
|
->findBy([ |
|
|
|
'tag' => $tagValue, |
|
|
|
'tag' => $tagValue, |
|
|
|
'fieldId' => $extraFieldInfo['id'] |
|
|
|
'fieldId' => $extraFieldInfo['id'] |
|
|
|
]); |
|
|
|
]); |
|
|
@ -168,7 +180,6 @@ class ExtraFieldValue extends Model |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
$em->flush(); |
|
|
|
$em->flush(); |
|
|
|
} |
|
|
|
|
|
|
|
break; |
|
|
|
break; |
|
|
|
case ExtraField::FIELD_TYPE_FILE_IMAGE: |
|
|
|
case ExtraField::FIELD_TYPE_FILE_IMAGE: |
|
|
|
$dirPermissions = api_get_permissions_for_new_directories(); |
|
|
|
$dirPermissions = api_get_permissions_for_new_directories(); |
|
|
@ -258,8 +269,6 @@ class ExtraFieldValue extends Model |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Save values in the *_field_values table |
|
|
|
* Save values in the *_field_values table |
|
|
|