/**
 * Format the BuddyBar/Toolbar notifications for the Friends component
 *
 * @package BuddyPress
 *
 * @param string $action The kind of notification being rendered
 * @param int $item_id The primary item id
 * @param int $secondary_item_id The secondary item id
 * @param int $total_items The total number of messaging-related notifications waiting for the user
 * @param string $format 'string' for BuddyBar-compatible notifications; 'array' for WP Toolbar
 */
function friends_format_notifications($action, $item_id, $secondary_item_id, $total_items, $format = 'string')
{
    switch ($action) {
        case 'friendship_accepted':
            $link = trailingslashit(bp_loggedin_user_domain() . bp_get_friends_slug() . '/my-friends');
            // Set up the string and the filter
            if ((int) $total_items > 1) {
                $text = sprintf(__('%d friends accepted your friendship requests', 'buddypress'), (int) $total_items);
                $filter = 'bp_friends_multiple_friendship_accepted_notification';
            } else {
                $text = sprintf(__('%s accepted your friendship request', 'buddypress'), bp_core_get_user_displayname($item_id));
                $filter = 'bp_friends_single_friendship_accepted_notification';
            }
            break;
        case 'friendship_request':
            $link = bp_loggedin_user_domain() . bp_get_friends_slug() . '/requests/?new';
            // Set up the string and the filter
            if ((int) $total_items > 1) {
                $text = sprintf(__('You have %d pending friendship requests', 'buddypress'), (int) $total_items);
                $filter = 'bp_friends_multiple_friendship_request_notification';
            } else {
                $text = sprintf(__('You have a friendship request from %s', 'buddypress'), bp_core_get_user_displayname($item_id));
                $filter = 'bp_friends_single_friendship_request_notification';
            }
            break;
    }
    // Return either an HTML link or an array, depending on the requested format
    if ('string' == $format) {
        $return = apply_filters($filter, '<a href="' . $link . '">' . $text . '</a>', (int) $total_items);
    } else {
        $return = apply_filters($filter, array('link' => $link, 'text' => $text), (int) $total_items);
    }
    do_action('friends_format_notifications', $action, $item_id, $secondary_item_id, $total_items, $return);
    return $return;
}
Esempio n. 2
0
/**
 * Format the BuddyBar/Toolbar notifications
 *
 * @since 2.5.0 bbPress (r5155)
 *
 * @package bbPress
 *
 * @param string $action The kind of notification being rendered
 * @param int $item_id The primary item id
 * @param int $secondary_item_id The secondary item id
 * @param int $total_items The total number of messaging-related notifications waiting for the user
 * @param string $format 'string' for BuddyBar-compatible notifications; 'array' for WP Toolbar
 */
function bbp_format_buddypress_notifications($action, $item_id, $secondary_item_id, $total_items, $format = 'string')
{
    // Bail if not the notification action we are looking for
    if ('bbp_new_reply' !== $action) {
        return $action;
    }
    // New reply notifications
    $topic_id = bbp_get_reply_topic_id($item_id);
    $topic_title = bbp_get_topic_title($topic_id);
    $topic_link = wp_nonce_url(add_query_arg(array('action' => 'bbp_mark_read', 'topic_id' => $topic_id), bbp_get_reply_url($item_id)), 'bbp_mark_topic_' . $topic_id);
    $title_attr = __('Topic Replies', 'bbpress');
    if ((int) $total_items > 1) {
        $text = sprintf(__('You have %d new replies', 'bbpress'), (int) $total_items);
        $filter = 'bbp_multiple_new_subscription_notification';
    } else {
        if (!empty($secondary_item_id)) {
            $text = sprintf(__('You have %d new reply to %2$s from %3$s', 'bbpress'), (int) $total_items, $topic_title, bp_core_get_user_displayname($secondary_item_id));
        } else {
            $text = sprintf(__('You have %d new reply to %s', 'bbpress'), (int) $total_items, $topic_title);
        }
        $filter = 'bbp_single_new_subscription_notification';
    }
    // WordPress Toolbar
    if ('string' === $format) {
        $return = apply_filters($filter, '<a href="' . esc_url($topic_link) . '" title="' . esc_attr($title_attr) . '">' . esc_html($text) . '</a>', (int) $total_items, $text, $topic_link);
        // Deprecated BuddyBar
    } else {
        $return = apply_filters($filter, array('text' => $text, 'link' => $topic_link), $topic_link, (int) $total_items, $text, $topic_title);
    }
    do_action('bbp_format_buddypress_notifications', $action, $item_id, $secondary_item_id, $total_items);
    return $return;
}
Esempio n. 3
0
	/**
	 * populate()
	 *
	 * Populate the instantiated class with data based on the User ID provided.
	 *
	 * @package BuddyPress Core
 	 * @global $userdata WordPress user data for the current logged in user.
	 * @uses bp_core_get_userurl() Returns the URL with no HTML markup for a user based on their user id
	 * @uses bp_core_get_userlink() Returns a HTML formatted link for a user with the user's full name as the link text
	 * @uses bp_core_get_user_email() Returns the email address for the user based on user ID
	 * @uses get_user_meta() WordPress function returns the value of passed usermeta name from usermeta table
	 * @uses bp_core_fetch_avatar() Returns HTML formatted avatar for a user
	 * @uses bp_profile_last_updated_date() Returns the last updated date for a user.
	 */
	function populate() {
		if ( function_exists( 'xprofile_install' ) )
			$this->profile_data = $this->get_profile_data();

		if ( $this->profile_data ) {
			$this->user_url = bp_core_get_user_domain( $this->id, $this->profile_data['user_nicename'], $this->profile_data['user_login'] );
			$this->fullname = esc_attr( $this->profile_data[BP_XPROFILE_FULLNAME_FIELD_NAME]['field_data'] );
			$this->user_link = "<a href='{$this->user_url}' title='{$this->fullname}'>{$this->fullname}</a>";
			$this->email = esc_attr( $this->profile_data['user_email'] );
		} else {
			$this->user_url = bp_core_get_user_domain( $this->id );
			$this->user_link = bp_core_get_userlink( $this->id );
			$this->fullname = esc_attr( bp_core_get_user_displayname( $this->id ) );
			$this->email = esc_attr( bp_core_get_user_email( $this->id ) );
		}

		/* Cache a few things that are fetched often */
		wp_cache_set( 'bp_user_fullname_' . $this->id, $this->fullname, 'bp' );
		wp_cache_set( 'bp_user_email_' . $this->id, $this->email, 'bp' );
		wp_cache_set( 'bp_user_url_' . $this->id, $this->user_url, 'bp' );

		$this->avatar = bp_core_fetch_avatar( array( 'item_id' => $this->id, 'type' => 'full' ) );
		$this->avatar_thumb = bp_core_fetch_avatar( array( 'item_id' => $this->id, 'type' => 'thumb' ) );
		$this->avatar_mini = bp_core_fetch_avatar( array( 'item_id' => $this->id, 'type' => 'thumb', 'width' => 30, 'height' => 30 ) );

		$this->last_active = bp_core_get_last_activity( get_user_meta( $this->id, 'last_activity', true ), __( 'active %s ago', 'buddypress' ) );
	}
