function sendgrid_sga_data_api() { header("Content-Type: application/json"); if ($_POST['api_key'] != get_option("sendgrid_sga_apikey")) { $output = array("error" => true, "message" => "Unauthenticated."); echo json_encode($output); die; } $period_start = create_start_time($_POST['period_start'], true); $period_end = create_end_time($_POST['period_end'], true); create_table($period_start, $period_end); $output = array("error" => true, "message" => "Unknown error."); $body = array(); if ($_POST['data'] == "users") { $top_users = get_top_users(); foreach ($top_users as $rank => $user_info) { $formatted_user_info = format_user_info($user_info); $body[] = array("raw" => array("post_author" => get_post_author($user_info->post_author), "mantime" => (int) $user_info->mantime, "visits" => (int) $user_info->visits, "pageviews" => (int) $user_info->pageviews, "avg_time_on_page" => (double) $user_info->avg_time_on_page, "entrance_rate" => (double) $user_info->entrance_rate, "exit_rate" => (double) $user_info->exit_rate), "formatted" => $formatted_user_info); } $output = array("error" => false, "body" => $body, "period_start" => $period_start, "period_end" => $period_end); } elseif ($_POST['data'] == "posts") { $top_posts = get_top_posts(); foreach ($top_posts as $rank => $post_info) { $formatted_post_info = format_post_info($post_info); $body[] = array("raw" => array("guid" => $post_info->guid, "post_title" => $post_info->post_title, "post_author" => get_post_author($post_info->post_author), "mantime" => (int) $post_info->mantime, "visits" => (int) $post_info->visits, "pageviews" => (int) $post_info->pageviews, "avg_time_on_page" => (double) $post_info->avg_time_on_page, "entrance_rate" => (double) $post_info->entrance_rate, "exit_rate" => (double) $post_info->exit_rate), "formatted" => $formatted_post_info); } $output = array("error" => false, "body" => $body, "period_start" => $period_start, "period_end" => $period_end); } else { $output = array("error" => true, "message" => "Data attribute not understood, please provide either users or posts"); } echo json_encode($output); die; }
/** * Add reply link below each post * * @param $post_links Array of the links * @param $args Array of args */ function em_reply_link($post_links = array(), $args = array()) { global $em_plugopts; if ($em_plugopts['reply-link'] == 1 && $em_plugopts['reply-text'] && bb_is_topic() && topic_is_open() && (bb_is_user_logged_in() || function_exists('bb_is_login_required') && !bb_is_login_required())) { /* Check if link is needed */ $text = str_replace("%%POSTLINK%%", get_post_link(), str_replace("%%USERNAME%%", get_post_author(), $em_plugopts['reply-text'])); $js = "var ema=document.getElementById('post_content');var emb=ema.value;if(emb!='')emb+='\\n\\n';ema.value=emb+'" . $text . "\\n\\n';ema.focus();void(0);"; $post_links[] = $args['before_each'] . '<a class="reply_link" style="cursor:pointer" onclick="' . $js . '">' . __('Reply', 'easy-mentions') . '</a>' . $args['after_each']; } return $post_links; }
function post_edit_text($post_id = 0) { $bb_post = bb_get_post(get_post_id($post_id)); if (bb_current_user_can('edit_post', $bb_post->post_id)) { $parts[] = ' | <a href="' . attribute_escape(apply_filters('post_edit_uri', bb_get_option('uri') . 'edit.php?id=' . $bb_post->post_id, $bb_post->post_id)) . '">Edit</a>'; } if (bb_current_user_can('delete_post', $bb_post->post_id)) { if (1 == $bb_post->post_status) { $parts[] = "<a href='" . attribute_escape(bb_nonce_url(bb_get_option('uri') . 'bb-admin/delete-post.php?id=' . $bb_post->post_id . '&status=0&view=all', 'delete-post_' . $bb_post->post_id)) . "' onclick='return confirm(\" " . js_escape(__('Are you sure you wanna undelete that?')) . " \");'>" . __('Undelete') . "</a>"; } else { $parts[] = "<a href='" . attribute_escape(bb_nonce_url(bb_get_option('uri') . 'bb-admin/delete-post.php?id=' . $bb_post->post_id . '&status=1', 'delete-post_' . $bb_post->post_id)) . "' onclick='return ajaxPostDelete(" . $bb_post->post_id . ", \"" . get_post_author($post_id) . "\");'>" . __('Delete') . "</a>"; } } if (count($parts) > 0) { echo implode(' | ', $parts); } }
function post_author_link($post_id = 0) { if ($link = get_user_link(get_post_author_id($post_id))) { echo '<a href="' . esc_attr($link) . '">' . get_post_author($post_id) . '</a>'; } elseif ($link = bb_get_post_meta('pingback_uri')) { echo '<a href="' . esc_attr($link) . '">' . get_post_author($post_id) . '</a>'; } else { post_author($post_id); } }
<ul class="posts"> <?php add_filter('get_topic_where', 'bb_no_where'); foreach ($objects as $object) { ?> <?php if ('post' == $object['type']) { global $bb_post; $bb_post = $object['data']; ?> <li> <?php if ($bb_post->poster_id) { printf(__('<a href="%1$s">Post</a> on <a href="%2$s">%3$s</a> by <a href="%4$s">%5$s</a>'), esc_attr(add_query_arg('view', 'all', get_post_link())), get_topic_link($bb_post->topic_id), get_topic_title($bb_post->topic_id), get_user_profile_link($bb_post->poster_id), get_post_author()); } else { printf(__('<a href="%1$s">Post</a> on <a href="%2$s">%3$s</a> by %4$s'), esc_attr(add_query_arg('view', 'all', get_post_link())), get_topic_link($bb_post->topic_id), get_topic_title($bb_post->topic_id), get_post_author()); } ?> </li> <?php } elseif ('topic' == $object['type']) { global $topic; $topic = $object['data']; ?> <li> <?php if ($topic->topic_poster) { printf(__('Topic titled <a href="%1$s">%2$s</a> started by <a href="%3$s">%4$s</a>'), esc_attr(add_query_arg('view', 'all', get_topic_link())), get_topic_title($topic->topic_id), get_user_profile_link($topic->topic_poster), get_topic_author($topic->topic_id)); } else { printf(__('Topic titled <a href="%1$s">%2$s</a> started by %3$s'), esc_attr(add_query_arg('view', 'all', get_topic_link())), get_topic_title($topic->topic_id), get_topic_author($topic->topic_id)); }
function post_author_link($post_id = 0) { if ($link = bb_get_option('name_link_profile') ? get_user_profile_link(get_post_author_id($post_id)) : get_user_link(get_post_author_id($post_id))) { echo '<a href="' . esc_attr($link) . '">' . get_post_author($post_id) . '</a>'; } elseif ($link = bb_get_post_meta('pingback_uri')) { echo '<a href="' . esc_attr($link) . '">' . get_post_author($post_id) . '</a>'; } elseif ($link = bb_get_post_meta('post_url')) { echo '<a href="' . esc_attr($link) . '">' . get_post_author($post_id) . '</a>'; } else { post_author($post_id); } }
/** * Sends notification emails for new posts. * * Gets new post's ID and check if there are subscribed * user to that topic, and if there are, send notifications * * @since 1.1 * * @param int $post_id ID of new post */ function bb_notify_subscribers($post_id) { global $bbdb, $bb_ksd_pre_post_status; if (!empty($bb_ksd_pre_post_status)) { return false; } if (!($post = bb_get_post($post_id))) { return false; } if (!($topic = get_topic($post->topic_id))) { return false; } $post_id = $post->post_id; $topic_id = $topic->topic_id; if (!($poster_name = get_post_author($post_id))) { return false; } do_action('bb_pre_notify_subscribers', $post_id, $topic_id); if (!($user_ids = $bbdb->get_col($bbdb->prepare("SELECT `{$bbdb->term_relationships}`.`object_id`\n\t\tFROM {$bbdb->term_relationships}, {$bbdb->term_taxonomy}, {$bbdb->terms}\n\t\tWHERE `{$bbdb->term_relationships}`.`term_taxonomy_id` = `{$bbdb->term_taxonomy}`.`term_taxonomy_id`\n\t\tAND `{$bbdb->term_taxonomy}`.`term_id` = `{$bbdb->terms}`.`term_id`\n\t\tAND `{$bbdb->term_taxonomy}`.`taxonomy` = 'bb_subscribe'\n\t\tAND `{$bbdb->terms}`.`slug` = 'topic-%d'", $topic_id)))) { return false; } foreach ((array) $user_ids as $user_id) { if ($user_id == $post->poster_id) { continue; } // don't send notifications to the person who made the post $user = bb_get_user($user_id); if (!($message = apply_filters('bb_subscription_mail_message', __("%1\$s wrote:\n\n%2\$s\n\nRead this post on the forums: %3\$s\n\nYou're getting this email because you subscribed to '%4\$s.'\nPlease click the link above, login, and click 'Unsubscribe' at the top of the page to stop receiving emails from this topic."), $post_id, $topic_id))) { continue; } /* For plugins */ bb_mail($user->user_email, apply_filters('bb_subscription_mail_title', '[' . bb_get_option('name') . '] ' . $topic->topic_title, $post_id, $topic_id), sprintf($message, $poster_name, strip_tags($post->post_text), get_post_link($post_id), strip_tags($topic->topic_title))); } do_action('bb_post_notify_subscribers', $post_id, $topic_id); }
<?php foreach ($recent as $bb_post) { ?> <li<?php alt_class('recent'); ?> > <a class="result" href="<?php post_link(); ?> "><?php echo bb_show_topic_context($q, get_topic_title($bb_post->topic_id)); ?> </a> <span class="freshness"><?php printf(__('By <a href="%1$s">%2$s</a> on %3$s'), get_user_profile_link($bb_post->poster_id), get_post_author(), bb_datetime_format_i18n(bb_get_post_time(array('format' => 'timestamp')))); ?> </span> <p><?php echo bb_show_context($q, $bb_post->post_text); ?> </p> </li> <?php } ?> </ol> </div> <?php } ?>