function bp_media_conditional_override_allowed_tags($content, $activity = null)
{
    if ($activity != null && $activity->type == 'media_upload') {
        add_filter('bp_activity_allowed_tags', 'bp_media_override_allowed_tags', 1);
    }
    return bp_activity_filter_kses($content);
}
function bp_media_conditional_override_allowed_tags($content, $activity = null)
{
    global $bp_media_activity_types;
    if ($activity != null && in_array($activity->type, $bp_media_activity_types)) {
        add_filter('bp_activity_allowed_tags', 'bp_media_override_allowed_tags', 1);
    }
    return bp_activity_filter_kses($content);
}
Esempio n. 3
0
 function create_activity_html()
 {
     $html = '';
     $html .= '<div class="rtmedia-activity-container">';
     if (!empty($this->activity_text)) {
         $html .= '<div class="rtmedia-activity-text">';
         $html .= $this->activity_text;
         $html .= '</div>';
     }
     global $rtmedia;
     if (isset($rtmedia->options['buddypress_limitOnActivity'])) {
         $limitActivityFeed = $rtmedia->options['buddypress_limitOnActivity'];
     } else {
         $limitActivityFeed = 0;
     }
     $mediaObj = new RTMediaModel();
     $media_details = $mediaObj->get(array('id' => $this->media));
     if (intval($limitActivityFeed) > 0) {
         $media_details = array_slice($media_details, 0, $limitActivityFeed, true);
     }
     $rtmedia_activity_ul_class = apply_filters('rtmedia_activity_ul_class', 'rtm-activity-media-list');
     $li_content = '';
     $count = 0;
     foreach ($media_details as $media) {
         $li_content .= '<li class="rtmedia-list-item media-type-' . $media->media_type . '">';
         if ('photo' == $media->media_type) {
             $li_content .= '<a href ="' . get_rtmedia_permalink($media->id) . '">';
         }
         $li_content .= '<div class="rtmedia-item-thumbnail">';
         $li_content .= $this->media($media);
         $li_content .= '</div>';
         $li_content .= '<div class="rtmedia-item-title">';
         $li_content .= '<h4 title="' . $media->media_title . '">';
         if ('photo' != $media->media_type) {
             $li_content .= '<a href="' . get_rtmedia_permalink($media->id) . '">';
         }
         $li_content .= $media->media_title;
         if ('photo' != $media->media_type) {
             $li_content .= '</a>';
         }
         $li_content .= '</h4>';
         $li_content .= '</div>';
         if ('photo' == $media->media_type) {
             $li_content .= '</a>';
         }
         $li_content .= '</li>';
         $count++;
     }
     $html .= '<ul class="rtmedia-list ' . $rtmedia_activity_ul_class . ' rtmedia-activity-media-length-' . $count . '">';
     $html .= $li_content;
     $html .= '</ul>';
     $html .= '</div>';
     return bp_activity_filter_kses($html);
 }
/**
 * Send email and BP notifications when an activity item receives a comment.
 *
 * @since 1.2.0
 *
 * @uses bp_get_user_meta()
 * @uses bp_core_get_user_displayname()
 * @uses bp_activity_get_permalink()
 * @uses bp_core_get_user_domain()
 * @uses bp_get_settings_slug()
 * @uses bp_activity_filter_kses()
 * @uses bp_core_get_core_userdata()
 * @uses wp_specialchars_decode()
 * @uses get_blog_option()
 * @uses bp_get_root_blog_id()
 * @uses apply_filters() To call the 'bp_activity_new_comment_notification_to' hook.
 * @uses apply_filters() To call the 'bp_activity_new_comment_notification_subject' hook.
 * @uses apply_filters() To call the 'bp_activity_new_comment_notification_message' hook.
 * @uses wp_mail()
 * @uses do_action() To call the 'bp_activity_sent_reply_to_update_email' hook.
 * @uses apply_filters() To call the 'bp_activity_new_comment_notification_comment_author_to' hook.
 * @uses apply_filters() To call the 'bp_activity_new_comment_notification_comment_author_subject' hook.
 * @uses apply_filters() To call the 'bp_activity_new_comment_notification_comment_author_message' hook.
 * @uses do_action() To call the 'bp_activity_sent_reply_to_reply_email' hook.
 *
 * @param int   $comment_id   The comment id.
 * @param int   $commenter_id The ID of the user who posted the comment.
 * @param array $params       {@link bp_activity_new_comment()}.
 * @return bool
 */