/**
 * Notification functions are used to send email notifications to users on specific events
 * They will check to see the users notification settings first, if the user has the notifications
 * turned on, they will be sent a formatted email notification. 
 *
 * You should use your own custom actions to determine when an email notification should be sent.
 */
function bp_chat_send_high_five_notification($to_user_id, $from_user_id)
{
    global $bp;
    /* Let's grab both user's names to use in the email. */
    $sender_name = bp_core_get_user_displayname($from_user_id, false);
    $reciever_name = bp_core_get_user_displayname($to_user_id, false);
    /* We need to check to see if the recipient has opted not to recieve high-five emails */
    if ('no' == get_usermeta((int) $to_user_id, 'notification_chat_new_high_five')) {
        return false;
    }
    /* Get the userdata for the reciever and sender, this will include usernames and emails that we need. */
    $reciever_ud = get_userdata($to_user_id);
    $sender_ud = get_userdata($from_user_id);
    /* Now we need to construct the URL's that we are going to use in the email */
    $sender_profile_link = site_url(BP_MEMBERS_SLUG . '/' . $sender_ud->user_login . '/' . $bp->profile->slug);
    $sender_highfive_link = site_url(BP_MEMBERS_SLUG . '/' . $sender_ud->user_login . '/' . $bp->chat->slug . '/screen-one');
    $reciever_settings_link = site_url(BP_MEMBERS_SLUG . '/' . $reciever_ud->user_login . '/settings/notifications');
    /* Set up and send the message */
    $to = $reciever_ud->user_email;
    $subject = '[' . get_blog_option(1, 'blogname') . '] ' . sprintf(__('%s high-fived you!', 'bp-chat'), stripslashes($sender_name));
    $message = sprintf(__('%s sent you a high-five! Why not send one back?

To see %s\'s profile: %s

To send %s a high five: %s

---------------------
', 'bp-chat'), $sender_name, $sender_name, $sender_profile_link, $sender_name, $sender_highfive_link);
    $message .= sprintf(__('To disable these notifications please log in and go to: %s', 'bp-chat'), $reciever_settings_link);
    // Send it!
    wp_mail($to, $subject, $message);
}
Esempio n. 5
0
function bp_gtm_email_notify()
{
    global $bp;
    // Get user data
    $reciever_name = bp_core_get_user_displayname($_GET['resp_id'], false);
    $reciever_ud = get_userdata($_GET['resp_id']);
    $sender_name = bp_core_get_user_displayname($bp->loggedin_user->id, false);
    $sender_link = bp_core_get_userlink($bp->loggedin_user->id, false, true);
    // Lunks to use in email
    $reciever_personal_tasks_link = site_url(BP_MEMBERS_SLUG . '/' . $reciever_ud->user_login . '/' . $bp->gtm->slug . '/tasks');
    $reciever_personal_projects_link = site_url(BP_MEMBERS_SLUG . '/' . $reciever_ud->user_login . '/' . $bp->gtm->slug . '/projects');
    /* Set up and send the message */
    $to = $reciever_ud->user_email;
    $subject = get_blog_option(1, 'blogname') . ': ' . __('Assignments');
    $message = sprintf(__('Hello there %s,

%s (%s) reminds you, that pending tasks and projects you are responsible for need to be done.

To see your personal tasks click here: %s

To see your personal projects click here: %s

---------------------
%s. %s
', 'bp_gtm'), $reciever_name, $sender_name, $sender_link, $reciever_personal_tasks_link, $reciever_personal_projects_link, get_blog_option(1, 'blogname'), get_blog_option(1, 'blogdescription'));
    // Send it!
    wp_mail($to, $subject, $message);
    echo 'sent!';
}
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);
}
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 bp_course_bp_mail_filter($email_content, $sender_name, $subject, $content, $message_link, $settings_link, $ud)
 {
     $settings = get_option('lms_settings');
     if (!empty($this->html_emails)) {
         $email_content = bp_course_process_mail(bp_core_get_user_displayname($ud->ID), $subject, $email_content);
     }
     return $email_content;
 }
Esempio n. 9
0
function dln_get_avatar_link()
{
    if (!bp_loggedin_user_id()) {
        return '';
    }
    $user_id = bp_loggedin_user_id();
    $link = bp_core_fetch_avatar(array('item_id' => $user_id, 'width' => 40, 'height' => 40, 'class' => 'img-circle', 'alt' => bp_core_get_user_displayname($user_id)));
    return $link;
}
Esempio n. 10
0
/**
 * Basic keyword substitution routine for welcome message and start page values.
 *
 * @param string $text
 * @param int $user_id
 * @since 2.0
 */
function dpw_do_keyword_replacement($text, $user_id)
{
    // [admin]
    $text = str_replace("USERNAME", bp_core_get_username($user_id), $text);
    // [Admin McAdmin]
    $text = str_replace("NICKNAME", bp_core_get_user_displayname($user_id), $text);
    // http://www.example.com/members/[admin]/
    $text = str_replace("USER_URL", bp_core_get_user_domain($user_id), $text);
    return $text;
}
/**
 * Format 'updated_profile' activity actions.
 *
 * @since BuddyPress (2.0.0)
 *
 * @param string $action Static activity action.
 * @param object $activity Activity object.
 * @return string
 */
function bp_xprofile_format_activity_action_updated_profile($action, $activity)
{
    // Note for translators: The natural phrasing in English, "Joe updated
    // his profile", requires that we know Joe's gender, which we don't. If
    // your language doesn't have this restriction, feel free to use a more
    // natural translation.
    $profile_link = trailingslashit(bp_core_get_user_domain($activity->user_id) . buddypress()->profile->slug);
    $action = sprintf(__('%s&#8217;s profile was updated', 'buddypress'), '<a href="' . $profile_link . '">' . bp_core_get_user_displayname($activity->user_id) . '</a>');
    return apply_filters('bp_xprofile_format_activity_action_updated_profile', $action, $activity);
}
/**
 * Create a activity item
 * @param $params
 * @return string
 */
function buddystreamCreateActivity($params)
{
    global $bp, $wpdb;
    $buddyStreamExtensions = new BuddyStreamExtensions();
    $buddyStreamFilters = new BuddyStreamFilters();
    /**
     * buddystreamCreateActivity(array(
     *     'user_id'    => $user_meta->user_id,
     *     'extension'  => 'facebook',
     *     'type'       => 'photo',
     *     'content'    => $content,
     *     'item_id'    => $item['id'],
     *     'raw_date'   => $item['created_time'],
     *     'actionlink' => 'url_to_original_item')
     *  ));
     *
     */
    if (is_array($params)) {
        //load config of extension
        $originalText = $params['content'];
        foreach ($buddyStreamExtensions->getExtensionsConfigs() as $extension) {
            if (isset($extension['hashtag'])) {
                $originalText = str_replace($extension['hashtag'], "", $originalText);
                $originalText = trim($originalText);
            }
        }
        //set the content
        $content = "";
        $content = '<div class="buddystream_activity_container ' . $params['extension'] . '">' . $originalText . '</div>';
        if (!buddyStreamCheckImportLog($params['user_id'], $params['item_id'], $params['extension']) && !buddyStreamCheckExistingContent($content) && !buddyStreamCheckExistingContent($originalText)) {
            buddyStreamAddToImportLog($params['user_id'], $params['item_id'], $params['extension']);
            remove_filter('bp_activity_action_before_save', 'bp_activity_filter_kses', 1);
            $activity = new BP_Activity_Activity();
            $activity->user_id = $params['user_id'];
            $activity->component = $params['extension'];
            $activity->type = $params['extension'];
            $activity->content = $content;
            $activity->item_id = $params['item_id'];
            $activity->secondary_item_id = '';
            $activity->date_recorded = $params['raw_date'];
            $activity->hide_sitewide = 0;
            $activity->action .= '<a href="' . bp_core_get_user_domain($params['user_id']) . '" title="' . bp_core_get_username($params['user_id']) . '">' . bp_core_get_user_displayname($params['user_id']) . '</a>';
            $activity->action .= ' ' . __('posted&nbsp;a', 'buddystream_lang') . ' ';
            $activity->action .= '<a href="' . $params['actionlink'] . '" target="_blank" rel="external"> ' . __($params['type'], 'buddystream_' . $extension['name']);
            $activity->action .= '</a>: ';
            $activity->primary_link = $params['actionlink'];
            if (!preg_match("/" . $params['item_id'] . "/i", get_user_meta($params['user_id'], 'buddystream_blacklist_ids', 1))) {
                $activity->save();
                $buddyStreamFilters->updateDayLimitByOne($params['extension'], $params['user_id']);
                return true;
            }
        }
    }
    return false;
}
Esempio n. 13
0
 /**
  * Setup globals
  *
  * The BP_MEMBERS_SLUG constant is deprecated, and only used here for
  * backwards compatibility.
  *
  * @since 1.5
  * @global obj $bp
  */
 function setup_globals()
 {
     global $bp, $current_user, $displayed_user_id;
     // Define a slug, if necessary
     if (!defined('BP_MEMBERS_SLUG')) {
         define('BP_MEMBERS_SLUG', $this->id);
     }
     $globals = array('path' => BP_PLUGIN_DIR, 'slug' => BP_MEMBERS_SLUG, 'root_slug' => isset($bp->pages->members->slug) ? $bp->pages->members->slug : BP_MEMBERS_SLUG, 'has_directory' => true, 'search_string' => __('Search Members...', 'buddypress'));
     parent::setup_globals($globals);
     /** Logged in user ****************************************************/
     // Fetch the full name for the logged in user
     $bp->loggedin_user->fullname = bp_core_get_user_displayname(bp_loggedin_user_id());
     // Hits the DB on single WP installs so get this separately
     $bp->loggedin_user->is_super_admin = $bp->loggedin_user->is_site_admin = is_super_admin(bp_loggedin_user_id());
     // The domain for the user currently logged in. eg: http://domain.com/members/andy
     $bp->loggedin_user->domain = bp_core_get_user_domain(bp_loggedin_user_id());
     // The core userdata of the user who is currently logged in.
     $bp->loggedin_user->userdata = bp_core_get_core_userdata(bp_loggedin_user_id());
     /** Displayed user ****************************************************/
     // The domain for the user currently being displayed
     $bp->displayed_user->domain = bp_core_get_user_domain(bp_displayed_user_id());
     // The core userdata of the user who is currently being displayed
     $bp->displayed_user->userdata = bp_core_get_core_userdata(bp_displayed_user_id());
     // Fetch the full name displayed user
     $bp->displayed_user->fullname = bp_core_get_user_displayname(bp_displayed_user_id());
     /** Profiles Fallback *************************************************/
     if (!bp_is_active('xprofile')) {
         $bp->profile->slug = 'profile';
         $bp->profile->id = 'profile';
     }
     /** Default Profile Component *****************************************/
     if (!defined('BP_DEFAULT_COMPONENT')) {
         if (bp_is_active('activity') && isset($bp->pages->activity)) {
             $bp->default_component = bp_get_activity_slug();
         } else {
             $bp->default_component = 'xprofile' == $bp->profile->id ? 'profile' : $bp->profile->id;
         }
     } else {
         $bp->default_component = BP_DEFAULT_COMPONENT;
     }
     if (!bp_current_component() && bp_displayed_user_id()) {
         /**
          * BuddyPress will attempt to resolve to the most specific URL possible,
          * to avoid search-engine-unfriendly content reduplication. Filter
          * bp_guarantee_unique_uris (and return false) to avoid this behavior
          */
         if (apply_filters('bp_guarantee_unique_uris', true)) {
             bp_core_redirect(bp_displayed_user_domain() . $bp->default_component);
         } else {
             $bp->current_component = $bp->default_component;
         }
     }
 }
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);
}
Esempio n. 15
0
/**
 * Extend chat messages by injecting the username, avatar image and escaping the message
 * 
 * @param array $messages
 * @param type $uid
 * @return type
 */
