Index: trunk/core/units/user_profile/user_profile_tp.php
===================================================================
diff -u -r8634 -r8636
--- trunk/core/units/user_profile/user_profile_tp.php (.../user_profile_tp.php) (revision 8634)
+++ trunk/core/units/user_profile/user_profile_tp.php (.../user_profile_tp.php) (revision 8636)
@@ -57,11 +57,23 @@
$sql = 'SELECT VariableValue, VariableName
FROM '.TABLE_PREFIX.'PersistantSessionData
- WHERE (PortalUserId = '.$user_id.') AND (LENGTH(VariableValue) < 10)';
+ WHERE (PortalUserId = '.$user_id.')';
$cached_vars = $this->Conn->GetCol($sql, 'VariableName');
}
- return isset($cached_vars[$var_name]) ? $cached_vars[$var_name] : false;
+ if (isset($cached_vars[$var_name])) {
+ // get variable value from persistent session
+ return $cached_vars[$var_name];
+ }
+ else {
+ // not found in persistent session -> get default value from config variable with same name
+ $config_value = $this->Application->ConfigValue($var_name);
+ if ($config_value !== false) {
+ return $config_value;
+ }
+ }
+
+ return false;
}
/**
@@ -122,6 +134,21 @@
return $counter < $this->ProfileFieldCount();
}
+
+ /**
+ * Because of persistant session table doesn't have ids, we use user id as id for each record
+ *
+ * @param Array $params
+ * @return Array (id,field)
+ * @access private
+ */
+ function prepareInputName($params)
+ {
+ list ($id, $field) = parent::prepareInputName($params);
+ $id = $this->Application->RecallVar('user_id');
+
+ return Array($id, $field);
+ }
}
?>
\ No newline at end of file
Index: trunk/kernel/units/user_profile/user_profile_tp.php
===================================================================
diff -u -r8634 -r8636
--- trunk/kernel/units/user_profile/user_profile_tp.php (.../user_profile_tp.php) (revision 8634)
+++ trunk/kernel/units/user_profile/user_profile_tp.php (.../user_profile_tp.php) (revision 8636)
@@ -57,11 +57,23 @@
$sql = 'SELECT VariableValue, VariableName
FROM '.TABLE_PREFIX.'PersistantSessionData
- WHERE (PortalUserId = '.$user_id.') AND (LENGTH(VariableValue) < 10)';
+ WHERE (PortalUserId = '.$user_id.')';
$cached_vars = $this->Conn->GetCol($sql, 'VariableName');
}
- return isset($cached_vars[$var_name]) ? $cached_vars[$var_name] : false;
+ if (isset($cached_vars[$var_name])) {
+ // get variable value from persistent session
+ return $cached_vars[$var_name];
+ }
+ else {
+ // not found in persistent session -> get default value from config variable with same name
+ $config_value = $this->Application->ConfigValue($var_name);
+ if ($config_value !== false) {
+ return $config_value;
+ }
+ }
+
+ return false;
}
/**
@@ -122,6 +134,21 @@
return $counter < $this->ProfileFieldCount();
}
+
+ /**
+ * Because of persistant session table doesn't have ids, we use user id as id for each record
+ *
+ * @param Array $params
+ * @return Array (id,field)
+ * @access private
+ */
+ function prepareInputName($params)
+ {
+ list ($id, $field) = parent::prepareInputName($params);
+ $id = $this->Application->RecallVar('user_id');
+
+ return Array($id, $field);
+ }
}
?>
\ No newline at end of file
Index: trunk/core/units/user_profile/user_profile_config.php
===================================================================
diff -u -r8615 -r8636
--- trunk/core/units/user_profile/user_profile_config.php (.../user_profile_config.php) (revision 8615)
+++ trunk/core/units/user_profile/user_profile_config.php (.../user_profile_config.php) (revision 8636)
@@ -6,7 +6,6 @@
'ListClass' => Array('class' => 'kDBList', 'file' => '', 'build_event' => 'OnListBuild'),
'EventHandlerClass' => Array('class' => 'UserProfileEventHandler', 'file' => 'user_profile_eh.php', 'build_event' => 'OnBuild'),
'TagProcessorClass' => Array('class' => 'UserProfileTagProcessor', 'file' => 'user_profile_tp.php', 'build_event' => 'OnBuild'),
- 'AutoLoad' => true,
'QueryString' => Array (
1 => 'id',
Index: trunk/core/units/user_profile/user_profile_eh.php
===================================================================
diff -u -r8615 -r8636
--- trunk/core/units/user_profile/user_profile_eh.php (.../user_profile_eh.php) (revision 8615)
+++ trunk/core/units/user_profile/user_profile_eh.php (.../user_profile_eh.php) (revision 8636)
@@ -10,6 +10,7 @@
{
parent::mapPermissions();
$permissions = Array (
+ 'OnItemBuild' => Array('subitem' => true),
'OnUpdate' => Array('subitem' => true),
);
@@ -23,11 +24,17 @@
*/
function OnUpdate(&$event)
{
- $items_info = $this->Application->GetVar('user_profile');
+ $items_info = $this->Application->GetVar($event->getPrefixSpecial(true));
+ list ($user_id, $field_values) = each($items_info);
- foreach ($items_info as $variable_name => $variable_value) {
- $this->Application->StorePersistentVar($variable_name, $variable_value);
+ if ($user_id != $this->Application->RecallVar('user_id')) {
+ // we are not updating own profile
+ return ;
}
+
+ foreach ($field_values as $variable_name => $variable_value) {
+ $this->Application->StorePersistentVar($variable_name, unhtmlentities($variable_value));
+ }
}
Index: trunk/kernel/units/user_profile/user_profile_config.php
===================================================================
diff -u -r8615 -r8636
--- trunk/kernel/units/user_profile/user_profile_config.php (.../user_profile_config.php) (revision 8615)
+++ trunk/kernel/units/user_profile/user_profile_config.php (.../user_profile_config.php) (revision 8636)
@@ -6,7 +6,6 @@
'ListClass' => Array('class' => 'kDBList', 'file' => '', 'build_event' => 'OnListBuild'),
'EventHandlerClass' => Array('class' => 'UserProfileEventHandler', 'file' => 'user_profile_eh.php', 'build_event' => 'OnBuild'),
'TagProcessorClass' => Array('class' => 'UserProfileTagProcessor', 'file' => 'user_profile_tp.php', 'build_event' => 'OnBuild'),
- 'AutoLoad' => true,
'QueryString' => Array (
1 => 'id',
Index: trunk/themes/default2007/platform/my_account/my_preferences.tpl
===================================================================
diff -u -r8634 -r8636
--- trunk/themes/default2007/platform/my_account/my_preferences.tpl (.../my_preferences.tpl) (revision 8634)
+++ trunk/themes/default2007/platform/my_account/my_preferences.tpl (.../my_preferences.tpl) (revision 8636)
@@ -26,6 +26,7 @@
Profile