decomplicate cont.
This commit is contained in:
parent
512f3a7643
commit
3e7dffb676
50
boot.php
50
boot.php
@ -1450,58 +1450,10 @@ function check_config() {
|
|||||||
$x = new \Zotlabs\Lib\DB_Upgrade(DB_UPDATE_VERSION);
|
$x = new \Zotlabs\Lib\DB_Upgrade(DB_UPDATE_VERSION);
|
||||||
|
|
||||||
|
|
||||||
/**
|
plugins_sync();
|
||||||
*
|
|
||||||
* Synchronise plugins:
|
|
||||||
*
|
|
||||||
* App::$config['system']['addon'] contains a comma-separated list of names
|
|
||||||
* of plugins/addons which are used on this system.
|
|
||||||
* Go through the database list of already installed addons, and if we have
|
|
||||||
* an entry, but it isn't in the config list, call the unload procedure
|
|
||||||
* and mark it uninstalled in the database (for now we'll remove it).
|
|
||||||
* Then go through the config list and if we have a plugin that isn't installed,
|
|
||||||
* call the install procedure and add it to the database.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
$r = q("SELECT * FROM addon WHERE installed = 1");
|
|
||||||
if($r)
|
|
||||||
$installed = $r;
|
|
||||||
else
|
|
||||||
$installed = array();
|
|
||||||
|
|
||||||
$plugins = get_config('system', 'addon');
|
|
||||||
$plugins_arr = array();
|
|
||||||
|
|
||||||
if($plugins)
|
|
||||||
$plugins_arr = explode(',', str_replace(' ', '', $plugins));
|
|
||||||
|
|
||||||
App::$plugins = $plugins_arr;
|
|
||||||
|
|
||||||
$installed_arr = array();
|
|
||||||
|
|
||||||
if(count($installed)) {
|
|
||||||
foreach($installed as $i) {
|
|
||||||
if(! in_array($i['aname'], $plugins_arr)) {
|
|
||||||
unload_plugin($i['aname']);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$installed_arr[] = $i['aname'];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(count($plugins_arr)) {
|
|
||||||
foreach($plugins_arr as $p) {
|
|
||||||
if(! in_array($p, $installed_arr)) {
|
|
||||||
load_plugin($p);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
load_hooks();
|
load_hooks();
|
||||||
|
|
||||||
|
|
||||||
check_for_new_perms();
|
check_for_new_perms();
|
||||||
|
|
||||||
check_cron_broken();
|
check_cron_broken();
|
||||||
|
@ -179,6 +179,66 @@ function reload_plugins() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function plugins_installed_list() {
|
||||||
|
|
||||||
|
$r = q("select * from addon where installed = 1 order by aname asc");
|
||||||
|
return(($r) ? ids_to_array($r,'aname') : []);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function plugins_sync() {
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Synchronise plugins:
|
||||||
|
*
|
||||||
|
* App::$config['system']['addon'] contains a comma-separated list of names
|
||||||
|
* of plugins/addons which are used on this system.
|
||||||
|
* Go through the database list of already installed addons, and if we have
|
||||||
|
* an entry, but it isn't in the config list, call the unload procedure
|
||||||
|
* and mark it uninstalled in the database (for now we'll remove it).
|
||||||
|
* Then go through the config list and if we have a plugin that isn't installed,
|
||||||
|
* call the install procedure and add it to the database.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
$installed = plugins_installed_list();
|
||||||
|
|
||||||
|
$plugins = get_config('system', 'addon', '');
|
||||||
|
|
||||||
|
$plugins_arr = explode(',', $plugins);
|
||||||
|
|
||||||
|
// array_trim is in include/text.php
|
||||||
|
|
||||||
|
if(! array_walk($plugins_arr,'array_trim'))
|
||||||
|
return;
|
||||||
|
|
||||||
|
App::$plugins = $plugins_arr;
|
||||||
|
|
||||||
|
$installed_arr = [];
|
||||||
|
|
||||||
|
if(count($installed)) {
|
||||||
|
foreach($installed as $i) {
|
||||||
|
if(! in_array($i, $plugins_arr)) {
|
||||||
|
unload_plugin($i);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$installed_arr[] = $i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(count($plugins_arr)) {
|
||||||
|
foreach($plugins_arr as $p) {
|
||||||
|
if(! in_array($p, $installed_arr)) {
|
||||||
|
load_plugin($p);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Get a list of non hidden addons.
|
* @brief Get a list of non hidden addons.
|
||||||
*
|
*
|
||||||
|
Reference in New Issue
Block a user