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 wlcms_custom_css() { $wlcms_header_css = ''; if (get_option('wlcms_o_custom_css') != "") { $wlcms_header_css .= nxt_specialchars_decode(stripslashes(get_option('wlcms_o_custom_css')), 1, 0, 1); } if (get_option('wlcms_o_dashboard_remove_help_box') == 1) { $wlcms_header_css .= '#contextual-help-link-wrap { display: none; }'; $wlcms_header_css .= '#contextual-help-link { display: none; }'; } if (get_option('wlcms_o_post_meta_box_slug')) { $wlcms_header_css .= '#slugdiv, #edit-slug-box { display: none; } '; } if (get_option('wlcms_o_dashboard_remove_screen_options') == 1) { $wlcms_header_css .= '#screen-options-link-wrap { display: none; }'; } if (!current_user_can('activate_plugins')) { if (get_option('wlcms_o_hide_admin_bar_option') == 1) { $wlcms_header_css .= '.show-admin-bar { display: none; }'; } if (get_option('wlcms_o_inherit_hide_menus') == 1) { if (get_option('wlcms_o_hide_posts')) { $wlcms_header_css .= '#nxt-admin-bar-new-post { display: none; }'; } if (get_option('wlcms_o_hide_pages')) { $wlcms_header_css .= '#nxt-admin-bar-new-page { display: none; }'; } if (get_option('wlcms_o_hide_media')) { $wlcms_header_css .= '#nxt-admin-bar-new-media { display: none; }'; } if (get_option('wlcms_o_hide_links')) { $wlcms_header_css .= '#nxt-admin-bar-new-link { display: none; }'; } if (get_option('wlcms_o_hide_comments')) { $wlcms_header_css .= '#nxt-admin-bar-comments { display: none; }'; } if (!get_option('wlcms_o_show_widgets')) { $wlcms_header_css .= '#nxt-admin-bar-widgets { display: none; }'; } if (!get_option('wlcms_o_show_appearance')) { $wlcms_header_css .= '#nxt-admin-bar-menus { display: none; }'; } if (!get_option('wlcms_o_show_background')) { $wlcms_header_css .= '#nxt-admin-bar-background { display: none; }'; } if (!get_option('wlcms_o_show_header')) { $wlcms_header_css .= '#nxt-admin-bar-header { display: none; }'; } } } echo '<style type="text/css">'; echo $wlcms_header_css; echo '</style>'; }
function messages_notification_new_message($args) { global $bp; extract($args); $email_subject = $email_content = $args = ''; $sender_name = bp_core_get_user_displayname($sender_id); 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(nxt_filter_kses($subject)); $content = stripslashes(nxt_filter_kses($content)); // Set up and send the message $email_to = $ud->user_email; $sitename = nxt_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(__('%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, $settings_link); nxt_mail($email_to, $email_subject, $email_content); } do_action('bp_messages_sent_notification_email', $recipients, $email_subject, $email_content, $args); }
/** * Sends the email notification to the user when an Achievement is unlocked. * * @global object $bp BuddyPress global settings * @global nxtdb $nxtdb NXTClass database object * @param int $achievement_id * @param int $user_id * @since 2.0 */ function dpa_achievement_unlocked_notification($achievement_id, $user_id) { global $achievements_template, $bp, $nxtdb; if ('no' == get_user_meta($user_id, 'notification_dpa_unlock_achievement', true)) { return; } $recipient = get_userdata($user_id); $settings_link = bp_core_get_user_domain($user_id) . bp_get_settings_slug() . '/notifications/'; $achievements_link = bp_core_get_user_domain($user_id) . DPA_SLUG . '/'; $email_subject = sprintf(__('[%1$s] Achievement unlocked: %2$s', 'dpa'), nxt_specialchars_decode(get_blog_option(BP_ROOT_BLOG, 'blogname'), ENT_QUOTES), dpa_get_achievement_name()); $email_content = sprintf(__(' You have unlocked an Achievement: %1$s To review this and see all of your Achievements, go to %2$s --------------------- To disable these notifications please log in and go to: %3$s', 'dpa'), dpa_get_achievement_name(), $achievements_link, $settings_link); // Send the message $email_to = apply_filters('dpa_unlock_achievement_notification_to', $recipient->user_email, $achievement_id); $email_subject = apply_filters('dpa_unlock_achievement_notification_subject', $email_subject, $achievement_id); $email_content = apply_filters('dpa_unlock_achievement_notification_message', $email_content, $achievement_id, $achievements_link, $settings_link); nxt_mail($email_to, $email_subject, $email_content); }
function bb_upgrade_process_all_slugs() { global $bbdb; // Forums $forums = (array) $bbdb->get_results("SELECT forum_id, forum_name FROM {$bbdb->forums} ORDER BY forum_order ASC"); $slugs = array(); foreach ($forums as $forum) { $slug = bb_slug_sanitize(nxt_specialchars_decode($forum->forum_name, ENT_QUOTES)); $slugs[$slug][] = $forum->forum_id; } foreach ($slugs as $slug => $forum_ids) { foreach ($forum_ids as $count => $forum_id) { $_slug = $slug; $count = -$count; // madness if (is_numeric($slug) || $count) { $_slug = bb_slug_increment($slug, $count); } $bbdb->query("UPDATE {$bbdb->forums} SET forum_slug = '{$_slug}' WHERE forum_id = '{$forum_id}';"); } } unset($forums, $forum, $slugs, $slug, $_slug, $forum_ids, $forum_id, $count); // Topics $topics = (array) $bbdb->get_results("SELECT topic_id, topic_title FROM {$bbdb->topics} ORDER BY topic_start_time ASC"); $slugs = array(); foreach ($topics as $topic) { $slug = bb_slug_sanitize(nxt_specialchars_decode($topic->topic_title, ENT_QUOTES)); $slugs[$slug][] = $topic->topic_id; } foreach ($slugs as $slug => $topic_ids) { foreach ($topic_ids as $count => $topic_id) { $_slug = $slug; $count = -$count; if (is_numeric($slug) || $count) { $_slug = bb_slug_increment($slug, $count); } $bbdb->query("UPDATE {$bbdb->topics} SET topic_slug = '{$_slug}' WHERE topic_id = '{$topic_id}';"); } } unset($topics, $topic, $slugs, $slug, $_slug, $topic_ids, $topic_id, $count); }
function bb_update_forum($args) { global $bbdb; if (!bb_current_user_can('manage_forums')) { return false; } $defaults = array('forum_id' => 0, 'forum_name' => '', 'forum_slug' => '', 'forum_desc' => '', 'forum_parent' => 0, 'forum_order' => 0, 'forum_is_category' => 0); $fields = array('forum_name', 'forum_desc', 'forum_parent', 'forum_order'); $args = nxt_parse_args($args, $defaults); if (1 < func_num_args()) { // For back compat $args['forum_id'] = func_get_arg(0); $args['forum_name'] = func_get_arg(1); $args['forum_desc'] = 2 < func_num_args() ? func_get_arg(2) : ''; $args['forum_order'] = 3 < func_num_args() && is_numeric(func_get_arg(3)) ? func_get_arg(3) : 0; } extract($args, EXTR_SKIP); if (!($forum_id = (int) $forum_id)) { return false; } if (!($forum = bb_get_forum($forum_id))) { return false; } $forum_order = (int) $forum_order; $forum_parent = (int) $forum_parent; $forum_is_category = (int) $forum_is_category; $forum_name = apply_filters('bb_pre_forum_name', stripslashes(nxt_specialchars_decode($forum_name, ENT_QUOTES)), $forum_id); $forum_desc = apply_filters('bb_pre_forum_desc', stripslashes($forum_desc), $forum_id); if (strlen($forum_name) < 1) { return false; } // Slug is not changing, don't update it if (!$forum_slug || $forum_slug == $forum->forum_slug) { // [sic] } else { $forum_slug = $_forum_slug = bb_slug_sanitize($forum_slug); if (strlen($_forum_slug) < 1) { return false; } $forum_sql = "SELECT forum_slug FROM {$bbdb->forums} WHERE forum_slug = %s"; while (is_numeric($forum_slug) || ($existing_slug = $bbdb->get_var($bbdb->prepare($forum_sql, $forum_slug)))) { $forum_slug = bb_slug_increment($_forum_slug, $existing_slug); } $fields[] = 'forum_slug'; } nxt_cache_delete($forum_id, 'bb_forum'); nxt_cache_flush('bb_forums'); $update_result = $bbdb->update($bbdb->forums, compact($fields), compact('forum_id')); if ($forum_is_category) { bb_update_forummeta($forum_id, 'forum_is_category', $forum_is_category); } else { bb_delete_forummeta($forum_id, 'forum_is_category'); } return $update_result; }
/** * Send an email and a BP notification on receipt of an @-mention in a group * * @deprecated 1.5 * @deprecated Deprecated in favor of the more general bp_activity_at_message_notification() */ function groups_at_message_notification($content, $poster_user_id, $group_id, $activity_id) { global $bp; _deprecated_function(__FUNCTION__, '1.5', 'bp_activity_at_message_notification()'); /* 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; } $group = new BP_Groups_Group($group_id); foreach ((array) $usernames as $username) { if (!($receiver_user_id = bp_core_get_userid($username))) { continue; } /* Check the user is a member of the group before sending the update. */ if (!groups_is_user_member($receiver_user_id, $group_id)) { continue; } // 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($poster_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_groups_filter_kses(stripslashes($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(__('%1$s mentioned you in the group "%2$s"', 'buddypress'), $poster_name, $group->name); $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, $group->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('groups_at_message_notification_to', $to); $subject = apply_filters('groups_at_message_notification_subject', $subject, $group, $poster_name); $message = apply_filters('groups_at_message_notification_message', $message, $group, $poster_name, $content, $message_link, $settings_link); nxt_mail($to, $subject, $message); } } do_action('bp_groups_sent_mention_email', $usernames, $subject, $message, $content, $poster_user_id, $group_id, $activity_id); }
function bb_insert_topic($args = null) { global $bbdb; if (!($args = nxt_parse_args($args))) { return false; } $fields = array_keys($args); if (isset($args['topic_id']) && false !== $args['topic_id']) { $update = true; if (!($topic_id = (int) get_topic_id($args['topic_id']))) { return false; } // Get from db, not cache. Good idea? Prevents trying to update meta_key names in the topic table (get_topic() returns appended topic obj) $topic = $bbdb->get_row($bbdb->prepare("SELECT * FROM {$bbdb->topics} WHERE topic_id = %d", $topic_id)); $defaults = get_object_vars($topic); unset($defaults['topic_id']); // Only update the args we passed $fields = array_intersect($fields, array_keys($defaults)); if (in_array('topic_poster', $fields)) { $fields[] = 'topic_poster_name'; } if (in_array('topic_last_poster', $fields)) { $fields[] = 'topic_last_poster_name'; } } else { $topic_id = false; $update = false; $now = bb_current_time('mysql'); $current_user_id = bb_get_current_user_info('id'); $defaults = array('topic_title' => '', 'topic_slug' => '', 'topic_poster' => $current_user_id, 'topic_poster_name' => '', 'topic_last_poster' => $current_user_id, 'topic_last_poster_name' => '', 'topic_start_time' => $now, 'topic_time' => $now, 'topic_open' => 1, 'forum_id' => 0); // Insert all args $fields = array_keys($defaults); } $defaults['tags'] = false; // accepts array or comma delimited string extract(nxt_parse_args($args, $defaults)); unset($defaults['tags']); if (!($forum = bb_get_forum($forum_id))) { return false; } $forum_id = (int) $forum->forum_id; if (!($user = bb_get_user($topic_poster))) { $user = bb_get_user($topic_poster_name, array('by' => 'login')); } if (!empty($user)) { $topic_poster = $user->ID; $topic_poster_name = $user->user_login; } if (!($last_user = bb_get_user($topic_last_poster))) { $last_user = bb_get_user($topic_last_poster_name, array('by' => 'login')); } if (!empty($last_user)) { $topic_last_poster = $last_user->ID; $topic_last_poster_name = $last_user->user_login; } if (in_array('topic_title', $fields)) { $topic_title = apply_filters('pre_topic_title', $topic_title, $topic_id); if (strlen($topic_title) < 1) { return false; } } if (in_array('topic_slug', $fields)) { $slug_sql = $update ? "SELECT topic_slug FROM {$bbdb->topics} WHERE topic_slug = %s AND topic_id != %d" : "SELECT topic_slug FROM {$bbdb->topics} WHERE topic_slug = %s"; $topic_slug = $_topic_slug = bb_slug_sanitize($topic_slug ? $topic_slug : nxt_specialchars_decode($topic_title, ENT_QUOTES)); if (strlen($_topic_slug) < 1) { $topic_slug = $_topic_slug = '0'; } while (is_numeric($topic_slug) || ($existing_slug = $bbdb->get_var($bbdb->prepare($slug_sql, $topic_slug, $topic_id)))) { $topic_slug = bb_slug_increment($_topic_slug, $existing_slug); } } if ($update) { $bbdb->update($bbdb->topics, compact($fields), compact('topic_id')); nxt_cache_delete($topic_id, 'bb_topic'); if (in_array('topic_slug', $fields)) { nxt_cache_delete($topic->topic_slug, 'bb_topic_slug'); } nxt_cache_flush('bb_query'); nxt_cache_flush('bb_cache_posts_post_ids'); do_action('bb_update_topic', $topic_id); } else { $bbdb->insert($bbdb->topics, compact($fields)); $topic_id = $bbdb->insert_id; $bbdb->query($bbdb->prepare("UPDATE {$bbdb->forums} SET topics = topics + 1 WHERE forum_id = %d", $forum_id)); nxt_cache_delete($forum_id, 'bb_forum'); nxt_cache_flush('bb_forums'); nxt_cache_flush('bb_query'); nxt_cache_flush('bb_cache_posts_post_ids'); do_action('bb_new_topic', $topic_id); } if (!empty($tags)) { bb_add_topic_tags($topic_id, $tags); } do_action('bb_insert_topic', $topic_id, $args, compact(array_keys($args))); // topic_id, what was passed, what was used return $topic_id; }
/** * Sends an email notification and a BP notification when someone mentions you in an update * * @since 1.2.0 * * @param int $comment_id The comment id * @param int $commenter_id The unique user_id of the user who posted the comment * @param array $params {@link bp_activity_new_comment()} * * @global object $bp BuddyPress global settings * @uses bp_get_user_meta() * @uses bp_core_get_user_displayname() * @uses bp_activity_get_permalink() * @uses bp_core_get_user_domain() * @uses bp_get_settings_slug() * @uses bp_activity_filter_kses() * @uses bp_core_get_core_userdata() * @uses nxt_specialchars_decode() * @uses get_blog_option() * @uses bp_get_root_blog_id() * @uses apply_filters() To call the 'bp_activity_new_comment_notification_to' hook * @uses apply_filters() To call the 'bp_activity_new_comment_notification_subject' hook * @uses apply_filters() To call the 'bp_activity_new_comment_notification_message' hook * @uses nxt_mail() * @uses do_action() To call the 'bp_activity_sent_reply_to_update_email' hook * @uses apply_filters() To call the 'bp_activity_new_comment_notification_comment_author_to' hook * @uses apply_filters() To call the 'bp_activity_new_comment_notification_comment_author_subject' hook * @uses apply_filters() To call the 'bp_activity_new_comment_notification_comment_author_message' hook * @uses do_action() To call the 'bp_activity_sent_reply_to_reply_email' hook */ function bp_activity_new_comment_notification($comment_id, $commenter_id, $params) { global $bp; extract($params); $original_activity = new BP_Activity_Activity($activity_id); if ($original_activity->user_id != $commenter_id && 'no' != bp_get_user_meta($original_activity->user_id, 'notification_activity_new_reply', true)) { $poster_name = bp_core_get_user_displayname($commenter_id); $thread_link = bp_activity_get_permalink($activity_id); $settings_slug = function_exists('bp_get_settings_slug') ? bp_get_settings_slug() : 'settings'; $settings_link = bp_core_get_user_domain($original_activity->user_id) . $settings_slug . '/notifications/'; $poster_name = stripslashes($poster_name); $content = bp_activity_filter_kses(stripslashes($content)); // Set up and send the message $ud = bp_core_get_core_userdata($original_activity->user_id); $to = $ud->user_email; $sitename = nxt_specialchars_decode(get_blog_option(bp_get_root_blog_id(), 'blogname'), ENT_QUOTES); $subject = '[' . $sitename . '] ' . sprintf(__('%s replied to one of your updates', 'buddypress'), $poster_name); $message = sprintf(__('%1$s replied to one of your updates: "%2$s" To view your original update and all comments, log in and visit: %3$s --------------------- ', 'buddypress'), $poster_name, $content, $thread_link); $message .= sprintf(__('To disable these notifications please log in and go to: %s', 'buddypress'), $settings_link); /* Send the message */ $to = apply_filters('bp_activity_new_comment_notification_to', $to); $subject = apply_filters('bp_activity_new_comment_notification_subject', $subject, $poster_name); $message = apply_filters('bp_activity_new_comment_notification_message', $message, $poster_name, $content, $thread_link, $settings_link); nxt_mail($to, $subject, $message); do_action('bp_activity_sent_reply_to_update_email', $original_activity->user_id, $subject, $message, $comment_id, $commenter_id, $params); } /*** * If this is a reply to another comment, send an email notification to the * author of the immediate parent comment. */ if ($activity_id == $parent_id) { return false; } $parent_comment = new BP_Activity_Activity($parent_id); if ($parent_comment->user_id != $commenter_id && $original_activity->user_id != $parent_comment->user_id && 'no' != bp_get_user_meta($parent_comment->user_id, 'notification_activity_new_reply', true)) { $poster_name = bp_core_get_user_displayname($commenter_id); $thread_link = bp_activity_get_permalink($activity_id); $settings_slug = function_exists('bp_get_settings_slug') ? bp_get_settings_slug() : 'settings'; $settings_link = bp_core_get_user_domain($parent_comment->user_id) . $settings_slug . '/notifications/'; // Set up and send the message $ud = bp_core_get_core_userdata($parent_comment->user_id); $to = $ud->user_email; $sitename = nxt_specialchars_decode(get_blog_option(bp_get_root_blog_id(), 'blogname'), ENT_QUOTES); $subject = '[' . $sitename . '] ' . sprintf(__('%s replied to one of your comments', 'buddypress'), $poster_name); $poster_name = stripslashes($poster_name); $content = bp_activity_filter_kses(stripslashes($content)); $message = sprintf(__('%1$s replied to one of your comments: "%2$s" To view the original activity, your comment and all replies, log in and visit: %3$s --------------------- ', 'buddypress'), $poster_name, $content, $thread_link); $message .= sprintf(__('To disable these notifications please log in and go to: %s', 'buddypress'), $settings_link); /* Send the message */ $to = apply_filters('bp_activity_new_comment_notification_comment_author_to', $to); $subject = apply_filters('bp_activity_new_comment_notification_comment_author_subject', $subject, $poster_name); $message = apply_filters('bp_activity_new_comment_notification_comment_author_message', $message, $poster_name, $content, $settings_link, $thread_link); nxt_mail($to, $subject, $message); do_action('bp_activity_sent_reply_to_reply_email', $original_activity->user_id, $subject, $message, $comment_id, $commenter_id, $params); } }
/** * bp_core_email_from_name_filter() * * Sets the "From" name in emails sent to the name of the site and not "NXTClass" * * @package BuddyPress Core * @uses get_blog_option() fetches the value for a meta_key in the nxt_X_options table * @return The blog name for the root blog */ function bp_core_email_from_name_filter() { return apply_filters('bp_core_email_from_name_filter', nxt_specialchars_decode(get_blog_option(bp_get_root_blog_id(), 'blogname'), ENT_QUOTES)); }
/** * Converts a number of special characters into their HTML entities. * * Specifically deals with: &, <, >, ", and '. * * $quote_style can be set to ENT_COMPAT to encode " to * ", or ENT_QUOTES to do both. Default is ENT_NOQUOTES where no quotes are encoded. * * @since 1.2.2 * * @param string $string The text which is to be encoded. * @param mixed $quote_style Optional. Converts double quotes if set to ENT_COMPAT, both single and double if set to ENT_QUOTES or none if set to ENT_NOQUOTES. Also compatible with old values; converting single quotes if set to 'single', double if set to 'double' or both if otherwise set. Default is ENT_NOQUOTES. * @param string $charset Optional. The character encoding of the string. Default is false. * @param boolean $double_encode Optional. Whether or not to encode existing html entities. Default is false. * @return string The encoded text with HTML entities. */ function _nxt_specialchars($string, $quote_style = ENT_NOQUOTES, $charset = false, $double_encode = false) { $string = (string) $string; if (0 === strlen($string)) { return ''; } // Don't bother if there are no specialchars - saves some processing if (!preg_match('/[&<>"\']/', $string)) { return $string; } // Account for the previous behaviour of the function when the $quote_style is not an accepted value if (empty($quote_style)) { $quote_style = ENT_NOQUOTES; } elseif (!in_array($quote_style, array(0, 2, 3, 'single', 'double'), true)) { $quote_style = ENT_QUOTES; } // Store the site charset as a static to avoid multiple calls to backpress_get_option() if (!$charset) { static $_charset; if (!isset($_charset)) { $_charset = backpress_get_option('charset'); } $charset = $_charset; } if (in_array($charset, array('utf8', 'utf-8', 'UTF8'))) { $charset = 'UTF-8'; } $_quote_style = $quote_style; if ($quote_style === 'double') { $quote_style = ENT_COMPAT; $_quote_style = ENT_COMPAT; } elseif ($quote_style === 'single') { $quote_style = ENT_NOQUOTES; } // Handle double encoding ourselves if (!$double_encode) { $string = nxt_specialchars_decode($string, $_quote_style); $string = preg_replace('/&(#?x?[0-9a-z]+);/i', '|nxt_entity|$1|/nxt_entity|', $string); } $string = @htmlspecialchars($string, $quote_style, $charset); // Handle double encoding ourselves if (!$double_encode) { $string = str_replace(array('|nxt_entity|', '|/nxt_entity|'), array('&', ';'), $string); } // Backwards compatibility if ('single' === $_quote_style) { $string = str_replace("'", ''', $string); } return $string; }
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 = nxt_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)); nxt_mail($to, $subject, $message); do_action('bp_groups_sent_invited_email', $invited_user_id, $subject, $message, $group); } }
function htmlspecialchars_decode($str, $quote_style = ENT_COMPAT) { if (!is_scalar($string)) { trigger_error('htmlspecialchars_decode() expects parameter 1 to be string, ' . gettype($string) . ' given', E_USER_WARNING); return; } if (!is_int($quote_style) && $quote_style !== null) { trigger_error('htmlspecialchars_decode() expects parameter 2 to be integer, ' . gettype($quote_style) . ' given', E_USER_WARNING); return; } return nxt_specialchars_decode($str, $quote_style); }
/** * Notify the blog admin of a new user, normally via email. * * @since 2.0 * * @param int $user_id User ID * @param string $plaintext_pass Optional. The user's plaintext password */ function nxt_new_user_notification($user_id, $plaintext_pass = '') { $user = new nxt_User($user_id); $user_login = stripslashes($user->user_login); $user_email = stripslashes($user->user_email); // The blogname option is escaped with esc_html on the way into the database in sanitize_option // we want to reverse this for the plain text arena of emails. $blogname = nxt_specialchars_decode(get_option('blogname'), ENT_QUOTES); $message = sprintf(__('New user registration on your site %s:'), $blogname) . "\r\n\r\n"; $message .= sprintf(__('Username: %s'), $user_login) . "\r\n\r\n"; $message .= sprintf(__('E-mail: %s'), $user_email) . "\r\n"; @nxt_mail(get_option('admin_email'), sprintf(__('[%s] New User Registration'), $blogname), $message); if (empty($plaintext_pass)) { return; } $message = sprintf(__('Username: %s'), $user_login) . "\r\n"; $message .= sprintf(__('Password: %s'), $plaintext_pass) . "\r\n"; $message .= nxt_login_url() . "\r\n"; nxt_mail($user_email, sprintf(__('[%s] Your username and password'), $blogname), $message); }
/** * Loads the comment template specified in $file. * * Will not display the comments template if not on single post or page, or if * the post does not have comments. * * Uses the NXTClass database object to query for the comments. The comments * are passed through the 'comments_array' filter hook with the list of comments * and the post ID respectively. * * The $file path is passed through a filter hook called, 'comments_template' * which includes the TEMPLATEPATH and $file combined. Tries the $filtered path * first and if it fails it will require the default comment template from the * default theme. If either does not exist, then the NXTClass process will be * halted. It is advised for that reason, that the default theme is not deleted. * * @since 1.5.0 * @global array $comment List of comment objects for the current post * @uses $nxtdb * @uses $post * @uses $withcomments Will not try to get the comments if the post has none. * * @param string $file Optional, default '/comments.php'. The file to load * @param bool $separate_comments Optional, whether to separate the comments by comment type. Default is false. * @return null Returns null if no comments appear */ function comments_template($file = '/comments.php', $separate_comments = false) { global $nxt_query, $withcomments, $post, $nxtdb, $id, $comment, $user_login, $user_ID, $user_identity, $overridden_cpage; if (!(is_single() || is_page() || $withcomments) || empty($post)) { return; } if (empty($file)) { $file = '/comments.php'; } $req = get_option('require_name_email'); /** * Comment author information fetched from the comment cookies. * * @uses nxt_get_current_commenter() */ $commenter = nxt_get_current_commenter(); /** * The name of the current comment author escaped for use in attributes. */ $comment_author = $commenter['comment_author']; // Escaped by sanitize_comment_cookies() /** * The email address of the current comment author escaped for use in attributes. */ $comment_author_email = $commenter['comment_author_email']; // Escaped by sanitize_comment_cookies() /** * The url of the current comment author escaped for use in attributes. */ $comment_author_url = esc_url($commenter['comment_author_url']); /** @todo Use API instead of SELECTs. */ if ($user_ID) { $comments = $nxtdb->get_results($nxtdb->prepare("SELECT * FROM {$nxtdb->comments} WHERE comment_post_ID = %d AND (comment_approved = '1' OR ( user_id = %d AND comment_approved = '0' ) ) ORDER BY comment_date_gmt", $post->ID, $user_ID)); } else { if (empty($comment_author)) { $comments = get_comments(array('post_id' => $post->ID, 'status' => 'approve', 'order' => 'ASC')); } else { $comments = $nxtdb->get_results($nxtdb->prepare("SELECT * FROM {$nxtdb->comments} WHERE comment_post_ID = %d AND ( comment_approved = '1' OR ( comment_author = %s AND comment_author_email = %s AND comment_approved = '0' ) ) ORDER BY comment_date_gmt", $post->ID, nxt_specialchars_decode($comment_author, ENT_QUOTES), $comment_author_email)); } } // keep $comments for legacy's sake $nxt_query->comments = apply_filters('comments_array', $comments, $post->ID); $comments =& $nxt_query->comments; $nxt_query->comment_count = count($nxt_query->comments); update_comment_cache($nxt_query->comments); if ($separate_comments) { $nxt_query->comments_by_type =& separate_comments($comments); $comments_by_type =& $nxt_query->comments_by_type; } $overridden_cpage = FALSE; if ('' == get_query_var('cpage') && get_option('page_comments')) { set_query_var('cpage', 'newest' == get_option('default_comments_page') ? get_comment_pages_count() : 1); $overridden_cpage = TRUE; } if (!defined('COMMENTS_TEMPLATE') || !COMMENTS_TEMPLATE) { define('COMMENTS_TEMPLATE', true); } $include = apply_filters('comments_template', STYLESHEETPATH . $file); if (file_exists($include)) { require $include; } elseif (file_exists(TEMPLATEPATH . $file)) { require TEMPLATEPATH . $file; } else { // Backward compat code will be removed in a future release require ABSPATH . nxtINC . '/theme-compat/comments.php'; } }
/** * Converts a number of special characters into their HTML entities. * * Specifically deals with: &, <, >, ", and '. * * $quote_style can be set to ENT_COMPAT to encode " to * ", or ENT_QUOTES to do both. Default is ENT_NOQUOTES where no quotes are encoded. * * @since 1.2.2 * * @param string $string The text which is to be encoded. * @param mixed $quote_style Optional. Converts double quotes if set to ENT_COMPAT, both single and double if set to ENT_QUOTES or none if set to ENT_NOQUOTES. Also compatible with old values; converting single quotes if set to 'single', double if set to 'double' or both if otherwise set. Default is ENT_NOQUOTES. * @param string $charset Optional. The character encoding of the string. Default is false. * @param boolean $double_encode Optional. Whether to encode existing html entities. Default is false. * @return string The encoded text with HTML entities. */ function _nxt_specialchars($string, $quote_style = ENT_NOQUOTES, $charset = false, $double_encode = false) { $string = (string) $string; if (0 === strlen($string)) { return ''; } // Don't bother if there are no specialchars - saves some processing if (!preg_match('/[&<>"\']/', $string)) { return $string; } // Account for the previous behaviour of the function when the $quote_style is not an accepted value if (empty($quote_style)) { $quote_style = ENT_NOQUOTES; } elseif (!in_array($quote_style, array(0, 2, 3, 'single', 'double'), true)) { $quote_style = ENT_QUOTES; } // Store the site charset as a static to avoid multiple calls to nxt_load_alloptions() if (!$charset) { static $_charset; if (!isset($_charset)) { $alloptions = nxt_load_alloptions(); $_charset = isset($alloptions['blog_charset']) ? $alloptions['blog_charset'] : ''; } $charset = $_charset; } if (in_array($charset, array('utf8', 'utf-8', 'UTF8'))) { $charset = 'UTF-8'; } $_quote_style = $quote_style; if ($quote_style === 'double') { $quote_style = ENT_COMPAT; $_quote_style = ENT_COMPAT; } elseif ($quote_style === 'single') { $quote_style = ENT_NOQUOTES; } // Handle double encoding ourselves if ($double_encode) { $string = @htmlspecialchars($string, $quote_style, $charset); } else { // Decode & into & $string = nxt_specialchars_decode($string, $_quote_style); // Guarantee every &entity; is valid or re-encode the & $string = nxt_kses_normalize_entities($string); // Now re-encode everything except &entity; $string = preg_split('/(&#?x?[0-9a-z]+;)/i', $string, -1, PREG_SPLIT_DELIM_CAPTURE); for ($i = 0; $i < count($string); $i += 2) { $string[$i] = @htmlspecialchars($string[$i], $quote_style, $charset); } $string = implode('', $string); } // Backwards compatibility if ('single' === $_quote_style) { $string = str_replace("'", ''', $string); } return $string; }