aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMario Vavti <mario@mariovavti.com>2018-07-18 20:59:45 +0200
committerMario Vavti <mario@mariovavti.com>2018-07-18 20:59:45 +0200
commitdfbdeafa39da8605c124f47d811ebca2330d9169 (patch)
tree1f1431f9306cc06de7fc20616cb6124f4535d1a7
parenteb322e831297ee8fd773049c1a00c915c49dc93e (diff)
parent82a4bbd571131462bbff1cb2455af46747f3b840 (diff)
downloadvolse-hubzilla-dfbdeafa39da8605c124f47d811ebca2330d9169.tar.gz
volse-hubzilla-dfbdeafa39da8605c124f47d811ebca2330d9169.tar.bz2
volse-hubzilla-dfbdeafa39da8605c124f47d811ebca2330d9169.zip
Merge remote-tracking branch 'mike/master' into dev
-rw-r--r--Zotlabs/Extend/Route.php48
-rw-r--r--Zotlabs/Extend/Widget.php47
-rw-r--r--Zotlabs/Lib/Apps.php36
-rw-r--r--Zotlabs/Module/Settings/Oauth2.php4
-rw-r--r--Zotlabs/Render/Comanche.php34
-rw-r--r--Zotlabs/Web/Router.php32
-rwxr-xr-xutil/update_addon_repo7
7 files changed, 183 insertions, 25 deletions
diff --git a/Zotlabs/Extend/Route.php b/Zotlabs/Extend/Route.php
new file mode 100644
index 000000000..f7b90ec6e
--- /dev/null
+++ b/Zotlabs/Extend/Route.php
@@ -0,0 +1,48 @@
+<?php
+
+namespace Zotlabs\Extend;
+
+
+class Route {
+
+ static function register($file,$modname) {
+ $rt = self::get();
+ $rt[] = [ $file, $modname ];
+ self::set($rt);
+ }
+
+ static function unregister($file,$modname) {
+ $rt = self::get();
+ if($rt) {
+ $n = [];
+ foreach($rt as $r) {
+ if($r[0] !== $file && $r[1] !== $modname) {
+ $n[] = $r;
+ }
+ }
+ self::set($n);
+ }
+ }
+
+ static function unregister_by_file($file) {
+ $rt = self::get();
+ if($rt) {
+ $n = [];
+ foreach($rt as $r) {
+ if($r[0] !== $file) {
+ $n[] = $r;
+ }
+ }
+ self::set($n);
+ }
+ }
+
+ static function get() {
+ return get_config('system','routes',[]);
+ }
+
+ static function set($r) {
+ return set_config('system','routes',$r);
+ }
+}
+
diff --git a/Zotlabs/Extend/Widget.php b/Zotlabs/Extend/Widget.php
new file mode 100644
index 000000000..dee64c61b
--- /dev/null
+++ b/Zotlabs/Extend/Widget.php
@@ -0,0 +1,47 @@
+<?php
+
+namespace Zotlabs\Extend;
+
+
+class Widget {
+
+ static function register($file,$widget) {
+ $rt = self::get();
+ $rt[] = [ $file, $widget ];
+ self::set($rt);
+ }
+
+ static function unregister($file,$widget) {
+ $rt = self::get();
+ if($rt) {
+ $n = [];
+ foreach($rt as $r) {
+ if($r[0] !== $file && $r[1] !== $widget) {
+ $n[] = $r;
+ }
+ }
+ self::set($n);
+ }
+ }
+
+ static function unregister_by_file($file) {
+ $rt = self::get();
+ if($rt) {
+ $n = [];
+ foreach($rt as $r) {
+ if($r[0] !== $file) {
+ $n[] = $r;
+ }
+ }
+ self::set($n);
+ }
+ }
+
+ static function get() {
+ return get_config('system','widgets',[]);
+ }
+
+ static function set($r) {
+ return set_config('system','widgets',$r);
+ }
+}
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 = "";
diff --git a/Zotlabs/Module/Settings/Oauth2.php b/Zotlabs/Module/Settings/Oauth2.php
index 985095115..f58d01d8c 100644
--- a/Zotlabs/Module/Settings/Oauth2.php
+++ b/Zotlabs/Module/Settings/Oauth2.php
@@ -115,8 +115,8 @@ class Oauth2 {
'$name' => array('name', t('Name'), $app['client_id'], t('Name of application')),
'$secret' => array('secret', t('Consumer Secret'), $app['client_secret'], t('Automatically generated - change if desired. Max length 20')),
'$redirect' => array('redirect', t('Redirect'), $app['redirect_uri'], t('Redirect URI - leave blank unless your application specifically requires this')),
- '$grant' => array('grant', t('Grant Types'), $app['grant_types'], t('leave blank unless your application sepcifically requires this')),
- '$scope' => array('scope', t('Authorization scope'), $app['scope'], t('leave blank unless your application sepcifically requires this')),
+ '$grant' => array('grant', t('Grant Types'), $app['grant_types'], t('leave blank unless your application specifically requires this')),
+ '$scope' => array('scope', t('Authorization scope'), $app['scope'], t('leave blank unless your application specifically requires this')),
));
return $o;
}
diff --git a/Zotlabs/Render/Comanche.php b/Zotlabs/Render/Comanche.php
index fb400b6fe..f58dba60e 100644
--- a/Zotlabs/Render/Comanche.php
+++ b/Zotlabs/Render/Comanche.php
@@ -528,18 +528,32 @@ class Comanche {
$clsname = ucfirst($name);
$nsname = "\\Zotlabs\\Widget\\" . $clsname;
- if(file_exists('Zotlabs/SiteWidget/' . $clsname . '.php'))
- require_once('Zotlabs/SiteWidget/' . $clsname . '.php');
- elseif(file_exists('widget/' . $clsname . '/' . $clsname . '.php'))
- require_once('widget/' . $clsname . '/' . $clsname . '.php');
- elseif(file_exists('Zotlabs/Widget/' . $clsname . '.php'))
- require_once('Zotlabs/Widget/' . $clsname . '.php');
- else {
- $pth = theme_include($clsname . '.php');
- if($pth) {
- require_once($pth);
+ $found = false;
+ $widgets = \Zotlabs\Extend\Widget::get();
+ if($widgets) {
+ foreach($widgets as $widget) {
+ if(is_array($widget) && strtolower($widget[1]) === strtolower($name) && file_exists($widget[0])) {
+ require_once($widget[0]);
+ $found = true;
+ }
}
}
+
+ if(! $found) {
+ if(file_exists('Zotlabs/SiteWidget/' . $clsname . '.php'))
+ require_once('Zotlabs/SiteWidget/' . $clsname . '.php');
+ elseif(file_exists('widget/' . $clsname . '/' . $clsname . '.php'))
+ require_once('widget/' . $clsname . '/' . $clsname . '.php');
+ elseif(file_exists('Zotlabs/Widget/' . $clsname . '.php'))
+ require_once('Zotlabs/Widget/' . $clsname . '.php');
+ else {
+ $pth = theme_include($clsname . '.php');
+ if($pth) {
+ require_once($pth);
+ }
+ }
+ }
+
if(class_exists($nsname)) {
$x = new $nsname;
$f = 'widget';
diff --git a/Zotlabs/Web/Router.php b/Zotlabs/Web/Router.php
index fb551e36f..c4db0ef3e 100644
--- a/Zotlabs/Web/Router.php
+++ b/Zotlabs/Web/Router.php
@@ -2,6 +2,7 @@
namespace Zotlabs\Web;
+use Zotlabs\Extend\Route;
use Exception;
/**
@@ -52,14 +53,31 @@ class Router {
* First see if we have a plugin which is masquerading as a module.
*/
- if(is_array(\App::$plugins) && in_array($module,\App::$plugins) && file_exists("addon/{$module}/{$module}.php")) {
- include_once("addon/{$module}/{$module}.php");
- if(class_exists($modname)) {
- $this->controller = new $modname;
- \App::$module_loaded = true;
+ $routes = Route::get();
+ if($routes) {
+ foreach($routes as $route) {
+ if(is_array($route) && strtolower($route[1]) === $module) {
+ include_once($route[0]);
+ if(class_exists($modname)) {
+ $this->controller = new $modname;
+ \App::$module_loaded = true;
+ }
+ }
}
- elseif(function_exists($module . '_module')) {
- \App::$module_loaded = true;
+ }
+
+ // legacy plugins - this can be removed when they have all been converted
+
+ if(! (\App::$module_loaded)) {
+ if(is_array(\App::$plugins) && in_array($module,\App::$plugins) && file_exists("addon/{$module}/{$module}.php")) {
+ include_once("addon/{$module}/{$module}.php");
+ if(class_exists($modname)) {
+ $this->controller = new $modname;
+ \App::$module_loaded = true;
+ }
+ elseif(function_exists($module . '_module')) {
+ \App::$module_loaded = true;
+ }
}
}
diff --git a/util/update_addon_repo b/util/update_addon_repo
index 0e471eb4f..02c860c8c 100755
--- a/util/update_addon_repo
+++ b/util/update_addon_repo
@@ -44,3 +44,10 @@ for a in "${filelist[@]}" ; do
echo linking $base
ln -s ../extend/addon/$1/$base $base
done
+
+for x in `ls` ; do
+ if [ -L "$x" ] && ! [ -e "$x" ]; then
+ echo "removing dead symlink $x" ;
+ rm -- "$x";
+ fi;
+done