aboutsummaryrefslogtreecommitdiffstats
path: root/boot.php
diff options
context:
space:
mode:
authorroot <root@diekershoff.homeunix.net>2010-12-23 07:39:23 +0100
committerroot <root@diekershoff.homeunix.net>2010-12-23 07:39:23 +0100
commita1d593613d737d6f1a694adaddf515187580105c (patch)
tree1bf8cc90900dcf52f66b7c09a453acb5133a9b6a /boot.php
parent780ab072f55bd18575ca821eb6ea481cc0728814 (diff)
parentd8969bb84b7a710bf77f23de0d392a192dfc8f53 (diff)
downloadvolse-hubzilla-a1d593613d737d6f1a694adaddf515187580105c.tar.gz
volse-hubzilla-a1d593613d737d6f1a694adaddf515187580105c.tar.bz2
volse-hubzilla-a1d593613d737d6f1a694adaddf515187580105c.zip
Merge branch 'master' of git://github.com/friendika/friendika
Diffstat (limited to 'boot.php')
-rw-r--r--boot.php105
1 files changed, 99 insertions, 6 deletions
diff --git a/boot.php b/boot.php
index 9cc4d0f34..3a6886fd1 100644
--- a/boot.php
+++ b/boot.php
@@ -2,7 +2,7 @@
set_time_limit(0);
-define ( 'BUILD_ID', 1027 );
+define ( 'BUILD_ID', 1028 );
define ( 'DFRN_PROTOCOL_VERSION', '2.0' );
define ( 'EOL', "<br />\r\n" );
@@ -35,6 +35,13 @@ define ( 'REL_VIP', 1);
define ( 'REL_FAN', 2);
define ( 'REL_BUD', 3);
+/**
+ * Hook array order
+ */
+
+define ( 'HOOK_HOOK', 0);
+define ( 'HOOK_FILE', 1);
+define ( 'HOOK_FUNCTION', 2);
/**
*
@@ -372,7 +379,8 @@ function system_unavailable() {
// Primarily involved with database upgrade, but also sets the
// base url for use in cmdline programs which don't have
-// $_SERVER variables.
+// $_SERVER variables, and synchronising the state of installed plugins.
+
if(! function_exists('check_config')) {
function check_config(&$a) {
@@ -404,6 +412,70 @@ function check_config(&$a) {
set_config('system','build', BUILD_ID);
}
}
+
+ /**
+ *
+ * Synchronise plugins:
+ *
+ * $a->config['system']['addon'] contains a comma-separated list of names
+ * of plugins/addons which are used on this system.
+ * Go through the database list of already installed addons, and if we have
+ * an entry, but it isn't in the config list, call the uninstall procedure
+ * and mark it uninstalled in the database (for now we'll remove it).
+ * Then go through the config list and if we have a plugin that isn't installed,
+ * call the install procedure and add it to the database.
+ *
+ */
+
+ $r = q("SELECT * FROM `addon` WHERE `installed` = 1");
+ if(count($r))
+ $installed = $r;
+ else
+ $installed = array();
+
+ $plugins = get_config('system','addon');
+ $plugins_arr = array();
+
+ if($plugins)
+ $plugins_arr = explode(',',str_replace(' ', '',$plugins));
+
+ $installed_arr = array();
+
+ if(count($installed)) {
+ foreach($installed as $i) {
+ if(! in_array($i['name'],$plugins_arr)) {
+ logger("Addons: uninstalling " . $i['name']);
+ q("DELETE FROM `addon` WHERE `id` = %d LIMIT 1",
+ intval($i['id'])
+ );
+
+ @include_once('addon/' . $i['name'] . '/' . $i['name'] . '.php');
+ if(function_exists($i['name'] . '_uninstall')) {
+ $func = $i['name'] . '_uninstall';
+ $func();
+ }
+ }
+ else
+ $installed_arr[] = $i['name'];
+ }
+ }
+
+ if(count($plugins_arr)) {
+ foreach($plugins_arr as $p) {
+ if(! in_array($p,$installed_arr)) {
+ logger("Addons: installing " . $p);
+ @include_once('addon/' . $p . '/' . $p . '.php');
+ if(function_exists($p . '_install')) {
+ $func = $p . '_install';
+ $func();
+ $r = q("INSERT INTO `addon` (`name`, `installed`) VALUES ( '%s', 1 ) ",
+ dbesc($p)
+ );
+ }
+ }
+ }
+ }
+
return;
}}
@@ -1046,6 +1118,23 @@ function set_config($family,$key,$value) {
}}
+if(! function_exists('load_pconfig')) {
+function load_pconfig($uid,$family) {
+ global $a;
+ $r = q("SELECT * FROM `pconfig` WHERE `cat` = '%s' AND `uid` = %d",
+ dbesc($family),
+ intval($uid)
+ );
+ if(count($r)) {
+ foreach($r as $rr) {
+ $k = $rr['k'];
+ $a->config[$uid][$family][$k] = $rr['v'];
+ }
+ }
+}}
+
+
+
if(! function_exists('get_pconfig')) {
function get_pconfig($uid,$family, $key, $instore = false) {
@@ -1687,6 +1776,8 @@ function contact_block() {
$o .= '<div id="viewcontacts"><a id="viewcontacts-link" href="viewcontacts/' . $a->profile['nickname'] . '">' . t('View Contacts') . '</a></div>';
}
+
+ call_hooks('contact_block_end', $o);
return $o;
}}
@@ -1946,6 +2037,8 @@ function profile_sidebar($profile) {
'$homepage' => $homepage
));
+ call_hooks('profile_sidebar', $o);
+
return $o;
}}
@@ -1991,10 +2084,10 @@ function call_hooks($name, $data = null) {
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];
+ if($hook[HOOK_HOOK] === $name) {
+ @include_once($hook[HOOK_FILE]);
+ if(function_exists($hook[HOOK_FUNCTION])) {
+ $func = $hook[HOOK_FUNCTION];
$func($a,$data);
}
}