function bpchat_extend_messages($messages, $uid = 'sender_id')
{
    if (empty($messages)) {
        return $messages;
    }
    $message_count = count($messages);
    for ($i = 0; $i < $message_count; $i++) {
        $messages[$i]->name = bp_core_get_user_displayname($messages[$i]->{$uid});
        $messages[$i]->message = stripslashes($messages[$i]->message);
        $messages[$i]->thumb = bp_core_fetch_avatar(array('item_id' => $messages[$i]->{$uid}, 'type' => 'thumb', 'width' => 50, 'height' => 50, 'html' => false));
    }
    return $messages;
}
Esempio n. 16
0
 /**
  * Setup globals
  *
  * The BP_MEMBERS_SLUG constant is deprecated, and only used here for
  * backwards compatibility.
  *
  * @since 1.5
  * @global obj $bp
  */
 function setup_globals()
 {
     global $bp, $current_user, $displayed_user_id;
     // Define a slug, if necessary
     if (!defined('BP_MEMBERS_SLUG')) {
         define('BP_MEMBERS_SLUG', $this->id);
     }
     $globals = array('path' => BP_PLUGIN_DIR, 'slug' => BP_MEMBERS_SLUG, 'root_slug' => isset($bp->pages->members->slug) ? $bp->pages->members->slug : BP_MEMBERS_SLUG, 'has_directory' => true, 'search_string' => __('Search Members...', 'buddypress'));
     parent::setup_globals($globals);
     /** Logged in user ****************************************************/
     // Fetch the full name for the logged in user
     $bp->loggedin_user->fullname = bp_core_get_user_displayname($bp->loggedin_user->id);
     // Hits the DB on single nxt installs so get this separately
     $bp->loggedin_user->is_super_admin = $bp->loggedin_user->is_site_admin = is_super_admin();
     // The domain for the user currently logged in. eg: http://domain.com/members/andy
     $bp->loggedin_user->domain = bp_core_get_user_domain($bp->loggedin_user->id);
     // The core userdata of the user who is currently logged in.
     $bp->loggedin_user->userdata = bp_core_get_core_userdata($bp->loggedin_user->id);
     /** Displayed user ****************************************************/
     // The user id of the user currently being viewed:
     // $bp->displayed_user->id is set in /bp-core/bp-core-catchuri.php
     if (empty($bp->displayed_user->id)) {
         $bp->displayed_user->id = 0;
     }
     // The domain for the user currently being displayed
     $bp->displayed_user->domain = bp_core_get_user_domain($bp->displayed_user->id);
     // The core userdata of the user who is currently being displayed
     $bp->displayed_user->userdata = bp_core_get_core_userdata($bp->displayed_user->id);
     // Fetch the full name displayed user
     $bp->displayed_user->fullname = bp_core_get_user_displayname($bp->displayed_user->id);
     /** Profiles Fallback *************************************************/
     if (!bp_is_active('xprofile')) {
         $bp->profile->slug = 'profile';
         $bp->profile->id = 'profile';
     }
     /** Default Profile Component *****************************************/
     if (!defined('BP_DEFAULT_COMPONENT')) {
         if (bp_is_active('activity') && isset($bp->pages->activity)) {
             $bp->default_component = bp_get_activity_slug();
         } else {
             $bp->default_component = 'xprofile' == $bp->profile->id ? 'profile' : $bp->profile->id;
         }
     } else {
         $bp->default_component = BP_DEFAULT_COMPONENT;
     }
     if (!$bp->current_component && $bp->displayed_user->id) {
         $bp->current_component = $bp->default_component;
     }
 }
