aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xboot.php44
-rw-r--r--doc/hook/event_store_event.bb11
-rw-r--r--doc/hooklist.bb3
-rw-r--r--include/event.php7
4 files changed, 43 insertions, 22 deletions
diff --git a/boot.php b/boot.php
index d034749a2..19d64bd61 100755
--- a/boot.php
+++ b/boot.php
@@ -1583,13 +1583,13 @@ function fix_system_urls($oldurl, $newurl) {
);
if($r) {
- foreach($r as $rr) {
- $channel_address = substr($rr['hubloc_addr'],0,strpos($rr['hubloc_addr'],'@'));
+ foreach($r as $rv) {
+ $channel_address = substr($rv['hubloc_addr'],0,strpos($rv['hubloc_addr'],'@'));
// get the associated channel. If we don't have a local channel, do nothing for this entry.
$c = q("select * from channel where channel_hash = '%s' limit 1",
- dbesc($rr['hubloc_hash'])
+ dbesc($rv['hubloc_hash'])
);
if(! $c)
continue;
@@ -1611,19 +1611,19 @@ function fix_system_urls($oldurl, $newurl) {
// The xchan_url might point to another nomadic identity clone
- $replace_xchan_url = ((strpos($rr['xchan_url'],$oldurl) !== false) ? true : false);
+ $replace_xchan_url = ((strpos($rv['xchan_url'],$oldurl) !== false) ? true : false);
$x = q("update xchan set xchan_addr = '%s', xchan_url = '%s', xchan_connurl = '%s', xchan_follow = '%s', xchan_connpage = '%s', xchan_photo_l = '%s', xchan_photo_m = '%s', xchan_photo_s = '%s', xchan_photo_date = '%s' where xchan_hash = '%s'",
dbesc($channel_address . '@' . $rhs),
- dbesc(($replace_xchan_url) ? str_replace($oldurl,$newurl,$rr['xchan_url']) : $rr['xchan_url']),
- dbesc(str_replace($oldurl,$newurl,$rr['xchan_connurl'])),
- dbesc(str_replace($oldurl,$newurl,$rr['xchan_follow'])),
- dbesc(str_replace($oldurl,$newurl,$rr['xchan_connpage'])),
- dbesc(str_replace($oldurl,$newurl,$rr['xchan_photo_l'])),
- dbesc(str_replace($oldurl,$newurl,$rr['xchan_photo_m'])),
- dbesc(str_replace($oldurl,$newurl,$rr['xchan_photo_s'])),
+ dbesc(($replace_xchan_url) ? str_replace($oldurl,$newurl,$rv['xchan_url']) : $rv['xchan_url']),
+ dbesc(str_replace($oldurl,$newurl,$rv['xchan_connurl'])),
+ dbesc(str_replace($oldurl,$newurl,$rv['xchan_follow'])),
+ dbesc(str_replace($oldurl,$newurl,$rv['xchan_connpage'])),
+ dbesc(str_replace($oldurl,$newurl,$rv['xchan_photo_l'])),
+ dbesc(str_replace($oldurl,$newurl,$rv['xchan_photo_m'])),
+ dbesc(str_replace($oldurl,$newurl,$rv['xchan_photo_s'])),
dbesc(datetime_convert()),
- dbesc($rr['xchan_hash'])
+ dbesc($rv['xchan_hash'])
);
$y = q("update hubloc set hubloc_addr = '%s', hubloc_url = '%s', hubloc_url_sig = '%s', hubloc_host = '%s', hubloc_callback = '%s' where hubloc_hash = '%s' and hubloc_url = '%s'",
@@ -1632,13 +1632,13 @@ function fix_system_urls($oldurl, $newurl) {
dbesc(base64url_encode(rsa_sign($newurl,$c[0]['channel_prvkey']))),
dbesc($newhost),
dbesc($newurl . '/post'),
- dbesc($rr['xchan_hash']),
+ dbesc($rv['xchan_hash']),
dbesc($oldurl)
);
$z = q("update profile set photo = '%s', thumb = '%s' where uid = %d",
- dbesc(str_replace($oldurl,$newurl,$rr['xchan_photo_l'])),
- dbesc(str_replace($oldurl,$newurl,$rr['xchan_photo_m'])),
+ dbesc(str_replace($oldurl,$newurl,$rv['xchan_photo_l'])),
+ dbesc(str_replace($oldurl,$newurl,$rv['xchan_photo_m'])),
intval($c[0]['channel_id'])
);
@@ -1666,12 +1666,12 @@ function fix_system_urls($oldurl, $newurl) {
);
if($r) {
- foreach($r as $rr) {
+ foreach($r as $rv) {
$x = q("update xchan set xchan_photo_l = '%s', xchan_photo_m = '%s', xchan_photo_s = '%s' where xchan_hash = '%s'",
- dbesc(str_replace($oldurl,$newurl,$rr['xchan_photo_l'])),
- dbesc(str_replace($oldurl,$newurl,$rr['xchan_photo_m'])),
- dbesc(str_replace($oldurl,$newurl,$rr['xchan_photo_s'])),
- dbesc($rr['xchan_hash'])
+ dbesc(str_replace($oldurl,$newurl,$rv['xchan_photo_l'])),
+ dbesc(str_replace($oldurl,$newurl,$rv['xchan_photo_m'])),
+ dbesc(str_replace($oldurl,$newurl,$rv['xchan_photo_s'])),
+ dbesc($rv['xchan_hash'])
);
}
}
@@ -2029,8 +2029,8 @@ function load_contact_links($uid) {
intval($uid)
);
if($r) {
- foreach($r as $rr){
- $ret[$rr['xchan_hash']] = $rr;
+ foreach($r as $rv){
+ $ret[$rv['xchan_hash']] = $rv;
}
}
else
diff --git a/doc/hook/event_store_event.bb b/doc/hook/event_store_event.bb
new file mode 100644
index 000000000..7015a8322
--- /dev/null
+++ b/doc/hook/event_store_event.bb
@@ -0,0 +1,11 @@
+[h2]event_store_event[/h2]
+
+Called from event_store_event() when an event record is being stored.
+
+Hook info is an array
+
+'event' => the passed event details, ready for storage
+'existing_event' => If the event already exists, a copy of the original event record from the database
+'cancel' => false - set to true to cancel the operation.
+
+
diff --git a/doc/hooklist.bb b/doc/hooklist.bb
index 66ff1cf71..858a7d021 100644
--- a/doc/hooklist.bb
+++ b/doc/hooklist.bb
@@ -184,6 +184,9 @@ Hooks allow plugins/addons to "hook into" the code at many points and alter the
[zrl=[baseurl]/help/hook/event_created]event_created[/zrl]
called when an event record is created
+[zrl=[baseurl]/help/hook/event_store_event]event_store_event[/zrl]
+ called when an event record is created or updated
+
[zrl=[baseurl]/help/hook/event_updated]event_updated[/zrl]
called when an event record is modified
diff --git a/include/event.php b/include/event.php
index 3d650cd14..407736a23 100644
--- a/include/event.php
+++ b/include/event.php
@@ -343,6 +343,13 @@ function event_store_event($arr) {
}
}
+ $hook_info = [ 'event' => $arr, 'existing_event' => $existing_event, 'cancel' => false ];
+ call_hooks('event_store_event',$hook_info);
+ if($hook_info['cancel'])
+ return false;
+
+ $arr = $hook_info['event'];
+ $existing_event = $hook_info['existing_event'];
if($existing_event) {