diff options
author | redmatrix <git@macgirvin.com> | 2016-06-02 17:08:47 -0700 |
---|---|---|
committer | redmatrix <git@macgirvin.com> | 2016-06-02 17:08:47 -0700 |
commit | e596bf025bc2cb700d2603871286df1102d41031 (patch) | |
tree | ced9a7608ecf03ab8ae8f302f2eb9c5193c26d9f /Zotlabs/Lib | |
parent | 4a3ec65409f1b89f7f96ca0b102716735be2108e (diff) | |
download | volse-hubzilla-e596bf025bc2cb700d2603871286df1102d41031.tar.gz volse-hubzilla-e596bf025bc2cb700d2603871286df1102d41031.tar.bz2 volse-hubzilla-e596bf025bc2cb700d2603871286df1102d41031.zip |
preserve app categories when updating a system app
Diffstat (limited to 'Zotlabs/Lib')
-rw-r--r-- | Zotlabs/Lib/Apps.php | 32 |
1 files changed, 25 insertions, 7 deletions
diff --git a/Zotlabs/Lib/Apps.php b/Zotlabs/Lib/Apps.php index fd713a3f8..9dd4bf2d7 100644 --- a/Zotlabs/Lib/Apps.php +++ b/Zotlabs/Lib/Apps.php @@ -60,12 +60,30 @@ class Apps { if($apps) { foreach($apps as $app) { - if(self::check_install_system_app($app)) { - $app['uid'] = local_channel(); - $app['guid'] = hash('whirlpool',$app['name']); - $app['system'] = 1; - self::app_install(local_channel(),$app); - } + $id = self::check_install_system_app($app); + // $id will be boolean true or false to install an app, or an integer id to update an existing app + if($id === false) + continue; + if($id !== true) { + // if we already installed this app, but it changed, preserve any categories we created + $s = ''; + $r = q("select * from term where otype = %d and oid = d", + intval(TERM_OBJ_APP), + intval($id) + ); + if($r) { + foreach($r as $t) { + if($s) + $s .= ','; + $s .= $t['term']; + } + $app['categories'] = $s; + } + } + $app['uid'] = local_channel(); + $app['guid'] = hash('whirlpool',$app['name']); + $app['system'] = 1; + self::app_install(local_channel(),$app); } } } @@ -84,7 +102,7 @@ class Apps { if($iapp['app_id'] == hash('whirlpool',$app['name'])) { $notfound = false; if($iapp['app_version'] != $app['version']) { - return true; + return intval($iapp['app_id']); } } } |