This commit is contained in:
friendica 2012-07-23 16:51:02 -07:00
commit dbdcbaa7ef
4 changed files with 15 additions and 6 deletions

View File

@ -12,7 +12,7 @@ require_once('include/cache.php');
define ( 'FRIENDICA_PLATFORM', 'Friendica'); define ( 'FRIENDICA_PLATFORM', 'Friendica');
define ( 'FRIENDICA_VERSION', '3.0.1413' ); define ( 'FRIENDICA_VERSION', '3.0.1413' );
define ( 'DFRN_PROTOCOL_VERSION', '2.23' ); define ( 'DFRN_PROTOCOL_VERSION', '2.23' );
define ( 'DB_UPDATE_VERSION', 1153 ); define ( 'DB_UPDATE_VERSION', 1154 );
define ( 'EOL', "<br />\r\n" ); define ( 'EOL', "<br />\r\n" );
define ( 'ATOM_TIME', 'Y-m-d\TH:i:s\Z' ); define ( 'ATOM_TIME', 'Y-m-d\TH:i:s\Z' );

View File

@ -456,6 +456,7 @@ CREATE TABLE IF NOT EXISTS `hook` (
`hook` char(255) NOT NULL, `hook` char(255) NOT NULL,
`file` char(255) NOT NULL, `file` char(255) NOT NULL,
`function` char(255) NOT NULL, `function` char(255) NOT NULL,
`priority` int(11) UNSIGNED NOT NULL DEFAULT '0',
PRIMARY KEY (`id`) PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8; ) ENGINE=MyISAM DEFAULT CHARSET=utf8;

View File

@ -111,7 +111,7 @@ function reload_plugins() {
if(! function_exists('register_hook')) { if(! function_exists('register_hook')) {
function register_hook($hook,$file,$function) { function register_hook($hook,$file,$function,$priority=0) {
$r = q("SELECT * FROM `hook` WHERE `hook` = '%s' AND `file` = '%s' AND `function` = '%s' LIMIT 1", $r = q("SELECT * FROM `hook` WHERE `hook` = '%s' AND `file` = '%s' AND `function` = '%s' LIMIT 1",
dbesc($hook), dbesc($hook),
@ -121,10 +121,11 @@ function register_hook($hook,$file,$function) {
if(count($r)) if(count($r))
return true; return true;
$r = q("INSERT INTO `hook` (`hook`, `file`, `function`) VALUES ( '%s', '%s', '%s' ) ", $r = q("INSERT INTO `hook` (`hook`, `file`, `function`, `priority`) VALUES ( '%s', '%s', '%s', '%s' ) ",
dbesc($hook), dbesc($hook),
dbesc($file), dbesc($file),
dbesc($function) dbesc($function),
dbesc($priority)
); );
return $r; return $r;
}} }}
@ -145,7 +146,7 @@ if(! function_exists('load_hooks')) {
function load_hooks() { function load_hooks() {
$a = get_app(); $a = get_app();
$a->hooks = array(); $a->hooks = array();
$r = q("SELECT * FROM `hook` WHERE 1"); $r = q("SELECT * FROM `hook` WHERE 1 ORDER BY `priority` DESC");
if(count($r)) { if(count($r)) {
foreach($r as $rr) { foreach($r as $rr) {
if(! array_key_exists($rr['hook'],$a->hooks)) if(! array_key_exists($rr['hook'],$a->hooks))

View File

@ -1,6 +1,6 @@
<?php <?php
define( 'UPDATE_VERSION' , 1153 ); define( 'UPDATE_VERSION' , 1154 );
/** /**
* *
@ -1337,3 +1337,10 @@ function update_1152() {
return UPDATE_SUCCESS; return UPDATE_SUCCESS;
} }
function update_1153() {
$r = q("ALTER TABLE `hook` ADD `priority` INT(11) UNSIGNED NOT NULL DEFAULT '0'");
if(!$r) return UPDATE_FAILED;
return UPDATE_SUCCESS;
}