Esempio n. 1
0
 /**
  * Handle reply data
  *
  * To handle the raw data gotten from the database
  *
  * @param int $id The id of the reply we want to handle
  * @param int|bool $trim_text If we want to trim the text or not(if true we will trim with the setting in $config['user_blog_user_text_limit'], else if it is an integer we will trim the text to that length)
  */
 public function handle_reply_data($id, $trim_text = false)
 {
     global $user, $phpbb_root_path, $config, $phpEx, $auth, $highlight_match;
     global $blog_attachment, $category_id;
     if (!isset(self::$reply[$id])) {
         return array();
     }
     $reply =& self::$reply[$id];
     $blog_id = $reply['blog_id'];
     $user_id = $reply['user_id'];
     blog_plugins::plugin_do('reply_handle_data_start');
     if ($trim_text !== false) {
         $reply_text = trim_text_length(false, $id, $trim_text === true ? $config['user_blog_user_text_limit'] : intval($trim_text));
         $shortened = $reply_text === false ? false : true;
         $reply_text = $reply_text === false ? $reply['reply_text'] : $reply_text;
     } else {
         $reply_text = $reply['reply_text'];
         $shortened = false;
     }
     // censor the text of the subject
     $reply_subject = censor_text($reply['reply_subject']);
     // Parse BBCode and prepare the message for viewing
     $bbcode_options = ($reply['enable_bbcode'] ? OPTION_FLAG_BBCODE : 0) + ($reply['enable_smilies'] ? OPTION_FLAG_SMILIES : 0) + ($reply['enable_magic_url'] ? OPTION_FLAG_LINKS : 0);
     $reply_text = generate_text_for_display($reply_text, $reply['bbcode_uid'], $reply['bbcode_bitfield'], $bbcode_options);
     // For Highlighting
     if ($highlight_match) {
         $reply_subject = preg_replace('#(?!<.*)(?<!\\w)(' . $highlight_match . ')(?!\\w|[^<>]*(?:</s(?:cript|tyle))?>)#is', '<span class="posthilit">\\1</span>', $reply_subject);
         $reply_text = preg_replace('#(?!<.*)(?<!\\w)(' . $highlight_match . ')(?!\\w|[^<>]*(?:</s(?:cript|tyle))?>)#is', '<span class="posthilit">\\1</span>', $reply_text);
     }
     // Attachments
     $update_count = $attachments = array();
     parse_attachments_for_view($reply_text, $reply['attachment_data'], $update_count);
     foreach ($reply['attachment_data'] as $i => $attachment) {
         $attachments[]['DISPLAY_ATTACHMENT'] = $attachment;
     }
     $replyrow = array('ID' => $id, 'TITLE' => $reply_subject, 'DATE' => $user->format_date($reply['reply_time']), 'MESSAGE' => $reply_text, 'EDITED_MESSAGE' => $reply['edited_message'], 'EDIT_REASON' => $reply['edit_reason'], 'DELETED_MESSAGE' => $reply['deleted_message'], 'EXTRA' => '', 'U_VIEW' => blog_url($user_id, $blog_id, $id), 'U_VIEW_PERMANENT' => blog_url($user_id, $blog_id, $id, array(), array(), true), 'U_APPROVE' => $reply['reply_approved'] == 0 ? blog_url($user_id, $blog_id, $id, array('page' => 'reply', 'mode' => 'approve')) : '', 'U_DELETE' => check_blog_permissions('reply', 'delete', true, $blog_id, $id) ? blog_url(false, false, $id, array('page' => 'reply', 'mode' => 'delete')) : '', 'U_EDIT' => check_blog_permissions('reply', 'edit', true, $blog_id, $id) ? blog_url(false, false, $id, array('page' => 'reply', 'mode' => 'edit')) : '', 'U_QUOTE' => check_blog_permissions('reply', 'quote', true, $blog_id, $id) ? blog_url(false, false, $id, array('page' => 'reply', 'mode' => 'quote')) : '', 'U_REPLY' => check_blog_permissions('reply', 'add', true, $blog_id) ? blog_url(false, $blog_id, false, array('page' => 'reply', 'mode' => 'add')) : '', 'U_REPORT' => check_blog_permissions('reply', 'report', true, $blog_id, $id) ? blog_url(false, false, $id, array('page' => 'reply', 'mode' => 'report')) : '', 'U_WARN' => $auth->acl_get('m_warn') && $reply['user_id'] != $user->data['user_id'] && $reply['user_id'] != ANONYMOUS ? append_sid("{$phpbb_root_path}mcp.{$phpEx}", "i=warn&amp;mode=warn_user&amp;u={$user_id}") : '', 'S_DELETED' => $reply['reply_deleted'] != 0 ? true : false, 'S_UNAPPROVED' => $reply['reply_approved'] == 0 ? true : false, 'S_REPORTED' => $reply['reply_reported'] && $auth->acl_get('m_blogreplyreport') ? true : false, 'S_DISPLAY_NOTICE' => !$auth->acl_get('u_download') && $reply['reply_attachment'] && sizeof($reply['attachment_data']) ? true : false, 'S_HAS_ATTACHMENTS' => $reply['reply_attachment'] ? true : false, 'attachment' => $attachments);
     blog_plugins::plugin_do_ref('reply_handle_data_end', $replyrow);
     return $replyrow;
 }
