Add filters for addon/app installed checks and docs
This commit is contained in:
parent
d83fe9d417
commit
995fc63f2c
@ -532,7 +532,7 @@ class Apps {
|
|||||||
static public function app_install($uid,$app) {
|
static public function app_install($uid,$app) {
|
||||||
$app['uid'] = $uid;
|
$app['uid'] = $uid;
|
||||||
|
|
||||||
if(self::app_installed($uid,$app))
|
if(self::app_installed($uid,$app,true))
|
||||||
$x = self::app_update($app);
|
$x = self::app_update($app);
|
||||||
else
|
else
|
||||||
$x = self::app_store($app);
|
$x = self::app_store($app);
|
||||||
@ -660,33 +660,60 @@ class Apps {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static public function app_installed($uid,$app) {
|
static public function app_installed($uid,$app,$bypass_filter=false) {
|
||||||
|
|
||||||
$r = q("select id from app where app_id = '%s' and app_channel = %d limit 1",
|
$r = q("select id from app where app_id = '%s' and app_channel = %d limit 1",
|
||||||
dbesc((array_key_exists('guid',$app)) ? $app['guid'] : ''),
|
dbesc((array_key_exists('guid',$app)) ? $app['guid'] : ''),
|
||||||
intval($uid)
|
intval($uid)
|
||||||
);
|
);
|
||||||
|
if (!$bypass_filter) {
|
||||||
|
$filter_arr = [
|
||||||
|
'uid'=>$uid,
|
||||||
|
'app'=>$app,
|
||||||
|
'installed'=>$r
|
||||||
|
];
|
||||||
|
call_hooks('app_installed_filter',$filter_arr);
|
||||||
|
$r = $filter_arr['installed'];
|
||||||
|
}
|
||||||
return(($r) ? true : false);
|
return(($r) ? true : false);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static public function addon_app_installed($uid,$app) {
|
static public function addon_app_installed($uid,$app,$bypass_filter=false) {
|
||||||
|
|
||||||
$r = q("select id from app where app_plugin = '%s' and app_channel = %d limit 1",
|
$r = q("select id from app where app_plugin = '%s' and app_channel = %d limit 1",
|
||||||
dbesc($app),
|
dbesc($app),
|
||||||
intval($uid)
|
intval($uid)
|
||||||
);
|
);
|
||||||
|
if (!$bypass_filter) {
|
||||||
|
$filter_arr = [
|
||||||
|
'uid'=>$uid,
|
||||||
|
'app'=>$app,
|
||||||
|
'installed'=>$r
|
||||||
|
];
|
||||||
|
call_hooks('addon_app_installed_filter',$filter_arr);
|
||||||
|
$r = $filter_arr['installed'];
|
||||||
|
}
|
||||||
return(($r) ? true : false);
|
return(($r) ? true : false);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static public function system_app_installed($uid,$app) {
|
static public function system_app_installed($uid,$app,$bypass_filter=false) {
|
||||||
|
|
||||||
$r = q("select id from app where app_id = '%s' and app_channel = %d limit 1",
|
$r = q("select id from app where app_id = '%s' and app_channel = %d limit 1",
|
||||||
dbesc(hash('whirlpool',$app)),
|
dbesc(hash('whirlpool',$app)),
|
||||||
intval($uid)
|
intval($uid)
|
||||||
);
|
);
|
||||||
|
if (!$bypass_filter) {
|
||||||
|
$filter_arr = [
|
||||||
|
'uid'=>$uid,
|
||||||
|
'app'=>$app,
|
||||||
|
'installed'=>$r
|
||||||
|
];
|
||||||
|
call_hooks('system_app_installed_filter',$filter_arr);
|
||||||
|
$r = $filter_arr['installed'];
|
||||||
|
}
|
||||||
return(($r) ? true : false);
|
return(($r) ? true : false);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
18
doc/hook/addon_app_installed_filter.bb
Normal file
18
doc/hook/addon_app_installed_filter.bb
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
[h2]addon_app_installed_filter[/h2]
|
||||||
|
|
||||||
|
Allow plugins to filter the result of addon_app_installed.
|
||||||
|
|
||||||
|
Code excerpt:
|
||||||
|
|
||||||
|
[code]
|
||||||
|
$filter_arr = [
|
||||||
|
'uid'=>$uid,
|
||||||
|
'app'=>$app,
|
||||||
|
'installed'=>$r
|
||||||
|
];
|
||||||
|
call_hooks('addon_app_installed_filter',$filter_arr);
|
||||||
|
$r = $filter_arr['installed'];
|
||||||
|
[/code]
|
||||||
|
|
||||||
|
cxref: Zotlabs/Lib/Apps.php
|
||||||
|
|
17
doc/hook/app_installed_filter.bb
Normal file
17
doc/hook/app_installed_filter.bb
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
[h2]app_installed_filter[/h2]
|
||||||
|
|
||||||
|
Allow plugins to filter the result of app_installed.
|
||||||
|
|
||||||
|
Code excerpt:
|
||||||
|
|
||||||
|
[code]
|
||||||
|
$filter_arr = [
|
||||||
|
'uid'=>$uid,
|
||||||
|
'app'=>$app,
|
||||||
|
'installed'=>$r
|
||||||
|
];
|
||||||
|
call_hooks('app_installed_filter',$filter_arr);
|
||||||
|
$r = $filter_arr['installed'];
|
||||||
|
[/code]
|
||||||
|
|
||||||
|
cxref: Zotlabs/Lib/Apps.php
|
18
doc/hook/system_app_installed_filter.bb
Normal file
18
doc/hook/system_app_installed_filter.bb
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
[h2]system_app_installed_filter[/h2]
|
||||||
|
|
||||||
|
Allow plugins to filter the result of system_app_installed.
|
||||||
|
|
||||||
|
Code excerpt:
|
||||||
|
|
||||||
|
[code]
|
||||||
|
$filter_arr = [
|
||||||
|
'uid'=>$uid,
|
||||||
|
'app'=>$app,
|
||||||
|
'installed'=>$r
|
||||||
|
];
|
||||||
|
call_hooks('system_app_installed_filter',$filter_arr);
|
||||||
|
$r = $filter_arr['installed'];
|
||||||
|
[/code]
|
||||||
|
|
||||||
|
cxref: Zotlabs/Lib/Apps.php
|
||||||
|
|
@ -37,6 +37,9 @@ Hooks allow plugins/addons to "hook into" the code at many points and alter the
|
|||||||
[zrl=[baseurl]/help/hook/activity_order]activity_order[/zrl]
|
[zrl=[baseurl]/help/hook/activity_order]activity_order[/zrl]
|
||||||
Called when generating the list of order options for the network page
|
Called when generating the list of order options for the network page
|
||||||
|
|
||||||
|
[zrl=[baseurl]/help/hook/addon_app_installed_filter]addon_app_installed_filter[/zrl]
|
||||||
|
Called when determining whether an addon_app is installed
|
||||||
|
|
||||||
[zrl=[baseurl]/help/hook/activity_received]activity_received[/zrl]
|
[zrl=[baseurl]/help/hook/activity_received]activity_received[/zrl]
|
||||||
Called when an activity (post, comment, like, etc.) has been received from a zot source
|
Called when an activity (post, comment, like, etc.) has been received from a zot source
|
||||||
|
|
||||||
@ -49,6 +52,9 @@ Hooks allow plugins/addons to "hook into" the code at many points and alter the
|
|||||||
[zrl=[baseurl]/help/hook/api_perm_is_allowed]api_perm_is_allowed[/zrl]
|
[zrl=[baseurl]/help/hook/api_perm_is_allowed]api_perm_is_allowed[/zrl]
|
||||||
Called when perm_is_allowed() is executed from an API call.
|
Called when perm_is_allowed() is executed from an API call.
|
||||||
|
|
||||||
|
[zrl=[baseurl]/help/hook/app_installed_filter]app_installed_filter[/zrl]
|
||||||
|
Called when determining whether an app is installed
|
||||||
|
|
||||||
[zrl=[baseurl]/help/hook/app_menu]app_menu[/zrl]
|
[zrl=[baseurl]/help/hook/app_menu]app_menu[/zrl]
|
||||||
Called when generating the app_menu dropdown (may be obsolete)
|
Called when generating the app_menu dropdown (may be obsolete)
|
||||||
|
|
||||||
@ -592,6 +598,9 @@ Hooks allow plugins/addons to "hook into" the code at many points and alter the
|
|||||||
[zrl=[baseurl]/help/hook/stream_item]stream_item[/zrl]
|
[zrl=[baseurl]/help/hook/stream_item]stream_item[/zrl]
|
||||||
Called for each item which is rendered for viewing via conversation()
|
Called for each item which is rendered for viewing via conversation()
|
||||||
|
|
||||||
|
[zrl=[baseurl]/help/hook/system_app_installed_filter]system_app_installed_filter[/zrl]
|
||||||
|
Called when determining whether a system app is installed
|
||||||
|
|
||||||
[zrl=[baseurl]/help/hook/tagged]tagged[/zrl]
|
[zrl=[baseurl]/help/hook/tagged]tagged[/zrl]
|
||||||
Called when a delivery is processed which results in you being tagged
|
Called when a delivery is processed which results in you being tagged
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user