Esempio n. 17
0
 public static function get($id, $link = TRUE)
 {
     $html = get_avatar($id, 40, '', 'avatar');
     if (!$link) {
         return $html;
     }
     if (function_exists('bp_core_get_userlink')) {
         $html = '<a href="' . bp_core_get_user_domain($id) . '" title="' . bp_core_get_user_displayname($id) . '">' . $html . '</a>';
     } else {
         if ($user = get_userdata($id)) {
             $html = '<a href="#" title="' . esc_attr($user->display_name) . '">' . $html . '</a>';
         }
     }
     // FIXME: get user URL
     return $html;
 }
 /**
  * response_added_message( $data, $body = false, $subject = false )
  * 
  * Generated content for new request messages.
  * 
  * @param Mixed $data, contains the student id, teacher id, response id etc.
  * @param bool $body if true generates the message body content
  * @param bool $subject if true generates the message subject content
  * @return String $content the generated message content
  */
 function response_added_message($data, $body = false, $subject = false)
 {
     $content = null;
     if ($subject) {
         $content = __('Student replied to your assignment.', 'bpsp');
     }
     if ($body) {
         $content = bp_core_get_user_displayname($data['response']->post_author);
         $content .= __(" added a response to: ", 'bpsp');
         $content .= "\n";
         $content .= '<a href="' . $data['assignment']->permalink . '">' . attribute_escape($data['assignment']->post_title) . '</a>';
         $content .= "\n";
         $content .= __("Follow the link above to see it.", 'bpsp');
     }
     return $content;
 }
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);
}
/**
 * Format 'updated_profile' activity actions.
 *
 * @since 2.0.0
 *
 * @param string $action   Static activity action.
 * @param object $activity Activity object.
 *
 * @return string
 */
