From 0f1fcd97433cd3b1251daee8a9064a189cb5c132 Mon Sep 17 00:00:00 2001 From: redmatrix Date: Thu, 2 Jun 2016 16:38:15 -0700 Subject: install system apps if a) they have never been installed, or b) if the app version changes --- Zotlabs/Lib/Apps.php | 39 +++++++++++++++++++++++++++++---------- 1 file changed, 29 insertions(+), 10 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Lib/Apps.php b/Zotlabs/Lib/Apps.php index 6d2ef4e45..7e232af02 100644 --- a/Zotlabs/Lib/Apps.php +++ b/Zotlabs/Lib/Apps.php @@ -13,6 +13,8 @@ require_once('include/channel.php'); class Apps { + static public $installed_system_apps = null; + static public function get_system_apps($translate = true) { $ret = array(); @@ -49,22 +51,35 @@ class Apps { static public function import_system_apps() { if(! local_channel()) return; + $apps = self::get_system_apps(false); - // Eventually we want to look at modification dates and update system apps. - $installed = get_pconfig(local_channel(),'system','apps_installed'); - if($installed) - return; - $apps = self::get_system_apps(false); + self::$installed_system_apps = q("select * from app where app_system = 1 and app_channel = %d", + intval(local_channel()) + ); + if($apps) { foreach($apps as $app) { - $app['uid'] = local_channel(); - $app['guid'] = hash('whirlpool',$app['name']); - $app['system'] = 1; - self::app_install(local_channel(),$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); + } } } - set_pconfig(local_channel(),'system','apps_installed',1); + } + + static public function check_install_system_app($app) { + if((! is_array(self::$installed_system_apps)) || (! count(self::$installed_system_apps))) { + return true; + } + foreach(self::$installed_system_apps as $iapp) { + if(($iapp['app_id'] == hash('whirlpool',$app['name'])) && ($iapp['app_version'] != $app['version'])) { + return true; + } + } + return false; } @@ -111,6 +126,10 @@ class Apps { if(array_key_exists('target',$ret)) $ret['target'] = str_replace(array('\'','"'),array(''','&dquot;'),$ret['target']); + if(array_key_exists('version',$ret)) + $ret['version'] = str_replace(array('\'','"'),array(''','&dquot;'),$ret['version']); + + if(array_key_exists('requires',$ret)) { $requires = explode(',',$ret['requires']); foreach($requires as $require) { -- cgit v1.2.3 From 4a3ec65409f1b89f7f96ca0b102716735be2108e Mon Sep 17 00:00:00 2001 From: redmatrix Date: Thu, 2 Jun 2016 16:45:00 -0700 Subject: adjust algorithm to ensure new system apps are installed. --- Zotlabs/Lib/Apps.php | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Lib/Apps.php b/Zotlabs/Lib/Apps.php index 7e232af02..fd713a3f8 100644 --- a/Zotlabs/Lib/Apps.php +++ b/Zotlabs/Lib/Apps.php @@ -70,16 +70,25 @@ class Apps { } } + /** + * Install the system app if no system apps have been installed, or if a new system app + * is discovered, or if the version of a system app changes. + */ + static public function check_install_system_app($app) { if((! is_array(self::$installed_system_apps)) || (! count(self::$installed_system_apps))) { return true; } + $notfound = true; foreach(self::$installed_system_apps as $iapp) { - if(($iapp['app_id'] == hash('whirlpool',$app['name'])) && ($iapp['app_version'] != $app['version'])) { - return true; + if($iapp['app_id'] == hash('whirlpool',$app['name'])) { + $notfound = false; + if($iapp['app_version'] != $app['version']) { + return true; + } } } - return false; + return $notfound; } -- cgit v1.2.3 From e596bf025bc2cb700d2603871286df1102d41031 Mon Sep 17 00:00:00 2001 From: redmatrix Date: Thu, 2 Jun 2016 17:08:47 -0700 Subject: preserve app categories when updating a system app --- Zotlabs/Lib/Apps.php | 32 +++++++++++++++++++++++++------- 1 file changed, 25 insertions(+), 7 deletions(-) (limited to 'Zotlabs') 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']); } } } -- cgit v1.2.3 From 390ce207db5b2e0a68e82cb80b6667431e07d31c Mon Sep 17 00:00:00 2001 From: redmatrix Date: Thu, 2 Jun 2016 20:31:34 -0700 Subject: experimental emoji support --- Zotlabs/Module/React.php | 50 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 Zotlabs/Module/React.php (limited to 'Zotlabs') diff --git a/Zotlabs/Module/React.php b/Zotlabs/Module/React.php new file mode 100644 index 000000000..85a1e2350 --- /dev/null +++ b/Zotlabs/Module/React.php @@ -0,0 +1,50 @@ +