From e6cfa64686ab8f9678e3a8010cbee7a3e520519c Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Wed, 2 Sep 2015 13:08:25 +0000 Subject: [PATCH] * All apps: fix broken group-favorites --- phpgwapi/setup/setup.inc.php | 2 +- phpgwapi/setup/tables_update.inc.php | 39 ++++++++++++++++++++++++++-- 2 files changed, 38 insertions(+), 3 deletions(-) diff --git a/phpgwapi/setup/setup.inc.php b/phpgwapi/setup/setup.inc.php index f799f1a839..81a196d3af 100755 --- a/phpgwapi/setup/setup.inc.php +++ b/phpgwapi/setup/setup.inc.php @@ -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.903'; +$setup_info['phpgwapi']['version'] = '14.3.904'; $setup_info['phpgwapi']['versions']['current_header'] = '1.29'; $setup_info['phpgwapi']['enable'] = 3; $setup_info['phpgwapi']['app_order'] = 1; diff --git a/phpgwapi/setup/tables_update.inc.php b/phpgwapi/setup/tables_update.inc.php index 5a7fb7723e..ca0259448b 100644 --- a/phpgwapi/setup/tables_update.inc.php +++ b/phpgwapi/setup/tables_update.inc.php @@ -836,7 +836,7 @@ function phpgwapi_upgrade14_3_002() { $value = array( 'name' => substr($name, 9), // skip "favorite_" - 'group' => !($owner > 0), + 'group' => $owner < -2 ? $owner+2 : false, 'state' => $state, ); } @@ -862,6 +862,29 @@ function phpgwapi_upgrade14_3_003() return $GLOBALS['setup_info']['phpgwapi']['currentver'] = '14.3.004'; } +/** + * Fix by 14.3.003 broken group favorites + * + * @return string + */ +function phpgwapi_upgrade14_3_004() +{ + $GLOBALS['run-from-upgrade14_3_004'] = true; + + preferences::change_preference(null, '/^favorite_/', function($name, $value, $owner) + { + unset($name); // not used, but required by function signature + + if ($value['group'] === true) + { + $value['group'] = $owner+2; + } + return $value; + }); + + return $GLOBALS['setup_info']['phpgwapi']['currentver'] = '14.3.005'; +} + /** * Updates on the way to 15.1 */ @@ -871,7 +894,7 @@ function phpgwapi_upgrade14_3_003() * * @return string */ -function phpgwapi_upgrade14_3_004() +function phpgwapi_upgrade14_3_005() { $GLOBALS['egw_setup']->oProc->DropTable('egw_api_content_history'); @@ -923,3 +946,15 @@ function phpgwapi_upgrade14_3_902() return $GLOBALS['setup_info']['phpgwapi']['currentver'] = '14.3.903'; } + +/** + * Run 14.3.004 upgrade for everyone who was already on 14.3.900 + */ +function phpgwapi_upgrade14_3_903() +{ + if (empty($GLOBALS['run-from-upgrade14_3_004'])) + { + phpgwapi_upgrade14_3_004(); + } + return $GLOBALS['setup_info']['phpgwapi']['currentver'] = '14.3.904'; +}