function bp_xprofile_format_activity_action_updated_profile($action, $activity)
{
    // Note for translators: The natural phrasing in English, "Joe updated
    // his profile", requires that we know Joe's gender, which we don't. If
    // your language doesn't have this restriction, feel free to use a more
    // natural translation.
    $profile_link = trailingslashit(bp_core_get_user_domain($activity->user_id) . bp_get_profile_slug());
    $action = sprintf(__("%s's profile was updated", 'buddypress'), '<a href="' . $profile_link . '">' . bp_core_get_user_displayname($activity->user_id) . '</a>');
    /**
     * Filters the formatted 'updated_profile' activity stream action.
     *
     * @since 2.0.0
     *
     * @param string $action   Formatted action for activity stream.
     * @param object $activity Activity object.
     */
    return apply_filters('bp_xprofile_format_activity_action_updated_profile', $action, $activity);
}
Esempio n. 21
0
function messages_notification_new_message( $args ) {
	global $bp;
	extract($args);

	$sender_name = bp_core_get_user_displayname( $sender_id );

	foreach( $recipients as $recipient ) {
		if ( $sender_id == $recipient->user_id || 'no' == get_user_meta( $recipient->user_id, 'notification_messages_new_message', true ) ) continue;

		$ud = get_userdata( $recipient->user_id );
		$message_link = bp_core_get_user_domain( $recipient->user_id ) . BP_MESSAGES_SLUG .'/';
		$settings_link = bp_core_get_user_domain( $recipient->user_id ) .  BP_SETTINGS_SLUG . '/notifications/';

		$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_ROOT_BLOG, 'blogname' ), ENT_QUOTES );
		$email_subject = '[' . $sitename . '] ' . sprintf( __( 'New message from %s', 'buddypress' ), $sender_name );

		$email_content = sprintf( __(
'%s sent you a new message:

Subject: %s

"%s"

To view and read your messages please log in and visit: %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 );

		wp_mail( $email_to, $email_subject, $email_content );
	}
}
Esempio n. 22
0
/**
 * Get user display name
 * 
 * @param int $user_id
 * @return string user display name
 */
