Ignore favorite preferences which are not correctly serialized, and somehow are stroed in database. At the moment we just ignore them, but they stays in database, need to be watched closely to find the cause, though.

This commit is contained in:
Hadi Nategh 2014-06-13 16:03:16 +00:00
parent 541e6f9bb5
commit 2ff1107b78
2 changed files with 10 additions and 3 deletions

View File

@ -214,7 +214,7 @@ var et2_favorites = et2_dropdown_button.extend([et2_INextmatchHeader],
var preferences = egw.preference("*",app);
for(var pref_name in preferences)
{
if(pref_name.indexOf(this.favorite_prefix) == 0)
if(pref_name.indexOf(this.favorite_prefix) == 0 && typeof preferences[pref_name] == 'object')
{
var name = pref_name.substr(this.favorite_prefix.length);
stored_filters[name] = preferences[pref_name];

View File

@ -34,7 +34,7 @@ class egw_favorites
* a nextmatch is on the page, it will update / replace this list.
*
* @param string $app application, needed to find preferences
* @param string $default=null preference name for default favorite, default "nextmatch-$app.index.rows-favorite"
* @param string $default preference name for default favorite, default "nextmatch-$app.index.rows-favorite"
*
* @return array with a single sidebox menu item (array) containing html for favorites
*/
@ -72,6 +72,13 @@ class egw_favorites
}
foreach($filters as $name => $filter)
{
//filter must not be empty if there's one, ignore it at the moment but it need to be checked how it got there in database
if (!$filter)
{
error_log(__METHOD__.'Favorite filter is not suppose to be empty, it should be an array. 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="'.htmlspecialchars($href).'" class="ui-corner-all" tabindex="-1">';
@ -189,7 +196,7 @@ class egw_favorites
* @param string $name Name of the favorite
* @param string $action "add" or "delete"
* @param boolean|int|String $group ID of the group to create the favorite for, or 'all' for all users
* @param array $filters=array() key => value pairs for the filter
* @param array $filters key => value pairs for the filter
* @return boolean Success
*/
public static function set_favorite($app, $name, $action, $group, $filters = array())