Esempio n. 2
0
// If some of the pages needed extra language files included, add them now.
if (isset($add_lang)) {
    $user->add_lang($add_lang);
}
if ($blog_id) {
    $subscribed = get_subscription_info($blog_id);
    $subscribed_title = $subscribed ? $user->lang['UNSUBSCRIBE_BLOG'] : $user->lang['SUBSCRIBE_BLOG'];
} else {
    if ($user_id) {
        $subscribed = get_subscription_info(false, $user_id);
        $subscribed_title = $subscribed ? $user->lang['UNSUBSCRIBE_USER'] : $user->lang['SUBSCRIBE_USER'];
    }
}
// Generate the common URL's
generate_blog_urls();
// Include the file(s) we need for the page.
if (!is_array($inc_file)) {
    include $phpbb_root_path . 'blog/' . $inc_file . '.' . $phpEx;
} else {
    foreach ($inc_file as $file) {
        include $phpbb_root_path . 'blog/' . $file . '.' . $phpEx;
    }
}
// Lets add credits for the User Blog Mod.  This is not the best way to do it, but it makes it so the person installing it has 1 less edit to do per style
// Sounds like the mod team will not accept this, so we are commenting it out for now and having the user just do the extra edit for each style.
//$user->lang['TRANSLATION_INFO'] = (!empty($user->lang['TRANSLATION_INFO'])) ? $user->lang['BLOG_CREDITS'] . '<br />' . $user->lang['TRANSLATION_INFO'] : $user->lang['BLOG_CREDITS'];
// Add some data to the template
$template->assign_vars(array('MODE' => $mode, 'PAGE' => $page, 'BLOG_TITLE' => isset($user_settings[$user_id]) ? censor_text($user_settings[$user_id]['title']) : false, 'BLOG_DESCRIPTION' => isset($user_settings[$user_id]) ? generate_text_for_display($user_settings[$user_id]['description'], $user_settings[$user_id]['description_bbcode_uid'], $user_settings[$user_id]['description_bbcode_bitfield'], 7) : false, 'BLOG_CREDITS' => $user->lang['BLOG_CREDITS'], 'U_ADD_BLOG' => check_blog_permissions('blog', 'add', true) ? $blog_urls['add_blog'] : '', 'U_BLOG_MCP' => $auth->acl_gets('m_blogapprove', 'm_blogreport', 'm_blogreplyapprove', 'm_blogreplyreport') ? append_sid("{$phpbb_root_path}mcp.{$phpEx}", 'i=blog') : '', 'U_BLOG_SELF' => $blog_urls['self_minus_print'], 'U_REPLY_BLOG' => $blog_id && check_blog_permissions('reply', 'add', true, $blog_id) ? $blog_urls['add_reply'] : '', 'U_VIEW_RESULTS' => $blog_urls['viewpoll'], 'S_HIDDEN_FIELDS' => $s_hidden_fields, 'S_POST_ACTION' => $blog_urls['self'], 'S_POLL_ACTION' => $blog_urls['vote'], 'S_PRINT_MODE' => $print, 'S_WATCH_FORUM_TITLE' => $subscribed_title, 'S_WATCH_FORUM_LINK' => $subscribed ? $blog_urls['unsubscribe'] : ($user->data['user_id'] != $user_id || $blog_id ? $blog_urls['subscribe'] : ''), 'S_WATCHING_FORUM' => $subscribed, 'L_USERNAMES_BLOGS' => $username == $user->data['username'] ? $user->lang['MY_BLOG'] : sprintf($user->lang['USERNAMES_BLOGS'], $username), 'UA_GREY_STAR_SRC' => $blog_images_path . 'star_grey.gif', 'UA_GREEN_STAR_SRC' => $blog_images_path . 'star_green.gif', 'UA_RED_STAR_SRC' => $blog_images_path . 'star_red.gif', 'UA_ORANGE_STAR_SRC' => $blog_images_path . 'star_orange.gif', 'UA_MAX_RATING' => $config['user_blog_max_rating'], 'UA_MIN_RATING' => $config['user_blog_min_rating'], 'REPLY_IMG' => $user->img('button_topic_reply', 'POST_A_NEW_REPLY'), 'POLL_LEFT_CAP_IMG' => $user->img('poll_left'), 'POLL_RIGHT_CAP_IMG' => $user->img('poll_right'), 'REPORT_IMG' => $user->img('icon_post_report', 'REPORT_POST'), 'WARN_IMG' => $user->img('icon_user_warn', 'WARN_USER'), 'DELETE_IMG' => $user->img('icon_post_delete', 'DELETE_POST'), 'PROFILE_IMG' => $user->img('icon_user_profile', 'READ_PROFILE'), 'PM_IMG' => $user->img('icon_contact_pm', 'SEND_PRIVATE_MESSAGE'), 'EMAIL_IMG' => $user->img('icon_contact_email', 'SEND_EMAIL'), 'EDIT_IMG' => $user->img('icon_post_edit', 'EDIT_POST'), 'QUOTE_IMG' => $user->img('icon_post_quote', 'REPLY_WITH_QUOTE')));
blog_plugins::plugin_do('blog_end');
// setup the page footer
page_footer();