aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-x.openshift/action_hooks/deploy24
-rw-r--r--Zotlabs/Extend/Hook.php76
-rw-r--r--Zotlabs/Web/Router.php44
-rwxr-xr-xboot.php4
-rwxr-xr-xinclude/plugin.php26
-rw-r--r--install/schema_mysql.sql4
-rw-r--r--install/schema_postgres.sql2
-rw-r--r--install/update.php15
-rw-r--r--version.inc2
9 files changed, 154 insertions, 43 deletions
diff --git a/.openshift/action_hooks/deploy b/.openshift/action_hooks/deploy
index c3bdf575a..bc3050339 100755
--- a/.openshift/action_hooks/deploy
+++ b/.openshift/action_hooks/deploy
@@ -197,22 +197,22 @@ echo "Try to add or update Hubzilla addons"
cd ${OPENSHIFT_REPO_DIR}
util/add_addon_repo https://github.com/redmatrix/hubzilla-addons.git HubzillaAddons
-# Hubzilla themes
-echo "Try to add or update Hubzilla themes"
+# Hubzilla themes - unofficial repo
+echo "Try to add or update Hubzilla themes - unofficial repo"
cd ${OPENSHIFT_REPO_DIR}
-util/add_theme_repo https://github.com/DeadSuperHero/hubzilla-themes.git DeadSuperHeroThemes
+util/add_theme_repo https://github.com/DeadSuperHero/hubzilla-themes.git DeadSuperHeroThemes insecure
-# Hubzilla ownMapp
-echo "Try to add or update Hubzilla ownMapp"
+# Hubzilla ownMapp - unofficial repo
+echo "Try to add or update Hubzilla ownMapp - unofficial repo"
cd ${OPENSHIFT_REPO_DIR}
-util/add_addon_repo https://gitlab.com/zot/ownmapp.git ownMapp
+util/add_addon_repo https://gitlab.com/zot/ownmapp.git ownMapp insecure
-# Hubzilla Chess
-echo "Try to add or update Hubzilla chess "
+# Hubzilla Chess - unofficial repo
+echo "Try to add or update Hubzilla chess - unofficial repo"
cd ${OPENSHIFT_REPO_DIR}
-util/add_addon_repo https://gitlab.com/zot/hubzilla-chess.git Chess
+util/add_addon_repo https://gitlab.com/zot/hubzilla-chess.git Chess insecure
-# Hubzilla Hubsites
-echo "Try to add or update Hubzilla Hubsites"
+# Hubzilla Hubsites - unofficial repo
+echo "Try to add or update Hubzilla Hubsites - unofficial repo"
cd ${OPENSHIFT_REPO_DIR}
-util/add_addon_repo https://gitlab.com/zot/hubsites.git Hubsites
+util/add_addon_repo https://gitlab.com/zot/hubsites.git Hubsites insecure
diff --git a/Zotlabs/Extend/Hook.php b/Zotlabs/Extend/Hook.php
new file mode 100644
index 000000000..836b29db8
--- /dev/null
+++ b/Zotlabs/Extend/Hook.php
@@ -0,0 +1,76 @@
+<?php
+
+namespace Zotlabs\Extend;
+
+
+class Hook {
+
+ static public function register($hook,$file,$function,$version = 1,$priority = 0) {
+ $r = q("SELECT * FROM `hook` WHERE `hook` = '%s' AND `file` = '%s' AND `function` = '%s' and priority = %d and hook_version = %d LIMIT 1",
+ dbesc($hook),
+ dbesc($file),
+ dbesc($function),
+ intval($priority),
+ intval($version)
+ );
+ if($r)
+ return true;
+
+ $r = q("INSERT INTO `hook` (`hook`, `file`, `function`, `priority`, `hook_version`) VALUES ( '%s', '%s', '%s', %d, %d )",
+ dbesc($hook),
+ dbesc($file),
+ dbesc($function),
+ intval($priority),
+ intval($version)
+ );
+
+ return $r;
+ }
+
+ static public function unregister($hook,$file,$function,$version = 1,$priority = 0) {
+ $r = q("DELETE FROM hook WHERE hook = '%s' AND `file` = '%s' AND `function` = '%s' and priority = %d and hook_version = %d",
+ dbesc($hook),
+ dbesc($file),
+ dbesc($function),
+ intval($priority),
+ intval($version)
+ );
+
+ return $r;
+ }
+
+
+ /**
+ * @brief Inserts a hook into a page request.
+ *
+ * Insert a short-lived hook into the running page request.
+ * Hooks are normally persistent so that they can be called
+ * across asynchronous processes such as delivery and poll
+ * processes.
+ *
+ * insert_hook lets you attach a hook callback immediately
+ * which will not persist beyond the life of this page request
+ * or the current process.
+ *
+ * @param string $hook
+ * name of hook to attach callback
+ * @param string $fn
+ * function name of callback handler
+ * @param int $version
+ * hook interface version, 0 uses two callback params, 1 uses one callback param
+ * @param int $priority
+ * currently not implemented in this function, would require the hook array to be resorted
+ */
+
+ static public function insert($hook, $fn, $version = 0, $priority = 0) {
+
+ if(! is_array(App::$hooks))
+ App::$hooks = array();
+
+ if(! array_key_exists($hook, App::$hooks))
+ App::$hooks[$hook] = array();
+
+ App::$hooks[$hook][] = array('', $fn, $priority, $version);
+ }
+
+} \ No newline at end of file
diff --git a/Zotlabs/Web/Router.php b/Zotlabs/Web/Router.php
index 6376f7697..e6733ffdb 100644
--- a/Zotlabs/Web/Router.php
+++ b/Zotlabs/Web/Router.php
@@ -16,7 +16,7 @@ class Router {
*
* App::$argv[0] is our module name. Let's call it 'foo'. We will load the
* Zotlabs/Module/Foo.php (object) or file mod/foo.php (procedural)
- * and use it for handling our URL request.
+ * and use it for handling our URL request to 'https://ourgreatwebsite.something/foo' .
* The module file contains a few functions that we call in various circumstances
* and in the following order:
*
@@ -24,7 +24,7 @@ class Router {
* class Foo extends Zotlabs\Web\Controller {
* function init() { init function }
* function post() { post function }
- * function get() { nomral page function }
+ * function get() { normal page function }
* }
*
* Procedual interface:
@@ -38,6 +38,7 @@ class Router {
*/
$module = \App::$module;
+ $modname = "Zotlabs\\Module\\" . ucfirst($module);
if(strlen($module)) {
@@ -50,8 +51,13 @@ class Router {
if(is_array(\App::$plugins) && in_array($module,\App::$plugins) && file_exists("addon/{$module}/{$module}.php")) {
include_once("addon/{$module}/{$module}.php");
- if(function_exists($module . '_module'))
+ if(class_exists($modname)) {
+ $this->controller = new $modname;
\App::$module_loaded = true;
+ }
+ elseif(function_exists($module . '_module')) {
+ \App::$module_loaded = true;
+ }
}
if((strpos($module,'admin') === 0) && (! is_site_admin())) {
@@ -62,18 +68,27 @@ class Router {
/**
* If the site has a custom module to over-ride the standard module, use it.
- * Otherwise, look for the standard program module in the 'mod' directory
+ * Otherwise, look for the standard program module
*/
if(! (\App::$module_loaded)) {
try {
- $modname = "Zotlabs\\Module\\" . ucfirst($module);
- $filename = 'Zotlabs/Module/'. ucfirst($module). '.php';
+ $filename = 'Zotlabs/SiteModule/'. ucfirst($module). '.php';
if(file_exists($filename)) {
+ // This won't be picked up by the autoloader, so load it explicitly
+ require_once($filename);
$this->controller = new $modname;
\App::$module_loaded = true;
}
- else throw new \Exception('Module not found');
+ else {
+ $filename = 'Zotlabs/Module/'. ucfirst($module). '.php';
+ if(file_exists($filename)) {
+ $this->controller = new $modname;
+ \App::$module_loaded = true;
+ }
+ }
+ if(! \App::$module_loaded)
+ throw new \Exception('Module not found');
}
catch(\Exception $e) {
if(file_exists("mod/site/{$module}.php")) {
@@ -84,22 +99,23 @@ class Router {
include_once("mod/{$module}.php");
\App::$module_loaded = true;
}
- else logger("mod/{$module}.php not found.");
}
}
-
-
+
/**
- * This provides a place for plugins to register module handlers which don't otherwise exist on the system.
+ * This provides a place for plugins to register module handlers which don't otherwise exist
+ * on the system, or to completely over-ride an existing module.
* If the plugin sets 'installed' to true we won't throw a 404 error for the specified module even if
* there is no specific module file or matching plugin name.
* The plugin should catch at least one of the module hooks for this URL.
*/
- $x = array('module' => $module, 'installed' => false);
+ $x = array('module' => $module, 'installed' => \App::$module_loaded, 'controller' => $this->controller);
call_hooks('module_loaded', $x);
- if($x['installed'])
+ if($x['installed']) {
\App::$module_loaded = true;
+ $this->controller = $x['controller'];
+ }
/**
* The URL provided does not resolve to a valid module.
@@ -119,6 +135,8 @@ class Router {
killme();
}
+ logger("Module {$module} not found.", LOGGER_DEBUG, LOG_WARNING);
+
if((x($_SERVER, 'QUERY_STRING')) && ($_SERVER['QUERY_STRING'] === 'q=internal_error.html') && \App::$config['system']['dreamhost_error_hack']) {
logger('index.php: dreamhost_error_hack invoked. Original URI =' . $_SERVER['REQUEST_URI']);
goaway(z_root() . $_SERVER['REQUEST_URI']);
diff --git a/boot.php b/boot.php
index 674e3731e..78a6b7d32 100755
--- a/boot.php
+++ b/boot.php
@@ -47,10 +47,10 @@ require_once('include/account.php');
define ( 'PLATFORM_NAME', 'hubzilla' );
define ( 'RED_VERSION', trim(file_get_contents('version.inc')));
-define ( 'STD_VERSION', '1.4.1' );
+define ( 'STD_VERSION', '1.4.2' );
define ( 'ZOT_REVISION', 1 );
-define ( 'DB_UPDATE_VERSION', 1165 );
+define ( 'DB_UPDATE_VERSION', 1166 );
/**
diff --git a/include/plugin.php b/include/plugin.php
index 7df3e302c..80e3ae20e 100755
--- a/include/plugin.php
+++ b/include/plugin.php
@@ -185,7 +185,7 @@ function register_hook($hook, $file, $function, $priority = 0) {
dbesc($file),
dbesc($function)
);
- if(count($r))
+ if($r)
return true;
$r = q("INSERT INTO `hook` (`hook`, `file`, `function`, `priority`) VALUES ( '%s', '%s', '%s', '%s' )",
@@ -226,9 +226,8 @@ function unregister_hook($hook, $file, $function) {
function load_hooks() {
- $a = get_app();
-// if(! is_array(App::$hooks))
- App::$hooks = array();
+
+ App::$hooks = array();
$r = q("SELECT * FROM hook WHERE true ORDER BY priority DESC");
if($r) {
@@ -236,10 +235,10 @@ function load_hooks() {
if(! array_key_exists($rr['hook'],App::$hooks))
App::$hooks[$rr['hook']] = array();
- App::$hooks[$rr['hook']][] = array($rr['file'],$rr['function']);
+ App::$hooks[$rr['hook']][] = array($rr['file'],$rr['function'],$rr['priority'],$rr['hook_version']);
}
}
-//logger('hooks: ' . print_r(App::$hooks,true));
+ //logger('hooks: ' . print_r(App::$hooks,true));
}
/**
@@ -259,15 +258,15 @@ function load_hooks() {
* @param string $fn
* function name of callback handler
*/
-function insert_hook($hook, $fn) {
- $a = get_app();
+function insert_hook($hook, $fn, $version = 0, $priority = 0) {
+
if(! is_array(App::$hooks))
App::$hooks = array();
if(! array_key_exists($hook, App::$hooks))
App::$hooks[$hook] = array();
- App::$hooks[$hook][] = array('', $fn);
+ App::$hooks[$hook][] = array('', $fn, $priority, $version);
}
/**
@@ -280,8 +279,7 @@ function insert_hook($hook, $fn) {
* @param string|array &$data to transmit to the callback handler
*/
function call_hooks($name, &$data = null) {
- $a = get_app();
-
+ $a = 0;
if((is_array(App::$hooks)) && (array_key_exists($name, App::$hooks))) {
foreach(App::$hooks[$name] as $hook) {
if($hook[0])
@@ -289,9 +287,11 @@ function call_hooks($name, &$data = null) {
if(function_exists($hook[1])) {
$func = $hook[1];
- $func($a, $data);
+ if($hook[3])
+ $func($data);
+ else
+ $func($a, $data);
} else {
-
q("DELETE FROM hook WHERE hook = '%s' AND file = '%s' AND function = '%s'",
dbesc($name),
dbesc($hook[0]),
diff --git a/install/schema_mysql.sql b/install/schema_mysql.sql
index 01cf97674..c36bfaa57 100644
--- a/install/schema_mysql.sql
+++ b/install/schema_mysql.sql
@@ -517,8 +517,10 @@ CREATE TABLE IF NOT EXISTS `hook` (
`file` char(255) NOT NULL DEFAULT '',
`function` char(255) NOT NULL DEFAULT '',
`priority` int(11) unsigned NOT NULL DEFAULT '0',
+ `hook_version` int(11) NOT NULL DEFAULT '0',
PRIMARY KEY (`id`),
- KEY `hook` (`hook`)
+ KEY `hook` (`hook`),
+ KEY `hook_version` (`hook_version`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
CREATE TABLE IF NOT EXISTS `hubloc` (
diff --git a/install/schema_postgres.sql b/install/schema_postgres.sql
index a7cd5875c..d4bb54b1e 100644
--- a/install/schema_postgres.sql
+++ b/install/schema_postgres.sql
@@ -512,10 +512,12 @@ CREATE TABLE "hook" (
"file" text NOT NULL,
"function" text NOT NULL,
"priority" bigint NOT NULL DEFAULT '0',
+ "hook_version" smallint NOT NULL DEFAULT '0',
PRIMARY KEY ("id")
);
create index "hook_idx" on hook ("hook");
+create index "hook_version_idx" on hook ("hook_version");
CREATE TABLE "hubloc" (
"hubloc_id" serial NOT NULL,
"hubloc_guid" text NOT NULL DEFAULT '',
diff --git a/install/update.php b/install/update.php
index bfd01494f..2dc4a6db3 100644
--- a/install/update.php
+++ b/install/update.php
@@ -1,6 +1,6 @@
<?php
-define( 'UPDATE_VERSION' , 1165 );
+define( 'UPDATE_VERSION' , 1166 );
/**
*
@@ -2058,3 +2058,16 @@ function update_r1164() {
return UPDATE_FAILED;
}
+function update_r1165() {
+
+ $r1 = q("alter table hook add hook_version int not null default '0' ");
+
+ if(ACTIVE_DBTYPE == DBTYPE_POSTGRES)
+ $r2 = q("create index \"hook_version_idx\" on hook (\"hook_version\") ");
+ else
+ $r2 = q("alter table hook add index ( hook_version ) ");
+ if($r1 && $r2)
+ return UPDATE_SUCCESS;
+ return UPDATE_FAILED;
+}
+
diff --git a/version.inc b/version.inc
index c414fb0fd..70f35be4a 100644
--- a/version.inc
+++ b/version.inc
@@ -1 +1 @@
-2016-04-20.1372H
+2016-04-21.1373H