'Report',
'bbrp_option_label' => 'Report as:',
'bbrp_textarea_msg' => 'Reason for reporting (optional):',
'bbrp_options' => '
Invalid content
Abusive words
Irrelevent to topic',
'bbrp_success_msg' => 'The post has been reported. Thank you.',
'bbrp_error_msg' => 'There was an error reporting this post. Please try again later.',
'bbrp_already_reported_msg' => 'You have already reported this post'
);
$report_options = array(
'bbrp_link_text' => (trim( bb_get_option('bbrp_link_text') ) ) ? trim( bb_get_option('bbrp_link_text') ) : $defaultOptions['bbrp_link_text'],
'bbrp_option_label' => (trim( bb_get_option('bbrp_option_label') ) ) ? trim( bb_get_option('bbrp_option_label') ) : $defaultOptions['bbrp_option_label'],
'bbrp_textarea_msg' => (trim( bb_get_option('bbrp_textarea_msg') ) ) ? trim( bb_get_option('bbrp_textarea_msg') ) : $defaultOptions['bbrp_textarea_msg'],
'bbrp_options' => (trim( bb_get_option('bbrp_options') ) ) ? trim( bb_get_option('bbrp_options') ) : $defaultOptions['bbrp_options'],
'bbrp_success_msg' => (trim( bb_get_option('bbrp_success_msg') ) ) ? trim( bb_get_option('bbrp_success_msg') ) : $defaultOptions['bbrp_success_msg'],
'bbrp_error_msg' => (trim( bb_get_option('bbrp_error_msg') ) ) ? trim( bb_get_option('bbrp_error_msg') ) : $defaultOptions['bbrp_error_msg'],
'bbrp_already_reported_msg' => (trim( bb_get_option('bbrp_already_reported_msg') ) ) ? trim( bb_get_option('bbrp_already_reported_msg') ) : $defaultOptions['bbrp_already_reported_msg'],
);
}
function bbrp_report_link() {
if ( !bb_is_topic() )
return false;
global $page, $topic, $bb_post, $report_options;
if ( !$topic || !topic_is_open( $bb_post->topic_id ) || !bb_is_user_logged_in() || !bb_current_user_can('participate') )
return false;
$post_id = get_post_id();
$post_author_id=get_post_author_id($post_id); // to do, exclude all admin/moderators
if ($post_author_id != bb_get_current_user_info( 'id' ) && $post_author_id!="1") {
echo ' '.$report_options['bbrp_link_text'].' ';
}
return apply_filters( 'bbrp_report_link', $link );
}
add_filter('bb_post_admin', 'bbrp_report_post_link');
function bbrp_report_post_link($post_links) {
if ( $link = bbrp_report_link() )
$post_links[] = $link;
return $post_links;
}
function bbrp_trim_sentence($str, $numChars = 0, $force = 0, $from = 0) {
mb_internal_encoding ( "UTF-8" );
$strLength = mb_strlen ( $str );
if ((mb_strlen ( $str ) <= $numChars) && ! $force) {
return $str;
}
if ($numChars == 0) {
$numChars = mb_strlen ( $str );
}
$str = mb_substr ( $str, $from, $numChars );
$pos = mb_strrpos ( $str, ' ' );
if (! empty ( $pos )) {
$str = mb_substr ( $str, 0, $pos );
}
if ($strLength > $numChars) {
$str .= '...';
}
return $str;
}
function bbrp_addBreakStringSlashes($string){
$string = str_replace(array("\\r\\n", "\\r", "\\n"), '
', $string);
return stripslashes($string);
}
/// Prints JS header.
add_action('bb_init', 'bbrp_report_print_js');
add_action('bb_head', 'bbrp_report_header_js', 100);
function bbrp_report_print_js() {
bb_enqueue_script('jquery');
}
function bbrp_report_header_js() {
global $report_options;
if ( bb_is_topic() && bb_current_user_can('participate') && !bb_is_topic_edit() ) {
$action_url = bb_nonce_url( BB_PLUGIN_URL . 'ajax-report-post/report.ajax.php');
$options = split("\r\n", addslashes($report_options['bbrp_options']));
$optionsHtml = '';
if (!empty($options)) {
$optionsHtml .= '