Author: ralfbecker
New Revision: 53455
URL: http://svn.stylite.de/viewvc/egroupware?rev=53455&view=rev
Log:
- Calendar/all apps: fix since last package not working old favorites and json-encode all php-serialized preferences
Modified:
trunk/phpgwapi/inc/class.egw_favorites.inc.php
trunk/phpgwapi/inc/class.preferences.inc.php
trunk/phpgwapi/setup/setup.inc.php
trunk/phpgwapi/setup/tables_update.inc.php
Modified: trunk/phpgwapi/inc/class.egw_favorites.inc.php
URL: http://svn.stylite.de/viewvc/egroupware/trunk/phpgwapi/inc/class.egw_favorites.inc.php?rev=53455&r1=53454&r2=53455&view=diff
— trunk/phpgwapi/inc/class.egw_favorites.inc.php (original)
+++ trunk/phpgwapi/inc/class.egw_favorites.inc.php Mon Aug 24 18:00:31 2015
@@ -78,7 +78,6 @@
error_log(METHOD.‘Favorite filter "’.$name.’" is not supposed to be empty, it should be an array. Skipping, more investigation needed. filter = '. array2string($filters[$name]));
continue;
}
-
$href = "javascript:app.$app.setState(" . json_encode($filter,JSON_FORCE_OBJECT) . ');'; $li = "<li data-id='$name' data-group='{$filter['group']}' class='ui-menu-item' role='menuitem'>\n"; $li .= '<a href="#" class="ui-corner-all" tabindex="-1">'; $li .= "<div class='" . ((string)$name === (string)$default_filter ? 'ui-icon ui-icon-heart' : 'sideboxstar') . "'></div>".
@@ -158,20 +157,8 @@
{
if(strpos($pref_name, $pref_prefix) === 0)
{
-
if(!is_array($pref)) // old favorite -
{ -
if (!($pref = unserialize($pref))) -
{ -
continue; -
} -
$pref = array( -
'name' => substr($pref_name,strlen($pref_prefix)), -
'group' => !isset($GLOBALS['egw']->preferences->user[$app][$pref_name]), -
'state' => $pref, -
); -
//error_log(__METHOD__."() old favorite '$pref_name' converted to ".array2string($pref)); -
} -
//else error_log(__METHOD__."() new favorite '$pref_name' ".array2string($pref));
-
if(!is_array($pref)) continue; // old favorite -
$favorites[(string)substr($pref_name,strlen($pref_prefix))] = $pref; } }
Modified: trunk/phpgwapi/inc/class.preferences.inc.php
URL: http://svn.stylite.de/viewvc/egroupware/trunk/phpgwapi/inc/class.preferences.inc.php?rev=53455&r1=53454&r2=53455&view=diff
— trunk/phpgwapi/inc/class.preferences.inc.php (original)
+++ trunk/phpgwapi/inc/class.preferences.inc.php Mon Aug 24 18:00:31 2015
@@ -216,17 +216,6 @@
$app = trim($row[‘preference_app’]);
$prefs[$row['preference_owner']][$app] = self::unserialize($row['preference_value']);
-
// fix old PHP serialized attribute-values -
foreach($prefs[$row['preference_owner']][$app] as $name => &$val) -
{ -
if (is_string($val) && $val[0] != 'a' && $val[1] != ':' && -
// using a white-list currently only matching favorites -
substr($name, 0, 9) == 'favorite_' && ($v = php_safe_unserialize($val))) -
{ -
$val = $v; -
} -
} } foreach($db_read as $id) {
@@ -740,9 +729,9 @@
/**
* Change single value in preferences of all users (incl. groups, default and forced)
*
-
- @param string $app
-
- @param string $name
-
- @param string $value new value to set, or null or ‘’ to delete it
-
- @param string $app app-name or null for all apps
-
- @param string $name attribute name or regular expression (enclosed in /) to match attribute-name eg. ‘/^favorite_/’
-
- @param string|callable $value new value to set, or null or ‘’ to delete it or callable returning new value: function($attr, $old_value)
- @param string $old_value if given, only change if that’s current value
-
@param string $type if given limit to “user”, “forced”, “default”, “group”
*/
@@ -750,9 +739,9 @@
{
$db = isset($GLOBALS[‘egw_setup’]->db) ? $GLOBALS[‘egw_setup’]->db : $GLOBALS[‘egw’]->db;
-
$where = array( -
'preference_app' => $app, -
);
-
$where = array(); -
if ($app) $where['preference_app'] = $app; -
switch($type) { case 'forced':
@@ -772,30 +761,53 @@
{
$prefs = self::unserialize($row[‘preference_value’]);
-
if (isset($old_value) && $prefs[$name] != $old_value) continue; -
if ((string)$value !== '') -
{ -
$prefs[$name] = $value;
-
if ($name[0] == '/' && substr($name, -1) == '/') -
{ -
$attrs = array_filter(array_keys($prefs), function($n) use ($name) -
{ -
return preg_match($name, $n); -
}); } else {
-
unset($prefs[$name]); -
} -
$db->update(self::TABLE, array( -
'preference_value' => json_encode($prefs), -
), array( -
'preference_owner' => $row['preference_owner'], -
'preference_app' => $row['preference_app'], -
), __LINE__, __FILE__); -
// update instance-wide cache -
$cached = egw_cache::getInstance(__CLASS__, $row['preference_owner']); -
if($cached && $cached[$row['preference_app']]) -
{ -
$cached[$row['preference_app']] = $prefs; -
egw_cache::setInstance(__CLASS__, $row['preference_owner'], $cached);
-
$attrs = array($name); -
} -
$updated = false; -
foreach($attrs as $attr) -
{ -
if (isset($old_value) && $prefs[$attr] != $old_value) continue; -
$val = is_callable($value) ? call_user_func($value, $attr, $prefs[$attr]) : $value; -
if ($val === $prefs[$attr]) continue; -
$updated = true; -
if ((string)$val !== '') -
{ -
$prefs[$attr] = $val; -
} -
else -
{ -
unset($prefs[$attr]); -
} -
} -
// if somethings changed or old row was php-serialized --> store it again json-encoded -
if ($updated || $row['preference_value'][0] == 'a' && $row['preference_value'][1] == ':') -
{ -
$db->update(self::TABLE, array( -
'preference_value' => json_encode($prefs), -
), array( -
'preference_owner' => $row['preference_owner'], -
'preference_app' => $row['preference_app'], -
), __LINE__, __FILE__); -
// update instance-wide cache -
$cached = egw_cache::getInstance(__CLASS__, $row['preference_owner']); -
if($cached && $cached[$row['preference_app']]) -
{ -
$cached[$row['preference_app']] = $prefs; -
egw_cache::setInstance(__CLASS__, $row['preference_owner'], $cached); -
}} } }
Modified: trunk/phpgwapi/setup/setup.inc.php
URL: http://svn.stylite.de/viewvc/egroupware/trunk/phpgwapi/setup/setup.inc.php?rev=53455&r1=53454&r2=53455&view=diff
— trunk/phpgwapi/setup/setup.inc.php (original)
+++ trunk/phpgwapi/setup/setup.inc.php Mon Aug 24 18:00:31 2015
@@ -12,7 +12,7 @@
/* Basic information about this app */
$setup_info[‘phpgwapi’][‘name’] = ‘phpgwapi’;
$setup_info[‘phpgwapi’][‘title’] = ‘EGroupware API’;
-$setup_info[‘phpgwapi’][‘version’] = ‘14.3.900’;
+$setup_info[‘phpgwapi’][‘version’] = ‘14.3.901’;
$setup_info[‘phpgwapi’][‘versions’][‘current_header’] = ‘1.29’;
$setup_info[‘phpgwapi’][‘enable’] = 3;
$setup_info[‘phpgwapi’][‘app_order’] = 1;
Modified: trunk/phpgwapi/setup/tables_update.inc.php
URL: http://svn.stylite.de/viewvc/egroupware/trunk/phpgwapi/setup/tables_update.inc.php?rev=53455&r1=53454&r2=53455&view=diff
— trunk/phpgwapi/setup/tables_update.inc.php (original)
+++ trunk/phpgwapi/setup/tables_update.inc.php Mon Aug 24 18:00:31 2015
@@ -815,6 +815,32 @@
}
/**
-
- Fix old php-serialized favorites to use new format with name, group and state attributes
-
- Change still php-serialized values in column egw_preferences.preference_value to json-encoding
-
-
- @return string
- */
+function phpgwapi_upgrade14_3_002()
+{ - $GLOBALS[‘run-from-upgrade14_3_002’] = true;
- preferences::change_preference(null, ‘/^favorite_/’, function($name, $value, $owner)
- {
-
if (is_string($value) && $value[0] == 'a' && $value[1] == ':' && ($state = php_safe_unserialize($value))) -
{ -
$value = array( -
'name' => substr($name, 9), // skip "favorite_" -
'group' => !($owner > 0), -
'state' => $state, -
); -
} -
return $value; - });
- return $GLOBALS[‘setup_info’][‘phpgwapi’][‘currentver’] = ‘14.3.003’;
+}
+/**
- Updates on the way to 15.1
*/
@@ -823,9 +849,21 @@
*
-
@return string
*/
-function phpgwapi_upgrade14_3_002()
+function phpgwapi_upgrade14_3_003()
{
$GLOBALS[‘egw_setup’]->oProc->DropTable(‘egw_api_content_history’);return $GLOBALS[‘setup_info’][‘phpgwapi’][‘currentver’] = ‘14.3.900’;
}
+/**
-
- Run 14.3.002 upgrade for everyone who was already on 14.3.900
- */
+function phpgwapi_upgrade14_3_900()
+{ - if (empty($GLOBALS[‘run-from-upgrade14_3_002’]))
- {
-
phpgwapi_upgrade14_3_002(); - }
- return $GLOBALS[‘setup_info’][‘phpgwapi’][‘currentver’] = ‘14.3.901’;
+}
eGroupWare-cvs mailing list
eGroupWare-cvs@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/egroupware-cvs