function activateAccount($memID)
{
    global $sourcedir, $context, $user_profile, $modSettings;
    isAllowedTo('moderate_forum');
    if (isset($_REQUEST['save']) && isset($user_profile[$memID]['is_activated']) && $user_profile[$memID]['is_activated'] != 1) {
        // If we are approving the deletion of an account, we do something special ;)
        if ($user_profile[$memID]['is_activated'] == 4) {
            require_once $sourcedir . '/Subs-Members.php';
            deleteMembers($context['id_member']);
            redirectexit();
        }
        // Let the integrations know of the activation.
        call_integration_hook('integrate_activate', array($user_profile[$memID]['member_name']));
        // Actually update this member now, as it guarantees the unapproved count can't get corrupted.
        updateMemberData($context['id_member'], array('is_activated' => $user_profile[$memID]['is_activated'] >= 10 ? 11 : 1, 'validation_code' => ''));
        // If we are doing approval, update the stats for the member just in case.
        if (in_array($user_profile[$memID]['is_activated'], array(3, 4, 13, 14))) {
            updateSettings(array('unapprovedMembers' => $modSettings['unapprovedMembers'] > 1 ? $modSettings['unapprovedMembers'] - 1 : 0));
        }
        // Make sure we update the stats too.
        updateStats('member', false);
    }
    // Leave it be...
    redirectexit('action=profile;u=' . $memID . ';area=summary');
}
Пример #2
0
 /**
  * This keeps track of all registered handling functions for auto suggest
  * functionality and passes execution to them.
  * Accessed by action=suggest.
  * @uses Xml template
  */
 public function action_suggest()
 {
     global $context;
     // These are all registered types.
     $searchTypes = array('member' => array('file' => SUBSDIR . '/Suggest.class.php', 'class' => 'Suggest', 'function' => 'member'));
     call_integration_hook('integrate_autosuggest', array(&$searchTypes));
     checkSession('get');
     loadTemplate('Xml');
     // Any parameters?
     $context['search_param'] = isset($_REQUEST['search_param']) ? unserialize(base64_decode($_REQUEST['search_param'])) : array();
     if (isset($_REQUEST['suggest_type'], $_REQUEST['search']) && isset($searchTypes[$_REQUEST['suggest_type']])) {
         // Shortcut
         $currentSearch = $searchTypes[$_REQUEST['suggest_type']];
         // Do we have a file to include?
         if (!empty($currentSearch['file']) && file_exists($currentSearch['file'])) {
             require_once $currentSearch['file'];
         }
         // If it is a class, let's instantiate it
         if (!empty($currentSearch['class']) && class_exists($currentSearch['class'])) {
             $suggest = new $currentSearch['class']();
             // Okay, let's at least assume the method exists... *rolleyes*
             $context['xml_data'] = $suggest->{$currentSearch}['function']();
         } elseif (function_exists('action_suggest_' . $currentSearch['function'])) {
             $function = 'action_suggest_' . $searchTypes[$_REQUEST['suggest_type']];
             $context['xml_data'] = $function();
         }
         if (!empty($context['xml_data'])) {
             $context['sub_template'] = 'generic_xml';
         }
     }
 }
Пример #3
0
/**
 * This function shows the board index.
 * It uses the BoardIndex template, and main sub template.
 * It may use the boardindex subtemplate for wireless support.
 * It updates the most online statistics.
 * It is accessed by ?action=boardindex.
 */
function BoardIndex()
{
    global $txt, $user_info, $sourcedir, $modSettings, $context, $settings, $scripturl;
    // For wireless, we use the Wireless template...
    if (WIRELESS) {
        $context['sub_template'] = WIRELESS_PROTOCOL . '_boardindex';
    } else {
        loadTemplate('BoardIndex');
    }
    // Set a canonical URL for this page.
    $context['canonical_url'] = $scripturl;
    // Do not let search engines index anything if there is a random thing in $_GET.
    if (!empty($_GET)) {
        $context['robot_no_index'] = true;
    }
    // Retrieve the categories and boards.
    require_once $sourcedir . '/Subs-BoardIndex.php';
    $boardIndexOptions = array('include_categories' => true, 'base_level' => 0, 'parent_id' => 0, 'set_latest_post' => true, 'countChildPosts' => !empty($modSettings['countChildPosts']));
    $context['categories'] = getBoardIndex($boardIndexOptions);
    // Get the user online list.
    require_once $sourcedir . '/Subs-MembersOnline.php';
    $membersOnlineOptions = array('show_hidden' => allowedTo('moderate_forum'), 'sort' => 'log_time', 'reverse_sort' => true);
    $context += getMembersOnlineStats($membersOnlineOptions);
    $context['show_buddies'] = !empty($user_info['buddies']);
    // Are we showing all membergroups on the board index?
    if (!empty($settings['show_group_key'])) {
        $context['membergroups'] = cache_quick_get('membergroup_list', 'Subs-Membergroups.php', 'cache_getMembergroupList', array());
    }
    // Track most online statistics? (Subs-MembersOnline.php)
    if (!empty($modSettings['trackStats'])) {
        trackStatsUsersOnline($context['num_guests'] + $context['num_spiders'] + $context['num_users_online']);
    }
    // Retrieve the latest posts if the theme settings require it.
    if (isset($settings['number_recent_posts']) && $settings['number_recent_posts'] > 1) {
        $latestPostOptions = array('number_posts' => $settings['number_recent_posts']);
        $context['latest_posts'] = cache_quick_get('boardindex-latest_posts:' . md5($user_info['query_wanna_see_board'] . $user_info['language']), 'Subs-Recent.php', 'cache_getLastPosts', array($latestPostOptions));
    }
    $settings['display_recent_bar'] = !empty($settings['number_recent_posts']) ? $settings['number_recent_posts'] : 0;
    $settings['show_member_bar'] &= allowedTo('view_mlist');
    $context['show_stats'] = allowedTo('view_stats') && !empty($modSettings['trackStats']);
    $context['show_member_list'] = allowedTo('view_mlist');
    $context['show_who'] = allowedTo('who_view') && !empty($modSettings['who_enabled']);
    // Load the calendar?
    if (!empty($modSettings['cal_enabled']) && allowedTo('calendar_view')) {
        // Retrieve the calendar data (events, birthdays, holidays).
        $eventOptions = array('include_holidays' => $modSettings['cal_showholidays'] > 1, 'include_birthdays' => $modSettings['cal_showbdays'] > 1, 'include_events' => $modSettings['cal_showevents'] > 1, 'num_days_shown' => empty($modSettings['cal_days_for_index']) || $modSettings['cal_days_for_index'] < 1 ? 1 : $modSettings['cal_days_for_index']);
        $context += cache_quick_get('calendar_index_offset_' . ($user_info['time_offset'] + $modSettings['time_offset']), 'Subs-Calendar.php', 'cache_getRecentEvents', array($eventOptions));
        // Whether one or multiple days are shown on the board index.
        $context['calendar_only_today'] = $modSettings['cal_days_for_index'] == 1;
        // This is used to show the "how-do-I-edit" help.
        $context['calendar_can_edit'] = allowedTo('calendar_edit_any');
    } else {
        $context['show_calendar'] = false;
    }
    $context['page_title'] = sprintf($txt['forum_index'], $context['forum_name']);
    // Mark read button
    $context['mark_read_button'] = array('markread' => array('text' => 'mark_as_read', 'image' => 'markread.png', 'lang' => true, 'url' => $scripturl . '?action=markasread;sa=all;' . $context['session_var'] . '=' . $context['session_id']));
    // Allow mods to add additional buttons here
    call_integration_hook('integrate_mark_read_button');
}
Пример #4
0
/**
 * Config array for chaning the karma settings
 * Accessed  from ?action=admin;area=featuresettings;sa=karma;
 *
 * @param $return_config
 */
function ModifyKarmaSettings($return_config = false)
{
    global $txt, $scripturl, $context, $modSettings;
    loadLanguage('Karma+ManageKarma');
    if (empty($modSettings['karmaMode'])) {
        $config_vars = array(array('select', 'karmaMode', explode('|', $txt['karma_options'])));
    } else {
        $config_vars = array(array('select', 'karmaMode', explode('|', $txt['karma_options'])), '', array('int', 'karmaMinPosts', 6, 'postinput' => strtolower($txt['posts'])), array('float', 'karmaWaitTime', 6, 'postinput' => $txt['hours']), array('check', 'karmaTimeRestrictAdmins'));
    }
    call_integration_hook('integrate_karma_settings', array(&$config_vars));
    if ($return_config) {
        return $config_vars;
    }
    // Saving?
    if (isset($_GET['save'])) {
        checkSession();
        call_integration_hook('integrate_save_karma_settings');
        saveDBSettings($config_vars);
        $_SESSION['adm-save'] = true;
        redirectexit('action=admin;area=featuresettings;sa=karma');
    }
    $context['post_url'] = $scripturl . '?action=admin;area=featuresettings;save;sa=karma';
    $context['settings_title'] = $txt['karma'];
    loadLanguage('ManageKarma');
    prepareDBSettingContext($config_vars);
}
Пример #5
0
/**
 * Simple function that loads and returns all the verification controls known to Elk
 */
function loadVerificationControls()
{
    $known_verifications = array('captcha', 'questions', 'emptyfield');
    // Let integration add some more controls
    call_integration_hook('integrate_control_verification', array(&$known_verifications));
    return $known_verifications;
}
Пример #6
0
 /**
  * We want to see if they are called
  */
 function testCallHooks()
 {
     $call = call_integration_hook($this->_hook_name);
     foreach ($this->_tests as $test) {
         $this->assertTrue($this->_is_hook_called($call, $test['call'] . (!empty($test['file']) ? '|' . $test['file'] : '')));
     }
 }
Пример #7
0
/**
 * Attempt to start the session, unless it already has been.
 */
