diff options
author | Friendika <info@friendika.com> | 2010-12-20 19:38:34 -0800 |
---|---|---|
committer | Friendika <info@friendika.com> | 2010-12-20 19:38:34 -0800 |
commit | ddec422de6707809aceb541e1191073b43aec18a (patch) | |
tree | da79ea09482cf8984c7d9e02076dd2e4f0e8e65e /boot.php | |
parent | 1a9f8eacc4bc2b7a67894018b63fc7b0864d760a (diff) | |
download | volse-hubzilla-ddec422de6707809aceb541e1191073b43aec18a.tar.gz volse-hubzilla-ddec422de6707809aceb541e1191073b43aec18a.tar.bz2 volse-hubzilla-ddec422de6707809aceb541e1191073b43aec18a.zip |
begin plugin api
Diffstat (limited to 'boot.php')
-rw-r--r-- | boot.php | 60 |
1 files changed, 58 insertions, 2 deletions
@@ -2,7 +2,7 @@ set_time_limit(0); -define ( 'BUILD_ID', 1026 ); +define ( 'BUILD_ID', 1027 ); define ( 'DFRN_PROTOCOL_VERSION', '2.0' ); define ( 'EOL', "<br />\r\n" ); @@ -174,8 +174,10 @@ class App { public $pager; public $strings; public $path; + public $hooks; public $interactive = true; + private $scheme; private $hostname; private $baseurl; @@ -1945,4 +1947,58 @@ function profile_sidebar($profile) { )); return $o; -}}
\ No newline at end of file +}} + + +if(! function_exists('register_hook')) { +function register_hook($hook,$file,$function) { + + $r = q("INSERT INTO `hook` (`hook`, `file`, `function`) VALUES ( '%s', '%s', '%s' ) ", + dbesc($hook), + dbesc($file), + dbesc($function) + ); + return $r; +}} + +if(! function_exists('unregister_hook')) { +function unregister_hook($hook,$file,$function) { + + $r = q("DELETE FROM `hook` WHERE `hook` = '%s' AND `file` = '%s' AND `function` = '%s' LIMIT 1", + dbesc($hook), + dbesc($file), + dbesc($function) + ); + return $r; +}} + + +if(! function_exists('load_hooks')) { +function load_hooks() { + $a = get_app(); + $r = q("SELECT * FROM `hook` WHERE 1"); + if(count($r)) { + foreach($r as $rr) { + $a->hooks[] = array($rr['hook'], $rr['file'], $rr['function']); + } + } +}} + + +if(! function_exists('call_hooks')) { +function call_hooks($name, $data = null) { + $a = get_app(); + + if(count($a->hooks)) { + foreach($a->hooks as $hook) { + if($hook[0] === $name) { + @require_once($hook[1]); + if(function_exists($hook[2])) { + $func = $hook[2]; + $func($a,$data); + } + } + } + } +}} + |