mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-11-23 00:13:35 +01:00
* Calendar/all apps: fix since last package not working old favorites and json-encode all php-serialized preferences
This commit is contained in:
parent
d0dae2b32a
commit
9ae329ae72
@ -78,7 +78,6 @@ class egw_favorites
|
||||
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 @@ class egw_favorites
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
@ -216,17 +216,6 @@ class preferences
|
||||
$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 @@ class preferences
|
||||
/**
|
||||
* 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 @@ class preferences
|
||||
{
|
||||
$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,17 +761,39 @@ class preferences
|
||||
{
|
||||
$prefs = self::unserialize($row['preference_value']);
|
||||
|
||||
if (isset($old_value) && $prefs[$name] != $old_value) continue;
|
||||
|
||||
if ((string)$value !== '')
|
||||
if ($name[0] == '/' && substr($name, -1) == '/')
|
||||
{
|
||||
$prefs[$name] = $value;
|
||||
$attrs = array_filter(array_keys($prefs), function($n) use ($name)
|
||||
{
|
||||
return preg_match($name, $n);
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
unset($prefs[$name]);
|
||||
$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(
|
||||
@ -799,6 +810,7 @@ class preferences
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Completely delete the specified preference name from all users
|
||||
|
@ -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;
|
||||
|
@ -814,6 +814,32 @@ function phpgwapi_upgrade14_3_001()
|
||||
return $GLOBALS['setup_info']['phpgwapi']['currentver'] = '14.3.002';
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 @@ function phpgwapi_upgrade14_3_001()
|
||||
*
|
||||
* @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';
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user