function loadSession()
{
    global $HTTP_SESSION_VARS, $modSettings, $boardurl, $sc;
    // Attempt to change a few PHP settings.
    @ini_set('session.use_cookies', true);
    @ini_set('session.use_only_cookies', false);
    @ini_set('url_rewriter.tags', '');
    @ini_set('session.use_trans_sid', false);
    @ini_set('arg_separator.output', '&amp;');
    if (!empty($modSettings['globalCookies'])) {
        $parsed_url = parse_url($boardurl);
        if (preg_match('~^\\d{1,3}(\\.\\d{1,3}){3}$~', $parsed_url['host']) == 0 && preg_match('~(?:[^\\.]+\\.)?([^\\.]{2,}\\..+)\\z~i', $parsed_url['host'], $parts) == 1) {
            @ini_set('session.cookie_domain', '.' . $parts[1]);
        }
    }
    // @todo Set the session cookie path?
    // If it's already been started... probably best to skip this.
    if (ini_get('session.auto_start') == 1 && !empty($modSettings['databaseSession_enable']) || session_id() == '') {
        // Attempt to end the already-started session.
        if (ini_get('session.auto_start') == 1) {
            session_write_close();
        }
        // This is here to stop people from using bad junky PHPSESSIDs.
        if (isset($_REQUEST[session_name()]) && preg_match('~^[A-Za-z0-9,-]{16,64}$~', $_REQUEST[session_name()]) == 0 && !isset($_COOKIE[session_name()])) {
            $session_id = md5(md5('smf_sess_' . time()) . mt_rand());
            $_REQUEST[session_name()] = $session_id;
            $_GET[session_name()] = $session_id;
            $_POST[session_name()] = $session_id;
        }
        // Use database sessions? (they don't work in 4.1.x!)
        if (!empty($modSettings['databaseSession_enable'])) {
            session_set_save_handler('sessionOpen', 'sessionClose', 'sessionRead', 'sessionWrite', 'sessionDestroy', 'sessionGC');
            @ini_set('session.gc_probability', '1');
        } elseif (ini_get('session.gc_maxlifetime') <= 1440 && !empty($modSettings['databaseSession_lifetime'])) {
            @ini_set('session.gc_maxlifetime', max($modSettings['databaseSession_lifetime'], 60));
        }
        // Use cache setting sessions?
        if (empty($modSettings['databaseSession_enable']) && !empty($modSettings['cache_enable']) && php_sapi_name() != 'cli') {
            call_integration_hook('integrate_session_handlers');
            // @todo move these to a plugin.
            if (function_exists('mmcache_set_session_handlers')) {
                mmcache_set_session_handlers();
            } elseif (function_exists('eaccelerator_set_session_handlers')) {
                eaccelerator_set_session_handlers();
            }
        }
        session_start();
        // Change it so the cache settings are a little looser than default.
        if (!empty($modSettings['databaseSession_loose'])) {
            header('Cache-Control: private');
        }
    }
    // Set the randomly generated code.
    if (!isset($_SESSION['session_var'])) {
        $_SESSION['session_value'] = md5(session_id() . mt_rand());
        $_SESSION['session_var'] = substr(preg_replace('~^\\d+~', '', sha1(mt_rand() . session_id() . mt_rand())), 0, rand(7, 12));
    }
    $sc = $_SESSION['session_value'];
}
/**
 *	Provides a list of the known role/permission templates for the system.
 *
 *	@since 2.0
*/
function shd_load_role_templates()
{
    global $context, $modSettings;
    // UNDER PAIN OF DEATH
    // Do not add anything other than ROLEPERM_ALLOW rules here.
    $context['shd_permissions']['roles'] = array(ROLE_USER => array('description' => 'shd_permrole_user', 'icon' => 'user.png', 'permissions' => array('access_helpdesk' => ROLEPERM_ALLOW, 'shd_view_ticket_own' => ROLEPERM_ALLOW, 'shd_view_ticket_private_own' => ROLEPERM_ALLOW, 'shd_view_closed_own' => ROLEPERM_ALLOW, 'shd_new_ticket' => ROLEPERM_ALLOW, 'shd_edit_ticket_own' => ROLEPERM_ALLOW, 'shd_reply_ticket_own' => ROLEPERM_ALLOW, 'shd_edit_reply_own' => ROLEPERM_ALLOW, 'shd_view_attachment' => ROLEPERM_ALLOW, 'shd_post_attachment' => ROLEPERM_ALLOW, 'shd_resolve_ticket_own' => ROLEPERM_ALLOW, 'shd_unresolve_ticket_own' => ROLEPERM_ALLOW, 'shd_view_ticket_logs_own' => ROLEPERM_ALLOW, 'shd_view_profile_own' => ROLEPERM_ALLOW, 'shd_view_profile_log_own' => ROLEPERM_ALLOW, 'shd_view_preferences_own' => ROLEPERM_ALLOW, 'shd_view_relationships' => ROLEPERM_ALLOW, 'shd_delete_ticket_own' => ROLEPERM_ALLOW, 'shd_delete_reply_own' => ROLEPERM_ALLOW)), ROLE_STAFF => array('description' => 'shd_permrole_staff', 'icon' => 'staff.png', 'permissions' => array('access_helpdesk' => ROLEPERM_ALLOW, 'shd_staff' => ROLEPERM_ALLOW, 'shd_view_ticket_any' => ROLEPERM_ALLOW, 'shd_view_ticket_private_any' => ROLEPERM_ALLOW, 'shd_view_closed_any' => ROLEPERM_ALLOW, 'shd_view_ip_own' => ROLEPERM_ALLOW, 'shd_search' => ROLEPERM_ALLOW, 'shd_new_ticket' => ROLEPERM_ALLOW, 'shd_edit_ticket_any' => ROLEPERM_ALLOW, 'shd_reply_ticket_any' => ROLEPERM_ALLOW, 'shd_edit_reply_any' => ROLEPERM_ALLOW, 'shd_post_proxy' => ROLEPERM_ALLOW, 'shd_monitor_ticket_any' => ROLEPERM_ALLOW, 'shd_singleton_email' => ROLEPERM_ALLOW, 'shd_ignore_ticket_own' => ROLEPERM_ALLOW, 'shd_silent_update' => ROLEPERM_ALLOW, 'shd_view_attachment' => ROLEPERM_ALLOW, 'shd_post_attachment' => ROLEPERM_ALLOW, 'shd_resolve_ticket_any' => ROLEPERM_ALLOW, 'shd_unresolve_ticket_any' => ROLEPERM_ALLOW, 'shd_view_ticket_logs_any' => ROLEPERM_ALLOW, 'shd_alter_urgency_any' => ROLEPERM_ALLOW, 'shd_alter_privacy_any' => ROLEPERM_ALLOW, 'shd_assign_ticket_own' => ROLEPERM_ALLOW, 'shd_view_profile_any' => ROLEPERM_ALLOW, 'shd_view_profile_log_any' => ROLEPERM_ALLOW, 'shd_view_preferences_own' => ROLEPERM_ALLOW, 'shd_view_relationships' => ROLEPERM_ALLOW, 'shd_create_relationships' => ROLEPERM_ALLOW, 'shd_delete_relationships' => ROLEPERM_ALLOW, 'shd_access_recyclebin' => ROLEPERM_ALLOW, 'shd_delete_ticket_any' => ROLEPERM_ALLOW, 'shd_delete_reply_any' => ROLEPERM_ALLOW, 'shd_restore_ticket_any' => ROLEPERM_ALLOW, 'shd_restore_reply_any' => ROLEPERM_ALLOW, 'shd_ticket_to_topic' => ROLEPERM_ALLOW, 'shd_topic_to_ticket' => ROLEPERM_ALLOW, 'shd_move_dept_own' => ROLEPERM_ALLOW)), ROLE_ADMIN => array('description' => 'shd_permrole_admin', 'icon' => 'admin.png', 'permissions' => array('access_helpdesk' => ROLEPERM_ALLOW, 'shd_staff' => ROLEPERM_ALLOW, 'admin_helpdesk' => ROLEPERM_ALLOW, 'shd_view_ticket_any' => ROLEPERM_ALLOW, 'shd_view_ticket_private_any' => ROLEPERM_ALLOW, 'shd_view_closed_any' => ROLEPERM_ALLOW, 'shd_view_ip_any' => ROLEPERM_ALLOW, 'shd_search' => ROLEPERM_ALLOW, 'shd_new_ticket' => ROLEPERM_ALLOW, 'shd_edit_ticket_any' => ROLEPERM_ALLOW, 'shd_reply_ticket_any' => ROLEPERM_ALLOW, 'shd_edit_reply_any' => ROLEPERM_ALLOW, 'shd_post_proxy' => ROLEPERM_ALLOW, 'shd_override_cf' => ROLEPERM_ALLOW, 'shd_monitor_ticket_any' => ROLEPERM_ALLOW, 'shd_singleton_email' => ROLEPERM_ALLOW, 'shd_ignore_ticket_any' => ROLEPERM_ALLOW, 'shd_silent_update' => ROLEPERM_ALLOW, 'shd_view_attachment' => ROLEPERM_ALLOW, 'shd_post_attachment' => ROLEPERM_ALLOW, 'shd_delete_attachment' => ROLEPERM_ALLOW, 'shd_resolve_ticket_any' => ROLEPERM_ALLOW, 'shd_unresolve_ticket_any' => ROLEPERM_ALLOW, 'shd_view_ticket_logs_any' => ROLEPERM_ALLOW, 'shd_alter_urgency_any' => ROLEPERM_ALLOW, 'shd_alter_urgency_higher_any' => ROLEPERM_ALLOW, 'shd_alter_privacy_any' => ROLEPERM_ALLOW, 'shd_assign_ticket_any' => ROLEPERM_ALLOW, 'shd_view_profile_any' => ROLEPERM_ALLOW, 'shd_view_profile_log_any' => ROLEPERM_ALLOW, 'shd_view_preferences_any' => ROLEPERM_ALLOW, 'shd_view_relationships' => ROLEPERM_ALLOW, 'shd_create_relationships' => ROLEPERM_ALLOW, 'shd_delete_relationships' => ROLEPERM_ALLOW, 'shd_access_recyclebin' => ROLEPERM_ALLOW, 'shd_delete_ticket_any' => ROLEPERM_ALLOW, 'shd_delete_reply_any' => ROLEPERM_ALLOW, 'shd_restore_ticket_any' => ROLEPERM_ALLOW, 'shd_restore_reply_any' => ROLEPERM_ALLOW, 'shd_ticket_to_topic' => ROLEPERM_ALLOW, 'shd_topic_to_ticket' => ROLEPERM_ALLOW, 'shd_move_dept_any' => ROLEPERM_ALLOW)));
    call_integration_hook('shd_hook_permstemplate');
}
Пример #9
0
function AdminMain()
{
    global $txt, $context, $scripturl, $sc, $modSettings, $user_info, $settings, $sourcedir, $options, $smcFunc, $boarddir;
    // Load the language and templates....
    loadLanguage('Admin');
    loadTemplate('Admin', 'admin');
    //-- SMFHacks.com; Global Headers and Footers
    loadLanguage('smfhacks_languages/global-hf');
    // End SMFHacks.com; Global Headers and Footers --//
    // No indexing evil stuff.
    $context['robot_no_index'] = true;
    require_once $sourcedir . '/Subs-Menu.php';
    // Some preferences.
    $context['admin_preferences'] = !empty($options['admin_preferences']) ? unserialize($options['admin_preferences']) : array();
    // Define all the menu structure - see Subs-Menu.php for details!
    $admin_areas = array('forum' => array('title' => $txt['admin_main'], 'permission' => array('admin_forum', 'manage_permissions', 'moderate_forum', 'manage_membergroups', 'manage_bans', 'send_mail', 'edit_news', 'manage_boards', 'manage_smileys', 'manage_attachments'), 'areas' => array('index' => array('label' => $txt['admin_center'], 'function' => 'AdminHome', 'icon' => 'administration.gif'), 'credits' => array('label' => $txt['support_credits_title'], 'function' => 'AdminHome', 'icon' => 'support.gif'), 'news' => array('label' => $txt['news_title'], 'file' => 'ManageNews.php', 'function' => 'ManageNews', 'icon' => 'news.gif', 'permission' => array('edit_news', 'send_mail', 'admin_forum'), 'subsections' => array('editnews' => array($txt['admin_edit_news'], 'edit_news'), 'mailingmembers' => array($txt['admin_newsletters'], 'send_mail'), 'settings' => array($txt['settings'], 'admin_forum'))), 'packages' => array('label' => $txt['package'], 'file' => 'Packages.php', 'function' => 'Packages', 'permission' => array('admin_forum'), 'icon' => 'packages.gif', 'subsections' => array('browse' => array($txt['browse_packages']), 'packageget' => array($txt['download_packages'], 'url' => $scripturl . '?action=admin;area=packages;sa=packageget;get'), 'installed' => array($txt['installed_packages']), 'perms' => array($txt['package_file_perms']), 'options' => array($txt['package_settings']))), 'search' => array('function' => 'AdminSearch', 'permission' => array('admin_forum'), 'select' => 'index'))), 'config' => array('title' => $txt['admin_config'], 'permission' => array('admin_forum'), 'areas' => array('corefeatures' => array('label' => $txt['core_settings_title'], 'file' => 'ManageSettings.php', 'function' => 'ModifyCoreFeatures', 'icon' => 'corefeatures.gif'), 'featuresettings' => array('label' => $txt['modSettings_title'], 'file' => 'ManageSettings.php', 'function' => 'ModifyFeatureSettings', 'icon' => 'features.gif', 'subsections' => array('basic' => array($txt['mods_cat_features']), 'layout' => array($txt['mods_cat_layout']), 'karma' => array($txt['karma'], 'enabled' => in_array('k', $context['admin_features'])), 'sig' => array($txt['signature_settings_short']), 'profile' => array($txt['custom_profile_shorttitle'], 'enabled' => in_array('cp', $context['admin_features'])))), 'securitysettings' => array('label' => $txt['admin_security_moderation'], 'file' => 'ManageSettings.php', 'function' => 'ModifySecuritySettings', 'icon' => 'security.gif', 'subsections' => array('general' => array($txt['mods_cat_security_general']), 'spam' => array($txt['antispam_title']), 'moderation' => array($txt['moderation_settings_short'], 'enabled' => substr($modSettings['warning_settings'], 0, 1) == 1))), 'languages' => array('label' => $txt['language_configuration'], 'file' => 'ManageServer.php', 'function' => 'ManageLanguages', 'icon' => 'languages.gif', 'subsections' => array('edit' => array($txt['language_edit']), 'add' => array($txt['language_add']), 'settings' => array($txt['language_settings']))), 'serversettings' => array('label' => $txt['admin_server_settings'], 'file' => 'ManageServer.php', 'function' => 'ModifySettings', 'icon' => 'server.gif', 'subsections' => array('general' => array($txt['general_settings']), 'database' => array($txt['database_paths_settings']), 'cookie' => array($txt['cookies_sessions_settings']), 'cache' => array($txt['caching_settings']), 'loads' => array($txt['load_balancing_settings']))), 'globalhf' => array('label' => $txt['global_hf']['title'], 'file' => 'smfhacks_source/global-hf.php', 'function' => 'GlobalHF', 'icon' => '../smfhacks_images/global-hf-table-select-row.png', 'subsections' => array()), 'current_theme' => array('label' => $txt['theme_current_settings'], 'file' => 'Themes.php', 'function' => 'ThemesMain', 'custom_url' => $scripturl . '?action=admin;area=theme;sa=settings;th=' . $settings['theme_id'], 'icon' => 'current_theme.gif'), 'theme' => array('label' => $txt['theme_admin'], 'file' => 'Themes.php', 'function' => 'ThemesMain', 'custom_url' => $scripturl . '?action=admin;area=theme;sa=admin', 'icon' => 'themes.gif', 'subsections' => array('admin' => array($txt['themeadmin_admin_title']), 'list' => array($txt['themeadmin_list_title']), 'reset' => array($txt['themeadmin_reset_title']), 'edit' => array($txt['themeadmin_edit_title']))), 'modsettings' => array('label' => $txt['admin_modifications'], 'file' => 'ManageSettings.php', 'function' => 'ModifyModSettings', 'icon' => 'modifications.gif', 'subsections' => array('general' => array($txt['mods_cat_modifications_misc']))))), 'layout' => array('title' => $txt['layout_controls'], 'permission' => array('manage_boards', 'admin_forum', 'manage_smileys', 'manage_attachments', 'moderate_forum'), 'areas' => array('manageboards' => array('label' => $txt['admin_boards'], 'file' => 'ManageBoards.php', 'function' => 'ManageBoards', 'icon' => 'boards.gif', 'permission' => array('manage_boards'), 'subsections' => array('main' => array($txt['boardsEdit']), 'newcat' => array($txt['mboards_new_cat']), 'settings' => array($txt['settings'], 'admin_forum'))), 'postsettings' => array('label' => $txt['manageposts'], 'file' => 'ManagePosts.php', 'function' => 'ManagePostSettings', 'permission' => array('admin_forum'), 'icon' => 'posts.gif', 'subsections' => array('posts' => array($txt['manageposts_settings']), 'bbc' => array($txt['manageposts_bbc_settings']), 'censor' => array($txt['admin_censored_words']), 'topics' => array($txt['manageposts_topic_settings']))), 'managecalendar' => array('label' => $txt['manage_calendar'], 'file' => 'ManageCalendar.php', 'function' => 'ManageCalendar', 'icon' => 'calendar.gif', 'permission' => array('admin_forum'), 'enabled' => in_array('cd', $context['admin_features']), 'subsections' => array('holidays' => array($txt['manage_holidays'], 'admin_forum', 'enabled' => !empty($modSettings['cal_enabled'])), 'settings' => array($txt['calendar_settings'], 'admin_forum'))), 'managesearch' => array('label' => $txt['manage_search'], 'file' => 'ManageSearch.php', 'function' => 'ManageSearch', 'icon' => 'search.gif', 'permission' => array('admin_forum'), 'subsections' => array('weights' => array($txt['search_weights']), 'method' => array($txt['search_method']), 'settings' => array($txt['settings']))), 'smileys' => array('label' => $txt['smileys_manage'], 'file' => 'ManageSmileys.php', 'function' => 'ManageSmileys', 'icon' => 'smiley.gif', 'permission' => array('manage_smileys'), 'subsections' => array('editsets' => array($txt['smiley_sets']), 'addsmiley' => array($txt['smileys_add'], 'enabled' => !empty($modSettings['smiley_enable'])), 'editsmileys' => array($txt['smileys_edit'], 'enabled' => !empty($modSettings['smiley_enable'])), 'setorder' => array($txt['smileys_set_order'], 'enabled' => !empty($modSettings['smiley_enable'])), 'editicons' => array($txt['icons_edit_message_icons'], 'enabled' => !empty($modSettings['messageIcons_enable'])), 'settings' => array($txt['settings']))), 'manageattachments' => array('label' => $txt['attachments_avatars'], 'file' => 'ManageAttachments.php', 'function' => 'ManageAttachments', 'icon' => 'attachment.gif', 'permission' => array('manage_attachments'), 'subsections' => array('browse' => array($txt['attachment_manager_browse']), 'attachments' => array($txt['attachment_manager_settings']), 'avatars' => array($txt['attachment_manager_avatar_settings']), 'maintenance' => array($txt['attachment_manager_maintenance']))))), 'members' => array('title' => $txt['admin_manage_members'], 'permission' => array('moderate_forum', 'manage_membergroups', 'manage_bans', 'manage_permissions', 'admin_forum'), 'areas' => array('viewmembers' => array('label' => $txt['admin_users'], 'file' => 'ManageMembers.php', 'function' => 'ViewMembers', 'icon' => 'members.gif', 'permission' => array('moderate_forum'), 'subsections' => array('all' => array($txt['view_all_members']), 'search' => array($txt['mlist_search']))), 'membergroups' => array('label' => $txt['admin_groups'], 'file' => 'ManageMembergroups.php', 'function' => 'ModifyMembergroups', 'icon' => 'membergroups.gif', 'permission' => array('manage_membergroups'), 'subsections' => array('index' => array($txt['membergroups_edit_groups'], 'manage_membergroups'), 'add' => array($txt['membergroups_new_group'], 'manage_membergroups'), 'settings' => array($txt['settings'], 'admin_forum'))), 'permissions' => array('label' => $txt['edit_permissions'], 'file' => 'ManagePermissions.php', 'function' => 'ModifyPermissions', 'icon' => 'permissions.gif', 'permission' => array('manage_permissions'), 'subsections' => array('index' => array($txt['permissions_groups'], 'manage_permissions'), 'board' => array($txt['permissions_boards'], 'manage_permissions'), 'profiles' => array($txt['permissions_profiles'], 'manage_permissions'), 'postmod' => array($txt['permissions_post_moderation'], 'manage_permissions', 'enabled' => $modSettings['postmod_active']), 'settings' => array($txt['settings'], 'admin_forum'))), 'regcenter' => array('label' => $txt['registration_center'], 'file' => 'ManageRegistration.php', 'function' => 'RegCenter', 'icon' => 'regcenter.gif', 'permission' => array('admin_forum', 'moderate_forum'), 'subsections' => array('register' => array($txt['admin_browse_register_new'], 'moderate_forum'), 'agreement' => array($txt['registration_agreement'], 'admin_forum'), 'reservednames' => array($txt['admin_reserved_set'], 'admin_forum'), 'settings' => array($txt['settings'], 'admin_forum'))), 'ban' => array('label' => $txt['ban_title'], 'file' => 'ManageBans.php', 'function' => 'Ban', 'icon' => 'ban.gif', 'permission' => 'manage_bans', 'subsections' => array('list' => array($txt['ban_edit_list']), 'add' => array($txt['ban_add_new']), 'browse' => array($txt['ban_trigger_browse']), 'log' => array($txt['ban_log']))), 'paidsubscribe' => array('label' => $txt['paid_subscriptions'], 'enabled' => in_array('ps', $context['admin_features']), 'file' => 'ManagePaid.php', 'icon' => 'paid.gif', 'function' => 'ManagePaidSubscriptions', 'permission' => 'admin_forum', 'subsections' => array('view' => array($txt['paid_subs_view']), 'settings' => array($txt['settings']))), 'sengines' => array('label' => $txt['search_engines'], 'enabled' => in_array('sp', $context['admin_features']), 'file' => 'ManageSearchEngines.php', 'icon' => 'engines.gif', 'function' => 'SearchEngines', 'permission' => 'admin_forum', 'subsections' => array('stats' => array($txt['spider_stats']), 'logs' => array($txt['spider_logs']), 'spiders' => array($txt['spiders']), 'settings' => array($txt['settings']))))), 'maintenance' => array('title' => $txt['admin_maintenance'], 'permission' => array('admin_forum'), 'areas' => array('maintain' => array('label' => $txt['maintain_title'], 'file' => 'ManageMaintenance.php', 'icon' => 'maintain.gif', 'function' => 'ManageMaintenance', 'subsections' => array('routine' => array($txt['maintain_sub_routine'], 'admin_forum'), 'database' => array($txt['maintain_sub_database'], 'admin_forum'), 'members' => array($txt['maintain_sub_members'], 'admin_forum'), 'topics' => array($txt['maintain_sub_topics'], 'admin_forum'))), 'scheduledtasks' => array('label' => $txt['maintain_tasks'], 'file' => 'ManageScheduledTasks.php', 'icon' => 'scheduled.gif', 'function' => 'ManageScheduledTasks', 'subsections' => array('tasks' => array($txt['maintain_tasks'], 'admin_forum'), 'tasklog' => array($txt['scheduled_log'], 'admin_forum'))), 'mailqueue' => array('label' => $txt['mailqueue_title'], 'file' => 'ManageMail.php', 'function' => 'ManageMail', 'icon' => 'mail.gif', 'subsections' => array('browse' => array($txt['mailqueue_browse'], 'admin_forum'), 'settings' => array($txt['mailqueue_settings'], 'admin_forum'))), 'reports' => array('enabled' => in_array('rg', $context['admin_features']), 'label' => $txt['generate_reports'], 'file' => 'Reports.php', 'function' => 'ReportsMain', 'icon' => 'reports.gif'), 'logs' => array('label' => $txt['logs'], 'function' => 'AdminLogs', 'icon' => 'logs.gif', 'subsections' => array('errorlog' => array($txt['errlog'], 'admin_forum', 'enabled' => !empty($modSettings['enableErrorLogging']), 'url' => $scripturl . '?action=admin;area=logs;sa=errorlog;desc'), 'adminlog' => array($txt['admin_log'], 'admin_forum', 'enabled' => in_array('ml', $context['admin_features'])), 'modlog' => array($txt['moderation_log'], 'admin_forum', 'enabled' => in_array('ml', $context['admin_features'])), 'banlog' => array($txt['ban_log'], 'manage_bans'), 'spiderlog' => array($txt['spider_logs'], 'admin_forum', 'enabled' => in_array('sp', $context['admin_features'])), 'tasklog' => array($txt['scheduled_log'], 'admin_forum'), 'pruning' => array($txt['pruning_title'], 'admin_forum'))), 'repairboards' => array('label' => $txt['admin_repair'], 'file' => 'RepairBoards.php', 'function' => 'RepairBoards', 'select' => 'maintain', 'hidden' => true))));
    // Any files to include for administration?
    if (!empty($modSettings['integrate_admin_include'])) {
        $admin_includes = explode(',', $modSettings['integrate_admin_include']);
        foreach ($admin_includes as $include) {
            $include = strtr(trim($include), array('$boarddir' => $boarddir, '$sourcedir' => $sourcedir, '$themedir' => $settings['theme_dir']));
            if (file_exists($include)) {
                require_once $include;
            }
        }
    }
    // Let them modify admin areas easily.
    call_integration_hook('integrate_admin_areas', array(&$admin_areas));
    // Make sure the administrator has a valid session...
    validateSession();
    // Actually create the menu!
    $admin_include_data = createMenu($admin_areas);
    unset($admin_areas);
    // Nothing valid?
    if ($admin_include_data == false) {
        fatal_lang_error('no_access', false);
    }
    // Build the link tree.
    $context['linktree'][] = array('url' => $scripturl . '?action=admin', 'name' => $txt['admin_center']);
    if (isset($admin_include_data['current_area']) && $admin_include_data['current_area'] != 'index') {
        $context['linktree'][] = array('url' => $scripturl . '?action=admin;area=' . $admin_include_data['current_area'] . ';' . $context['session_var'] . '=' . $context['session_id'], 'name' => $admin_include_data['label']);
    }
    if (!empty($admin_include_data['current_subsection']) && $admin_include_data['subsections'][$admin_include_data['current_subsection']][0] != $admin_include_data['label']) {
        $context['linktree'][] = array('url' => $scripturl . '?action=admin;area=' . $admin_include_data['current_area'] . ';sa=' . $admin_include_data['current_subsection'] . ';' . $context['session_var'] . '=' . $context['session_id'], 'name' => $admin_include_data['subsections'][$admin_include_data['current_subsection']][0]);
    }
    // Make a note of the Unique ID for this menu.
    $context['admin_menu_id'] = $context['max_menu_id'];
    $context['admin_menu_name'] = 'menu_data_' . $context['admin_menu_id'];
    // Why on the admin are we?
    $context['admin_area'] = $admin_include_data['current_area'];
    // Now - finally - call the right place!
    if (isset($admin_include_data['file'])) {
        require_once $sourcedir . '/' . $admin_include_data['file'];
    }
    $admin_include_data['function']();
}
Пример #10
0
 public function __construct()
 {
     // Commented only for testing purposes
     //require_once(SUBSDIR . '/Attachments.subs.php');
     $empty_tags = $this->empty_tags;
     $closable_tags = $this->closable_tags;
     call_integration_hook('integrate_html_parser_load', array(&$empty_tags, &$closable_tags));
     $this->empty_tags = $empty_tags;
     $this->closable_tags = $closable_tags;
 }
Пример #11
0
function XMLhttpMain()
{
    loadTemplate('Xml');
    $sub_actions = array('jumpto' => array('function' => 'GetJumpTo'), 'messageicons' => array('function' => 'ListMessageIcons'), 'corefeatures' => array('function' => 'EnableCoreFeatures'), 'previews' => array('function' => 'RetrievePreview'));
    // Easy adding of sub actions
    call_integration_hook('integrate_xmlhttp', array(&$sub_actions));
    if (!isset($_REQUEST['sa'], $sub_actions[$_REQUEST['sa']])) {
        fatal_lang_error('no_access', false);
    }
    $sub_actions[$_REQUEST['sa']]['function']();
}
Пример #12
0
/**
 * Ban center. The main entrance point for all ban center functions.
 * It is accesssed by ?action=admin;area=ban.
 * It choses a function based on the 'sa' parameter, like many others.
 * The default sub-action is BanList().
 * It requires the ban_members permission.
 * It initializes the admin tabs.
 *
 * @uses ManageBans template.
 */
function Ban()
{
    global $context, $txt, $scripturl;
    isAllowedTo('manage_bans');
    loadTemplate('ManageBans');
    $subActions = array('add' => 'BanEdit', 'browse' => 'BanBrowseTriggers', 'edittrigger' => 'BanEditTrigger', 'edit' => 'BanEdit', 'list' => 'BanList', 'log' => 'BanLog');
    call_integration_hook('integrate_manage_bans', array(&$subActions));
    // Default the sub-action to 'view ban list'.
    $_REQUEST['sa'] = isset($_REQUEST['sa']) && isset($subActions[$_REQUEST['sa']]) ? $_REQUEST['sa'] : 'list';
    $context['page_title'] = $txt['ban_title'];
    $context['sub_action'] = $_REQUEST['sa'];
    // Tabs for browsing the different ban functions.
    $context[$context['admin_menu_name']]['tab_data'] = array('title' => $txt['ban_title'], 'help' => 'ban_members', 'description' => $txt['ban_description'], 'tabs' => array('list' => array('description' => $txt['ban_description'], 'href' => $scripturl . '?action=admin;area=ban;sa=list', 'is_selected' => $_REQUEST['sa'] == 'list' || $_REQUEST['sa'] == 'edit' || $_REQUEST['sa'] == 'edittrigger'), 'add' => array('description' => $txt['ban_description'], 'href' => $scripturl . '?action=admin;area=ban;sa=add', 'is_selected' => $_REQUEST['sa'] == 'add'), 'browse' => array('description' => $txt['ban_trigger_browse_description'], 'href' => $scripturl . '?action=admin;area=ban;sa=browse', 'is_selected' => $_REQUEST['sa'] == 'browse'), 'log' => array('description' => $txt['ban_log_description'], 'href' => $scripturl . '?action=admin;area=ban;sa=log', 'is_selected' => $_REQUEST['sa'] == 'log', 'is_last' => true)));
    // Call the right function for this sub-acton.
    $subActions[$_REQUEST['sa']]();
}
Пример #13
0
/**
 * Shows a listing of registered members.
 * - If a subaction is not specified, lists all registered members.
 * - It allows searching for members with the 'search' sub action.
 * - It calls MLAll or MLSearch depending on the sub action.
 * - Requires the view_mlist permission.
 * - Accessed via ?action=mlist.
 *
 * @uses Memberlist template, main sub template.
 */
