• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP bp_core_add_notification函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中bp_core_add_notification函数的典型用法代码示例。如果您正苦于以下问题:PHP bp_core_add_notification函数的具体用法?PHP bp_core_add_notification怎么用?PHP bp_core_add_notification使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了bp_core_add_notification函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: xprofile_record_wire_post_notification

/**
 * xprofile_record_wire_post_notification()
 *
 * Records a notification for a new profile wire post to the database and sends out a notification
 * email if the user has this setting enabled.
 * 
 * @package BuddyPress XProfile
 * @param $wire_post_id The ID of the wire post
 * @param $user_id The id of the user that the wire post was sent to
 * @param $poster_id The id of the user who wrote the wire post
 * @global $bp The global BuddyPress settings variable created in bp_core_setup_globals()
 * @global $current_user WordPress global variable containing current logged in user information
 * @uses bp_is_home() Returns true if the current user being viewed is equal the logged in user
 * @uses get_usermeta() Get a user meta value based on meta key from wp_usermeta
 * @uses BP_Wire_Post Class Creates a new wire post object based on ID.
 * @uses site_url Returns the site URL
 * @uses wp_mail Sends an email
 */
function xprofile_record_wire_post_notification($wire_post_id, $user_id, $poster_id)
{
    global $bp, $current_user;
    if ($bp->current_component == $bp->wire->slug && !bp_is_home()) {
        bp_core_add_notification($poster_id, $user_id, 'xprofile', 'new_wire_post');
        if (!get_usermeta($bp->loggedin_user->id, 'notification_profile_wire_post') || 'yes' == get_usermeta($bp->loggedin_user->id, 'notification_profile_wire_post')) {
            $poster_name = bp_fetch_user_fullname($poster_id, false);
            $wire_post = new BP_Wire_Post($bp->profile->table_name_wire, $wire_post_id, true);
            $ud = get_userdata($user_id);
            $wire_link = site_url() . '/' . BP_MEMBERS_SLUG . '/' . $ud->user_login . '/wire';
            $settings_link = site_url() . '/' . BP_MEMBERS_SLUG . '/' . $ud->user_login . '/settings/notifications';
            // Set up and send the message
            $to = $ud->user_email;
            $subject = '[' . get_blog_option(1, 'blogname') . '] ' . sprintf(__('%s posted on your wire.', 'buddypress'), stripslashes($poster_name));
            $message = sprintf(__('%s posted on your wire:

"%s"

To view your wire: %s

---------------------
', 'buddypress'), $poster_name, stripslashes($wire_post->content), $wire_link);
            $message .= sprintf(__('To disable these notifications please log in and go to: %s', 'buddypress'), $settings_link);
            // Send it
            wp_mail($to, $subject, $message);
        }
    }
}
开发者ID:alvaropereyra,项目名称:shrekcms,代码行数:46,代码来源:bp-xprofile-notifications.php


示例2: bp_activity_at_message_notification

/**
 * Sends an email notification and a BP notification when someone mentions you in an update
 *
 * @since BuddyPress (1.2)
 *
 * @param int $activity_id The id of the activity update
 * @param int $receiver_user_id The unique user_id of the user who is receiving the update
 *
 * @uses bp_core_add_notification()
 * @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_is_active()
 * @uses bp_is_group()
 * @uses bp_get_current_group_name()
 * @uses apply_filters() To call the 'bp_activity_at_message_notification_to' hook
 * @uses apply_filters() To call the 'bp_activity_at_message_notification_subject' hook
 * @uses apply_filters() To call the 'bp_activity_at_message_notification_message' hook
 * @uses wp_mail()
 * @uses do_action() To call the 'bp_activity_sent_mention_email' hook
 */
function bp_activity_at_message_notification($activity_id, $receiver_user_id)
{
    // Don't leave multiple notifications for the same activity item
    $notifications = BP_Core_Notification::get_all_for_user($receiver_user_id, 'all');
    foreach ($notifications as $notification) {
        if ($activity_id == $notification->item_id) {
            return;
        }
    }
    $activity = new BP_Activity_Activity($activity_id);
    $subject = '';
    $message = '';
    $content = '';
    // Add the BP notification
    bp_core_add_notification($activity_id, $receiver_user_id, 'activity', 'new_at_mention', $activity->user_id);
    // Now email the user with the contents of the message (if they have enabled email notifications)
    if ('no' != bp_get_user_meta($receiver_user_id, 'notification_activity_new_mention', true)) {
        $poster_name = bp_core_get_user_displayname($activity->user_id);
        $message_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($receiver_user_id) . $settings_slug . '/notifications/';
        $poster_name = stripslashes($poster_name);
        $content = bp_activity_filter_kses(strip_tags(stripslashes($activity->content)));
        // Set up and send the message
        $ud = bp_core_get_core_userdata($receiver_user_id);
        $to = $ud->user_email;
        $subject = bp_get_email_subject(array('text' => sprintf(__('%s mentioned you in an update', 'buddypress'), $poster_name)));
        if (bp_is_active('groups') && bp_is_group()) {
            $message = sprintf(__('%1$s mentioned you in the group "%2$s":

"%3$s"

To view and respond to the message, log in and visit: %4$s

---------------------
', 'buddypress'), $poster_name, bp_get_current_group_name(), $content, $message_link);
        } else {
            $message = sprintf(__('%1$s mentioned you in an update:

"%2$s"

To view and respond to the message, log in and visit: %3$s

---------------------
', 'buddypress'), $poster_name, $content, $message_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_at_message_notification_to', $to);
        $subject = apply_filters('bp_activity_at_message_notification_subject', $subject, $poster_name);
        $message = apply_filters('bp_activity_at_message_notification_message', $message, $poster_name, $content, $message_link, $settings_link);
        wp_mail($to, $subject, $message);
    }
    do_action('bp_activity_sent_mention_email', $activity, $subject, $message, $content);
}
开发者ID:pyropictures,项目名称:wordpress-plugins,代码行数:85,代码来源:bp-activity-notifications.php


示例3: social_articles_send_notification

function social_articles_send_notification($id)
{
    global $bp, $socialArticles;
    $savedPost = get_post($id);
    $notification_already_sent = get_post_meta($id, 'notification_already_sent', true);
    if (empty($notification_already_sent) && function_exists("friends_get_friend_user_ids") && $savedPost->post_status == "publish" && $savedPost->post_type == "post" && !wp_is_post_revision($id) && $socialArticles->options['bp_notifications'] == "true") {
        $friends = friends_get_friend_user_ids($savedPost->post_author);
        foreach ($friends as $friend) {
            bp_core_add_notification($savedPost->ID, $friend, $bp->social_articles->id, 'new_article' . $savedPost->ID, $savedPost->post_author);
        }
        bp_core_add_notification($savedPost->ID, $savedPost->post_author, $bp->social_articles->id, 'new_article' . $savedPost->ID, -1);
        update_post_meta($id, 'notification_already_sent', true);
    }
}
开发者ID:Dannypid,项目名称:Tinymce-social-articles-1.8,代码行数:14,代码来源:social-articles-functions.php


示例4: bp_activity_at_message_notification

/**
 * Sends an email notification and a BP notification when someone mentions you in an update
 *
 * @since 1.2.0
 *
 * @param int $activity_id The id of the activity update
 * @param int $receiver_user_id The unique user_id of the user who is receiving the update
 *
 * @global object $bp BuddyPress global settings
 * @uses bp_core_add_notification()
 * @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_is_active()
 * @uses bp_is_group()
 * @uses bp_get_current_group_name()
 * @uses apply_filters() To call the 'bp_activity_at_message_notification_to' hook
 * @uses apply_filters() To call the 'bp_activity_at_message_notification_subject' hook
 * @uses apply_filters() To call the 'bp_activity_at_message_notification_message' hook
 * @uses nxt_mail()
 * @uses do_action() To call the 'bp_activity_sent_mention_email' hook
 */
function bp_activity_at_message_notification($activity_id, $receiver_user_id)
{
    global $bp;
    $activity = new BP_Activity_Activity($activity_id);
    $subject = '';
    $message = '';
    // Add the BP notification
    bp_core_add_notification($activity_id, $receiver_user_id, 'activity', 'new_at_mention', $activity->user_id);
    // Now email the user with the contents of the message (if they have enabled email notifications)
    if ('no' != bp_get_user_meta($receiver_user_id, 'notification_activity_new_mention', true)) {
        $poster_name = bp_core_get_user_displayname($activity->user_id);
        $message_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($receiver_user_id) . $settings_slug . '/notifications/';
        $poster_name = stripslashes($poster_name);
        $content = bp_activity_filter_kses(strip_tags(stripslashes($activity->content)));
        // Set up and send the message
        $ud = bp_core_get_core_userdata($receiver_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 mentioned you in an update', 'buddypress'), $poster_name);
        if (bp_is_active('groups') && bp_is_group()) {
            $message = sprintf(__('%1$s mentioned you in the group "%2$s":

"%3$s"

To view and respond to the message, log in and visit: %4$s

---------------------
', 'buddypress'), $poster_name, bp_get_current_group_name(), $content, $message_link);
        } else {
            $message = sprintf(__('%1$s mentioned you in an update:

"%2$s"

To view and respond to the message, log in and visit: %3$s

---------------------
', 'buddypress'), $poster_name, $content, $message_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_at_message_notification_to', $to);
        $subject = apply_filters('bp_activity_at_message_notification_subject', $subject, $poster_name);
        $message = apply_filters('bp_activity_at_message_notification_message', $message, $poster_name, $content, $message_link, $settings_link);
        nxt_mail($to, $subject, $message);
    }
    do_action('bp_activity_sent_mention_email', $activity, $subject, $message, $content);
}
开发者ID:nxtclass,项目名称:NXTClass-Plugin,代码行数:77,代码来源:bp-activity-notifications.php


示例5: bp_em_add_booking_notification

/**
 * Catch booking saves and add a BP notification.
 * @param boolean $result
 * @param EM_Booking $EM_Booking
 * @return boolean
 */
function bp_em_add_booking_notification($result, $EM_Booking)
{
    global $bp;
    if (get_option('dbem_bookings_approval') && $EM_Booking->get_status() == 0) {
        $action = 'pending_booking';
    } elseif ($EM_Booking->get_status() == 1 || get_option('dbem_bookings_approval') && $EM_Booking->get_status() == 0) {
        $action = 'confirmed_booking';
    } elseif ($EM_Booking->get_status() == 3) {
        $action = 'cancelled_booking';
    }
    if (!empty($action)) {
        bp_core_add_notification($EM_Booking->booking_id, $EM_Booking->get_event()->get_contact()->ID, 'events', $action);
    }
    return $result;
}
开发者ID:adisonc,项目名称:MaineLearning,代码行数:21,代码来源:bp-em-notifications.php


示例6: bp_follow_notifications_add_on_follow

/**
 * Adds notification when a user follows another user.
 *
 * @since 1.2.1
 *
 * @param object $follow The BP_Follow object.
 */
function bp_follow_notifications_add_on_follow(BP_Follow $follow)
{
    // this only applies to users
    if (!empty($follow->follow_type)) {
        return;
    }
    // Add a screen notification
    //
    // BP 1.9+
    if (bp_is_active('notifications')) {
        bp_notifications_add_notification(array('item_id' => $follow->follower_id, 'user_id' => $follow->leader_id, 'component_name' => buddypress()->follow->id, 'component_action' => 'new_follow'));
        // BP < 1.9 - add notifications the old way
    } elseif (!class_exists('BP_Core_Login_Widget')) {
        global $bp;
        bp_core_add_notification($follow->follower_id, $follow->leader_id, $bp->follow->id, 'new_follow');
    }
    // Add an email notification
    bp_follow_new_follow_email_notification(array('leader_id' => $follow->leader_id, 'follower_id' => $follow->follower_id));
}
开发者ID:vikramshaw,项目名称:buddypress-followers,代码行数:26,代码来源:notifications.php


示例7: ac_notifier_notify

/**
 * storing notification for users
 * notify all the users who have commented, or who was the original poster of the update, when someone comments
 * hook to activity_comment_posted action
 */
function ac_notifier_notify($comment_id, $params)
{
    global $bp;
    extract($params);
    $users = ac_notifier_find_involved_persons($activity_id);
    $activity = new BP_Activity_Activity($activity_id);
    //since there is a bug in bp 1.2.9 and causes trouble with private notificatin, so let us  not notify for any of the private activities
    if ($activity->hide_sitewide) {
        return;
    }
    //push the original poster user_id, if the original poster has not commented on his/her status yet
    if (!in_array($activity->user_id, $users) && $bp->loggedin_user->id != $activity->user_id) {
        //if someone else is commenting
        array_push($users, $activity->user_id);
    }
    foreach ((array) $users as $user_id) {
        //create a notification
        bp_core_add_notification($activity_id, $user_id, $bp->ac_notifier->id, 'new_activity_comment_' . $activity_id);
        //a hack to not allow grouping by component,action, rather group by component and individual action item
    }
}
开发者ID:pyropictures,项目名称:wordpress-plugins,代码行数:26,代码来源:ac-notify.php


示例8: friends_accept_friendship

function friends_accept_friendship($friendship_id)
{
    global $bp;
    $friendship = new BP_Friends_Friendship($friendship_id, true, false);
    if (!$friendship->is_confirmed && BP_Friends_Friendship::accept($friendship_id)) {
        friends_update_friend_totals($friendship->initiator_user_id, $friendship->friend_user_id);
        // Remove the friend request notice
        bp_core_delete_notifications_by_item_id($friendship->friend_user_id, $friendship->initiator_user_id, $bp->friends->id, 'friendship_request');
        // Add a friend accepted notice for the initiating user
        bp_core_add_notification($friendship->friend_user_id, $friendship->initiator_user_id, $bp->friends->id, 'friendship_accepted');
        $initiator_link = bp_core_get_userlink($friendship->initiator_user_id);
        $friend_link = bp_core_get_userlink($friendship->friend_user_id);
        // Record in activity streams for the initiator
        friends_record_activity(array('user_id' => $friendship->initiator_user_id, 'type' => 'friendship_created', 'action' => apply_filters('friends_activity_friendship_accepted_action', sprintf(__('%1$s and %2$s are now friends', 'buddypress'), $initiator_link, $friend_link), $friendship), 'item_id' => $friendship_id, 'secondary_item_id' => $friendship->friend_user_id));
        // Record in activity streams for the friend
        friends_record_activity(array('user_id' => $friendship->friend_user_id, 'type' => 'friendship_created', 'action' => apply_filters('friends_activity_friendship_accepted_action', sprintf(__('%1$s and %2$s are now friends', 'buddypress'), $friend_link, $initiator_link), $friendship), 'item_id' => $friendship_id, 'secondary_item_id' => $friendship->initiator_user_id, 'hide_sitewide' => true));
        // Send the email notification
        friends_notification_accepted_request($friendship->id, $friendship->initiator_user_id, $friendship->friend_user_id);
        do_action('friends_friendship_accepted', $friendship->id, $friendship->initiator_user_id, $friendship->friend_user_id);
        return true;
    }
    return false;
}
开发者ID:nxtclass,项目名称:NXTClass,代码行数:23,代码来源:bp-friends-functions.php


示例9: bp_zoneideas_send_highfive

/**
 * bp_zoneideas_send_high_five()
 *
 * Sends a high five message to a user. Registers an notification to the user
 * via their notifications menu, as well as sends an email to the user.
 *
 * Also records an activity stream item saying "User 1 high-fived User 2".
 */
function bp_zoneideas_send_highfive($to_user_id, $from_user_id)
{
    global $bp;
    if (!check_admin_referer('bp_zoneideas_send_high_five')) {
        return false;
    }
    /**
     * We'll store high-fives as usermeta, so we don't actually need
     * to do any database querying. If we did, and we were storing them
     * in a custom DB table, we'd want to reference a function in
     * bp-zoneideas-classes.php that would run the SQL query.
     */
    /* Get existing fives */
    $existing_fives = maybe_unserialize(get_usermeta($to_user_id, 'high-fives'));
    /* Check to see if the user has already high-fived. That's okay, but lets not
     * store duplicate high-fives in the database. What's the point, right?
     */
    if (!in_array($from_user_id, (array) $existing_fives)) {
        $existing_fives[] = (int) $from_user_id;
        /* Now wrap it up and fire it back to the database overlords. */
        update_usermeta($to_user_id, 'high-fives', serialize($existing_fives));
    }
    /***
     * Now we've registered the new high-five, lets work on some notification and activity
     * stream magic. 
     */
    /***
     * Post a screen notification to the user's notifications menu.
     * Remember, like activity streams we need to tell the activity stream component how to format
     * this notification in bp_zoneideas_format_notifications() using the 'new_high_five' action.
     */
    bp_core_add_notification($from_user_id, $to_user_id, $bp->zoneideas->slug, 'new_high_five');
    /* Now record the new 'new_high_five' activity item */
    bp_zoneideas_record_activity(array('item_id' => $to_user_id, 'user_id' => $from_user_id, 'component_name' => $bp->zoneideas->slug, 'component_action' => 'new_high_five', 'is_private' => 0));
    /* We'll use this do_action call to send the email notification. See bp-zoneideas-notifications.php */
    do_action('bp_zoneideas_send_high_five', $to_user_id, $from_user_id);
    return true;
}
开发者ID:BGCX261,项目名称:zoneideas-svn-to-git,代码行数:46,代码来源:bp-zoneideas.php


示例10: groups_notification_group_invites

function groups_notification_group_invites(&$group, &$member, $inviter_user_id)
{
    global $bp;
    $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_link = bp_core_get_user_domain($invited_user_id) . bp_get_settings_slug() . '/notifications/';
        $invited_link = bp_core_get_user_domain($invited_user_id);
        $invites_link = $invited_link . bp_get_groups_slug() . '/invites';
        // Set up and send the message
        $to = $invited_ud->user_email;
        $sitename = wp_specialchars_decode(get_blog_option(bp_get_root_blog_id(), 'blogname'), ENT_QUOTES);
        $subject = '[' . $sitename . '] ' . 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);
        $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);
    }
}
开发者ID:newington,项目名称:buddypress,代码行数:41,代码来源:bp-groups-notifications.php


示例11: bp_compliments_notifications_add_on_compliment

/**
 * Add a notification when a compliment get submitted.
 *
 * @since 0.0.2
 * @package BuddyPress_Compliments
 *
 * @global object $bp BuddyPress instance.
 * @param BP_Compliments $compliment The compliment object.
 */
function bp_compliments_notifications_add_on_compliment(BP_Compliments $compliment)
{
    // Add a screen notification
    // BP 1.9+
    if (bp_is_active('notifications')) {
        bp_notifications_add_notification(array('item_id' => $compliment->sender_id, 'user_id' => $compliment->receiver_id, 'secondary_item_id' => $compliment->id, 'component_name' => buddypress()->compliments->id, 'component_action' => 'new_compliment'));
        // BP < 1.9 - add notifications the old way
    } elseif (!class_exists('BP_Core_Login_Widget')) {
        global $bp;
        bp_core_add_notification($compliment->sender_id, $compliment->receiver_id, $bp->compliments->id, 'new_compliment');
    }
    // Add an email notification
    bp_compliments_new_compliment_email_notification(array('receiver_id' => $compliment->receiver_id, 'sender_id' => $compliment->sender_id));
}
开发者ID:kprajapatii,项目名称:buddypress-compliments,代码行数:23,代码来源:bp-compliments-notifications.php


示例12: friends_accept_friendship

function friends_accept_friendship($friendship_id)
{
    /* Check the nonce */
    if (!check_admin_referer('friends_accept_friendship')) {
        return false;
    }
    $friendship = new BP_Friends_Friendship($friendship_id, true, false);
    if (!$friendship->is_confirmed && BP_Friends_Friendship::accept($friendship_id)) {
        friends_update_friend_totals($friendship->initiator_user_id, $friendship->friend_user_id);
        // Remove the friend request notice
        bp_core_delete_notifications_for_user_by_item_id($friendship->friend_user_id, $friendship->initiator_user_id, 'friends', 'friendship_request');
        // Add a friend accepted notice for the initiating user
        bp_core_add_notification($friendship->friend_user_id, $friendship->initiator_user_id, 'friends', 'friendship_accepted');
        // Record in activity streams
        friends_record_activity(array('item_id' => $friendship_id, 'component_name' => $bp->friends->slug, 'component_action' => 'friendship_accepted', 'is_private' => 0, 'user_id' => $friendship->initiator_user_id, 'secondary_user_id' => $friendship->friend_user_id));
        // Send the email notification
        require_once BP_PLUGIN_DIR . '/bp-friends/bp-friends-notifications.php';
        friends_notification_accepted_request($friendship->id, $friendship->initiator_user_id, $friendship->friend_user_id);
        do_action('friends_friendship_accepted', $friendship->id, $friendship->initiator_user_id, $friendship->friend_user_id);
        return true;
    }
    return false;
}
开发者ID:alvaropereyra,项目名称:shrekcms,代码行数:23,代码来源:bp-friends.php


示例13: groups_notification_group_invites

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);
    }
}
开发者ID:pyropictures,项目名称:wordpress-plugins,代码行数:44,代码来源:bp-groups-notifications.php


示例14: xprofile_action_new_wire_post

/**
 * xprofile_action_new_wire_post()
 *
 * Posts a new wire post to the users profile wire. 
 * 
 * @package BuddyPress XProfile
 * @global $bp The global BuddyPress settings variable created in bp_core_setup_globals()
 * @uses bp_wire_new_post() Adds a new wire post to a specific wire using the ID of the item passed and the table name.
 * @uses bp_core_add_message() Adds an error/success message to the session to be displayed on the next page load.
 * @uses bp_core_redirect() Safe redirects to a new page using the wp_redirect() function
 */
function xprofile_action_new_wire_post()
{
    global $bp;
    if ($bp->current_component != $bp->wire->slug) {
        return false;
    }
    if ('post' != $bp->current_action) {
        return false;
    }
    /* Check the nonce */
    if (!check_admin_referer('bp_wire_post')) {
        return false;
    }
    if (!($wire_post_id = bp_wire_new_post($bp->displayed_user->id, $_POST['wire-post-textarea'], $bp->profile->slug, false, $bp->profile->table_name_wire))) {
        bp_core_add_message(__('Wire message could not be posted. Please try again.', 'buddypress'), 'error');
    } else {
        bp_core_add_message(__('Wire message successfully posted.', 'buddypress'));
        if (!bp_is_home()) {
            /* Record the notification for the user */
            bp_core_add_notification($bp->loggedin_user->id, $bp->displayed_user->id, 'profile', 'new_wire_post');
        }
        do_action('xprofile_new_wire_post', $wire_post_id);
    }
    if (!strpos($_SERVER['HTTP_REFERER'], $bp->wire->slug)) {
        bp_core_redirect($bp->displayed_user->domain);
    } else {
        bp_core_redirect($bp->displayed_user->domain . $bp->wire->slug);
    }
}
开发者ID:alvaropereyra,项目名称:shrekcms,代码行数:40,代码来源:bp-xprofile.php


示例15: add_notification

 /**
  * Adds a new post notification
  * @uses publish_post action
  * @param int $post_id
  * @param obj $post
  * @return void
  */
 public function add_notification($post_id, $post)
 {
     // Bail early if post_type isn't post or if post has already been published
     if (get_post_type($post) !== 'post' || $_POST['original_post_status'] == 'publish') {
         return;
     }
     // Get all subscribers
     $subscribers = get_option('bp_site_subscriber_subscribers', array());
     // Bail early if no subscribers
     if (empty($subscribers)) {
         return;
     }
     $subscribers = array_values($subscribers);
     $subscribers = array_unique($subscribers);
     $link = get_permalink($post_id);
     $title = get_the_title($post_id);
     $site_name = get_option('blogname');
     foreach ($subscribers as $subscriber) {
         if ($subscriber != $post->post_author && !in_array($subscriber, $sent)) {
             // Notify
             bp_core_add_notification($post_id, $subscriber, $this->id, 'new_post_' . $post_id, get_current_blog_id());
             // Mail
             if ('no' != bp_get_user_meta($subscriber, 'bp-site-subscriber-send-email', true)) {
                 $user = get_userdata($subscriber);
                 $email = $user->user_email;
                 $profile_link = bp_core_get_user_domain($subscriber);
                 $subject = sprintf(__('New post on the site %s', 'bp-site-subscriber'), $site_name);
                 $message = sprintf(__("New post %s (%s) on the site %s \n\n--------------------\n\n Go to your profile to disable these emails: %s", 'bp-site-subscriber'), $title, $link, $site_name, $profile_link);
                 wp_mail($email, $subject, $message);
             }
         }
     }
 }
开发者ID:lakrisgubben,项目名称:BP-Site-Subscriber,代码行数:40,代码来源:notifier.php


示例16: bp_gtm_edit_g_task

 protected function bp_gtm_edit_g_task($data)
 {
     global $bp, $wpdb;
     if (!check_admin_referer('bp_gtm_edit_task')) {
         return false;
     }
     $task_id = $_POST['task_id'];
     if (!$project_id) {
         $project_id = $_POST['task_project'];
     }
     $name = apply_filters('bp_gtm_task_name_content', $_POST['task_name']);
     $description = apply_filters('bp_gtm_task_desc_content', $_POST['task_desc']);
     $status = bp_gtm_get_project_status($project_id);
     // resps workaround
     if (!empty($_POST['user_ids'])) {
         $task_resps_old = $_POST['user_ids'];
         // array{ slaFFik: 0, bot1: 1, ... }
     } else {
         $task_resps_old = array();
     }
     $resps = (array) $task_resps_old;
     bp_gtm_change_user_group_role($change_roles, $project_id, $task_id);
     // todo smth with this:
     if (count($resps) > 0) {
         bp_gtm_save_g_resps($task_id, $_POST['task_project'], $_POST['task_group'], $resps);
         $task_resps = implode(' ', $resps);
         // make resps in a line to save in DB
     } else {
         $resps[] = bp_core_get_username($_POST['task_creator']);
         bp_gtm_save_g_resps($task_id, $_POST['task_project'], $_POST['task_group'], $resps);
         $task_resps = bp_core_get_username($_POST['task_creator']);
     }
     // update task
     $updated_task = $wpdb->query($wpdb->prepare("\n            UPDATE " . $bp->gtm->table_tasks . "\n            SET `name` = %s, `desc` = %s, `status` = %s, `resp_id` = %s, `project_id` = %d, `deadline` = %s\n            WHERE `group_id` = %d AND `id` = %d\n            ", $name, $description, $status, $task_resps, $_POST['task_project'], bp_gtm_covert_date($_POST['task_deadline']), $_POST['task_group'], $task_id));
     // delete old tags
     $updated_tag = $wpdb->query($wpdb->prepare("DELETE FROM " . $bp->gtm->table_taxon . " WHERE `task_id` = %d AND `taxon` = 'tag'", $task_id));
     // get rid of unnecessary chars in existed tags
     $this->bp_gtm_insert_term($_POST['task_tag_names'], '', $project_id, 'tag', $task_id);
     // update cats
     $updated_cat = $wpdb->query($wpdb->prepare("DELETE FROM " . $bp->gtm->table_taxon . " WHERE `task_id` = %d AND `taxon` = 'cat'", $task_id));
     $this->bp_gtm_insert_term($_POST['task_old_cats'], $_POST['project_cats'], $project_id, 'cat', $task_id);
     // display user message
     if ($updated_task != null || $updated_cat != null || $updated_tag != null) {
         if (count($resps) > 0) {
             foreach ((array) $resps as $resp) {
                 $resp_id = bp_core_get_userid($resp);
                 bp_core_add_notification($task_id, $resp_id, 'gtm', 'task_edited', $_POST['task_group']);
             }
         }
     }
     do_action('bp_gtm_save_discussion_post', 'task', $_POST['task_creator'], false, $task_id, false, $bp->groups->current_group->id);
     bp_core_add_message(__('Task data was successfully updated.', 'bp_gtm'));
     do_action('bp_gtm_edit_task', $_POST['task_group']);
     bp_core_redirect(bp_get_group_permalink($bp->groups->current_group) . $bp->gtm->slug . '/tasks/view/' . $task_id . '?action=edited');
 }
开发者ID:adisonc,项目名称:MaineLearning,代码行数:55,代码来源:bp-gtm-core.php


示例17: dpa_maybe_unlock_achievement

/**
 * Checks if an Achievement's criteria has been met, and if it has, unlock the Achievement.
 * Achievements with an action count of 0 are, effectively, unlocked each time but only
 * the points are added to user's total.
 *
 * @global object $bp BuddyPress global settings
 * @param int $user_id
 * @param string $skip_validation Set to 'force' to skip Achievement validation, e.g. the Achievement is unlocked regardless of its criteria.
 * @since 2.0
 */
function dpa_maybe_unlock_achievement($user_id, $skip_validation = '')
{
    global $bp;
    $action_count = dpa_get_achievement_action_count();
    if (dpa_is_achievement_unlocked() && $action_count > 0) {
        return;
    }
    $counters = get_user_meta($user_id, 'achievements_counters', true);
    $achievement_id = dpa_get_achievement_id();
    $skip_validation = 'force' == $skip_validation;
    // No point saving a count of 1 if the action_count is 1.
    $unlocked = false;
    if (0 === $action_count || 1 == $action_count) {
        $unlocked = true;
    } elseif (!$skip_validation) {
        if (!$counters && !is_array($counters)) {
            $counters = array();
        }
        $counters[$achievement_id] += apply_filters('dpa_achievement_counter_increment_by', 1);
        update_user_meta($user_id, 'achievements_counters', $counters);
        do_action('dpa_achievement_counter_incremented');
    }
    if (!$unlocked && ($skip_validation || $counters[$achievement_id] >= $action_count)) {
        if (isset($counters[$achievement_id])) {
            unset($counters[$achievement_id]);
            update_user_meta($user_id, 'achievements_counters', $counters);
        }
        $unlocked = true;
    }
    // Update points, insert unlocked record into DB and send notifications.
    if ($unlocked) {
        dpa_points_increment(dpa_get_achievement_points(), $user_id);
        // Let Achievements with action_count == 0, which have already been unlocked, only increment points.
        if (dpa_is_achievement_unlocked() && 0 === $action_count) {
            return;
        }
        dpa_unlock_achievement($user_id);
        if (apply_filters('dpa_achievement_unlocked_tell_user', true, $achievement_id, $user_id)) {
            bp_core_add_notification($achievement_id, $user_id, $bp->achievements->id, 'new_achievement', $user_id);
            dpa_record_activity($user_id, dpa_format_activity($user_id, $achievement_id), $achievement_id);
        }
        do_action('dpa_achievement_unlocked', $achievement_id, $user_id);
    }
}
开发者ID:nxtclass,项目名称:NXTClass,代码行数:54,代码来源:achievements-core.php


示例18: messages_new_message

function messages_new_message($args = '')
{
    $defaults = array('sender_id' => bp_loggedin_user_id(), 'thread_id' => false, 'recipients' => false, 'subject' => false, 'content' => false, 'date_sent' => bp_core_current_time());
    $r = wp_parse_args($args, $defaults);
    extract($r, EXTR_SKIP);
    if (empty($sender_id) || empty($content)) {
        return false;
    }
    // Create a new message object
    $message = new BP_Messages_Message();
    $message->thread_id = $thread_id;
    $message->sender_id = $sender_id;
    $message->subject = $subject;
    $message->message = $content;
    $message->date_sent = $date_sent;
    // If we have a thread ID, use the existing recipients, otherwise use the recipients passed
    if (!empty($thread_id)) {
        $thread = new BP_Messages_Thread($thread_id);
        $message->recipients = $thread->get_recipients();
        // Strip the sender from the recipient list if they exist
        if (isset($message->recipients[$sender_id])) {
            unset($message->recipients[$sender_id]);
        }
        if (empty($message->subject)) {
            $message->subject = sprintf(__('Re: %s', 'buddypress'), $thread->messages[0]->subject);
        }
        // No thread ID, so make some adjustments
    } else {
        if (empty($recipients)) {
            return false;
        }
        if (empty($message->subject)) {
            $message->subject = __('No Subject', 'buddypress');
        }
        $recipient_ids = array();
        // Invalid recipients are added to an array, for future enhancements
        $invalid_recipients = array();
        // Loop the recipients and convert all usernames to user_ids where needed
        foreach ((array) $recipients as $recipient) {
            $recipient = trim($recipient);
            if (empty($recipient)) {
                continue;
            }
            $recipient_id = false;
            // input was numeric
            if (is_numeric($recipient)) {
                // do a check against the user ID column first
                if (bp_core_get_core_userdata((int) $recipient)) {
                    $recipient_id = (int) $recipient;
                } else {
                    if (bp_is_username_compatibility_mode()) {
                        $recipient_id = bp_core_get_userid((int) $recipient);
                    } else {
                        $recipient_id = bp_core_get_userid_from_nicename((int) $recipient);
                    }
                }
            } else {
                if (bp_is_username_compatibility_mode()) {
                    $recipient_id = bp_core_get_userid($recipient);
                } else {
                    $recipient_id = bp_core_get_userid_from_nicename($recipient);
                }
            }
            if (!$recipient_id) {
                $invalid_recipients[] = $re 

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP bp_core_add_page_mappings函数代码示例发布时间:2022-05-24
下一篇:
PHP bp_core_add_message函数代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap