/
comments_moderation_inc.php
66 lines (57 loc) · 1.86 KB
/
comments_moderation_inc.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
<?php
/**
* @version $Header$
*
* Copyright (c) 2004-2008 bitweaver Group
* All Rights Reserved.
* Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See http://www.gnu.org/copyleft/lesser.html for details.
*
* @author Will <will@onnyturf.com>
* @version $Revision$
* @package modcomments
*/
/**
* load up moderation
* we need to include its bit_setup_inc incase comments gets loaded first
*/
if ( is_file( BIT_ROOT_PATH.'moderation/bit_setup_inc.php' ) ){
require_once( BIT_ROOT_PATH.'moderation/bit_setup_inc.php' );
}
if( $gBitSystem->isPackageActive('moderation') &&
!defined('modcomments_moderation_callback') ) {
global $gModerationSystem;
require_once(MODERATION_PKG_PATH.'ModerationSystem.php');
// What are our transitions
$commentTransitions = array( "comment_post" =>
array (MODERATION_PENDING =>
array(MODERATION_APPROVED,
MODERATION_REJECTED),
MODERATION_REJECTED => MODERATION_DELETE,
MODERATION_APPROVED => MODERATION_DELETE,
),
);
function modcomments_moderation_callback(&$pModeration) {
global $gBitUser, $gBitSystem;
if ($pModeration['type'] == 'comment_post') {
$comment = new LibertyComment( NULL, $pModeration['content_id'] );
$comment->load();
if ($pModeration['status'] == MODERATION_APPROVED) {
// change its status
$comment->storeStatus( 50 );
// delete the ticket
$pModeration['status'] = MODERATION_DELETE;
}else if($pModeration['status'] == MODERATION_REJECTED) {
// change its status to soft delete
$comment->storeStatus( -999 );
// delete the ticket
$pModeration['status'] = MODERATION_DELETE;
}
}
return TRUE;
}
// Register our moderation transitions
$gModerationSystem->registerModerationListener('liberty',
'modcomments_moderation_callback',
$commentTransitions);
}
?>