Skip to content

Commit 48e4fc3

Browse files
committed
Merge pull request #4406 from rmcgirr83/ticket/14581
[ticket/14581] Add core events to content_visibility
2 parents 6ba77ee + 413b57e commit 48e4fc3

File tree

1 file changed

+108
-4
lines changed

1 file changed

+108
-4
lines changed

content_visibility.php

Lines changed: 108 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -428,7 +428,35 @@ public function set_post_visibility($visibility, $post_id, $topic_id, $forum_id,
428428
'post_delete_time' => ((int) $time) ?: time(),
429429
'post_delete_reason' => truncate_string($reason, 255, 255, false),
430430
);
431-
431+
/**
432+
* Perform actions right before the query to change post visibility
433+
*
434+
* @event core.set_post_visibility_before_sql
435+
* @var int visibility Element of {ITEM_APPROVED, ITEM_DELETED, ITEM_REAPPROVE}
436+
* @var array post_id Array containing all post IDs to be modified. If blank, all posts within the topic are modified.
437+
* @var int topic_id Topic of the post IDs to be modified.
438+
* @var int forum_id Forum ID that the topic_id resides in.
439+
* @var int user_id User ID doing this action.
440+
* @var int timestamp Timestamp of this action.
441+
* @var string reason Reason specified by the user for this change.
442+
* @var bool is_starter Are we changing the topic's starter?
443+
* @var bool is_latest Are we changing the topic's latest post?
444+
* @var array data The data array for this action.
445+
* @since 3.1.10-RC1
446+
*/
447+
$vars = array(
448+
'visibility',
449+
'post_id',
450+
'topic_id',
451+
'forum_id',
452+
'user_id',
453+
'timestamp',
454+
'reason',
455+
'is_starter',
456+
'is_latest',
457+
'data',
458+
);
459+
extract($this->phpbb_dispatcher->trigger_event('core.set_post_visibility_before_sql', compact($vars)));
432460
$sql = 'UPDATE ' . $this->posts_table . '
433461
SET ' . $this->db->sql_build_array('UPDATE', $data) . '
434462
WHERE ' . $this->db->sql_in_set('post_id', $post_ids);
@@ -585,7 +613,35 @@ public function set_post_visibility($visibility, $post_id, $topic_id, $forum_id,
585613
WHERE topic_id = ' . (int) $topic_id;
586614
$this->db->sql_query($sql);
587615
}
588-
616+
/**
617+
* Perform actions after all steps to changing post visibility
618+
*
619+
* @event core.set_post_visibility_after
620+
* @var int visibility Element of {ITEM_APPROVED, ITEM_DELETED, ITEM_REAPPROVE}
621+
* @var array post_id Array containing all post IDs to be modified. If blank, all posts within the topic are modified.
622+
* @var int topic_id Topic of the post IDs to be modified.
623+
* @var int forum_id Forum ID that the topic_id resides in.
624+
* @var int user_id User ID doing this action.
625+
* @var int timestamp Timestamp of this action.
626+
* @var string reason Reason specified by the user for this change.
627+
* @var bool is_starter Are we changing the topic's starter?
628+
* @var bool is_latest Are we changing the topic's latest post?
629+
* @var array data The data array for this action.
630+
* @since 3.1.10-RC1
631+
*/
632+
$vars = array(
633+
'visibility',
634+
'post_id',
635+
'topic_id',
636+
'forum_id',
637+
'user_id',
638+
'timestamp',
639+
'reason',
640+
'is_starter',
641+
'is_latest',
642+
'data',
643+
);
644+
extract($this->phpbb_dispatcher->trigger_event('core.set_post_visibility_after', compact($vars)));
589645
return $data;
590646
}
591647

@@ -645,7 +701,31 @@ public function set_topic_visibility($visibility, $topic_id, $forum_id, $user_id
645701
'topic_delete_time' => ((int) $time) ?: time(),
646702
'topic_delete_reason' => truncate_string($reason, 255, 255, false),
647703
);
648-
704+
/**
705+
* Perform actions right before the query to change topic visibility
706+
*
707+
* @event core.set_topic_visibility_before_sql
708+
* @var int visibility Element of {ITEM_APPROVED, ITEM_DELETED, ITEM_REAPPROVE}
709+
* @var int topic_id Topic of the post IDs to be modified.
710+
* @var int forum_id Forum ID that the topic_id resides in.
711+
* @var int user_id User ID doing this action.
712+
* @var int timestamp Timestamp of this action.
713+
* @var string reason Reason specified by the user for this change.
714+
* @var bool force_update_all Force an update on all posts within the topic, regardless of their current approval state.
715+
* @var array data The data array for this action.
716+
* @since 3.1.10-RC1
717+
*/
718+
$vars = array(
719+
'visibility',
720+
'topic_id',
721+
'forum_id',
722+
'user_id',
723+
'timestamp',
724+
'reason',
725+
'force_update_all',
726+
'data',
727+
);
728+
extract($this->phpbb_dispatcher->trigger_event('core.set_topic_visibility_before_sql', compact($vars)));
649729
$sql = 'UPDATE ' . $this->topics_table . '
650730
SET ' . $this->db->sql_build_array('UPDATE', $data) . '
651731
WHERE topic_id = ' . (int) $topic_id;
@@ -670,7 +750,31 @@ public function set_topic_visibility($visibility, $topic_id, $forum_id, $user_id
670750
{
671751
$this->set_post_visibility($visibility, false, $topic_id, $forum_id, $user_id, $time, '', true, true);
672752
}
673-
753+
/**
754+
* Perform actions after all steps to changing topic visibility
755+
*
756+
* @event core.set_topic_visibility_after
757+
* @var int visibility Element of {ITEM_APPROVED, ITEM_DELETED, ITEM_REAPPROVE}
758+
* @var int topic_id Topic of the post IDs to be modified.
759+
* @var int forum_id Forum ID that the topic_id resides in.
760+
* @var int user_id User ID doing this action.
761+
* @var int timestamp Timestamp of this action.
762+
* @var string reason Reason specified by the user for this change.
763+
* @var bool force_update_all Force an update on all posts within the topic, regardless of their current approval state.
764+
* @var array data The data array for this action.
765+
* @since 3.1.10-RC1
766+
*/
767+
$vars = array(
768+
'visibility',
769+
'topic_id',
770+
'forum_id',
771+
'user_id',
772+
'timestamp',
773+
'reason',
774+
'force_update_all',
775+
'data',
776+
);
777+
extract($this->phpbb_dispatcher->trigger_event('core.set_topic_visibility_after', compact($vars)));
674778
return $data;
675779
}
676780

0 commit comments

Comments
 (0)