예제 #1
0
/**
 * Get allowed space for the given component( In MB) 
 * @param type $component
 * @param type $component_id
 * @return numeric : no. of MBs
 */
function mpp_get_allowed_space($component, $component_id = null)
{
    if (!empty($component_id)) {
        if ($component == 'members') {
            $space_allowed = bp_get_user_meta($component_id, 'mpp_upload_space', true);
        } elseif ($component == 'groups' && function_exists('groups_get_groupmeta')) {
            $space_allowed = groups_get_groupmeta($component_id, 'mpp_upload_space', true);
        }
    }
    if (empty($component_id) || empty($space_allowed)) {
        //if owner id is empty
        //get the gallery/group space
        if ($component == 'members') {
            $space_allowed = mpp_get_option('mpp_upload_space');
        } elseif ($component == 'groups') {
            $space_allowed = mpp_get_option('mpp_upload_space_groups');
        }
    }
    //we should have some value by now
    //if( empty($space_allowed))
    ///   $space_allowed = get_option("gallery_upload_space");//currently let us deal with blog space gallery will have it's own limit later
    if (empty($space_allowed)) {
        $space_allowed = mpp_get_option('mpp_upload_space');
    }
    //if we still don't have anything
    if (empty($space_allowed) || !is_numeric($space_allowed)) {
        $space_allowed = 10;
    }
    //by default
    return apply_filters('mpp_allowed_space', $space_allowed, $component, $component_id);
    //allow to override for specific users/groups
}
function friends_notification_accepted_request($friendship_id, $initiator_id, $friend_id)
{
    $friend_name = bp_core_get_user_displayname($friend_id);
    if ('no' == bp_get_user_meta((int) $initiator_id, 'notification_friends_friendship_accepted', true)) {
        return false;
    }
    $ud = get_userdata($initiator_id);
    $friend_link = bp_core_get_user_domain($friend_id);
    $settings_slug = function_exists('bp_get_settings_slug') ? bp_get_settings_slug() : 'settings';
    $settings_link = trailingslashit(bp_core_get_user_domain($initiator_id) . $settings_slug . '/notifications');
    // Set up and send the message
    $to = $ud->user_email;
    $subject = bp_get_email_subject(array('text' => sprintf(__('%s accepted your friendship request', 'buddypress'), $friend_name)));
    $message = sprintf(__('%1$s accepted your friend request.

To view %2$s\'s profile: %3$s

---------------------
', 'buddypress'), $friend_name, $friend_name, $friend_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('friends_notification_accepted_request_to', $to);
    $subject = apply_filters('friends_notification_accepted_request_subject', $subject, $friend_name);
    $message = apply_filters('friends_notification_accepted_request_message', $message, $friend_name, $friend_link, $settings_link);
    wp_mail($to, $subject, $message);
    do_action('bp_friends_sent_accepted_email', $initiator_id, $subject, $message, $friendship_id, $friend_id);
}
function friends_notification_accepted_request($friendship_id, $initiator_id, $friend_id)
{
    global $bp;
    $friendship = new BP_Friends_Friendship($friendship_id, false, false);
    $friend_name = bp_core_get_user_displayname($friend_id);
    if ('no' == bp_get_user_meta((int) $initiator_id, 'notification_friends_friendship_accepted', true)) {
        return false;
    }
    $ud = get_userdata($initiator_id);
    $friend_link = bp_core_get_user_domain($friend_id);
    $settings_slug = function_exists('bp_get_settings_slug') ? bp_get_settings_slug() : 'settings';
    $settings_link = bp_core_get_user_domain($initiator_id) . $settings_slug . '/notifications';
    // Set up and send the message
    $to = $ud->user_email;
    $sitename = nxt_specialchars_decode(get_blog_option(bp_get_root_blog_id(), 'blogname'), ENT_QUOTES);
    $subject = '[' . $sitename . '] ' . sprintf(__('%s accepted your friendship request', 'buddypress'), $friend_name);
    $message = sprintf(__('%1$s accepted your friend request.

To view %2$s\'s profile: %3$s

---------------------
', 'buddypress'), $friend_name, $friend_name, $friend_link);
    $message .= sprintf(__('To disable these notifications please log in and go to: %s', 'buddypress'), $settings_link);
    /* Send the message */
    $to = apply_filters('friends_notification_accepted_request_to', $to);
    $subject = apply_filters('friends_notification_accepted_request_subject', $subject, $friend_name);
    $message = apply_filters('friends_notification_accepted_request_message', $message, $friend_name, $friend_link, $settings_link);
    nxt_mail($to, $subject, $message);
    do_action('bp_friends_sent_accepted_email', $initiator_id, $subject, $message, $friendship_id, $friend_id);
}
/**
 * Send notifications related to the acceptance of a friendship request.
 *
 * When a friendship request is accepted, an email and a BP notification are
 * sent to the user who requested the friendship ($initiator_id).
 *
 * @since 1.0.0
 *
 * @param int $friendship_id ID of the friendship object.
 * @param int $initiator_id  ID of the user who initiated the request.
 * @param int $friend_id     ID of the request recipient.
 */
function friends_notification_accepted_request($friendship_id, $initiator_id, $friend_id)
{
    if ('no' == bp_get_user_meta((int) $initiator_id, 'notification_friends_friendship_accepted', true)) {
        return;
    }
    $args = array('tokens' => array('friend.id' => $friend_id, 'friendship.url' => esc_url(bp_core_get_user_domain($friend_id)), 'friend.name' => bp_core_get_user_displayname($friend_id), 'friendship.id' => $friendship_id, 'initiator.id' => $initiator_id));
    bp_send_email('friends-request-accepted', $initiator_id, $args);
}
 /**
  * Post a gallery or media Main comment on single page
  * 
  * @return type
  */
 public function post_comment()
 {
     // Bail if not a POST action
     if ('POST' !== strtoupper($_SERVER['REQUEST_METHOD'])) {
         return;
     }
     // Check the nonce
     check_admin_referer('post_update', '_wpnonce_post_update');
     if (!is_user_logged_in()) {
         exit('-1');
     }
     $mpp_type = $_POST['mpp-type'];
     $mpp_id = $_POST['mpp-id'];
     if (empty($_POST['content'])) {
         exit('-1<div id="message" class="error"><p>' . __('Please enter some content to post.', 'mediapress') . '</p></div>');
     }
     $activity_id = 0;
     if (empty($_POST['object']) && bp_is_active('activity')) {
         //we are preventing this comment to be set as the user's lastes_update
         $user_id = bp_loggedin_user_id();
         $old_latest_update = bp_get_user_meta($user_id, 'bp_latest_update', true);
         $activity_id = bp_activity_post_update(array('content' => $_POST['content']));
         //restore
         if (!empty($old_latest_update)) {
             bp_update_user_meta($user_id, 'bp_latest_update', $old_latest_update);
         }
     } elseif ($_POST['object'] == 'groups') {
         if (!empty($_POST['item_id']) && bp_is_active('groups')) {
             $activity_id = groups_post_update(array('content' => $_POST['content'], 'group_id' => $_POST['item_id']));
         }
     } else {
         $activity_id = apply_filters('bp_activity_custom_update', $_POST['object'], $_POST['item_id'], $_POST['content']);
     }
     if (empty($activity_id)) {
         exit('-1<div id="message" class="error"><p>' . __('There was a problem posting your update, please try again.', 'mediapress') . '</p></div>');
     }
     //if we have got activity id, let us add a meta key
     if ($mpp_type == 'gallery') {
         mpp_activity_update_gallery_id($activity_id, $mpp_id);
     } elseif ($mpp_type == 'media') {
         mpp_activity_update_media_id($activity_id, $mpp_id);
     }
     $activity = new BP_Activity_Activity($activity_id);
     // $activity->component = buddypress()->mediapress->id;
     $activity->type = 'mpp_media_upload';
     $activity->save();
     if (bp_has_activities('include=' . $activity_id)) {
         while (bp_activities()) {
             bp_the_activity();
             mpp_locate_template(array('activity/entry.php'), true);
         }
     }
     exit;
 }
function messages_notification_new_message($args = array())
{
    // These should be extracted below
    $recipients = array();
    $email_subject = $email_content = '';
    extract($args);
    $sender_name = bp_core_get_user_displayname($sender_id);
    // Bail if no recipients
    if (!empty($recipients)) {
        foreach ($recipients as $recipient) {
            if ($sender_id == $recipient->user_id || 'no' == bp_get_user_meta($recipient->user_id, 'notification_messages_new_message', true)) {
                continue;
            }
            // User data and links
            $ud = get_userdata($recipient->user_id);
            // Bail if user cannot be found
            if (empty($ud)) {
                continue;
            }
            $message_link = bp_core_get_user_domain($recipient->user_id) . bp_get_messages_slug() . '/';
            $settings_slug = function_exists('bp_get_settings_slug') ? bp_get_settings_slug() : 'settings';
            $settings_link = bp_core_get_user_domain($recipient->user_id) . $settings_slug . '/notifications/';
            // Sender info
            $sender_name = stripslashes($sender_name);
            $subject = stripslashes(wp_filter_kses($subject));
            $content = stripslashes(wp_filter_kses($content));
            // Set up and send the message
            $email_to = $ud->user_email;
            $email_subject = bp_get_email_subject(array('text' => sprintf(__('New message from %s', 'buddypress'), $sender_name)));
            $email_content = sprintf(__('%1$s sent you a new message:

Subject: %2$s

"%3$s"

To view and read your messages please log in and visit: %4$s

---------------------
', 'buddypress'), $sender_name, $subject, $content, $message_link);
            // Only show the disable notifications line if the settings component is enabled
            if (bp_is_active('settings')) {
                $email_content .= sprintf(__('To disable these notifications please log in and go to: %s', 'buddypress'), $settings_link);
            }
            // Send the message
            $email_to = apply_filters('messages_notification_new_message_to', $email_to);
            $email_subject = apply_filters('messages_notification_new_message_subject', $email_subject, $sender_name);
            $email_content = apply_filters('messages_notification_new_message_message', $email_content, $sender_name, $subject, $content, $message_link, $settings_link);
            wp_mail($email_to, $email_subject, $email_content);
        }
    }
    do_action('bp_messages_sent_notification_email', $recipients, $email_subject, $email_content, $args);
}
function messages_notification_new_message($args = array())
{
    // These should be extracted below
    $recipients = array();
    $email_subject = $email_content = '';
    extract($args);
    $sender_name = bp_core_get_user_displayname($sender_id);
    // Bail if no recipients
    if (!empty($recipients)) {
        foreach ($recipients as $recipient) {
            if ($sender_id == $recipient->user_id || 'no' == bp_get_user_meta($recipient->user_id, 'notification_messages_new_message', true)) {
                continue;
            }
            // User data and links
            $ud = get_userdata($recipient->user_id);
            $message_link = bp_core_get_user_domain($recipient->user_id) . bp_get_messages_slug() . '/';
            $settings_slug = function_exists('bp_get_settings_slug') ? bp_get_settings_slug() : 'settings';
            $settings_link = bp_core_get_user_domain($recipient->user_id) . $settings_slug . '/notifications/';
            // Sender info
            $sender_name = stripslashes($sender_name);
            $subject = stripslashes(wp_filter_kses($subject));
            $content = stripslashes(wp_filter_kses($content));
            // Set up and send the message
            $email_to = $ud->user_email;
            $sitename = wp_specialchars_decode(get_blog_option(bp_get_root_blog_id(), 'blogname'), ENT_QUOTES);
            $email_subject = '[' . $sitename . '] ' . sprintf(__('New message from %s', 'buddypress'), $sender_name);
            $email_content = sprintf(__('%1$s sent you a new message:

Subject: %2$s

"%3$s"

To view and read your messages please log in and visit: %4$s

---------------------
', 'buddypress'), $sender_name, $subject, $content, $message_link);
            $email_content .= sprintf(__('To disable these notifications please log in and go to: %s', 'buddypress'), $settings_link);
            // Send the message
            $email_to = apply_filters('messages_notification_new_message_to', $email_to);
            $email_subject = apply_filters('messages_notification_new_message_subject', $email_subject, $sender_name);
            $email_content = apply_filters('messages_notification_new_message_message', $email_content, $sender_name, $subject, $content, $message_link, $settings_link);
            wp_mail($email_to, $email_subject, $email_content);
        }
    }
    do_action('bp_messages_sent_notification_email', $recipients, $email_subject, $email_content, $args);
}
/**
 * bp_group_documents_screen_notification_settings()
 *
 * Adds notification settings for the component, so that a user can turn off email
 * notifications set on specific component actions.  These will be added to the
 * bottom of the existing "Group" settings
 * @version 2, 21/6/2013, stergatu, fix a bug which prevented the notifications setting to be saved
 */
function bp_group_documents_screen_notification_settings()
{
    if (!($notification_group_documents_upload_member = bp_get_user_meta(bp_displayed_user_id(), 'notification_group_documents_upload_member', true))) {
        $notification_group_documents_upload_member = 'yes';
    }
    if (!($notification_group_documents_upload_mod = bp_get_user_meta(bp_displayed_user_id(), 'notification_group_documents_upload_mod', true))) {
        $notification_group_documents_upload_mod = 'yes';
    }
    ?>
    <tr id="groups-notification-settings-user-upload-file">
        <td></td>
        <td><?php 
    _e('A member uploads a document to a group you belong to', 'bp-group-documents');
    ?>
</td>
        <td class="yes"><input type="radio" name="notifications[notification_group_documents_upload_member]" value="yes" <?php 
    checked($notification_group_documents_upload_member, 'yes', true);
    ?>
/></td>
        <td class="no"><input type="radio" name="notifications[notification_group_documents_upload_member]" value="no" <?php 
    checked($notification_group_documents_upload_member, 'no', true);
    ?>
/></td>
    </tr>
    <tr>
        <td></td>
        <td><?php 
    _e('A member uploads a document to a group for which you are an moderator/admin', 'bp-group-documents');
    ?>
</td>
        <td class="yes"><input type="radio" name="notifications[notification_group_documents_upload_mod]" value="yes" <?php 
    checked($notification_group_documents_upload_mod, 'yes', true);
    ?>
/></td>
        <td class="no"><input type="radio" name="notifications[notification_group_documents_upload_mod]" value="no" <?php 
    checked($notification_group_documents_upload_mod, 'no', true);
    ?>
/></td>
    </tr>

    <?php 
    do_action('bp_group_documents_notification_settings');
    ?>
    <?php 
}
/**
 * Email message recipients to alert them of a new unread private message.
 *
 * @since 1.0.0
 *
 * @param array|BP_Messages_Message $raw_args {
 *     Array of arguments. Also accepts a BP_Messages_Message object.
 *     @type array  $recipients    User IDs of recipients.
 *     @type string $email_subject Subject line of message.
 *     @type string $email_content Content of message.
 *     @type int    $sender_id     User ID of sender.
 * }
 */
function messages_notification_new_message($raw_args = array())
{
    if (is_object($raw_args)) {
        $args = (array) $raw_args;
    } else {
        $args = $raw_args;
    }
    // These should be extracted below.
    $recipients = array();
    $email_subject = $email_content = '';
    $sender_id = 0;
    // Barf.
    extract($args);
    if (empty($recipients)) {
        return;
    }
    $sender_name = bp_core_get_user_displayname($sender_id);
    // Send an email to each recipient.
    foreach ($recipients as $recipient) {
        if ($sender_id == $recipient->user_id || 'no' == bp_get_user_meta($recipient->user_id, 'notification_messages_new_message', true)) {
            continue;
        }
        // User data and links.
        $ud = get_userdata($recipient->user_id);
        if (empty($ud)) {
            continue;
        }
        $args = array('tokens' => array('usermessage' => wp_strip_all_tags(stripslashes($message)), 'message.url' => esc_url(bp_core_get_user_domain($recipient->user_id) . bp_get_messages_slug() . '/view/' . $thread_id . '/'), 'sender.name' => $sender_name, 'usersubject' => sanitize_text_field(stripslashes($subject))));
        bp_send_email('messages-unread', $ud, $args);
    }
    /**
     * Fires after the sending of a new message email notification.
     *
     * @since 1.5.0
     * @deprecated 2.5.0 Use the filters in BP_Email.
     *                   $email_subject and $email_content arguments unset and deprecated.
     *
     * @param array  $recipients    User IDs of recipients.
     * @param string $email_subject Deprecated in 2.5; now an empty string.
     * @param string $email_content Deprecated in 2.5; now an empty string.
     * @param array  $args          Array of originally provided arguments.
     */
    do_action('bp_messages_sent_notification_email', $recipients, '', '', $args);
}
/**
 * Add the 'pending email change' message to the settings page.
 *
 * @since 2.1.0
 */
function bp_settings_pending_email_notice()
{
    $pending_email = bp_get_user_meta(bp_displayed_user_id(), 'pending_email_change', true);
    if (empty($pending_email['newemail'])) {
        return;
    }
    if (bp_get_displayed_user_email() == $pending_email['newemail']) {
        return;
    }
    ?>

	<div id="message" class="bp-template-notice error">
		<p><?php 
    printf(__('There is a pending change of your email address to <code>%1$s</code>.<br />Check your email (<code>%2$s</code>) for the verification link. <a href="%3$s">Cancel</a>', 'buddypress'), $pending_email['newemail'], bp_get_displayed_user_email(), esc_url(bp_displayed_user_domain() . bp_get_settings_slug() . '/?dismiss_email_change=1'));
    ?>
</p>
	</div>

	<?php 
}
/**
 * Email message recipients to alert them of a new unread private message.
 *
 * @since BuddyPress (1.0.0)
 *
 * @param array|BP_Messages_Message $raw_args {
 *     Array of arguments. Also accepts a BP_Messages_Message object.
 *     @type array  $recipients    User IDs of recipients.
 *     @type string $email_subject Subject line of message.
 *     @type string $email_content Content of message.
 *     @type int    $sender_id     User ID of sender.
 * }
 */
function messages_notification_new_message($raw_args = array())
{
    // Cast possible $message object as an array
    if (is_object($raw_args)) {
        $args = (array) $raw_args;
    } else {
        $args = $raw_args;
    }
    // These should be extracted below
    $recipients = array();
    $email_subject = $email_content = '';
    $sender_id = 0;
    // Barf
    extract($args);
    // Get the sender display name
    $sender_name = bp_core_get_user_displayname($sender_id);
    // Bail if no recipients
    if (!empty($recipients)) {
        foreach ($recipients as $recipient) {
            if ($sender_id == $recipient->user_id || 'no' == bp_get_user_meta($recipient->user_id, 'notification_messages_new_message', true)) {
                continue;
            }
            // User data and links
            $ud = get_userdata($recipient->user_id);
            // Bail if user cannot be found
            if (empty($ud)) {
                continue;
            }
            $message_link = bp_core_get_user_domain($recipient->user_id) . bp_get_messages_slug() . '/';
            $settings_slug = function_exists('bp_get_settings_slug') ? bp_get_settings_slug() : 'settings';
            $settings_link = bp_core_get_user_domain($recipient->user_id) . $settings_slug . '/notifications/';
            // Sender info
            $sender_name = stripslashes($sender_name);
            $subject = stripslashes(wp_filter_kses($subject));
            $content = stripslashes(wp_filter_kses($message));
            // Set up and send the message
            $email_to = $ud->user_email;
            $email_subject = bp_get_email_subject(array('text' => sprintf(__('New message from %s', 'buddypress'), $sender_name)));
            $email_content = sprintf(__('%1$s sent you a new message:

Subject: %2$s

"%3$s"

To view and read your messages please log in and visit: %4$s

---------------------
', 'buddypress'), $sender_name, $subject, $content, $message_link);
            // Only show the disable notifications line if the settings component is enabled
            if (bp_is_active('settings')) {
                $email_content .= sprintf(__('To disable these notifications, please log in and go to: %s', 'buddypress'), $settings_link);
            }
            /**
             * Filters the user email that the message notification will be sent to.
             *
             * @since BuddyPress (1.2.0)
             *
             * @param string  $email_to User email the notification is being sent to.
             * @param WP_User $ud       WP_User object of who is receiving the message.
             */
            $email_to = apply_filters('messages_notification_new_message_to', $email_to, $ud);
            /**
             * Filters the message notification subject that will be sent to user.
             *
             * @since BuddyPress (1.2.0)
             *
             * @param string  $email_subject Email notification subject text.
             * @param string  $sender_name   Name of the person who sent the message.
             * @param WP_User $ud            WP_User object of who is receiving the message.
             */
            $email_subject = apply_filters('messages_notification_new_message_subject', $email_subject, $sender_name, $ud);
            /**
             * Filters the message notification message that will be sent to user.
             *
             * @since BuddyPress (1.2.0)
             *
             * @param string  $email_content Email notification message text.
             * @param string  $sender_name   Name of the person who sent the message.
             * @param string  $subject       Email notification subject text.
             * @param string  $content       Content of the message.
             * @param string  $message_link  URL permalink for the message.
             * @param string  $settings_link URL permalink for the user's notification settings area.
             * @param WP_User $ud            WP_User object of who is receiving the message.
             */
            $email_content = apply_filters('messages_notification_new_message_message', $email_content, $sender_name, $subject, $content, $message_link, $settings_link, $ud);
            wp_mail($email_to, $email_subject, $email_content);
        }
    }
    /**
     * Fires after the sending of a new message email notification.
     *
     * @since BuddyPress (1.5.0)
     *
     * @param array  $recipients    User IDs of recipients.
     * @param string $email_subject Email notification subject text.
     * @param string $email_content Email notification message text.
     * @param array  $$args         Array of originally provided arguments.
     */
    do_action('bp_messages_sent_notification_email', $recipients, $email_subject, $email_content, $args);
}
/**
 * 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);
    }
}
예제 #13
0
/**
 * Process email change verification or cancel requests.
 *
 * @since 2.1.0
 */
function bp_settings_verify_email_change()
{
    if (!bp_is_settings_component()) {
        return;
    }
    if (!bp_is_my_profile()) {
        return;
    }
    $redirect_to = trailingslashit(bp_displayed_user_domain() . bp_get_settings_slug());
    // Email change is being verified
    if (isset($_GET['verify_email_change'])) {
        $pending_email = bp_get_user_meta(bp_displayed_user_id(), 'pending_email_change', true);
        // Bail if the hash provided doesn't match the one saved in the database
        if (urldecode($_GET['verify_email_change']) !== $pending_email['hash']) {
            return;
        }
        $email_changed = wp_update_user(array('ID' => bp_displayed_user_id(), 'user_email' => trim($pending_email['newemail'])));
        if ($email_changed) {
            // Delete object cache for displayed user
            wp_cache_delete('bp_core_userdata_' . bp_displayed_user_id(), 'bp');
            // Delete the pending email change key
            bp_delete_user_meta(bp_displayed_user_id(), 'pending_email_change');
            // Post a success message and redirect
            bp_core_add_message(__('You have successfully verified your new email address.', 'buddypress'));
        } else {
            // Unknown error
            bp_core_add_message(__('There was a problem verifying your new email address. Please try again.', 'buddypress'), 'error');
        }
        bp_core_redirect($redirect_to);
        die;
        // Email change is being dismissed
    } elseif (!empty($_GET['dismiss_email_change'])) {
        bp_delete_user_meta(bp_displayed_user_id(), 'pending_email_change');
        bp_core_add_message(__('You have successfully dismissed your pending email change.', 'buddypress'));
        bp_core_redirect($redirect_to);
        die;
    }
}
예제 #14
0
function bp_dtheme_ajax_close_notice()
{
    global $userdata;
    // Bail if not a POST action
    if ('POST' !== strtoupper($_SERVER['REQUEST_METHOD'])) {
        return;
    }
    if (!isset($_POST['notice_id'])) {
        echo "-1<div id='message' class='error'><p>" . __('There was a problem closing the notice.', 'buddypress') . '</p></div>';
    } else {
        $notice_ids = bp_get_user_meta($userdata->ID, 'closed_notices', true);
        $notice_ids[] = (int) $_POST['notice_id'];
        bp_update_user_meta($userdata->ID, 'closed_notices', $notice_ids);
    }
}
 /**
  * Constructor method.
  *
  * The arguments passed to this class constructor are of the same
  * format as {@link BP_Activity_Activity::get()}.
  *
  * @since 1.5.0
  *
  * @see BP_Activity_Activity::get() for a description of the argument
  *      structure, as well as default values.
  *
  * @param array $args {
  *     Array of arguments. Supports all arguments from
  *     BP_Activity_Activity::get(), as well as 'page_arg' and
  *     'include'. Default values for 'per_page' and 'display_comments'
  *     differ from the originating function, and are described below.
  *     @type string      $page_arg         The string used as a query parameter in
  *                                         pagination links. Default: 'acpage'.
  *     @type array|bool  $include          Pass an array of activity IDs to
  *                                         retrieve only those items, or false to noop the 'include'
  *                                         parameter. 'include' differs from 'in' in that 'in' forms
  *                                         an IN clause that works in conjunction with other filters
  *                                         passed to the function, while 'include' is interpreted as
  *                                         an exact list of items to retrieve, which skips all other
  *                                         filter-related parameters. Default: false.
  *     @type int|bool    $per_page         Default: 20.
  *     @type string|bool $display_comments Default: 'threaded'.
  * }
  */
 public function __construct($args)
 {
     $bp = buddypress();
     // Backward compatibility with old method of passing arguments.
     if (!is_array($args) || func_num_args() > 1) {
         _deprecated_argument(__METHOD__, '1.6', sprintf(__('Arguments passed to %1$s should be in an associative array. See the inline documentation at %2$s for more details.', 'buddypress'), __METHOD__, __FILE__));
         $old_args_keys = array(0 => 'page', 1 => 'per_page', 2 => 'max', 3 => 'include', 4 => 'sort', 5 => 'filter', 6 => 'search_terms', 7 => 'display_comments', 8 => 'show_hidden', 9 => 'exclude', 10 => 'in', 11 => 'spam', 12 => 'page_arg');
         $func_args = func_get_args();
         $args = bp_core_parse_args_array($old_args_keys, $func_args);
     }
     $defaults = array('page' => 1, 'per_page' => 20, 'page_arg' => 'acpage', 'max' => false, 'fields' => 'all', 'count_total' => false, 'sort' => false, 'include' => false, 'exclude' => false, 'in' => false, 'filter' => false, 'scope' => false, 'search_terms' => false, 'meta_query' => false, 'date_query' => false, 'filter_query' => false, 'display_comments' => 'threaded', 'show_hidden' => false, 'spam' => 'ham_only', 'update_meta_cache' => true);
     $r = wp_parse_args($args, $defaults);
     extract($r);
     $this->pag_arg = sanitize_key($r['page_arg']);
     $this->pag_page = bp_sanitize_pagination_arg($this->pag_arg, $r['page']);
     $this->pag_num = bp_sanitize_pagination_arg('num', $r['per_page']);
     // Check if blog/forum replies are disabled.
     $this->disable_blogforum_replies = (bool) bp_core_get_root_option('bp-disable-blogforum-comments');
     // Get an array of the logged in user's favorite activities.
     $this->my_favs = maybe_unserialize(bp_get_user_meta(bp_loggedin_user_id(), 'bp_favorite_activities', true));
     // Fetch specific activity items based on ID's.
     if (!empty($include)) {
         $this->activities = bp_activity_get_specific(array('activity_ids' => explode(',', $include), 'max' => $max, 'count_total' => $count_total, 'page' => $this->pag_page, 'per_page' => $this->pag_num, 'sort' => $sort, 'display_comments' => $display_comments, 'show_hidden' => $show_hidden, 'spam' => $spam, 'update_meta_cache' => $update_meta_cache));
         // Fetch all activity items.
     } else {
         $this->activities = bp_activity_get(array('display_comments' => $display_comments, 'max' => $max, 'count_total' => $count_total, 'per_page' => $this->pag_num, 'page' => $this->pag_page, 'sort' => $sort, 'search_terms' => $search_terms, 'meta_query' => $meta_query, 'date_query' => $date_query, 'filter_query' => $filter_query, 'filter' => $filter, 'scope' => $scope, 'show_hidden' => $show_hidden, 'exclude' => $exclude, 'in' => $in, 'spam' => $spam, 'update_meta_cache' => $update_meta_cache));
     }
     // The total_activity_count property will be set only if a
     // 'count_total' query has taken place.
     if (!is_null($this->activities['total'])) {
         if (!$max || $max >= (int) $this->activities['total']) {
             $this->total_activity_count = (int) $this->activities['total'];
         } else {
             $this->total_activity_count = (int) $max;
         }
     }
     $this->has_more_items = $this->activities['has_more_items'];
     $this->activities = $this->activities['activities'];
     if ($max) {
         if ($max >= count($this->activities)) {
             $this->activity_count = count($this->activities);
         } else {
             $this->activity_count = (int) $max;
         }
     } else {
         $this->activity_count = count($this->activities);
     }
     $this->full_name = bp_get_displayed_user_fullname();
     // Fetch parent content for activity comments so we do not have to query in the loop.
     foreach ((array) $this->activities as $activity) {
         if ('activity_comment' != $activity->type) {
             continue;
         }
         $parent_ids[] = $activity->item_id;
     }
     if (!empty($parent_ids)) {
         $activity_parents = bp_activity_get_specific(array('activity_ids' => $parent_ids));
     }
     if (!empty($activity_parents['activities'])) {
         foreach ($activity_parents['activities'] as $parent) {
             $this->activity_parents[$parent->id] = $parent;
         }
         unset($activity_parents);
     }
     if ((int) $this->total_activity_count && (int) $this->pag_num) {
         $this->pag_links = paginate_links(array('base' => add_query_arg($this->pag_arg, '%#%'), 'format' => '', 'total' => ceil((int) $this->total_activity_count / (int) $this->pag_num), 'current' => (int) $this->pag_page, 'prev_text' => _x('&larr;', 'Activity pagination previous text', 'buddypress'), 'next_text' => _x('&rarr;', 'Activity pagination next text', 'buddypress'), 'mid_size' => 1, 'add_args' => array()));
     }
 }
function groups_notification_group_invites(&$group, &$member, $inviter_user_id)
{
    // @todo $inviter_up may be used for caching, test without it
    $inviter_ud = bp_core_get_core_userdata($inviter_user_id);
    $inviter_name = bp_core_get_userlink($inviter_user_id, true, false, true);
    $inviter_link = bp_core_get_user_domain($inviter_user_id);
    $group_link = bp_get_group_permalink($group);
    if (!$member->invite_sent) {
        $invited_user_id = $member->user_id;
        // Post a screen notification first.
        bp_core_add_notification($group->id, $invited_user_id, 'groups', 'group_invite');
        if ('no' == bp_get_user_meta($invited_user_id, 'notification_groups_invite', true)) {
            return false;
        }
        $invited_ud = bp_core_get_core_userdata($invited_user_id);
        $settings_slug = function_exists('bp_get_settings_slug') ? bp_get_settings_slug() : 'settings';
        $settings_link = bp_core_get_user_domain($invited_user_id) . $settings_slug . '/notifications/';
        $invited_link = bp_core_get_user_domain($invited_user_id);
        $invites_link = trailingslashit($invited_link . bp_get_groups_slug() . '/invites');
        // Set up and send the message
        $to = $invited_ud->user_email;
        $subject = bp_get_email_subject(array('text' => sprintf(__('You have an invitation to the group: "%s"', 'buddypress'), $group->name)));
        $message = sprintf(__('One of your friends %1$s has invited you to the group: "%2$s".

To view your group invites visit: %3$s

To view the group visit: %4$s

To view %5$s\'s profile visit: %6$s

---------------------
', 'buddypress'), $inviter_name, $group->name, $invites_link, $group_link, $inviter_name, $inviter_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('groups_notification_group_invites_to', $to);
        $subject = apply_filters_ref_array('groups_notification_group_invites_subject', array($subject, &$group));
        $message = apply_filters_ref_array('groups_notification_group_invites_message', array($message, &$group, $inviter_name, $inviter_link, $invites_link, $group_link, $settings_link));
        wp_mail($to, $subject, $message);
        do_action('bp_groups_sent_invited_email', $invited_user_id, $subject, $message, $group);
    }
}
 function total_favorite_count($user_id)
 {
     if (!($favorite_activity_entries = bp_get_user_meta($user_id, 'bp_favorite_activities', true))) {
         return 0;
     }
     return count(maybe_unserialize($favorite_activity_entries));
 }
예제 #18
0
파일: ajax.php 프로젝트: hscale/webento
function bp_dtheme_ajax_close_notice()
{
    global $userdata;
    if (!isset($_POST['notice_id'])) {
        echo "-1<div id='message' class='error'><p>" . __('There was a problem closing the notice.', 'buddypress') . '</p></div>';
    } else {
        $notice_ids = bp_get_user_meta($userdata->ID, 'closed_notices', true);
        $notice_ids[] = (int) $_POST['notice_id'];
        bp_update_user_meta($userdata->ID, 'closed_notices', $notice_ids);
    }
}
 /**
  * Fetch the field visibility level for the fields returned by the query
  *
  * @since BuddyPress (1.6)
  *
  * @param int $user_id The profile owner's user_id
  * @param array $fields The database results returned by the get() query
  * @return array $fields The database results, with field_visibility added
  */
 public static function fetch_visibility_level($user_id = 0, $fields = array())
 {
     // Get the user's visibility level preferences
     $visibility_levels = bp_get_user_meta($user_id, 'bp_xprofile_visibility_levels', true);
     foreach ((array) $fields as $key => $field) {
         // Does the admin allow this field to be customized?
         $allow_custom = 'disabled' !== bp_xprofile_get_meta($field->id, 'field', 'allow_custom_visibility');
         // Look to see if the user has set the visibility for this field
         if ($allow_custom && isset($visibility_levels[$field->id])) {
             $field_visibility = $visibility_levels[$field->id];
             // If no admin-set default is saved, fall back on a global default
         } else {
             $fallback_visibility = bp_xprofile_get_meta($field->id, 'field', 'default_visibility');
             $field_visibility = !empty($fallback_visibility) ? $fallback_visibility : apply_filters('bp_xprofile_default_visibility_level', 'public');
         }
         $fields[$key]->visibility_level = $field_visibility;
     }
     return $fields;
 }
예제 #20
0
/**
 * Fetch an array of the xprofile fields that a given user has marked with certain visibility levels
 *
 * @since BuddyPress (1.6.0)
 * @see bp_xprofile_get_hidden_fields_for_user()
 *
 * @param int $user_id The id of the profile owner
 * @param array $levels An array of visibility levels ('public', 'friends', 'loggedin', 'adminsonly' etc) to be
 *    checked against
 * @return array $field_ids The fields that match the requested visibility levels for the given user
 */
function bp_xprofile_get_fields_by_visibility_levels($user_id, $levels = array())
{
    if (!is_array($levels)) {
        $levels = (array) $levels;
    }
    $user_visibility_levels = bp_get_user_meta($user_id, 'bp_xprofile_visibility_levels', true);
    // Parse the user-provided visibility levels with the default levels, which may take
    // precedence
    $default_visibility_levels = BP_XProfile_Group::fetch_default_visibility_levels();
    foreach ((array) $default_visibility_levels as $d_field_id => $defaults) {
        // If the admin has forbidden custom visibility levels for this field, replace
        // the user-provided setting with the default specified by the admin
        if (isset($defaults['allow_custom']) && isset($defaults['default']) && 'disabled' == $defaults['allow_custom']) {
            $user_visibility_levels[$d_field_id] = $defaults['default'];
        }
    }
    $field_ids = array();
    foreach ((array) $user_visibility_levels as $field_id => $field_visibility) {
        if (in_array($field_visibility, $levels)) {
            $field_ids[] = $field_id;
        }
    }
    // Never allow the fullname field to be excluded
    if (in_array(1, $field_ids)) {
        $key = array_search(1, $field_ids);
        unset($field_ids[$key]);
    }
    return $field_ids;
}
/**
 * Notify a member they have been invited to a group.
 *
 * @since 1.0.0
 *
 * @param BP_Groups_Group  $group           Group object.
 * @param BP_Groups_Member $member          Member object.
 * @param int              $inviter_user_id ID of the user who sent the invite.
 */
function groups_notification_group_invites(&$group, &$member, $inviter_user_id)
{
    // Bail if member has already been invited.
    if (!empty($member->invite_sent)) {
        return;
    }
    // @todo $inviter_ud may be used for caching, test without it
    $inviter_ud = bp_core_get_core_userdata($inviter_user_id);
    $invited_user_id = $member->user_id;
    // Trigger a BuddyPress Notification.
    if (bp_is_active('notifications')) {
        bp_notifications_add_notification(array('user_id' => $invited_user_id, 'item_id' => $group->id, 'component_name' => buddypress()->groups->id, 'component_action' => 'group_invite'));
    }
    // Bail if member opted out of receiving this email.
    if ('no' === bp_get_user_meta($invited_user_id, 'notification_groups_invite', true)) {
        return;
    }
    $invited_link = bp_core_get_user_domain($invited_user_id) . bp_get_groups_slug();
    $unsubscribe_args = array('user_id' => $invited_user_id, 'notification_type' => 'groups-invitation');
    $args = array('tokens' => array('group' => $group, 'group.url' => bp_get_group_permalink($group), 'group.name' => $group->name, 'inviter.name' => bp_core_get_userlink($inviter_user_id, true, false, true), 'inviter.url' => bp_core_get_user_domain($inviter_user_id), 'inviter.id' => $inviter_user_id, 'invites.url' => esc_url($invited_link . '/invites/'), 'unsubscribe' => esc_url(bp_email_get_unsubscribe_link($unsubscribe_args))));
    bp_send_email('groups-invitation', (int) $invited_user_id, $args);
}
예제 #22
0
/**
 * Render the group settings fields on the Notification Settings page.
 */
function groups_screen_notification_settings()
{
    if (!($group_invite = bp_get_user_meta(bp_displayed_user_id(), 'notification_groups_invite', true))) {
        $group_invite = 'yes';
    }
    if (!($group_update = bp_get_user_meta(bp_displayed_user_id(), 'notification_groups_group_updated', true))) {
        $group_update = 'yes';
    }
    if (!($group_promo = bp_get_user_meta(bp_displayed_user_id(), 'notification_groups_admin_promotion', true))) {
        $group_promo = 'yes';
    }
    if (!($group_request = bp_get_user_meta(bp_displayed_user_id(), 'notification_groups_membership_request', true))) {
        $group_request = 'yes';
    }
    ?>

	<table class="notification-settings" id="groups-notification-settings">
		<thead>
			<tr>
				<th class="icon"></th>
				<th class="title"><?php 
    _ex('Groups', 'Group settings on notification settings page', 'buddypress');
    ?>
</th>
				<th class="yes"><?php 
    _e('Yes', 'buddypress');
    ?>
</th>
				<th class="no"><?php 
    _e('No', 'buddypress');
    ?>
</th>
			</tr>
		</thead>

		<tbody>
			<tr id="groups-notification-settings-invitation">
				<td></td>
				<td><?php 
    _ex('A member invites you to join a group', 'group settings on notification settings page', 'buddypress');
    ?>
</td>
				<td class="yes"><input type="radio" name="notifications[notification_groups_invite]" id="notification-groups-invite-yes" value="yes" <?php 
    checked($group_invite, 'yes', true);
    ?>
/><label for="notification-groups-invite-yes" class="bp-screen-reader-text"><?php 
    _e('Yes, send email', 'buddypress');
    ?>
</label></td>
				<td class="no"><input type="radio" name="notifications[notification_groups_invite]" id="notification-groups-invite-no" value="no" <?php 
    checked($group_invite, 'no', true);
    ?>
/><label for="notification-groups-invite-no" class="bp-screen-reader-text"><?php 
    _e('No, do not send email', 'buddypress');
    ?>
</label></td>
			</tr>
			<tr id="groups-notification-settings-info-updated">
				<td></td>
				<td><?php 
    _ex('Group information is updated', 'group settings on notification settings page', 'buddypress');
    ?>
</td>
				<td class="yes"><input type="radio" name="notifications[notification_groups_group_updated]" id="notification-groups-group-updated-yes" value="yes" <?php 
    checked($group_update, 'yes', true);
    ?>
/><label for="notification-groups-group-updated-yes" class="bp-screen-reader-text"><?php 
    _e('Yes, send email', 'buddypress');
    ?>
</label></td>
				<td class="no"><input type="radio" name="notifications[notification_groups_group_updated]" id="notification-groups-group-updated-no" value="no" <?php 
    checked($group_update, 'no', true);
    ?>
/><label for="notification-groups-group-updated-no" class="bp-screen-reader-text"><?php 
    _e('No, do not send email', 'buddypress');
    ?>
</label></td>
			</tr>
			<tr id="groups-notification-settings-promoted">
				<td></td>
				<td><?php 
    _ex('You are promoted to a group administrator or moderator', 'group settings on notification settings page', 'buddypress');
    ?>
</td>
				<td class="yes"><input type="radio" name="notifications[notification_groups_admin_promotion]" id="notification-groups-admin-promotion-yes" value="yes" <?php 
    checked($group_promo, 'yes', true);
    ?>
/><label for="notification-groups-admin-promotion-yes" class="bp-screen-reader-text"><?php 
    _e('Yes, send email', 'buddypress');
    ?>
</label></td>
				<td class="no"><input type="radio" name="notifications[notification_groups_admin_promotion]" id="notification-groups-admin-promotion-no" value="no" <?php 
    checked($group_promo, 'no', true);
    ?>
/><label for="notification-groups-admin-promotion-no" class="bp-screen-reader-text"><?php 
    _e('No, do not send email', 'buddypress');
    ?>
</label></td>
			</tr>
			<tr id="groups-notification-settings-request">
				<td></td>
				<td><?php 
    _ex('A member requests to join a private group for which you are an admin', 'group settings on notification settings page', 'buddypress');
    ?>
</td>
				<td class="yes"><input type="radio" name="notifications[notification_groups_membership_request]" id="notification-groups-membership-request-yes" value="yes" <?php 
    checked($group_request, 'yes', true);
    ?>
/><label for="notification-groups-membership-request-yes" class="bp-screen-reader-text"><?php 
    _e('Yes, send email', 'buddypress');
    ?>
</label></td>
				<td class="no"><input type="radio" name="notifications[notification_groups_membership_request]" id="notification-groups-membership-request-no" value="no" <?php 
    checked($group_request, 'no', true);
    ?>
/><label for="notification-groups-membership-request-no" class="bp-screen-reader-text"><?php 
    _e('No, do not send email', 'buddypress');
    ?>
</label></td>
			</tr>

			<?php 
    /**
     * Fires at the end of the available group settings fields on Notification Settings page.
     *
     * @since 1.0.0
     */
    do_action('groups_screen_notification_settings');
    ?>

		</tbody>
	</table>

<?php 
}
예제 #23
0
/**
 * Add Friends-related settings to the Settings > Notifications page.
 */
function friends_screen_notification_settings()
{
    if (!($send_requests = bp_get_user_meta(bp_displayed_user_id(), 'notification_friends_friendship_request', true))) {
        $send_requests = 'yes';
    }
    if (!($accept_requests = bp_get_user_meta(bp_displayed_user_id(), 'notification_friends_friendship_accepted', true))) {
        $accept_requests = 'yes';
    }
    ?>

	<table class="notification-settings" id="friends-notification-settings">
		<thead>
			<tr>
				<th class="icon"></th>
				<th class="title"><?php 
    _ex('Friends', 'Friend settings on notification settings page', 'buddypress');
    ?>
</th>
				<th class="yes"><?php 
    _e('Yes', 'buddypress');
    ?>
</th>
				<th class="no"><?php 
    _e('No', 'buddypress');
    ?>
</th>
			</tr>
		</thead>

		<tbody>
			<tr id="friends-notification-settings-request">
				<td></td>
				<td><?php 
    _ex('A member sends you a friendship request', 'Friend settings on notification settings page', 'buddypress');
    ?>
</td>
				<td class="yes"><input type="radio" name="notifications[notification_friends_friendship_request]" value="yes" <?php 
    checked($send_requests, 'yes', true);
    ?>
/></td>
				<td class="no"><input type="radio" name="notifications[notification_friends_friendship_request]" value="no" <?php 
    checked($send_requests, 'no', true);
    ?>
/></td>
			</tr>
			<tr id="friends-notification-settings-accepted">
				<td></td>
				<td><?php 
    _ex('A member accepts your friendship request', 'Friend settings on notification settings page', 'buddypress');
    ?>
</td>
				<td class="yes"><input type="radio" name="notifications[notification_friends_friendship_accepted]" value="yes" <?php 
    checked($accept_requests, 'yes', true);
    ?>
/></td>
				<td class="no"><input type="radio" name="notifications[notification_friends_friendship_accepted]" value="no" <?php 
    checked($accept_requests, 'no', true);
    ?>
/></td>
			</tr>

			<?php 
    /**
     * Fires after the last table row on the friends notification screen.
     *
     * @since BuddyPress (1.0.0)
     */
    do_action('friends_screen_notification_settings');
    ?>

		</tbody>
	</table>

<?php 
}
/**
 * Shows the media count of a user in the tabs
 * 
 * @since BP Media 2.0
 */
function bp_media_init_count($user = null)
{
    global $bp_media_count;
    if (!$user) {
        $user = bp_displayed_user_id();
    }
    if ($user < 1) {
        $bp_media_count = null;
        return false;
    }
    $count = bp_get_user_meta($user, 'bp_media_count', true);
    if (!$count) {
        $bp_media_count = array('images' => 0, 'videos' => 0, 'audio' => 0);
        bp_update_user_meta($user, 'bp_media_count', $bp_media_count);
    } else {
        $bp_media_count = $count;
    }
    add_filter('bp_get_displayed_user_nav_' . BP_MEDIA_SLUG, 'bp_media_items_count_filter', 10, 2);
    if (bp_current_component() == BP_MEDIA_SLUG) {
        add_filter('bp_get_options_nav_' . BP_MEDIA_IMAGES_SLUG, 'bp_media_items_count_filter', 10, 2);
        add_filter('bp_get_options_nav_' . BP_MEDIA_VIDEOS_SLUG, 'bp_media_items_count_filter', 10, 2);
        add_filter('bp_get_options_nav_' . BP_MEDIA_AUDIO_SLUG, 'bp_media_items_count_filter', 10, 2);
    }
    return true;
}
예제 #25
0
function friends_screen_notification_settings()
{
    global $bp;
    if (!($send_requests = bp_get_user_meta($bp->displayed_user->id, 'notification_friends_friendship_request', true))) {
        $send_requests = 'yes';
    }
    if (!($accept_requests = bp_get_user_meta($bp->displayed_user->id, 'notification_friends_friendship_accepted', true))) {
        $accept_requests = 'yes';
    }
    ?>

	<table class="notification-settings" id="friends-notification-settings">
		<thead>
			<tr>
				<th class="icon"></th>
				<th class="title"><?php 
    _e('Friends', 'buddypress');
    ?>
</th>
				<th class="yes"><?php 
    _e('Yes', 'buddypress');
    ?>
</th>
				<th class="no"><?php 
    _e('No', 'buddypress');
    ?>
</th>
			</tr>
		</thead>

		<tbody>
			<tr id="friends-notification-settings-request">
				<td></td>
				<td><?php 
    _e('A member sends you a friendship request', 'buddypress');
    ?>
</td>
				<td class="yes"><input type="radio" name="notifications[notification_friends_friendship_request]" value="yes" <?php 
    checked($send_requests, 'yes', true);
    ?>
/></td>
				<td class="no"><input type="radio" name="notifications[notification_friends_friendship_request]" value="no" <?php 
    checked($send_requests, 'no', true);
    ?>
/></td>
			</tr>
			<tr id="friends-notification-settings-accepted">
				<td></td>
				<td><?php 
    _e('A member accepts your friendship request', 'buddypress');
    ?>
</td>
				<td class="yes"><input type="radio" name="notifications[notification_friends_friendship_accepted]" value="yes" <?php 
    checked($accept_requests, 'yes', true);
    ?>
/></td>
				<td class="no"><input type="radio" name="notifications[notification_friends_friendship_accepted]" value="no" <?php 
    checked($accept_requests, 'no', true);
    ?>
/></td>
			</tr>

			<?php 
    do_action('friends_screen_notification_settings');
    ?>

		</tbody>
	</table>

<?php 
}
/**
 * Map a user's WP display name to the XProfile fullname field, if necessary.
 *
 * This only happens when a user is registered in wp-admin by an administrator;
 * during normal registration, XProfile data is provided directly by the user.
 *
 * @since 1.2.0
 *
 * @param int $user_id ID of the user.
 * @return bool
 */
function bp_core_map_user_registration($user_id)
{
    // Only map data when the site admin is adding users, not on registration.
    if (!is_admin()) {
        return false;
    }
    // Add the user's fullname to Xprofile.
    if (bp_is_active('xprofile')) {
        $firstname = bp_get_user_meta($user_id, 'first_name', true);
        $lastname = ' ' . bp_get_user_meta($user_id, 'last_name', true);
        $name = $firstname . $lastname;
        if (empty($name) || ' ' == $name) {
            $name = bp_get_user_meta($user_id, 'nickname', true);
        }
        xprofile_set_field_data(1, $user_id, $name);
    }
}
예제 #27
0
 function remove()
 {
     global $wpdb, $bp;
     $sql = $wpdb->prepare("DELETE FROM {$bp->groups->table_name_members} WHERE user_id = %d AND group_id = %d", $this->user_id, $this->group_id);
     if (!($result = $wpdb->query($sql))) {
         return false;
     }
     groups_update_groupmeta($this->group_id, 'total_member_count', (int) groups_get_groupmeta($this->group_id, 'total_member_count') - 1);
     $group_count = bp_get_user_meta($this->user_id, 'total_group_count', true);
     if (!empty($group_count)) {
         bp_update_user_meta($this->user_id, 'total_group_count', (int) $group_count - 1);
     }
     return $result;
 }
예제 #28
0
/**
 * Add activity notifications settings to the notifications settings page.
 *
 * @since 1.2.0
 *
 * @uses bp_get_user_meta()
 * @uses bp_core_get_username()
 * @uses do_action() To call the 'bp_activity_screen_notification_settings' hook.
 */
function bp_activity_screen_notification_settings()
{
    if (bp_activity_do_mentions()) {
        if (!($mention = bp_get_user_meta(bp_displayed_user_id(), 'notification_activity_new_mention', true))) {
            $mention = 'yes';
        }
    }
    if (!($reply = bp_get_user_meta(bp_displayed_user_id(), 'notification_activity_new_reply', true))) {
        $reply = 'yes';
    }
    ?>

	<table class="notification-settings" id="activity-notification-settings">
		<thead>
			<tr>
				<th class="icon">&nbsp;</th>
				<th class="title"><?php 
    _e('Activity', 'buddypress');
    ?>
</th>
				<th class="yes"><?php 
    _e('Yes', 'buddypress');
    ?>
</th>
				<th class="no"><?php 
    _e('No', 'buddypress');
    ?>
</th>
			</tr>
		</thead>

		<tbody>
			<?php 
    if (bp_activity_do_mentions()) {
        ?>
				<tr id="activity-notification-settings-mentions">
					<td>&nbsp;</td>
					<td><?php 
        printf(__('A member mentions you in an update using "@%s"', 'buddypress'), bp_core_get_username(bp_displayed_user_id()));
        ?>
</td>
					<td class="yes"><input type="radio" name="notifications[notification_activity_new_mention]" id="notification-activity-new-mention-yes" value="yes" <?php 
        checked($mention, 'yes', true);
        ?>
/><label for="notification-activity-new-mention-yes" class="bp-screen-reader-text"><?php 
        _e('Yes, send email', 'buddypress');
        ?>
</label></td>
					<td class="no"><input type="radio" name="notifications[notification_activity_new_mention]" id="notification-activity-new-mention-no" value="no" <?php 
        checked($mention, 'no', true);
        ?>
/><label for="notification-activity-new-mention-no" class="bp-screen-reader-text"><?php 
        _e('No, do not send email', 'buddypress');
        ?>
</label></td>
				</tr>
			<?php 
    }
    ?>

			<tr id="activity-notification-settings-replies">
				<td>&nbsp;</td>
				<td><?php 
    _e("A member replies to an update or comment you've posted", 'buddypress');
    ?>
</td>
				<td class="yes"><input type="radio" name="notifications[notification_activity_new_reply]" id="notification-activity-new-reply-yes" value="yes" <?php 
    checked($reply, 'yes', true);
    ?>
/><label for="notification-activity-new-reply-yes" class="bp-screen-reader-text"><?php 
    _e('Yes, send email', 'buddypress');
    ?>
</label></td>
				<td class="no"><input type="radio" name="notifications[notification_activity_new_reply]" id="notification-activity-new-reply-no" value="no" <?php 
    checked($reply, 'no', true);
    ?>
/><label for="notification-activity-new-reply-no" class="bp-screen-reader-text"><?php 
    _e('No, do not send email', 'buddypress');
    ?>
</label></td>
			</tr>

			<?php 
    /**
     * Fires inside the closing </tbody> tag for activity screen notification settings.
     *
     * @since 1.2.0
     */
    do_action('bp_activity_screen_notification_settings');
    ?>
		</tbody>
	</table>

<?php 
}
예제 #29
0
 function kleo_ajax_search()
 {
     //if "s" input is missing exit
     if (empty($_REQUEST['s']) && empty($_REQUEST['bbp_search'])) {
         die;
     }
     if (!empty($_REQUEST['bbp_search'])) {
         $search_string = $_REQUEST['bbp_search'];
     } else {
         $search_string = $_REQUEST['s'];
     }
     $output = "";
     $context = "any";
     $defaults = array('numberposts' => 4, 'posts_per_page' => 20, 'post_type' => 'any', 'post_status' => 'publish', 'post_password' => '', 'suppress_filters' => false, 's' => $_REQUEST['s']);
     if (isset($_REQUEST['context']) && $_REQUEST['context'] != '') {
         $context = explode(",", $_REQUEST['context']);
         $defaults['post_type'] = $context;
     }
     $defaults = apply_filters('kleo_ajax_query_args', $defaults);
     $the_query = new WP_Query($defaults);
     $posts = $the_query->get_posts();
     $members = array();
     $members['total'] = 0;
     $groups = array();
     $groups['total'] = 0;
     $forums = FALSE;
     if (function_exists('bp_is_active') && ($context == "any" || in_array("members", $context))) {
         $members = bp_core_get_users(array('search_terms' => $search_string, 'per_page' => $defaults['numberposts'], 'populate_extras' => false));
     }
     if (function_exists('bp_is_active') && bp_is_active("groups") && ($context == "any" || in_array("groups", $context))) {
         $groups = groups_get_groups(array('search_terms' => $search_string, 'per_page' => $defaults['numberposts'], 'populate_extras' => false));
     }
     if (class_exists('bbPress') && ($context == "any" || in_array("forum", $context))) {
         $forums = kleo_bbp_get_replies($search_string);
     }
     //if there are no posts, groups nor members
     if (empty($posts) && $members['total'] == 0 && $groups['total'] == 0 && !$forums) {
         $output = "<div class='kleo_ajax_entry ajax_not_found'>";
         $output .= "<div class='ajax_search_content'>";
         $output .= "<i class='icon icon-exclamation-sign'></i> ";
         $output .= __("Sorry, we haven't found anything based on your criteria.", 'kleo_framework');
         $output .= "<br>";
         $output .= __("Please try searching by different terms.", 'kleo_framework');
         $output .= "</div>";
         $output .= "</div>";
         echo $output;
         die;
     }
     //if there are members
     if ($members['total'] != 0) {
         $output .= '<div class="kleo-ajax-part kleo-ajax-type-members">';
         $output .= '<h4><span>' . __("Members", 'kleo_framework') . '</span></h4>';
         foreach ((array) $members['users'] as $member) {
             $image = '<img src="' . bp_core_fetch_avatar(array('item_id' => $member->ID, 'width' => 25, 'height' => 25, 'html' => false)) . '" class="kleo-rounded" alt="">';
             if ($update = bp_get_user_meta($member->ID, 'bp_latest_update', true)) {
                 $latest_activity = char_trim(trim(strip_tags(bp_create_excerpt($update['content'], 50, "..."))));
             } else {
                 $latest_activity = '';
             }
             $output .= "<div class ='kleo_ajax_entry'>";
             $output .= "<div class='ajax_search_image'>{$image}</div>";
             $output .= "<div class='ajax_search_content'>";
             $output .= "<a href='" . bp_core_get_user_domain($member->ID) . "' class='search_title'>";
             $output .= $member->display_name;
             $output .= "</a>";
             $output .= "<span class='search_excerpt'>";
             $output .= $latest_activity;
             $output .= "</span>";
             $output .= "</div>";
             $output .= "</div>";
         }
         $output .= "<a class='ajax_view_all' href='" . bp_get_members_directory_permalink() . "?s=" . $search_string . "'>" . __('View member results', 'kleo_framework') . "</a>";
         $output .= "</div>";
     }
     //if there are groups
     if ($groups['total'] != 0) {
         $output .= '<div class="kleo-ajax-part kleo-ajax-type-groups">';
         $output .= '<h4><span>' . __("Groups", 'kleo_framework') . '</span></h4>';
         foreach ((array) $groups['groups'] as $group) {
             $image = '<img src="' . bp_core_fetch_avatar(array('item_id' => $group->id, 'object' => 'group', 'width' => 25, 'height' => 25, 'html' => false)) . '" class="kleo-rounded" alt="">';
             $output .= "<div class ='kleo_ajax_entry'>";
             $output .= "<div class='ajax_search_image'>{$image}</div>";
             $output .= "<div class='ajax_search_content'>";
             $output .= "<a href='" . bp_get_group_permalink($group) . "' class='search_title'>";
             $output .= $group->name;
             $output .= "</a>";
             $output .= "</div>";
             $output .= "</div>";
         }
         $output .= "<a class='ajax_view_all' href='" . bp_get_groups_directory_permalink() . "?s=" . $search_string . "'>" . __('View group results', 'kleo_framework') . "</a>";
         $output .= "</div>";
     }
     //if there are posts
     if (!empty($posts)) {
         $post_types = array();
         $post_type_obj = array();
         foreach ($posts as $post) {
             $post_types[$post->post_type][] = $post;
             if (empty($post_type_obj[$post->post_type])) {
                 $post_type_obj[$post->post_type] = get_post_type_object($post->post_type);
             }
         }
         foreach ($post_types as $ptype => $post_type) {
             $output .= '<div class="kleo-ajax-part kleo-ajax-type-' . esc_attr($post_type_obj[$ptype]->name) . '">';
             if (isset($post_type_obj[$ptype]->labels->name)) {
                 $output .= "<h4><span>" . $post_type_obj[$ptype]->labels->name . "</span></h4>";
             } else {
                 $output .= "<hr>";
             }
             $count = 0;
             foreach ($post_type as $post) {
                 $count++;
                 if ($count > 4) {
                     continue;
                 }
                 $format = get_post_format($post->ID);
                 if ($img_url = kleo_get_post_thumbnail_url($post->ID)) {
                     $image = aq_resize($img_url, 44, 44, true, true, true);
                     if (!$image) {
                         $image = $img_url;
                     }
                     $image = '<img src="' . $image . '" class="kleo-rounded">';
                 } else {
                     if ($format == 'video') {
                         $image = "<i class='icon icon-video'></i>";
                     } elseif ($format == 'image' || $format == 'gallery') {
                         $image = "<i class='icon icon-picture'></i>";
                     } else {
                         $image = "<i class='icon icon-link'></i>";
                     }
                 }
                 $excerpt = "";
                 if (!empty($post->post_content)) {
                     $excerpt = char_trim(trim(strip_tags(strip_shortcodes($post->post_content))), 40, "...");
                 }
                 $link = apply_filters('kleo_custom_url', get_permalink($post->ID));
                 $classes = "format-" . $format;
                 $output .= "<div class ='kleo_ajax_entry {$classes}'>";
                 $output .= "<div class='ajax_search_image'>{$image}</div>";
                 $output .= "<div class='ajax_search_content'>";
                 $output .= "<a href='{$link}' class='search_title'>";
                 $output .= get_the_title($post->ID);
                 $output .= "</a>";
                 $output .= "<span class='search_excerpt'>";
                 $output .= $excerpt;
                 $output .= "</span>";
                 $output .= "</div>";
                 $output .= "</div>";
             }
             $output .= '</div>';
         }
         $output .= "<a class='ajax_view_all' href='" . home_url('/') . '?s=' . $search_string . "'>" . __('View all results', 'kleo_framework') . "</a>";
     }
     /* Forums topics search */
     if (!empty($forums)) {
         $output .= '<div class="kleo-ajax-part kleo-ajax-type-forums">';
         $output .= '<h4><span>' . __("Forums", 'kleo_framework') . '</span></h4>';
         $i = 0;
         foreach ($forums as $fk => $forum) {
             $i++;
             if ($i <= 4) {
                 $image = "<i class='icon icon-chat-1'></i>";
                 $output .= "<div class ='kleo_ajax_entry'>";
                 $output .= "<div class='ajax_search_image'>{$image}</div>";
                 $output .= "<div class='ajax_search_content'>";
                 $output .= "<a href='" . $forum['url'] . "' class='search_title'>";
                 $output .= $forum['name'];
                 $output .= "</a>";
                 //$output .= "<span class='search_excerpt'>";
                 //$output .= $latest_activity;
                 //$output .= "</span>";
                 $output .= "</div>";
                 $output .= "</div>";
             }
         }
         $output .= "<a class='ajax_view_all' href='" . bbp_get_search_url() . "?bbp_search=" . $search_string . "'>" . __('View forum results', 'kleo_framework') . "</a>";
         $output .= "</div>";
     }
     echo $output;
     die;
 }
/**
 * Add Friends-related settings to the Settings > Notifications page.
 *
 * @since 1.0.0
 */
function friends_screen_notification_settings()
{
    if (!($send_requests = bp_get_user_meta(bp_displayed_user_id(), 'notification_friends_friendship_request', true))) {
        $send_requests = 'yes';
    }
    if (!($accept_requests = bp_get_user_meta(bp_displayed_user_id(), 'notification_friends_friendship_accepted', true))) {
        $accept_requests = 'yes';
    }
    ?>

	<table class="notification-settings" id="friends-notification-settings">
		<thead>
			<tr>
				<th class="icon"></th>
				<th class="title"><?php 
    _ex('Friends', 'Friend settings on notification settings page', 'buddypress');
    ?>
</th>
				<th class="yes"><?php 
    _e('Yes', 'buddypress');
    ?>
</th>
				<th class="no"><?php 
    _e('No', 'buddypress');
    ?>
</th>
			</tr>
		</thead>

		<tbody>
			<tr id="friends-notification-settings-request">
				<td></td>
				<td><?php 
    _ex('A member sends you a friendship request', 'Friend settings on notification settings page', 'buddypress');
    ?>
</td>
				<td class="yes"><input type="radio" name="notifications[notification_friends_friendship_request]" id="notification-friends-friendship-request-yes" value="yes" <?php 
    checked($send_requests, 'yes', true);
    ?>
/><label for="notification-friends-friendship-request-yes" class="bp-screen-reader-text"><?php 
    /* translators: accessibility text */
    _e('Yes, send email', 'buddypress');
    ?>
</label></td>
				<td class="no"><input type="radio" name="notifications[notification_friends_friendship_request]" id="notification-friends-friendship-request-no" value="no" <?php 
    checked($send_requests, 'no', true);
    ?>
/><label for="notification-friends-friendship-request-no" class="bp-screen-reader-text"><?php 
    /* translators: accessibility text */
    _e('No, do not send email', 'buddypress');
    ?>
</label></td>
			</tr>
			<tr id="friends-notification-settings-accepted">
				<td></td>
				<td><?php 
    _ex('A member accepts your friendship request', 'Friend settings on notification settings page', 'buddypress');
    ?>
</td>
				<td class="yes"><input type="radio" name="notifications[notification_friends_friendship_accepted]" id="notification-friends-friendship-accepted-yes" value="yes" <?php 
    checked($accept_requests, 'yes', true);
    ?>
/><label for="notification-friends-friendship-accepted-yes" class="bp-screen-reader-text"><?php 
    /* translators: accessibility text */
    _e('Yes, send email', 'buddypress');
    ?>
</label></td>
				<td class="no"><input type="radio" name="notifications[notification_friends_friendship_accepted]" id="notification-friends-friendship-accepted-no" value="no" <?php 
    checked($accept_requests, 'no', true);
    ?>
/><label for="notification-friends-friendship-accepted-no" class="bp-screen-reader-text"><?php 
    /* translators: accessibility text */
    _e('No, do not send email', 'buddypress');
    ?>
</label></td>
			</tr>

			<?php 
    /**
     * Fires after the last table row on the friends notification screen.
     *
     * @since 1.0.0
     */
    do_action('friends_screen_notification_settings');
    ?>

		</tbody>
	</table>

<?php 
}