function Memberlist()
{
    global $scripturl, $txt, $modSettings, $context, $settings, $modSettings;
    // Make sure they can view the memberlist.
    isAllowedTo('view_mlist');
    loadTemplate('Memberlist');
    $context['listing_by'] = !empty($_GET['sa']) ? $_GET['sa'] : 'all';
    // $subActions array format:
    // 'subaction' => array('label', 'function', 'is_selected')
    $subActions = array('all' => array($txt['view_all_members'], 'MLAll', $context['listing_by'] == 'all'), 'search' => array($txt['mlist_search'], 'MLSearch', $context['listing_by'] == 'search'));
    // Set up the sort links.
    $context['sort_links'] = array();
    foreach ($subActions as $act => $text) {
        $context['sort_links'][] = array('label' => $text[0], 'action' => $act, 'selected' => $text[2]);
    }
    $context['num_members'] = $modSettings['totalMembers'];
    // Set up the columns...
    $context['columns'] = array('is_online' => array('label' => $txt['status'], 'width' => 60, 'class' => 'first_th', 'sort' => array('down' => allowedTo('moderate_forum') ? 'IFNULL(lo.log_time, 1) ASC, real_name ASC' : 'CASE WHEN mem.show_online THEN IFNULL(lo.log_time, 1) ELSE 1 END ASC, real_name ASC', 'up' => allowedTo('moderate_forum') ? 'IFNULL(lo.log_time, 1) DESC, real_name DESC' : 'CASE WHEN mem.show_online THEN IFNULL(lo.log_time, 1) ELSE 1 END DESC, real_name DESC')), 'real_name' => array('label' => $txt['username'], 'sort' => array('down' => 'mem.real_name DESC', 'up' => 'mem.real_name ASC')), 'email_address' => array('label' => $txt['email'], 'width' => 25, 'sort' => array('down' => allowedTo('moderate_forum') ? 'mem.email_address DESC' : 'mem.hide_email DESC, mem.email_address DESC', 'up' => allowedTo('moderate_forum') ? 'mem.email_address ASC' : 'mem.hide_email ASC, mem.email_address ASC')), 'website_url' => array('label' => $txt['website'], 'width' => 70, 'link_with' => 'website', 'sort' => array('down' => 'LENGTH(mem.website_url) > 0 ASC, IFNULL(mem.website_url, 1=1) DESC, mem.website_url DESC', 'up' => 'LENGTH(mem.website_url) > 0 DESC, IFNULL(mem.website_url, 1=1) ASC, mem.website_url ASC')), 'icq' => array('label' => $txt['icq'], 'width' => 30, 'sort' => array('down' => 'LENGTH(mem.icq) > 0 ASC, mem.icq = 0 DESC, mem.icq DESC', 'up' => 'LENGTH(mem.icq) > 0 DESC, mem.icq = 0 ASC, mem.icq ASC')), 'aim' => array('label' => $txt['aim'], 'width' => 30, 'sort' => array('down' => 'LENGTH(mem.aim) > 0 ASC, IFNULL(mem.aim, 1=1) DESC, mem.aim DESC', 'up' => 'LENGTH(mem.aim) > 0 DESC, IFNULL(mem.aim, 1=1) ASC, mem.aim ASC')), 'yim' => array('label' => $txt['yim'], 'width' => 30, 'sort' => array('down' => 'LENGTH(mem.yim) > 0 ASC, IFNULL(mem.yim, 1=1) DESC, mem.yim DESC', 'up' => 'LENGTH(mem.yim) > 0 DESC, IFNULL(mem.yim, 1=1) ASC, mem.yim ASC')), 'msn' => array('label' => $txt['msn'], 'width' => 30, 'sort' => array('down' => 'LENGTH(mem.msn) > 0 ASC, IFNULL(mem.msn, 1=1) DESC, mem.msn DESC', 'up' => 'LENGTH(mem.msn) > 0 DESC, IFNULL(mem.msn, 1=1) ASC, mem.msn ASC')), 'id_group' => array('label' => $txt['position'], 'sort' => array('down' => 'IFNULL(mg.group_name, 1=1) DESC, mg.group_name DESC', 'up' => 'IFNULL(mg.group_name, 1=1) ASC, mg.group_name ASC')), 'registered' => array('label' => $txt['date_registered'], 'sort' => array('down' => 'mem.date_registered DESC', 'up' => 'mem.date_registered ASC')), 'posts' => array('label' => $txt['posts'], 'width' => 115, 'colspan' => 2, 'default_sort_rev' => true, 'sort' => array('down' => 'mem.posts DESC', 'up' => 'mem.posts ASC')));
    $context['colspan'] = 0;
    $context['disabled_fields'] = isset($modSettings['disabled_profile_fields']) ? array_flip(explode(',', $modSettings['disabled_profile_fields'])) : array();
    foreach ($context['columns'] as $key => $column) {
        if (isset($context['disabled_fields'][$key]) || isset($column['link_with']) && isset($context['disabled_fields'][$column['link_with']])) {
            unset($context['columns'][$key]);
            continue;
        }
        $context['colspan'] += isset($column['colspan']) ? $column['colspan'] : 1;
    }
    // Aesthetic stuff.
    end($context['columns']);
    $context['columns'][key($context['columns'])]['class'] = 'last_th';
    $context['linktree'][] = array('url' => $scripturl . '?action=mlist', 'name' => $txt['members_list']);
    $context['can_send_pm'] = allowedTo('pm_send');
    $context['can_send_email'] = allowedTo('send_email_to_members');
    // Build the memberlist button array.
    $context['memberlist_buttons'] = array('view_all_members' => array('text' => 'view_all_members', 'image' => 'mlist.png', 'lang' => true, 'url' => $scripturl . '?action=mlist' . ';sa=all', 'active' => true), 'mlist_search' => array('text' => 'mlist_search', 'image' => 'mlist.png', 'lang' => true, 'url' => $scripturl . '?action=mlist' . ';sa=search'));
    // Allow mods to add additional buttons here
    call_integration_hook('integrate_memberlist_buttons');
    // Jump to the sub action.
    if (isset($subActions[$context['listing_by']])) {
        $subActions[$context['listing_by']][1]();
    } else {
        $subActions['all'][1]();
    }
}
Пример #14
0
/**
 * Handling function for generating reports.
 * Requires the admin_forum permission.
 * Loads the Reports template and language files.
 * Decides which type of report to generate, if this isn't passed
 * through the querystring it will set the report_type sub-template to
 * force the user to choose which type.
 * When generating a report chooses which sub_template to use.
 * Depends on the cal_enabled setting, and many of the other cal_
 * settings.
 * Will call the relevant report generation function.
 * If generating report will call finishTables before returning.
 * Accessed through ?action=admin;area=reports.
 */
function ReportsMain()
{
    global $txt, $modSettings, $context, $scripturl;
    // Only admins, only EVER admins!
    isAllowedTo('admin_forum');
    // Let's get our things running...
    loadTemplate('Reports');
    loadLanguage('Reports');
    $context['page_title'] = $txt['generate_reports'];
    // These are the types of reports which exist - and the functions to generate them.
    $context['report_types'] = array('boards' => 'BoardReport', 'board_perms' => 'BoardPermissionsReport', 'member_groups' => 'MemberGroupsReport', 'group_perms' => 'GroupPermissionsReport', 'staff' => 'StaffReport');
    call_integration_hook('integrate_report_types');
    $is_first = 0;
    foreach ($context['report_types'] as $k => $temp) {
        $context['report_types'][$k] = array('id' => $k, 'title' => isset($txt['gr_type_' . $k]) ? $txt['gr_type_' . $k] : $type['id'], 'description' => isset($txt['gr_type_desc_' . $k]) ? $txt['gr_type_desc_' . $k] : null, 'function' => $temp, 'is_first' => $is_first++ == 0);
    }
    // If they haven't choosen a report type which is valid, send them off to the report type chooser!
    if (empty($_REQUEST['rt']) || !isset($context['report_types'][$_REQUEST['rt']])) {
        $context['sub_template'] = 'report_type';
        return;
    }
    $context['report_type'] = $_REQUEST['rt'];
    // What are valid templates for showing reports?
    $reportTemplates = array('main' => array('layers' => null), 'print' => array('layers' => array('print')));
    // Specific template? Use that instead of main!
    if (isset($_REQUEST['st']) && isset($reportTemplates[$_REQUEST['st']])) {
        $context['sub_template'] = $_REQUEST['st'];
        // Are we disabling the other layers - print friendly for example?
        if ($reportTemplates[$_REQUEST['st']]['layers'] !== null) {
            $context['template_layers'] = $reportTemplates[$_REQUEST['st']]['layers'];
        }
    }
    // Make the page title more descriptive.
    $context['page_title'] .= ' - ' . (isset($txt['gr_type_' . $context['report_type']]) ? $txt['gr_type_' . $context['report_type']] : $context['report_type']);
    // Build the reports button array.
    $context['report_buttons'] = array('generate_reports' => array('text' => 'generate_reports', 'image' => 'print.png', 'lang' => true, 'url' => $scripturl . '?action=admin;area=reports', 'active' => true), 'print' => array('text' => 'print', 'image' => 'print.png', 'lang' => true, 'url' => $scripturl . '?action=admin;area=reports;rt=' . $context['report_type'] . ';st=print', 'custom' => 'target="_blank"'));
    // Allow mods to add additional buttons here
    call_integration_hook('integrate_report_buttons');
    // Now generate the data.
    $context['report_types'][$context['report_type']]['function']();
    // Finish the tables before exiting - this is to help the templates a little more.
    finishTables();
}
Пример #15
0
 /**
  * Show boxes with more detailed help on items, when the user clicks on their help icon.
  * It handles both administrative or user help.
  * Data: $_GET['help'] parameter, it holds what string to display
  * and where to get the string from. ($helptxt or $txt)
  * It is accessed via ?action=quickhelp;help=?.
  *
  * @uses ManagePermissions language file, if the help starts with permissionhelp.
  * @uses Help template, 'popup' sub-template.
  */
 public function action_quickhelp()
 {
     global $txt, $helptxt, $context, $scripturl;
     if (!isset($_GET['help']) || !is_string($_GET['help'])) {
         fatal_lang_error('no_access', false);
     }
     if (!isset($helptxt)) {
         $helptxt = array();
     }
     $help_str = Util::htmlspecialchars($_GET['help']);
     // Load the admin help language file and template.
     loadLanguage('Help');
     // Load permission specific help
     if (substr($help_str, 0, 14) == 'permissionhelp') {
         loadLanguage('ManagePermissions');
     }
     // Load our template
     loadTemplate('Help');
     // Allow addons to load their own language file here.
     call_integration_hook('integrate_quickhelp');
     // Set the page title to something relevant.
     $context['page_title'] = $context['forum_name'] . ' - ' . $txt['help'];
     // Only show the 'popup' sub-template, no layers.
     Template_Layers::getInstance()->removeAll();
     $context['sub_template'] = 'popup';
     $helps = explode('+', $help_str);
     $context['help_text'] = '';
     // Find what to display: the string will be in $helptxt['help'] or in $txt['help]
     foreach ($helps as $help) {
         if (isset($helptxt[$help])) {
             $context['help_text'] .= $helptxt[$help];
         } elseif (isset($txt[$help])) {
             $context['help_text'] .= $txt[$help];
         } else {
             // nothing :(
             $context['help_text'] .= $help;
         }
     }
     // Link to the forum URL, and include session id.
     if (preg_match('~%([0-9]+\\$)?s\\?~', $context['help_text'], $match)) {
         $context['help_text'] = sprintf($context['help_text'], $scripturl, $context['session_id'], $context['session_var']);
     }
 }
Пример #16
0
/**
 * Scheduled tasks management dispatcher. This function checks permissions and delegates
 * to the appropriate function based on the sub-action.
 * Everything here requires adin_forum permission.
 *
 * @uses ManageScheduledTasks template file
 * @uses ManageScheduledTasks language file
 */
function ManageScheduledTasks()
{
    global $context, $txt, $modSettings;
    isAllowedTo('admin_forum');
    loadLanguage('ManageScheduledTasks');
    loadTemplate('ManageScheduledTasks');
    $subActions = array('taskedit' => 'EditTask', 'tasklog' => 'TaskLog', 'tasks' => 'ScheduledTasks');
    call_integration_hook('integrate_manage_scheduled_tasks', array(&$subActions));
    // We need to find what's the action.
    if (isset($_REQUEST['sa']) && isset($subActions[$_REQUEST['sa']])) {
        $context['sub_action'] = $_REQUEST['sa'];
    } else {
        $context['sub_action'] = 'tasks';
    }
    // Now for the lovely tabs. That we all love.
    $context[$context['admin_menu_name']]['tab_data'] = array('title' => $txt['scheduled_tasks_title'], 'help' => '', 'description' => $txt['maintain_info'], 'tabs' => array('tasks' => array('description' => $txt['maintain_tasks_desc']), 'tasklog' => array('description' => $txt['scheduled_log_desc'])));
    // Call it.
    $subActions[$context['sub_action']]();
}
Пример #17
0
 /**
  * Ban center. The main entrance point for all ban center functions.
  *
  * What it does:
  * - It is accesssed by ?action=admin;area=ban.
  * - It choses a function based on the 'sa' parameter, like many others.
  * - The default sub-action is action_list().
  * - It requires the ban_members permission.
  * - It initializes the admin tabs.
  *
  * @uses ManageBans template.
  */
 public function action_index()
 {
     global $context, $txt, $scripturl;
     loadTemplate('ManageBans');
     require_once SUBSDIR . '/Bans.subs.php';
     $subActions = array('add' => array($this, 'action_edit', 'permission' => 'manage_bans'), 'browse' => array($this, 'action_browse', 'permission' => 'manage_bans'), 'edittrigger' => array($this, 'action_edittrigger', 'permission' => 'manage_bans'), 'edit' => array($this, 'action_edit', 'permission' => 'manage_bans'), 'list' => array($this, 'action_list', 'permission' => 'manage_bans'), 'log' => array($this, 'action_log', 'permission' => 'manage_bans'));
     // Start up the controller
     $action = new Action();
     // Default the sub-action to 'view ban list'.
     $subAction = isset($_REQUEST['sa']) && isset($subActions[$_REQUEST['sa']]) ? $_REQUEST['sa'] : 'list';
     // Tabs for browsing the different ban functions.
     $context[$context['admin_menu_name']]['tab_data'] = array('title' => $txt['ban_title'], 'help' => 'ban_members', 'description' => $txt['ban_description'], 'tabs' => array('list' => array('description' => $txt['ban_description'], 'href' => $scripturl . '?action=admin;area=ban;sa=list', 'is_selected' => $subAction == 'list' || $subAction == 'edit' || $subAction == 'edittrigger'), 'add' => array('description' => $txt['ban_description'], 'href' => $scripturl . '?action=admin;area=ban;sa=add', 'is_selected' => $subAction == 'add'), 'browse' => array('description' => $txt['ban_trigger_browse_description'], 'href' => $scripturl . '?action=admin;area=ban;sa=browse', 'is_selected' => $subAction == 'browse'), 'log' => array('description' => $txt['ban_log_description'], 'href' => $scripturl . '?action=admin;area=ban;sa=log', 'is_selected' => $subAction == 'log', 'is_last' => true)));
     // Make the call to integrate-manage_bans
     call_integration_hook('integrate_manage_bans', array(&$subActions));
     // Prepare some items for the template
     $context['page_title'] = $txt['ban_title'];
     $context['sub_action'] = $subAction;
     // Call the right function for this sub-action.
     $action->initialize($subActions, 'list');
     $action->dispatch($subAction);
 }
Пример #18
0
function shd_profile_main($memID)
{
    global $context, $txt, $scripturl, $sourcedir, $user_info, $settings, $user_profile, $modSettings;
    // Load the profile details
    loadTemplate('sd_template/SimpleDesk-Profile', array('helpdesk', 'helpdesk_admin'));
    shd_load_language('sd_language/SimpleDeskProfile');
    $context['shd_preferences'] = shd_load_user_prefs();
    shd_load_plugin_files('hdprofile');
    shd_load_plugin_langfiles('hdprofile');
    $context['page_title'] = $txt['shd_profile_area'] . ' - ' . $txt['shd_profile_main'];
    $context['sub_template'] = 'shd_profile_main';
    $subActions = array('helpdesk' => 'shd_profile_frontpage', 'hd_prefs' => 'shd_profile_preferences', 'hd_showtickets' => 'shd_profile_show_tickets', 'hd_permissions' => 'shd_profile_permissions', 'hd_actionlog' => 'shd_profile_actionlog');
    $context['shd_profile_menu'] = array(array('image' => 'user.png', 'link' => $scripturl . '?action=profile;u=' . $context['member']['id'] . ';area=helpdesk', 'text' => $txt['shd_profile_home'], 'show' => true), array('image' => 'preferences.png', 'link' => $scripturl . '?action=profile;u=' . $context['member']['id'] . ';area=hd_prefs', 'text' => $txt['shd_profile_preferences'], 'show' => true), array('image' => 'ticket.png', 'link' => $scripturl . '?action=profile;u=' . $context['member']['id'] . ';area=hd_showtickets', 'text' => $txt['shd_profile_show_tickets'], 'show' => true), array('image' => 'permissions.png', 'link' => $scripturl . '?action=profile;u=' . $context['member']['id'] . ';area=hd_permissions', 'text' => $txt['shd_profile_permissions'], 'show' => !empty($context['helpdesk_menu']['areas']['hd_permissions']['enabled'])), array('image' => 'log.png', 'link' => $scripturl . '?action=profile;u=' . $context['member']['id'] . ';area=hd_actionlog', 'text' => $txt['shd_profile_actionlog'], 'show' => !empty($context['helpdesk_menu']['areas']['hd_actionlog']['enabled'])), array('image' => 'go_to_helpdesk.png', 'link' => $scripturl . '?action=helpdesk;sa=main', 'text' => $txt['shd_profile_go_to_helpdesk'], 'show' => true));
    // Int hooks - after we basically set everything up (so it's manipulatable by the hook, but before we do the last bits of finalisation)
    call_integration_hook('shd_hook_hdprofile', array(&$subActions, &$memID));
    // Make sure the menu is configured appropriately
    $context['shd_profile_menu'][count($context['shd_profile_menu']) - 1]['is_last'] = true;
    $_REQUEST['area'] = isset($_REQUEST['area']) && isset($subActions[$_REQUEST['area']]) ? $_REQUEST['area'] : 'helpdesk';
    $context['sub_action'] = $_REQUEST['area'];
    $subActions[$_REQUEST['area']]($memID);
    // Maintenance mode? If it were, the helpdesk is considered inactive for the purposes of everything to all but those without admin-helpdesk rights - but we must have them if we're here!
    if (!empty($modSettings['shd_maintenance_mode'])) {
        loadTemplate('sd_template/SimpleDesk');
        $temp_layers = $context['template_layers'];
        $context['template_layers'] = array();
        $added = false;
        foreach ($temp_layers as $layer) {
            $context['template_layers'][] = $layer;
            if ($layer == 'body') {
                $context['template_layers'][] = 'shd_maintenance';
                $added = true;
            }
        }
        // Well, we tried to add it as near the top as possible, but not all themes use the standard body layer.
        if (!$added) {
            $context['template_layers'][] = 'shd_maintenance';
        }
    }
    $context['template_layers'][] = 'shd_profile_navigation';
}
Пример #19
0
 /**
  * Allow to edit the settings on the pruning screen.
  *
  * Uses the _pruningSettings form.
  */
 public function action_pruningSettings_display()
 {
     global $txt, $scripturl, $context, $modSettings;
     // Make sure we understand what's going on.
     loadLanguage('ManageSettings');
     $context['page_title'] = $txt['pruning_title'];
     $config_vars = $this->_pruningSettings->settings();
     call_integration_hook('integrate_prune_settings');
     // Saving?
     if (isset($_GET['save'])) {
         checkSession();
         $savevar = array(array('text', 'pruningOptions'));
         if (!empty($_POST['pruningOptions'])) {
             $vals = array();
             foreach ($config_vars as $index => $dummy) {
                 if (!is_array($dummy) || $index == 'pruningOptions') {
                     continue;
                 }
                 $vals[] = empty($_POST[$dummy[1]]) || $_POST[$dummy[1]] < 0 ? 0 : (int) $_POST[$dummy[1]];
             }
             $_POST['pruningOptions'] = implode(',', $vals);
         } else {
             $_POST['pruningOptions'] = '';
         }
         Settings_Form::save_db($savevar);
         redirectexit('action=admin;area=logs;sa=pruning');
     }
     $context['post_url'] = $scripturl . '?action=admin;area=logs;save;sa=pruning';
     $context['settings_title'] = $txt['pruning_title'];
     $context['sub_template'] = 'show_settings';
     // Get the actual values
     if (!empty($modSettings['pruningOptions'])) {
         @(list($modSettings['pruneErrorLog'], $modSettings['pruneModLog'], $modSettings['pruneBanLog'], $modSettings['pruneReportLog'], $modSettings['pruneScheduledTaskLog'], $modSettings['pruneBadbehaviorLog'], $modSettings['pruneSpiderHitLog']) = explode(',', $modSettings['pruningOptions']));
     } else {
         $modSettings['pruneErrorLog'] = $modSettings['pruneModLog'] = $modSettings['pruneBanLog'] = $modSettings['pruneReportLog'] = $modSettings['pruneScheduledTaskLog'] = $modSettings['pruneBadbehaviorLog'] = $modSettings['pruneSpiderHitLog'] = 0;
     }
     Settings_Form::prepare_db($config_vars);
 }