function mpp_get_user_display_name($user_id)
{
    if (function_exists('bp_core_get_user_displayname')) {
        return bp_core_get_user_displayname($user_id);
    }
    $user = get_user_by('id', $user_id);
    if (!$user) {
        return '';
    }
    $display_name = $user->display_name;
    if (!$display_name && ($user->first_name || $user->last_name)) {
        $display_name = trim($user->first_name . ' ' . $user->last_name);
    }
    //if it is still not set, set it to user_login
    if (!$display_name) {
        $display_name = $user->user_login;
    }
    return $display_name;
}
Esempio n. 23
0
 /**
  * Front-end display of widget.
  *
  * @see WP_Widget::widget()
  *
  * @param array $args     Widget arguments.
  * @param array $instance Saved values from database.
  */
 function widget($args, $instance)
 {
     extract($args);
     $single_post = $instance['single_post'];
     $display_name = $instance['display_name'];
     $map_height = $instance['map_height'];
     $map_width = $instance['map_width'];
     $directions = $instance['directions'];
     $map_type = $instance['map_type'];
     $address = $instance['address'];
     $no_location = $instance['no_location'];
     $zoom_level = $instance['zoom_level'];
     $address_fields = $instance['address_fields'];
     if (bp_is_user() || is_single() && isset($single_post) && $single_post == 1) {
         if (!isset($no_location)) {
             if (is_single()) {
                 global $post;
                 $member_id = $post->post_author;
             } else {
                 $member_id = $bp->displayed_user->id;
             }
             $member_info = gmw_get_member_info_from_db($member_id);
             if (!isset($member_info) || empty($member_info)) {
                 return;
             }
         }
         echo $before_widget;
         if (isset($display_name) && $display_name == 1) {
             if (is_single() && !bp_is_user()) {
                 global $post;
                 $member_id = $post->post_author;
             } elseif (bp_is_user()) {
                 global $bp;
                 $member_id = $bp->displayed_user->id;
             }
             echo $before_title . '<a href="' . bp_core_get_user_domain($member_id) . '">' . bp_core_get_user_displayname($member_id) . '&#39;s Location</a>' . $after_title;
         }
         $mAddress = isset($address_fields) && !empty($address_fields) ? implode(',', $address_fields) : 'street,city,state,zipcode,country';
         echo do_shortcode('[gmw_member_location widget="1" display_name="0" show_on_single_post="' . $single_post . '" address_fields="' . $mAddress . '" map_width="' . $map_width . '" map_height="' . $map_height . '" address="' . $address . '" map_type="' . $map_type . '" directions="' . $directions . '" no_location="' . $no_location . '" zoom_level="' . $zoom_level . '"]');
         echo $after_widget;
     }
 }
Esempio n. 24
0
 public function who_is($args = array())
 {
     $args = wp_parse_args($args, array('meta_key' => 'last_active', 'meta_value' => time() - 24 * 60 * 60, 'meta_compare' => '>', 'count_total' => FALSE));
     $users = get_users($args);
     // $online = array();
     $html = '';
     foreach ($users as $user) {
         if (!get_user_meta($user->ID, 'is_online', TRUE)) {
             continue;
         }
         if (function_exists('bp_core_get_userlink')) {
             $html .= '<li><a href="' . bp_core_get_user_domain($user->ID) . '" title="' . bp_core_get_user_displayname($user->ID) . '">' . get_avatar($user->user_email, 40, '', 'avatar') . '</a></li>';
         } else {
             $html .= '<li><a title="' . esc_attr($user->display_name) . '" >' . get_avatar($user->user_email, 40, '', 'avatar') . '</a></li>';
         }
         // $online[$user->ID] = $user->user_login;
         // $online[$user->ID] = $user->display_name;
     }
     return $html;
 }
