aboutsummaryrefslogtreecommitdiffstats
path: root/include/plugin.php
diff options
context:
space:
mode:
authormrjive <mrjive@mrjive.it>2018-02-21 12:55:29 +0100
committerGitHub <noreply@github.com>2018-02-21 12:55:29 +0100
commit2d17e1c677cd981858a4080af98edb51bbb5d822 (patch)
tree54d5d148d368632158584ba7eec7872170524e00 /include/plugin.php
parentd7ecaa8b23a36ea1e9a0f185017930b5552c00b5 (diff)
parenta829256bc4803731881a51bddd19ee59a5a234ff (diff)
downloadvolse-hubzilla-2d17e1c677cd981858a4080af98edb51bbb5d822.tar.gz
volse-hubzilla-2d17e1c677cd981858a4080af98edb51bbb5d822.tar.bz2
volse-hubzilla-2d17e1c677cd981858a4080af98edb51bbb5d822.zip
Merge pull request #15 from redmatrix/dev
Dev
Diffstat (limited to 'include/plugin.php')
-rwxr-xr-xinclude/plugin.php72
1 files changed, 71 insertions, 1 deletions
diff --git a/include/plugin.php b/include/plugin.php
index 67157dee7..62d443ab8 100755
--- a/include/plugin.php
+++ b/include/plugin.php
@@ -179,14 +179,84 @@ 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.
*
* @return array
*/
function visible_plugin_list() {
+
$r = q("select * from addon where hidden = 0 order by aname asc");
- return(($r) ? ids_to_array($r,'aname') : array());
+ $x = (($r) ? ids_to_array($r,'aname') : array());
+ $y = [];
+ if($x) {
+ foreach($x as $xv) {
+ if(is_dir('addon/' . $xv)) {
+ $y[] = $xv;
+ }
+ }
+ }
+ return $y;
}