@@ -2691,16 +2691,54 @@ function phpbb_upload_popup($forum_style = 0)
26912691
26922692/**
26932693* Do the various checks required for removing posts as well as removing it
2694+ *
2695+ * @param int $forum_id The id of the forum
2696+ * @param int $topic_id The id of the topic
2697+ * @param int $post_id The id of the post
2698+ * @param array $post_data Array with the post data
2699+ * @param bool $is_soft The flag indicating whether it is the soft delete mode
2700+ * @param string $delete_reason Description for the post deletion reason
2701+ *
2702+ * @return null
26942703*/
26952704function phpbb_handle_post_delete ($ forum_id , $ topic_id , $ post_id , &$ post_data , $ is_soft = false , $ delete_reason = '' )
26962705{
26972706 global $ user , $ auth , $ config , $ request ;
2698- global $ phpbb_root_path , $ phpEx ;
2707+ global $ phpbb_root_path , $ phpEx, $ phpbb_dispatcher ;
26992708
2709+ $ force_delete_allowed = $ force_softdelete_allowed = false ;
27002710 $ perm_check = ($ is_soft ) ? 'softdelete ' : 'delete ' ;
27012711
2712+ /**
2713+ * This event allows to modify the conditions for the post deletion
2714+ *
2715+ * @event core.handle_post_delete_conditions
2716+ * @var int forum_id The id of the forum
2717+ * @var int topic_id The id of the topic
2718+ * @var int post_id The id of the post
2719+ * @var array post_data Array with the post data
2720+ * @var bool is_soft The flag indicating whether it is the soft delete mode
2721+ * @var string delete_reason Description for the post deletion reason
2722+ * @var bool force_delete_allowed Allow the user to delete the post (all permissions and conditions are ignored)
2723+ * @var bool force_softdelete_allowed Allow the user to softdelete the post (all permissions and conditions are ignored)
2724+ * @var string perm_check The deletion mode softdelete|delete
2725+ * @since 3.1.11-RC1
2726+ */
2727+ $ vars = array (
2728+ 'forum_id ' ,
2729+ 'topic_id ' ,
2730+ 'post_id ' ,
2731+ 'post_data ' ,
2732+ 'is_soft ' ,
2733+ 'delete_reason ' ,
2734+ 'force_delete_allowed ' ,
2735+ 'force_softdelete_allowed ' ,
2736+ 'perm_check ' ,
2737+ );
2738+ extract ($ phpbb_dispatcher ->trigger_event ('core.handle_post_delete_conditions ' , compact ($ vars )));
2739+
27022740 // If moderator removing post or user itself removing post, present a confirmation screen
2703- if ($ auth ->acl_get ("m_ $ perm_check " , $ forum_id ) || ($ post_data ['poster_id ' ] == $ user ->data ['user_id ' ] && $ user ->data ['is_registered ' ] && $ auth ->acl_get ("f_ $ perm_check " , $ forum_id ) && $ post_id == $ post_data ['topic_last_post_id ' ] && !$ post_data ['post_edit_locked ' ] && ($ post_data ['post_time ' ] > time () - ($ config ['delete_time ' ] * 60 ) || !$ config ['delete_time ' ])))
2741+ if ($ force_delete_allowed || ( $ is_soft && $ force_softdelete_allowed ) || $ auth ->acl_get ("m_ $ perm_check " , $ forum_id ) || ($ post_data ['poster_id ' ] == $ user ->data ['user_id ' ] && $ user ->data ['is_registered ' ] && $ auth ->acl_get ("f_ $ perm_check " , $ forum_id ) && $ post_id == $ post_data ['topic_last_post_id ' ] && !$ post_data ['post_edit_locked ' ] && ($ post_data ['post_time ' ] > time () - ($ config ['delete_time ' ] * 60 ) || !$ config ['delete_time ' ])))
27042742 {
27052743 $ s_hidden_fields = array (
27062744 'p ' => $ post_id ,
@@ -2757,10 +2795,10 @@ function phpbb_handle_post_delete($forum_id, $topic_id, $post_id, &$post_data, $
27572795 }
27582796 else
27592797 {
2760- global $ user , $ template, $ request ;
2798+ global $ template ;
27612799
2762- $ can_delete = $ auth ->acl_get ('m_delete ' , $ forum_id ) || ($ post_data ['poster_id ' ] == $ user ->data ['user_id ' ] && $ user ->data ['is_registered ' ] && $ auth ->acl_get ('f_delete ' , $ forum_id ));
2763- $ can_softdelete = $ auth ->acl_get ('m_softdelete ' , $ forum_id ) || ($ post_data ['poster_id ' ] == $ user ->data ['user_id ' ] && $ user ->data ['is_registered ' ] && $ auth ->acl_get ('f_softdelete ' , $ forum_id ));
2800+ $ can_delete = $ force_delete_allowed || ( $ auth ->acl_get ('m_delete ' , $ forum_id ) || ($ post_data ['poster_id ' ] == $ user ->data ['user_id ' ] && $ user ->data ['is_registered ' ] && $ auth ->acl_get ('f_delete ' , $ forum_id) ));
2801+ $ can_softdelete = $ force_softdelete_allowed || ( $ auth ->acl_get ('m_softdelete ' , $ forum_id ) || ($ post_data ['poster_id ' ] == $ user ->data ['user_id ' ] && $ user ->data ['is_registered ' ] && $ auth ->acl_get ('f_softdelete ' , $ forum_id) ));
27642802
27652803 $ template ->assign_vars (array (
27662804 'S_SOFTDELETED ' => $ post_data ['post_visibility ' ] == ITEM_DELETED ,
0 commit comments