diff --git a/phpgwapi/inc/class.egw_framework.inc.php b/phpgwapi/inc/class.egw_framework.inc.php index ab22d51250..6aa10901a3 100644 --- a/phpgwapi/inc/class.egw_framework.inc.php +++ b/phpgwapi/inc/class.egw_framework.inc.php @@ -507,6 +507,30 @@ abstract class egw_framework return egw::link($index,$GLOBALS['egw_info']['flags']['params'][$app]); } + /** + * Internal usort callback function used to sort an array according to the + * user sort order + */ + private static function _sort_apparray($a, $b) + { + //Unserialize the user_apporder array + $arr = unserialize($GLOBALS['egw_info']['user']['preferences']['common']['user_apporder']); + + $ind_a = isset($arr[$a['name']]) ? $arr[$a['name']] : null; + $ind_b = isset($arr[$b['name']]) ? $arr[$b['name']] : null; + + if ($ind_a == $ind_b) + return 0; + + if ($ind_a == null) + return -1; + + if ($ind_b == null) + return 1; + + return $ind_a > $ind_b ? 1 : -1; + } + /** * Prepare an array with apps used to render the navbar * @@ -578,6 +602,15 @@ abstract class egw_framework } } } + + //Sort the applications accordingly to their user sort setting + if ($GLOBALS['egw_info']['user']['preferences']['common']['user_apporder']) + { + //Sort the application array using the user_apporder array as sort index + uasort($apps, 'egw_framework::_sort_apparray'); + } + + if ($GLOBALS['egw_info']['flags']['currentapp'] == 'preferences' || $GLOBALS['egw_info']['flags']['currentapp'] == 'about') { $app = $app_title = 'EGroupware'; diff --git a/phpgwapi/js/egw_json.js b/phpgwapi/js/egw_json.js index 8acf89368e..714b205e23 100644 --- a/phpgwapi/js/egw_json.js +++ b/phpgwapi/js/egw_json.js @@ -87,11 +87,13 @@ function egw_json_encode(input) { switch (input.constructor) { - case Array: + case Array: var buf = []; for (var k in input) { - buf.push(egw_json_encode(input[k])); + //Filter the remove function, which is added to arrays in egw_fw_classes + if (k != 'remove') + buf.push(egw_json_encode(input[k])); } return '[' + buf.join(',') + ']';