Permalink
Browse files

fix(profile): able to store more information in tag fields

Storing large amounts of data in your profile is not advised outside of
longtext fields. However if the field is a tags,select of checkbox field
this allows for more room. Now the individual string length is still
limited but not the total.

fixes #7694
  • Loading branch information...
jeabakker committed Mar 22, 2016
1 parent 75d0b1e commit 0467e3ffcc35e0cf88a476dfbbc15a669dbdad80
Showing with 15 additions and 10 deletions.
  1. +15 −10 actions/profile/edit.php
View
@@ -42,24 +42,29 @@
} else {
$value = elgg_html_decode($value);
}
// convert tags fields to array values
if ($valuetype == 'tags') {
$value = string_to_tag_array($value);
}
// limit to reasonable sizes
// @todo - throwing away changes due to this is dumb!
// ^^ This is a sticky form so changes aren't lost...?
if (!is_array($value) && $valuetype != 'longtext' && elgg_strlen($value) > 250) {
$error = elgg_echo('profile:field_too_long', array(elgg_echo("profile:{$shortname}")));
register_error($error);
forward(REFERER);
if ($valuetype != 'longtext') {
$check_values = (array) $value;
// also check tags/checkboxes/etc
array_walk_recursive($check_values, function($v, $index, $short) {
if (elgg_strlen($v) > 250) {
register_error(elgg_echo('profile:field_too_long', array(elgg_echo("profile:{$short}"))));
forward(REFERER);
}
}, $shortname);
}
if ($value && $valuetype == 'url' && !preg_match('~^https?\://~i', $value)) {
$value = "http://$value";
}
if ($valuetype == 'tags') {
$value = string_to_tag_array($value);
}
if ($valuetype == 'email' && !empty($value) && !is_email_address($value)) {
register_error(elgg_echo('profile:invalid_email', array(
elgg_echo("profile:{$shortname}")

0 comments on commit 0467e3f

Please sign in to comment.