Пример #20
0
function AdkModules()
{
    global $context, $txt, $settings, $boardurl, $adkFolder;
    isAllowedTo('adk_portal');
    adktemplate('Adk-AdminModules');
    adkLanguage('Adk-AdminModules');
    $subActions = array('intro' => 'introAdk', 'viewadminpages' => 'viewadminpages', 'createpages' => 'createpages', 'savecreatedpages' => 'savecreatedpages', 'editpages' => 'editpages', 'saveeditpages' => 'saveeditpages', 'deletepages' => 'deletepages', 'uploadanyimage' => 'UploadNewImage', 'saveuploadimg' => 'SaveUploadNewImage', 'manageimagesadk' => 'ManageImagesAdk', 'deleteimagesadk' => 'DeleteImagesAdk', 'contact' => 'ContactAdmin', 'save_contact' => 'SaveContactAdmin', 'enable_page_menu' => 'EnablePageMenu', 'enable_comments' => 'EnableComments', 'enable_notifications' => 'EnableNotifications');
    $context[$context['admin_menu_name']]['tab_data'] = array('title' => $txt['adkmodules_modules_settings'], 'description' => $txt['adkmodules_first_modules'], 'tabs' => array('intro' => array('description' => $txt['adkmodules_first_modules'], 'label' => '<img style="vertical-align: middle;" alt="" src="' . $settings['default_theme_url'] . '/images/admin/intro.png" /> ' . $txt['adkmod_modules_intro']), 'viewadminpages' => array('description' => $txt['adkmodules_second_modules'], 'label' => '<img style="vertical-align: middle;" alt="" src="' . $settings['default_theme_url'] . '/images/admin/pages.png" /> ' . $txt['adkmod_modules_pages']), 'contact' => array('description' => $txt['adkmodules_desc_contacto'], 'label' => '<img style="vertical-align: middle;" alt="" src="' . $adkFolder['images'] . '/newmsg.png" /> ' . $txt['adkmod_modules_contacto']), 'uploadanyimage' => array('description' => $txt['adkmodules_tirth_modules'], 'label' => '<img style="vertical-align: middle;" alt="" src="' . $settings['default_theme_url'] . '/images/admin/imagesadvanced.png" /> ' . $txt['adkmod_modules_images']), 'manageimagesadk' => array('description' => $txt['adkmodules_fourth_modules'], 'label' => '<img style="vertical-align: middle;" alt="" src="' . $settings['default_theme_url'] . '/images/admin/images.png" /> ' . $txt['adkmod_modules_manage_images'])));
    // Hooks menu integrations
    call_integration_hook('integrate_modules_menu', array(&$context[$context['admin_menu_name']]['tab_data']));
    // Hooks sa integration
    call_integration_hook('modules_subactions', array(&$subActions));
    //Hooks pre includes
    adkportal_include_hooks('integrate_pre_include_modules');
    $context['html_headers'] .= getCss('admin_adkportal');
    $context['html_headers'] .= getJs('admin');
    // Follow the sa or just go to View function
    if (!empty($_GET['sa']) && !empty($subActions[$_GET['sa']])) {
        $subActions[@$_GET['sa']]();
    } else {
        $subActions['intro']();
    }
}
Пример #21
0
/**
 * Show some of the more detailed help to give the admin an idea...
 * It shows a popup for administrative or user help.
 * It uses the help parameter to decide what string to display and where to get
 * the string from. ($helptxt or $txt?)
 * It is accessed via ?action=helpadmin;help=?.
 * @uses ManagePermissions language file, if the help starts with permissionhelp.
 * @uses Help template, popup sub template, no layers.
 */
