/** * Display the message box */ public function display() { $for_edit = $this->post_object->generate_text_for_edit(); // Initialize our post options class $post_options = new post_options(); $post_options->set_auth($this->auth['bbcode'], $this->auth['smilies'], true, true, true); $post_options->set_status($for_edit['allow_bbcode'], $for_edit['allow_smilies'], $for_edit['allow_urls']); // Setup the attachments! $this->setup_attachments(); if ($this->auth['polls']) { $this->posting_panels['poll-panel'] = 'POLL'; } // Add the forum key add_form_key($this->settings['form_name']); // Generate smiley listing if ($post_options->get_status('smilies')) { phpbb::_include('functions_posting', 'generate_smilies'); generate_smilies('inline', false); } // Build custom bbcodes array if ($post_options->get_status('bbcode')) { phpbb::_include('functions_display', 'display_custom_bbcodes'); display_custom_bbcodes(); } // Display the Captcha if required if ($this->settings['display_captcha']) { phpbb::_include('captcha/captcha_factory', false, 'phpbb_captcha_factory'); $captcha =& phpbb_captcha_factory::get_instance(phpbb::$config['captcha_plugin']); $captcha->init(CONFIRM_POST); if ($captcha->validate($this->request_data()) !== false) { phpbb::reset_template(); // Parse the captcha template phpbb::$template->set_filenames(array('captcha' => $captcha->get_template())); // Correct confirm image link phpbb::$template->assign_var('CONFIRM_IMAGE_LINK', phpbb::append_sid('ucp', 'mode=confirm&confirm_id=' . $captcha->confirm_id . '&type=' . $captcha->type)); phpbb::$template->assign_display('captcha', 'CAPTCHA', false); titania::set_custom_template(); } $this->s_hidden_fields = array_merge($this->s_hidden_fields, $captcha->get_hidden_fields()); } $post_options->set_in_template(); // Save the opened panel to show again $default_panel = request_var('open_panel', 'options-panel'); $default_panel = isset($this->posting_panels[$default_panel]) ? $default_panel : 'options-panel'; phpbb::$template->assign_vars(array('ACCESS_OPTIONS' => titania_access_select(isset($for_edit['access']) ? $for_edit['access'] : TITANIA_ACCESS_PUBLIC), 'EDIT_REASON' => isset($for_edit['edit_reason']) ? $for_edit['edit_reason'] : '', 'POSTING_FORM_NAME' => $this->settings['form_name'], 'POSTING_TEXT_NAME' => $this->settings['text_name'], 'POSTING_SUBJECT_NAME' => $this->settings['subject_name'], 'POSTING_PANELS_DEFAULT' => $default_panel, 'POSTING_TEXT' => $this->settings['text_default_override'] !== false ? $this->settings['text_default_override'] : $for_edit['text'], 'SUBJECT' => $this->settings['subject_default_override'] !== false ? $this->settings['subject_default_override'] : (isset($for_edit['subject']) ? $for_edit['subject'] : ''), 'S_ENHANCED_EDITOR' => phpbb::$user->data['titania_enhanced_editor'], 'S_DISPLAY_ERROR' => $this->settings['display_error'], 'S_DISPLAY_SUBJECT' => $this->settings['display_subject'], 'S_STICKY_TOPIC_ALLOWED' => $this->auth['sticky_topic'], 'S_STICKY_TOPIC_CHECKED' => isset($for_edit['topic_sticky']) ? $for_edit['topic_sticky'] : false, 'S_LOCK_TOPIC_ALLOWED' => $this->auth['lock_topic'], 'S_LOCK_TOPIC_CHECKED' => isset($for_edit['topic_locked']) ? $for_edit['topic_locked'] : false, 'S_LOCK_POST_ALLOWED' => $this->auth['lock'], 'S_LOCK_POST_CHECKED' => isset($for_edit['locked']) ? $for_edit['locked'] : false, 'S_EDIT_REASON' => $this->settings['display_edit_reason'], 'S_HIDDEN_FIELDS' => build_hidden_fields($this->s_hidden_fields))); if ($this->attachments) { phpbb::$template->assign_vars(array('UPLOADER' => $this->attachments->parse_uploader($this->settings['attachment_tpl']), 'S_FORM_ENCTYPE' => ' enctype="multipart/form-data"')); } $this->display_panels(); }
$poll_title = blog_data::$blog[$blog_id]['poll_title']; $poll_start = blog_data::$blog[$blog_id]['poll_start']; $poll_length = blog_data::$blog[$blog_id]['poll_length'] ? (blog_data::$blog[$blog_id]['poll_length'] - $poll_start) / 86400 : 0; $poll_max_options = blog_data::$blog[$blog_id]['poll_max_options']; $poll_vote_change = blog_data::$blog[$blog_id]['poll_vote_change']; decode_message($poll_title, blog_data::$blog[$blog_id]['bbcode_uid']); // Attachments $blog_attachment->get_attachment_data($blog_id); $blog_attachment->attachment_data = blog_data::$blog[$blog_id]['attachment_data']; } $temp = compact('blog_subject', 'blog_text', 'error'); blog_plugins::plugin_do_ref('blog_edit_after_setup', $temp); extract($temp); unset($temp); // Set the options up in the template $post_options->set_in_template(); // if they did not submit or they have an error if (!$submit || sizeof($error)) { // if they are trying to preview the message and do not have an error if ($preview && !sizeof($error)) { $preview_message = $message_parser->format_display($post_options->enable_bbcode, $post_options->enable_magic_url, $post_options->enable_smilies, false); // Poll Preview if (!empty($poll)) { $parse_poll = new parse_message($poll_title); $parse_poll->bbcode_uid = $message_parser->bbcode_uid; $parse_poll->bbcode_bitfield = $message_parser->bbcode_bitfield; $parse_poll->format_display($post_options->enable_bbcode, $post_options->enable_magic_url, $post_options->enable_smilies); if ($poll_length) { $poll_end = $poll_length * 86400 + ($poll_start ? $poll_start : time()); } $template->assign_vars(array('S_HAS_POLL_OPTIONS' => sizeof($poll_options), 'S_IS_MULTI_CHOICE' => $poll_max_options > 1 ? true : false, 'POLL_QUESTION' => $parse_poll->message, 'L_POLL_LENGTH' => $poll_length ? sprintf($user->lang['POLL_RUN_TILL'], $user->format_date($poll_end)) : '', 'L_MAX_VOTES' => $poll_max_options == 1 ? $user->lang['MAX_OPTION_SELECT'] : sprintf($user->lang['MAX_OPTIONS_SELECT'], $poll_max_options)));
function main($id, $mode) { global $auth, $cache, $template, $user, $db, $config, $phpEx, $phpbb_root_path; global $blog_plugins, $blog_plugins_path, $user_settings; $preview = isset($_POST['preview']) ? true : false; $submit = isset($_POST['submit']) ? true : false; $error = array(); $user->add_lang(array('mods/blog/common', 'mods/blog/ucp')); include $phpbb_root_path . 'blog/functions.' . $phpEx; blog_plugins::plugin_do('ucp_start'); get_user_settings($user->data['user_id']); switch ($mode) { case 'ucp_blog_settings': $subscription_types = get_blog_subscription_types(); if ($submit) { $sql_ary = array('instant_redirect' => request_var('instant_redirect', 0), 'blog_subscription_default' => 0, 'blog_style' => $auth->acl_get('u_blog_style') ? request_var('blog_style', '') : '', 'blog_css' => $auth->acl_get('u_blog_css') ? request_var('blog_css', '') : ''); if ($config['user_blog_subscription_enabled']) { foreach ($subscription_types as $type => $name) { if (request_var('subscription_' . $type, false)) { $sql_ary['blog_subscription_default'] += $type; } } } update_user_blog_settings($user->data['user_id'], $sql_ary); } else { if ($config['user_blog_subscription_enabled']) { $subscribed = array(); if (isset($user_settings[$user->data['user_id']])) { foreach ($subscription_types as $type => $name) { // Bitwise check if ($user_settings[$user->data['user_id']]['blog_subscription_default'] & $type) { $subscribed[$type] = true; } } } foreach ($subscription_types as $type => $name) { $template->assign_block_vars('subscriptions', array('TYPE' => 'subscription_' . $type, 'NAME' => isset($user->lang[$name]) ? $user->lang[$name] : $name, 'S_CHECKED' => isset($subscribed[$type]) ? true : false)); } } if ($auth->acl_get('u_blog_style')) { $available_styles = array(array('name' => $user->lang['NONE'], 'value' => 0, 'demo' => $phpbb_root_path . 'images/spacer.gif')); $sql = 'SELECT * FROM ' . STYLES_TABLE . ' s, ' . STYLES_TEMPLATE_TABLE . ' st WHERE style_active = 1 AND s.template_id = st.template_id'; $result = $db->sql_query($sql); while ($row = $db->sql_fetchrow($result)) { $demo = $phpbb_root_path . 'images/spacer.gif'; if (@file_exists($phpbb_root_path . 'styles/' . $row['template_path'] . '/template/blog/demo.png')) { $demo = $phpbb_root_path . 'styles/' . $row['template_path'] . '/template/blog/demo.png'; } else { if (@file_exists($phpbb_root_path . 'styles/' . $row['template_path'] . '/template/blog/demo.gif')) { $demo = $phpbb_root_path . 'styles/' . $row['template_path'] . '/template/blog/demo.gif'; } else { if (@file_exists($phpbb_root_path . 'styles/' . $row['template_path'] . '/template/blog/demo.jpg')) { $demo = $phpbb_root_path . 'styles/' . $row['template_path'] . '/template/blog/demo.jpg'; } } } $available_styles[] = array('name' => $row['style_name'], 'value' => $row['style_id'], 'demo' => $demo); } $db->sql_freeresult($result); $dh = @opendir($phpbb_root_path . 'blog/styles/'); if ($dh) { while (($file = readdir($dh)) !== false) { if (file_exists($phpbb_root_path . 'blog/styles/' . $file . '/style.' . $phpEx)) { // Inside of the style.php file, add to the $available_styles array include $phpbb_root_path . 'blog/styles/' . $file . '/style.' . $phpEx; } } closedir($dh); } foreach ($available_styles as $row) { if (isset($user_settings[$user->data['user_id']]) && $user_settings[$user->data['user_id']]['blog_style'] == $row['value'] && isset($row['demo']) && $row['demo']) { $default_demo = $row['demo']; } $template->assign_block_vars('blog_styles', array('VALUE' => $row['value'], 'SELECTED' => isset($user_settings[$user->data['user_id']]) && $user_settings[$user->data['user_id']]['blog_style'] == $row['value'] ? true : false, 'NAME' => $row['name'], 'BLOG_CSS' => isset($row['blog_css']) && $row['blog_css'] ? true : false, 'DEMO' => isset($row['demo']) && $row['demo'] ? $row['demo'] : '')); } } $template->assign_vars(array('S_BLOG_INSTANT_REDIRECT' => isset($user_settings[$user->data['user_id']]) ? $user_settings[$user->data['user_id']]['instant_redirect'] : 0, 'S_SUBSCRIPTIONS' => $config['user_blog_subscription_enabled'] ? true : false, 'S_BLOG_STYLE' => isset($available_styles) && sizeof($available_styles) > 1 ? true : false, 'S_BLOG_CSS' => $auth->acl_get('u_blog_css') ? true : false, 'DEFAULT_DEMO' => isset($default_demo) ? $default_demo : $phpbb_root_path . 'images/spacer.gif', 'BLOG_CSS' => isset($user_settings[$user->data['user_id']]) ? $user_settings[$user->data['user_id']]['blog_css'] : '')); } break; case 'ucp_blog_permissions': if (!$config['user_blog_user_permissions']) { $error[] = $user->lang['USER_PERMISSIONS_DISABLED']; $template->assign_vars(array('PERMISSIONS_DISABLED' => true)); } else { if ($submit) { $sql_ary = array('perm_guest' => request_var('perm_guest', 1), 'perm_registered' => request_var('perm_registered', 2), 'perm_foe' => request_var('perm_foe', 0), 'perm_friend' => request_var('perm_friend', 2)); update_user_blog_settings($user->data['user_id'], $sql_ary, isset($_POST['resync']) ? true : false); } else { permission_settings_builder(); } } break; case 'ucp_blog_title_description': include $phpbb_root_path . 'includes/functions_posting.' . $phpEx; include $phpbb_root_path . 'includes/message_parser.' . $phpEx; include $phpbb_root_path . 'blog/includes/functions_posting.' . $phpEx; if (!function_exists('display_custom_bbcodes')) { include $phpbb_root_path . 'includes/functions_display.' . $phpEx; } $user->add_lang('posting'); $post_options = new post_options(); $post_options->set_status(true, true, true); $post_options->set_in_template(); if ($submit || $preview) { // see if they tried submitting a message or suject(if they hit preview or submit) put it in an array for consistency with the edit mode $blog_title = utf8_normalize_nfc(request_var('title', '', true)); $blog_description = utf8_normalize_nfc(request_var('message', '', true)); // set up the message parser to parse BBCode, Smilies, etc $message_parser = new parse_message(); $message_parser->message = $blog_description; $message_parser->parse($post_options->enable_bbcode, $post_options->enable_magic_url, $post_options->enable_smilies, $post_options->img_status, $post_options->flash_status, $post_options->bbcode_status, $post_options->url_status); } else { if (isset($user_settings[$user->data['user_id']])) { $blog_title = $user_settings[$user->data['user_id']]['title']; $blog_description = $user_settings[$user->data['user_id']]['description']; decode_message($blog_description, $user_settings[$user->data['user_id']]['description_bbcode_uid']); } else { $blog_title = $blog_description = ''; } } if (!$submit || sizeof($error)) { if ($preview && !sizeof($error)) { $preview_message = $message_parser->format_display($post_options->enable_bbcode, $post_options->enable_magic_url, $post_options->enable_smilies, false); // output some data to the template parser $template->assign_vars(array('S_DISPLAY_PREVIEW' => true, 'PREVIEW_SUBJECT' => censor_text($blog_title), 'PREVIEW_MESSAGE' => $preview_message, 'POST_DATE' => $user->format_date(time()))); } // Generate smiley listing generate_smilies('inline', false); // Build custom bbcodes array display_custom_bbcodes(); $template->assign_vars(array('S_PREVIEW_BUTTON' => true, 'TITLE' => $blog_title, 'MESSAGE' => $blog_description)); } else { if ($submit) { $sql_ary = array('user_id' => $user->data['user_id'], 'title' => $blog_title, 'description' => $message_parser->message, 'description_bbcode_bitfield' => $message_parser->bbcode_bitfield, 'description_bbcode_uid' => $message_parser->bbcode_uid); unset($message_parser); update_user_blog_settings($user->data['user_id'], $sql_ary); } } break; default: $default = true; $temp = compact('mode', 'error', 'default'); blog_plugins::plugin_do_ref('ucp_default', $temp); // make sure you set default to false if you use your own page extract($temp); if ($default) { trigger_error('NO_MODE'); } } blog_plugins::plugin_do('ucp_end'); if ($submit && !sizeof($error)) { //$cache->destroy('_blog_settings_' . $user->data['user_id']); meta_refresh(3, $this->u_action); $message = $user->lang['PREFERENCES_UPDATED'] . '<br /><br />' . sprintf($user->lang['RETURN_UCP'], '<a href="' . $this->u_action . '">', '</a>'); trigger_error($message); } $template->assign_vars(array('L_TITLE' => $user->lang[strtoupper($mode)], 'L_TITLE_EXPLAIN' => $user->lang[strtoupper($mode) . '_EXPLAIN'], 'ERROR' => sizeof($error) ? implode($error, '<br />') : false, 'MODE' => $mode, 'S_UCP_ACTION' => $this->u_action)); $this->tpl_name = 'blog/ucp_blog'; $this->page_title = strtoupper($mode); }