aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xboot.php2
-rw-r--r--doc/hook/item_custom.bb24
-rw-r--r--doc/hook/item_stored.bb18
-rw-r--r--doc/hook/item_stored_update.bb15
-rw-r--r--doc/hooklist.bb9
-rwxr-xr-xinclude/items.php30
6 files changed, 98 insertions, 0 deletions
diff --git a/boot.php b/boot.php
index 4087ec006..1d3897114 100755
--- a/boot.php
+++ b/boot.php
@@ -576,6 +576,8 @@ define ( 'ITEM_TYPE_BUG', 4 );
define ( 'ITEM_TYPE_DOC', 5 );
define ( 'ITEM_TYPE_CARD', 6 );
define ( 'ITEM_TYPE_ARTICLE', 7 );
+//OSADA ITEM_TYPE_MAIL = 8
+define ( 'ITEM_TYPE_CUSTOM', 9 );
define ( 'ITEM_IS_STICKY', 1000 );
diff --git a/doc/hook/item_custom.bb b/doc/hook/item_custom.bb
new file mode 100644
index 000000000..d20c7d76c
--- /dev/null
+++ b/doc/hook/item_custom.bb
@@ -0,0 +1,24 @@
+[h2]item_custom[/h2]
+
+Allow addons to create and process custom item types.
+
+Addon authors will need to use iconfig meta data (with sharing on) or some other method
+to specify and determine whether the custom item is destined for their addon.
+
+It is fed an array of ['item' => ${item_array}, 'allow_exec' => {true/false}]
+
+By default $arr['item']['cancel'] is set to TRUE which will abort storage of the
+custom item in the item table unless the addon unsets it or sets it to false.
+
+[code]
+ if ($arr['item_type']==ITEM_TYPE_CUSTOM) {
+ /* Custom items are not stored by default
+ because they require an addon to process. */
+ $d['item']['cancel']=true;
+
+ call_hooks('item_custom',$d);
+ }
+
+[/code]
+
+see: include/items.php
diff --git a/doc/hook/item_stored.bb b/doc/hook/item_stored.bb
new file mode 100644
index 000000000..8d706cb4e
--- /dev/null
+++ b/doc/hook/item_stored.bb
@@ -0,0 +1,18 @@
+[h2]item_stored[/h2]
+
+Allow addons to continue processing after an item has been stored in the event
+that they need access to the item_id or other data that gets assigned during
+the storage process.
+
+It is fed an array of type item (including terms and iconfig data).
+
+[code]
+ /**
+ * @hooks item_stored
+ * Called after new item is stored in the database.
+ * (By this time we have an item_id and other frequently needed info.)
+ */
+ call_hooks('item_stored',$arr);
+[/code]
+
+see: include/items.php
diff --git a/doc/hook/item_stored_update.bb b/doc/hook/item_stored_update.bb
new file mode 100644
index 000000000..4532a347c
--- /dev/null
+++ b/doc/hook/item_stored_update.bb
@@ -0,0 +1,15 @@
+[h2]item_stored_update[/h2]
+
+Allow addons to continue processing after an item update has been stored
+
+It is fed an array of type item (including terms and iconfig data).
+
+[code]
+ /**
+ * @hooks item_stored_update
+ * Called after updated item is stored in the database.
+ */
+ call_hooks('item_stored_update',$arr);
+[/code]
+
+see: include/items.php
diff --git a/doc/hooklist.bb b/doc/hooklist.bb
index 5d12a139e..08fc587e2 100644
--- a/doc/hooklist.bb
+++ b/doc/hooklist.bb
@@ -343,9 +343,18 @@ Hooks allow plugins/addons to "hook into" the code at many points and alter the
[zrl=[baseurl]/help/hook/item_store]item_store[/zrl]
Called when item_store() stores a record of type item
+[zrl=[baseurl]/help/hook/item_stored]item_stored[/zrl]
+ Called after item_store() has stored a record of type item in the database.
+
+[zrl=[baseurl]/help/hook/item_custom]item_custom[/zrl]
+ Called before item_store() stores a record of type item (allowing addons to process ITEM_TYPE_CUSTOM items).
+
[zrl=[baseurl]/help/hook/item_store_update]item_store_update[/zrl]
Called when item_store_update() is called to update a stored item.
+[zrl=[baseurl]/help/hook/item_stored_update]item_stored_update[/zrl]
+ Called after item_store_update() has updated a stored item.
+
[zrl=[baseurl]/help/hook/item_translate]item_translate[/zrl]
Called from item_store and item_store_update after the post language has been autodetected
diff --git a/include/items.php b/include/items.php
index 0cbca23fc..02d31fcb5 100755
--- a/include/items.php
+++ b/include/items.php
@@ -1591,6 +1591,14 @@ function item_store($arr, $allow_exec = false, $deliver = true) {
'item' => $arr,
'allow_exec' => $allow_exec
];
+
+ if ($arr['item_type']==ITEM_TYPE_CUSTOM) {
+ /* Custom items are not stored by default
+ because they require an addon to process. */
+ $d['item']['cancel']=true;
+
+ call_hooks('item_custom',$d);
+ }
/**
* @hooks item_store
* Called when item_store() stores a record of type item.
@@ -2016,6 +2024,13 @@ function item_store($arr, $allow_exec = false, $deliver = true) {
*/
call_hooks('post_remote_end', $arr);
+ /**
+ * @hooks item_stored
+ * Called after new item is stored in the database.
+ * (By this time we have an item_id and other frequently needed info.)
+ */
+ call_hooks('item_stored',$arr);
+
item_update_parent_commented($arr);
// If _creating_ a deleted item, don't propagate it further or send out notifications.
@@ -2049,6 +2064,15 @@ function item_store_update($arr, $allow_exec = false, $deliver = true) {
'item' => $arr,
'allow_exec' => $allow_exec
];
+
+ if ($arr['item_type']==ITEM_TYPE_CUSTOM) {
+ /* Custom items are not stored by default
+ because they require an addon to process. */
+ $d['item']['cancel']=true;
+
+ call_hooks('item_custom_update',$d);
+ }
+
/**
* @hooks item_store_update
* Called when item_store_update() is called to update a stored item. It
@@ -2339,6 +2363,12 @@ function item_store_update($arr, $allow_exec = false, $deliver = true) {
*/
call_hooks('post_remote_update_end', $arr);
+ /**
+ * @hooks item_stored_update
+ * Called after updated item is stored in the database.
+ */
+ call_hooks('item_stored_update',$arr);
+
if($deliver) {
send_status_notifications($orig_post_id,$arr);
tag_deliver($uid,$orig_post_id);