function ShowAdminHelp()
{
    global $txt, $helptxt, $context, $scripturl;
    if (!isset($_GET['help']) || !is_string($_GET['help'])) {
        fatal_lang_error('no_access', false);
    }
    if (!isset($helptxt)) {
        $helptxt = array();
    }
    // Load the admin help language file and template.
    loadLanguage('Help');
    // Permission specific help?
    if (isset($_GET['help']) && substr($_GET['help'], 0, 14) == 'permissionhelp') {
        loadLanguage('ManagePermissions');
    }
    loadTemplate('Help');
    // Allow mods to load their own language file here
    call_integration_hook('integrate_helpadmin');
    // Set the page title to something relevant.
    $context['page_title'] = $context['forum_name'] . ' - ' . $txt['help'];
    // Don't show any template layers, just the popup sub template.
    $context['template_layers'] = array();
    $context['sub_template'] = 'popup';
    // What help string should be used?
    if (isset($helptxt[$_GET['help']])) {
        $context['help_text'] = $helptxt[$_GET['help']];
    } elseif (isset($txt[$_GET['help']])) {
        $context['help_text'] = $txt[$_GET['help']];
    } else {
        $context['help_text'] = $_GET['help'];
    }
    // Does this text contain a link that we should fill in?
    if (preg_match('~%([0-9]+\\$)?s\\?~', $context['help_text'], $match)) {
        $context['help_text'] = sprintf($context['help_text'], $scripturl, $context['session_id'], $context['session_var']);
    }
}
/**
 *	Updates a ticket's relationships.
 *
 *	This function is responsible for adding, updating and removing relationships.
 *
 *	Accessed through ?action=helpdesk;sa=relation;ticket=x;linkticket=y;relation=[linked|duplicated|parent|child|delete];sessvar=sessid and will redirect back to the ticket once complete.
 *
 *	@since 2.0
*/
function shd_ticket_relation()
{
    global $context, $smcFunc, $modSettings;
    checkSession('request');
    if (!empty($modSettings['shd_disable_relationships'])) {
        fatal_lang_error('shd_relationships_are_disabled', false);
    }
    $otherticket = isset($_REQUEST['otherticket']) ? (int) $_REQUEST['otherticket'] : 0;
    if (empty($context['ticket_id']) || empty($otherticket)) {
        fatal_lang_error('shd_no_ticket', false);
    }
    if ($context['ticket_id'] == $otherticket) {
        fatal_lang_error('shd_cannot_relate_self', false);
    }
    $actions = array('linked', 'duplicated', 'parent', 'child', 'delete');
    $rel_action = isset($_REQUEST['relation']) && in_array($_REQUEST['relation'], $actions) ? $_REQUEST['relation'] : '';
    if (empty($rel_action)) {
        fatal_lang_error('shd_invalid_relation', false);
    }
    // Quick/consistent way to ensure permissions are adhered to and that the ticket exists. Might as well get the subject while here too.
    $ticketinfo = shd_load_ticket($context['ticket_id']);
    $primary_subject = $ticketinfo['subject'];
    $dept = $ticketinfo['dept'];
    $ticketinfo = shd_load_ticket($otherticket);
    $secondary_subject = $ticketinfo['subject'];
    if ($rel_action == 'delete') {
        shd_is_allowed_to('shd_delete_relationships', $dept);
    } else {
        shd_is_allowed_to('shd_create_relationships', $dept);
    }
    // See if there's an existing relationship with these parameters
    $query = shd_db_query('', '
		SELECT rel_type
		FROM {db_prefix}helpdesk_relationships
		WHERE primary_ticket = {int:ticket}
			AND secondary_ticket = {int:otherticket}', array('ticket' => $context['ticket_id'], 'otherticket' => $otherticket));
    $new_relationship = $smcFunc['db_num_rows']($query) == 0;
    list($existing_relation) = $new_relationship ? array(-1) : $smcFunc['db_fetch_row']($query);
    $smcFunc['db_free_result']($query);
    if ($rel_action == 'delete' && $new_relationship) {
        fatal_lang_error('shd_no_relation_delete', false);
    }
    $log_prefix = 'rel_' . ($new_relationship || $rel_action == 'delete' ? '' : 're_');
    $log_map = array('delete' => 'delete', 'linked' => 'linked', 'duplicated' => 'duplicated', 'parent' => 'child', 'child' => 'parent');
    $log_assoc_ids = array('delete' => -1, 'linked' => RELATIONSHIP_LINKED, 'duplicated' => RELATIONSHIP_DUPLICATED, 'parent' => RELATIONSHIP_ISPARENT, 'child' => RELATIONSHIP_ISCHILD);
    $logaction_ticket = $log_prefix . $rel_action;
    $logaction_otherticket = $log_prefix . $log_map[$rel_action];
    // The "from" ticket is $context['ticket_id'], $otherticket is the ticket whose id the user gives, and $rel_action sets the relationship type.
    call_integration_hook('shd_hook_relations', array(&$rel_action, &$otherticket));
    if ($rel_action == 'delete') {
        // Delete the link
        shd_db_query('', '
			DELETE FROM {db_prefix}helpdesk_relationships
			WHERE (primary_ticket = {int:ticket} AND secondary_ticket = {int:otherticket})
				OR (primary_ticket = {int:otherticket} AND secondary_ticket = {int:ticket})', array('ticket' => $context['ticket_id'], 'otherticket' => $otherticket));
    } else {
        $smcFunc['db_insert']('replace', '{db_prefix}helpdesk_relationships', array('primary_ticket' => 'int', 'secondary_ticket' => 'int', 'rel_type' => 'int'), array(array($context['ticket_id'], $otherticket, $log_assoc_ids[$rel_action]), array($otherticket, $context['ticket_id'], $log_assoc_ids[$log_map[$rel_action]])), array('primary_ticket', 'secondary_ticket'));
    }
    // Now actually log it, main ticket first -- if it's different to the one we had before
    if ($log_assoc_ids[$rel_action] != $existing_relation) {
        $params = array('ticket' => $context['ticket_id'], 'otherticket' => $otherticket, 'subject' => $primary_subject, 'othersubject' => $secondary_subject);
        shd_log_action($logaction_ticket, $params);
        $params = array('ticket' => $otherticket, 'otherticket' => $context['ticket_id'], 'subject' => $secondary_subject, 'othersubject' => $primary_subject);
        shd_log_action($logaction_otherticket, $params);
    }
    // See yah
    redirectexit('action=helpdesk;sa=ticket;ticket=' . $context['ticket_id']);
}
Пример #23
0
/**
 *	Updates a ticket/reply item in the database.
 *
 *	This function allows modification of all post/ticket details - and can be used independently; it is possible (and even done
 *	in SimpleDesk) to update just a ticket or just a post from this function. All three parameters are by <b>reference</b>
 *	meaning they WILL be updated if things change. Note that this function is not validating that they are sensible values; it is
 *	up to the calling function to ascertain that.
 *
 *	@param array &$msgOptions - a hash array by reference, stating zero or more details to change on a message (if the change is strictly ticket-only, the entire $msgOptions array can be an empty array):
 *	<ul>
 *	<li>id: Required if changing a message; the principle numeric id of the message to modify</li>
 *	<li>body: Optional, the principle body content of the message to change; if omitted, no change will occur. If set, assumed to have been cleaned already (with $smcFunc['htmlspecialchars'] and preparsecode)</li>
 *	<li>modified: Optional, hash array containing items relating to modification (if 'modified' key exists, all of these should be set)
 *		<ul>
 *			<li>time: Unsigned int timestamp of the change</li>
 *			<li>name: String; user name of the user making the change</li>
 *			<li>id: Unsigned int user id of the user making the change</li>
 *		</ul>
 *	</li>
 *	<li>smileys_enabled: Optional, boolean denoting whether smileys should be active on this post; if omitted no change will occur</li>
 *	<li>attachments: Optional, array of attachment ids that need attaching to this message; if omitted no changes will occur</li>
 *	</ul>
 *
 *	@param array &$ticketOptions - a hash array by reference, stating one or more details necessary to change on a ticket:
 *	<ul>
 *	<li>id: Required in all cases, numeric ticket id that the edit relates to</li>
 *	<li>subject: Optional string with the new subject in; if omitted no change will occur. If set, assumed to have been cleaned already (with $smcFunc['htmlspecialchars'] and strtr)</li>
 *	<li>urgency: Optional integer with the new urgency in; if omitted no change will occur</li>
 *	<li>status: Optional integer with the new status in; if omitted no change will occur</li>
 *	<li>ssigned: Optional integer with the user id of assigned user; if omitted no change will occur (note, you would declare this as 0 to unassign a ticket - set to 0 is not omitted)</li>
 *	<li>private: Optional boolean as to privacy of ticket: true = private, false = not private (note, you still declare this to change it)</li>
 *	</ul>
 *
 *	@param array &$posterOptions - a hash array by reference of details to change on the poster of a message:
 *	<ul>
 *	<li>name: Optional string, name of credited poster (in absence of id, this will be used); if omitted no change will occur</li>
 *	<li>email: Optional string, email address of poster; if omitted no change will occur</li>
 *	</ul>
 *
 *	@return bool True on success, false on failure.
 *	@since 1.0
*/
function shd_modify_ticket_post(&$msgOptions, &$ticketOptions, &$posterOptions)
{
    global $user_info, $txt, $modSettings, $smcFunc, $context;
    $messages_columns = array();
    $ticket_columns = array();
    $ticketOptions['id'] = !empty($ticketOptions['id']) ? (int) $ticketOptions['id'] : 0;
    if ($ticketOptions['id'] == 0) {
        return false;
    }
    if (isset($posterOptions['name'])) {
        $messages_columns['poster_name'] = $posterOptions['name'];
    }
    if (isset($posterOptions['email'])) {
        $messages_columns['poster_email'] = $posterOptions['email'];
    }
    if (isset($msgOptions['body'])) {
        $messages_columns['body'] = $msgOptions['body'];
    }
    if (!empty($msgOptions['modified'])) {
        $messages_columns['modified_time'] = $msgOptions['modified']['time'];
        $messages_columns['modified_name'] = $msgOptions['modified']['name'];
        $messages_columns['modified_member'] = $msgOptions['modified']['id'];
    }
    if (isset($msgOptions['smileys_enabled'])) {
        $messages_columns['smileys_enabled'] = empty($msgOptions['smileys_enabled']) ? 0 : 1;
    }
    if (isset($ticketOptions['subject'])) {
        $ticket_columns['subject'] = $ticketOptions['subject'];
    }
    if (isset($ticketOptions['status'])) {
        $ticket_columns['status'] = $ticketOptions['status'];
    }
    if (isset($ticketOptions['urgency'])) {
        $ticket_columns['urgency'] = $ticketOptions['urgency'];
    }
    if (isset($ticketOptions['assigned'])) {
        $ticket_columns['id_member_assigned'] = $ticketOptions['assigned'];
    }
    if (isset($ticketOptions['private'])) {
        $ticket_columns['private'] = empty($ticketOptions['private']) ? 0 : 1;
    }
    // Fix the attachments.
    if (!empty($msgOptions['attachments'])) {
        $array = array();
        foreach ($msgOptions['attachments'] as $attach) {
            $array[] = array($attach, $msgOptions['id'], $ticketOptions['id']);
        }
        $smcFunc['db_insert']('replace', '{db_prefix}helpdesk_attachments', array('id_attach' => 'int', 'id_msg' => 'int', 'id_ticket' => 'int'), $array, array('id_attach'));
    }
    if (empty($messages_columns) && empty($ticket_columns) && empty($ticketOptions['custom_fields']) && empty($msgOptions['custom_fields'])) {
        return true;
    }
    // It's do or die time: forget any user aborts!
    $previous_ignore_user_abort = ignore_user_abort(true);
    // OK, let's get all this set up ready for SQL magic
    // Which columns need to be ints?
    $messageInts = array('modified_time', 'modified_member', 'smileys_enabled');
    $msg_update_parameters = array('id_msg' => empty($msgOptions['id']) ? 0 : (int) $msgOptions['id']);
    foreach ($messages_columns as $var => $val) {
        $messages_columns[$var] = $var . ' = {' . (in_array($var, $messageInts) ? 'int' : 'string') . ':var_' . $var . '}';
        $msg_update_parameters['var_' . $var] = $val;
    }
    $ticketInts = array('status', 'urgency');
    $ticket_update_parameters = array('id_ticket' => $ticketOptions['id']);
    foreach ($ticket_columns as $var => $val) {
        $ticket_columns[$var] = $var . ' = {' . (in_array($var, $ticketInts) ? 'int' : 'string') . ':var_' . $var . '}';
        $ticket_update_parameters['var_' . $var] = $val;
    }
    // GO GO GO! (message first)
    if (!empty($messages_columns)) {
        shd_db_query('', '
			UPDATE {db_prefix}helpdesk_ticket_replies
			SET ' . implode(', ', $messages_columns) . '
			WHERE id_msg = {int:id_msg}', $msg_update_parameters);
    }
    if (!empty($ticket_columns)) {
        shd_db_query('', '
			UPDATE {db_prefix}helpdesk_tickets
			SET ' . implode(', ', $ticket_columns) . '
			WHERE id_ticket = {int:id_ticket}', $ticket_update_parameters);
    }
    // And fix unread list
    if (!empty($msgOptions['modified'])) {
        shd_db_query('', '
			UPDATE {db_prefix}helpdesk_log_read
			SET id_msg = {int:last_msg}
			WHERE id_member != {int:modified_member}
				AND id_ticket = {int:ticket}
				AND id_msg >= {int:edited_msg}', array('last_msg' => $msg_update_parameters['id_msg'] - 1, 'modified_member' => $msgOptions['modified']['id'], 'ticket' => $ticketOptions['id'], 'edited_msg' => $msg_update_parameters['id_msg']));
    }
    // Are we updating custom fields?
    $rows = array();
    $context['custom_fields_updated'] = array();
    if (!empty($ticketOptions['custom_fields'])) {
        // Some may be pre-existing, some may need purging.
        foreach ($ticketOptions['custom_fields'] as $field_id => $field) {
            // No new value, or new value is the same as the old one.
            if (!isset($field['new_value']) || isset($field['value']) && $field['value'] == $field['new_value']) {
                continue;
            }
            // So we have a new value, or a changed value. If it's changed, but changed to default, mark it as default
            $rows[] = array('id_post' => $ticketOptions['id'], 'id_field' => $field_id, 'value' => $field['new_value'], 'post_type' => CFIELD_TICKET);
            if ($field['type'] == CFIELD_TYPE_MULTI) {
                $values = array();
                if (!empty($field['value'])) {
                    foreach ($field['value'] as $value) {
                        if (!empty($value)) {
                            $values[] = $field['options'][$value];
                        }
                    }
                }
                $oldvalue = implode(', ', $values);
                $values = array();
                $newvalues = explode(',', $field['new_value']);
                foreach ($newvalues as $value) {
                    if (!empty($value)) {
                        $values[] = $field['options'][$value];
                    }
                }
                $newvalue = implode(', ', $values);
            } else {
                $oldvalue = !empty($field['value']) && ($field['type'] == CFIELD_TYPE_RADIO || $field['type'] == CFIELD_TYPE_SELECT) ? $field['options'][$field['value']] : (empty($field['value']) ? '' : $field['value']);
                $newvalue = !empty($field['new_value']) && ($field['type'] == CFIELD_TYPE_RADIO || $field['type'] == CFIELD_TYPE_SELECT) ? $field['options'][$field['new_value']] : $field['new_value'];
            }
            $context['custom_fields_updated'][] = array('ticket' => $ticketOptions['id'], 'fieldname' => $field['name'], 'oldvalue' => $oldvalue, 'newvalue' => $newvalue, 'scope' => CFIELD_TICKET, 'visible' => $field['visible'], 'fieldtype' => $field['type']);
            if ($field['new_value'] == $field['default_value']) {
                $context['custom_fields_updated'][count($context['custom_fields_updated']) - 1]['default'] = true;
            }
        }
    }
    // Same deal, this time for message options. See above for comments.
    if (!empty($msgOptions['custom_fields'])) {
        foreach ($msgOptions['custom_fields'] as $field_id => $field) {
            if (!isset($field['new_value']) || isset($field['value']) && $field['value'] == $field['new_value']) {
                continue;
            }
            $rows[] = array('id_post' => $msgOptions['id'], 'id_field' => $field_id, 'value' => $field['new_value'], 'post_type' => CFIELD_REPLY);
            if ($field['type'] == CFIELD_TYPE_MULTI) {
                $values = array();
                if (!empty($field['value'])) {
                    foreach ($field['value'] as $value) {
                        if (!empty($value)) {
                            $values[] = $field['options'][$value];
                        }
                    }
                }
                $oldvalue = implode(', ', $values);
                $values = array();
                $newvalues = explode(',', $field['new_value']);
                foreach ($newvalues as $value) {
                    if (!empty($value)) {
                        $values[] = $field['options'][$value];
                    }
                }
                $newvalue = implode(', ', $values);
            } else {
                $oldvalue = !empty($field['value']) && ($field['type'] == CFIELD_TYPE_RADIO || $field['type'] == CFIELD_TYPE_SELECT) ? $field['options'][$field['value']] : (empty($field['value']) ? $field['type'] != CFIELD_TYPE_LARGETEXT ? $field['default_value'] : '' : $field['value']);
                $newvalue = !empty($field['new_value']) && ($field['type'] == CFIELD_TYPE_RADIO || $field['type'] == CFIELD_TYPE_SELECT) ? $field['options'][$field['new_value']] : $field['new_value'];
            }
            if ($oldvalue != $newvalue) {
                $context['custom_fields_updated'][] = array('ticket' => $ticketOptions['id'], 'msg' => $msgOptions['id'], 'fieldname' => $field['name'], 'oldvalue' => $oldvalue, 'newvalue' => $newvalue, 'scope' => CFIELD_REPLY, 'visible' => $field['visible'], 'fieldtype' => $field['type']);
                if ($field['new_value'] == $field['default_value']) {
                    $context['custom_fields_updated'][count($context['custom_fields_updated']) - 1]['default'] = true;
                }
            }
        }
    }
    // If there are rows to add or update, commence.
    if (!empty($rows)) {
        $smcFunc['db_insert']('replace', '{db_prefix}helpdesk_custom_fields_values', array('id_post' => 'int', 'id_field' => 'int', 'value' => 'string-65534', 'post_type' => 'int'), $rows, array('id_post', 'id_field'));
    }
    // Int hook
    call_integration_hook('shd_hook_modpost', array(&$msgOptions, &$ticketOptions, &$posterOptions));
    ignore_user_abort($previous_ignore_user_abort);
    if (empty($ticketOptions['dept']) && !empty($ticketOptions['id'])) {
        // So we're making a reply, we need the department id. The ticket will already exist - we just added to it!
        $query = $smcFunc['db_query']('', '
			SELECT id_dept
			FROM {db_prefix}helpdesk_tickets
			WHERE id_ticket = {int:id_ticket}', array('id_ticket' => $ticketOptions['id']));
        list($ticketOptions['dept']) = $smcFunc['db_fetch_row']($query);
        $smcFunc['db_free_result']($query);
    }
    if (!empty($ticketOptions['dept'])) {
        shd_clear_active_tickets($ticketOptions['dept']);
    }
    // Success.
    return true;
}
Пример #24
0
/**
 * Prepare credits for display.
 *
 * - This is a helper function, used by admin panel for credits and support page, and by the credits page.
 */
function prepareCreditsData()
{
    global $txt;
    $credits = array();
    // Don't blink. Don't even blink. Blink and you're dead.
    $credits['credits'] = array(array('pretext' => $txt['credits_intro'], 'title' => $txt['credits_contributors'], 'groups' => array(array('title' => $txt['credits_groups_contrib'], 'members' => array($txt['credits_contrib_list'])), array('title' => $txt['credits_groups_translators'], 'members' => array($txt['credits_translators_message'])))));
    // Give credit to any graphic library's, software library's, plugins etc
    $credits['credits_software_graphics'] = array('graphics' => array('<a href="http://p.yusukekamiyamane.com/">Fugue Icons</a> | &copy; 2012 Yusuke Kamiyamane | These icons are licensed under a Creative Commons Attribution 3.0 License', '<a href="http://www.oxygen-icons.org/">Oxygen Icons</a> | These icons are licensed under <a href="http://creativecommons.org/licenses/by-sa/3.0/">CC BY-SA 3.0</a>'), 'fonts' => array('<a href="http://openfontlibrary.org/en/font/architect-s-daughter">Architect\'s Daughter</a> | &copy; 2010 <a href="http://kimberlygeswein.com/">Kimberly Geswein</a> | This font is licensed under the SIL Open Font License, Version 1.1', '<a href="http://openfontlibrary.org/en/font/klaudia-and-berenika">Berenika</a> | &copy; 2011 wmk69 | This font is licensed under the SIL Open Font License, Version 1.1', '<a href="http://openfontlibrary.org/en/font/dotrice">Dotrice</a> | &copy; 2010 <a href="http://hisdeedsaredust.com/">Paul Flo Williams</a> | This font is licensed under the SIL Open Font License, Version 1.1', '<a href="http://fontawesome.io/">Font Awesome</a> | Created by Dave Gandy | This font is licensed under the SIL Open Font License, Version 1.1', '<a href="http://openfontlibrary.org/en/font/press-start-2p">Press Start 2P</a> | &copy; 2012 Cody "CodeMan38" Boisclair | This font is licensed under the SIL Open Font License, Version 1.1', '<a href="http://openfontlibrary.org/en/font/vds">VDS</a> | &copy; 2012 <a href="http://www.wix.com/artmake1/artmaker">artmaker</a> | This font is licensed under the SIL Open Font License, Version 1.1', '<a href="http://openfontlibrary.org/en/font/vshexagonica-v1-0-1">vSHexagonica</a> | &copy; 2012 T.B. von Strong | This font is licensed under the SIL Open Font License, Version 1.1'), 'software' => array('<a href="http://ichord.github.com/At.js">At.js</a> | &copy; Chord Luo | Licensed under <a href="http://opensource.org/licenses/MIT">The MIT License (MIT)</a>', '<a href="http://bad-behavior.ioerror.us/">Bad Behavior</a> | &copy; Michael Hampton | Licensed under <a href="http://opensource.org/licenses/LGPL-3.0">GNU Lesser General Public License</a>', '<a href="https://code.google.com/p/google-code-prettify/">Google Code Prettify</a> | Licensed under <a href="http://opensource.org/licenses/Apache-2.0">Apache License, Version 2.0</a>', '<a href="http://cherne.net/brian/resources/jquery.hoverIntent.html">hoverIntent</a> | &copy; Brian Cherne | Licensed under <a href="http://opensource.org/licenses/MIT">The MIT License (MIT)</a>', '<a href="http://pajhome.org.uk/crypt/md5">Javascript Crypt</a> | &copy; Angel Marin, Paul Johnston | Licensed under <a href="http://opensource.org/licenses/BSD-3-Clause">The BSD License</a>', '<a href="http://jquery.org/">JQuery</a> | &copy; jQuery Foundation and other contributors | Licensed under <a href="http://opensource.org/licenses/MIT">The MIT License (MIT)</a>', '<a href="http://jqueryui.com/">JQuery UI</a> | &copy; jQuery Foundation and other contributors | Licensed under <a href="http://opensource.org/licenses/MIT">The MIT License (MIT)</a>', '<a href="http://crisp.tweakblogs.net/blog/6861/jsmin%2B-version-14.html">JSMinPlus</a> | Licensed under <a href="http://opensource.org/licenses/MPL-1.1">Mozilla_Public_License, Version 1.1</a>', '<a href="http://www.openwall.com/phpass/">PH Pass</a> | Author: Solar Designer | Placed in the public domain</a>', '<a href="http://www.sceditor.com/">SCEditor</a> | &copy; Sam Clarke | Licensed under <a href="http://opensource.org/licenses/MIT">The MIT License (MIT)</a>', '<a href="http://sourceforge.net/projects/simplehtmldom/">Simple HTML DOM</a> | Licensed under <a href="http://opensource.org/licenses/MIT">The MIT License (MIT)</a>', '<a href="http://www.simplemachines.org/">Simple Machines</a> | &copy; Simple Machines | Licensed under <a href="http://www.simplemachines.org/about/smf/license.php">The BSD License</a>', '<a href="http://users.tpg.com.au/j_birch/plugins/superfish/">Superfish</a> | &copy; Joel Birch | Licensed under <a href="http://opensource.org/licenses/MIT">The MIT License (MIT)</a>', '<a href="https://github.com/tubalmartin/YUI-CSS-compressor-PHP-port">YUI-CSS compressor (PHP port)</a> | &copy; Yahoo! Inc | Licensed under <a href="http://opensource.org/licenses/BSD-3-Clause">The BSD License</a>'));
    // Add-ons authors: to add credits, the simpler and better way is to add in your package.xml the <credits> <license> tags.
    // Support for addons that use the <credits> tag via the package manager
    $credits['credits_addons'] = addonsCredits();
    // An alternative for addons credits is to use a hook.
    call_integration_hook('integrate_credits', array(&$credits));
    // Copyright information
    $credits['copyrights']['elkarte'] = '&copy; 2012 - 2014 ElkArte Forum contributors';
    return $credits;
}
Пример #25
0
/**
 * A folder, ie. inbox/sent etc.
 */
function MessageFolder()
{
    global $txt, $scripturl, $modSettings, $context, $subjects_request;
    global $messages_request, $user_info, $recipients, $options, $smcFunc, $memberContext, $user_settings;
    // Changing view?
    if (isset($_GET['view'])) {
        $context['display_mode'] = $context['display_mode'] > 1 ? 0 : $context['display_mode'] + 1;
        updateMemberData($user_info['id'], array('pm_prefs' => $user_settings['pm_prefs'] & 252 | $context['display_mode']));
    }
    // Make sure the starting location is valid.
    if (isset($_GET['start']) && $_GET['start'] != 'new') {
        $_GET['start'] = (int) $_GET['start'];
    } elseif (!isset($_GET['start']) && !empty($options['view_newest_pm_first'])) {
        $_GET['start'] = 0;
    } else {
        $_GET['start'] = 'new';
    }
    // Set up some basic theme stuff.
    $context['from_or_to'] = $context['folder'] != 'sent' ? 'from' : 'to';
    $context['get_pmessage'] = 'prepareMessageContext';
    $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();
    $labelQuery = $context['folder'] != 'sent' ? '
			AND FIND_IN_SET(' . $context['current_label_id'] . ', pmr.labels) != 0' : '';
    // Set the index bar correct!
    messageIndexBar($context['current_label_id'] == -1 ? $context['folder'] : 'label' . $context['current_label_id']);
    // Sorting the folder.
    $sort_methods = array('date' => 'pm.id_pm', 'name' => 'IFNULL(mem.real_name, \'\')', 'subject' => 'pm.subject');
    // They didn't pick one, use the forum default.
    if (!isset($_GET['sort']) || !isset($sort_methods[$_GET['sort']])) {
        $context['sort_by'] = 'date';
        $_GET['sort'] = 'pm.id_pm';
        // An overriding setting?
        $descending = !empty($options['view_newest_pm_first']);
    } else {
        $context['sort_by'] = $_GET['sort'];
        $_GET['sort'] = $sort_methods[$_GET['sort']];
        $descending = isset($_GET['desc']);
    }
    $context['sort_direction'] = $descending ? 'down' : 'up';
    // Set the text to resemble the current folder.
    $pmbox = $context['folder'] != 'sent' ? $txt['inbox'] : $txt['sent_items'];
    $txt['delete_all'] = str_replace('PMBOX', $pmbox, $txt['delete_all']);
    // Now, build the link tree!
    if ($context['current_label_id'] == -1) {
        $context['linktree'][] = array('url' => $scripturl . '?action=pm;f=' . $context['folder'], 'name' => $pmbox);
    }
    // Build it further for a label.
    if ($context['current_label_id'] != -1) {
        $context['linktree'][] = array('url' => $scripturl . '?action=pm;f=' . $context['folder'] . ';l=' . $context['current_label_id'], 'name' => $txt['pm_current_label'] . ': ' . $context['current_label']);
    }
    // Figure out how many messages there are.
    if ($context['folder'] == 'sent') {
        $request = $smcFunc['db_query']('', '
			SELECT COUNT(' . ($context['display_mode'] == 2 ? 'DISTINCT pm.id_pm_head' : '*') . ')
			FROM {db_prefix}personal_messages AS pm
			WHERE pm.id_member_from = {int:current_member}
				AND pm.deleted_by_sender = {int:not_deleted}', array('current_member' => $user_info['id'], 'not_deleted' => 0));
    } else {
        $request = $smcFunc['db_query']('', '
			SELECT COUNT(' . ($context['display_mode'] == 2 ? 'DISTINCT pm.id_pm_head' : '*') . ')
			FROM {db_prefix}pm_recipients AS pmr' . ($context['display_mode'] == 2 ? '
				INNER JOIN {db_prefix}personal_messages AS pm ON (pm.id_pm = pmr.id_pm)' : '') . '
			WHERE pmr.id_member = {int:current_member}
				AND pmr.deleted = {int:not_deleted}' . $labelQuery, array('current_member' => $user_info['id'], 'not_deleted' => 0));
    }
    list($max_messages) = $smcFunc['db_fetch_row']($request);
    $smcFunc['db_free_result']($request);
    // Only show the button if there are messages to delete.
    $context['show_delete'] = $max_messages > 0;
    // Start on the last page.
    if (!is_numeric($_GET['start']) || $_GET['start'] >= $max_messages) {
        $_GET['start'] = $max_messages - 1 - ($max_messages - 1) % $modSettings['defaultMaxMessages'];
    } elseif ($_GET['start'] < 0) {
        $_GET['start'] = 0;
    }
    // ... but wait - what if we want to start from a specific message?
    if (isset($_GET['pmid'])) {
        $pmID = (int) $_GET['pmid'];
        // Make sure you have access to this PM.
        if (!isAccessiblePM($pmID, $context['folder'] == 'sent' ? 'outbox' : 'inbox')) {
            fatal_lang_error('no_access', false);
        }
        $context['current_pm'] = $pmID;
        // With only one page of PM's we're gonna want page 1.
        if ($max_messages <= $modSettings['defaultMaxMessages']) {
            $_GET['start'] = 0;
        } elseif (!isset($_GET['kstart'])) {
            if ($context['folder'] == 'sent') {
                $request = $smcFunc['db_query']('', '
					SELECT COUNT(' . ($context['display_mode'] == 2 ? 'DISTINCT pm.id_pm_head' : '*') . ')
					FROM {db_prefix}personal_messages
					WHERE id_member_from = {int:current_member}
						AND deleted_by_sender = {int:not_deleted}
						AND id_pm ' . ($descending ? '>' : '<') . ' {int:id_pm}', array('current_member' => $user_info['id'], 'not_deleted' => 0, 'id_pm' => $pmID));
            } else {
                $request = $smcFunc['db_query']('', '
					SELECT COUNT(' . ($context['display_mode'] == 2 ? 'DISTINCT pm.id_pm_head' : '*') . ')
					FROM {db_prefix}pm_recipients AS pmr' . ($context['display_mode'] == 2 ? '
						INNER JOIN {db_prefix}personal_messages AS pm ON (pm.id_pm = pmr.id_pm)' : '') . '
					WHERE pmr.id_member = {int:current_member}
						AND pmr.deleted = {int:not_deleted}' . $labelQuery . '
						AND pmr.id_pm ' . ($descending ? '>' : '<') . ' {int:id_pm}', array('current_member' => $user_info['id'], 'not_deleted' => 0, 'id_pm' => $pmID));
            }
            list($_GET['start']) = $smcFunc['db_fetch_row']($request);
            $smcFunc['db_free_result']($request);
            // To stop the page index's being abnormal, start the page on the page the message would normally be located on...
            $_GET['start'] = $modSettings['defaultMaxMessages'] * (int) ($_GET['start'] / $modSettings['defaultMaxMessages']);
        }
    }
    // Sanitize and validate pmsg variable if set.
    if (isset($_GET['pmsg'])) {
        $pmsg = (int) $_GET['pmsg'];
        if (!isAccessiblePM($pmsg, $context['folder'] == 'sent' ? 'outbox' : 'inbox')) {
            fatal_lang_error('no_access', false);
        }
    }
    // Set up the page index.
    $context['page_index'] = constructPageIndex($scripturl . '?action=pm;f=' . $context['folder'] . (isset($_REQUEST['l']) ? ';l=' . (int) $_REQUEST['l'] : '') . ';sort=' . $context['sort_by'] . ($descending ? ';desc' : ''), $_GET['start'], $max_messages, $modSettings['defaultMaxMessages']);
    $context['start'] = $_GET['start'];
    // Determine the navigation context (especially useful for the wireless template).
    $context['links'] = array('first' => $_GET['start'] >= $modSettings['defaultMaxMessages'] ? $scripturl . '?action=pm;start=0' : '', 'prev' => $_GET['start'] >= $modSettings['defaultMaxMessages'] ? $scripturl . '?action=pm;start=' . ($_GET['start'] - $modSettings['defaultMaxMessages']) : '', 'next' => $_GET['start'] + $modSettings['defaultMaxMessages'] < $max_messages ? $scripturl . '?action=pm;start=' . ($_GET['start'] + $modSettings['defaultMaxMessages']) : '', 'last' => $_GET['start'] + $modSettings['defaultMaxMessages'] < $max_messages ? $scripturl . '?action=pm;start=' . floor(($max_messages - 1) / $modSettings['defaultMaxMessages']) * $modSettings['defaultMaxMessages'] : '', 'up' => $scripturl);
    $context['page_info'] = array('current_page' => $_GET['start'] / $modSettings['defaultMaxMessages'] + 1, 'num_pages' => floor(($max_messages - 1) / $modSettings['defaultMaxMessages']) + 1);
    // First work out what messages we need to see - if grouped is a little trickier...
    if ($context['display_mode'] == 2) {
        // On a non-default sort due to PostgreSQL we have to do a harder sort.
        if ($smcFunc['db_title'] == 'PostgreSQL' && $_GET['sort'] != 'pm.id_pm') {
            $sub_request = $smcFunc['db_query']('', '
				SELECT MAX({raw:sort}) AS sort_param, pm.id_pm_head
				FROM {db_prefix}personal_messages AS pm' . ($context['folder'] == 'sent' ? $context['sort_by'] == 'name' ? '
					LEFT JOIN {db_prefix}pm_recipients AS pmr ON (pmr.id_pm = pm.id_pm)' : '' : '
					INNER JOIN {db_prefix}pm_recipients AS pmr ON (pmr.id_pm = pm.id_pm
						AND pmr.id_member = {int:current_member}
						AND pmr.deleted = {int:not_deleted}
						' . $labelQuery . ')') . ($context['sort_by'] == 'name' ? '
					LEFT JOIN {db_prefix}members AS mem ON (mem.id_member = {raw:id_member})' : '') . '
				WHERE ' . ($context['folder'] == 'sent' ? 'pm.id_member_from = {int:current_member}
					AND pm.deleted_by_sender = {int:not_deleted}' : '1=1') . (empty($pmsg) ? '' : '
					AND pm.id_pm = {int:id_pm}') . '
				GROUP BY pm.id_pm_head
				ORDER BY sort_param' . ($descending ? ' DESC' : ' ASC') . (empty($pmsg) ? '
				LIMIT ' . $_GET['start'] . ', ' . $modSettings['defaultMaxMessages'] : ''), array('current_member' => $user_info['id'], 'not_deleted' => 0, 'id_member' => $context['folder'] == 'sent' ? 'pmr.id_member' : 'pm.id_member_from', 'id_pm' => isset($pmsg) ? $pmsg : '0', 'sort' => $_GET['sort']));
            $sub_pms = array();
            while ($row = $smcFunc['db_fetch_assoc']($sub_request)) {
                $sub_pms[$row['id_pm_head']] = $row['sort_param'];
            }
            $smcFunc['db_free_result']($sub_request);
            $request = $smcFunc['db_query']('', '
				SELECT pm.id_pm AS id_pm, pm.id_pm_head
				FROM {db_prefix}personal_messages AS pm' . ($context['folder'] == 'sent' ? $context['sort_by'] == 'name' ? '
					LEFT JOIN {db_prefix}pm_recipients AS pmr ON (pmr.id_pm = pm.id_pm)' : '' : '
					INNER JOIN {db_prefix}pm_recipients AS pmr ON (pmr.id_pm = pm.id_pm
						AND pmr.id_member = {int:current_member}
						AND pmr.deleted = {int:not_deleted}
						' . $labelQuery . ')') . ($context['sort_by'] == 'name' ? '
					LEFT JOIN {db_prefix}members AS mem ON (mem.id_member = {raw:id_member})' : '') . '
				WHERE ' . (empty($sub_pms) ? '0=1' : 'pm.id_pm IN ({array_int:pm_list})') . '
				ORDER BY ' . ($_GET['sort'] == 'pm.id_pm' && $context['folder'] != 'sent' ? 'id_pm' : '{raw:sort}') . ($descending ? ' DESC' : ' ASC') . (empty($pmsg) ? '
				LIMIT ' . $_GET['start'] . ', ' . $modSettings['defaultMaxMessages'] : ''), array('current_member' => $user_info['id'], 'pm_list' => array_keys($sub_pms), 'not_deleted' => 0, 'sort' => $_GET['sort'], 'id_member' => $context['folder'] == 'sent' ? 'pmr.id_member' : 'pm.id_member_from'));
        } else {
            $request = $smcFunc['db_query']('pm_conversation_list', '
				SELECT MAX(pm.id_pm) AS id_pm, pm.id_pm_head
				FROM {db_prefix}personal_messages AS pm' . ($context['folder'] == 'sent' ? $context['sort_by'] == 'name' ? '
					LEFT JOIN {db_prefix}pm_recipients AS pmr ON (pmr.id_pm = pm.id_pm)' : '' : '
					INNER JOIN {db_prefix}pm_recipients AS pmr ON (pmr.id_pm = pm.id_pm
						AND pmr.id_member = {int:current_member}
						AND pmr.deleted = {int:deleted_by}
						' . $labelQuery . ')') . ($context['sort_by'] == 'name' ? '
					LEFT JOIN {db_prefix}members AS mem ON (mem.id_member = {raw:pm_member})' : '') . '
				WHERE ' . ($context['folder'] == 'sent' ? 'pm.id_member_from = {int:current_member}
					AND pm.deleted_by_sender = {int:deleted_by}' : '1=1') . (empty($pmsg) ? '' : '
					AND pm.id_pm = {int:pmsg}') . '
				GROUP BY pm.id_pm_head
				ORDER BY ' . ($_GET['sort'] == 'pm.id_pm' && $context['folder'] != 'sent' ? 'id_pm' : '{raw:sort}') . ($descending ? ' DESC' : ' ASC') . (empty($_GET['pmsg']) ? '
				LIMIT ' . $_GET['start'] . ', ' . $modSettings['defaultMaxMessages'] : ''), array('current_member' => $user_info['id'], 'deleted_by' => 0, 'sort' => $_GET['sort'], 'pm_member' => $context['folder'] == 'sent' ? 'pmr.id_member' : 'pm.id_member_from', 'pmsg' => isset($pmsg) ? (int) $pmsg : 0));
        }
    } else {
        // @todo SLOW This query uses a filesort. (inbox only.)
        $request = $smcFunc['db_query']('', '
			SELECT pm.id_pm, pm.id_pm_head, pm.id_member_from
			FROM {db_prefix}personal_messages AS pm' . ($context['folder'] == 'sent' ? '' . ($context['sort_by'] == 'name' ? '
				LEFT JOIN {db_prefix}pm_recipients AS pmr ON (pmr.id_pm = pm.id_pm)' : '') : '
				INNER JOIN {db_prefix}pm_recipients AS pmr ON (pmr.id_pm = pm.id_pm
					AND pmr.id_member = {int:current_member}
					AND pmr.deleted = {int:is_deleted}
					' . $labelQuery . ')') . ($context['sort_by'] == 'name' ? '
				LEFT JOIN {db_prefix}members AS mem ON (mem.id_member = {raw:pm_member})' : '') . '
			WHERE ' . ($context['folder'] == 'sent' ? 'pm.id_member_from = {raw:current_member}
				AND pm.deleted_by_sender = {int:is_deleted}' : '1=1') . (empty($pmsg) ? '' : '
				AND pm.id_pm = {int:pmsg}') . '
			ORDER BY ' . ($_GET['sort'] == 'pm.id_pm' && $context['folder'] != 'sent' ? 'pmr.id_pm' : '{raw:sort}') . ($descending ? ' DESC' : ' ASC') . (empty($pmsg) ? '
			LIMIT ' . $_GET['start'] . ', ' . $modSettings['defaultMaxMessages'] : ''), array('current_member' => $user_info['id'], 'is_deleted' => 0, 'sort' => $_GET['sort'], 'pm_member' => $context['folder'] == 'sent' ? 'pmr.id_member' : 'pm.id_member_from', 'pmsg' => isset($pmsg) ? (int) $pmsg : 0));
    }
    // Load the id_pms and initialize recipients.
    $pms = array();
    $lastData = array();
    $posters = $context['folder'] == 'sent' ? array($user_info['id']) : array();
    $recipients = array();
    while ($row = $smcFunc['db_fetch_assoc']($request)) {
        if (!isset($recipients[$row['id_pm']])) {
            if (isset($row['id_member_from'])) {
                $posters[$row['id_pm']] = $row['id_member_from'];
            }
            $pms[$row['id_pm']] = $row['id_pm'];
            $recipients[$row['id_pm']] = array('to' => array(), 'bcc' => array());
        }
        // Keep track of the last message so we know what the head is without another query!
        if (empty($pmID) && (empty($options['view_newest_pm_first']) || !isset($lastData)) || empty($lastData) || !empty($pmID) && $pmID == $row['id_pm']) {
            $lastData = array('id' => $row['id_pm'], 'head' => $row['id_pm_head']);
        }
    }
    $smcFunc['db_free_result']($request);
    // Make sure that we have been given a correct head pm id!
    if ($context['display_mode'] == 2 && !empty($pmID) && $pmID != $lastData['id']) {
        fatal_lang_error('no_access', false);
    }
    if (!empty($pms)) {
        // Select the correct current message.
        if (empty($pmID)) {
            $context['current_pm'] = $lastData['id'];
        }
        // This is a list of the pm's that are used for "full" display.
        if ($context['display_mode'] == 0) {
            $display_pms = $pms;
        } else {
            $display_pms = array($context['current_pm']);
        }
        // At this point we know the main id_pm's. But - if we are looking at conversations we need the others!
        if ($context['display_mode'] == 2) {
            $request = $smcFunc['db_query']('', '
				SELECT pm.id_pm, pm.id_member_from, pm.deleted_by_sender, pmr.id_member, pmr.deleted
				FROM {db_prefix}personal_messages AS pm
					INNER JOIN {db_prefix}pm_recipients AS pmr ON (pmr.id_pm = pm.id_pm)
				WHERE pm.id_pm_head = {int:id_pm_head}
					AND ((pm.id_member_from = {int:current_member} AND pm.deleted_by_sender = {int:not_deleted})
						OR (pmr.id_member = {int:current_member} AND pmr.deleted = {int:not_deleted}))
				ORDER BY pm.id_pm', array('current_member' => $user_info['id'], 'id_pm_head' => $lastData['head'], 'not_deleted' => 0));
            while ($row = $smcFunc['db_fetch_assoc']($request)) {
                // This is, frankly, a joke. We will put in a workaround for people sending to themselves - yawn!
                if ($context['folder'] == 'sent' && $row['id_member_from'] == $user_info['id'] && $row['deleted_by_sender'] == 1) {
                    continue;
                } elseif ($row['id_member'] == $user_info['id'] & $row['deleted'] == 1) {
                    continue;
                }
                if (!isset($recipients[$row['id_pm']])) {
                    $recipients[$row['id_pm']] = array('to' => array(), 'bcc' => array());
                }
                $display_pms[] = $row['id_pm'];
                $posters[$row['id_pm']] = $row['id_member_from'];
            }
            $smcFunc['db_free_result']($request);
        }
        // This is pretty much EVERY pm!
        $all_pms = array_merge($pms, $display_pms);
        $all_pms = array_unique($all_pms);
        // Get recipients (don't include bcc-recipients for your inbox, you're not supposed to know :P).
        $request = $smcFunc['db_query']('', '
			SELECT pmr.id_pm, mem_to.id_member AS id_member_to, mem_to.real_name AS to_name, pmr.bcc, pmr.labels, pmr.is_read
			FROM {db_prefix}pm_recipients AS pmr
				LEFT JOIN {db_prefix}members AS mem_to ON (mem_to.id_member = pmr.id_member)
			WHERE pmr.id_pm IN ({array_int:pm_list})', array('pm_list' => $all_pms));
        $context['message_labels'] = array();
        $context['message_replied'] = array();
        $context['message_unread'] = array();
        while ($row = $smcFunc['db_fetch_assoc']($request)) {
            if ($context['folder'] == 'sent' || empty($row['bcc'])) {
                $recipients[$row['id_pm']][empty($row['bcc']) ? 'to' : 'bcc'][] = empty($row['id_member_to']) ? $txt['guest_title'] : '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member_to'] . '">' . $row['to_name'] . '</a>';
            }
            if ($row['id_member_to'] == $user_info['id'] && $context['folder'] != 'sent') {
                $context['message_replied'][$row['id_pm']] = $row['is_read'] & 2;
                $context['message_unread'][$row['id_pm']] = $row['is_read'] == 0;
                $row['labels'] = $row['labels'] == '' ? array() : explode(',', $row['labels']);
                foreach ($row['labels'] as $v) {
                    if (isset($context['labels'][(int) $v])) {
                        $context['message_labels'][$row['id_pm']][(int) $v] = array('id' => $v, 'name' => $context['labels'][(int) $v]['name']);
                    }
                }
            }
        }
        $smcFunc['db_free_result']($request);
        // Make sure we don't load unnecessary data.
        if ($context['display_mode'] == 1) {
            foreach ($posters as $k => $v) {
                if (!in_array($k, $display_pms)) {
                    unset($posters[$k]);
                }
            }
        }
        // Load any users....
        $posters = array_unique($posters);
        if (!empty($posters)) {
            loadMemberData($posters);
        }
        // If we're on grouped/restricted view get a restricted list of messages.
        if ($context['display_mode'] != 0) {
            // Get the order right.
            $orderBy = array();
            foreach (array_reverse($pms) as $pm) {
                $orderBy[] = 'pm.id_pm = ' . $pm;
            }
            // Seperate query for these bits!
            $subjects_request = $smcFunc['db_query']('', '
				SELECT pm.id_pm, pm.subject, pm.id_member_from, pm.msgtime, IFNULL(mem.real_name, pm.from_name) AS from_name,
					IFNULL(mem.id_member, 0) AS not_guest
				FROM {db_prefix}personal_messages AS pm
					LEFT JOIN {db_prefix}members AS mem ON (mem.id_member = pm.id_member_from)
				WHERE pm.id_pm IN ({array_int:pm_list})
				ORDER BY ' . implode(', ', $orderBy) . '
				LIMIT ' . count($pms), array('pm_list' => $pms));
        }
        // Execute the query!
        $messages_request = $smcFunc['db_query']('', '
			SELECT pm.id_pm, pm.subject, pm.id_member_from, pm.body, pm.msgtime, pm.from_name
			FROM {db_prefix}personal_messages AS pm' . ($context['folder'] == 'sent' ? '
				LEFT JOIN {db_prefix}pm_recipients AS pmr ON (pmr.id_pm = pm.id_pm)' : '') . ($context['sort_by'] == 'name' ? '
				LEFT JOIN {db_prefix}members AS mem ON (mem.id_member = {raw:id_member})' : '') . '
			WHERE pm.id_pm IN ({array_int:display_pms})' . ($context['folder'] == 'sent' ? '
			GROUP BY pm.id_pm, pm.subject, pm.id_member_from, pm.body, pm.msgtime, pm.from_name' : '') . '
			ORDER BY ' . ($context['display_mode'] == 2 ? 'pm.id_pm' : $_GET['sort']) . ($descending ? ' DESC' : ' ASC') . '
			LIMIT ' . count($display_pms), array('display_pms' => $display_pms, 'id_member' => $context['folder'] == 'sent' ? 'pmr.id_member' : 'pm.id_member_from'));
    } else {
        $messages_request = false;
    }
    $context['can_send_pm'] = allowedTo('pm_send');
    $context['can_send_email'] = allowedTo('send_email_to_members');
    if (!WIRELESS) {
        $context['sub_template'] = 'folder';
    }
    $context['page_title'] = $txt['pm_inbox'];
    // Finally mark the relevant messages as read.
    if ($context['folder'] != 'sent' && !empty($context['labels'][(int) $context['current_label_id']]['unread_messages'])) {
        // If the display mode is "old sk00l" do them all...
        if ($context['display_mode'] == 0) {
            markMessages(null, $context['current_label_id']);
        } elseif (!empty($context['current_pm'])) {
            markMessages($display_pms, $context['current_label_id']);
        }
    }
    // Build the conversation button array.
    if ($context['display_mode'] == 2) {
        $context['conversation_buttons'] = array('reply' => array('text' => 'reply_to_all', 'image' => 'reply.png', 'lang' => true, 'url' => $scripturl . '?action=pm;sa=send;f=' . $context['folder'] . ($context['current_label_id'] != -1 ? ';l=' . $context['current_label_id'] : '') . ';pmsg=' . $context['current_pm'] . ';u=all', 'active' => true), 'delete' => array('text' => 'delete_conversation', 'image' => 'delete.png', 'lang' => true, 'url' => $scripturl . '?action=pm;sa=pmactions;pm_actions[' . $context['current_pm'] . ']=delete;conversation;f=' . $context['folder'] . ';start=' . $context['start'] . ($context['current_label_id'] != -1 ? ';l=' . $context['current_label_id'] : '') . ';' . $context['session_var'] . '=' . $context['session_id'], 'custom' => 'onclick="return confirm(\'' . addslashes($txt['remove_message']) . '?\');"'));
        // Allow mods to add additional buttons here
        call_integration_hook('integrate_conversation_buttons');
    }
}
Пример #26
0
function create_control_richedit($editorOptions)
{
    global $txt, $modSettings, $options, $smcFunc;
    global $context, $settings, $user_info, $sourcedir, $scripturl;
    // Load the Post language file... for the moment at least.
    loadLanguage('Post');
    // 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 some template stuff is initialised.
    if (empty($context['controls']['richedit'])) {
        // Some general stuff.
        $settings['smileys_url'] = $modSettings['smileys_url'] . '/' . $user_info['smiley_set'];
        // This really has some WYSIWYG stuff.
        loadTemplate('GenericControls', $context['browser']['is_ie'] ? 'editor_ie' : 'editor');
        $context['html_headers'] .= '
		<script type="text/javascript"><!-- // --><![CDATA[
			var smf_smileys_url = \'' . $settings['smileys_url'] . '\';
			var oEditorStrings= {
				wont_work: \'' . addcslashes($txt['rich_edit_wont_work'], "'") . '\',
				func_disabled: \'' . addcslashes($txt['rich_edit_function_disabled'], "'") . '\',
				prompt_text_email: \'' . addcslashes($txt['prompt_text_email'], "'") . '\',
				prompt_text_ftp: \'' . addcslashes($txt['prompt_text_ftp'], "'") . '\',
				prompt_text_url: \'' . addcslashes($txt['prompt_text_url'], "'") . '\',
				prompt_text_img: \'' . addcslashes($txt['prompt_text_img'], "'") . '\'
			}
		// ]]></script>
		<script type="text/javascript" src="' . $settings['default_theme_url'] . '/scripts/editor.js?fin20"></script>';
        $context['show_spellchecking'] = !empty($modSettings['enableSpellChecking']) && function_exists('pspell_new');
        if ($context['show_spellchecking']) {
            $context['html_headers'] .= '
		<script type="text/javascript" src="' . $settings['default_theme_url'] . '/scripts/spellcheck.js"></script>';
            // Some hidden information is needed in order to make the spell checking work.
            if (!isset($_REQUEST['xml'])) {
                $context['insert_after_template'] .= '
		<form name="spell_form" id="spell_form" method="post" accept-charset="' . $context['character_set'] . '" target="spellWindow" action="' . $scripturl . '?action=spellcheck">
			<input type="hidden" name="spellstring" value="" />
		</form>';
            }
            // Also make sure that spell check works with rich edit.
            $context['html_headers'] .= '
		<script type="text/javascript"><!-- // --><![CDATA[
		function spellCheckDone()
		{
			for (i = 0; i < smf_editorArray.length; i++)
				setTimeout("smf_editorArray[" + i + "].spellCheckEnd()", 150);
		}
		// ]]></script>';
        }
    }
    // Start off the editor...
    $context['controls']['richedit'][$editorOptions['id']] = array('id' => $editorOptions['id'], 'value' => $editorOptions['value'], 'rich_value' => bbc_to_html($editorOptions['value']), 'rich_active' => empty($modSettings['disable_wysiwyg']) && (!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'] : 12, 'width' => isset($editorOptions['width']) ? $editorOptions['width'] : '70%', 'height' => isset($editorOptions['height']) ? $editorOptions['height'] : '150px', '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());
    // 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($context['bbc_tags'])) {
        // The below array makes it dead easy to add images to this control. Add it to the array and everything else is done for you!
        $context['bbc_tags'] = array();
        $context['bbc_tags'][] = array(array('image' => 'bold', 'code' => 'b', 'before' => '[b]', 'after' => '[/b]', 'description' => $txt['bold']), array('image' => 'italicize', 'code' => 'i', 'before' => '[i]', 'after' => '[/i]', 'description' => $txt['italic']), array('image' => 'underline', 'code' => 'u', 'before' => '[u]', 'after' => '[/u]', 'description' => $txt['underline']), array('image' => 'strike', 'code' => 's', 'before' => '[s]', 'after' => '[/s]', 'description' => $txt['strike']), array(), array('image' => 'pre', 'code' => 'pre', 'before' => '[pre]', 'after' => '[/pre]', 'description' => $txt['preformatted']), array('image' => 'left', 'code' => 'left', 'before' => '[left]', 'after' => '[/left]', 'description' => $txt['left_align']), array('image' => 'center', 'code' => 'center', 'before' => '[center]', 'after' => '[/center]', 'description' => $txt['center']), array('image' => 'right', 'code' => 'right', 'before' => '[right]', 'after' => '[/right]', 'description' => $txt['right_align']));
        $context['bbc_tags'][] = array(array('image' => 'flash', 'code' => 'flash', 'before' => '[flash=200,200]', 'after' => '[/flash]', 'description' => $txt['flash']), array('image' => 'img', 'code' => 'img', 'before' => '[img]', 'after' => '[/img]', 'description' => $txt['image']), array('image' => 'url', 'code' => 'url', 'before' => '[url]', 'after' => '[/url]', 'description' => $txt['hyperlink']), array('image' => 'quote', 'code' => 'quote', 'before' => '[quote]', 'after' => '[/quote]', 'description' => $txt['bbc_quote']), array('image' => 'email', 'code' => 'email', 'before' => '[email]', 'after' => '[/email]', 'description' => $txt['insert_email']), array('image' => 'ftp', 'code' => 'ftp', 'before' => '[ftp]', 'after' => '[/ftp]', 'description' => $txt['ftp']), array('image' => 'nsfw', 'code' => 'nsfw', 'before' => '[nsfw]', 'after' => '[/nsfw]', 'description' => 'NSFW content'), array('image' => 'spoiler', 'code' => 'spoiler', 'before' => '[spoiler]', 'after' => '[/spoiler]', 'description' => 'Spoiler'), array(), array('image' => 'glow', 'code' => 'glow', 'before' => '[glow=red,2,300]', 'after' => '[/glow]', 'description' => $txt['glow']), array('image' => 'shadow', 'code' => 'shadow', 'before' => '[shadow=red,left]', 'after' => '[/shadow]', 'description' => $txt['shadow']), array('image' => 'move', 'code' => 'move', 'before' => '[move]', 'after' => '[/move]', 'description' => $txt['marquee']), array('image' => 'sup', 'code' => 'sup', 'before' => '[sup]', 'after' => '[/sup]', 'description' => $txt['superscript']), array('image' => 'sub', 'code' => 'sub', 'before' => '[sub]', 'after' => '[/sub]', 'description' => $txt['subscript']), array('image' => 'tele', 'code' => 'tt', 'before' => '[tt]', 'after' => '[/tt]', 'description' => $txt['teletype']), array(), array('image' => 'table', 'code' => 'table', 'before' => '[table]\\n[tr]\\n[td]', 'after' => '[/td]\\n[/tr]\\n[/table]', 'description' => $txt['table']), array('image' => 'code', 'code' => 'code', 'before' => '[code]', 'after' => '[/code]', 'description' => $txt['bbc_code']), array('image' => 'list', 'code' => 'list', 'before' => '[list]\\n[li]', 'after' => '[/li]\\n[li][/li]\\n[/list]', 'description' => $txt['list_unordered']), array('image' => 'orderlist', 'code' => 'orderlist', 'before' => '[list type=decimal]\\n[li]', 'after' => '[/li]\\n[li][/li]\\n[/list]', 'description' => $txt['list_ordered']), array('image' => 'hr', 'code' => 'hr', 'before' => '[hr]', 'description' => $txt['horizontal_rule']), array(), array('image' => 'video', 'code' => 'video', 'before' => '[video]', 'after' => '[/video]', 'description' => 'looped video (webm, ogg, mp4)'));
        // Allow mods to modify BBC buttons.
        call_integration_hook('integrate_bbc_buttons', array(&$context['bbc_tags']));
        // Show the toggle?
        if (empty($modSettings['disable_wysiwyg'])) {
            $context['bbc_tags'][count($context['bbc_tags']) - 1][] = array();
            $context['bbc_tags'][count($context['bbc_tags']) - 1][] = array('image' => 'unformat', 'code' => 'unformat', 'before' => '', 'description' => $txt['unformat_text']);
            /**
            			$context['bbc_tags'][count($context['bbc_tags']) - 1][] = array(
            				'image' => 'toggle',
            				'code' => 'toggle',
            				'before' => '',
            				'description' => $txt['toggle_view'],
            			);
                        **/
        }
        foreach ($context['bbc_tags'] as $row => $tagRow) {
            $context['bbc_tags'][$row][count($tagRow) - 1]['isLast'] = true;
        }
    }
    // 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' => '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' => ':\'(', '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 = $smcFunc['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 = $smcFunc['db_fetch_assoc']($request)) {
                    $row['filename'] = htmlspecialchars($row['filename']);
                    $row['description'] = htmlspecialchars($row['description']);
                    $context['smileys'][empty($row['hidden']) ? 'postform' : 'popup'][$row['smiley_row']]['smileys'][] = $row;
                }
                $smcFunc['db_free_result']($request);
                foreach ($context['smileys'] as $section => $smileyRows) {
                    foreach ($smileyRows as $rowIndex => $smileys) {
                        $context['smileys'][$section][$rowIndex]['smileys'][count($smileys['smileys']) - 1]['isLast'] = true;
                    }
                    if (!empty($smileyRows)) {
                        $context['smileys'][$section][count($smileyRows) - 1]['isLast'] = true;
                    }
                }
                cache_put_data('posting_smileys', $context['smileys'], 480);
            } else {
                $context['smileys'] = $temp;
            }
        }
    }
    // Set a flag so the sub template knows what to do...
    $context['show_bbc'] = !empty($modSettings['enableBBC']) && !empty($settings['show_bbc']);
    // Generate a list of buttons that shouldn't be shown - this should be the fastest way to do this.
    $disabled_tags = array();
    if (!empty($modSettings['disabledBBC'])) {
        $disabled_tags = explode(',', $modSettings['disabledBBC']);
    }
    if (empty($modSettings['enableEmbeddedFlash'])) {
        $disabled_tags[] = 'flash';
    }
    foreach ($disabled_tags as $tag) {
        if ($tag == 'list') {
            $context['disabled_tags']['orderlist'] = true;
        }
        $context['disabled_tags'][trim($tag)] = true;
    }
    // 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;
    }
}
Пример #27
0
/**
 * Show the list of topics in this board, along with any child boards.
 */
function MessageIndex()
{
    global $txt, $scripturl, $board, $modSettings, $context;
    global $options, $settings, $board_info, $user_info, $smcFunc, $sourcedir;
    // If this is a redirection board head off.
    if ($board_info['redirect']) {
        $smcFunc['db_query']('', '
			UPDATE {db_prefix}boards
			SET num_posts = num_posts + 1
			WHERE id_board = {int:current_board}', array('current_board' => $board));
        redirectexit($board_info['redirect']);
    }
    if (WIRELESS) {
        $context['sub_template'] = WIRELESS_PROTOCOL . '_messageindex';
    } else {
        loadTemplate('MessageIndex');
    }
    $context['name'] = $board_info['name'];
    $context['description'] = $board_info['description'];
    // How many topics do we have in total?
    $board_info['total_topics'] = allowedTo('approve_posts') ? $board_info['num_topics'] + $board_info['unapproved_topics'] : $board_info['num_topics'] + $board_info['unapproved_user_topics'];
    // View all the topics, or just a few?
    $context['topics_per_page'] = empty($modSettings['disableCustomPerPage']) && !empty($options['topics_per_page']) && !WIRELESS ? $options['topics_per_page'] : $modSettings['defaultMaxTopics'];
    $context['messages_per_page'] = empty($modSettings['disableCustomPerPage']) && !empty($options['messages_per_page']) && !WIRELESS ? $options['messages_per_page'] : $modSettings['defaultMaxMessages'];
    $maxindex = isset($_REQUEST['all']) && !empty($modSettings['enableAllMessages']) ? $board_info['total_topics'] : $context['topics_per_page'];
    // Right, let's only index normal stuff!
    if (count($_GET) > 1) {
        $session_name = session_name();
        foreach ($_GET as $k => $v) {
            if (!in_array($k, array('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;
    }
    // If we can view unapproved messages and there are some build up a list.
    if (allowedTo('approve_posts') && ($board_info['unapproved_topics'] || $board_info['unapproved_posts'])) {
        $untopics = $board_info['unapproved_topics'] ? '<a href="' . $scripturl . '?action=moderate;area=postmod;sa=topics;brd=' . $board . '">' . $board_info['unapproved_topics'] . '</a>' : 0;
        $unposts = $board_info['unapproved_posts'] ? '<a href="' . $scripturl . '?action=moderate;area=postmod;sa=posts;brd=' . $board . '">' . ($board_info['unapproved_posts'] - $board_info['unapproved_topics']) . '</a>' : 0;
        $context['unapproved_posts_message'] = sprintf($txt['there_are_unapproved_topics'], $untopics, $unposts, $scripturl . '?action=moderate;area=postmod;sa=' . ($board_info['unapproved_topics'] ? 'topics' : 'posts') . ';brd=' . $board);
    }
    // Make sure the starting place makes sense and construct the page index.
    if (isset($_REQUEST['sort'])) {
        $context['page_index'] = constructPageIndex($scripturl . '?board=' . $board . '.%1$d;sort=' . $_REQUEST['sort'] . (isset($_REQUEST['desc']) ? ';desc' : ''), $_REQUEST['start'], $board_info['total_topics'], $maxindex, true);
    } else {
        $context['page_index'] = constructPageIndex($scripturl . '?board=' . $board . '.%1$d', $_REQUEST['start'], $board_info['total_topics'], $maxindex, true);
    }
    $context['start'] =& $_REQUEST['start'];
    // Set a canonical URL for this page.
    $context['canonical_url'] = $scripturl . '?board=' . $board . '.' . $context['start'];
    $context['links'] = array('first' => $_REQUEST['start'] >= $context['topics_per_page'] ? $scripturl . '?board=' . $board . '.0' : '', 'prev' => $_REQUEST['start'] >= $context['topics_per_page'] ? $scripturl . '?board=' . $board . '.' . ($_REQUEST['start'] - $context['topics_per_page']) : '', 'next' => $_REQUEST['start'] + $context['topics_per_page'] < $board_info['total_topics'] ? $scripturl . '?board=' . $board . '.' . ($_REQUEST['start'] + $context['topics_per_page']) : '', 'last' => $_REQUEST['start'] + $context['topics_per_page'] < $board_info['total_topics'] ? $scripturl . '?board=' . $board . '.' . floor(($board_info['total_topics'] - 1) / $context['topics_per_page']) * $context['topics_per_page'] : '', 'up' => $board_info['parent'] == 0 ? $scripturl . '?' : $scripturl . '?board=' . $board_info['parent'] . '.0');
    $context['page_info'] = array('current_page' => $_REQUEST['start'] / $context['topics_per_page'] + 1, 'num_pages' => floor(($board_info['total_topics'] - 1) / $context['topics_per_page']) + 1);
    if (isset($_REQUEST['all']) && !empty($modSettings['enableAllMessages']) && $maxindex > $modSettings['enableAllMessages']) {
        $maxindex = $modSettings['enableAllMessages'];
        $_REQUEST['start'] = 0;
    }
    // Build a list of the board's moderators.
    $context['moderators'] =& $board_info['moderators'];
    $context['link_moderators'] = array();
    if (!empty($board_info['moderators'])) {
        foreach ($board_info['moderators'] as $mod) {
            $context['link_moderators'][] = '<a href="' . $scripturl . '?action=profile;u=' . $mod['id'] . '" title="' . $txt['board_moderator'] . '">' . $mod['name'] . '</a>';
        }
        $context['linktree'][count($context['linktree']) - 1]['extra_after'] = '<span class="board_moderators"> (' . (count($context['link_moderators']) == 1 ? $txt['moderator'] : $txt['moderators']) . ': ' . implode(', ', $context['link_moderators']) . ')</span>';
    }
    // Mark current and parent boards as seen.
    if (!$user_info['is_guest']) {
        // We can't know they read it if we allow prefetches.
        if (isset($_SERVER['HTTP_X_MOZ']) && $_SERVER['HTTP_X_MOZ'] == 'prefetch') {
            ob_end_clean();
            header('HTTP/1.1 403 Prefetch Forbidden');
            die;
        }
        $smcFunc['db_insert']('replace', '{db_prefix}log_boards', array('id_msg' => 'int', 'id_member' => 'int', 'id_board' => 'int'), array($modSettings['maxMsgID'], $user_info['id'], $board), array('id_member', 'id_board'));
        if (!empty($board_info['parent_boards'])) {
            $smcFunc['db_query']('', '
				UPDATE {db_prefix}log_boards
				SET id_msg = {int:id_msg}
				WHERE id_member = {int:current_member}
					AND id_board IN ({array_int:board_list})', array('current_member' => $user_info['id'], 'board_list' => array_keys($board_info['parent_boards']), 'id_msg' => $modSettings['maxMsgID']));
            // We've seen all these boards now!
            foreach ($board_info['parent_boards'] as $k => $dummy) {
                if (isset($_SESSION['topicseen_cache'][$k])) {
                    unset($_SESSION['topicseen_cache'][$k]);
                }
            }
        }
        if (isset($_SESSION['topicseen_cache'][$board])) {
            unset($_SESSION['topicseen_cache'][$board]);
        }
        $request = $smcFunc['db_query']('', '
			SELECT sent
			FROM {db_prefix}log_notify
			WHERE id_board = {int:current_board}
				AND id_member = {int:current_member}
			LIMIT 1', array('current_board' => $board, 'current_member' => $user_info['id']));
        $context['is_marked_notify'] = $smcFunc['db_num_rows']($request) != 0;
        if ($context['is_marked_notify']) {
            list($sent) = $smcFunc['db_fetch_row']($request);
            if (!empty($sent)) {
                $smcFunc['db_query']('', '
					UPDATE {db_prefix}log_notify
					SET sent = {int:is_sent}
					WHERE id_board = {int:current_board}
						AND id_member = {int:current_member}', array('current_board' => $board, 'current_member' => $user_info['id'], 'is_sent' => 0));
            }
        }
        $smcFunc['db_free_result']($request);
    } else {
        $context['is_marked_notify'] = false;
    }
    // 'Print' the header and board info.
    $context['page_title'] = strip_tags($board_info['name']);
    // Set the variables up for the template.
    $context['can_mark_notify'] = allowedTo('mark_notify') && !$user_info['is_guest'];
    $context['can_post_new'] = allowedTo('post_new') || $modSettings['postmod_active'] && allowedTo('post_unapproved_topics');
    $context['can_post_poll'] = $modSettings['pollMode'] == '1' && allowedTo('poll_post') && $context['can_post_new'];
    $context['can_moderate_forum'] = allowedTo('moderate_forum');
    $context['can_approve_posts'] = allowedTo('approve_posts');
    require_once $sourcedir . '/Subs-BoardIndex.php';
    $boardIndexOptions = array('include_categories' => false, 'base_level' => $board_info['child_level'] + 1, 'parent_id' => $board_info['id'], 'set_latest_post' => false, 'countChildPosts' => !empty($modSettings['countChildPosts']));
    $context['boards'] = getBoardIndex($boardIndexOptions);
    // Nosey, nosey - who's viewing this topic?
    if (!empty($settings['display_who_viewing'])) {
        $context['view_members'] = array();
        $context['view_members_list'] = array();
        $context['view_num_hidden'] = 0;
        $request = $smcFunc['db_query']('', '
			SELECT
				lo.id_member, lo.log_time, mem.real_name, mem.member_name, mem.show_online,
				mg.online_color, mg.id_group, mg.group_name
			FROM {db_prefix}log_online AS lo
				LEFT JOIN {db_prefix}members AS mem ON (mem.id_member = lo.id_member)
				LEFT JOIN {db_prefix}membergroups AS mg ON (mg.id_group = CASE WHEN mem.id_group = {int:reg_member_group} THEN mem.id_post_group ELSE mem.id_group END)
			WHERE INSTR(lo.url, {string:in_url_string}) > 0 OR lo.session = {string:session}', array('reg_member_group' => 0, 'in_url_string' => 's:5:"board";i:' . $board . ';', 'session' => $user_info['is_guest'] ? 'ip' . $user_info['ip'] : session_id()));
        while ($row = $smcFunc['db_fetch_assoc']($request)) {
            if (empty($row['id_member'])) {
                continue;
            }
            if (!empty($row['online_color'])) {
                $link = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '" style="color: ' . $row['online_color'] . ';">' . $row['real_name'] . '</a>';
            } else {
                $link = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>';
            }
            $is_buddy = in_array($row['id_member'], $user_info['buddies']);
            if ($is_buddy) {
                $link = '<strong>' . $link . '</strong>';
            }
            if (!empty($row['show_online']) || allowedTo('moderate_forum')) {
                $context['view_members_list'][$row['log_time'] . $row['member_name']] = empty($row['show_online']) ? '<em>' . $link . '</em>' : $link;
            }
            $context['view_members'][$row['log_time'] . $row['member_name']] = array('id' => $row['id_member'], 'username' => $row['member_name'], 'name' => $row['real_name'], 'group' => $row['id_group'], 'href' => $scripturl . '?action=profile;u=' . $row['id_member'], 'link' => $link, 'is_buddy' => $is_buddy, 'hidden' => empty($row['show_online']));
            if (empty($row['show_online'])) {
                $context['view_num_hidden']++;
            }
        }
        $context['view_num_guests'] = $smcFunc['db_num_rows']($request) - count($context['view_members']);
        $smcFunc['db_free_result']($request);
        // Put them in "last clicked" order.
        krsort($context['view_members_list']);
        krsort($context['view_members']);
    }
    // Default sort methods.
    $sort_methods = array('subject' => 'mf.subject', 'starter' => 'IFNULL(memf.real_name, mf.poster_name)', 'last_poster' => 'IFNULL(meml.real_name, ml.poster_name)', 'replies' => 't.num_replies', 'views' => 't.num_views', 'first_post' => 't.id_topic', 'last_post' => 't.id_last_msg');
    // They didn't pick one, default to by last post descending.
    if (!isset($_REQUEST['sort']) || !isset($sort_methods[$_REQUEST['sort']])) {
        $context['sort_by'] = 'last_post';
        $_REQUEST['sort'] = 'id_last_msg';
        $ascending = isset($_REQUEST['asc']);
    } else {
        $context['sort_by'] = $_REQUEST['sort'];
        $_REQUEST['sort'] = $sort_methods[$_REQUEST['sort']];
        $ascending = !isset($_REQUEST['desc']);
    }
    $context['sort_direction'] = $ascending ? 'up' : 'down';
    // Calculate the fastest way to get the topics.
    $start = (int) $_REQUEST['start'];
    if ($start > ($board_info['total_topics'] - 1) / 2) {
        $ascending = !$ascending;
        $fake_ascending = true;
        $maxindex = $board_info['total_topics'] < $start + $maxindex + 1 ? $board_info['total_topics'] - $start : $maxindex;
        $start = $board_info['total_topics'] < $start + $maxindex + 1 ? 0 : $board_info['total_topics'] - $start - $maxindex;
    } else {
        $fake_ascending = false;
    }
    // Setup the default topic icons...
    $stable_icons = array('xx', 'thumbup', 'thumbdown', 'exclamation', 'question', 'lamp', 'smiley', 'angry', 'cheesy', 'grin', 'sad', 'wink', 'poll', 'moved', 'recycled', 'wireless', 'clip');
    $context['icon_sources'] = array();
    foreach ($stable_icons as $icon) {
        $context['icon_sources'][$icon] = 'images_url';
    }
    $topic_ids = array();
    $context['topics'] = array();
    // Sequential pages are often not optimized, so we add an additional query.
    $pre_query = $start > 0;
    if ($pre_query && $maxindex > 0) {
        $request = $smcFunc['db_query']('', '
			SELECT t.id_topic
			FROM {db_prefix}topics AS t' . ($context['sort_by'] === 'last_poster' ? '
				INNER JOIN {db_prefix}messages AS ml ON (ml.id_msg = t.id_last_msg)' : (in_array($context['sort_by'], array('starter', 'subject')) ? '
				INNER JOIN {db_prefix}messages AS mf ON (mf.id_msg = t.id_first_msg)' : '')) . ($context['sort_by'] === 'starter' ? '
				LEFT JOIN {db_prefix}members AS memf ON (memf.id_member = mf.id_member)' : '') . ($context['sort_by'] === 'last_poster' ? '
				LEFT JOIN {db_prefix}members AS meml ON (meml.id_member = ml.id_member)' : '') . '
			WHERE t.id_board = {int:current_board}' . (!$modSettings['postmod_active'] || $context['can_approve_posts'] ? '' : '
				AND (t.approved = {int:is_approved}' . ($user_info['is_guest'] ? '' : ' OR t.id_member_started = {int:current_member}') . ')') . '
			ORDER BY ' . (!empty($modSettings['enableStickyTopics']) ? 'is_sticky' . ($fake_ascending ? '' : ' DESC') . ', ' : '') . $_REQUEST['sort'] . ($ascending ? '' : ' DESC') . '
			LIMIT {int:start}, {int:maxindex}', array('current_board' => $board, 'current_member' => $user_info['id'], 'is_approved' => 1, 'id_member_guest' => 0, 'start' => $start, 'maxindex' => $maxindex));
        $topic_ids = array();
        while ($row = $smcFunc['db_fetch_assoc']($request)) {
            $topic_ids[] = $row['id_topic'];
        }
    }
    // Grab the appropriate topic information...
    if (!$pre_query || !empty($topic_ids)) {
        // For search engine effectiveness we'll link guests differently.
        $context['pageindex_multiplier'] = empty($modSettings['disableCustomPerPage']) && !empty($options['messages_per_page']) && !WIRELESS ? $options['messages_per_page'] : $modSettings['defaultMaxMessages'];
        $result = $smcFunc['db_query']('substring', '
			SELECT
				t.id_topic, t.num_replies, t.locked, t.num_views, t.is_sticky, t.id_poll, t.id_previous_board,
				' . ($user_info['is_guest'] ? '0' : 'IFNULL(lt.id_msg, IFNULL(lmr.id_msg, -1)) + 1') . ' AS new_from,
				t.id_last_msg, t.approved, t.unapproved_posts, t.id_redirect_topic, ml.poster_time AS last_poster_time,
				ml.id_msg_modified, ml.subject AS last_subject, ml.icon AS last_icon,
				ml.poster_name AS last_member_name, ml.id_member AS last_id_member, ' . (!empty($settings['avatars_on_indexes']) ? 'meml.avatar,' : '') . '
				IFNULL(meml.real_name, ml.poster_name) AS last_display_name, t.id_first_msg,
				mf.poster_time AS first_poster_time, mf.subject AS first_subject, mf.icon AS first_icon,
				mf.poster_name AS first_member_name, mf.id_member AS first_id_member,
				IFNULL(memf.real_name, mf.poster_name) AS first_display_name, ' . (!empty($modSettings['preview_characters']) ? '
				SUBSTRING(ml.body, 1, ' . ($modSettings['preview_characters'] + 256) . ') AS last_body,
				SUBSTRING(mf.body, 1, ' . ($modSettings['preview_characters'] + 256) . ') AS first_body,' : '') . 'ml.smileys_enabled AS last_smileys, mf.smileys_enabled AS first_smileys' . (!empty($settings['avatars_on_indexes']) ? ',
				IFNULL(a.id_attach, 0) AS id_attach, a.filename, a.attachment_type' : '') . '
			FROM {db_prefix}topics AS t
				INNER JOIN {db_prefix}messages AS ml ON (ml.id_msg = t.id_last_msg)
				INNER JOIN {db_prefix}messages AS mf ON (mf.id_msg = t.id_first_msg)
				LEFT JOIN {db_prefix}members AS meml ON (meml.id_member = ml.id_member)
				LEFT JOIN {db_prefix}members AS memf ON (memf.id_member = mf.id_member)' . ($user_info['is_guest'] ? '' : '
				LEFT JOIN {db_prefix}log_topics AS lt ON (lt.id_topic = t.id_topic AND lt.id_member = {int:current_member})
				LEFT JOIN {db_prefix}log_mark_read AS lmr ON (lmr.id_board = {int:current_board} AND lmr.id_member = {int:current_member})') . (!empty($settings['avatars_on_indexes']) ? '
				LEFT JOIN {db_prefix}attachments AS a ON (a.id_member = ml.id_member)' : '') . '
			WHERE ' . ($pre_query ? 't.id_topic IN ({array_int:topic_list})' : 't.id_board = {int:current_board}') . (!$modSettings['postmod_active'] || $context['can_approve_posts'] ? '' : '
				AND (t.approved = {int:is_approved}' . ($user_info['is_guest'] ? '' : ' OR t.id_member_started = {int:current_member}') . ')') . '
			ORDER BY ' . ($pre_query ? 'FIND_IN_SET(t.id_topic, {string:find_set_topics})' : (!empty($modSettings['enableStickyTopics']) ? 'is_sticky' . ($fake_ascending ? '' : ' DESC') . ', ' : '') . $_REQUEST['sort'] . ($ascending ? '' : ' DESC')) . '
			LIMIT ' . ($pre_query ? '' : '{int:start}, ') . '{int:maxindex}', array('current_board' => $board, 'current_member' => $user_info['id'], 'topic_list' => $topic_ids, 'is_approved' => 1, 'find_set_topics' => implode(',', $topic_ids), 'start' => $start, 'maxindex' => $maxindex));
        // Begin 'printing' the message index for current board.
        while ($row = $smcFunc['db_fetch_assoc']($result)) {
            if ($row['id_poll'] > 0 && $modSettings['pollMode'] == '0') {
                continue;
            }
            if (!$pre_query) {
                $topic_ids[] = $row['id_topic'];
            }
            // Does the theme support message previews?
            if (!empty($settings['message_index_preview']) && !empty($modSettings['preview_characters'])) {
                // Limit them to $modSettings['preview_characters'] characters
                $row['first_body'] = strip_tags(strtr(parse_bbc($row['first_body'], $row['first_smileys'], $row['id_first_msg']), array('<br />' => '&#10;')));
                if ($smcFunc['strlen']($row['first_body']) > $modSettings['preview_characters']) {
                    $row['first_body'] = $smcFunc['substr']($row['first_body'], 0, $modSettings['preview_characters']) . '...';
                }
                $row['last_body'] = strip_tags(strtr(parse_bbc($row['last_body'], $row['last_smileys'], $row['id_last_msg']), array('<br />' => '&#10;')));
                if ($smcFunc['strlen']($row['last_body']) > $modSettings['preview_characters']) {
                    $row['last_body'] = $smcFunc['substr']($row['last_body'], 0, $modSettings['preview_characters']) . '...';
                }
                // Censor the subject and message preview.
                censorText($row['first_subject']);
                censorText($row['first_body']);
                // Don't censor them twice!
                if ($row['id_first_msg'] == $row['id_last_msg']) {
                    $row['last_subject'] = $row['first_subject'];
                    $row['last_body'] = $row['first_body'];
                } else {
                    censorText($row['last_subject']);
                    censorText($row['last_body']);
                }
            } else {
                $row['first_body'] = '';
                $row['last_body'] = '';
                censorText($row['first_subject']);
                if ($row['id_first_msg'] == $row['id_last_msg']) {
                    $row['last_subject'] = $row['first_subject'];
                } else {
                    censorText($row['last_subject']);
                }
            }
            // Decide how many pages the topic should have.
            if ($row['num_replies'] + 1 > $context['messages_per_page']) {
                $pages = '&#171; ';
                // We can't pass start by reference.
                $start = -1;
                $pages .= constructPageIndex($scripturl . '?topic=' . $row['id_topic'] . '.%1$d', $start, $row['num_replies'] + 1, $context['messages_per_page'], true, false);
                // If we can use all, show all.
                if (!empty($modSettings['enableAllMessages']) && $row['num_replies'] + 1 < $modSettings['enableAllMessages']) {
                    $pages .= ' &nbsp;<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.0;all">' . $txt['all'] . '</a>';
                }
                $pages .= ' &#187;';
            } else {
                $pages = '';
            }
            // We need to check the topic icons exist...
            if (!empty($modSettings['messageIconChecks_enable'])) {
                if (!isset($context['icon_sources'][$row['first_icon']])) {
                    $context['icon_sources'][$row['first_icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['first_icon'] . '.png') ? 'images_url' : 'default_images_url';
                }
                if (!isset($context['icon_sources'][$row['last_icon']])) {
                    $context['icon_sources'][$row['last_icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['last_icon'] . '.png') ? 'images_url' : 'default_images_url';
                }
            } else {
                if (!isset($context['icon_sources'][$row['first_icon']])) {
                    $context['icon_sources'][$row['first_icon']] = 'images_url';
                }
                if (!isset($context['icon_sources'][$row['last_icon']])) {
                    $context['icon_sources'][$row['last_icon']] = 'images_url';
                }
            }
            if (!empty($settings['avatars_on_indexes'])) {
                // Allow themers to show the latest poster's avatar along with the topic
                if (!empty($row['avatar'])) {
                    if ($modSettings['avatar_action_too_large'] == 'option_html_resize' || $modSettings['avatar_action_too_large'] == 'option_js_resize') {
                        $avatar_width = !empty($modSettings['avatar_max_width_external']) ? ' width="' . $modSettings['avatar_max_width_external'] . '"' : '';
                        $avatar_height = !empty($modSettings['avatar_max_height_external']) ? ' height="' . $modSettings['avatar_max_height_external'] . '"' : '';
                    } else {
                        $avatar_width = '';
                        $avatar_height = '';
                    }
                }
            }
            // 'Print' the topic info.
            $context['topics'][$row['id_topic']] = array('id' => $row['id_topic'], 'first_post' => array('id' => $row['id_first_msg'], 'member' => array('username' => $row['first_member_name'], 'name' => $row['first_display_name'], 'id' => $row['first_id_member'], 'href' => !empty($row['first_id_member']) ? $scripturl . '?action=profile;u=' . $row['first_id_member'] : '', 'link' => !empty($row['first_id_member']) ? '<a href="' . $scripturl . '?action=profile;u=' . $row['first_id_member'] . '" title="' . $txt['profile_of'] . ' ' . $row['first_display_name'] . '" class="preview">' . $row['first_display_name'] . '</a>' : $row['first_display_name']), 'time' => timeformat($row['first_poster_time']), 'timestamp' => forum_time(true, $row['first_poster_time']), 'subject' => $row['first_subject'], 'preview' => $row['first_body'], 'icon' => $row['first_icon'], 'icon_url' => $settings[$context['icon_sources'][$row['first_icon']]] . '/post/' . $row['first_icon'] . '.png', 'href' => $scripturl . '?topic=' . (empty($row['id_redirect_topic']) ? $row['id_topic'] : $row['id_redirect_topic']) . '.0', 'link' => '<a href="' . $scripturl . '?topic=' . (empty($row['id_redirect_topic']) ? $row['id_topic'] : $row['id_redirect_topic']) . '.0">' . $row['first_subject'] . '</a>'), 'last_post' => array('id' => $row['id_last_msg'], 'member' => array('username' => $row['last_member_name'], 'name' => $row['last_display_name'], 'id' => $row['last_id_member'], 'href' => !empty($row['last_id_member']) ? $scripturl . '?action=profile;u=' . $row['last_id_member'] : '', 'link' => !empty($row['last_id_member']) ? '<a href="' . $scripturl . '?action=profile;u=' . $row['last_id_member'] . '">' . $row['last_display_name'] . '</a>' : $row['last_display_name']), 'time' => timeformat($row['last_poster_time']), 'timestamp' => forum_time(true, $row['last_poster_time']), 'subject' => $row['last_subject'], 'preview' => $row['last_body'], 'icon' => $row['last_icon'], 'icon_url' => $settings[$context['icon_sources'][$row['last_icon']]] . '/post/' . $row['last_icon'] . '.png', 'href' => $scripturl . '?topic=' . (empty($row['id_redirect_topic']) ? $row['id_topic'] : $row['id_redirect_topic']) . ($user_info['is_guest'] ? '.' . (!empty($options['view_newest_first']) ? 0 : (int) ($row['num_replies'] / $context['pageindex_multiplier']) * $context['pageindex_multiplier']) . '#msg' . $row['id_last_msg'] : ($row['num_replies'] == 0 ? '.0' : '.msg' . $row['id_last_msg']) . '#new'), 'link' => '<a href="' . $scripturl . '?topic=' . (empty($row['id_redirect_topic']) ? $row['id_topic'] : $row['id_redirect_topic']) . ($user_info['is_guest'] ? '.' . (!empty($options['view_newest_first']) ? 0 : (int) ($row['num_replies'] / $context['pageindex_multiplier']) * $context['pageindex_multiplier']) . '#msg' . $row['id_last_msg'] : ($row['num_replies'] == 0 ? '.0' : '.msg' . $row['id_last_msg']) . '#new') . '" ' . ($row['num_replies'] == 0 ? '' : 'rel="nofollow"') . '>' . $row['last_subject'] . '</a>'), 'is_sticky' => !empty($modSettings['enableStickyTopics']) && !empty($row['is_sticky']), 'is_locked' => !empty($row['locked']), 'is_poll' => $modSettings['pollMode'] == '1' && $row['id_poll'] > 0, 'is_hot' => $row['num_replies'] >= $modSettings['hotTopicPosts'], 'is_very_hot' => $row['num_replies'] >= $modSettings['hotTopicVeryPosts'], 'is_posted_in' => false, 'icon' => $row['first_icon'], 'icon_url' => $settings[$context['icon_sources'][$row['first_icon']]] . '/post/' . $row['first_icon'] . '.png', 'subject' => $row['first_subject'], 'new' => $row['new_from'] <= $row['id_msg_modified'], 'new_from' => $row['new_from'], 'newtime' => $row['new_from'], 'new_href' => $scripturl . '?topic=' . (empty($row['id_redirect_topic']) ? $row['id_topic'] : $row['id_redirect_topic']) . '.msg' . $row['new_from'] . '#new', 'pages' => $pages, 'replies' => comma_format($row['num_replies']), 'views' => comma_format($row['num_views']), 'approved' => $row['approved'], 'unapproved_posts' => $row['unapproved_posts']);
            if (!empty($settings['avatars_on_indexes'])) {
                $context['topics'][$row['id_topic']]['last_post']['member']['avatar'] = array('name' => $row['avatar'], 'image' => $row['avatar'] == '' ? $row['id_attach'] > 0 ? '<img class="avatar" src="' . (empty($row['attachment_type']) ? $scripturl . '?action=dlattach;attach=' . $row['id_attach'] . ';type=avatar' : $modSettings['custom_avatar_url'] . '/' . $row['filename']) . '" alt="" />' : '' : (stristr($row['avatar'], 'http://') ? '<img class="avatar" src="' . $row['avatar'] . '"' . $avatar_width . $avatar_height . ' alt="" />' : '<img class="avatar" src="' . $modSettings['avatar_url'] . '/' . htmlspecialchars($row['avatar']) . '" alt="" />'), 'href' => $row['avatar'] == '' ? $row['id_attach'] > 0 ? empty($row['attachment_type']) ? $scripturl . '?action=dlattach;attach=' . $row['id_attach'] . ';type=avatar' : $modSettings['custom_avatar_url'] . '/' . $row['filename'] : '' : (stristr($row['avatar'], 'http://') ? $row['avatar'] : $modSettings['avatar_url'] . '/' . $row['avatar']), 'url' => $row['avatar'] == '' ? '' : (stristr($row['avatar'], 'http://') ? $row['avatar'] : $modSettings['avatar_url'] . '/' . $row['avatar']));
            }
            determineTopicClass($context['topics'][$row['id_topic']]);
        }
        $smcFunc['db_free_result']($result);
        // Fix the sequence of topics if they were retrieved in the wrong order. (for speed reasons...)
        if ($fake_ascending) {
            $context['topics'] = array_reverse($context['topics'], true);
        }
        if (!empty($modSettings['enableParticipation']) && !$user_info['is_guest'] && !empty($topic_ids)) {
            $result = $smcFunc['db_query']('', '
				SELECT id_topic
				FROM {db_prefix}messages
				WHERE id_topic IN ({array_int:topic_list})
					AND id_member = {int:current_member}
				GROUP BY id_topic
				LIMIT ' . count($topic_ids), array('current_member' => $user_info['id'], 'topic_list' => $topic_ids));
            while ($row = $smcFunc['db_fetch_assoc']($result)) {
                $context['topics'][$row['id_topic']]['is_posted_in'] = true;
                $context['topics'][$row['id_topic']]['class'] = 'my_' . $context['topics'][$row['id_topic']]['class'];
            }
            $smcFunc['db_free_result']($result);
        }
    }
    $context['jump_to'] = array('label' => addslashes(un_htmlspecialchars($txt['jump_to'])), 'board_name' => htmlspecialchars(strtr(strip_tags($board_info['name']), array('&amp;' => '&'))), 'child_level' => $board_info['child_level']);
    // Is Quick Moderation active/needed?
    if (!empty($options['display_quick_mod']) && !empty($context['topics'])) {
        $context['can_markread'] = $context['user']['is_logged'];
        $context['can_lock'] = allowedTo('lock_any');
        $context['can_sticky'] = allowedTo('make_sticky') && !empty($modSettings['enableStickyTopics']);
        $context['can_move'] = allowedTo('move_any');
        $context['can_remove'] = allowedTo('remove_any');
        $context['can_merge'] = allowedTo('merge_any');
        // Ignore approving own topics as it's unlikely to come up...
        $context['can_approve'] = $modSettings['postmod_active'] && allowedTo('approve_posts') && !empty($board_info['unapproved_topics']);
        // Can we restore topics?
        $context['can_restore'] = allowedTo('move_any') && !empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] == $board;
        // Set permissions for all the topics.
        foreach ($context['topics'] as $t => $topic) {
            $started = $topic['first_post']['member']['id'] == $user_info['id'];
            $context['topics'][$t]['quick_mod'] = array('lock' => allowedTo('lock_any') || $started && allowedTo('lock_own'), 'sticky' => allowedTo('make_sticky') && !empty($modSettings['enableStickyTopics']), 'move' => allowedTo('move_any') || $started && allowedTo('move_own'), 'modify' => allowedTo('modify_any') || $started && allowedTo('modify_own'), 'remove' => allowedTo('remove_any') || $started && allowedTo('remove_own'), 'approve' => $context['can_approve'] && $topic['unapproved_posts']);
            $context['can_lock'] |= $started && allowedTo('lock_own');
            $context['can_move'] |= $started && allowedTo('move_own');
            $context['can_remove'] |= $started && allowedTo('remove_own');
        }
        // Find the boards/cateogories they can move their topic to.
        if ($options['display_quick_mod'] == 1 && $context['can_move'] && !empty($context['topics'])) {
            require_once $sourcedir . '/Subs-MessageIndex.php';
            $boardListOptions = array('excluded_boards' => array($board), 'not_redirection' => true, 'use_permissions' => true, 'selected_board' => empty($_SESSION['move_to_topic']) ? null : $_SESSION['move_to_topic']);
            // With no other boards to see, it's useless to move.
            if (empty($context['move_to_boards'])) {
                $context['can_move'] = false;
            }
        }
        // Can we use quick moderation checkboxes?
        if ($options['display_quick_mod'] == 1) {
            $context['can_quick_mod'] = $context['user']['is_logged'] || $context['can_approve'] || $context['can_remove'] || $context['can_lock'] || $context['can_sticky'] || $context['can_move'] || $context['can_merge'] || $context['can_restore'];
        } else {
            $context['can_quick_mod'] = $context['can_remove'] || $context['can_lock'] || $context['can_sticky'] || $context['can_move'];
        }
    }
    if (!empty($context['can_quick_mod']) && $options['display_quick_mod'] == 1) {
        $context['qmod_actions'] = array('approve', 'remove', 'lock', 'sticky', 'move', 'merge', 'restore', 'markread');
        call_integration_hook('integrate_quick_mod_actions');
    }
    // If there are children, but no topics and no ability to post topics...
    $context['no_topic_listing'] = !empty($context['boards']) && empty($context['topics']) && !$context['can_post_new'];
    // Build the message index button array.
    $context['normal_buttons'] = array('new_topic' => array('test' => 'can_post_new', 'text' => 'new_topic', 'image' => 'new_topic.png', 'lang' => true, 'url' => $scripturl . '?action=post;board=' . $context['current_board'] . '.0', 'active' => true), 'post_poll' => array('test' => 'can_post_poll', 'text' => 'new_poll', 'image' => 'new_poll.png', 'lang' => true, 'url' => $scripturl . '?action=post;board=' . $context['current_board'] . '.0;poll'), '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 confirm(\'' . ($context['is_marked_notify'] ? $txt['notification_disable_board'] : $txt['notification_enable_board']) . '\');"', 'url' => $scripturl . '?action=notifyboard;sa=' . ($context['is_marked_notify'] ? 'off' : 'on') . ';board=' . $context['current_board'] . '.' . $context['start'] . ';' . $context['session_var'] . '=' . $context['session_id']), 'markread' => array('text' => 'mark_read_short', 'image' => 'markread.png', 'lang' => true, 'url' => $scripturl . '?action=markasread;sa=board;board=' . $context['current_board'] . '.0;' . $context['session_var'] . '=' . $context['session_id']));
    // Allow adding new buttons easily.
    call_integration_hook('integrate_messageindex_buttons');
}
Пример #28
0
/**
 * Set some general membergroup settings and permissions.
 * Called by ?action=admin;area=membergroups;sa=settings
 * Requires the admin_forum permission (and manage_permissions for changing permissions)
 * Redirects to itself.
 *
 * @uses membergroup_settings sub template of ManageMembergroups.
 */
function ModifyMembergroupsettings()
{
    global $context, $sourcedir, $scripturl, $modSettings, $txt;
    $context['sub_template'] = 'show_settings';
    $context['page_title'] = $txt['membergroups_settings'];
    // Needed for the settings functions.
    require_once $sourcedir . '/ManageServer.php';
    // Don't allow assignment of guests.
    $context['permissions_excluded'] = array(-1);
    // Only one thing here!
    $config_vars = array(array('permissions', 'manage_membergroups'));
    call_integration_hook('integrate_modify_membergroup_settings', array(&$config_vars));
    if (isset($_REQUEST['save'])) {
        checkSession();
        call_integration_hook('integrate_save_membergroup_settings');
        // Yeppers, saving this...
        saveDBSettings($config_vars);
        redirectexit('action=admin;area=membergroups;sa=settings');
    }
    // Some simple context.
    $context['post_url'] = $scripturl . '?action=admin;area=membergroups;save;sa=settings';
    $context['settings_title'] = $txt['membergroups_settings'];
    // We need this for the in-line permissions
    createToken('admin-mp');
    prepareDBSettingContext($config_vars);
}
Пример #29
0
 /**
  * Get the settings of the forum related to news.
  */
 private function _settings()
 {
     global $txt;
     $config_vars = array(array('title', 'settings'), array('permissions', 'edit_news', 'help' => ''), array('permissions', 'send_mail'), '', array('check', 'xmlnews_enable', 'onclick' => 'document.getElementById(\'xmlnews_maxlen\').disabled = !this.checked;document.getElementById(\'xmlnews_limit\').disabled = !this.checked;'), array('int', 'xmlnews_maxlen', 'subtext' => $txt['xmlnews_maxlen_note'], 10), array('int', 'xmlnews_limit', 'subtext' => $txt['xmlnews_limit_note'], 10));
     // Add new settings with a nice hook, makes them available for admin settings search as well
     call_integration_hook('integrate_modify_news_settings', array(&$config_vars));
     return $config_vars;
 }
Пример #30
0
 /**
  * Return admin configuration settings for posts.
  */
 private function _settings()
 {
     global $txt;
     // Initialize it with our settings
     $config_vars = array(array('check', 'removeNestedQuotes'), array('check', 'enableVideoEmbeding'), array('check', 'enableCodePrettify'), array('check', 'enableSpellChecking', 'postinput' => function_exists('pspell_new') ? $txt['enableSpellChecking_warning'] : '<span class="error">' . $txt['enableSpellChecking_error'] . '</span>'), '', array('int', 'max_messageLength', 'subtext' => $txt['max_messageLength_zero'], 'postinput' => $txt['manageposts_characters']), array('int', 'topicSummaryPosts', 'postinput' => $txt['manageposts_posts']), '', array('int', 'spamWaitTime', 'postinput' => $txt['manageposts_seconds']), array('int', 'edit_wait_time', 'postinput' => $txt['manageposts_seconds']), array('int', 'edit_disable_time', 'subtext' => $txt['edit_disable_time_zero'], 'postinput' => $txt['manageposts_minutes']), '', array('select', 'message_index_preview', array($txt['message_index_preview_off'], $txt['message_index_preview_first'], $txt['message_index_preview_last'])), array('int', 'preview_characters', 'subtext' => $txt['preview_characters_zero'], 'postinput' => $txt['preview_characters_units']));
     // Add new settings with a nice hook, makes them available for admin settings search as well
     call_integration_hook('integrate_modify_post_settings', array(&$config_vars));
     return $config_vars;
 }