function bp_activity_new_comment_notification($comment_id = 0, $commenter_id = 0, $params = array())
{
    // Set some default parameters.
    $activity_id = 0;
    $parent_id = 0;
    extract($params);
    $original_activity = new BP_Activity_Activity($activity_id);
    if ($original_activity->user_id != $commenter_id && 'no' != bp_get_user_meta($original_activity->user_id, 'notification_activity_new_reply', true)) {
        $poster_name = bp_core_get_user_displayname($commenter_id);
        $thread_link = bp_activity_get_permalink($activity_id);
        $settings_slug = function_exists('bp_get_settings_slug') ? bp_get_settings_slug() : 'settings';
        $settings_link = bp_core_get_user_domain($original_activity->user_id) . $settings_slug . '/notifications/';
        $poster_name = stripslashes($poster_name);
        $content = bp_activity_filter_kses(stripslashes($content));
        // Set up and send the message.
        $ud = bp_core_get_core_userdata($original_activity->user_id);
        $to = $ud->user_email;
        $subject = bp_get_email_subject(array('text' => sprintf(__('%s replied to one of your updates', 'buddypress'), $poster_name)));
        $message = sprintf(__('%1$s replied to one of your updates:

"%2$s"

To view your original update and all comments, log in and visit: %3$s

---------------------
', 'buddypress'), $poster_name, $content, $thread_link);
        // Only show the disable notifications line if the settings component is enabled.
        if (bp_is_active('settings')) {
            $message .= sprintf(__('To disable these notifications please log in and go to: %s', 'buddypress'), $settings_link);
        }
        /**
         * Filters the user email that the new comment notification will be sent to.
         *
         * @since 1.2.0
         *
         * @param string $to User email the notification is being sent to.
         */
        $to = apply_filters('bp_activity_new_comment_notification_to', $to);
        /**
         * Filters the new comment notification subject that will be sent to user.
         *
         * @since 1.2.0
         *
         * @param string $subject     Email notification subject text.
         * @param string $poster_name Name of the person who made the comment.
         */
        $subject = apply_filters('bp_activity_new_comment_notification_subject', $subject, $poster_name);
        /**
         * Filters the new comment notification message that will be sent to user.
         *
         * @since 1.2.0
         *
         * @param string $message       Email notification message text.
         * @param string $poster_name   Name of the person who made the comment.
         * @param string $content       Content of the comment.
         * @param string $thread_link   URL permalink for the activity thread.
         * @param string $settings_link URL permalink for the user's notification settings area.
         */
        $message = apply_filters('bp_activity_new_comment_notification_message', $message, $poster_name, $content, $thread_link, $settings_link);
        wp_mail($to, $subject, $message);
        /**
         * Fires after the sending of a reply to an update email notification.
         *
         * @since 1.5.0
         *
         * @param int    $user_id      ID of the original activity item author.
         * @param string $subject      Email notification subject text.
         * @param string $message      Email notification message text.
         * @param int    $comment_id   ID for the newly received comment.
         * @param int    $commenter_id ID of the user who made the comment.
         * @param array  $params       Arguments used with the original activity comment.
         */
        do_action('bp_activity_sent_reply_to_update_email', $original_activity->user_id, $subject, $message, $comment_id, $commenter_id, $params);
    }
    /*
     * If this is a reply to another comment, send an email notification to the
     * author of the immediate parent comment.
     */
    if (empty($parent_id) || $activity_id == $parent_id) {
        return false;
    }
    $parent_comment = new BP_Activity_Activity($parent_id);
    if ($parent_comment->user_id != $commenter_id && $original_activity->user_id != $parent_comment->user_id && 'no' != bp_get_user_meta($parent_comment->user_id, 'notification_activity_new_reply', true)) {
        $poster_name = bp_core_get_user_displayname($commenter_id);
        $thread_link = bp_activity_get_permalink($activity_id);
        $settings_slug = function_exists('bp_get_settings_slug') ? bp_get_settings_slug() : 'settings';
        $settings_link = bp_core_get_user_domain($parent_comment->user_id) . $settings_slug . '/notifications/';
        // Set up and send the message.
        $ud = bp_core_get_core_userdata($parent_comment->user_id);
        $to = $ud->user_email;
        $subject = bp_get_email_subject(array('text' => sprintf(__('%s replied to one of your comments', 'buddypress'), $poster_name)));
        $poster_name = stripslashes($poster_name);
        $content = bp_activity_filter_kses(stripslashes($content));
        $message = sprintf(__('%1$s replied to one of your comments:

"%2$s"

To view the original activity, your comment and all replies, log in and visit: %3$s

---------------------
', 'buddypress'), $poster_name, $content, $thread_link);
        // Only show the disable notifications line if the settings component is enabled.
        if (bp_is_active('settings')) {
            $message .= sprintf(__('To disable these notifications please log in and go to: %s', 'buddypress'), $settings_link);
        }
        /**
         * Filters the user email that the new comment reply notification will be sent to.
         *
         * @since 1.2.0
         *
         * @param string $to User email the notification is being sent to.
         */
        $to = apply_filters('bp_activity_new_comment_notification_comment_author_to', $to);
        /**
         * Filters the new comment reply notification subject that will be sent to user.
         *
         * @since 1.2.0
         *
         * @param string $subject     Email notification subject text.
         * @param string $poster_name Name of the person who made the comment reply.
         */
        $subject = apply_filters('bp_activity_new_comment_notification_comment_author_subject', $subject, $poster_name);
        /**
         * Filters the new comment reply notification message that will be sent to user.
         *
         * @since 1.2.0
         *
         * @param string $message       Email notification message text.
         * @param string $poster_name   Name of the person who made the comment reply.
         * @param string $content       Content of the comment reply.
         * @param string $settings_link URL permalink for the user's notification settings area.
         * @param string $thread_link   URL permalink for the activity thread.
         */
        $message = apply_filters('bp_activity_new_comment_notification_comment_author_message', $message, $poster_name, $content, $settings_link, $thread_link);
        wp_mail($to, $subject, $message);
        /**
         * Fires after the sending of a reply to a reply email notification.
         *
         * @since 1.5.0
         *
         * @param int    $user_id      ID of the parent activity item author.
         * @param string $subject      Email notification subject text.
         * @param string $message      Email notification message text.
         * @param int    $comment_id   ID for the newly received comment.
         * @param int    $commenter_id ID of the user who made the comment.
         * @param array  $params       Arguments used with the original activity comment.
         */
        do_action('bp_activity_sent_reply_to_reply_email', $parent_comment->user_id, $subject, $message, $comment_id, $commenter_id, $params);
    }
}
/**
 * Sends an email notification and a BP notification when someone mentions you in an update
 *
 * @since 1.2.0
 *
 * @param int $comment_id The comment id
 * @param int $commenter_id The unique user_id of the user who posted the comment
 * @param array $params {@link bp_activity_new_comment()}
 *
 * @global object $bp BuddyPress global settings
 * @uses bp_get_user_meta()
 * @uses bp_core_get_user_displayname()
 * @uses bp_activity_get_permalink()
 * @uses bp_core_get_user_domain()
 * @uses bp_get_settings_slug()
 * @uses bp_activity_filter_kses()
 * @uses bp_core_get_core_userdata()
 * @uses nxt_specialchars_decode()
 * @uses get_blog_option()
 * @uses bp_get_root_blog_id()
 * @uses apply_filters() To call the 'bp_activity_new_comment_notification_to' hook
 * @uses apply_filters() To call the 'bp_activity_new_comment_notification_subject' hook
 * @uses apply_filters() To call the 'bp_activity_new_comment_notification_message' hook
 * @uses nxt_mail()
 * @uses do_action() To call the 'bp_activity_sent_reply_to_update_email' hook
 * @uses apply_filters() To call the 'bp_activity_new_comment_notification_comment_author_to' hook
 * @uses apply_filters() To call the 'bp_activity_new_comment_notification_comment_author_subject' hook
 * @uses apply_filters() To call the 'bp_activity_new_comment_notification_comment_author_message' hook
 * @uses do_action() To call the 'bp_activity_sent_reply_to_reply_email' hook
 */
function bp_activity_new_comment_notification($comment_id, $commenter_id, $params)
{
    global $bp;
    extract($params);
    $original_activity = new BP_Activity_Activity($activity_id);
    if ($original_activity->user_id != $commenter_id && 'no' != bp_get_user_meta($original_activity->user_id, 'notification_activity_new_reply', true)) {
        $poster_name = bp_core_get_user_displayname($commenter_id);
        $thread_link = bp_activity_get_permalink($activity_id);
        $settings_slug = function_exists('bp_get_settings_slug') ? bp_get_settings_slug() : 'settings';
        $settings_link = bp_core_get_user_domain($original_activity->user_id) . $settings_slug . '/notifications/';
        $poster_name = stripslashes($poster_name);
        $content = bp_activity_filter_kses(stripslashes($content));
        // Set up and send the message
        $ud = bp_core_get_core_userdata($original_activity->user_id);
        $to = $ud->user_email;
        $sitename = nxt_specialchars_decode(get_blog_option(bp_get_root_blog_id(), 'blogname'), ENT_QUOTES);
        $subject = '[' . $sitename . '] ' . sprintf(__('%s replied to one of your updates', 'buddypress'), $poster_name);
        $message = sprintf(__('%1$s replied to one of your updates:

"%2$s"

To view your original update and all comments, log in and visit: %3$s

---------------------
', 'buddypress'), $poster_name, $content, $thread_link);
        $message .= sprintf(__('To disable these notifications please log in and go to: %s', 'buddypress'), $settings_link);
        /* Send the message */
        $to = apply_filters('bp_activity_new_comment_notification_to', $to);
        $subject = apply_filters('bp_activity_new_comment_notification_subject', $subject, $poster_name);
        $message = apply_filters('bp_activity_new_comment_notification_message', $message, $poster_name, $content, $thread_link, $settings_link);
        nxt_mail($to, $subject, $message);
        do_action('bp_activity_sent_reply_to_update_email', $original_activity->user_id, $subject, $message, $comment_id, $commenter_id, $params);
    }
    /***
     * If this is a reply to another comment, send an email notification to the
     * author of the immediate parent comment.
     */
    if ($activity_id == $parent_id) {
        return false;
    }
    $parent_comment = new BP_Activity_Activity($parent_id);
    if ($parent_comment->user_id != $commenter_id && $original_activity->user_id != $parent_comment->user_id && 'no' != bp_get_user_meta($parent_comment->user_id, 'notification_activity_new_reply', true)) {
        $poster_name = bp_core_get_user_displayname($commenter_id);
        $thread_link = bp_activity_get_permalink($activity_id);
        $settings_slug = function_exists('bp_get_settings_slug') ? bp_get_settings_slug() : 'settings';
        $settings_link = bp_core_get_user_domain($parent_comment->user_id) . $settings_slug . '/notifications/';
        // Set up and send the message
        $ud = bp_core_get_core_userdata($parent_comment->user_id);
        $to = $ud->user_email;
        $sitename = nxt_specialchars_decode(get_blog_option(bp_get_root_blog_id(), 'blogname'), ENT_QUOTES);
        $subject = '[' . $sitename . '] ' . sprintf(__('%s replied to one of your comments', 'buddypress'), $poster_name);
        $poster_name = stripslashes($poster_name);
        $content = bp_activity_filter_kses(stripslashes($content));
        $message = sprintf(__('%1$s replied to one of your comments:

"%2$s"

To view the original activity, your comment and all replies, log in and visit: %3$s

---------------------
', 'buddypress'), $poster_name, $content, $thread_link);
        $message .= sprintf(__('To disable these notifications please log in and go to: %s', 'buddypress'), $settings_link);
        /* Send the message */
        $to = apply_filters('bp_activity_new_comment_notification_comment_author_to', $to);
        $subject = apply_filters('bp_activity_new_comment_notification_comment_author_subject', $subject, $poster_name);
        $message = apply_filters('bp_activity_new_comment_notification_comment_author_message', $message, $poster_name, $content, $settings_link, $thread_link);
        nxt_mail($to, $subject, $message);
        do_action('bp_activity_sent_reply_to_reply_email', $original_activity->user_id, $subject, $message, $comment_id, $commenter_id, $params);
    }
}
/**
 * Sends an email notification and a BP notification when someone mentions you in an update
 *
 * @since BuddyPress (1.2)
 *
 * @param int $comment_id The comment id
 * @param int $commenter_id The unique user_id of the user who posted the comment
 * @param array $params {@link bp_activity_new_comment()}
 *
 * @uses bp_get_user_meta()
 * @uses bp_core_get_user_displayname()
 * @uses bp_activity_get_permalink()
 * @uses bp_core_get_user_domain()
 * @uses bp_get_settings_slug()
 * @uses bp_activity_filter_kses()
 * @uses bp_core_get_core_userdata()
 * @uses wp_specialchars_decode()
 * @uses get_blog_option()
 * @uses bp_get_root_blog_id()
 * @uses apply_filters() To call the 'bp_activity_new_comment_notification_to' hook
 * @uses apply_filters() To call the 'bp_activity_new_comment_notification_subject' hook
 * @uses apply_filters() To call the 'bp_activity_new_comment_notification_message' hook
 * @uses wp_mail()
 * @uses do_action() To call the 'bp_activity_sent_reply_to_update_email' hook
 * @uses apply_filters() To call the 'bp_activity_new_comment_notification_comment_author_to' hook
 * @uses apply_filters() To call the 'bp_activity_new_comment_notification_comment_author_subject' hook
 * @uses apply_filters() To call the 'bp_activity_new_comment_notification_comment_author_message' hook
 * @uses do_action() To call the 'bp_activity_sent_reply_to_reply_email' hook
 */
function bp_activity_new_comment_notification($comment_id, $commenter_id, $params)
{
    // Set some default parameters
    $activity_id = 0;
    $parent_id = 0;
    extract($params);
    $original_activity = new BP_Activity_Activity($activity_id);
    if ($original_activity->user_id != $commenter_id && 'no' != bp_get_user_meta($original_activity->user_id, 'notification_activity_new_reply', true)) {
        $poster_name = bp_core_get_user_displayname($commenter_id);
        $thread_link = bp_activity_get_permalink($activity_id);
        $settings_slug = function_exists('bp_get_settings_slug') ? bp_get_settings_slug() : 'settings';
        $settings_link = bp_core_get_user_domain($original_activity->user_id) . $settings_slug . '/notifications/';
        $poster_name = stripslashes($poster_name);
        $content = bp_activity_filter_kses(stripslashes($content));
        // Set up and send the message
        $ud = bp_core_get_core_userdata($original_activity->user_id);
        $to = $ud->user_email;
        $subject = bp_get_email_subject(array('text' => sprintf(__('%s replied to one of your updates', 'buddypress'), $poster_name)));
        $message = sprintf(__('%1$s replied to one of your updates:

"%2$s"

To view your original update and all comments, log in and visit: %3$s

---------------------
', 'buddypress'), $poster_name, $content, $thread_link);
        // Only show the disable notifications line if the settings component is enabled
        if (bp_is_active('settings')) {
            $message .= sprintf(__('To disable these notifications please log in and go to: %s', 'buddypress'), $settings_link);
        }
        /* Send the message */
        $to = apply_filters('bp_activity_new_comment_notification_to', $to);
        $subject = apply_filters('bp_activity_new_comment_notification_subject', $subject, $poster_name);
        $message = apply_filters('bp_activity_new_comment_notification_message', $message, $poster_name, $content, $thread_link, $settings_link);
        wp_mail($to, $subject, $message);
        do_action('bp_activity_sent_reply_to_update_email', $original_activity->user_id, $subject, $message, $comment_id, $commenter_id, $params);
    }
    /***
     * If this is a reply to another comment, send an email notification to the
     * author of the immediate parent comment.
     */
    if (empty($parent_id) || $activity_id == $parent_id) {
        return false;
    }
    $parent_comment = new BP_Activity_Activity($parent_id);
    if ($parent_comment->user_id != $commenter_id && $original_activity->user_id != $parent_comment->user_id && 'no' != bp_get_user_meta($parent_comment->user_id, 'notification_activity_new_reply', true)) {
        $poster_name = bp_core_get_user_displayname($commenter_id);
        $thread_link = bp_activity_get_permalink($activity_id);
        $settings_slug = function_exists('bp_get_settings_slug') ? bp_get_settings_slug() : 'settings';
        $settings_link = bp_core_get_user_domain($parent_comment->user_id) . $settings_slug . '/notifications/';
        // Set up and send the message
        $ud = bp_core_get_core_userdata($parent_comment->user_id);
        $to = $ud->user_email;
        $subject = bp_get_email_subject(array('text' => sprintf(__('%s replied to one of your comments', 'buddypress'), $poster_name)));
        $poster_name = stripslashes($poster_name);
        $content = bp_activity_filter_kses(stripslashes($content));
        $message = sprintf(__('%1$s replied to one of your comments:

"%2$s"

To view the original activity, your comment and all replies, log in and visit: %3$s

---------------------
', 'buddypress'), $poster_name, $content, $thread_link);
        // Only show the disable notifications line if the settings component is enabled
        if (bp_is_active('settings')) {
            $message .= sprintf(__('To disable these notifications please log in and go to: %s', 'buddypress'), $settings_link);
        }
        /* Send the message */
        $to = apply_filters('bp_activity_new_comment_notification_comment_author_to', $to);
        $subject = apply_filters('bp_activity_new_comment_notification_comment_author_subject', $subject, $poster_name);
        $message = apply_filters('bp_activity_new_comment_notification_comment_author_message', $message, $poster_name, $content, $settings_link, $thread_link);
        wp_mail($to, $subject, $message);
        do_action('bp_activity_sent_reply_to_reply_email', $original_activity->user_id, $subject, $message, $comment_id, $commenter_id, $params);
    }
}