From d71e70bedf4fa7244f3fcce789e29504c452d5cd Mon Sep 17 00:00:00 2001 From: zotlabs Date: Thu, 12 Jul 2018 16:23:32 -0700 Subject: functions to support module and widget registration by plugins. These have identical construction to core modules and widgets and are registered just like hooks during addon load. Also additional Apps functions addon_app_installed() and system_app_installed() which will eventually replace feature_installed() for features which are converted to apps. The convention being used is that the module associated with the app calls the appropriate *_app_installed() function and if not present emits descriptive text about the app and exits. This allows one to click on an 'available' app and learn about it. Once installed, the app module behaves normally and may offer functionality or what once were addon settings on the settings/featured page. Refer to zap-addons in the zap repository for examples of how this is being used to eliminate the 'additional features' and 'addon settings' pages. --- Zotlabs/Lib/Apps.php | 36 ++++++++++++++++++++++++++++++------ 1 file changed, 30 insertions(+), 6 deletions(-) (limited to 'Zotlabs/Lib/Apps.php') diff --git a/Zotlabs/Lib/Apps.php b/Zotlabs/Lib/Apps.php index c2ec5c967..82f0b57b8 100644 --- a/Zotlabs/Lib/Apps.php +++ b/Zotlabs/Lib/Apps.php @@ -534,13 +534,15 @@ class Apps { intval(TERM_OBJ_APP), intval($x[0]['id']) ); - $r = q("delete from app where app_id = '%s' and app_channel = %d", - dbesc($app['guid']), - intval($uid) - ); + if ($uid) { + $r = q("delete from app where app_id = '%s' and app_channel = %d", + dbesc($app['guid']), + intval($uid) + ); - // we don't sync system apps - they may be completely different on the other system - build_sync_packet($uid,array('app' => $x)); + // we don't sync system apps - they may be completely different on the other system + build_sync_packet($uid,array('app' => $x)); + } } else { self::app_undestroy($uid,$app); @@ -605,6 +607,28 @@ class Apps { } + static public function addon_app_installed($uid,$app) { + + $r = q("select id from app where app_plugin = '%s' and app_channel = %d limit 1", + dbesc($app), + intval($uid) + ); + return(($r) ? true : false); + + } + + static public function system_app_installed($uid,$app) { + + $r = q("select id from app where app_id = '%s' and app_channel = %d limit 1", + dbesc(hash('whirlpool',$app)), + intval($uid) + ); + return(($r) ? true : false); + + } + + + static public function app_list($uid, $deleted = false, $cats = []) { if($deleted) $sql_extra = ""; -- cgit v1.2.3