aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPayBas <contact@paybas.com>2014-04-29 16:16:19 +0200
committerShitiz Garg <mail@dragooon.net>2014-06-24 21:47:29 +0530
commit507eca319d2bff9779d662a36b845017b7464e68 (patch)
treef6416f51ce8e5d1420a1ad6aad77fe67f662cab5
parent4169fd65f07f67f99e64e7ab962d09c1e10f14dc (diff)
downloadforums-507eca319d2bff9779d662a36b845017b7464e68.tar
forums-507eca319d2bff9779d662a36b845017b7464e68.tar.gz
forums-507eca319d2bff9779d662a36b845017b7464e68.tar.bz2
forums-507eca319d2bff9779d662a36b845017b7464e68.tar.xz
forums-507eca319d2bff9779d662a36b845017b7464e68.zip
[ticket/12334] Implemented get_profile_valueid method
PHPBB3-12334
-rw-r--r--phpBB/phpbb/profilefields/manager.php2
-rw-r--r--phpBB/phpbb/profilefields/type/type_bool.php18
-rw-r--r--phpBB/phpbb/profilefields/type/type_date.php13
-rw-r--r--phpBB/phpbb/profilefields/type/type_dropdown.php18
-rw-r--r--phpBB/phpbb/profilefields/type/type_int.php12
-rw-r--r--phpBB/phpbb/profilefields/type/type_interface.php9
-rw-r--r--phpBB/phpbb/profilefields/type/type_string_common.php13
7 files changed, 84 insertions, 1 deletions
diff --git a/phpBB/phpbb/profilefields/manager.php b/phpBB/phpbb/profilefields/manager.php
index 7602abf9aa..a2b931ce27 100644
--- a/phpBB/phpbb/profilefields/manager.php
+++ b/phpBB/phpbb/profilefields/manager.php
@@ -389,7 +389,7 @@ class manager
{
$profile_field = $this->type_collection[$ident_ary['data']['field_type']];
$value = $profile_field->get_profile_value($ident_ary['value'], $ident_ary['data']);
- $valueid = (!$ident_ary['value'] && !$ident_ary['data']['field_show_novalue']) ? $ident_ary['data']['field_novalue'] : $ident_ary['value'];
+ $valueid = $profile_field->get_profile_valueid($ident_ary['value'], $ident_ary['data']);
if ($value === null)
{
diff --git a/phpBB/phpbb/profilefields/type/type_bool.php b/phpBB/phpbb/profilefields/type/type_bool.php
index eb8d3e47d6..64f4f8293f 100644
--- a/phpBB/phpbb/profilefields/type/type_bool.php
+++ b/phpBB/phpbb/profilefields/type/type_bool.php
@@ -180,6 +180,24 @@ class type_bool extends type_base
/**
* {@inheritDoc}
*/
+ public function get_profile_valueid($field_value, $field_data)
+ {
+ if ($field_value == $field_data['field_novalue'] && !$field_data['field_show_novalue'])
+ {
+ return null;
+ }
+
+ if (!$field_value && $field_data['field_show_novalue'])
+ {
+ $field_value = $field_data['field_novalue'];
+ }
+
+ return $field_value;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
public function generate_field($profile_row, $preview_options = false)
{
$profile_row['field_ident'] = (isset($profile_row['var_name'])) ? $profile_row['var_name'] : 'pf_' . $profile_row['field_ident'];
diff --git a/phpBB/phpbb/profilefields/type/type_date.php b/phpBB/phpbb/profilefields/type/type_date.php
index 158eec6a0c..f59d74c33d 100644
--- a/phpBB/phpbb/profilefields/type/type_date.php
+++ b/phpBB/phpbb/profilefields/type/type_date.php
@@ -208,6 +208,19 @@ class type_date extends type_base
/**
* {@inheritDoc}
*/
+ public function get_profile_valueid($field_value, $field_data)
+ {
+ if (($field_value === '' || $field_value === null) && !$field_data['field_show_novalue'])
+ {
+ return null;
+ }
+
+ return $field_value;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
public function generate_field($profile_row, $preview_options = false)
{
$profile_row['field_ident'] = (isset($profile_row['var_name'])) ? $profile_row['var_name'] : 'pf_' . $profile_row['field_ident'];
diff --git a/phpBB/phpbb/profilefields/type/type_dropdown.php b/phpBB/phpbb/profilefields/type/type_dropdown.php
index 52c9fcf86a..b201c4abbf 100644
--- a/phpBB/phpbb/profilefields/type/type_dropdown.php
+++ b/phpBB/phpbb/profilefields/type/type_dropdown.php
@@ -189,6 +189,24 @@ class type_dropdown extends type_base
/**
* {@inheritDoc}
*/
+ public function get_profile_valueid($field_value, $field_data)
+ {
+ if ($field_value == $field_data['field_novalue'] && !$field_data['field_show_novalue'])
+ {
+ return null;
+ }
+
+ if (!$field_value && $field_data['field_show_novalue'])
+ {
+ $field_value = $field_data['field_novalue'];
+ }
+
+ return $field_value;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
public function generate_field($profile_row, $preview_options = false)
{
$profile_row['field_ident'] = (isset($profile_row['var_name'])) ? $profile_row['var_name'] : 'pf_' . $profile_row['field_ident'];
diff --git a/phpBB/phpbb/profilefields/type/type_int.php b/phpBB/phpbb/profilefields/type/type_int.php
index 78f1c7d2c9..8a803293d0 100644
--- a/phpBB/phpbb/profilefields/type/type_int.php
+++ b/phpBB/phpbb/profilefields/type/type_int.php
@@ -154,6 +154,18 @@ class type_int extends type_base
/**
* {@inheritDoc}
*/
+ public function get_profile_valueid($field_value, $field_data)
+ {
+ if (($field_value === '' || $field_value === null) && !$field_data['field_show_novalue'])
+ {
+ return null;
+ }
+ return (int) $field_value;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
public function generate_field($profile_row, $preview_options = false)
{
$profile_row['field_ident'] = (isset($profile_row['var_name'])) ? $profile_row['var_name'] : 'pf_' . $profile_row['field_ident'];
diff --git a/phpBB/phpbb/profilefields/type/type_interface.php b/phpBB/phpbb/profilefields/type/type_interface.php
index 489e916fd5..8fe1bb2be5 100644
--- a/phpBB/phpbb/profilefields/type/type_interface.php
+++ b/phpBB/phpbb/profilefields/type/type_interface.php
@@ -94,6 +94,15 @@ interface type_interface
public function get_profile_value($field_value, $field_data);
/**
+ * Get Profile Value ID for display (the raw, unprocessed user data)
+ *
+ * @param mixed $field_value Field value as stored in the database
+ * @param array $field_data Array with requirements of the field
+ * @return mixed Field value ID to display
+ */
+ public function get_profile_valueid($field_value, $field_data);
+
+ /**
* Get Profile Value for display
*
* When displaying a contact field, we don't want to have links already parsed and more
diff --git a/phpBB/phpbb/profilefields/type/type_string_common.php b/phpBB/phpbb/profilefields/type/type_string_common.php
index b48e3c5add..1d26ba5d3a 100644
--- a/phpBB/phpbb/profilefields/type/type_string_common.php
+++ b/phpBB/phpbb/profilefields/type/type_string_common.php
@@ -112,6 +112,19 @@ abstract class type_string_common extends type_base
/**
* {@inheritDoc}
*/
+ public function get_profile_valueid($field_value, $field_data)
+ {
+ if (!$field_value && !$field_data['field_show_novalue'])
+ {
+ return null;
+ }
+
+ return $field_value;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
public function get_profile_contact_value($field_value, $field_data)
{
if (!$field_value && !$field_data['field_show_novalue'])