Merge remote-tracking branch 'mike/master' into dev
This commit is contained in:
commit
dfbdeafa39
48
Zotlabs/Extend/Route.php
Normal file
48
Zotlabs/Extend/Route.php
Normal file
@ -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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
47
Zotlabs/Extend/Widget.php
Normal file
47
Zotlabs/Extend/Widget.php
Normal file
@ -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);
|
||||||
|
}
|
||||||
|
}
|
@ -534,6 +534,7 @@ class Apps {
|
|||||||
intval(TERM_OBJ_APP),
|
intval(TERM_OBJ_APP),
|
||||||
intval($x[0]['id'])
|
intval($x[0]['id'])
|
||||||
);
|
);
|
||||||
|
if ($uid) {
|
||||||
$r = q("delete from app where app_id = '%s' and app_channel = %d",
|
$r = q("delete from app where app_id = '%s' and app_channel = %d",
|
||||||
dbesc($app['guid']),
|
dbesc($app['guid']),
|
||||||
intval($uid)
|
intval($uid)
|
||||||
@ -542,6 +543,7 @@ class Apps {
|
|||||||
// we don't sync system apps - they may be completely different on the other system
|
// we don't sync system apps - they may be completely different on the other system
|
||||||
build_sync_packet($uid,array('app' => $x));
|
build_sync_packet($uid,array('app' => $x));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
self::app_undestroy($uid,$app);
|
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 = []) {
|
static public function app_list($uid, $deleted = false, $cats = []) {
|
||||||
if($deleted)
|
if($deleted)
|
||||||
$sql_extra = "";
|
$sql_extra = "";
|
||||||
|
@ -115,8 +115,8 @@ class Oauth2 {
|
|||||||
'$name' => array('name', t('Name'), $app['client_id'], t('Name of application')),
|
'$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')),
|
'$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')),
|
'$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')),
|
'$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 sepcifically requires this')),
|
'$scope' => array('scope', t('Authorization scope'), $app['scope'], t('leave blank unless your application specifically requires this')),
|
||||||
));
|
));
|
||||||
return $o;
|
return $o;
|
||||||
}
|
}
|
||||||
|
@ -528,6 +528,18 @@ class Comanche {
|
|||||||
$clsname = ucfirst($name);
|
$clsname = ucfirst($name);
|
||||||
$nsname = "\\Zotlabs\\Widget\\" . $clsname;
|
$nsname = "\\Zotlabs\\Widget\\" . $clsname;
|
||||||
|
|
||||||
|
$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'))
|
if(file_exists('Zotlabs/SiteWidget/' . $clsname . '.php'))
|
||||||
require_once('Zotlabs/SiteWidget/' . $clsname . '.php');
|
require_once('Zotlabs/SiteWidget/' . $clsname . '.php');
|
||||||
elseif(file_exists('widget/' . $clsname . '/' . $clsname . '.php'))
|
elseif(file_exists('widget/' . $clsname . '/' . $clsname . '.php'))
|
||||||
@ -540,6 +552,8 @@ class Comanche {
|
|||||||
require_once($pth);
|
require_once($pth);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if(class_exists($nsname)) {
|
if(class_exists($nsname)) {
|
||||||
$x = new $nsname;
|
$x = new $nsname;
|
||||||
$f = 'widget';
|
$f = 'widget';
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
namespace Zotlabs\Web;
|
namespace Zotlabs\Web;
|
||||||
|
|
||||||
|
use Zotlabs\Extend\Route;
|
||||||
use Exception;
|
use Exception;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -52,6 +53,22 @@ class Router {
|
|||||||
* First see if we have a plugin which is masquerading as a module.
|
* First see if we have a plugin which is masquerading as a module.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
$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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 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")) {
|
if(is_array(\App::$plugins) && in_array($module,\App::$plugins) && file_exists("addon/{$module}/{$module}.php")) {
|
||||||
include_once("addon/{$module}/{$module}.php");
|
include_once("addon/{$module}/{$module}.php");
|
||||||
if(class_exists($modname)) {
|
if(class_exists($modname)) {
|
||||||
@ -62,6 +79,7 @@ class Router {
|
|||||||
\App::$module_loaded = true;
|
\App::$module_loaded = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If the site has a custom module to over-ride the standard module, use it.
|
* If the site has a custom module to over-ride the standard module, use it.
|
||||||
|
@ -44,3 +44,10 @@ for a in "${filelist[@]}" ; do
|
|||||||
echo linking $base
|
echo linking $base
|
||||||
ln -s ../extend/addon/$1/$base $base
|
ln -s ../extend/addon/$1/$base $base
|
||||||
done
|
done
|
||||||
|
|
||||||
|
for x in `ls` ; do
|
||||||
|
if [ -L "$x" ] && ! [ -e "$x" ]; then
|
||||||
|
echo "removing dead symlink $x" ;
|
||||||
|
rm -- "$x";
|
||||||
|
fi;
|
||||||
|
done
|
||||||
|
Reference in New Issue
Block a user