function bp_links_at_message_notification($content, $poster_user_id, $link_id, $activity_id)
{
    global $bp;
    /* Scan for @username strings in an activity update. Notify each user. */
    $pattern = '/[@]+([A-Za-z0-9-_]+)/';
    preg_match_all($pattern, $content, $usernames);
    /* Make sure there's only one instance of each username */
    if (!($usernames = array_unique($usernames[1]))) {
        return false;
    }
    $link = new BP_Links_Link($link_id);
    foreach ((array) $usernames as $username) {
        if (!($receiver_user_id = bp_core_get_userid($username))) {
            continue;
        }
        if (!bp_links_is_link_visibile($link, $receiver_user_id)) {
            continue;
        }
        // Now email the user with the contents of the message (if they have enabled email notifications)
        if ('no' != get_usermeta($user_id, 'notification_activity_new_mention')) {
            $poster_name = bp_core_get_user_displayname($poster_user_id);
            $message_link = bp_activity_get_permalink($activity_id);
            $settings_link = bp_core_get_user_domain($receiver_user_id) . 'settings/notifications/';
            // Set up and send the message
            $ud = bp_core_get_core_userdata($receiver_user_id);
            $to = $ud->user_email;
            $subject = '[' . get_blog_option(BP_ROOT_BLOG, 'blogname') . '] ' . sprintf(__('%s mentioned you in the link "%s"', 'buddypress-links'), stripslashes($poster_name), wp_filter_kses(stripslashes($link->name)));
            $message = sprintf(__('%s mentioned you in the link "%s":

"%s"

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

---------------------
', 'buddypress-links'), $poster_name, wp_filter_kses(stripslashes_deep($link->name)), wp_filter_kses(stripslashes_deep($content)), $message_link);
            $message .= sprintf(__('To disable these notifications please log in and go to: %s', 'buddypress'), $settings_link);
            // Send it
            wp_mail($to, $subject, $message);
        }
    }
}
 /**
  * Constructor.
  *
  * @since 2.5.0
  *
  * @param string|array|int|WP_User $email_or_user Either a email address, user ID, WP_User object,
  *                                                or an array containing any combination of the above.
  * @param string $name Optional. If $email_or_user is a string, this is the recipient's name.
  */
 public function __construct($email_or_user, $name = '')
 {
     $name = sanitize_text_field($name);
     // User ID, WP_User object.
     if (is_int($email_or_user) || is_object($email_or_user)) {
         $this->user_object = is_object($email_or_user) ? $email_or_user : get_user_by('id', $email_or_user);
         if ($this->user_object) {
             // This is escaped with esc_html in bp_core_get_user_displayname()
             $name = wp_specialchars_decode(bp_core_get_user_displayname($this->user_object->ID), ENT_QUOTES);
             $this->address = $this->user_object->user_email;
             $this->name = sanitize_text_field($name);
         }
         // Array, address, and name.
     } else {
         if (!is_array($email_or_user)) {
             $email_or_user = array($email_or_user => $name);
         }
         // Handle numeric arrays.
         if (is_int(key($email_or_user))) {
             $address = current($email_or_user);
         } else {
             $address = key($email_or_user);
             $name = current($email_or_user);
         }
         if (is_email($address)) {
             $this->address = sanitize_email($address);
         }
         $this->name = $name;
     }
     /**
      * Fires inside __construct() method for BP_Email_Recipient class.
      *
      * @since 2.5.0
      *
      * @param string|array|int|WP_User $email_or_user Either a email address, user ID, WP_User object,
      *                                                or an array containing any combination of the above.
      * @param string $name If $email_or_user is a string, this is the recipient's name.
      * @param BP_Email_Recipient $this Current instance of the email type class.
      */
     do_action('bp_email_recipient', $email_or_user, $name, $this);
 }
function groups_notification_new_membership_request($requesting_user_id, $admin_id, $group_id, $membership_id)
{
    bp_core_add_notification($requesting_user_id, $admin_id, 'groups', 'new_membership_request', $group_id);
    if ('no' == bp_get_user_meta($admin_id, 'notification_groups_membership_request', true)) {
        return false;
    }
    $requesting_user_name = bp_core_get_user_displayname($requesting_user_id);
    $group = groups_get_group(array('group_id' => $group_id));
    $ud = bp_core_get_core_userdata($admin_id);
    $group_requests = bp_get_group_permalink($group) . 'admin/membership-requests';
    $profile_link = bp_core_get_user_domain($requesting_user_id);
    $settings_slug = function_exists('bp_get_settings_slug') ? bp_get_settings_slug() : 'settings';
    $settings_link = bp_core_get_user_domain($requesting_user_id) . $settings_slug . '/notifications/';
    // Set up and send the message
    $to = $ud->user_email;
    $subject = bp_get_email_subject(array('text' => sprintf(__('Membership request for group: %s', 'buddypress'), $group->name)));
    $message = sprintf(__('%1$s wants to join the group "%2$s".

Because you are the administrator of this group, you must either accept or reject the membership request.

To view all pending membership requests for this group, please visit:
%3$s

To view %4$s\'s profile: %5$s

---------------------
', 'buddypress'), $requesting_user_name, $group->name, $group_requests, $requesting_user_name, $profile_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_new_membership_request_to', $to);
    $subject = apply_filters_ref_array('groups_notification_new_membership_request_subject', array($subject, &$group));
    $message = apply_filters_ref_array('groups_notification_new_membership_request_message', array($message, &$group, $requesting_user_name, $profile_link, $group_requests, $settings_link));
    wp_mail($to, $subject, $message);
    do_action('bp_groups_sent_membership_request_email', $admin_id, $subject, $message, $requesting_user_id, $group_id, $membership_id);
}
function groups_notification_new_membership_request($requesting_user_id, $admin_id, $group_id, $membership_id)
{
    global $bp;
    bp_core_add_notification($requesting_user_id, $admin_id, 'groups', 'new_membership_request', $group_id);
    if ('no' == bp_get_user_meta($admin_id, 'notification_groups_membership_request', true)) {
        return false;
    }
    $requesting_user_name = bp_core_get_user_displayname($requesting_user_id);
    $group = new BP_Groups_Group($group_id);
    $ud = bp_core_get_core_userdata($admin_id);
    $requesting_ud = bp_core_get_core_userdata($requesting_user_id);
    $group_requests = bp_get_group_permalink($group) . 'admin/membership-requests';
    $profile_link = bp_core_get_user_domain($requesting_user_id);
    $settings_slug = function_exists('bp_get_settings_slug') ? bp_get_settings_slug() : 'settings';
    $settings_link = bp_core_get_user_domain($requesting_user_id) . $settings_slug . '/notifications/';
    // Set up and send the message
    $to = $ud->user_email;
    $sitename = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES);
    $subject = '[' . $sitename . '] ' . sprintf(__('Membership request for group: %s', 'buddypress'), $group->name);
    $message = sprintf(__('%1$s wants to join the group "%2$s".

Because you are the administrator of this group, you must either accept or reject the membership request.

To view all pending membership requests for this group, please visit:
%3$s

To view %4$s\'s profile: %5$s

---------------------
', 'buddypress'), $requesting_user_name, $group->name, $group_requests, $requesting_user_name, $profile_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_new_membership_request_to', $to);
    $subject = apply_filters_ref_array('groups_notification_new_membership_request_subject', array($subject, &$group));
    $message = apply_filters_ref_array('groups_notification_new_membership_request_message', array($message, &$group, $requesting_user_name, $profile_link, $group_requests, $settings_link));
    wp_mail($to, $subject, $message);
    do_action('bp_groups_sent_membership_request_email', $admin_id, $subject, $message, $requesting_user_id, $group_id, $membership_id);
}
Esempio n. 29
0
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' == 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_link = bp_core_get_user_domain( $initiator_id ) .  BP_SETTINGS_SLUG . '/notifications';

	// Set up and send the message
	$to       = $ud->user_email;
	$sitename = wp_specialchars_decode( get_blog_option( BP_ROOT_BLOG, 'blogname' ), ENT_QUOTES );
	$subject  = '[' . $sitename . '] ' . sprintf( __( '%s accepted your friendship request', 'buddypress' ), $friend_name );

	$message = sprintf( __(
'%s accepted your friend request.

To view %s\'s profile: %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 );

	wp_mail( $to, $subject, $message );
}
Esempio n. 30
0
 function wplms_coauthor_plus_instructor($instructor, $id)
 {
     if (function_exists('get_coauthors')) {
         $coauthors = get_coauthors($id);
         $instructor = '';
         foreach ($coauthors as $k => $inst) {
             $instructor_id = $inst->ID;
             $displayname = bp_core_get_user_displayname($instructor_id);
             if (function_exists('vibe_get_option')) {
                 $field = vibe_get_option('instructor_field');
             }
             $special = '';
             if (bp_is_active('xprofile')) {
                 $special = bp_get_profile_field_data('field=' . $field . '&user_id=' . $instructor_id);
             }
             $r = array('item_id' => $instructor_id, 'object' => 'user');
             $instructor .= '<div class="instructor_course"><div class="item-avatar">' . bp_core_fetch_avatar($r) . '</div>';
             $instructor .= '<h5 class="course_instructor"><a href="' . bp_core_get_user_domain($instructor_id) . '">' . $displayname . '<span>' . $special . '</span></a></h5>';
             $instructor .= apply_filters('wplms_instructor_meta', '', $instructor_id);
             $instructor .= '</div>';
         }
     }
     return $instructor;
 }