Ejemplo n.º 1
0
 function process_request($request)
 {
     $userid = qa_get_logged_in_userid();
     $categoryid = mp_get_categoryid();
     $users = mp_get_category_userids($categoryid);
     $qa_content = qa_content_prepare();
     $qa_content['title'] = 'Classroom';
     $data = "<div class='mp-classroom'>";
     $data .= "<center><div class='mp-classroom-teacher'>&nbsp;</div></center>";
     $data .= "<div class='mp-classroom-users'>";
     foreach ($users as $user) {
         $userinfo = qa_db_select_with_pending(qa_db_user_account_selectspec($user['userid'], true));
         $data .= "<div class='mp-classroom-user'>";
         $data .= "<div class='mp-classroom-avatar'></div>";
         $data .= "<div class='mp-classroom-useremail'>" . qa_get_one_user_html($userinfo['handle'], false) . "</div>";
         $data .= "</div>";
     }
     $data .= "</div></div>";
     $qa_content['custom'] = $data;
     return $qa_content;
 }
            } else {
                $pageerror = qa_lang_html('main/general_error');
            }
            qa_report_event('u_message', $loginuserid, qa_get_logged_in_handle(), qa_cookie_get(), array('userid' => $toaccount['userid'], 'handle' => $toaccount['handle'], 'messageid' => $messageid, 'message' => $inmessage));
            if ($messagesent && qa_opt('show_message_history')) {
                // show message as part of general history
                qa_redirect(qa_request(), array('state' => 'message-sent'));
            }
        }
    }
}
//	Prepare content for theme
$qa_content = qa_content_prepare();
$qa_content['title'] = qa_lang_html('misc/private_message_title');
$qa_content['error'] = @$pageerror;
$qa_content['form_message'] = array('tags' => 'method="post" action="' . qa_self_html() . '"', 'style' => 'tall', 'fields' => array('message' => array('type' => $messagesent ? 'static' : '', 'label' => qa_lang_html_sub('misc/message_for_x', qa_get_one_user_html($handle, false)), 'tags' => 'name="message" id="message"', 'value' => qa_html(@$inmessage, $messagesent), 'rows' => 8, 'note' => qa_lang_html_sub('misc/message_explanation', qa_html(qa_opt('site_title'))), 'error' => qa_html(@$errors['message']))), 'buttons' => array('send' => array('tags' => 'onclick="qa_show_waiting_after(this, false);"', 'label' => qa_lang_html('main/send_button'))), 'hidden' => array('domessage' => '1', 'code' => qa_get_form_security_code('message-' . $handle)));
$qa_content['focusid'] = 'message';
if ($messagesent) {
    $qa_content['form_message']['ok'] = qa_lang_html('misc/message_sent');
    unset($qa_content['form_message']['buttons']);
    if (qa_opt('show_message_history')) {
        unset($qa_content['form_message']['fields']['message']);
    } else {
        unset($qa_content['form_message']['fields']['message']['note']);
        unset($qa_content['form_message']['fields']['message']['label']);
    }
}
//	If relevant, show recent message history
if (qa_opt('show_message_history')) {
    $recent = array_merge($torecent, $fromrecent);
    qa_sort_by($recent, 'created');
Ejemplo n.º 3
0
function qa_message_html_fields($message, $options = array())
{
    require_once QA_INCLUDE_DIR . 'app/users.php';
    if (qa_to_override(__FUNCTION__)) {
        $args = func_get_args();
        return qa_call_override(__FUNCTION__, $args);
    }
    $fields = array('raw' => $message);
    $fields['tags'] = 'id="m' . qa_html($message['messageid']) . '"';
    //	Message content
    $viewer = qa_load_viewer($message['content'], $message['format']);
    $fields['content'] = $viewer->get_html($message['content'], $message['format'], array('blockwordspreg' => @$options['blockwordspreg'], 'showurllinks' => @$options['showurllinks'], 'linksnewwindow' => @$options['linksnewwindow']));
    //	Set ordering of meta elements which can be language-specific
    $fields['meta_order'] = qa_lang_html('main/meta_order');
    $fields['what'] = qa_lang_html('main/written');
    //	When it was written
    if (@$options['whenview']) {
        $fields['when'] = qa_when_to_html($message['created'], @$options['fulldatedays']);
    }
    //	Who wrote it, and their avatar
    if (@$options['towhomview']) {
        // for sent private messages page (i.e. show who message was sent to)
        $fields['who'] = qa_lang_html_sub_split('main/to_x', qa_get_one_user_html($message['tohandle'], false));
        $fields['avatar'] = qa_get_user_avatar_html(@$message['toflags'], @$message['toemail'], @$message['tohandle'], @$message['toavatarblobid'], @$message['toavatarwidth'], @$message['toavatarheight'], $options['avatarsize']);
    } else {
        // for everything else (received private messages, wall messages)
        if (@$options['whoview']) {
            $fields['who'] = qa_lang_html_sub_split('main/by_x', qa_get_one_user_html($message['fromhandle'], false));
        }
        if (@$options['avatarsize'] > 0) {
            $fields['avatar'] = qa_get_user_avatar_html(@$message['fromflags'], @$message['fromemail'], @$message['fromhandle'], @$message['fromavatarblobid'], @$message['fromavatarwidth'], @$message['fromavatarheight'], $options['avatarsize']);
        }
    }
    //	That's it!
    return $fields;
}
Ejemplo n.º 4
0
    }
    if (empty($errors)) {
        require_once QA_INCLUDE_DIR . 'qa-app-emails.php';
        $fromhandle = qa_get_logged_in_handle();
        $canreply = !(qa_get_logged_in_flags() & QA_USER_FLAGS_NO_MESSAGES);
        $more = strtr(qa_lang($canreply ? 'emails/private_message_reply' : 'emails/private_message_info'), array('^f_handle' => $fromhandle, '^url' => qa_path($canreply ? 'message/' . $fromhandle : 'user/' . $fromhandle, null, qa_opt('site_url'))));
        $subs = array('^message' => $inmessage, '^f_handle' => $fromhandle, '^f_url' => qa_path('user/' . $fromhandle, null, qa_opt('site_url')), '^more' => $more, '^a_url' => qa_path_html('account', null, qa_opt('site_url')));
        if (qa_send_notification($useraccount['userid'], $useraccount['email'], $useraccount['handle'], qa_lang('emails/private_message_subject'), qa_lang('emails/private_message_body'), $subs)) {
            $messagesent = true;
        } else {
            $page_error = qa_lang_html('main/general_error');
        }
        qa_limits_increment($qa_login_userid, 'M');
        qa_report_event('u_message', $qa_login_userid, qa_get_logged_in_handle(), $qa_cookieid, array('userid' => $useraccount['userid'], 'handle' => $useraccount['handle'], 'message' => $inmessage));
    }
}
//	Prepare content for theme
$qa_content = qa_content_prepare();
$qa_content['title'] = qa_lang_html('misc/private_message_title');
$qa_content['error'] = @$page_error;
$qa_content['form'] = array('tags' => 'METHOD="POST" ACTION="' . qa_self_html() . '"', 'style' => 'tall', 'fields' => array('message' => array('type' => $messagesent ? 'static' : '', 'label' => qa_lang_html_sub('misc/message_for_x', qa_get_one_user_html($handle, false)), 'tags' => 'NAME="message" ID="message"', 'value' => qa_html(@$inmessage, $messagesent), 'rows' => 16, 'note' => qa_lang_html_sub('misc/message_explanation', qa_html(qa_opt('site_title'))), 'error' => qa_html(@$errors['message']))), 'buttons' => array('send' => array('label' => qa_lang_html('main/send_button'))), 'hidden' => array('domessage' => '1'));
$qa_content['focusid'] = 'message';
if ($messagesent) {
    $qa_content['form']['ok'] = qa_lang_html('misc/message_sent');
    unset($qa_content['form']['fields']['message']['note']);
    unset($qa_content['form']['buttons']);
}
return $qa_content;
/*
	Omit PHP closing tag to help avoid accidental output
*/
Ejemplo n.º 5
0
function qa_content_prepare($voting = false, $categoryids = null)
{
    if (qa_to_override(__FUNCTION__)) {
        $args = func_get_args();
        return qa_call_override(__FUNCTION__, $args);
    }
    global $qa_template, $qa_page_error_html;
    if (QA_DEBUG_PERFORMANCE) {
        global $qa_usage;
        $qa_usage->mark('control');
    }
    $request = qa_request();
    $requestlower = qa_request();
    $navpages = qa_db_get_pending_result('navpages');
    $widgets = qa_db_get_pending_result('widgets');
    if (isset($categoryids) && !is_array($categoryids)) {
        // accept old-style parameter
        $categoryids = array($categoryids);
    }
    $lastcategoryid = count($categoryids) ? end($categoryids) : null;
    $charset = 'utf-8';
    $qa_content = array('content_type' => 'text/html; charset=' . $charset, 'charset' => $charset, 'direction' => qa_opt('site_text_direction'), 'site_title' => qa_html(qa_opt('site_title')), 'head_lines' => array(), 'navigation' => array('user' => array(), 'main' => array(), 'footer' => array('feedback' => array('url' => qa_path_html('feedback'), 'label' => qa_lang_html('main/nav_feedback')))), 'sidebar' => qa_opt('show_custom_sidebar') ? qa_opt('custom_sidebar') : null, 'sidepanel' => qa_opt('show_custom_sidepanel') ? qa_opt('custom_sidepanel') : null, 'widgets' => array());
    if (qa_opt('show_custom_in_head')) {
        $qa_content['head_lines'][] = qa_opt('custom_in_head');
    }
    if (qa_opt('show_custom_header')) {
        $qa_content['body_header'] = qa_opt('custom_header');
    }
    if (qa_opt('show_custom_footer')) {
        $qa_content['body_footer'] = qa_opt('custom_footer');
    }
    if (isset($categoryids)) {
        $qa_content['categoryids'] = $categoryids;
    }
    foreach ($navpages as $page) {
        if ($page['nav'] == 'B') {
            qa_navigation_add_page($qa_content['navigation']['main'], $page);
        }
    }
    if (qa_opt('nav_home') && qa_opt('show_custom_home')) {
        $qa_content['navigation']['main']['$'] = array('url' => qa_path_html(''), 'label' => qa_lang_html('main/nav_home'));
    }
    if (qa_opt('nav_activity')) {
        $qa_content['navigation']['main']['activity'] = array('url' => qa_path_html('activity'), 'label' => qa_lang_html('main/nav_activity'));
    }
    $hascustomhome = qa_has_custom_home();
    if (qa_opt($hascustomhome ? 'nav_qa_not_home' : 'nav_qa_is_home')) {
        $qa_content['navigation']['main'][$hascustomhome ? 'qa' : '$'] = array('url' => qa_path_html($hascustomhome ? 'qa' : ''), 'label' => qa_lang_html('main/nav_qa'));
    }
    if (qa_opt('nav_questions')) {
        $qa_content['navigation']['main']['questions'] = array('url' => qa_path_html('questions'), 'label' => qa_lang_html('main/nav_qs'));
    }
    if (qa_opt('nav_hot')) {
        $qa_content['navigation']['main']['hot'] = array('url' => qa_path_html('hot'), 'label' => qa_lang_html('main/nav_hot'));
    }
    if (qa_opt('nav_unanswered')) {
        $qa_content['navigation']['main']['unanswered'] = array('url' => qa_path_html('unanswered'), 'label' => qa_lang_html('main/nav_unanswered'));
    }
    if (qa_using_tags() && qa_opt('nav_tags')) {
        $qa_content['navigation']['main']['tag'] = array('url' => qa_path_html('tags'), 'label' => qa_lang_html('main/nav_tags'), 'selected_on' => array('tags$', 'tag/'));
    }
    if (qa_using_categories() && qa_opt('nav_categories')) {
        $qa_content['navigation']['main']['categories'] = array('url' => qa_path_html('categories'), 'label' => qa_lang_html('main/nav_categories'), 'selected_on' => array('categories$', 'categories/'));
    }
    if (qa_opt('nav_users')) {
        $qa_content['navigation']['main']['user'] = array('url' => qa_path_html('users'), 'label' => qa_lang_html('main/nav_users'), 'selected_on' => array('users$', 'users/', 'user/'));
    }
    // Only the 'level' permission error prevents the menu option being shown - others reported on qa-page-ask.php
    if (qa_opt('nav_ask') && qa_user_maximum_permit_error('permit_post_q') != 'level') {
        $qa_content['navigation']['main']['ask'] = array('url' => qa_path_html('ask', qa_using_categories() && strlen($lastcategoryid) ? array('cat' => $lastcategoryid) : null), 'label' => qa_lang_html('main/nav_ask'));
    }
    if (qa_get_logged_in_level() >= QA_USER_LEVEL_ADMIN || !qa_user_maximum_permit_error('permit_moderate') || !qa_user_maximum_permit_error('permit_hide_show') || !qa_user_maximum_permit_error('permit_delete_hidden')) {
        $qa_content['navigation']['main']['admin'] = array('url' => qa_path_html('admin'), 'label' => qa_lang_html('main/nav_admin'), 'selected_on' => array('admin/'));
    }
    $qa_content['search'] = array('form_tags' => 'method="get" action="' . qa_path_html('search') . '"', 'form_extra' => qa_path_form_html('search'), 'title' => qa_lang_html('main/search_title'), 'field_tags' => 'name="q"', 'button_label' => qa_lang_html('main/search_button'));
    if (!qa_opt('feedback_enabled')) {
        unset($qa_content['navigation']['footer']['feedback']);
    }
    foreach ($navpages as $page) {
        if ($page['nav'] == 'M' || $page['nav'] == 'O' || $page['nav'] == 'F') {
            qa_navigation_add_page($qa_content['navigation'][$page['nav'] == 'F' ? 'footer' : 'main'], $page);
        }
    }
    $regioncodes = array('F' => 'full', 'M' => 'main', 'S' => 'side');
    $placecodes = array('T' => 'top', 'H' => 'high', 'L' => 'low', 'B' => 'bottom');
    foreach ($widgets as $widget) {
        if (is_numeric(strpos(',' . $widget['tags'] . ',', ',' . $qa_template . ',')) || is_numeric(strpos(',' . $widget['tags'] . ',', ',all,'))) {
            // see if it has been selected for display on this template
            $region = @$regioncodes[substr($widget['place'], 0, 1)];
            $place = @$placecodes[substr($widget['place'], 1, 2)];
            if (isset($region) && isset($place)) {
                // check region/place codes recognized
                $module = qa_load_module('widget', $widget['title']);
                if (isset($module) && method_exists($module, 'allow_template') && $module->allow_template(substr($qa_template, 0, 7) == 'custom-' ? 'custom' : $qa_template) && method_exists($module, 'allow_region') && $module->allow_region($region) && method_exists($module, 'output_widget')) {
                    $qa_content['widgets'][$region][$place][] = $module;
                }
                // if module loaded and happy to be displayed here, tell theme about it
            }
        }
    }
    $logoshow = qa_opt('logo_show');
    $logourl = qa_opt('logo_url');
    $logowidth = qa_opt('logo_width');
    $logoheight = qa_opt('logo_height');
    if ($logoshow) {
        $qa_content['logo'] = '<a href="' . qa_path_html('') . '" class="qa-logo-link" title="' . qa_html(qa_opt('site_title')) . '">' . '<img src="' . qa_html(is_numeric(strpos($logourl, '://')) ? $logourl : qa_path_to_root() . $logourl) . '"' . ($logowidth ? ' width="' . $logowidth . '"' : '') . ($logoheight ? ' height="' . $logoheight . '"' : '') . ' border="0" alt="' . qa_html(qa_opt('site_title')) . '"/></a>';
    } else {
        $qa_content['logo'] = '<a href="' . qa_path_html('') . '" class="qa-logo-link">' . qa_html(qa_opt('site_title')) . '</a>';
    }
    $topath = qa_get('to');
    // lets user switch between login and register without losing destination page
    $userlinks = qa_get_login_links(qa_path_to_root(), isset($topath) ? $topath : qa_path($request, $_GET, ''));
    $qa_content['navigation']['user'] = array();
    if (qa_is_logged_in()) {
        $qa_content['loggedin'] = qa_lang_html_sub_split('main/logged_in_x', QA_FINAL_EXTERNAL_USERS ? qa_get_logged_in_user_html(qa_get_logged_in_user_cache(), qa_path_to_root(), false) : qa_get_one_user_html(qa_get_logged_in_handle(), false));
        $qa_content['navigation']['user']['updates'] = array('url' => qa_path_html('updates'), 'label' => qa_lang_html('main/nav_updates'));
        if (!empty($userlinks['logout'])) {
            $qa_content['navigation']['user']['logout'] = array('url' => qa_html(@$userlinks['logout']), 'label' => qa_lang_html('main/nav_logout'));
        }
        if (!QA_FINAL_EXTERNAL_USERS) {
            $source = qa_get_logged_in_source();
            if (strlen($source)) {
                $loginmodules = qa_load_modules_with('login', 'match_source');
                foreach ($loginmodules as $module) {
                    if ($module->match_source($source) && method_exists($module, 'logout_html')) {
                        ob_start();
                        $module->logout_html(qa_path('logout', array(), qa_opt('site_url')));
                        $qa_content['navigation']['user']['logout'] = array('label' => ob_get_clean());
                    }
                }
            }
        }
        $notices = qa_db_get_pending_result('notices');
        foreach ($notices as $notice) {
            $qa_content['notices'][] = qa_notice_form($notice['noticeid'], qa_viewer_html($notice['content'], $notice['format']), $notice);
        }
    } else {
        require_once QA_INCLUDE_DIR . 'util/string.php';
        if (!QA_FINAL_EXTERNAL_USERS) {
            $loginmodules = qa_load_modules_with('login', 'login_html');
            foreach ($loginmodules as $tryname => $module) {
                ob_start();
                $module->login_html(isset($topath) ? qa_opt('site_url') . $topath : qa_path($request, $_GET, qa_opt('site_url')), 'menu');
                $label = ob_get_clean();
                if (strlen($label)) {
                    $qa_content['navigation']['user'][implode('-', qa_string_to_words($tryname))] = array('label' => $label);
                }
            }
        }
        if (!empty($userlinks['login'])) {
            $qa_content['navigation']['user']['login'] = array('url' => qa_html(@$userlinks['login']), 'label' => qa_lang_html('main/nav_login'));
        }
        if (!empty($userlinks['register'])) {
            $qa_content['navigation']['user']['register'] = array('url' => qa_html(@$userlinks['register']), 'label' => qa_lang_html('main/nav_register'));
        }
    }
    if (QA_FINAL_EXTERNAL_USERS || !qa_is_logged_in()) {
        if (qa_opt('show_notice_visitor') && !isset($topath) && !isset($_COOKIE['qa_noticed'])) {
            $qa_content['notices'][] = qa_notice_form('visitor', qa_opt('notice_visitor'));
        }
    } else {
        setcookie('qa_noticed', 1, time() + 86400 * 3650, '/', QA_COOKIE_DOMAIN);
        // don't show first-time notice if a user has logged in
        if (qa_opt('show_notice_welcome') && qa_get_logged_in_flags() & QA_USER_FLAGS_WELCOME_NOTICE) {
            if ($requestlower != 'confirm' && $requestlower != 'account') {
                // let people finish registering in peace
                $qa_content['notices'][] = qa_notice_form('welcome', qa_opt('notice_welcome'));
            }
        }
    }
    $qa_content['script_rel'] = array('qa-content/jquery-1.11.2.min.js');
    $qa_content['script_rel'][] = 'qa-content/qa-page.js?' . QA_VERSION;
    if ($voting) {
        $qa_content['error'] = @$qa_page_error_html;
    }
    $qa_content['script_var'] = array('qa_root' => qa_path_to_root(), 'qa_request' => $request);
    return $qa_content;
}
Ejemplo n.º 6
0
$qa_content['message_list'] = array('form' => array('tags' => 'method="post" action="' . qa_self_html() . '"', 'hidden' => array('code' => qa_get_form_security_code('admin/click'))), 'messages' => array());
if (count($users)) {
    foreach ($users as $user) {
        $message = array();
        $message['tags'] = 'id="p' . qa_html($user['userid']) . '"';
        // use p prefix for qa_admin_click() in qa-admin.js
        $message['content'] = qa_lang_html('users/registered_label') . ' ' . strtr(qa_lang_html('users/x_ago_from_y'), array('^1' => qa_time_to_string(qa_opt('db_time') - $user['created']), '^2' => qa_ip_anchor_html($user['createip']))) . '<br/>';
        $htmlemail = qa_html($user['email']);
        $message['content'] .= qa_lang_html('users/email_label') . ' <a href="mailto:' . $htmlemail . '">' . $htmlemail . '</a>';
        if (qa_opt('confirm_user_emails')) {
            $message['content'] .= '<small> - ' . qa_lang_html($user['flags'] & QA_USER_FLAGS_EMAIL_CONFIRMED ? 'users/email_confirmed' : 'users/email_not_confirmed') . '</small>';
        }
        foreach ($userfields as $userfield) {
            if (strlen(@$user['profile'][$userfield['title']])) {
                $message['content'] .= '<br/>' . qa_html($userfield['content'] . ': ' . $user['profile'][$userfield['title']]);
            }
        }
        $message['meta_order'] = qa_lang_html('main/meta_order');
        $message['who']['data'] = qa_get_one_user_html($user['handle']);
        $message['form'] = array('style' => 'light', 'buttons' => array('approve' => array('tags' => 'name="admin_' . $user['userid'] . '_userapprove" onclick="return qa_admin_click(this);"', 'label' => qa_lang_html('question/approve_button'), 'popup' => qa_lang_html('admin/approve_user_popup')), 'block' => array('tags' => 'name="admin_' . $user['userid'] . '_userblock" onclick="return qa_admin_click(this);"', 'label' => qa_lang_html('admin/block_button'), 'popup' => qa_lang_html('admin/block_user_popup'))));
        $qa_content['message_list']['messages'][] = $message;
    }
} else {
    $qa_content['title'] = qa_lang_html('admin/no_unapproved_found');
}
$qa_content['navigation']['sub'] = qa_admin_sub_navigation();
$qa_content['script_rel'][] = 'qa-content/qa-admin.js?' . QA_VERSION;
return $qa_content;
/*
	Omit PHP closing tag to help avoid accidental output
*/
Ejemplo n.º 7
0
function qa_content_prepare($voting = false, $categoryids = null)
{
    global $qa_root_url_relative, $qa_request, $qa_template, $qa_login_userid, $qa_vote_error_html, $qa_nav_pages_cached, $qa_widgets_cached, $QA_CONST_ROUTING;
    if (QA_DEBUG_PERFORMANCE) {
        qa_usage_mark('control');
    }
    if (isset($categoryids) && !is_array($categoryids)) {
        // accept old-style parameter
        $categoryids = array($categoryids);
    }
    $lastcategoryid = count($categoryids) ? end($categoryids) : null;
    $qa_content = array('content_type' => 'text/html; charset=utf-8', 'site_title' => qa_html(qa_opt('site_title')), 'head_lines' => array(), 'navigation' => array('user' => array(), 'main' => array(), 'footer' => array('feedback' => array('url' => qa_path_html('feedback'), 'label' => qa_lang_html('main/nav_feedback')))), 'sidebar' => qa_opt('show_custom_sidebar') ? qa_opt('custom_sidebar') : null, 'sidepanel' => qa_opt('show_custom_sidepanel') ? qa_opt('custom_sidepanel') : null, 'widgets' => array());
    if (qa_opt('show_custom_in_head')) {
        $qa_content['head_lines'][] = qa_opt('custom_in_head');
    }
    if (qa_opt('show_custom_header')) {
        $qa_content['body_header'] = qa_opt('custom_header');
    }
    if (qa_opt('show_custom_footer')) {
        $qa_content['body_footer'] = qa_opt('custom_footer');
    }
    if (isset($categoryids)) {
        $qa_content['categoryids'] = $categoryids;
    }
    foreach ($qa_nav_pages_cached as $page) {
        if ($page['nav'] == 'B') {
            qa_navigation_add_page($qa_content['navigation']['main'], $page);
        }
    }
    if (qa_opt('nav_home') && qa_opt('show_custom_home')) {
        $qa_content['navigation']['main']['$'] = array('url' => qa_path_html(''), 'label' => qa_lang_html('main/nav_home'));
    }
    if (qa_opt('nav_activity')) {
        $qa_content['navigation']['main']['activity'] = array('url' => qa_path_html('activity'), 'label' => qa_lang_html('main/nav_activity'));
    }
    $hascustomhome = qa_has_custom_home();
    if (qa_opt($hascustomhome ? 'nav_qa_not_home' : 'nav_qa_is_home')) {
        $qa_content['navigation']['main'][$hascustomhome ? 'qa' : '$'] = array('url' => qa_path_html($hascustomhome ? 'qa' : ''), 'label' => qa_lang_html('main/nav_qa'));
    }
    if (qa_opt('nav_questions')) {
        $qa_content['navigation']['main']['questions'] = array('url' => qa_path_html('questions'), 'label' => qa_lang_html('main/nav_qs'));
    }
    if (qa_opt('nav_hot')) {
        $qa_content['navigation']['main']['hot'] = array('url' => qa_path_html('hot'), 'label' => qa_lang_html('main/nav_hot'));
    }
    if (qa_opt('nav_unanswered')) {
        $qa_content['navigation']['main']['unanswered'] = array('url' => qa_path_html('unanswered'), 'label' => qa_lang_html('main/nav_unanswered'));
    }
    if (qa_using_tags() && qa_opt('nav_tags')) {
        $qa_content['navigation']['main']['tag'] = array('url' => qa_path_html('tags'), 'label' => qa_lang_html('main/nav_tags'));
    }
    if (qa_using_categories() && qa_opt('nav_categories')) {
        $qa_content['navigation']['main']['categories'] = array('url' => qa_path_html('categories'), 'label' => qa_lang_html('main/nav_categories'));
    }
    if (qa_opt('nav_users')) {
        $qa_content['navigation']['main']['user'] = array('url' => qa_path_html('users'), 'label' => qa_lang_html('main/nav_users'));
    }
    if (qa_user_permit_error('permit_post_q') != 'level') {
        $qa_content['navigation']['main']['ask'] = array('url' => qa_path_html('ask', qa_using_categories() && strlen($lastcategoryid) ? array('cat' => $lastcategoryid) : null), 'label' => qa_lang_html('main/nav_ask'));
    }
    if (qa_get_logged_in_level() >= QA_USER_LEVEL_ADMIN) {
        $qa_content['navigation']['main']['admin'] = array('url' => qa_path_html(isset($_COOKIE['qa_admin_last']) && isset($QA_CONST_ROUTING[$_COOKIE['qa_admin_last']]) ? $_COOKIE['qa_admin_last'] : 'admin'), 'label' => qa_lang_html('main/nav_admin'));
    }
    $qa_content['search'] = array('form_tags' => 'METHOD="GET" ACTION="' . qa_path_html('search') . '"', 'form_extra' => qa_path_form_html('search'), 'title' => qa_lang_html('main/search_title'), 'field_tags' => 'NAME="q"', 'button_label' => qa_lang_html('main/search_button'));
    if (!qa_opt('feedback_enabled')) {
        unset($qa_content['navigation']['footer']['feedback']);
    }
    foreach ($qa_nav_pages_cached as $page) {
        if ($page['nav'] == 'M' || $page['nav'] == 'O' || $page['nav'] == 'F') {
            qa_navigation_add_page($qa_content['navigation'][$page['nav'] == 'F' ? 'footer' : 'main'], $page);
        }
    }
    $regioncodes = array('F' => 'full', 'M' => 'main', 'S' => 'side');
    $placecodes = array('T' => 'top', 'H' => 'high', 'L' => 'low', 'B' => 'bottom');
    foreach ($qa_widgets_cached as $widget) {
        if (is_numeric(strpos(',' . $widget['tags'] . ',', ',' . $qa_template . ',')) || is_numeric(strpos(',' . $widget['tags'] . ',', ',all,'))) {
            // see if it has been selected for display on this template
            $region = @$regioncodes[substr($widget['place'], 0, 1)];
            $place = @$placecodes[substr($widget['place'], 1, 2)];
            if (isset($region) && isset($place)) {
                // check region/place codes recognized
                $module = qa_load_module('widget', $widget['title']);
                if (isset($module) && method_exists($module, 'allow_template') && $module->allow_template($qa_template) && method_exists($module, 'allow_region') && $module->allow_region($region) && method_exists($module, 'output_widget')) {
                    $qa_content['widgets'][$region][$place][] = $module;
                }
                // if module loaded and happy to be displayed here, tell theme about it
            }
        }
    }
    $logoshow = qa_opt('logo_show');
    $logourl = qa_opt('logo_url');
    $logowidth = qa_opt('logo_width');
    $logoheight = qa_opt('logo_height');
    if ($logoshow) {
        $qa_content['logo'] = '<A HREF="' . qa_path_html('') . '" CLASS="qa-logo-link" TITLE="' . qa_html(qa_opt('site_title')) . '">' . '<IMG SRC="' . qa_html(is_numeric(strpos($logourl, '://')) ? $logourl : $qa_root_url_relative . $logourl) . '"' . ($logowidth ? ' WIDTH="' . $logowidth . '"' : '') . ($logoheight ? ' HEIGHT="' . $logoheight . '"' : '') . ' BORDER="0"/></A>';
    } else {
        $qa_content['logo'] = '<A HREF="' . qa_path_html('') . '" CLASS="qa-logo-link">' . qa_html(qa_opt('site_title')) . '</A>';
    }
    $topath = qa_get('to');
    // lets user switch between login and register without losing destination page
    $userlinks = qa_get_login_links($qa_root_url_relative, isset($topath) ? $topath : qa_path($qa_request, $_GET, ''));
    $qa_content['navigation']['user'] = array();
    if (isset($qa_login_userid)) {
        $qa_content['loggedin'] = qa_lang_html_sub_split('main/logged_in_x', QA_FINAL_EXTERNAL_USERS ? qa_get_logged_in_user_html(qa_get_logged_in_user_cache(), $qa_root_url_relative, false) : qa_get_one_user_html(qa_get_logged_in_handle(), false));
        if (!QA_FINAL_EXTERNAL_USERS) {
            $qa_content['navigation']['user']['account'] = array('url' => qa_path_html('account'), 'label' => qa_lang_html('main/nav_account'));
        }
        if (!empty($userlinks['logout'])) {
            $qa_content['navigation']['user']['logout'] = array('url' => qa_html(@$userlinks['logout']), 'label' => qa_lang_html('main/nav_logout'));
        }
        if (!QA_FINAL_EXTERNAL_USERS) {
            $source = qa_get_logged_in_source();
            if (strlen($source)) {
                $modulenames = qa_list_modules('login');
                foreach ($modulenames as $tryname) {
                    $module = qa_load_module('login', $tryname);
                    if (method_exists($module, 'match_source') && $module->match_source($source) && method_exists($module, 'logout_html')) {
                        ob_start();
                        $module->logout_html(qa_path('logout', array(), qa_opt('site_url')));
                        $qa_content['navigation']['user']['logout'] = array('label' => ob_get_clean());
                    }
                }
            }
        }
    } else {
        $modulenames = qa_list_modules('login');
        foreach ($modulenames as $tryname) {
            $module = qa_load_module('login', $tryname);
            if (method_exists($module, 'login_html')) {
                ob_start();
                $module->login_html(isset($topath) ? qa_opt('site_url') . $topath : qa_path($qa_request, $_GET, qa_opt('site_url')), 'menu');
                $qa_content['navigation']['user'][$tryname] = array('label' => ob_get_clean());
            }
        }
        if (!empty($userlinks['login'])) {
            $qa_content['navigation']['user']['login'] = array('url' => qa_html(@$userlinks['login']), 'label' => qa_lang_html('main/nav_login'));
        }
        if (!empty($userlinks['register'])) {
            $qa_content['navigation']['user']['register'] = array('url' => qa_html(@$userlinks['register']), 'label' => qa_lang_html('main/nav_register'));
        }
    }
    $qa_content['script_rel'] = array('qa-content/jquery-1.6.1.min.js');
    if ($voting) {
        $qa_content['error'] = @$qa_vote_error_html;
        $qa_content['script_rel'][] = 'qa-content/qa-votes.js?' . QA_VERSION;
    }
    $qa_content['script_var'] = array('qa_root' => $qa_root_url_relative, 'qa_request' => $qa_request);
    return $qa_content;
}
Ejemplo n.º 8
0
function qa_userids_handles_html($useridhandles, $microformats = false)
{
    require_once QA_INCLUDE_DIR . 'qa-app-users.php';
    if (QA_FINAL_EXTERNAL_USERS) {
        $keyuserids = array();
        foreach ($useridhandles as $useridhandle) {
            if (isset($useridhandle['userid'])) {
                $keyuserids[$useridhandle['userid']] = true;
            }
            if (isset($useridhandle['lastuserid'])) {
                $keyuserids[$useridhandle['lastuserid']] = true;
            }
        }
        if (count($keyuserids)) {
            return qa_get_users_html(array_keys($keyuserids), true, qa_path_to_root(), $microformats);
        } else {
            return array();
        }
    } else {
        $usershtml = array();
        foreach ($useridhandles as $useridhandle) {
            if (isset($useridhandle['userid']) && $useridhandle['handle']) {
                $usershtml[$useridhandle['userid']] = qa_get_one_user_html($useridhandle['handle'], $microformats);
            }
            if (isset($useridhandle['lastuserid']) && $useridhandle['lasthandle']) {
                $usershtml[$useridhandle['lastuserid']] = qa_get_one_user_html($useridhandle['lasthandle'], $microformats);
            }
        }
        return $usershtml;
    }
}