Permalink
Browse files

Adds post-operation hooks to splitTopic() and mergeTopic()

Signed-off-by: Jon Stovell <jonstovell@gmail.com>
  • Loading branch information...
1 parent 01aa553 commit 45900ec6a789a6b08b7d98e5314aae98a10169c0 @Sesquipedalian Sesquipedalian committed with live627 Jan 8, 2017
Showing with 39 additions and 0 deletions.
  1. +39 −0 Sources/SplitTopics.php
@@ -788,6 +788,27 @@ function splitTopic($split1_ID_TOPIC, $splitMessages, $new_subject)
if (is_callable(array($searchAPI, 'topicSplit')))
$searchAPI->topicSplit($split2_ID_TOPIC, $splitMessages);
+ // Maybe we want to let an external CMS know about this split
+ $split1 = array(
+ 'num_replies' => $split1_replies,
+ 'id_first_msg' => $split1_first_msg,
+ 'id_last_msg' => $split1_last_msg,
+ 'id_member_started' => $split1_firstMem,
+ 'id_member_updated' => $split1_lastMem,
+ 'unapproved_posts' => $split1_unapprovedposts,
+ 'id_topic' => $split1_ID_TOPIC,
+ );
+ $split2 = array(
+ 'num_replies' => $split2_replies,
+ 'id_first_msg' => $split2_first_msg,
+ 'id_last_msg' => $split2_last_msg,
+ 'id_member_started' => $split2_firstMem,
+ 'id_member_updated' => $split2_lastMem,
+ 'unapproved_posts' => $split2_unapprovedposts,
+ 'id_topic' => $split2_ID_TOPIC,
+ );
+ call_integration_hook('integrate_split_topic', array($split1, $split2, $new_subject, $id_board));
+
// Return the ID of the newly created topic.
return $split2_ID_TOPIC;
}
@@ -1710,6 +1731,24 @@ function MergeExecute($topics = array())
if (is_callable(array($searchAPI, 'topicMerge')))
$searchAPI->topicMerge($id_topic, $topics, $affected_msgs, empty($_POST['enforce_subject']) ? null : array($context['response_prefix'], $target_subject));
+ // Merging is the sort of thing an external CMS might want to know about
+ $merged_topic = array(
+ 'id_board' => $target_board,
+ 'is_sticky' => $is_sticky,
+ 'approved' => $topic_approved,
+ 'id_topic' => $id_topic,
+ 'id_member_started' => $member_started,
+ 'id_member_updated' => $member_updated,
+ 'id_first_msg' => $first_msg,
+ 'id_last_msg' => $last_msg,
+ 'id_poll' => $target_poll,
+ 'num_replies' => $num_replies,
+ 'unapproved_posts' => $num_unapproved,
+ 'num_views' => $num_views,
+ 'subject' => $target_subject,
+ );
+ call_integration_hook('integrate_merge_topic', array($merged_topic, $updated_topics, $deleted_topics, $deleted_polls));
+
// Send them to the all done page.
redirectexit('action=mergetopics;sa=done;to=' . $id_topic . ';targetboard=' . $target_board);
}

0 comments on commit 45900ec

Please sign in to comment.