/** * InitContent. */ function pmxc_InitContent() { global $user_info, $modSettings, $txt; if ($this->visible) { // show current time as realtime? if (!empty($this->cfg['config']['settings']['show_time']) && !empty($this->cfg['config']['settings']['show_realtime'])) { $cdate = date('Y,n-1,j,G,', Forum_Time()) . intval(date('i', Forum_Time())) . ',' . intval(date('s', Forum_Time())); if (empty($modSettings['pmxUserLoginLoaded'])) { addInlineJavascript(' var pmx_rtcFormat = {};'); } if (empty($this->cfg['config']['settings']['rtc_format'])) { addInlineJavascript(' pmx_rtcFormat[' . $this->cfg['id'] . '] = "' . (empty($user_info['time_format']) ? $modSettings['time_format'] : $user_info['time_format']) . '";'); } else { addInlineJavascript(' pmx_rtcFormat[' . $this->cfg['id'] . '] = "' . $this->cfg['config']['settings']['rtc_format'] . '";'); } if (empty($modSettings['pmxUserLoginLoaded'])) { addInlineJavascript(' var pmx_rctMonths = new Array("' . implode('","', $txt['months']) . '"); var pmx_rctShortMonths = new Array("' . implode('","', $txt['months_short']) . '"); var pmx_rctDays = new Array("' . implode('","', $txt['days']) . '"); var pmx_rctShortDays = new Array("' . implode('","', $txt['days_short']) . '"); var pmx_rtcFormatTypes = new Array("%a", "%A", "%d", "%b", "%B", "%m", "%Y", "%y", "%H", "%I", "%M", "%S", "%p", "%%", "%D", "%e", "%R", "%T"); var pmx_rtcOffset = new Date(' . $cdate . ') - new Date();'); loadJavascriptFile(PortaMx_loadCompressed('PortaMxUser.js'), array('external' => true)); $modSettings['pmxUserLoginLoaded'] = true; } } } // return the visibility flag (true/false) return $this->visible; }
/** * @name Dismissible Notices * @copyright Dismissible Notices contributors * @license BSD http://opensource.org/licenses/BSD-3-Clause * * @version 0.0.1 * */ function template_notices_above() { global $context, $txt, $scripturl; echo ' <noscript> <div id="notices">'; foreach ($context['notices'] as $notice) { addInlineJavascript(' setTimeout(function() { $' . ($notice['positioning']['element'] !== 'global' && !empty($notice['positioning']['element_name']) ? '(".' . $notice['positioning']['element_name'] . '")' : '') . '.notify({ title: ' . JavaScriptEscape($notice['body']) . ', button: ' . JavaScriptEscape($txt['dismiss_notice_dismis']) . ', cancel: ' . JavaScriptEscape($txt['dismiss_notice_cancel']) . ', id: ' . JavaScriptEscape($notice['id_notice']) . ' }, { style: \'default\', className: ' . javaScriptEscape($notice['class']) . ', autoHide: ' . ($context['user']['is_guest'] ? 'true' : 'false') . ', position: ' . javaScriptEscape(dismissnotices_translate_positions($notice['positioning']['position'])) . ', clickToHide: false }); }, 500);', true); echo ' <div class="' . $notice['class'] . '"> ' . $notice['body'] . '<br /> <a href="' . $scripturl . '?action=dismissnotice;url=' . urlencode($_SERVER['REQUEST_URL']) . $txt['dismiss_notice_dismis'] . '">X</a>, </div>'; } echo ' </div> </noscript>'; }
/** * Url Favicon * * @author emanuele & BurkeKnight * @license BSD http://opensource.org/licenses/BSD-3-Clause * * @version 0.0.2 */ function urlFavicon() { addInlineJavascript(' $(\'.inner .bbc_link\').each(function() { var url = $(this).attr(\'href\'), domain = url.match(/:\\/\\/(.[^/]+)/)[1], schema = url.match(/^(http[s]*):\\/\\//)[1]; $(this).css({ \'background-image\': \'url(//www.google.com/s2/favicons?domain=\' + schema + \'://\' + domain + \')\', \'background-repeat\': \'no-repeat\', \'background-position\': \'0 2px\', \'padding-left\': \'18px\' }); })', true); }
/** * Template for the profile header - goes before any other profile template. */ function template_profile_above() { global $context; // Prevent browssers from auto completing fields when viewing/editing other members profiles if (!$context['user']['is_owner']) { addInlineJavascript('disableAutoComplete();', true); } // If an error occurred while trying to save previously, give the user a clue! echo ' ', template_error_message(); // If the profile was update successfully, let the user know this. if (!empty($context['profile_updated'])) { echo ' <div class="successbox"> ', $context['profile_updated'], ' </div>'; } }
/** * System none modal ECL init */ function pmx_eclnonemodal() { global $context, $settings, $modSettings, $maintenance, $scripturl, $options, $txt; if (!empty($modSettings['pmx_eclmodal']) && !pmx_checkECL_Cookie()) { if (!empty($modSettings['pmxportal_disabled'])) { loadJavascriptFile(PortaMx_loadCompressed('PortaMx.js', array('dir' => $settings['default_theme_dir'] . '/PortaMx/Scripts/', 'url' => $settings['default_theme_url'] . '/PortaMx/Scripts/')), array('external' => true)); addInlineJavascript(' var pmxIsInit = true;'); loadLanguage('PortaMx/PortaMx'); } addInlineJavascript(' var eclOverlay = true; function Setlang(elm){window.location.href = elm.options[elm.selectedIndex].value;}'); loadCSSFile(PortaMx_loadCompressed('pmx_ecl.css', array('dir' => $settings['default_theme_dir'] . '/PortaMx/SysCss/', 'url' => $settings['default_theme_url'] . '/PortaMx/SysCss/')), array('external' => true)); loadtemplate('PortaMx/EclMain'); $context['template_layers'][] = 'eclmain'; } }
/** * InitContent. */ function pmxc_InitContent() { global $context, $user_info, $modSettings, $pmxCacheFunc; // if visible init the content if ($this->visible) { $cbtopic = isset($_GET['topic']) ? $_GET['topic'] : 0; if ($this->cfg['cache'] > 0) { // check the block cache if (($cachedata = $pmxCacheFunc['get']($this->cache_key, $this->cache_mode)) !== null) { list($this->topics, $isRead, $this->boards, $this->cat_board) = $cachedata; if (isset($isRead[$user_info['id']]) && array_key_exists($cbtopic, $isRead[$user_info['id']]) && empty($isRead[$user_info['id']][$cbtopic])) { $isRead[$user_info['id']][$cbtopic] = 1; $cachedata = array($this->topics, $isRead, $this->boards, $this->cat_board); $pmxCacheFunc['put']($this->cache_key, $cachedata, $this->cache_time, $this->cache_mode); } } else { $cachedata = $this->cbt_fetchdata(); $pmxCacheFunc['put']($this->cache_key, $cachedata, $this->cache_time, $this->cache_mode); list($this->topics, $isRead, $this->boards, $this->cat_board) = $cachedata; } } else { $cachedata = $this->cbt_fetchdata(); list($this->topics, $isRead, $this->boards, $this->cat_board) = $cachedata; } unset($cachedata); $this->isRead = isset($isRead[$user_info['id']]) ? $isRead[$user_info['id']] : null; // no boards .. disable the block if (!empty($this->boards)) { if (empty($modSettings['pmxCBTNavLoaded'])) { addInlineJavascript(' var pmxCBTimages = new Array("' . $context['pmx_imageurl'] . 'minus.png", "' . $context['pmx_imageurl'] . 'plus.png"); var pmxCBTallBoards = {};'); loadJavascriptFile(PortaMx_loadCompressed('PortaMxCBTNav.js'), array('external' => true)); $modSettings['pmxCBTNavLoaded'] = true; } addInlineJavascript(' pmxCBTallBoards[' . $this->cfg['id'] . '] = new Array("' . implode('", "', $this->boards) . '");'); } else { $this->visible = false; } } // return the visibility flag (true/false) return $this->visible; }
function template_view_category() { global $context, $txt; echo ' <div id="sp_view_category"> <h3 class="category_header"> ', $context['page_title'], ' </h3>'; if (empty($context['articles'])) { echo ' <div class="sp_content_padding">', $txt['error_sp_no_articles'], '</div>'; } foreach ($context['articles'] as $article) { echo ' <div class="sp_content_padding"> <div class="sp_article_detail">'; if (!empty($article['author']['avatar']['image'])) { echo $article['author']['avatar']['image']; } echo ' <span class="sp_article_latest"> ', sprintf(!empty($context['using_relative_time']) ? $txt['sp_posted_on_in_by'] : $txt['sp_posted_in_on_by'], $article['category']['link'], $article['date'], $article['author']['link']), ' <br /> ', sprintf($article['view_count'] == 1 ? $txt['sp_viewed_time'] : $txt['sp_viewed_times'], $article['view_count']), ', ', sprintf($article['comment_count'] == 1 ? $txt['sp_commented_on_time'] : $txt['sp_commented_on_times'], $article['comment_count']), ' </span> <h4>', $article['link'], '</h4> </div> <hr /> <p>', $article['preview'], '<a href="', $article['href'], '">...</a></p> <div class="sp_article_extra"> <a href="', $article['href'], '">', $txt['sp_read_more'], '</a> | <a href="', $article['href'], '#sp_view_comments">', $txt['sp_write_comment'], '</a> </div> </div>'; } echo ' </div>'; // Pages as well? if (!empty($context['page_index'])) { template_pagesection(); } if (!empty($context['using_relative_time'])) { addInlineJavascript('$(\'.sp_article_latest\').addClass(\'relative\');', true); } }
/** * Administration page in Posts and Topics > BBC. * * - This method handles displaying and changing which BBC tags are enabled on the forum. * * @uses Admin template, edit_bbc_settings sub-template. */ public function action_bbcSettings_display() { global $context, $txt, $modSettings, $scripturl; // Initialize the form $this->_initBBCSettingsForm(); $config_vars = $this->_bbcSettings->settings(); // Make sure a nifty javascript will enable/disable checkboxes, according to BBC globally set or not. addInlineJavascript(' toggleBBCDisabled(\'disabledBBC\', ' . (empty($modSettings['enableBBC']) ? 'true' : 'false') . ');', true); // We'll need this forprepare_db() and save_db() require_once SUBSDIR . '/SettingsForm.class.php'; // Make sure we check the right tags! $modSettings['bbc_disabled_disabledBBC'] = empty($modSettings['disabledBBC']) ? array() : explode(',', $modSettings['disabledBBC']); // Save page if (isset($_GET['save'])) { checkSession(); // Security: make a pass through all tags and fix them as necessary $bbcTags = array(); foreach (parse_bbc(false) as $tag) { $bbcTags[] = $tag['tag']; } if (!isset($_POST['disabledBBC_enabledTags'])) { $_POST['disabledBBC_enabledTags'] = array(); } elseif (!is_array($_POST['disabledBBC_enabledTags'])) { $_POST['disabledBBC_enabledTags'] = array($_POST['disabledBBC_enabledTags']); } // Work out what is actually disabled! $_POST['disabledBBC'] = implode(',', array_diff($bbcTags, $_POST['disabledBBC_enabledTags'])); // Notify addons and integrations call_integration_hook('integrate_save_bbc_settings', array($bbcTags)); // Save the result Settings_Form::save_db($config_vars); // And we're out of here! redirectexit('action=admin;area=postsettings;sa=bbc'); } // Make sure the template stuff is ready now... $context['sub_template'] = 'show_settings'; $context['page_title'] = $txt['manageposts_bbc_settings_title']; $context['post_url'] = $scripturl . '?action=admin;area=postsettings;save;sa=bbc'; $context['settings_title'] = $txt['manageposts_bbc_settings_title']; Settings_Form::prepare_db($config_vars); }
/** * Modify any setting related to drafts. * * - Requires the admin_forum permission. * - Accessed from ?action=admin;area=managedrafts * * @uses Admin template, edit_topic_settings sub-template. */ public function action_draftSettings_display() { global $context, $txt, $scripturl; isAllowedTo('admin_forum'); loadLanguage('Drafts'); // Initialize the form $this->_initDraftSettingsForm(); $config_vars = $this->_draftSettings->settings(); // Setup the template. $context['page_title'] = $txt['managedrafts_settings']; $context['sub_template'] = 'show_settings'; $context[$context['admin_menu_name']]['tab_data'] = array('title' => $txt['drafts'], 'help' => '', 'description' => $txt['managedrafts_settings_description']); // Saving them ? if (isset($_GET['save'])) { checkSession(); call_integration_hook('integrate_save_drafts_settings'); // Protect them from themselves. $_POST['drafts_autosave_frequency'] = $_POST['drafts_autosave_frequency'] < 30 ? 30 : $_POST['drafts_autosave_frequency']; Settings_Form::save_db($config_vars); redirectexit('action=admin;area=managedrafts'); } // Some javascript to enable / disable the frequency input box addInlineJavascript(' var autosave = document.getElementById(\'drafts_autosave_enabled\'); createEventListener(autosave); autosave.addEventListener(\'change\', toggle); toggle(); function toggle() { var select_elem = document.getElementById(\'drafts_autosave_frequency\'); select_elem.disabled = !autosave.checked; }', true); // Final settings... $context['post_url'] = $scripturl . '?action=admin;area=managedrafts;save'; $context['settings_title'] = $txt['managedrafts_settings']; // Prepare the settings... Settings_Form::prepare_db($config_vars); }
public function action_list() { global $txt, $context, $scripturl, $modSettings, $settings; loadJavascriptFile('notify.js', array('defer' => true)); loadJavascriptFile('jquery.knob.js', array('defer' => true)); loadCSSFile('notify.css'); addInlineJavascript('dismissnotice_editable();', true); $modSettings['jquery_include_ui'] = true; loadCSSFile('dism/jquery.ui.theme.css'); loadCSSFile('dism/jquery.ui.datepicker.css'); loadCSSFile('dism/jquery.ui.d.theme.css'); loadCSSFile('dism/jquery.ui.core.css'); $possible_locals = array($txt['lang_locale']); $b = explode('_', $txt['lang_locale']); foreach ($b as $a) { $possible_locals[] = $a; } foreach ($possible_locals as $local) { if (file_exists($settings['default_theme_dir'] . '/scripts/datepicker-i18n/datepicker-' . $local . '.js')) { loadJavascriptFile('datepicker-i18n/datepicker-' . $local . '.js', array('defer' => true)); break; $context['datepicker_local'] = $local; } } $list_options = array('id' => 'list_dismissible_notices', 'title' => $txt['dismissnotices_title_list'], 'items_per_page' => 20, 'base_href' => $scripturl . '?action=admin;area=dismissnotice;sa=list' . $context['session_var'] . '=' . $context['session_id'], 'default_sort_col' => 'timeadded', 'get_items' => array('function' => array($this, 'getItems')), 'get_count' => array('function' => array($this, 'countItems')), 'data_check' => array('class' => function ($rowData) { return 'editable_' . $rowData['id_notice']; }), 'no_items_label' => $txt['hooks_no_hooks'], 'columns' => array('timeadded' => array('header' => array('value' => $txt['dismissnotices_time_added']), 'data' => array('function' => function ($rowData) { return standardTime($rowData['added']); }), 'sort' => array('default' => 'added', 'reverse' => 'added DESC')), 'body' => array('header' => array('value' => $txt['dismissnotices_body']), 'data' => array('db' => 'body')), 'class' => array('header' => array('value' => $txt['dismissnotices_class']), 'data' => array('db_htmlsafe' => 'class'), 'sort' => array('default' => 'class', 'reverse' => 'class DESC')), 'expire' => array('header' => array('value' => $txt['dismissnotices_expire']), 'data' => array('function' => function ($rowData) { return Dismissible_Notices_Integrate::formatExpireCol($rowData['expire']); }), 'sort' => array('default' => 'expire', 'reverse' => 'expire DESC')), 'edit' => array('header' => array('value' => ''), 'data' => array('function' => function ($rowData) { global $txt; return '<a data-idnotice="' . $rowData['id_notice'] . '" class="dismissnotice_editable" href="#">' . $txt['modify'] . '</a>'; }))), 'additional_rows' => array(array('position' => 'bottom_of_list', 'value' => '<a id="dismissnotice_new" class="floatright linkbutton" href="#">' . $txt['new'] . '</a>'))); require_once SUBSDIR . '/GenericList.class.php'; createList($list_options); }
/** * Set the theme settings for display and edit in admin panel. */ function template_settings() { global $context, $txt; $context['theme_settings'] = array(array('id' => 'header_logo_url', 'label' => $txt['header_logo_url'], 'description' => $txt['header_logo_url_desc'], 'type' => 'text'), array('id' => 'site_slogan', 'label' => $txt['site_slogan'], 'description' => $txt['site_slogan_desc'], 'type' => 'text'), array('id' => 'custom_favicon', 'label' => $txt['custom_favicon'], 'description' => $txt['custom_favicon_desc'], 'type' => 'text'), array('id' => 'custom_copyright', 'label' => $txt['custom_copyright'], 'description' => $txt['custom_copyright_desc'], 'type' => 'text'), '', array('id' => 'smiley_sets_default', 'label' => $txt['smileys_default_set_for_theme'], 'options' => $context['smiley_sets'], 'type' => 'text'), array('id' => 'forum_width', 'label' => $txt['forum_width'], 'description' => $txt['forum_width_desc'], 'type' => 'text', 'size' => 8), '', array('id' => 'linktree_link', 'label' => $txt['current_pos_text_img']), array('id' => 'show_mark_read', 'label' => $txt['enable_mark_as_read']), array('id' => 'enable_news', 'label' => $txt['enable_news'], 'options' => array(0 => $txt['enable_news_off'], 1 => $txt['enable_news_random'], 2 => $txt['enable_news_fader']), 'type' => 'number', 'description' => array('main' => '', 'options' => array(0 => array('enable_news_off_name', 'enable_news_off_desc'), 1 => array('enable_news_random_name', 'enable_news_random_desc'), 2 => array('enable_news_fader_name', 'enable_news_fader_desc')))), array('id' => 'newsfader_time', 'label' => $txt['admin_fader_delay'], 'type' => 'number'), '', array('id' => 'number_recent_posts', 'label' => $txt['number_recent_posts'], 'description' => $txt['number_recent_posts_desc'], 'type' => 'number'), array('id' => 'show_stats_index', 'label' => $txt['show_stats_index']), array('id' => 'show_latest_member', 'label' => $txt['latest_members']), array('id' => 'show_group_key', 'label' => $txt['show_group_key']), array('id' => 'display_who_viewing', 'label' => $txt['who_display_viewing'], 'options' => array(0 => $txt['who_display_viewing_off'], 1 => $txt['who_display_viewing_numbers'], 2 => $txt['who_display_viewing_names']), 'type' => 'number'), '', array('id' => 'show_modify', 'label' => $txt['last_modification']), array('id' => 'show_profile_buttons', 'label' => $txt['show_view_profile_button']), array('id' => 'show_user_images', 'label' => $txt['user_avatars']), array('id' => 'show_blurb', 'label' => $txt['user_text']), array('id' => 'show_gender', 'label' => $txt['gender_images']), array('id' => 'hide_post_group', 'label' => $txt['hide_post_group'], 'description' => $txt['hide_post_group_desc']), '', array('id' => 'show_bbc', 'label' => $txt['admin_bbc']), array('id' => 'additional_options_collapsible', 'label' => $txt['additional_options_collapsible']), '', array('id' => 'facebook_id', 'label' => $txt['facebook_id'], 'description' => $txt['url_desc'], 'type' => 'text'), array('id' => 'googleplus_id', 'label' => $txt['googleplus_id'], 'description' => $txt['url_desc'], 'type' => 'text'), array('id' => 'github_id', 'label' => $txt['github_id'], 'description' => $txt['url_desc'], 'type' => 'text'), array('id' => 'steam_id', 'label' => $txt['steam_id'], 'description' => $txt['url_desc'], 'type' => 'text'), array('id' => 'linkedin_id', 'label' => $txt['linkedin_id'], 'description' => $txt['url_desc'], 'type' => 'text'), array('id' => 'pinterest_id', 'label' => $txt['pinterest_id'], 'description' => $txt['url_desc'], 'type' => 'text'), array('id' => 'twitter_id', 'label' => $txt['twitter_id'], 'description' => $txt['url_desc'], 'type' => 'text'), array('id' => 'youtube_id', 'label' => $txt['youtube_id'], 'description' => $txt['url_desc'], 'type' => 'text')); addInlineJavascript(' // Hide the option first $("#dt_newsfader_time, #dd_newsfader_time").hide(); // Update visablity based on the select value toggleNewsFaderTime($("#enable_news").val()); // Set up the onchange event $("#enable_news").on("change", function() { toggleNewsFaderTime($(this).val()); }); function toggleNewsFaderTime(val) { if (val == 2) $("#dt_newsfader_time, #dd_newsfader_time").fadeIn(); else $("#dt_newsfader_time, #dd_newsfader_time").fadeOut(); }', true); }
/** * @package SimplePortal ElkArte * * @author SimplePortal Team * @copyright 2015 SimplePortal Team * @license BSD 3-clause * @version 1.0.0 Beta 1 */ function template_pages_edit() { global $context, $scripturl, $txt; // Previewing the page before submitting? echo ' <div id="preview_section" class="forumposts"', !empty($context['SPortal']['preview']) ? '' : ' style="display: none;"', '>', !empty($context['SPortal']['preview']) ? template_view_page() : '', ' </div>'; // If there were errors creating the page, show them. template_show_error('pages_errors'); // Adding or editing a page echo ' <div id="sp_edit_page"> <form id="admin_form_wrapper" action="', $scripturl, '?action=admin;area=portalpages;sa=edit" method="post" accept-charset="UTF-8" onsubmit="submitonce(this);"> <h3 class="category_header"> ', $context['SPortal']['is_new'] ? $txt['sp_admin_pages_add'] : $txt['sp_admin_pages_edit'], ' </h3> <div class="editor_wrapper"> <dl class="sp_form"> <dt> <label for="page_title">', $txt['sp_admin_pages_col_title'], ':</label> </dt> <dd> <input type="text" name="title" id="page_title" value="', $context['SPortal']['page']['title'], '" class="input_text" /> </dd> <dt> <label for="page_namespace">', $txt['sp_admin_pages_col_namespace'], ':</label> </dt> <dd> <input type="text" name="namespace" id="page_namespace" value="', $context['SPortal']['page']['page_id'], '" class="input_text" /> </dd> <dt> <label for="page_type">', $txt['sp_admin_pages_col_type'], ':</label> </dt> <dd> <select name="type" id="page_type">'; $content_types = array('bbc', 'html', 'php'); foreach ($content_types as $type) { echo ' <option value="', $type, '"', $context['SPortal']['page']['type'] == $type ? ' selected="selected"' : '', '>', $txt['sp_pages_type_' . $type], '</option>'; } echo ' </select> </dd> <dt> <label for="page_permissions">', $txt['sp_admin_pages_col_permissions'], ':</label> </dt> <dd> <select name="permissions" id="page_permissions">'; foreach ($context['SPortal']['page']['permission_profiles'] as $profile) { echo ' <option value="', $profile['id'], '"', $profile['id'] == $context['SPortal']['page']['permissions'] ? ' selected="selected"' : '', '>', $profile['label'], '</option>'; } echo ' </select> </dd> <dt> <label for="page_blocks">', $txt['sp_admin_pages_col_blocks'], ':</label> </dt> <dd> <select name="blocks[]" id="page_blocks" size="7" multiple="multiple">'; foreach ($context['sides'] as $side => $label) { if (empty($context['page_blocks'][$side])) { continue; } echo ' <optgroup label="', $label, '">'; foreach ($context['page_blocks'][$side] as $block) { echo ' <option value="', $block['id'], '"', $block['shown'] ? ' selected="selected"' : '', '>', $block['label'], '</option>'; } echo ' </optgroup>'; } echo ' </select> </dd> <dt> <label for="page_status">', $txt['sp_admin_pages_col_status'], ':</label> </dt> <dd> <input type="checkbox" name="status" id="page_status" value="1"', $context['SPortal']['page']['status'] ? ' checked="checked"' : '', ' class="input_check" /> </dd> <dt> ', $txt['sp_admin_pages_col_body'], ': </dt> <dd> </dd> </dl> <div>', template_control_richedit($context['post_box_name'], 'smileyBox_message', 'bbcBox_message'), '</div> <input type="submit" name="submit" value="', $context['page_title'], '" class="right_submit" /> <input type="submit" name="preview" value="', $txt['sp_admin_pages_preview'], '" class="right_submit" /> <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '" /> </div>'; $style_sections = array('title' => 'left', 'body' => 'right'); $style_types = array('default' => 'DefaultClass', 'class' => 'CustomClass', 'style' => 'CustomStyle'); $style_parameters = array('title' => array('category_header', 'secondary_header'), 'body' => array('content', 'information', 'roundframe')); echo ' <br /> <h3 class="category_header"> ', $txt['sp_admin_pages_style'], ' </h3> <div class="sp_content_padding">'; foreach ($style_sections as $section => $float) { echo ' <dl id="sp_edit_style_', $section, '" class="sp_form sp_float_', $float, '">'; foreach ($style_types as $type => $label) { echo ' <dt> ', $txt['sp-blocks' . ucfirst($section) . $label], ': </dt> <dd>'; if ($type == 'default') { echo ' <select name="', $section, '_default_class" id="', $section, '_default_class">'; foreach ($style_parameters[$section] as $class) { echo ' <option value="', $class, '"', $context['SPortal']['page']['style'][$section . '_default_class'] == $class ? ' selected="selected"' : '', '>', $class, '</option>'; } echo ' </select>'; } else { echo ' <input type="text" name="', $section, '_custom_', $type, '" id="', $section, '_custom_', $type, '" value="', $context['SPortal']['page']['style'][$section . '_custom_' . $type], '" class="input_text" />'; } echo ' </dd>'; } echo ' <dt> ', $txt['sp-blocksNo' . ucfirst($section)], ': </dt> <dd> <input type="checkbox" name="no_', $section, '" id="no_', $section, '" value="1"', !empty($context['SPortal']['page']['style']['no_' . $section]) ? ' checked="checked"' : '', ' onclick="check_style_options();" class="input_check" /> </dd> </dl>'; } echo ' <input type="submit" name="submit" value="', $context['page_title'], '" class="right_submit" /> <input type="submit" name="preview" value="', $txt['sp_admin_pages_preview'], '" class="right_submit" /> </div> <input type="hidden" name="page_id" value="', $context['SPortal']['page']['id'], '" /> </form> </div>'; addInlineJavascript('sp_editor_change_type("page_type");', true); }
/** * Creates a box that can be used for richedit stuff like BBC, Smileys etc. * @param mixed[] $editorOptions associative array of options => value * must contain: * - id => unique id for the css * - value => text for the editor or blank * Optionaly * - height => height of the intial box * - width => width of the box (100%) * - force_rich => force wysiwyg to be enabled * - disable_smiley_box => boolean to turn off the smiley box * - labels => array( * - 'post_button' => $txt['for post button'], * ), * - preview_type => 2 how to act on preview click, see template_control_richedit_buttons */ function create_control_richedit($editorOptions) { global $txt, $modSettings, $options, $context, $settings, $user_info, $scripturl; static $bbc_tags; $db = database(); // Load the Post language file... for the moment at least. loadLanguage('Post'); if (!empty($context['drafts_save']) || !empty($context['drafts_pm_save'])) { loadLanguage('Drafts'); } // Every control must have a ID! assert(isset($editorOptions['id'])); assert(isset($editorOptions['value'])); // Is this the first richedit - if so we need to ensure things are initialised and that we load all of the needed files if (empty($context['controls']['richedit'])) { // Store the name / ID we are creating for template compatibility. $context['post_box_name'] = $editorOptions['id']; // Some general stuff. $settings['smileys_url'] = $modSettings['smileys_url'] . '/' . $user_info['smiley_set']; if (!empty($context['drafts_autosave']) && !empty($options['drafts_autosave_enabled'])) { $context['drafts_autosave_frequency'] = empty($modSettings['drafts_autosave_frequency']) ? 30000 : $modSettings['drafts_autosave_frequency'] * 1000; } // This really has some WYSIWYG stuff. loadTemplate('GenericControls', 'jquery.sceditor'); if (!empty($context['theme_variant']) && file_exists($settings['theme_dir'] . '/css/' . $context['theme_variant'] . '/jquery.sceditor.elk' . $context['theme_variant'] . '.css')) { loadCSSFile($context['theme_variant'] . '/jquery.sceditor.elk' . $context['theme_variant'] . '.css'); } // JS makes the editor go round loadJavascriptFile(array('jquery.sceditor.min.js', 'jquery.sceditor.bbcode.min.js', 'jquery.sceditor.elkarte.js', 'post.js', 'splittag.plugin.js', 'dropAttachments.js')); addJavascriptVar(array('post_box_name' => $editorOptions['id'], 'elk_smileys_url' => $settings['smileys_url'], 'bbc_quote_from' => $txt['quote_from'], 'bbc_quote' => $txt['quote'], 'bbc_search_on' => $txt['search_on']), true); // Editor language file if (!empty($txt['lang_locale'])) { loadJavascriptFile($scripturl . '?action=jslocale;sa=sceditor', array('defer' => true), 'sceditor_language'); } // Drafts? if ((!empty($context['drafts_save']) || !empty($context['drafts_pm_save'])) && !empty($context['drafts_autosave']) && !empty($options['drafts_autosave_enabled'])) { loadJavascriptFile('drafts.plugin.js'); } // Mentions? if (!empty($context['mentions_enabled'])) { loadJavascriptFile(array('jquery.atwho.js', 'jquery.caret.min.js', 'mentioning.plugin.js')); } // Our not so concise shortcut line $context['shortcuts_text'] = $txt['shortcuts' . (!empty($context['drafts_save']) || !empty($context['drafts_pm_save']) ? '_drafts' : '') . (isBrowser('is_firefox') ? '_firefox' : '')]; // Spellcheck? $context['show_spellchecking'] = !empty($modSettings['enableSpellChecking']) && function_exists('pspell_new'); if ($context['show_spellchecking']) { // Some hidden information is needed in order to make spell check work. if (!isset($_REQUEST['xml'])) { $context['insert_after_template'] .= ' <form name="spell_form" id="spell_form" method="post" accept-charset="UTF-8" target="spellWindow" action="' . $scripturl . '?action=spellcheck"> <input type="hidden" name="spellstring" value="" /> <input type="hidden" name="fulleditor" value="" /> </form>'; } loadJavascriptFile('spellcheck.js', array('defer' => true)); } } // Start off the editor... $context['controls']['richedit'][$editorOptions['id']] = array('id' => $editorOptions['id'], 'value' => $editorOptions['value'], 'rich_active' => !empty($options['wysiwyg_default']) || !empty($editorOptions['force_rich']) || !empty($_REQUEST[$editorOptions['id'] . '_mode']), 'disable_smiley_box' => !empty($editorOptions['disable_smiley_box']), 'columns' => isset($editorOptions['columns']) ? $editorOptions['columns'] : 60, 'rows' => isset($editorOptions['rows']) ? $editorOptions['rows'] : 18, 'width' => isset($editorOptions['width']) ? $editorOptions['width'] : '100%', 'height' => isset($editorOptions['height']) ? $editorOptions['height'] : '250px', 'form' => isset($editorOptions['form']) ? $editorOptions['form'] : 'postmodify', 'bbc_level' => !empty($editorOptions['bbc_level']) ? $editorOptions['bbc_level'] : 'full', 'preview_type' => isset($editorOptions['preview_type']) ? (int) $editorOptions['preview_type'] : 1, 'labels' => !empty($editorOptions['labels']) ? $editorOptions['labels'] : array(), 'locale' => !empty($txt['lang_locale']) ? $txt['lang_locale'] : 'en_US'); // Switch between default images and back... mostly in case you don't have an PersonalMessage template, but do have a Post template. if (isset($settings['use_default_images']) && $settings['use_default_images'] == 'defaults' && isset($settings['default_template'])) { $temp1 = $settings['theme_url']; $settings['theme_url'] = $settings['default_theme_url']; $temp2 = $settings['images_url']; $settings['images_url'] = $settings['default_images_url']; $temp3 = $settings['theme_dir']; $settings['theme_dir'] = $settings['default_theme_dir']; } if (empty($bbc_tags)) { // The below array is used to show a command button in the editor, the execution // and display details of any added buttons must be defined in the javascript files // see jquery.sceditor.elkarte.js under the $.sceditor.plugins.bbcode.bbcode area // for examples of how to use the .set command to add codes. Include your new // JS with addInlineJavascript() or loadJavascriptFile() $bbc_tags['row1'] = array(array('bold', 'italic', 'underline', 'strike', 'superscript', 'subscript'), array('left', 'center', 'right', 'pre', 'tt'), array('font', 'size', 'color')); $bbc_tags['row2'] = array(array('quote', 'code', 'table'), array('bulletlist', 'orderedlist', 'horizontalrule'), array('spoiler', 'footnote'), array('image', 'link', 'email')); // Allow mods to add BBC buttons to the toolbar, actions are defined in the JS call_integration_hook('integrate_bbc_buttons', array(&$bbc_tags)); // Show the wysiwyg format and toggle buttons? $bbc_tags['row2'][] = array('removeformat', 'source'); // Generate a list of buttons that shouldn't be shown $disabled_tags = array(); if (!empty($modSettings['disabledBBC'])) { $disabled_tags = explode(',', $modSettings['disabledBBC']); } // Map codes to tags $translate_tags_to_code = array('b' => 'bold', 'i' => 'italic', 'u' => 'underline', 's' => 'strike', 'img' => 'image', 'url' => 'link', 'sup' => 'superscript', 'sub' => 'subscript', 'hr' => 'horizontalrule'); // Remove the toolbar buttons for any bbc tags that have been turned off in the ACP foreach ($disabled_tags as $tag) { // list is special, its prevents two tags if ($tag === 'list') { $context['disabled_tags']['bulletlist'] = true; $context['disabled_tags']['orderedlist'] = true; } elseif (isset($translate_tags_to_code[$tag])) { $context['disabled_tags'][$translate_tags_to_code[$tag]] = true; } // Tag is the same as the code, like font, color, size etc $context['disabled_tags'][trim($tag)] = true; } // Build our toolbar, taking in to account any bbc codes from integration $context['bbc_toolbar'] = array(); foreach ($bbc_tags as $row => $tagRow) { if (!isset($context['bbc_toolbar'][$row])) { $context['bbc_toolbar'][$row] = array(); } $tagsRow = array(); // For each row of buttons defined, lets build our tags foreach ($tagRow as $tags) { foreach ($tags as $tag) { // Just add this code in the existing grouping if (!isset($context['disabled_tags'][$tag])) { $tagsRow[] = $tag; } } // If the row is not empty, and the last added tag is not a space, add a space. if (!empty($tagsRow) && $tagsRow[count($tagsRow) - 1] != 'space') { $tagsRow[] = 'space'; } } // Build that beautiful button row if (!empty($tagsRow)) { $context['bbc_toolbar'][$row][] = implode(',', $tagsRow); } } } // Initialize smiley array... if not loaded before. if (empty($context['smileys']) && empty($editorOptions['disable_smiley_box'])) { $context['smileys'] = array('postform' => array(), 'popup' => array()); // Load smileys - don't bother to run a query if we're not using the database's ones anyhow. if (empty($modSettings['smiley_enable']) && $user_info['smiley_set'] != 'none') { $context['smileys']['postform'][] = array('smileys' => array(array('code' => ':)', 'filename' => 'smiley.gif', 'description' => $txt['icon_smiley']), array('code' => ';)', 'filename' => 'wink.gif', 'description' => $txt['icon_wink']), array('code' => ':D', 'filename' => 'cheesy.gif', 'description' => $txt['icon_cheesy']), array('code' => ';D', 'filename' => 'grin.gif', 'description' => $txt['icon_grin']), array('code' => '>:(', 'filename' => 'angry.gif', 'description' => $txt['icon_angry']), array('code' => ':))', 'filename' => 'laugh.gif', 'description' => $txt['icon_laugh']), array('code' => ':(', 'filename' => 'sad.gif', 'description' => $txt['icon_sad']), array('code' => ':o', 'filename' => 'shocked.gif', 'description' => $txt['icon_shocked']), array('code' => '8)', 'filename' => 'cool.gif', 'description' => $txt['icon_cool']), array('code' => '???', 'filename' => 'huh.gif', 'description' => $txt['icon_huh']), array('code' => '::)', 'filename' => 'rolleyes.gif', 'description' => $txt['icon_rolleyes']), array('code' => ':P', 'filename' => 'tongue.gif', 'description' => $txt['icon_tongue']), array('code' => ':-[', 'filename' => 'embarrassed.gif', 'description' => $txt['icon_embarrassed']), array('code' => ':-X', 'filename' => 'lipsrsealed.gif', 'description' => $txt['icon_lips']), array('code' => ':-\\', 'filename' => 'undecided.gif', 'description' => $txt['icon_undecided']), array('code' => ':-*', 'filename' => 'kiss.gif', 'description' => $txt['icon_kiss']), array('code' => 'O:)', 'filename' => 'angel.gif', 'description' => $txt['icon_angel']), array('code' => ':\'(', 'filename' => 'cry.gif', 'description' => $txt['icon_cry'], 'isLast' => true)), 'isLast' => true); } elseif ($user_info['smiley_set'] != 'none') { if (($temp = cache_get_data('posting_smileys', 480)) == null) { $request = $db->query('', ' SELECT code, filename, description, smiley_row, hidden FROM {db_prefix}smileys WHERE hidden IN (0, 2) ORDER BY smiley_row, smiley_order', array()); while ($row = $db->fetch_assoc($request)) { $row['filename'] = htmlspecialchars($row['filename'], ENT_COMPAT, 'UTF-8'); $row['description'] = htmlspecialchars($row['description'], ENT_COMPAT, 'UTF-8'); $context['smileys'][empty($row['hidden']) ? 'postform' : 'popup'][$row['smiley_row']]['smileys'][] = $row; } $db->free_result($request); foreach ($context['smileys'] as $section => $smileyRows) { $last_row = null; foreach ($smileyRows as $rowIndex => $smileys) { $context['smileys'][$section][$rowIndex]['smileys'][count($smileys['smileys']) - 1]['isLast'] = true; $last_row = $rowIndex; } if ($last_row !== null) { $context['smileys'][$section][$last_row]['isLast'] = true; } } cache_put_data('posting_smileys', $context['smileys'], 480); } else { $context['smileys'] = $temp; } // The smiley popup may take advantage of Jquery UI .... if (!empty($context['smileys']['popup'])) { $modSettings['jquery_include_ui'] = true; } } } // Set a flag so the sub template knows what to do... $context['show_bbc'] = !empty($modSettings['enableBBC']) && !empty($settings['show_bbc']); // Switch the URLs back... now we're back to whatever the main sub template is. (like folder in PersonalMessage.) if (isset($settings['use_default_images']) && $settings['use_default_images'] == 'defaults' && isset($settings['default_template'])) { $settings['theme_url'] = $temp1; $settings['images_url'] = $temp2; $settings['theme_dir'] = $temp3; } if (!empty($editorOptions['live_errors'])) { loadLanguage('Errors'); addInlineJavascript(' error_txts[\'no_subject\'] = ' . JavaScriptEscape($txt['error_no_subject']) . '; error_txts[\'no_message\'] = ' . JavaScriptEscape($txt['error_no_message']) . '; var subject_err = new errorbox_handler({ self: \'subject_err\', error_box_id: \'post_error\', error_checks: [{ code: \'no_subject\', efunction: function(box_value) { if (box_value.length === 0) return true; else return false; } }], check_id: "post_subject" }); var body_err_' . $editorOptions['id'] . ' = new errorbox_handler({ self: \'body_err_' . $editorOptions['id'] . '\', error_box_id: \'post_error\', error_checks: [{ code: \'no_message\', efunction: function(box_value) { if (box_value.length === 0) return true; else return false; } }], editor_id: \'' . $editorOptions['id'] . '\', editor: ' . JavaScriptEscape(' (function () { return $editor_data[\'' . $editorOptions['id'] . '\'].val(); });') . ' });', true); } }
/** * Configuration settings for the admin template * * @return string */ public function settings() { global $txt, $scripturl, $modSettings; // Generate a sample registration image. $verification_image = $scripturl . '?action=verificationcode;rand=' . md5(mt_rand()); // Visual verification. $config_vars = array(array('title', 'configure_verification_means'), array('desc', 'configure_verification_means_desc'), array('int', 'visual_verification_num_chars'), 'vv' => array('select', 'visual_verification_type', array($txt['setting_image_verification_off'], $txt['setting_image_verification_vsimple'], $txt['setting_image_verification_simple'], $txt['setting_image_verification_medium'], $txt['setting_image_verification_high'], $txt['setting_image_verification_extreme']), 'subtext' => $txt['setting_visual_verification_type_desc'])); // Save it if (isset($_GET['save'])) { if (isset($_POST['visual_verification_num_chars']) && $_POST['visual_verification_num_chars'] < 6) { $_POST['visual_verification_num_chars'] = 5; } } $_SESSION['visual_verification_code'] = ''; for ($i = 0; $i < $this->_num_chars; $i++) { $_SESSION['visual_verification_code'] .= $this->_standard_captcha_range[array_rand($this->_standard_captcha_range)]; } // Some javascript for CAPTCHA. if ($this->_use_graphic_library) { loadJavascriptFile('jquery.captcha.js'); addInlineJavascript(' $(\'#visual_verification_type\').Elk_Captcha({ \'imageURL\': ' . JavaScriptEscape($verification_image) . ', \'useLibrary\': true, \'letterCount\': ' . $this->_num_chars . ', \'refreshevent\': \'change\', \'admin\': true });', true); } // Show the image itself, or text saying we can't. if ($this->_use_graphic_library) { $config_vars['vv']['postinput'] = '<br /><img src="' . $verification_image . ';type=' . (empty($modSettings['visual_verification_type']) ? 0 : $modSettings['visual_verification_type']) . '" alt="' . $txt['setting_image_verification_sample'] . '" id="verification_image" /><br />'; } else { $config_vars['vv']['postinput'] = '<br /><span class="smalltext">' . $txt['setting_image_verification_nogd'] . '</span>'; } return $config_vars; }
/** * A template that displays a list of boards subdivided by categories, with * a checkbox to allow select them, toggle selection on the category title * * @param string $form_name The name of the form that contains the list * @param string $input_names Name that should be assigned to the inputs * @param bool $select_all if true the a "select all" option is shown */ function template_pick_boards($form_name, $input_names = 'brd', $select_all = true) { global $context, $txt; if ($select_all) { echo ' <h3 class="secondary_header"> <span id="category_toggle"> <span id="advanced_panel_toggle" class="', $context['boards_check_all'] ? 'expand' : 'collapse', '" style="display: none;" title="', $txt['hide'], '"></span> </span> <a href="#" id="advanced_panel_link">', $txt['choose_board'], '</a> </h3> <div id="advanced_panel_div"', $context['boards_check_all'] ? ' style="display: none;"' : '', '>'; } // Make two nice columns of boards, link each category header to toggle select all boards in each $group_cats = optimizeBoardsSubdivision($context['boards_in_category'], $context['num_boards']); foreach ($group_cats as $groups) { echo ' <ul class="ignoreboards floatleft">'; foreach ($groups as $cat_id) { $category = $context['categories'][$cat_id]; echo ' <li class="category"> <a href="javascript:void(0);" onclick="selectBoards([', implode(', ', $category['child_ids']), '], \'', $form_name, '\', \'', $input_names, '\'); return false;">', $category['name'], '</a> <ul>'; foreach ($category['boards'] as $board) { echo ' <li class="board" style="margin-', $context['right_to_left'] ? 'right' : 'left', ': ', $board['child_level'], 'em;"> <label for="', $input_names, $board['id'], '"> <input type="checkbox" id="', $input_names, $board['id'], '" name="', $input_names, '[', $board['id'], ']" value="', $board['id'], '"', $board['selected'] ? ' checked="checked"' : '', ' class="input_check" /> ', $board['name'], ' </label> </li>'; } echo ' </ul> </li>'; } echo ' </ul>'; } // Provide an easy way to select all boards if ($select_all) { echo ' </div> <div class="submitbutton"> <span class="floatleft"> <input type="checkbox" name="all" id="check_all" value=""', $context['boards_check_all'] ? ' checked="checked"' : '', ' onclick="invertAll(this, this.form, \'', $input_names, '\');" class="input_check" /> <label for="check_all"> <em> ', $txt['check_all'], '</em> </label> </span> </div>'; // And now all the JS to make this work addInlineJavascript(' // Some javascript for the advanced board select toggling var oAdvancedPanelToggle = new elk_Toggle({ bToggleEnabled: true, bCurrentlyCollapsed: ' . ($context['boards_check_all'] ? 'true' : 'false') . ', aSwappableContainers: [ \'advanced_panel_div\' ], aSwapClasses: [ { sId: \'advanced_panel_toggle\', classExpanded: \'collapse\', titleExpanded: ' . JavaScriptEscape($txt['hide']) . ', classCollapsed: \'expand\', titleCollapsed: ' . JavaScriptEscape($txt['show']) . ' } ], aSwapLinks: [ { sId: \'advanced_panel_link\', msgExpanded: ' . JavaScriptEscape($txt['choose_board']) . ', msgCollapsed: ' . JavaScriptEscape($txt['choose_board']) . ' } ], });', true); } }
/** * Interface to list the existing themes. */ function template_list_themes() { global $context, $settings, $scripturl, $txt; echo ' <div id="admincenter"> <h2 class="category_header">', $txt['themeadmin_list_heading'], '</h2> <div class="information"> ', $txt['themeadmin_list_tip'], ' </div> <form id="admin_form_wrapper" action="', $scripturl, '?action=admin;area=theme;', $context['session_var'], '=', $context['session_id'], ';sa=list" method="post" accept-charset="UTF-8">'; // Show each theme.... with X for delete and a link to settings. foreach ($context['themes'] as $theme) { echo ' <div class="theme_', $theme['id'], '"> <h3 class="category_header"> ', $theme['name'], '', !empty($theme['version']) ? ' <em>(' . $theme['version'] . ')</em>' : ''; // You *cannot* delete the default theme. It's important! if ($theme['id'] != 1) { echo ' <a class="delete_theme icon" data-theme_id="', $theme['id'], '" href="', $scripturl, '?action=admin;area=theme;sa=remove;th=', $theme['id'], ';', $context['session_var'], '=', $context['session_id'], ';', $context['admin-tr_token_var'], '=', $context['admin-tr_token'], '"> <img src="', $settings['images_url'], '/icons/delete.png" alt="', $txt['theme_remove'], '" title="', $txt['theme_remove'], '" /> </a>'; } else { echo ' <a class="hdicon cat_img_helptopics help floatleft" href="' . $scripturl . '?action=quickhelp;help=themeadmin_delete_help" onclick="return reqOverlayDiv(this.href);" id="themeadmin_delete_help" title="' . $txt['help'] . '"></a>'; } echo ' </h3> <dl class="content settings themes_list"> <dt><a href="', $scripturl, '?action=admin;area=theme;th=', $theme['id'], ';', $context['session_var'], '=', $context['session_id'], ';sa=list" class="linkbutton floatleft">', $txt['theme_edit_settings'], '</a></dt> <dt>', $txt['themeadmin_list_theme_dir'], '</dt> <dd', $theme['valid_path'] ? '' : ' class="error"', '>', $theme['theme_dir'], $theme['valid_path'] ? '' : ' ' . $txt['themeadmin_list_invalid'], '</dd> <dt>', $txt['themeadmin_list_theme_url'], '</dt> <dd>', $theme['theme_url'], '</dd> <dt>', $txt['themeadmin_list_images_url'], '</dt> <dd>', $theme['images_url'], '</dd> </dl> </div>'; } echo ' <h3 class="category_header"> <a class="hdicon cat_img_helptopics help" href="', $scripturl, '?action=quickhelp;help=themeadmin_list_reset" onclick="return reqOverlayDiv(this.href);" id="themeadmin_list_reset" title="', $txt['help'], '"></a> ', $txt['themeadmin_list_reset'], ' </h3> <dl class="content settings themes_list"> <dt> <label for="reset_dir">', $txt['themeadmin_list_reset_dir'], '</label> </dt> <dd> <input type="text" name="reset_dir" id="reset_dir" value="', $context['reset_dir'], '" size="40" style="width: 80%;" class="input_text" /> </dd> <dt> <label for="reset_url">', $txt['themeadmin_list_reset_url'], '</label> </dt> <dd> <input type="text" name="reset_url" id="reset_url" value="', $context['reset_url'], '" size="40" style="width: 80%;" class="input_text" /> </dd> </dl> <input type="submit" name="save" value="', $txt['themeadmin_list_reset_go'], '" class="right_submit" /> <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '" /> <input type="hidden" name="', $context['admin-tl_token_var'], '" value="', $context['admin-tl_token'], '" /> </form> </div>'; addInlineJavascript(' initDeleteThemes();', true); }
function integrate_chars_main_menu(&$buttons) { global $context, $scripturl, $txt, $settings; // While we're here in setupMenuContext, we might as well do other things we would // otherwise have done in that function. if (!$context['user']['is_guest']) { if (file_exists($settings['default_theme_dir'] . '/css/chars.css')) { loadCSSFile('chars.css', ['default_theme' => true], 'chars'); addInlineJavascript(' user_menus.add("characters", "' . $scripturl . '?action=profile;area=characters_popup");', true); } } // Now add a characters menu, to effectively replace the members menu. $temp_buttons = []; foreach ($buttons as $k => $v) { if ($k == 'mlist') { $temp_buttons['characters'] = ['title' => $txt['chars_menu_title'], 'icon' => 'mlist', 'href' => $scripturl . '?action=characters', 'show' => $context['allow_memberlist'], 'sub_buttons' => []]; $groups = get_main_menu_groups(); foreach ($groups as $id => $group_name) { $temp_buttons['characters']['sub_buttons']['group' . $id] = ['title' => $group_name, 'href' => $scripturl . '?action=characters;sa=sheets;group=' . $id, 'show' => true]; } continue; } $temp_buttons[$k] = $v; } $buttons = $temp_buttons; }
/** * Edit some profile fields? * * - Accessed with ?action=admin;area=featuresettings;sa=profileedit * * @uses sub template edit_profile_field */ public function action_profileedit() { global $txt, $scripturl, $context; require_once SUBSDIR . '/ManageFeatures.subs.php'; loadTemplate('ManageFeatures'); // Sort out the context! $context['fid'] = isset($_GET['fid']) ? (int) $_GET['fid'] : 0; $context[$context['admin_menu_name']]['current_subsection'] = 'profile'; $context['page_title'] = $context['fid'] ? $txt['custom_edit_title'] : $txt['custom_add_title']; $context['sub_template'] = 'edit_profile_field'; // any errors messages to show? if (isset($_GET['msg'])) { loadLanguage('Errors'); if (isset($txt['custom_option_' . $_GET['msg']])) { $context['custom_option__error'] = $txt['custom_option_' . $_GET['msg']]; } } // Load the profile language for section names. loadLanguage('Profile'); // Load up the profile field, if one was supplied if ($context['fid']) { $context['field'] = getProfileField($context['fid']); } // Setup the default values as needed. if (empty($context['field'])) { $context['field'] = array('name' => '', 'colname' => '???', 'desc' => '', 'profile_area' => 'forumprofile', 'reg' => false, 'display' => false, 'memberlist' => false, 'type' => 'text', 'max_length' => 255, 'rows' => 4, 'cols' => 30, 'bbc' => false, 'default_check' => false, 'default_select' => '', 'options' => array('', '', ''), 'active' => true, 'private' => false, 'can_search' => false, 'mask' => 'nohtml', 'regex' => '', 'enclose' => '', 'placement' => 0); } // All the javascript for this page... everything else is in admin.js addJavascriptVar(array('startOptID' => count($context['field']['options']))); addInlineJavascript('updateInputBoxes();', true); // Are we toggling which ones are active? if (isset($_POST['onoff'])) { checkSession(); validateToken('admin-scp'); // Enable and disable custom fields as required. $enabled = array(0); foreach ($_POST['cust'] as $id) { $enabled[] = (int) $id; } updateRenamedProfileStatus($enabled); } elseif (isset($_POST['save'])) { checkSession(); validateToken('admin-ecp'); // Everyone needs a name - even the (bracket) unknown... if (trim($_POST['field_name']) == '') { redirectexit($scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $_GET['fid'] . ';msg=need_name'); } // Regex you say? Do a very basic test to see if the pattern is valid if (!empty($_POST['regex']) && @preg_match($_POST['regex'], 'dummy') === false) { redirectexit($scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $_GET['fid'] . ';msg=regex_error'); } $_POST['field_name'] = Util::htmlspecialchars($_POST['field_name']); $_POST['field_desc'] = Util::htmlspecialchars($_POST['field_desc']); // Checkboxes... $show_reg = isset($_POST['reg']) ? (int) $_POST['reg'] : 0; $show_display = isset($_POST['display']) ? 1 : 0; $show_memberlist = isset($_POST['memberlist']) ? 1 : 0; $bbc = isset($_POST['bbc']) ? 1 : 0; $show_profile = $_POST['profile_area']; $active = isset($_POST['active']) ? 1 : 0; $private = isset($_POST['private']) ? (int) $_POST['private'] : 0; $can_search = isset($_POST['can_search']) ? 1 : 0; // Some masking stuff... $mask = isset($_POST['mask']) ? $_POST['mask'] : ''; if ($mask == 'regex' && isset($_POST['regex'])) { $mask .= $_POST['regex']; } $field_length = isset($_POST['max_length']) ? (int) $_POST['max_length'] : 255; $enclose = isset($_POST['enclose']) ? $_POST['enclose'] : ''; $placement = isset($_POST['placement']) ? (int) $_POST['placement'] : 0; // Select options? $field_options = ''; $newOptions = array(); $default = isset($_POST['default_check']) && $_POST['field_type'] == 'check' ? 1 : ''; if (!empty($_POST['select_option']) && ($_POST['field_type'] == 'select' || $_POST['field_type'] == 'radio')) { foreach ($_POST['select_option'] as $k => $v) { // Clean, clean, clean... $v = Util::htmlspecialchars($v); $v = strtr($v, array(',' => '')); // Nada, zip, etc... if (trim($v) == '') { continue; } // Otherwise, save it boy. $field_options .= $v . ','; // This is just for working out what happened with old options... $newOptions[$k] = $v; // Is it default? if (isset($_POST['default_select']) && $_POST['default_select'] == $k) { $default = $v; } } if (isset($_POST['default_select']) && $_POST['default_select'] == 'no_default') { $default = 'no_default'; } $field_options = substr($field_options, 0, -1); } // Text area by default has dimensions if ($_POST['field_type'] == 'textarea') { $default = (int) $_POST['rows'] . ',' . (int) $_POST['cols']; } // Come up with the unique name? if (empty($context['fid'])) { $colname = Util::substr(strtr($_POST['field_name'], array(' ' => '')), 0, 6); preg_match('~([\\w\\d_-]+)~', $colname, $matches); // If there is nothing to the name, then let's start our own - for foreign languages etc. if (isset($matches[1])) { $colname = $initial_colname = 'cust_' . strtolower($matches[1]); } else { $colname = $initial_colname = 'cust_' . mt_rand(1, 999999); } $unique = ensureUniqueProfileField($colname, $initial_colname); // Still not a unique colum name? Leave it up to the user, then. if (!$unique) { fatal_lang_error('custom_option_not_unique'); } } else { // Anything going to check or select is pointless keeping - as is anything coming from check! if ($_POST['field_type'] == 'check' && $context['field']['type'] != 'check' || ($_POST['field_type'] == 'select' || $_POST['field_type'] == 'radio') && $context['field']['type'] != 'select' && $context['field']['type'] != 'radio' || $context['field']['type'] == 'check' && $_POST['field_type'] != 'check') { deleteProfileFieldUserData($context['field']['colname']); } elseif ($_POST['field_type'] == 'select' || $_POST['field_type'] == 'radio') { $optionChanges = array(); $takenKeys = array(); // Work out what's changed! foreach ($context['field']['options'] as $k => $option) { if (trim($option) == '') { continue; } // Still exists? if (in_array($option, $newOptions)) { $takenKeys[] = $k; continue; } } // Finally - have we renamed it - or is it really gone? foreach ($optionChanges as $k => $option) { // Just been renamed? if (!in_array($k, $takenKeys) && !empty($newOptions[$k])) { updateRenamedProfileField($k, $newOptions, $context['field']['colname'], $option); } } } // @todo Maybe we should adjust based on new text length limits? } // Updating an existing field? if ($context['fid']) { $field_data = array('field_length' => $field_length, 'show_reg' => $show_reg, 'show_display' => $show_display, 'show_memberlist' => $show_memberlist, 'private' => $private, 'active' => $active, 'can_search' => $can_search, 'bbc' => $bbc, 'current_field' => $context['fid'], 'field_name' => $_POST['field_name'], 'field_desc' => $_POST['field_desc'], 'field_type' => $_POST['field_type'], 'field_options' => $field_options, 'show_profile' => $show_profile, 'default_value' => $default, 'mask' => $mask, 'enclose' => $enclose, 'placement' => $placement); updateProfileField($field_data); // Just clean up any old selects - these are a pain! if (($_POST['field_type'] == 'select' || $_POST['field_type'] == 'radio') && !empty($newOptions)) { deleteOldProfileFieldSelects($newOptions, $context['field']['colname']); } } else { $new_field = array('col_name' => $colname, 'field_name' => $_POST['field_name'], 'field_desc' => $_POST['field_desc'], 'field_type' => $_POST['field_type'], 'field_length' => $field_length, 'field_options' => $field_options, 'show_reg' => $show_reg, 'show_display' => $show_display, 'show_memberlist' => $show_memberlist, 'show_profile' => $show_profile, 'private' => $private, 'active' => $active, 'default' => $default, 'can_search' => $can_search, 'bbc' => $bbc, 'mask' => $mask, 'enclose' => $enclose, 'placement' => $placement, 'vieworder' => list_getProfileFieldSize() + 1); addProfileField($new_field); } } elseif (isset($_POST['delete']) && $context['field']['colname']) { checkSession(); validateToken('admin-ecp'); // Delete the old data first, then the field. deleteProfileFieldUserData($context['field']['colname']); deleteProfileField($context['fid']); } // Rebuild display cache etc. if (isset($_POST['delete']) || isset($_POST['save']) || isset($_POST['onoff'])) { checkSession(); // Update the display cache updateDisplayCache(); redirectexit('action=admin;area=featuresettings;sa=profile'); } createToken('admin-ecp'); }
function template_shoutbox_prune() { global $context, $scripturl, $txt; echo ' <form id="admin_form_wrapper" action="', $scripturl, '?action=admin;area=portalshoutbox;sa=prune" method="post" accept-charset="UTF-8"> <h3 class="category_header"> ', $context['page_title'], ' </h3> <div class="sp_content_padding"> <dl class="sp_form"> <dt> <input type="radio" name="type" id="type_all" value="all" class="input_radio" /> <label for="type_all">', $txt['sp_admin_shoutbox_opt_all'], '</label> </dt> <dd> </dd> <dt> <input type="radio" name="type" id="type_days" value="days" class="input_radio" /> <label for="type_days">', $txt['sp_admin_shoutbox_opt_days'], '</label> </dt> <dd> <input type="text" name="days" value="" size="5" onfocus="document.getElementById(\'type_days\').checked = true;" class="input_text" /> </dd> <dt> <input type="radio" name="type" id="type_member" value="member" class="input_radio" /> <label for="type_member">', $txt['sp_admin_shoutbox_opt_member'], '</label> </dt> <dd> <input type="text" name="member" id="member" value="" onclick="document.getElementById(\'type_member\').checked = true;" size="15" class="input_text" /> </dd> </dl> <input type="submit" name="submit" value="', $context['page_title'], '" class="right_submit" /> </div> <input type="hidden" name="shoutbox_id" value="', $context['shoutbox']['id'], '" /> <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '" /> </form>'; addInlineJavascript(' var oPruneSuggest = new smc_AutoSuggest({ sSelf: \'oPruneSuggest\', sSessionId: elk_session_id, sSessionVar: elk_session_var, sSuggestId: \'member\', sControlId: \'member\', sSearchType: \'member\', sTextDeleteItem: \'' . $txt['autosuggest_delete_item'] . '\', bItemList: false });', true); }
/** * Retrieve and return all admin settings for the calendar. */ private function _initCalendarSettingsForm() { global $txt, $context; // Instantiate the form $this->_calendarSettings = new Settings_Form(); // Initialize it with our settings $config_vars = $this->_settings(); // Some important context stuff $context['page_title'] = $txt['calendar_settings']; $context['sub_template'] = 'show_settings'; // Lets start off with the premission blocks collapsed addInlineJavascript('var legend = $(\'legend\'); legend.siblings().slideToggle("fast"); legend.parent().toggleClass("collapsed")', true); return $this->_calendarSettings->settings($config_vars); }
/** * Allows to view and modify the mail settings. * * @uses show_settings sub template */ public function action_mailSettings_display() { global $txt, $scripturl, $context, $txtBirthdayEmails; // Some important context stuff $context['page_title'] = $txt['mail_settings']; $context['sub_template'] = 'show_settings'; // Initialize the form $this->_initMailSettingsForm(); // Piece of redundant code, for the javascript $processedBirthdayEmails = array(); foreach ($txtBirthdayEmails as $key => $value) { $index = substr($key, 0, strrpos($key, '_')); $element = substr($key, strrpos($key, '_') + 1); $processedBirthdayEmails[$index][$element] = $value; } $config_vars = $this->_mailSettings->settings(); // Saving? if (isset($_GET['save'])) { // Make the SMTP password a little harder to see in a backup etc. if (!empty($_POST['smtp_password'][1])) { $_POST['smtp_password'][0] = base64_encode($_POST['smtp_password'][0]); $_POST['smtp_password'][1] = base64_encode($_POST['smtp_password'][1]); } checkSession(); // We don't want to save the subject and body previews. unset($config_vars['birthday_subject'], $config_vars['birthday_body']); call_integration_hook('integrate_save_mail_settings'); // You can not send more per page load than you can per minute if (!empty($_POST['mail_batch_size'])) { $_POST['mail_batch_size'] = min((int) $_POST['mail_batch_size'], (int) $_POST['mail_period_limit']); } Settings_Form::save_db($config_vars); redirectexit('action=admin;area=mailqueue;sa=settings'); } $context['post_url'] = $scripturl . '?action=admin;area=mailqueue;save;sa=settings'; $context['settings_title'] = $txt['mailqueue_settings']; // Prepare the config form Settings_Form::prepare_db($config_vars); // Build a litte JS so the birthday mail can be seen $javascript = ' var bDay = {'; $i = 0; foreach ($processedBirthdayEmails as $index => $email) { $is_last = ++$i == count($processedBirthdayEmails); $javascript .= ' ' . $index . ': { subject: ' . JavaScriptEscape($email['subject']) . ', body: ' . JavaScriptEscape(nl2br($email['body'])) . ' }' . (!$is_last ? ',' : ''); } addInlineJavascript($javascript . ' }; function fetch_birthday_preview() { var index = document.getElementById(\'birthday_email\').value; document.getElementById(\'birthday_subject\').innerHTML = bDay[index].subject; document.getElementById(\'birthday_body\').innerHTML = bDay[index].body; }', true); }
/** * Template for the section to compose an email to members */ function template_email_members_compose() { global $context, $txt, $scripturl; echo ' <div id="admincenter"> <form name="newsmodify" action="', $scripturl, '?action=admin;area=news;sa=mailingsend" method="post" accept-charset="UTF-8"> <h3 class="category_header"> <a class="hdicon cat_img_helptopics help" href="', $scripturl, '?action=quickhelp;help=email_members" onclick="return reqOverlayDiv(this.href);" title="', $txt['help'], '"></a> ', $txt['admin_newsletters'], ' </h3> <div class="information"> ', str_replace('{help_emailmembers}', $scripturl . '?action=quickhelp;help=emailmembers" onclick="return reqOverlayDiv(this.href);', $txt['email_variables']), ' </div>'; // The preview section echo ' <div id="preview_section" class="forumposts"', isset($context['preview_message']) ? '' : ' style="display: none;"', '> <h3 class="category_header"> <span id="preview_subject">', empty($context['preview_subject']) ? '' : $context['preview_subject'], '</span> </h3> <div class="post" id="preview_body"> ', empty($context['preview_message']) ? '<br />' : $context['preview_message'], ' </div> </div>'; // Any errors to speak of? echo ' <div class="windowbg"> <div id="post_error" class="', empty($context['error_type']) || $context['error_type'] != 'serious' ? 'warningbox' : 'errorbox', '"', empty($context['post_error']['messages']) ? ' style="display: none"' : '', '> <dl> <dt> <strong id="error_serious">', $txt['error_while_submitting'], '</strong> </dt> <dd> <ul class="error" id="post_error_list"> ', empty($context['post_error']['messages']) ? '' : '<li>' . implode('</li><li>', $context['post_error']['messages']) . '</li>', ' </ul> </dd> </dl> </div>'; // Show the editor area echo ' <div class="editor_wrapper"> <dl id="post_header"> <dt class="clear_left"> <label for="subject"', isset($context['post_error']['no_subject']) ? ' class="error"' : '', ' id="caption_subject">', $txt['subject'], ':</label> </dt> <dd id="pm_subject"> <input type="text" id="subject" name="subject" value="', $context['subject'], '" tabindex="', $context['tabindex']++, '" size="60" maxlength="60"', isset($context['post_error']['no_subject']) ? ' class="error"' : ' class="input_text"', '/> </dd> </dl> <hr class="clear" />'; // Show BBC buttons, smileys and textbox. echo ' ', template_control_richedit($context['post_box_name'], 'smileyBox_message', 'bbcBox_message'); echo ' <ul> <li><label for="send_pm"><input type="checkbox" name="send_pm" id="send_pm" ', !empty($context['send_pm']) ? 'checked="checked"' : '', 'class="input_check" onclick="checkboxes_status(this);" /> ', $txt['email_as_pms'], '</label></li> <li><label for="send_html"><input type="checkbox" name="send_html" id="send_html" ', !empty($context['send_html']) ? 'checked="checked"' : '', 'class="input_check" onclick="checkboxes_status(this);" /> ', $txt['email_as_html'], '</label></li> <li><label for="parse_html"><input type="checkbox" name="parse_html" id="parse_html" checked="checked" disabled="disabled" class="input_check" /> ', $txt['email_parsed_html'], '</label></li> </ul> <div class="submitbutton"> ', template_control_richedit_buttons($context['post_box_name']), ' </div> </div> <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '" /> <input type="hidden" name="email_force" value="', $context['email_force'], '" /> <input type="hidden" name="total_emails" value="', $context['total_emails'], '" /> <input type="hidden" name="max_id_member" value="', $context['max_id_member'], '" /> </div>'; foreach ($context['recipients'] as $key => $values) { echo ' <input type="hidden" name="', $key, '" value="', implode($key == 'emails' ? ';' : ',', $values), '" />'; } // The vars used to preview a newsletter without loading a new page, used by post.js previewControl() addInlineJavascript(' var form_name = "newsmodify", preview_area = "news", txt_preview_title = "' . $txt['preview_title'] . '", txt_preview_fetch = "' . $txt['preview_fetch'] . '"; function checkboxes_status (item) { if (item.id == \'send_html\') document.getElementById(\'parse_html\').disabled = !document.getElementById(\'parse_html\').disabled; if (item.id == \'send_pm\') { if (!document.getElementById(\'send_html\').checked) document.getElementById(\'parse_html\').disabled = true; else document.getElementById(\'parse_html\').disabled = false; document.getElementById(\'send_html\').disabled = !document.getElementById(\'send_html\').disabled; } }', true); echo ' </form> </div>'; }
/** * Handles admin security spam settings. * * - Displays a page with settings and eventually allows the admin to change them. */ public function action_spamSettings_display() { global $txt, $scripturl, $context, $modSettings; // Initialize the form $this->_initSpamSettingsForm(); // Retrieve the current config settings $config_vars = $this->_spamSettings->settings(); // Saving? if (isset($_GET['save'])) { checkSession(); // Fix PM settings. $_POST['pm_spam_settings'] = (int) $_POST['max_pm_recipients'] . ',' . (int) $_POST['pm_posts_verification'] . ',' . (int) $_POST['pm_posts_per_hour']; // Guest requiring verification! if (empty($_POST['posts_require_captcha']) && !empty($_POST['guests_require_captcha'])) { $_POST['posts_require_captcha'] = -1; } unset($config_vars['pm1'], $config_vars['pm2'], $config_vars['pm3'], $config_vars['guest_verify']); $config_vars[] = array('text', 'pm_spam_settings'); call_integration_hook('integrate_save_spam_settings'); // Now save. Settings_Form::save_db($config_vars); cache_put_data('verificationQuestionIds', null, 300); redirectexit('action=admin;area=securitysettings;sa=spam'); } // Add in PM spam settings on the fly list($modSettings['max_pm_recipients'], $modSettings['pm_posts_verification'], $modSettings['pm_posts_per_hour']) = explode(',', $modSettings['pm_spam_settings']); // And the same for guests requiring verification. $modSettings['guests_require_captcha'] = !empty($modSettings['posts_require_captcha']); $modSettings['posts_require_captcha'] = !isset($modSettings['posts_require_captcha']) || $modSettings['posts_require_captcha'] == -1 ? 0 : $modSettings['posts_require_captcha']; // Some minor javascript for the guest post setting. if ($modSettings['posts_require_captcha']) { addInlineJavascript('document.getElementById(\'guests_require_captcha\').disabled = true;', true); } $context['post_url'] = $scripturl . '?action=admin;area=securitysettings;save;sa=spam'; $context['settings_title'] = $txt['antispam_Settings']; Settings_Form::prepare_db($config_vars); }
/** * The central part of the board - topic display. * * What it does: * - This function loads the posts in a topic up so they can be displayed. * - It uses the main sub template of the Display template. * - It requires a topic, and can go to the previous or next topic from it. * - It jumps to the correct post depending on a number/time/IS_MSG passed. * - It depends on the messages_per_page, defaultMaxMessages and enableAllMessages settings. * - It is accessed by ?topic=id_topic.START. */ public function action_display() { global $scripturl, $txt, $modSettings, $context, $settings; global $options, $user_info, $board_info, $topic, $board; global $attachments, $messages_request; // What are you gonna display if these are empty?! if (empty($topic)) { fatal_lang_error('no_board', false); } // Load the template loadTemplate('Display'); $context['sub_template'] = 'messages'; // And the topic functions require_once SUBSDIR . '/Topic.subs.php'; require_once SUBSDIR . '/Messages.subs.php'; // Not only does a prefetch make things slower for the server, but it makes it impossible to know if they read it. if (isset($_SERVER['HTTP_X_MOZ']) && $_SERVER['HTTP_X_MOZ'] == 'prefetch') { @ob_end_clean(); header('HTTP/1.1 403 Prefetch Forbidden'); die; } // How much are we sticking on each page? $context['messages_per_page'] = empty($modSettings['disableCustomPerPage']) && !empty($options['messages_per_page']) ? $options['messages_per_page'] : $modSettings['defaultMaxMessages']; $template_layers = Template_Layers::getInstance(); $template_layers->addEnd('messages_informations'); $includeUnapproved = !$modSettings['postmod_active'] || allowedTo('approve_posts'); // Let's do some work on what to search index. if (count($_GET) > 2) { foreach ($_GET as $k => $v) { if (!in_array($k, array('topic', 'board', 'start', session_name()))) { $context['robot_no_index'] = true; } } } if (!empty($_REQUEST['start']) && (!is_numeric($_REQUEST['start']) || $_REQUEST['start'] % $context['messages_per_page'] != 0)) { $context['robot_no_index'] = true; } // Find the previous or next topic. Make a fuss if there are no more. if (isset($_REQUEST['prev_next']) && ($_REQUEST['prev_next'] == 'prev' || $_REQUEST['prev_next'] == 'next')) { // No use in calculating the next topic if there's only one. if ($board_info['num_topics'] > 1) { $includeStickies = !empty($modSettings['enableStickyTopics']); $topic = $_REQUEST['prev_next'] === 'prev' ? previousTopic($topic, $board, $user_info['id'], $includeUnapproved, $includeStickies) : nextTopic($topic, $board, $user_info['id'], $includeUnapproved, $includeStickies); $context['current_topic'] = $topic; } // Go to the newest message on this topic. $_REQUEST['start'] = 'new'; } // Add 1 to the number of views of this topic (except for robots). if (!$user_info['possibly_robot'] && (empty($_SESSION['last_read_topic']) || $_SESSION['last_read_topic'] != $topic)) { increaseViewCounter($topic); $_SESSION['last_read_topic'] = $topic; } $topic_selects = array(); $topic_tables = array(); $topic_parameters = array('topic' => $topic, 'member' => $user_info['id'], 'board' => (int) $board); // Allow addons to add additional details to the topic query call_integration_hook('integrate_topic_query', array(&$topic_selects, &$topic_tables, &$topic_parameters)); // Load the topic details $topicinfo = getTopicInfo($topic_parameters, 'all', $topic_selects, $topic_tables); if (empty($topicinfo)) { fatal_lang_error('not_a_topic', false); } // Is this a moved topic that we are redirecting to? if (!empty($topicinfo['id_redirect_topic']) && !isset($_GET['noredir'])) { markTopicsRead(array($user_info['id'], $topic, $topicinfo['id_last_msg'], 0), $topicinfo['new_from'] !== 0); redirectexit('topic=' . $topicinfo['id_redirect_topic'] . '.0;redirfrom=' . $topicinfo['id_topic']); } $context['real_num_replies'] = $context['num_replies'] = $topicinfo['num_replies']; $context['topic_first_message'] = $topicinfo['id_first_msg']; $context['topic_last_message'] = $topicinfo['id_last_msg']; $context['topic_unwatched'] = isset($topicinfo['unwatched']) ? $topicinfo['unwatched'] : 0; if (isset($_GET['redirfrom'])) { $redir_topics = topicsList(array((int) $_GET['redirfrom'])); if (!empty($redir_topics[(int) $_GET['redirfrom']])) { $context['topic_redirected_from'] = $redir_topics[(int) $_GET['redirfrom']]; $context['topic_redirected_from']['redir_href'] = $scripturl . '?topic=' . $context['topic_redirected_from']['id_topic'] . '.0;noredir'; } } // Add up unapproved replies to get real number of replies... if ($modSettings['postmod_active'] && allowedTo('approve_posts')) { $context['real_num_replies'] += $topicinfo['unapproved_posts'] - ($topicinfo['approved'] ? 0 : 1); } // If this topic was derived from another, set the followup details if (!empty($topicinfo['derived_from'])) { require_once SUBSDIR . '/FollowUps.subs.php'; $context['topic_derived_from'] = topicStartedHere($topic, $includeUnapproved); } // If this topic has unapproved posts, we need to work out how many posts the user can see, for page indexing. if (!$includeUnapproved && $topicinfo['unapproved_posts'] && !$user_info['is_guest']) { $myUnapprovedPosts = unapprovedPosts($topic, $user_info['id']); $context['total_visible_posts'] = $context['num_replies'] + $myUnapprovedPosts + ($topicinfo['approved'] ? 1 : 0); } elseif ($user_info['is_guest']) { $context['total_visible_posts'] = $context['num_replies'] + ($topicinfo['approved'] ? 1 : 0); } else { $context['total_visible_posts'] = $context['num_replies'] + $topicinfo['unapproved_posts'] + ($topicinfo['approved'] ? 1 : 0); } // When was the last time this topic was replied to? Should we warn them about it? if (!empty($modSettings['oldTopicDays'])) { $mgsOptions = basicMessageInfo($topicinfo['id_last_msg'], true); $context['oldTopicError'] = $mgsOptions['poster_time'] + $modSettings['oldTopicDays'] * 86400 < time() && empty($topicinfo['is_sticky']); } else { $context['oldTopicError'] = false; } // The start isn't a number; it's information about what to do, where to go. if (!is_numeric($_REQUEST['start'])) { // Redirect to the page and post with new messages, originally by Omar Bazavilvazo. if ($_REQUEST['start'] == 'new') { // Guests automatically go to the last post. if ($user_info['is_guest']) { $context['start_from'] = $context['total_visible_posts'] - 1; $_REQUEST['start'] = $context['start_from']; } else { // Fall through to the next if statement. $_REQUEST['start'] = 'msg' . $topicinfo['new_from']; } } // Start from a certain time index, not a message. if (substr($_REQUEST['start'], 0, 4) == 'from') { $timestamp = (int) substr($_REQUEST['start'], 4); if ($timestamp === 0) { $_REQUEST['start'] = 0; } else { // Find the number of messages posted before said time... $context['start_from'] = countNewPosts($topic, $topicinfo, $timestamp); $_REQUEST['start'] = $context['start_from']; } } elseif (substr($_REQUEST['start'], 0, 3) == 'msg') { $virtual_msg = (int) substr($_REQUEST['start'], 3); if (!$topicinfo['unapproved_posts'] && $virtual_msg >= $topicinfo['id_last_msg']) { $context['start_from'] = $context['total_visible_posts'] - 1; } elseif (!$topicinfo['unapproved_posts'] && $virtual_msg <= $topicinfo['id_first_msg']) { $context['start_from'] = 0; } else { $only_approved = $modSettings['postmod_active'] && $topicinfo['unapproved_posts'] && !allowedTo('approve_posts'); $context['start_from'] = countMessagesBefore($topic, $virtual_msg, false, $only_approved, !$user_info['is_guest']); } // We need to reverse the start as well in this case. $_REQUEST['start'] = $context['start_from']; } } // Mark the mention as read if requested if (isset($_REQUEST['mentionread']) && !empty($virtual_msg)) { require_once CONTROLLERDIR . '/Mentions.controller.php'; $mentions = new Mentions_Controller(); $mentions->setData(array('id_mention' => $_REQUEST['item'], 'mark' => $_REQUEST['mark'])); $mentions->action_markread(); } // Create a previous next string if the selected theme has it as a selected option. if ($modSettings['enablePreviousNext']) { $context['links'] += array('go_prev' => $scripturl . '?topic=' . $topic . '.0;prev_next=prev#new', 'go_next' => $scripturl . '?topic=' . $topic . '.0;prev_next=next#new'); } // Derived from, set the link back if (!empty($context['topic_derived_from'])) { $context['links']['derived_from'] = $scripturl . '?msg=' . $context['topic_derived_from']['derived_from']; } // Check if spellchecking is both enabled and actually working. (for quick reply.) $context['show_spellchecking'] = !empty($modSettings['enableSpellChecking']) && function_exists('pspell_new'); if ($context['show_spellchecking']) { loadJavascriptFile('spellcheck.js', array('defer' => true)); } // Do we need to show the visual verification image? $context['require_verification'] = !$user_info['is_mod'] && !$user_info['is_admin'] && !empty($modSettings['posts_require_captcha']) && ($user_info['posts'] < $modSettings['posts_require_captcha'] || $user_info['is_guest'] && $modSettings['posts_require_captcha'] == -1); if ($context['require_verification']) { require_once SUBSDIR . '/VerificationControls.class.php'; $verificationOptions = array('id' => 'post'); $context['require_verification'] = create_control_verification($verificationOptions); $context['visual_verification_id'] = $verificationOptions['id']; } // Are we showing signatures - or disabled fields? $context['signature_enabled'] = substr($modSettings['signature_settings'], 0, 1) == 1; $context['disabled_fields'] = isset($modSettings['disabled_profile_fields']) ? array_flip(explode(',', $modSettings['disabled_profile_fields'])) : array(); // Censor the title... censorText($topicinfo['subject']); $context['page_title'] = $topicinfo['subject']; // Is this topic sticky, or can it even be? $topicinfo['is_sticky'] = empty($modSettings['enableStickyTopics']) ? '0' : $topicinfo['is_sticky']; // Allow addons access to the topicinfo array call_integration_hook('integrate_display_topic', array($topicinfo)); // Default this topic to not marked for notifications... of course... $context['is_marked_notify'] = false; // Did we report a post to a moderator just now? $context['report_sent'] = isset($_GET['reportsent']); if ($context['report_sent']) { $template_layers->add('report_sent'); } // Let's get nosey, who is viewing this topic? if (!empty($settings['display_who_viewing'])) { require_once SUBSDIR . '/Who.subs.php'; formatViewers($topic, 'topic'); } // If all is set, but not allowed... just unset it. $can_show_all = !empty($modSettings['enableAllMessages']) && $context['total_visible_posts'] > $context['messages_per_page'] && $context['total_visible_posts'] < $modSettings['enableAllMessages']; if (isset($_REQUEST['all']) && !$can_show_all) { unset($_REQUEST['all']); } elseif (isset($_REQUEST['all'])) { $_REQUEST['start'] = -1; } // Construct the page index, allowing for the .START method... $context['page_index'] = constructPageIndex($scripturl . '?topic=' . $topic . '.%1$d', $_REQUEST['start'], $context['total_visible_posts'], $context['messages_per_page'], true, array('all' => $can_show_all, 'all_selected' => isset($_REQUEST['all']))); $context['start'] = $_REQUEST['start']; // This is information about which page is current, and which page we're on - in case you don't like the constructed page index. (again, wireles..) $context['page_info'] = array('current_page' => $_REQUEST['start'] / $context['messages_per_page'] + 1, 'num_pages' => floor(($context['total_visible_posts'] - 1) / $context['messages_per_page']) + 1); // Figure out all the link to the next/prev $context['links'] += array('prev' => $_REQUEST['start'] >= $context['messages_per_page'] ? $scripturl . '?topic=' . $topic . '.' . ($_REQUEST['start'] - $context['messages_per_page']) : '', 'next' => $_REQUEST['start'] + $context['messages_per_page'] < $context['total_visible_posts'] ? $scripturl . '?topic=' . $topic . '.' . ($_REQUEST['start'] + $context['messages_per_page']) : ''); // If they are viewing all the posts, show all the posts, otherwise limit the number. if ($can_show_all && isset($_REQUEST['all'])) { // No limit! (actually, there is a limit, but...) $context['messages_per_page'] = -1; // Set start back to 0... $_REQUEST['start'] = 0; } // Build the link tree. $context['linktree'][] = array('url' => $scripturl . '?topic=' . $topic . '.0', 'name' => $topicinfo['subject']); // Build a list of this board's moderators. $context['moderators'] =& $board_info['moderators']; $context['link_moderators'] = array(); // Information about the current topic... $context['is_locked'] = $topicinfo['locked']; $context['is_sticky'] = $topicinfo['is_sticky']; $context['is_very_hot'] = $topicinfo['num_replies'] >= $modSettings['hotTopicVeryPosts']; $context['is_hot'] = $topicinfo['num_replies'] >= $modSettings['hotTopicPosts']; $context['is_approved'] = $topicinfo['approved']; $context['is_poll'] = $topicinfo['id_poll'] > 0 && !empty($modSettings['pollMode']) && allowedTo('poll_view'); determineTopicClass($context); // Did this user start the topic or not? $context['user']['started'] = $user_info['id'] == $topicinfo['id_member_started'] && !$user_info['is_guest']; $context['topic_starter_id'] = $topicinfo['id_member_started']; // Set the topic's information for the template. $context['subject'] = $topicinfo['subject']; $context['num_views'] = $topicinfo['num_views']; $context['num_views_text'] = $context['num_views'] == 1 ? $txt['read_one_time'] : sprintf($txt['read_many_times'], $context['num_views']); $context['mark_unread_time'] = !empty($virtual_msg) ? $virtual_msg : $topicinfo['new_from']; // Set a canonical URL for this page. $context['canonical_url'] = $scripturl . '?topic=' . $topic . '.' . $context['start']; // For quick reply we need a response prefix in the default forum language. $context['response_prefix'] = response_prefix(); // If we want to show event information in the topic, prepare the data. if (allowedTo('calendar_view') && !empty($modSettings['cal_showInTopic']) && !empty($modSettings['cal_enabled'])) { // We need events details and all that jazz require_once SUBSDIR . '/Calendar.subs.php'; // First, try create a better time format, ignoring the "time" elements. if (preg_match('~%[AaBbCcDdeGghjmuYy](?:[^%]*%[AaBbCcDdeGghjmuYy])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0])) { $date_string = $user_info['time_format']; } else { $date_string = $matches[0]; } // Get event information for this topic. $events = eventInfoForTopic($topic); $context['linked_calendar_events'] = array(); foreach ($events as $event) { // Prepare the dates for being formatted. $start_date = sscanf($event['start_date'], '%04d-%02d-%02d'); $start_date = mktime(12, 0, 0, $start_date[1], $start_date[2], $start_date[0]); $end_date = sscanf($event['end_date'], '%04d-%02d-%02d'); $end_date = mktime(12, 0, 0, $end_date[1], $end_date[2], $end_date[0]); $context['linked_calendar_events'][] = array('id' => $event['id_event'], 'title' => $event['title'], 'can_edit' => allowedTo('calendar_edit_any') || $event['id_member'] == $user_info['id'] && allowedTo('calendar_edit_own'), 'modify_href' => $scripturl . '?action=post;msg=' . $topicinfo['id_first_msg'] . ';topic=' . $topic . '.0;calendar;eventid=' . $event['id_event'] . ';' . $context['session_var'] . '=' . $context['session_id'], 'can_export' => allowedTo('calendar_edit_any') || $event['id_member'] == $user_info['id'] && allowedTo('calendar_edit_own'), 'export_href' => $scripturl . '?action=calendar;sa=ical;eventid=' . $event['id_event'] . ';' . $context['session_var'] . '=' . $context['session_id'], 'start_date' => standardTime($start_date, $date_string, 'none'), 'start_timestamp' => $start_date, 'end_date' => standardTime($end_date, $date_string, 'none'), 'end_timestamp' => $end_date, 'is_last' => false); } if (!empty($context['linked_calendar_events'])) { $context['linked_calendar_events'][count($context['linked_calendar_events']) - 1]['is_last'] = true; $template_layers->add('display_calendar'); } } // Create the poll info if it exists. if ($context['is_poll']) { $template_layers->add('display_poll'); require_once SUBSDIR . '/Poll.subs.php'; loadPollContext($topicinfo['id_poll']); // Build the poll moderation button array. $context['poll_buttons'] = array('vote' => array('test' => 'allow_return_vote', 'text' => 'poll_return_vote', 'image' => 'poll_options.png', 'lang' => true, 'url' => $scripturl . '?topic=' . $context['current_topic'] . '.' . $context['start']), 'results' => array('test' => 'allow_poll_view', 'text' => 'poll_results', 'image' => 'poll_results.png', 'lang' => true, 'url' => $scripturl . '?topic=' . $context['current_topic'] . '.' . $context['start'] . ';viewresults'), 'change_vote' => array('test' => 'allow_change_vote', 'text' => 'poll_change_vote', 'image' => 'poll_change_vote.png', 'lang' => true, 'url' => $scripturl . '?action=poll;sa=vote;topic=' . $context['current_topic'] . '.' . $context['start'] . ';poll=' . $context['poll']['id'] . ';' . $context['session_var'] . '=' . $context['session_id']), 'lock' => array('test' => 'allow_lock_poll', 'text' => !$context['poll']['is_locked'] ? 'poll_lock' : 'poll_unlock', 'image' => 'poll_lock.png', 'lang' => true, 'url' => $scripturl . '?action=lockvoting;topic=' . $context['current_topic'] . '.' . $context['start'] . ';' . $context['session_var'] . '=' . $context['session_id']), 'edit' => array('test' => 'allow_edit_poll', 'text' => 'poll_edit', 'image' => 'poll_edit.png', 'lang' => true, 'url' => $scripturl . '?action=editpoll;topic=' . $context['current_topic'] . '.' . $context['start']), 'remove_poll' => array('test' => 'can_remove_poll', 'text' => 'poll_remove', 'image' => 'admin_remove_poll.png', 'lang' => true, 'custom' => 'onclick="return confirm(\'' . $txt['poll_remove_warn'] . '\');"', 'url' => $scripturl . '?action=poll;sa=remove;topic=' . $context['current_topic'] . '.' . $context['start'] . ';' . $context['session_var'] . '=' . $context['session_id'])); // Allow mods to add additional buttons here call_integration_hook('integrate_poll_buttons'); } // Calculate the fastest way to get the messages! $ascending = true; $start = $_REQUEST['start']; $limit = $context['messages_per_page']; $firstIndex = 0; if ($start >= $context['total_visible_posts'] / 2 && $context['messages_per_page'] != -1) { $ascending = !$ascending; $limit = $context['total_visible_posts'] <= $start + $limit ? $context['total_visible_posts'] - $start : $limit; $start = $context['total_visible_posts'] <= $start + $limit ? 0 : $context['total_visible_posts'] - $start - $limit; $firstIndex = $limit - 1; } // Taking care of member specific settings $limit_settings = array('messages_per_page' => $context['messages_per_page'], 'start' => $start, 'offset' => $limit); // Get each post and poster in this topic. $topic_details = getTopicsPostsAndPoster($topic, $limit_settings, $ascending); $messages = $topic_details['messages']; $posters = array_unique($topic_details['all_posters']); $all_posters = $topic_details['all_posters']; unset($topic_details); call_integration_hook('integrate_display_message_list', array(&$messages, &$posters)); // Guests can't mark topics read or for notifications, just can't sorry. if (!$user_info['is_guest'] && !empty($messages)) { $mark_at_msg = max($messages); if ($mark_at_msg >= $topicinfo['id_last_msg']) { $mark_at_msg = $modSettings['maxMsgID']; } if ($mark_at_msg >= $topicinfo['new_from']) { markTopicsRead(array($user_info['id'], $topic, $mark_at_msg, $topicinfo['unwatched']), $topicinfo['new_from'] !== 0); } updateReadNotificationsFor($topic, $board); // Have we recently cached the number of new topics in this board, and it's still a lot? if (isset($_REQUEST['topicseen']) && isset($_SESSION['topicseen_cache'][$board]) && $_SESSION['topicseen_cache'][$board] > 5) { $_SESSION['topicseen_cache'][$board]--; } elseif (isset($_REQUEST['topicseen'])) { // Use the mark read tables... and the last visit to figure out if this should be read or not. $numNewTopics = getUnreadCountSince($board, empty($_SESSION['id_msg_last_visit']) ? 0 : $_SESSION['id_msg_last_visit']); // If there're no real new topics in this board, mark the board as seen. if (empty($numNewTopics)) { $_REQUEST['boardseen'] = true; } else { $_SESSION['topicseen_cache'][$board] = $numNewTopics; } } elseif (isset($_SESSION['topicseen_cache'][$board])) { $_SESSION['topicseen_cache'][$board]--; } // Mark board as seen if we came using last post link from BoardIndex. (or other places...) if (isset($_REQUEST['boardseen'])) { require_once SUBSDIR . '/Boards.subs.php'; markBoardsRead($board, false, false); } } $attachments = array(); // If there _are_ messages here... (probably an error otherwise :!) if (!empty($messages)) { require_once SUBSDIR . '/Attachments.subs.php'; // Fetch attachments. $includeUnapproved = !$modSettings['postmod_active'] || allowedTo('approve_posts'); if (!empty($modSettings['attachmentEnable']) && allowedTo('view_attachments')) { $attachments = getAttachments($messages, $includeUnapproved, 'filter_accessible_attachment', $all_posters); } $msg_parameters = array('message_list' => $messages, 'new_from' => $topicinfo['new_from']); $msg_selects = array(); $msg_tables = array(); call_integration_hook('integrate_message_query', array(&$msg_selects, &$msg_tables, &$msg_parameters)); // What? It's not like it *couldn't* be only guests in this topic... if (!empty($posters)) { loadMemberData($posters); } // Load in the likes for this group of messages if (!empty($modSettings['likes_enabled'])) { require_once SUBSDIR . '/Likes.subs.php'; $context['likes'] = loadLikes($messages, true); // ajax controller for likes loadJavascriptFile('like_posts.js', array('defer' => true)); loadLanguage('Errors'); // Initiate likes and the tooltips for likes addInlineJavascript(' $(document).ready(function () { var likePostInstance = likePosts.prototype.init({ oTxt: ({ btnText : ' . JavaScriptEscape($txt['ok_uppercase']) . ', likeHeadingError : ' . JavaScriptEscape($txt['like_heading_error']) . ', error_occurred : ' . JavaScriptEscape($txt['error_occurred']) . ' }), }); $(".like_button, .unlike_button").SiteTooltip({ hoverIntent: { sensitivity: 10, interval: 150, timeout: 50 } }); });', true); } $messages_request = loadMessageRequest($msg_selects, $msg_tables, $msg_parameters); if (!empty($modSettings['enableFollowup'])) { require_once SUBSDIR . '/FollowUps.subs.php'; $context['follow_ups'] = followupTopics($messages, $includeUnapproved); } // Go to the last message if the given time is beyond the time of the last message. if (isset($context['start_from']) && $context['start_from'] >= $topicinfo['num_replies']) { $context['start_from'] = $topicinfo['num_replies']; } // Since the anchor information is needed on the top of the page we load these variables beforehand. $context['first_message'] = isset($messages[$firstIndex]) ? $messages[$firstIndex] : $messages[0]; $context['first_new_message'] = isset($context['start_from']) && $_REQUEST['start'] == $context['start_from']; } else { $messages_request = false; $context['first_message'] = 0; $context['first_new_message'] = false; } $context['jump_to'] = array('label' => addslashes(un_htmlspecialchars($txt['jump_to'])), 'board_name' => htmlspecialchars(strtr(strip_tags($board_info['name']), array('&' => '&')), ENT_COMPAT, 'UTF-8'), 'child_level' => $board_info['child_level']); // Set the callback. (do you REALIZE how much memory all the messages would take?!?) // This will be called from the template. $context['get_message'] = array($this, 'prepareDisplayContext_callback'); // Now set all the wonderful, wonderful permissions... like moderation ones... $common_permissions = array('can_approve' => 'approve_posts', 'can_ban' => 'manage_bans', 'can_sticky' => 'make_sticky', 'can_merge' => 'merge_any', 'can_split' => 'split_any', 'calendar_post' => 'calendar_post', 'can_mark_notify' => 'mark_any_notify', 'can_send_topic' => 'send_topic', 'can_send_pm' => 'pm_send', 'can_send_email' => 'send_email_to_members', 'can_report_moderator' => 'report_any', 'can_moderate_forum' => 'moderate_forum', 'can_issue_warning' => 'issue_warning', 'can_restore_topic' => 'move_any', 'can_restore_msg' => 'move_any'); foreach ($common_permissions as $contextual => $perm) { $context[$contextual] = allowedTo($perm); } // Permissions with _any/_own versions. $context[YYY] => ZZZ_any/_own. $anyown_permissions = array('can_move' => 'move', 'can_lock' => 'lock', 'can_delete' => 'remove', 'can_add_poll' => 'poll_add', 'can_remove_poll' => 'poll_remove', 'can_reply' => 'post_reply', 'can_reply_unapproved' => 'post_unapproved_replies'); foreach ($anyown_permissions as $contextual => $perm) { $context[$contextual] = allowedTo($perm . '_any') || $context['user']['started'] && allowedTo($perm . '_own'); } // Cleanup all the permissions with extra stuff... $context['can_mark_notify'] &= !$context['user']['is_guest']; $context['can_sticky'] &= !empty($modSettings['enableStickyTopics']); $context['calendar_post'] &= !empty($modSettings['cal_enabled']) && (allowedTo('modify_any') || $context['user']['started'] && allowedTo('modify_own')); $context['can_add_poll'] &= !empty($modSettings['pollMode']) && $topicinfo['id_poll'] <= 0; $context['can_remove_poll'] &= !empty($modSettings['pollMode']) && $topicinfo['id_poll'] > 0; $context['can_reply'] &= empty($topicinfo['locked']) || allowedTo('moderate_board'); $context['can_reply_unapproved'] &= $modSettings['postmod_active'] && (empty($topicinfo['locked']) || allowedTo('moderate_board')); $context['can_issue_warning'] &= in_array('w', $context['admin_features']) && !empty($modSettings['warning_enable']); // Handle approval flags... $context['can_reply_approved'] = $context['can_reply']; $context['can_reply'] |= $context['can_reply_unapproved']; $context['can_quote'] = $context['can_reply'] && (empty($modSettings['disabledBBC']) || !in_array('quote', explode(',', $modSettings['disabledBBC']))); $context['can_mark_unread'] = !$user_info['is_guest'] && $settings['show_mark_read']; $context['can_unwatch'] = !$user_info['is_guest'] && $modSettings['enable_unwatch']; $context['can_send_topic'] = (!$modSettings['postmod_active'] || $topicinfo['approved']) && allowedTo('send_topic'); $context['can_print'] = empty($modSettings['disable_print_topic']); // Start this off for quick moderation - it will be or'd for each post. $context['can_remove_post'] = allowedTo('delete_any') || allowedTo('delete_replies') && $context['user']['started']; // Can restore topic? That's if the topic is in the recycle board and has a previous restore state. $context['can_restore_topic'] &= !empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] == $board && !empty($topicinfo['id_previous_board']); $context['can_restore_msg'] &= !empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] == $board && !empty($topicinfo['id_previous_topic']); $context['can_follow_up'] = !empty($modSettings['enableFollowup']) && boardsallowedto('post_new') !== array(); // Check if the draft functions are enabled and that they have permission to use them (for quick reply.) $context['drafts_save'] = !empty($modSettings['drafts_enabled']) && !empty($modSettings['drafts_post_enabled']) && allowedTo('post_draft') && $context['can_reply']; $context['drafts_autosave'] = !empty($context['drafts_save']) && !empty($modSettings['drafts_autosave_enabled']) && allowedTo('post_autosave_draft'); if (!empty($context['drafts_save'])) { loadLanguage('Drafts'); } if (!empty($context['drafts_autosave']) && empty($options['use_editor_quick_reply'])) { loadJavascriptFile('drafts.js'); } if (!empty($modSettings['mentions_enabled'])) { $context['mentions_enabled'] = true; // Just using the plain text quick reply and not the editor if (empty($options['use_editor_quick_reply'])) { loadJavascriptFile(array('jquery.atwho.js', 'jquery.caret.min.js', 'mentioning.js')); } loadCSSFile('jquery.atwho.css'); addInlineJavascript(' $(document).ready(function () { for (var i = 0, count = all_elk_mentions.length; i < count; i++) all_elk_mentions[i].oMention = new elk_mentions(all_elk_mentions[i].oOptions); });'); } // Load up the Quick ModifyTopic and Quick Reply scripts loadJavascriptFile('topic.js'); // Auto video embeding enabled? if (!empty($modSettings['enableVideoEmbeding'])) { addInlineJavascript(' $(document).ready(function() { $().linkifyvideo(oEmbedtext); });'); } // Load up the "double post" sequencing magic. if (!empty($options['display_quick_reply'])) { checkSubmitOnce('register'); $context['name'] = isset($_SESSION['guest_name']) ? $_SESSION['guest_name'] : ''; $context['email'] = isset($_SESSION['guest_email']) ? $_SESSION['guest_email'] : ''; if (!empty($options['use_editor_quick_reply']) && $context['can_reply']) { // Needed for the editor and message icons. require_once SUBSDIR . '/Editor.subs.php'; // Now create the editor. $editorOptions = array('id' => 'message', 'value' => '', 'labels' => array('post_button' => $txt['post']), 'height' => '250px', 'width' => '100%', 'preview_type' => 0); create_control_richedit($editorOptions); $context['attached'] = ''; $context['make_poll'] = isset($_REQUEST['poll']); // Message icons - customized icons are off? $context['icons'] = getMessageIcons($board); if (!empty($context['icons'])) { $context['icons'][count($context['icons']) - 1]['is_last'] = true; } } } addJavascriptVar(array('notification_topic_notice' => $context['is_marked_notify'] ? $txt['notification_disable_topic'] : $txt['notification_enable_topic']), true); if ($context['can_send_topic']) { addJavascriptVar(array('sendtopic_cancel' => $txt['modify_cancel'], 'sendtopic_back' => $txt['back'], 'sendtopic_close' => $txt['find_close'], 'sendtopic_error' => $txt['send_error_occurred'], 'required_field' => $txt['require_field']), true); } // Build the normal button array. $context['normal_buttons'] = array('reply' => array('test' => 'can_reply', 'text' => 'reply', 'image' => 'reply.png', 'lang' => true, 'url' => $scripturl . '?action=post;topic=' . $context['current_topic'] . '.' . $context['start'] . ';last_msg=' . $context['topic_last_message'], 'active' => true), 'notify' => array('test' => 'can_mark_notify', 'text' => $context['is_marked_notify'] ? 'unnotify' : 'notify', 'image' => ($context['is_marked_notify'] ? 'un' : '') . 'notify.png', 'lang' => true, 'custom' => 'onclick="return notifyButton(this);"', 'url' => $scripturl . '?action=notify;sa=' . ($context['is_marked_notify'] ? 'off' : 'on') . ';topic=' . $context['current_topic'] . '.' . $context['start'] . ';' . $context['session_var'] . '=' . $context['session_id']), 'mark_unread' => array('test' => 'can_mark_unread', 'text' => 'mark_unread', 'image' => 'markunread.png', 'lang' => true, 'url' => $scripturl . '?action=markasread;sa=topic;t=' . $context['mark_unread_time'] . ';topic=' . $context['current_topic'] . '.' . $context['start'] . ';' . $context['session_var'] . '=' . $context['session_id']), 'unwatch' => array('test' => 'can_unwatch', 'text' => ($context['topic_unwatched'] ? '' : 'un') . 'watch', 'image' => ($context['topic_unwatched'] ? '' : 'un') . 'watched.png', 'lang' => true, 'custom' => 'onclick="return unwatchButton(this);"', 'url' => $scripturl . '?action=unwatchtopic;topic=' . $context['current_topic'] . '.' . $context['start'] . ';sa=' . ($context['topic_unwatched'] ? 'off' : 'on') . ';' . $context['session_var'] . '=' . $context['session_id']), 'send' => array('test' => 'can_send_topic', 'text' => 'send_topic', 'image' => 'sendtopic.png', 'lang' => true, 'url' => $scripturl . '?action=emailuser;sa=sendtopic;topic=' . $context['current_topic'] . '.0', 'custom' => 'onclick="return sendtopicOverlayDiv(this.href, \'' . $txt['send_topic'] . '\');"'), 'print' => array('test' => 'can_print', 'text' => 'print', 'image' => 'print.png', 'lang' => true, 'custom' => 'rel="nofollow"', 'class' => 'new_win', 'url' => $scripturl . '?action=topic;sa=printpage;topic=' . $context['current_topic'] . '.0')); // Build the mod button array $context['mod_buttons'] = array('move' => array('test' => 'can_move', 'text' => 'move_topic', 'image' => 'admin_move.png', 'lang' => true, 'url' => $scripturl . '?action=movetopic;current_board=' . $context['current_board'] . ';topic=' . $context['current_topic'] . '.0'), 'delete' => array('test' => 'can_delete', 'text' => 'remove_topic', 'image' => 'admin_rem.png', 'lang' => true, 'custom' => 'onclick="return confirm(\'' . $txt['are_sure_remove_topic'] . '\');"', 'url' => $scripturl . '?action=removetopic2;topic=' . $context['current_topic'] . '.0;' . $context['session_var'] . '=' . $context['session_id']), 'lock' => array('test' => 'can_lock', 'text' => empty($context['is_locked']) ? 'set_lock' : 'set_unlock', 'image' => 'admin_lock.png', 'lang' => true, 'url' => $scripturl . '?action=topic;sa=lock;topic=' . $context['current_topic'] . '.' . $context['start'] . ';' . $context['session_var'] . '=' . $context['session_id']), 'sticky' => array('test' => 'can_sticky', 'text' => empty($context['is_sticky']) ? 'set_sticky' : 'set_nonsticky', 'image' => 'admin_sticky.png', 'lang' => true, 'url' => $scripturl . '?action=topic;sa=sticky;topic=' . $context['current_topic'] . '.' . $context['start'] . ';' . $context['session_var'] . '=' . $context['session_id']), 'merge' => array('test' => 'can_merge', 'text' => 'merge', 'image' => 'merge.png', 'lang' => true, 'url' => $scripturl . '?action=mergetopics;board=' . $context['current_board'] . '.0;from=' . $context['current_topic']), 'calendar' => array('test' => 'calendar_post', 'text' => 'calendar_link', 'image' => 'linktocal.png', 'lang' => true, 'url' => $scripturl . '?action=post;calendar;msg=' . $context['topic_first_message'] . ';topic=' . $context['current_topic'] . '.0')); // Restore topic. eh? No monkey business. if ($context['can_restore_topic']) { $context['mod_buttons'][] = array('text' => 'restore_topic', 'image' => '', 'lang' => true, 'url' => $scripturl . '?action=restoretopic;topics=' . $context['current_topic'] . ';' . $context['session_var'] . '=' . $context['session_id']); } if ($context['can_reply'] && !empty($options['display_quick_reply'])) { $template_layers->add('quickreply'); } $template_layers->add('pages_and_buttons'); // Allow adding new buttons easily. call_integration_hook('integrate_display_buttons'); call_integration_hook('integrate_mod_buttons'); }
/** * Below is the template for adding/editing an board on the forum. */ function template_modify_board() { global $context, $scripturl, $txt, $modSettings; // The main table header. echo ' <div id="manage_boards"> <form action="', $scripturl, '?action=admin;area=manageboards;sa=board2" method="post" accept-charset="UTF-8"> <input type="hidden" name="boardid" value="', $context['board']['id'], '" /> <h2 class="category_header"> ', isset($context['board']['is_new']) ? $txt['mboards_new_board_name'] : $txt['boardsEdit'], ' </h2> <div class="windowbg"> <div class="content"> <dl class="settings">'; // Option for choosing the category the board lives in. echo ' <dt> <strong><label for="new_cat">', $txt['mboards_category'], '</label>:</strong> </dt> <dd> <select id="new_cat" name="new_cat" onchange="if (this.form.order) {this.form.order.disabled = this.options[this.selectedIndex].value != 0; this.form.board_order.disabled = this.options[this.selectedIndex].value != 0 || this.form.order.options[this.form.order.selectedIndex].value == \'\';}">'; foreach ($context['categories'] as $category) { echo ' <option', $category['selected'] ? ' selected="selected"' : '', ' value="', $category['id'], '">', $category['name'], '</option>'; } echo ' </select> </dd>'; // If this isn't the only board in this category let the user choose where the board is to live. if (isset($context['board']['is_new']) && count($context['board_order']) > 0 || count($context['board_order']) > 1) { echo ' <dt> <strong><label for="order">', $txt['order'], '</label>:</strong> </dt> <dd>'; // The first select box gives the user the option to position it before, after or as a child of another board. echo ' <select id="order" name="placement" onchange="this.form.board_order.disabled = this.options[this.selectedIndex].value == \'\';"> ', !isset($context['board']['is_new']) ? '<option value="">(' . $txt['mboards_unchanged'] . ')</option>' : '', ' <option value="after">' . $txt['mboards_order_after'] . '...</option> <option value="child">' . $txt['mboards_order_child_of'] . '...</option> <option value="before">' . $txt['mboards_order_before'] . '...</option> </select>'; // The second select box lists all the boards in the category. echo ' <select id="board_order" name="board_order" ', isset($context['board']['is_new']) ? '' : 'disabled="disabled"', '> ', !isset($context['board']['is_new']) ? '<option value="">(' . $txt['mboards_unchanged'] . ')</option>' : ''; foreach ($context['board_order'] as $order) { echo ' <option', $order['selected'] ? ' selected="selected"' : '', ' value="', $order['id'], '">', $order['name'], '</option>'; } echo ' </select> </dd>'; } // Options for board name and description. echo ' <dt> <strong><label for="board_name">', $txt['full_name'], '</label>:</strong><br /> <span class="smalltext">', $txt['name_on_display'], '</span> </dt> <dd> <input type="text" id="board_name" name="board_name" value="', $context['board']['name'], '" size="30" class="input_text" /> </dd> <dt> <strong><label for="desc">', $txt['mboards_description'], '</label>:</strong><br /> <span class="smalltext">', $txt['mboards_description_desc'], '</span> </dt> <dd> <textarea id="desc" name="desc" rows="3" cols="35" style="' . (isBrowser('is_ie8') ? 'width: 635px; max-width: 99%; min-width: 99%' : 'width: 99%') . ';">', $context['board']['description'], '</textarea> </dd> <dt> <strong><label for="profile">', $txt['permission_profile'], '</label>:</strong><br /> <span class="smalltext">', $context['can_manage_permissions'] ? sprintf($txt['permission_profile_desc'], $scripturl . '?action=admin;area=permissions;sa=profiles;' . $context['session_var'] . '=' . $context['session_id']) : strip_tags($txt['permission_profile_desc']), '</span> </dt> <dd> <select id="profile" name="profile">'; if (isset($context['board']['is_new'])) { echo ' <option value="-1">[', $txt['permission_profile_inherit'], ']</option>'; } foreach ($context['profiles'] as $id => $profile) { echo ' <option value="', $id, '" ', $id == $context['board']['profile'] ? 'selected="selected"' : '', '>', $profile['name'], '</option>'; } echo ' </select> </dd> <dt> <strong>', $txt['mboards_groups'], ':</strong><br /> <span class="smalltext">', empty($modSettings['deny_boards_access']) ? $txt['mboards_groups_desc'] : $txt['boardsaccess_option_desc'], '</span>'; echo ' </dt> <dd>'; if (!empty($modSettings['deny_boards_access'])) { echo ' <table> <tr> <td></td> <th>', $txt['permissions_option_on'], '</th> <th>', $txt['permissions_option_off'], '</th> <th>', $txt['permissions_option_deny'], '</th> <th></th> </tr>'; } // List all the membergroups so the user can choose who may access this board. foreach ($context['groups'] as $group) { if (empty($modSettings['deny_boards_access'])) { echo ' <label for="groups_', $group['id'], '"> <input type="checkbox" name="groups[', $group['id'], ']" value="allow" id="groups_', $group['id'], '"', $group['allow'] ? ' checked="checked"' : '', ' class="input_check" /> <span', $group['is_post_group'] ? ' class="post_group" title="' . $txt['mboards_groups_post_group'] . '"' : '', $group['id'] == 0 ? ' class="regular_members" title="' . $txt['mboards_groups_regular_members'] . '"' : '', '> ', $group['name'], ' </span> </label> <br />'; } else { echo ' <tr> <td> <span', $group['is_post_group'] ? ' class="post_group" title="' . $txt['mboards_groups_post_group'] . '"' : '', $group['id'] == 0 ? ' class="regular_members" title="' . $txt['mboards_groups_regular_members'] . '"' : '', '> ', $group['name'], ' </span> </td> <td> <input type="radio" name="groups[', $group['id'], ']" value="allow" id="groups_', $group['id'], '_a"', $group['allow'] ? ' checked="checked"' : '', ' class="input_radio" /> </td> <td> <input type="radio" name="groups[', $group['id'], ']" value="ignore" id="groups_', $group['id'], '_x"', !$group['allow'] && !$group['deny'] ? ' checked="checked"' : '', ' class="input_radio" /> </td> <td> <input type="radio" name="groups[', $group['id'], ']" value="deny" id="groups_', $group['id'], '_d"', $group['deny'] ? ' checked="checked"' : '', ' class="input_radio" /> </td> <td></td> </tr>'; } } if (empty($modSettings['deny_boards_access'])) { echo ' <span class="select_all_box"> <em><label for="check_all">', $txt['check_all'], '</label></em> <input type="checkbox" id="check_all" class="input_check" onclick="invertAll(this, this.form, \'groups[\');" /> </span> <br /> <br /> </dd>'; } else { echo ' <tr class="select_all_box"> <td> </td> <td> <input type="radio" name="select_all" class="input_radio" onclick="selectAllRadio(this, this.form, \'groups\', \'allow\');" /> </td> <td> <input type="radio" name="select_all" class="input_radio" onclick="selectAllRadio(this, this.form, \'groups\', \'ignore\');" /> </td> <td> <input type="radio" name="select_all" class="input_radio" onclick="selectAllRadio(this, this.form, \'groups\', \'deny\');" /> </td> <td> <em>', $txt['check_all'], '</em> </td> </tr> </table> </dd>'; } // Options to choose moderators, specify as announcement board and choose whether to count posts here. echo ' <dt> <strong><label for="moderators">', $txt['mboards_moderators'], '</label>:</strong><br /> <span class="smalltext">', $txt['mboards_moderators_desc'], '</span><br /> </dt> <dd> <input type="text" name="moderators" id="moderators" value="', $context['board']['moderator_list'], '" size="30" class="input_text" /> <div id="moderator_container"></div> </dd> </dl> <hr />'; // Add a select all box for the allowed groups section echo ' <script><!-- // --><![CDATA[ $(document).ready(function () { $(".select_all_box").each(function () { $(this).removeClass(\'select_all_box\'); }); }); // ]]></script>'; if (empty($context['board']['is_recycle']) && empty($context['board']['topics'])) { echo ' <dl class="settings"> <dt> <strong><label for="redirect_enable">', $txt['mboards_redirect'], '</label>:</strong><br /> <span class="smalltext">', $txt['mboards_redirect_desc'], '</span><br /> </dt> <dd> <input type="checkbox" id="redirect_enable" name="redirect_enable"', $context['board']['redirect'] != '' ? ' checked="checked"' : '', ' onclick="refreshOptions();" class="input_check" /> </dd> </dl>'; } if (!empty($context['board']['is_recycle'])) { echo ' <div class="infobox">', $txt['mboards_redirect_disabled_recycle'], '<br />', $txt['mboards_recycle_disabled_delete'], '</div>'; } if (empty($context['board']['is_recycle']) && !empty($context['board']['topics'])) { echo ' <div class="infobox"> <strong>', $txt['mboards_redirect'], '</strong><br /> ', $txt['mboards_redirect_disabled'], ' </div>'; } if (!$context['board']['topics'] && empty($context['board']['is_recycle'])) { echo ' <div id="redirect_address_div"> <dl class="settings"> <dt> <strong><label for="redirect_address">', $txt['mboards_redirect_url'], '</label>:</strong><br /> <span class="smalltext">', $txt['mboards_redirect_url_desc'], '</span><br /> </dt> <dd> <input type="text" id="redirect_address" name="redirect_address" value="', $context['board']['redirect'], '" size="40" class="input_text" /> </dd> </dl> </div>'; if ($context['board']['redirect']) { echo ' <div id="reset_redirect_div"> <dl class="settings"> <dt> <strong><label for="reset_redirect">', $txt['mboards_redirect_reset'], '</label>:</strong><br /> <span class="smalltext">', $txt['mboards_redirect_reset_desc'], '</span><br /> </dt> <dd> <input type="checkbox" id="reset_redirect" name="reset_redirect" class="input_check" /> <em>(', sprintf($txt['mboards_current_redirects'], $context['board']['posts']), ')</em> </dd> </dl> </div>'; } } echo ' <div id="count_posts_div"> <dl class="settings"> <dt> <strong><label for="count">', $txt['mboards_count_posts'], '</label>:</strong><br /> <span class="smalltext">', $txt['mboards_count_posts_desc'], '</span><br /> </dt> <dd> <input type="checkbox" id="count" name="count" ', $context['board']['count_posts'] ? ' checked="checked"' : '', ' class="input_check" /> </dd> </dl> </div>'; // Here the user can choose to force this board to use a theme other than the default theme for the forum. echo ' <div id="board_theme_div"> <dl class="settings"> <dt> <strong><label for="boardtheme">', $txt['mboards_theme'], '</label>:</strong><br /> <span class="smalltext">', $txt['mboards_theme_desc'], '</span><br /> </dt> <dd> <select name="boardtheme" id="boardtheme" onchange="refreshOptions();"> <option value="0"', $context['board']['theme'] == 0 ? ' selected="selected"' : '', '>', $txt['mboards_theme_default'], '</option>'; foreach ($context['themes'] as $theme) { echo ' <option value="', $theme['id'], '"', $context['board']['theme'] == $theme['id'] ? ' selected="selected"' : '', '>', $theme['name'], '</option>'; } echo ' </select> </dd> </dl> </div> <div id="override_theme_div"> <dl class="settings"> <dt> <strong><label for="override_theme">', $txt['mboards_override_theme'], '</label>:</strong><br /> <span class="smalltext">', $txt['mboards_override_theme_desc'], '</span><br /> </dt> <dd> <input type="checkbox" id="override_theme" name="override_theme"', $context['board']['override_theme'] ? ' checked="checked"' : '', ' class="input_check" /> </dd> </dl> </div>'; echo ' <div class="submitbutton"> <input type="hidden" name="rid" value="', $context['redirect_location'], '" /> <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '" /> <input type="hidden" name="', $context['admin-be-' . $context['board']['id'] . '_token_var'], '" value="', $context['admin-be-' . $context['board']['id'] . '_token'], '" />'; // If this board has no children don't bother with the next confirmation screen. if ($context['board']['no_children']) { echo ' <input type="hidden" name="no_children" value="1" />'; } if (isset($context['board']['is_new'])) { echo ' <input type="hidden" name="cur_cat" value="', $context['board']['category'], '" /> <input type="submit" name="add" value="', $txt['mboards_new_board'], '" onclick="return !isEmptyText(this.form.board_name);" class="button_submit" />'; } else { echo ' <input type="submit" name="edit" value="', $txt['modify'], '" onclick="return !isEmptyText(this.form.board_name);" class="button_submit" />'; } if (!isset($context['board']['is_new']) && empty($context['board']['is_recycle'])) { echo ' <span', $context['board']['is_recycle'] ? ' style="visibility:hidden">' : '>', '<input type="submit" name="delete" value="', $txt['mboards_delete_board'], '" onclick="return confirm(\'', $txt['boardConfirm'], '\');"', ' class="button_submit" /></span>'; } echo ' </div> </div> </div> </form> </div>'; $js = ' var oModeratorSuggest = new smc_AutoSuggest({ sSelf: \'oModeratorSuggest\', sSessionId: elk_session_id, sSessionVar: elk_session_var, sSuggestId: \'moderators\', sControlId: \'moderators\', sSearchType: \'member\', bItemList: true, sPostName: \'moderator_list\', sURLMask: \'action=profile;u=%item_id%\', sTextDeleteItem: \'' . $txt['autosuggest_delete_item'] . '\', sItemListContainerId: \'moderator_container\', aListItems: ['; foreach ($context['board']['moderators'] as $id_member => $member_name) { $js .= ' { sItemId: ' . JavaScriptEscape($id_member) . ', sItemName: ' . JavaScriptEscape($member_name) . ' }' . ($id_member == $context['board']['last_moderator_id'] ? '' : ','); } $js .= ' ] });'; addInlineJavascript($js, true); // Javascript for deciding what to show. echo ' <script><!-- // --><![CDATA[ function refreshOptions() { var redirect = document.getElementById("redirect_enable"), redirectEnabled = redirect ? redirect.checked : false, nonDefaultTheme = document.getElementById("boardtheme").value == 0 ? false : true; // What to show? document.getElementById("override_theme_div").style.display = redirectEnabled || !nonDefaultTheme ? "none" : ""; document.getElementById("board_theme_div").style.display = redirectEnabled ? "none" : ""; document.getElementById("count_posts_div").style.display = redirectEnabled ? "none" : "";'; if (!$context['board']['topics'] && empty($context['board']['is_recycle'])) { echo ' document.getElementById("redirect_address_div").style.display = redirectEnabled ? "" : "none";'; if ($context['board']['redirect']) { echo ' document.getElementById("reset_redirect_div").style.display = redirectEnabled ? "" : "none";'; } } echo ' } refreshOptions(); // ]]></script>'; }
function template_character_list() { global $context, $txt, $scripturl; echo ' <div class="cat_bar"> <h3 class="catbg"> <span class="generic_icons mlist"></span> ', $txt['chars_menu_title'], ' </h3> </div>'; if (!empty($context['filterable_groups'])) { echo ' <div class="information"> <form action="', $scripturl, '?action=characters" method="post"> <a href="javascript:void(0);" id="filter_opts_link" onclick="$(\'#filter_opts\').show(); $(this).hide(); return false;" class="toggle_down">', $txt['filter_characters'], '</a> <fieldset id="filter_opts" style="display:none"> <legend> <a href="javascript:void(0);" onclick="$(this).closest(\'fieldset\').hide();$(\'#filter_opts_link\').show(); return false;" class="toggle_up"> ', $txt['filter_characters'], '</a> </legend>'; foreach ($context['filterable_groups'] as $id_group => $group) { if (is_array($context['filter_groups'])) { $disabled = false; $checked = in_array($id_group, $context['filter_groups']); } else { $disabled = true; $checked = false; } echo ' <div class="filter_container"> <label> <input type="checkbox"', $checked ? ' checked' : '', $disabled ? ' disabled' : '', ' name="filter[]" value="', $id_group, '"> <div class="group_name">', $group['group_name'], '</div> <div class="group_badge">', $group['parsed_icons'], '</div> </label> </div>'; } if (allowedTo('admin_forum')) { echo ' <div class="filter_container"> <label> <input type="checkbox"', $context['filter_groups'] === true ? ' checked' : '', ' name="filter[]" id="ungroup" value="-1" onchange="$(\'.filter_container input:not(#ungroup)\').prop(\'disabled\', this.checked)"> <div class="group_name">', $txt['characters_in_no_groups'], '</div> <div class="group_badge"></div> </label> </div>'; } echo ' <div class="clearfix"> <input type="submit" class="button_submit" value="', $txt['apply_filter'], '"> </div> </fieldset> </form> </div>'; if (!empty($context['filter_groups'])) { addInlineJavascript('$(\'#filter_opts_link\').trigger(\'click\');', true); } } if (empty($context['char_list'])) { echo ' <div class="windowbg2">', $txt['characters_none'], '</div>'; } else { echo $context['page_index'], ' <div class="char_list_container">'; foreach ($context['char_list'] as $char) { echo ' <div class="windowbg2 char_list"> <div class="char_list_name"><a href="', $scripturl, '?action=profile;u=', $char['id_member'], ';area=characters;char=', $char['id_character'], '">', $char['character_name'], '</a></div> <div class="char_list_avatar"><img src="', $char['avatar'], '" class="avatar"></div> <div class="char_list_group">', !empty($char['group_title']) ? $char['group_title'] : '<em>' . $txt['char_no_group'] . '</em>', '</div> <div class="char_list_posts">', $txt['member_postcount'], ': ', $char['posts'], '</div> <div class="char_list_created">', timeformat($char['date_created']), '</div> <div class="char_list_sheet">', !empty($char['retired']) ? $txt['char_retired'] : (!empty($char['char_sheet']) ? '<a href="' . $scripturl . '?action=profile;u=' . $char['id_member'] . ';area=characters;char=' . $char['id_character'] . ';sa=sheet">' . $txt['char_sheet'] . '</a>' : '<em>' . $txt['char_sheet_none_short'] . '</em>'), '</div> </div>'; } echo ' </div>'; } }
/** * Set general news and newsletter settings and permissions. * * What it does: * - Called by ?action=admin;area=news;sa=settings. * - Requires the forum_admin permission. * * @uses ManageNews template, news_settings sub-template. */ public function action_newsSettings_display() { global $context, $txt, $scripturl; // Initialize the form $this->_initNewsSettingsForm(); $config_vars = $this->_newsSettings->settings(); // Add some javascript at the bottom... addInlineJavascript(' document.getElementById("xmlnews_maxlen").disabled = !document.getElementById("xmlnews_enable").checked; document.getElementById("xmlnews_limit").disabled = !document.getElementById("xmlnews_enable").checked;', true); $context['page_title'] = $txt['admin_edit_news'] . ' - ' . $txt['settings']; $context['sub_template'] = 'show_settings'; // Wrap it all up nice and warm... $context['post_url'] = $scripturl . '?action=admin;area=news;save;sa=settings'; $context['permissions_excluded'] = array(-1); // Saving the settings? if (isset($_GET['save'])) { checkSession(); call_integration_hook('integrate_save_news_settings'); Settings_Form::save_db($config_vars); redirectexit('action=admin;area=news;sa=settings'); } // We need this for the in-line permissions createToken('admin-mp'); Settings_Form::prepare_db($config_vars); }
/** * Begin the registration process. * Accessed by ?action=register * * @uses Register template, registration_agreement or registration_form sub template * @uses Login language file */ public function action_register() { global $txt, $context, $modSettings, $user_info, $language, $scripturl, $cur_profile; // Is this an incoming AJAX check? if (isset($_GET['sa']) && $_GET['sa'] == 'usernamecheck') { return $this->_registerCheckUsername(); } // Check if the administrator has it disabled. if (!empty($modSettings['registration_method']) && $modSettings['registration_method'] == '3') { fatal_lang_error('registration_disabled', false); } // If this user is an admin - redirect them to the admin registration page. if (allowedTo('moderate_forum') && !$user_info['is_guest']) { redirectexit('action=admin;area=regcenter;sa=register'); } elseif (empty($user_info['is_guest'])) { redirectexit(); } if (isset($_POST['show_contact'])) { redirectexit('action=contact'); } loadLanguage('Login'); loadTemplate('Register'); // Do we need them to agree to the registration agreement, first? $context['require_agreement'] = !empty($modSettings['requireAgreement']); $context['checkbox_agreement'] = !empty($modSettings['checkboxAgreement']); $context['registration_passed_agreement'] = !empty($_SESSION['registration_agreed']); $context['show_coppa'] = !empty($modSettings['coppaAge']); $context['show_contact_button'] = !empty($modSettings['enable_contactform']) && $modSettings['enable_contactform'] == 'registration'; // Under age restrictions? if ($context['show_coppa']) { $context['skip_coppa'] = false; $context['coppa_agree_above'] = sprintf($txt[($context['require_agreement'] ? 'agreement_' : '') . 'agree_coppa_above'], $modSettings['coppaAge']); $context['coppa_agree_below'] = sprintf($txt[($context['require_agreement'] ? 'agreement_' : '') . 'agree_coppa_below'], $modSettings['coppaAge']); } // What step are we at? $current_step = isset($_REQUEST['step']) ? (int) $_REQUEST['step'] : ($context['require_agreement'] && !$context['checkbox_agreement'] ? 1 : 2); // Does this user agree to the registration agreement? if ($current_step == 1 && (isset($_POST['accept_agreement']) || isset($_POST['accept_agreement_coppa']))) { $context['registration_passed_agreement'] = $_SESSION['registration_agreed'] = true; $current_step = 2; // Skip the coppa procedure if the user says he's old enough. if ($context['show_coppa']) { $_SESSION['skip_coppa'] = !empty($_POST['accept_agreement']); // Are they saying they're under age, while under age registration is disabled? if (empty($modSettings['coppaType']) && empty($_SESSION['skip_coppa'])) { loadLanguage('Login'); fatal_lang_error('under_age_registration_prohibited', false, array($modSettings['coppaAge'])); } } } elseif ($current_step > 1 && $context['require_agreement'] && !$context['checkbox_agreement'] && !$context['registration_passed_agreement']) { $current_step = 1; } // Show the user the right form. $context['sub_template'] = $current_step == 1 ? 'registration_agreement' : 'registration_form'; $context['page_title'] = $current_step == 1 ? $txt['registration_agreement'] : $txt['registration_form']; loadJavascriptFile('register.js'); addInlineJavascript('disableAutoComplete();', true); // Add the register chain to the link tree. $context['linktree'][] = array('url' => $scripturl . '?action=register', 'name' => $txt['register']); // Prepare the time gate! Done like this to allow later steps to reset the limit for any reason if (!isset($_SESSION['register'])) { $_SESSION['register'] = array('timenow' => time(), 'limit' => 8); } else { $_SESSION['register']['timenow'] = time(); } // If you have to agree to the agreement, it needs to be fetched from the file. if ($context['require_agreement']) { // Have we got a localized one? if (file_exists(BOARDDIR . '/agreement.' . $user_info['language'] . '.txt')) { $context['agreement'] = parse_bbc(file_get_contents(BOARDDIR . '/agreement.' . $user_info['language'] . '.txt'), true, 'agreement_' . $user_info['language']); } elseif (file_exists(BOARDDIR . '/agreement.txt')) { $context['agreement'] = parse_bbc(file_get_contents(BOARDDIR . '/agreement.txt'), true, 'agreement'); } else { $context['agreement'] = ''; } // Nothing to show, lets disable registration and inform the admin of this error if (empty($context['agreement'])) { // No file found or a blank file, log the error so the admin knows there is a problem! log_error($txt['registration_agreement_missing'], 'critical'); fatal_lang_error('registration_disabled', false); } } if (!empty($modSettings['userLanguage'])) { // Do we have any languages? $languages = getLanguages(); if (isset($_POST['lngfile']) && isset($languages[$_POST['lngfile']])) { $_SESSION['language'] = $_POST['lngfile']; } $selectedLanguage = empty($_SESSION['language']) ? $language : $_SESSION['language']; // Try to find our selected language. foreach ($languages as $key => $lang) { $context['languages'][$key]['name'] = $lang['name']; // Found it! if ($selectedLanguage == $lang['filename']) { $context['languages'][$key]['selected'] = true; } } } // Any custom fields we want filled in? require_once SUBSDIR . '/Profile.subs.php'; loadCustomFields(0, 'register'); // Or any standard ones? if (!empty($modSettings['registration_fields'])) { // Setup some important context. loadLanguage('Profile'); loadTemplate('Profile'); $context['user']['is_owner'] = true; // Here, and here only, emulate the permissions the user would have to do this. $user_info['permissions'] = array_merge($user_info['permissions'], array('profile_account_own', 'profile_extra_own')); $reg_fields = explode(',', $modSettings['registration_fields']); // We might have had some submissions on this front - go check. foreach ($reg_fields as $field) { if (isset($_POST[$field])) { $cur_profile[$field] = Util::htmlspecialchars($_POST[$field]); } } // Load all the fields in question. setupProfileContext($reg_fields, 'registration'); } // Generate a visual verification code to make sure the user is no bot. if (!empty($modSettings['reg_verification']) && $current_step > 1) { require_once SUBSDIR . '/VerificationControls.class.php'; $verificationOptions = array('id' => 'register'); $context['visual_verification'] = create_control_verification($verificationOptions); $context['visual_verification_id'] = $verificationOptions['id']; } else { $context['visual_verification'] = false; } // Are they coming from an OpenID login attempt? if (!empty($_SESSION['openid']['verified']) && !empty($_SESSION['openid']['openid_uri']) && !empty($_SESSION['openid']['nickname'])) { $context['openid'] = $_SESSION['openid']['openid_uri']; $context['username'] = !empty($_POST['user']) ? Util::htmlspecialchars($_POST['user']) : $_SESSION['openid']['nickname']; $context['email'] = !empty($_POST['email']) ? Util::htmlspecialchars($_POST['email']) : $_SESSION['openid']['email']; } else { $context += array('openid' => isset($_POST['openid_identifier']) ? $_POST['openid_identifier'] : '', 'username' => isset($_POST['user']) ? Util::htmlspecialchars($_POST['user']) : '', 'email' => isset($_POST['email']) ? Util::htmlspecialchars($_POST['email']) : ''); } // Were there any errors? $context['registration_errors'] = array(); $reg_errors = Error_Context::context('register', 0); if ($reg_errors->hasErrors()) { $context['registration_errors'] = $reg_errors->prepareErrors(); } createToken('register'); }
/** * Displays the search results page. */ function template_results() { global $context, $settings, $options, $txt, $scripturl, $message; // Let them know if we ignored a word in the search if (!empty($context['search_ignored'])) { echo ' <div id="search_results"> <h3 class="category_header"> ', $txt['generic_warning'], ' </h3> <p class="warningbox">', $txt['search_warning_ignored_word' . (count($context['search_ignored']) == 1 ? '' : 's')], ': ', implode(', ', $context['search_ignored']), '</p> </div>'; } // Or perhaps they made a spelling error, lets give them a hint if (isset($context['did_you_mean']) || empty($context['topics'])) { echo ' <div id="search_results"> <h2 class="category_header">', $txt['search_adjust_query'], '</h2> <div class="roundframe">'; // Did they make any typos or mistakes, perhaps? if (isset($context['did_you_mean'])) { echo ' <p>', $txt['search_did_you_mean'], ' <a href="', $scripturl, '?action=search;sa=results;params=', $context['did_you_mean_params'], '">', $context['did_you_mean'], '</a>.</p>'; } echo ' <form action="', $scripturl, '?action=search;sa=results" method="post" accept-charset="UTF-8"> <dl class="settings"> <dt class="righttext"> <label for="search"><strong>', $txt['search_for'], ':</strong></label> </dt> <dd> <input type="text" id="search" name="search" value="', $context['search_params']['search'], '" maxlength="', $context['search_string_limit'], '" size="40" class="input_text" /> </dd> </dl> <div class="submitbutton" > <input type="submit" name="edit_search" value="', $txt['search_adjust_submit'], '" class="button_submit" /> <input type="hidden" name="searchtype" value="', $context['search_params']['searchtype'], '" /> <input type="hidden" name="userspec" value="', $context['search_params']['userspec'], '" /> <input type="hidden" name="show_complete" value="', $context['search_params']['show_complete'], '" /> <input type="hidden" name="subject_only" value="', $context['search_params']['subject_only'], '" /> <input type="hidden" name="minage" value="', $context['search_params']['minage'], '" /> <input type="hidden" name="maxage" value="', $context['search_params']['maxage'], '" /> <input type="hidden" name="sort" value="', $context['search_params']['sort'], '" /> </div>'; if (!empty($context['search_params']['brd'])) { foreach ($context['search_params']['brd'] as $board_id) { echo ' <input type="hidden" name="brd[', $board_id, ']" value="', $board_id, '" />'; } } echo ' </form> </div> </div> <br />'; } // Quick moderation set to checkboxes? Oh, how fun :/. if (!empty($options['display_quick_mod']) && $options['display_quick_mod'] == 1) { echo ' <form action="', $scripturl, '?action=quickmod" method="post" accept-charset="UTF-8" name="topicForm" id="topicForm" class="search_results_posts', $context['compact'] ? ' compact_view' : '', '">'; } echo ' <h3 class="category_header hdicon cat_img_search"> <span class="floatright">'; if (!empty($options['display_quick_mod']) && $options['display_quick_mod'] == 1) { echo ' <input type="checkbox" onclick="invertAll(this, this.form, \'topics[]\');" class="input_check" />'; } echo ' </span> ', $txt['mlist_search_results'], ': ', $context['search_params']['search'], ' </h3>'; // Was anything even found? if (!empty($context['topics'])) { template_pagesection(); } else { echo ' <div class="roundframe">', $txt['find_no_results'], '</div>'; } if ($context['compact']) { echo ' <ul class="topic_listing compact_view search_results_posts">'; } else { echo ' <ul class="core_posts topic_listing search_results_posts">'; } // While we have results to show ... $controller = $context['get_topics'][0]; while ($topic = $controller->{$context['get_topics'][1]}()) { if ($context['compact']) { // We start with locked and sticky topics. if ($topic['is_sticky'] && $topic['is_locked']) { $color_class = 'locked_row sticky_row'; } elseif ($topic['is_sticky']) { $color_class = 'sticky_row'; } elseif ($topic['is_locked']) { $color_class = 'locked_row'; } else { $color_class = 'basic_row'; } } else { $color_class = $message['alternate'] == 0 ? 'windowbg' : 'windowbg2'; } foreach ($topic['matches'] as $message) { echo ' <li class="', $color_class, '"> <div class="topic_details"> <div class="counter">', $message['counter'], '</div> <h5>', $topic['board']['link'], ' / <a href="', $scripturl, '?topic=', $topic['id'], '.msg', $message['id'], '#msg', $message['id'], '">', $message['subject_highlighted'], '</a></h5> <span class="smalltext">« ', $txt['by'], ' <strong>', $message['member']['link'], '</strong> ', $txt['on'], ' <em>', $message['time'], '</em> »</span>'; echo ' </div>'; if (!$context['compact'] || $message['body_highlighted'] != '') { echo ' <div class="topic_body">', $message['body_highlighted'], '</div>'; } if (!empty($topic['buttons'])) { template_quickbutton_strip($topic['buttons'], $topic['tests']); } if (!empty($options['display_quick_mod'])) { echo ' <p class="topic_moderation">'; if ($options['display_quick_mod'] == 1) { echo ' <input type="checkbox" name="topics[]" value="', $topic['id'], '" class="input_check" />'; } else { if ($topic['quick_mod']['remove']) { echo ' <a href="', $scripturl, '?action=quickmod;actions%5B', $topic['id'], '%5D=remove;', $context['session_var'], '=', $context['session_id'], '" onclick="return confirm(\'', $txt['quickmod_confirm'], '\');"><img src="', $settings['images_url'], '/icons/quick_remove.png" style="width: 16px;" alt="', $txt['remove_topic'], '" title="', $txt['remove_topic'], '" /></a>'; } if ($topic['quick_mod']['lock']) { echo ' <a href="', $scripturl, '?action=quickmod;actions%5B', $topic['id'], '%5D=lock;', $context['session_var'], '=', $context['session_id'], '" onclick="return confirm(\'', $txt['quickmod_confirm'], '\');"><img src="', $settings['images_url'], '/icons/quick_lock.png" style="width: 16px;" alt="', $txt[$topic['is_locked'] ? 'set_unlock' : 'set_lock'], '" title="', $txt[$topic['is_locked'] ? 'set_unlock' : 'set_lock'], '" /></a>'; } if ($topic['quick_mod']['lock'] || $topic['quick_mod']['remove']) { echo ' <br />'; } if ($topic['quick_mod']['sticky']) { echo ' <a href="', $scripturl, '?action=quickmod;actions%5B', $topic['id'], '%5D=sticky;', $context['session_var'], '=', $context['session_id'], '" onclick="return confirm(\'', $txt['quickmod_confirm'], '\');"><img src="', $settings['images_url'], '/icons/quick_sticky.png" style="width: 16px;" alt="', $txt[$topic['is_sticky'] ? 'set_nonsticky' : 'set_sticky'], '" title="', $txt[$topic['is_sticky'] ? 'set_nonsticky' : 'set_sticky'], '" /></a>'; } if ($topic['quick_mod']['move']) { echo ' <a href="', $scripturl, '?action=movetopic;topic=', $topic['id'], '.0"><img src="', $settings['images_url'], '/icons/quick_move.png" style="width: 16px;" alt="', $txt['move_topic'], '" title="', $txt['move_topic'], '" /></a>'; } } echo ' </p>'; } echo ' </li>'; } } echo ' </ul>'; // If we have results show a page index if (!empty($context['topics'])) { template_pagesection(); } // Quick moderation enabled, then show an action area if (!empty($context['topics']) && !empty($options['display_quick_mod']) && $options['display_quick_mod'] == 1) { echo ' <div class="search_controls floatright"> <div class="additional_row"> <select class="qaction" name="qaction"', $context['can_move'] ? ' onchange="this.form.move_to.disabled = (this.options[this.selectedIndex].value != \'move\');"' : '', '> <option value=""> </option>'; foreach ($context['qmod_actions'] as $qmod_action) { if ($context['can_' . $qmod_action]) { echo ' <option value="' . $qmod_action . '">' . (isBrowser('ie8') ? '»' : '➤') . ' ', $txt['quick_mod_' . $qmod_action] . '</option>'; } } echo ' </select>'; // Show a list of boards they can move the topic to. if ($context['can_move']) { echo ' <span id="quick_mod_jump_to"> </span>'; } echo ' <input type="hidden" name="redirect_url" value="', $scripturl . '?action=search;sa=results;params=' . $context['params'], '" /> <input class="button_submit" type="submit" value="', $txt['quick_mod_go'], '" onclick="return document.forms.topicForm.qaction.value != \'\' && confirm(\'', $txt['quickmod_confirm'], '\');" /> </div> </div>'; echo ' <input type="hidden" name="' . $context['session_var'] . '" value="' . $context['session_id'] . '" /> </form>'; } // Show a jump to box for easy navigation. echo ' <div class="floatright" id="search_jump_to"> </div>'; if (!empty($options['display_quick_mod']) && $options['display_quick_mod'] == 1 && !empty($context['topics']) && $context['can_move']) { addInlineJavascript(' aJumpTo[aJumpTo.length] = new JumpTo({ sContainerId: "quick_mod_jump_to", sClassName: "qaction", sJumpToTemplate: "%dropdown_list%", sCurBoardName: "' . $context['jump_to']['board_name'] . '", sBoardChildLevelIndicator: " ", sBoardPrefix: "' . (isBrowser('ie8') ? '»' : '➤') . ' ", sCatClass: "jump_to_header", sCatPrefix: "", bNoRedirect: true, bDisabled: true, sCustomName: "move_to" });', true); } addInlineJavascript(' aJumpTo[aJumpTo.length] = new JumpTo({ sContainerId: "search_jump_to", sJumpToTemplate: "<label class=\\"smalltext\\" for=\\"%select_id%\\">' . $context['jump_to']['label'] . ':<" + "/label> %dropdown_list%", iCurBoardId: 0, iCurBoardChildLevel: 0, sCurBoardName: "' . $context['jump_to']['board_name'] . '", sBoardChildLevelIndicator: " ", sBoardPrefix: "' . (isBrowser('ie8') ? '»' : '➤') . ' ", sCatClass: "jump_to_header", sCatPrefix: "", sGoButtonLabel: "' . $txt['quick_mod_go'] . '" });', true); }
/** * All the post by email settings, used to control how the feature works * * @uses Admin language */ public function action_settings() { global $scripturl, $context, $txt, $modSettings; // Be nice, show them we did something if (isset($_GET['saved'])) { $context['settings_message'] = $txt['saved']; } // Templates and language loadLanguage('Admin'); loadTemplate('Admin', 'admin'); // Load any existing email => board values used for new topic creation $context['maillist_from_to_board'] = array(); $data = !empty($modSettings['maillist_receiving_address']) ? unserialize($modSettings['maillist_receiving_address']) : array(); foreach ($data as $key => $addr) { $context['maillist_from_to_board'][$key] = array('id' => $key, 'emailfrom' => $addr[0], 'boardto' => $addr[1]); } // Initialize the maillist settings form $this->_initMaillistSettingsForm(); // Retrieve the config settings $config_vars = $this->_maillistSettings->settings(); // Saving settings? if (isset($_GET['save'])) { checkSession(); call_integration_hook('integrate_save_maillist_settings'); $email_error = false; $board_error = false; $maillist_receiving_address = array(); // Basic checking of the email addresses require_once SUBSDIR . '/DataValidator.class.php'; if (!Data_Validator::is_valid($_POST, array('maillist_sitename_address' => 'valid_email'), array('maillist_sitename_address' => 'trim'))) { $email_error = $_POST['maillist_sitename_address']; } if (!Data_Validator::is_valid($_POST, array('maillist_sitename_help' => 'valid_email'), array('maillist_sitename_help' => 'trim'))) { $email_error = $_POST['maillist_sitename_help']; } if (!Data_Validator::is_valid($_POST, array('maillist_mail_from' => 'valid_email'), array('maillist_mail_from' => 'trim'))) { $email_error = $_POST['maillist_mail_from']; } // Inbound email set up then we need to check for both valid email and valid board if (!$email_error && !empty($_POST['emailfrom'])) { // Get the board ids for a quick check $boards = maillist_board_list(); // Check the receiving emails and the board id as well $boardtocheck = !empty($_POST['boardto']) ? $_POST['boardto'] : array(); $addresstocheck = !empty($_POST['emailfrom']) ? $_POST['emailfrom'] : array(); foreach ($addresstocheck as $key => $checkme) { // Valid email syntax if (!Data_Validator::is_valid($addresstocheck, array($key => 'valid_email'), array($key => 'trim'))) { $email_error = $checkme; $context['error_type'] = 'notice'; continue; } // Valid board id? if (!isset($boardtocheck[$key]) || !isset($boards[$key])) { $board_error = $checkme; $context['error_type'] = 'notice'; continue; } // Decipher as [0]emailaddress and [1]board id $maillist_receiving_address[] = array($checkme, $boardtocheck[$key]); } } // Enable or disable the fake cron enable_maillist_imap_cron(!empty($_POST['maillist_imap_cron'])); // Check and set any errors or give the go ahead to save if ($email_error) { $context['settings_message'] = sprintf($txt['email_not_valid'], $email_error); } elseif ($board_error) { $context['settings_message'] = sprintf($txt['board_not_valid'], $board_error); } else { // Clear the moderation count cache cache_put_data('num_menu_errors', null, 900); // Should be off if mail posting is on, we ignore it anyway but this at least updates the ACP if (!empty($_POST['maillist_enabled'])) { updateSettings(array('disallow_sendBody' => '')); } updateSettings(array('maillist_receiving_address' => serialize($maillist_receiving_address))); Settings_Form::save_db($config_vars); writeLog(); redirectexit('action=admin;area=maillist;sa=emailsettings;saved'); } } // Javascript vars for the "add more" buttons in the receive_email callback $board_list = maillist_board_list(); $script = ''; $i = 0; // Create the board selection list foreach ($board_list as $board_id => $board_name) { $script .= $i++ . ': {id:' . $board_id . ', name:' . JavaScriptEscape($board_name) . '},'; } addInlineJavascript(' var sEmailParent = \'add_more_email_placeholder\', oEmailOptionsdt = {size: \'50\', name: \'emailfrom[]\', class: \'input_text\'}, oEmailOptionsdd = {size: \'1\', type: \'select\', name: \'boardto[]\', class: \'input_select\'}, oEmailSelectData = {' . $script . '}; document.getElementById(\'add_more_board_div\').style.display = \'\';', true); $context['boards'] = $board_list; $context['settings_title'] = $txt['ml_emailsettings']; $context['page_title'] = $txt['ml_emailsettings']; $context['post_url'] = $scripturl . '?action=admin;area=maillist;sa=emailsettings;save'; $context['sub_template'] = 'show_settings'; Settings_Form::prepare_db($config_vars); }