Commit 2be2b6bb by Scott

Coding style (misc. pages)

parent d057c557
...@@ -20,99 +20,94 @@ ...@@ -20,99 +20,94 @@
More about this license: http://www.question2answer.org/license.php More about this license: http://www.question2answer.org/license.php
*/ */
if (!defined('QA_VERSION')) { // don't allow this page to be requested directly from browser if (!defined('QA_VERSION')) { // don't allow this page to be requested directly from browser
header('Location: ../'); header('Location: ../');
exit; exit;
} }
require_once QA_INCLUDE_DIR.'db/selects.php'; require_once QA_INCLUDE_DIR . 'db/selects.php';
require_once QA_INCLUDE_DIR.'app/format.php'; require_once QA_INCLUDE_DIR . 'app/format.php';
$categoryslugs=qa_request_parts(1); $categoryslugs = qa_request_parts(1);
$countslugs=count($categoryslugs); $countslugs = count($categoryslugs);
// Get information about appropriate categories and redirect to questions page if category has no sub-categories // Get information about appropriate categories and redirect to questions page if category has no sub-categories
$userid=qa_get_logged_in_userid(); $userid = qa_get_logged_in_userid();
list($categories, $categoryid, $favoritecats)=qa_db_select_with_pending( list($categories, $categoryid, $favoritecats) = qa_db_select_with_pending(
qa_db_category_nav_selectspec($categoryslugs, false, false, true), qa_db_category_nav_selectspec($categoryslugs, false, false, true),
$countslugs ? qa_db_slugs_to_category_id_selectspec($categoryslugs) : null, $countslugs ? qa_db_slugs_to_category_id_selectspec($categoryslugs) : null,
isset($userid) ? qa_db_user_favorite_categories_selectspec($userid) : null isset($userid) ? qa_db_user_favorite_categories_selectspec($userid) : null
); );
if ($countslugs && !isset($categoryid)) if ($countslugs && !isset($categoryid))
return include QA_INCLUDE_DIR.'qa-page-not-found.php'; return include QA_INCLUDE_DIR . 'qa-page-not-found.php';
// Function for recursive display of categories // Function for recursive display of categories
function qa_category_nav_to_browse(&$navigation, $categories, $categoryid, $favoritemap) function qa_category_nav_to_browse(&$navigation, $categories, $categoryid, $favoritemap)
{ {
foreach ($navigation as $key => $navlink) { foreach ($navigation as $key => $navlink) {
$category=$categories[$navlink['categoryid']]; $category = $categories[$navlink['categoryid']];
if (!$category['childcount']) if (!$category['childcount'])
unset($navigation[$key]['url']); unset($navigation[$key]['url']);
elseif ($navlink['selected']) { elseif ($navlink['selected']) {
$navigation[$key]['state']='open'; $navigation[$key]['state'] = 'open';
$navigation[$key]['url']=qa_path_html('categories/'.qa_category_path_request($categories, $category['parentid'])); $navigation[$key]['url'] = qa_path_html('categories/' . qa_category_path_request($categories, $category['parentid']));
} else } else
$navigation[$key]['state']='closed'; $navigation[$key]['state'] = 'closed';
if (@$favoritemap[$navlink['categoryid']]) if (@$favoritemap[$navlink['categoryid']])
$navigation[$key]['favorited']=true; $navigation[$key]['favorited'] = true;
$navigation[$key]['note']=''; $navigation[$key]['note'] = '';
$navigation[$key]['note'].= $navigation[$key]['note'] .=
' - <a href="'.qa_path_html('questions/'.implode('/', array_reverse(explode('/', $category['backpath'])))).'">'.( ($category['qcount']==1) ' - <a href="' . qa_path_html('questions/' . implode('/', array_reverse(explode('/', $category['backpath'])))) . '">' . (($category['qcount'] == 1)
? qa_lang_html_sub('main/1_question', '1', '1') ? qa_lang_html_sub('main/1_question', '1', '1')
: qa_lang_html_sub('main/x_questions', qa_format_number($category['qcount'], 0, true)) : qa_lang_html_sub('main/x_questions', qa_format_number($category['qcount'], 0, true))
).'</a>'; ) . '</a>';
if (strlen($category['content'])) if (strlen($category['content']))
$navigation[$key]['note'].=qa_html(' - '.$category['content']); $navigation[$key]['note'] .= qa_html(' - ' . $category['content']);
if (isset($navlink['subnav'])) if (isset($navlink['subnav']))
qa_category_nav_to_browse($navigation[$key]['subnav'], $categories, $categoryid, $favoritemap); qa_category_nav_to_browse($navigation[$key]['subnav'], $categories, $categoryid, $favoritemap);
}
} }
}
// Prepare content for theme // Prepare content for theme
$qa_content=qa_content_prepare(false, array_keys(qa_category_path($categories, $categoryid))); $qa_content = qa_content_prepare(false, array_keys(qa_category_path($categories, $categoryid)));
$qa_content['title']=qa_lang_html('misc/browse_categories'); $qa_content['title'] = qa_lang_html('misc/browse_categories');
if (count($categories)) { if (count($categories)) {
$navigation=qa_category_navigation($categories, $categoryid, 'categories/', false); $navigation = qa_category_navigation($categories, $categoryid, 'categories/', false);
unset($navigation['all']); unset($navigation['all']);
$favoritemap=array(); $favoritemap = array();
if (isset($favoritecats)) if (isset($favoritecats))
foreach ($favoritecats as $category) foreach ($favoritecats as $category)
$favoritemap[$category['categoryid']]=true; $favoritemap[$category['categoryid']] = true;
qa_category_nav_to_browse($navigation, $categories, $categoryid, $favoritemap); qa_category_nav_to_browse($navigation, $categories, $categoryid, $favoritemap);
$qa_content['nav_list']=array(
'nav' => $navigation,
'type' => 'browse-cat',
);
} else {
$qa_content['title']=qa_lang_html('main/no_categories_found');
$qa_content['suggest_next']=qa_html_suggest_qs_tags(qa_using_tags());
}
$qa_content['nav_list'] = array(
'nav' => $navigation,
'type' => 'browse-cat',
);
return $qa_content; } else {
$qa_content['title'] = qa_lang_html('main/no_categories_found');
$qa_content['suggest_next'] = qa_html_suggest_qs_tags(qa_using_tags());
}
/* return $qa_content;
Omit PHP closing tag to help avoid accidental output
*/
\ No newline at end of file
...@@ -20,88 +20,84 @@ ...@@ -20,88 +20,84 @@
More about this license: http://www.question2answer.org/license.php More about this license: http://www.question2answer.org/license.php
*/ */
if (!defined('QA_VERSION')) { // don't allow this page to be requested directly from browser if (!defined('QA_VERSION')) { // don't allow this page to be requested directly from browser
header('Location: ../'); header('Location: ../');
exit; exit;
} }
require_once QA_INCLUDE_DIR.'db/selects.php'; require_once QA_INCLUDE_DIR . 'db/selects.php';
require_once QA_INCLUDE_DIR.'app/format.php'; require_once QA_INCLUDE_DIR . 'app/format.php';
require_once QA_INCLUDE_DIR.'app/favorites.php'; require_once QA_INCLUDE_DIR . 'app/favorites.php';
// Data for functions to run // Data for functions to run
$favswitch = array(
'questions' => array( $favswitch = array(
'page_opt' => 'page_size_qs', 'questions' => array(
'fn_spec' => 'qa_db_user_favorite_qs_selectspec', 'page_opt' => 'page_size_qs',
'fn_view' => 'qa_favorite_q_list_view', 'fn_spec' => 'qa_db_user_favorite_qs_selectspec',
'key' => 'q_list', 'fn_view' => 'qa_favorite_q_list_view',
), 'key' => 'q_list',
'users' => array( ),
'page_opt' => 'page_size_users', 'users' => array(
'fn_spec' => 'qa_db_user_favorite_users_selectspec', 'page_opt' => 'page_size_users',
'fn_view' => 'qa_favorite_users_view', 'fn_spec' => 'qa_db_user_favorite_users_selectspec',
'key' => 'ranking_users', 'fn_view' => 'qa_favorite_users_view',
), 'key' => 'ranking_users',
'tags' => array( ),
'page_opt' => 'page_size_tags', 'tags' => array(
'fn_spec' => 'qa_db_user_favorite_tags_selectspec', 'page_opt' => 'page_size_tags',
'fn_view' => 'qa_favorite_tags_view', 'fn_spec' => 'qa_db_user_favorite_tags_selectspec',
'key' => 'ranking_tags', 'fn_view' => 'qa_favorite_tags_view',
), 'key' => 'ranking_tags',
); ),
);
// Check that we're logged in // Check that we're logged in
$userid = qa_get_logged_in_userid(); $userid = qa_get_logged_in_userid();
if (!isset($userid)) if (!isset($userid))
qa_redirect('login'); qa_redirect('login');
// Get lists of favorites of this type // Get lists of favorites of this type
$favtype = qa_request_part(1); $favtype = qa_request_part(1);
$start = qa_get_start(); $start = qa_get_start();
if (!array_key_exists($favtype, $favswitch) || ($favtype === 'users' && QA_FINAL_EXTERNAL_USERS)) if (!array_key_exists($favtype, $favswitch) || ($favtype === 'users' && QA_FINAL_EXTERNAL_USERS))
return include QA_INCLUDE_DIR.'qa-page-not-found.php'; return include QA_INCLUDE_DIR . 'qa-page-not-found.php';
extract($favswitch[$favtype]); // get switch variables extract($favswitch[$favtype]); // get switch variables
$pagesize = qa_opt($page_opt); $pagesize = qa_opt($page_opt);
list($totalItems, $items) = qa_db_select_with_pending( list($totalItems, $items) = qa_db_select_with_pending(
qa_db_selectspec_count($fn_spec($userid)), qa_db_selectspec_count($fn_spec($userid)),
$fn_spec($userid, $pagesize, $start) $fn_spec($userid, $pagesize, $start)
); );
$count = $totalItems['count']; $count = $totalItems['count'];
$usershtml = qa_userids_handles_html($items); $usershtml = qa_userids_handles_html($items);
// Prepare and return content for theme // Prepare and return content for theme
$qa_content = qa_content_prepare(true); $qa_content = qa_content_prepare(true);
$qa_content['title'] = qa_lang_html('misc/my_favorites_title'); $qa_content['title'] = qa_lang_html('misc/my_favorites_title');
$qa_content[$key] = $fn_view($items, $usershtml); $qa_content[$key] = $fn_view($items, $usershtml);
// Sub navigation for account pages and suggestion // Sub navigation for account pages and suggestion
$qa_content['suggest_next'] = qa_lang_html_sub('misc/suggest_favorites_add', '<span class="qa-favorite-image">&nbsp;</span>'); $qa_content['suggest_next'] = qa_lang_html_sub('misc/suggest_favorites_add', '<span class="qa-favorite-image">&nbsp;</span>');
$qa_content['page_links'] = qa_html_page_links(qa_request(), $start, $pagesize, $count, qa_opt('pages_prev_next'));
$qa_content['navigation']['sub'] = qa_user_sub_navigation(qa_get_logged_in_handle(), 'favorites', true); $qa_content['page_links'] = qa_html_page_links(qa_request(), $start, $pagesize, $count, qa_opt('pages_prev_next'));
$qa_content['navigation']['sub'] = qa_user_sub_navigation(qa_get_logged_in_handle(), 'favorites', true);
return $qa_content;
return $qa_content;
/*
Omit PHP closing tag to help avoid accidental output
*/
\ No newline at end of file
...@@ -20,105 +20,100 @@ ...@@ -20,105 +20,100 @@
More about this license: http://www.question2answer.org/license.php More about this license: http://www.question2answer.org/license.php
*/ */
if (!defined('QA_VERSION')) { // don't allow this page to be requested directly from browser if (!defined('QA_VERSION')) { // don't allow this page to be requested directly from browser
header('Location: ../'); header('Location: ../');
exit; exit;
} }
require_once QA_INCLUDE_DIR.'db/selects.php'; require_once QA_INCLUDE_DIR . 'db/selects.php';
require_once QA_INCLUDE_DIR.'app/format.php'; require_once QA_INCLUDE_DIR . 'app/format.php';
require_once QA_INCLUDE_DIR.'app/favorites.php'; require_once QA_INCLUDE_DIR . 'app/favorites.php';
// Check that we're logged in // Check that we're logged in
$userid = qa_get_logged_in_userid(); $userid = qa_get_logged_in_userid();
if (!isset($userid)) if (!isset($userid))
qa_redirect('login'); qa_redirect('login');
// Get lists of favorites for this user // Get lists of favorites for this user
$pagesize_qs = qa_opt('page_size_qs'); $pagesize_qs = qa_opt('page_size_qs');
$pagesize_users = qa_opt('page_size_users'); $pagesize_users = qa_opt('page_size_users');
$pagesize_tags = qa_opt('page_size_tags'); $pagesize_tags = qa_opt('page_size_tags');
list($numQs, $questions, $numUsers, $users, $numTags, $tags, $categories) = qa_db_select_with_pending( list($numQs, $questions, $numUsers, $users, $numTags, $tags, $categories) = qa_db_select_with_pending(
qa_db_selectspec_count( qa_db_user_favorite_qs_selectspec($userid) ), qa_db_selectspec_count(qa_db_user_favorite_qs_selectspec($userid)),
qa_db_user_favorite_qs_selectspec($userid, $pagesize_qs), qa_db_user_favorite_qs_selectspec($userid, $pagesize_qs),
QA_FINAL_EXTERNAL_USERS ? null : qa_db_selectspec_count( qa_db_user_favorite_users_selectspec($userid) ), QA_FINAL_EXTERNAL_USERS ? null : qa_db_selectspec_count(qa_db_user_favorite_users_selectspec($userid)),
QA_FINAL_EXTERNAL_USERS ? null : qa_db_user_favorite_users_selectspec($userid, $pagesize_users), QA_FINAL_EXTERNAL_USERS ? null : qa_db_user_favorite_users_selectspec($userid, $pagesize_users),
qa_db_selectspec_count( qa_db_user_favorite_tags_selectspec($userid) ), qa_db_selectspec_count(qa_db_user_favorite_tags_selectspec($userid)),
qa_db_user_favorite_tags_selectspec($userid, $pagesize_tags), qa_db_user_favorite_tags_selectspec($userid, $pagesize_tags),
qa_db_user_favorite_categories_selectspec($userid) qa_db_user_favorite_categories_selectspec($userid)
); );
$usershtml = qa_userids_handles_html(QA_FINAL_EXTERNAL_USERS ? $questions : array_merge($questions, $users)); $usershtml = qa_userids_handles_html(QA_FINAL_EXTERNAL_USERS ? $questions : array_merge($questions, $users));
// Prepare and return content for theme // Prepare and return content for theme
$qa_content = qa_content_prepare(true); $qa_content = qa_content_prepare(true);
$qa_content['title'] = qa_lang_html('misc/my_favorites_title'); $qa_content['title'] = qa_lang_html('misc/my_favorites_title');
// Favorite questions // Favorite questions
$qa_content['q_list'] = qa_favorite_q_list_view($questions, $usershtml); $qa_content['q_list'] = qa_favorite_q_list_view($questions, $usershtml);
$qa_content['q_list']['title'] = count($questions) ? qa_lang_html('main/nav_qs') : qa_lang_html('misc/no_favorite_qs'); $qa_content['q_list']['title'] = count($questions) ? qa_lang_html('main/nav_qs') : qa_lang_html('misc/no_favorite_qs');
if ($numQs['count'] > count($questions)) { if ($numQs['count'] > count($questions)) {
$url = qa_path_html('favorites/questions', array('start'=>$pagesize_qs)); $url = qa_path_html('favorites/questions', array('start' => $pagesize_qs));
$qa_content['q_list']['footer'] = '<p class="qa-link-next"><a href="'.$url.'">'.qa_lang_html('misc/more_favorite_qs').'</a></p>'; $qa_content['q_list']['footer'] = '<p class="qa-link-next"><a href="' . $url . '">' . qa_lang_html('misc/more_favorite_qs') . '</a></p>';
} }
// Favorite users // Favorite users
if (!QA_FINAL_EXTERNAL_USERS) { if (!QA_FINAL_EXTERNAL_USERS) {
$qa_content['ranking_users'] = qa_favorite_users_view($users, $usershtml); $qa_content['ranking_users'] = qa_favorite_users_view($users, $usershtml);
$qa_content['ranking_users']['title'] = count($users) ? qa_lang_html('main/nav_users') : qa_lang_html('misc/no_favorite_users'); $qa_content['ranking_users']['title'] = count($users) ? qa_lang_html('main/nav_users') : qa_lang_html('misc/no_favorite_users');
if ($numUsers['count'] > count($users)) { if ($numUsers['count'] > count($users)) {
$url = qa_path_html('favorites/users', array('start'=>$pagesize_users)); $url = qa_path_html('favorites/users', array('start' => $pagesize_users));
$qa_content['ranking_users']['footer'] = '<p class="qa-link-next"><a href="'.$url.'">'.qa_lang_html('misc/more_favorite_users').'</a></p>'; $qa_content['ranking_users']['footer'] = '<p class="qa-link-next"><a href="' . $url . '">' . qa_lang_html('misc/more_favorite_users') . '</a></p>';
}
} }
}
// Favorite tags // Favorite tags
if (qa_using_tags()) { if (qa_using_tags()) {
$qa_content['ranking_tags'] = qa_favorite_tags_view($tags); $qa_content['ranking_tags'] = qa_favorite_tags_view($tags);
$qa_content['ranking_tags']['title'] = count($tags) ? qa_lang_html('main/nav_tags') : qa_lang_html('misc/no_favorite_tags'); $qa_content['ranking_tags']['title'] = count($tags) ? qa_lang_html('main/nav_tags') : qa_lang_html('misc/no_favorite_tags');
if ($numTags['count'] > count($tags)) { if ($numTags['count'] > count($tags)) {
$url = qa_path_html('favorites/tags', array('start'=>$pagesize_tags)); $url = qa_path_html('favorites/tags', array('start' => $pagesize_tags));
$qa_content['ranking_tags']['footer'] = '<p class="qa-link-next"><a href="'.$url.'">'.qa_lang_html('misc/more_favorite_tags').'</a></p>'; $qa_content['ranking_tags']['footer'] = '<p class="qa-link-next"><a href="' . $url . '">' . qa_lang_html('misc/more_favorite_tags') . '</a></p>';
}
} }
}
// Favorite categories (no pagination) // Favorite categories (no pagination)
if (qa_using_categories()) { if (qa_using_categories()) {
$qa_content['nav_list_categories'] = qa_favorite_categories_view($categories); $qa_content['nav_list_categories'] = qa_favorite_categories_view($categories);
$qa_content['nav_list_categories']['title'] = count($categories) ? qa_lang_html('main/nav_categories') : qa_lang_html('misc/no_favorite_categories'); $qa_content['nav_list_categories']['title'] = count($categories) ? qa_lang_html('main/nav_categories') : qa_lang_html('misc/no_favorite_categories');
} }
// Sub navigation for account pages and suggestion // Sub navigation for account pages and suggestion
$qa_content['suggest_next'] = qa_lang_html_sub('misc/suggest_favorites_add', '<span class="qa-favorite-image">&nbsp;</span>'); $qa_content['suggest_next'] = qa_lang_html_sub('misc/suggest_favorites_add', '<span class="qa-favorite-image">&nbsp;</span>');
$qa_content['navigation']['sub'] = qa_user_sub_navigation(qa_get_logged_in_handle(), 'favorites', true); $qa_content['navigation']['sub'] = qa_user_sub_navigation(qa_get_logged_in_handle(), 'favorites', true);
return $qa_content; return $qa_content;
/*
Omit PHP closing tag to help avoid accidental output
*/
\ No newline at end of file
...@@ -20,166 +20,163 @@ ...@@ -20,166 +20,163 @@
More about this license: http://www.question2answer.org/license.php More about this license: http://www.question2answer.org/license.php
*/ */
if (!defined('QA_VERSION')) { // don't allow this page to be requested directly from browser if (!defined('QA_VERSION')) { // don't allow this page to be requested directly from browser
header('Location: ../'); header('Location: ../');
exit; exit;
} }
require_once QA_INCLUDE_DIR.'app/captcha.php'; require_once QA_INCLUDE_DIR . 'app/captcha.php';
require_once QA_INCLUDE_DIR.'db/selects.php'; require_once QA_INCLUDE_DIR . 'db/selects.php';
// Get useful information on the logged in user // Get useful information on the logged in user
$userid=qa_get_logged_in_userid(); $userid = qa_get_logged_in_userid();
if (isset($userid) && !QA_FINAL_EXTERNAL_USERS) if (isset($userid) && !QA_FINAL_EXTERNAL_USERS) {
list($useraccount, $userprofile)=qa_db_select_with_pending( list($useraccount, $userprofile) = qa_db_select_with_pending(
qa_db_user_account_selectspec($userid, true), qa_db_user_account_selectspec($userid, true),
qa_db_user_profile_selectspec($userid, true) qa_db_user_profile_selectspec($userid, true)
); );
}
$usecaptcha=qa_opt('captcha_on_feedback') && qa_user_use_captcha(); $usecaptcha = qa_opt('captcha_on_feedback') && qa_user_use_captcha();
// Check feedback is enabled and the person isn't blocked // Check feedback is enabled and the person isn't blocked
if (!qa_opt('feedback_enabled')) if (!qa_opt('feedback_enabled'))
return include QA_INCLUDE_DIR.'qa-page-not-found.php'; return include QA_INCLUDE_DIR . 'qa-page-not-found.php';
if (qa_user_permit_error()) { if (qa_user_permit_error()) {
$qa_content=qa_content_prepare(); $qa_content = qa_content_prepare();
$qa_content['error']=qa_lang_html('users/no_permission'); $qa_content['error'] = qa_lang_html('users/no_permission');
return $qa_content; return $qa_content;
} }
// Send the feedback form // Send the feedback form
$feedbacksent=false; $feedbacksent = false;
if (qa_clicked('dofeedback')) { if (qa_clicked('dofeedback')) {
require_once QA_INCLUDE_DIR.'app/emails.php'; require_once QA_INCLUDE_DIR . 'app/emails.php';
require_once QA_INCLUDE_DIR.'util/string.php'; require_once QA_INCLUDE_DIR . 'util/string.php';
$inmessage=qa_post_text('message'); $inmessage = qa_post_text('message');
$inname=qa_post_text('name'); $inname = qa_post_text('name');
$inemail=qa_post_text('email'); $inemail = qa_post_text('email');
$inreferer=qa_post_text('referer'); $inreferer = qa_post_text('referer');
if (!qa_check_form_security_code('feedback', qa_post_text('code'))) if (!qa_check_form_security_code('feedback', qa_post_text('code')))
$pageerror=qa_lang_html('misc/form_security_again'); $pageerror = qa_lang_html('misc/form_security_again');
else { else {
if (empty($inmessage)) if (empty($inmessage))
$errors['message']=qa_lang('misc/feedback_empty'); $errors['message'] = qa_lang('misc/feedback_empty');
if ($usecaptcha) if ($usecaptcha)
qa_captcha_validate_post($errors); qa_captcha_validate_post($errors);
if (empty($errors)) { if (empty($errors)) {
$subs=array( $subs = array(
'^message' => $inmessage, '^message' => $inmessage,
'^name' => empty($inname) ? '-' : $inname, '^name' => empty($inname) ? '-' : $inname,
'^email' => empty($inemail) ? '-' : $inemail, '^email' => empty($inemail) ? '-' : $inemail,
'^previous' => empty($inreferer) ? '-' : $inreferer, '^previous' => empty($inreferer) ? '-' : $inreferer,
'^url' => isset($userid) ? qa_path_absolute('user/'.qa_get_logged_in_handle()) : '-', '^url' => isset($userid) ? qa_path_absolute('user/' . qa_get_logged_in_handle()) : '-',
'^ip' => qa_remote_ip_address(), '^ip' => qa_remote_ip_address(),
'^browser' => @$_SERVER['HTTP_USER_AGENT'], '^browser' => @$_SERVER['HTTP_USER_AGENT'],
); );
if (qa_send_email(array( if (qa_send_email(array(
'fromemail' => qa_email_validate(@$inemail) ? $inemail : qa_opt('from_email'), 'fromemail' => qa_email_validate(@$inemail) ? $inemail : qa_opt('from_email'),
'fromname' => $inname, 'fromname' => $inname,
'toemail' => qa_opt('feedback_email'), 'toemail' => qa_opt('feedback_email'),
'toname' => qa_opt('site_title'), 'toname' => qa_opt('site_title'),
'subject' => qa_lang_sub('emails/feedback_subject', qa_opt('site_title')), 'subject' => qa_lang_sub('emails/feedback_subject', qa_opt('site_title')),
'body' => strtr(qa_lang('emails/feedback_body'), $subs), 'body' => strtr(qa_lang('emails/feedback_body'), $subs),
'html' => false, 'html' => false,
))) ))) {
$feedbacksent=true; $feedbacksent = true;
else } else {
$pageerror=qa_lang_html('main/general_error'); $pageerror = qa_lang_html('main/general_error');
qa_report_event('feedback', $userid, qa_get_logged_in_handle(), qa_cookie_get(), array(
'email' => $inemail,
'name' => $inname,
'message' => $inmessage,
'previous' => $inreferer,
'browser' => @$_SERVER['HTTP_USER_AGENT'],
));
} }
qa_report_event('feedback', $userid, qa_get_logged_in_handle(), qa_cookie_get(), array(
'email' => $inemail,
'name' => $inname,
'message' => $inmessage,
'previous' => $inreferer,
'browser' => @$_SERVER['HTTP_USER_AGENT'],
));
} }
} }
}
// Prepare content for theme // Prepare content for theme
$qa_content=qa_content_prepare(); $qa_content = qa_content_prepare();
$qa_content['title']=qa_lang_html('misc/feedback_title'); $qa_content['title'] = qa_lang_html('misc/feedback_title');
$qa_content['error']=@$pageerror; $qa_content['error'] = @$pageerror;
$qa_content['form']=array( $qa_content['form'] = array(
'tags' => 'method="post" action="'.qa_self_html().'"', 'tags' => 'method="post" action="' . qa_self_html() . '"',
'style' => 'tall', 'style' => 'tall',
'fields' => array( 'fields' => array(
'message' => array( 'message' => array(
'type' => $feedbacksent ? 'static' : '', 'type' => $feedbacksent ? 'static' : '',
'label' => qa_lang_html_sub('misc/feedback_message', qa_opt('site_title')), 'label' => qa_lang_html_sub('misc/feedback_message', qa_opt('site_title')),
'tags' => 'name="message" id="message"', 'tags' => 'name="message" id="message"',
'value' => qa_html(@$inmessage), 'value' => qa_html(@$inmessage),
'rows' => 8, 'rows' => 8,
'error' => qa_html(@$errors['message']), 'error' => qa_html(@$errors['message']),
),
'name' => array(
'type' => $feedbacksent ? 'static' : '',
'label' => qa_lang_html('misc/feedback_name'),
'tags' => 'name="name"',
'value' => qa_html(isset($inname) ? $inname : @$userprofile['name']),
),
'email' => array(
'type' => $feedbacksent ? 'static' : '',
'label' => qa_lang_html('misc/feedback_email'),
'tags' => 'name="email"',
'value' => qa_html(isset($inemail) ? $inemail : qa_get_logged_in_email()),
'note' => $feedbacksent ? null : qa_opt('email_privacy'),
),
), ),
'buttons' => array( 'name' => array(
'send' => array( 'type' => $feedbacksent ? 'static' : '',
'label' => qa_lang_html('main/send_button'), 'label' => qa_lang_html('misc/feedback_name'),
), 'tags' => 'name="name"',
'value' => qa_html(isset($inname) ? $inname : @$userprofile['name']),
), ),
'hidden' => array( 'email' => array(
'dofeedback' => '1', 'type' => $feedbacksent ? 'static' : '',
'code' => qa_get_form_security_code('feedback'), 'label' => qa_lang_html('misc/feedback_email'),
'referer' => qa_html(isset($inreferer) ? $inreferer : @$_SERVER['HTTP_REFERER']), 'tags' => 'name="email"',
'value' => qa_html(isset($inemail) ? $inemail : qa_get_logged_in_email()),
'note' => $feedbacksent ? null : qa_opt('email_privacy'),
), ),
); ),
if ($usecaptcha && !$feedbacksent) 'buttons' => array(
qa_set_up_captcha_field($qa_content, $qa_content['form']['fields'], @$errors); 'send' => array(
'label' => qa_lang_html('main/send_button'),
),
),
'hidden' => array(
'dofeedback' => '1',
'code' => qa_get_form_security_code('feedback'),
'referer' => qa_html(isset($inreferer) ? $inreferer : @$_SERVER['HTTP_REFERER']),
),
);
$qa_content['focusid']='message'; if ($usecaptcha && !$feedbacksent)
qa_set_up_captcha_field($qa_content, $qa_content['form']['fields'], @$errors);
if ($feedbacksent) {
$qa_content['form']['ok']=qa_lang_html('misc/feedback_sent');
unset($qa_content['form']['buttons']);
}
$qa_content['focusid'] = 'message';
return $qa_content; if ($feedbacksent) {
$qa_content['form']['ok'] = qa_lang_html('misc/feedback_sent');
unset($qa_content['form']['buttons']);
}
/* return $qa_content;
Omit PHP closing tag to help avoid accidental output
*/
\ No newline at end of file
...@@ -20,106 +20,101 @@ ...@@ -20,106 +20,101 @@
More about this license: http://www.question2answer.org/license.php More about this license: http://www.question2answer.org/license.php
*/ */
if (!defined('QA_VERSION')) { // don't allow this page to be requested directly from browser if (!defined('QA_VERSION')) { // don't allow this page to be requested directly from browser
header('Location: ../'); header('Location: ../');
exit; exit;
} }
require_once QA_INCLUDE_DIR.'db/users.php'; require_once QA_INCLUDE_DIR . 'db/users.php';
require_once QA_INCLUDE_DIR.'app/captcha.php'; require_once QA_INCLUDE_DIR . 'app/captcha.php';
// Check we're not using single-sign on integration and that we're not logged in // Check we're not using single-sign on integration and that we're not logged in
if (QA_FINAL_EXTERNAL_USERS) if (QA_FINAL_EXTERNAL_USERS)
qa_fatal_error('User login is handled by external code'); qa_fatal_error('User login is handled by external code');
if (qa_is_logged_in()) if (qa_is_logged_in())
qa_redirect(''); qa_redirect('');
// Start the 'I forgot my password' process, sending email if appropriate // Start the 'I forgot my password' process, sending email if appropriate
if (qa_clicked('doforgot')) { if (qa_clicked('doforgot')) {
require_once QA_INCLUDE_DIR.'app/users-edit.php'; require_once QA_INCLUDE_DIR . 'app/users-edit.php';
$inemailhandle=qa_post_text('emailhandle'); $inemailhandle = qa_post_text('emailhandle');
$errors=array(); $errors = array();
if (!qa_check_form_security_code('forgot', qa_post_text('code'))) if (!qa_check_form_security_code('forgot', qa_post_text('code')))
$errors['page']=qa_lang_html('misc/form_security_again'); $errors['page'] = qa_lang_html('misc/form_security_again');
else { else {
if (strpos($inemailhandle, '@')===false) { // handles can't contain @ symbols if (strpos($inemailhandle, '@') === false) { // handles can't contain @ symbols
$matchusers=qa_db_user_find_by_handle($inemailhandle); $matchusers = qa_db_user_find_by_handle($inemailhandle);
$passemailhandle=!qa_opt('allow_login_email_only'); $passemailhandle = !qa_opt('allow_login_email_only');
} else { } else {
$matchusers=qa_db_user_find_by_email($inemailhandle); $matchusers = qa_db_user_find_by_email($inemailhandle);
$passemailhandle=true; $passemailhandle = true;
} }
if (count($matchusers)!=1) // if we get more than one match (should be impossible) also give an error if (count($matchusers) != 1) // if we get more than one match (should be impossible) also give an error
$errors['emailhandle']=qa_lang('users/user_not_found'); $errors['emailhandle'] = qa_lang('users/user_not_found');
if (qa_opt('captcha_on_reset_password')) if (qa_opt('captcha_on_reset_password'))
qa_captcha_validate_post($errors); qa_captcha_validate_post($errors);
if (empty($errors)) { if (empty($errors)) {
$inuserid=$matchusers[0]; $inuserid = $matchusers[0];
qa_start_reset_user($inuserid); qa_start_reset_user($inuserid);
qa_redirect('reset', $passemailhandle ? array('e' => $inemailhandle) : null); // redirect to page where code is entered qa_redirect('reset', $passemailhandle ? array('e' => $inemailhandle) : null); // redirect to page where code is entered
}
} }
}
} else } else
$inemailhandle=qa_get('e'); $inemailhandle = qa_get('e');
// Prepare content for theme // Prepare content for theme
$qa_content=qa_content_prepare(); $qa_content = qa_content_prepare();
$qa_content['title']=qa_lang_html('users/reset_title'); $qa_content['title'] = qa_lang_html('users/reset_title');
$qa_content['error']=@$errors['page']; $qa_content['error'] = @$errors['page'];
$qa_content['form']=array( $qa_content['form'] = array(
'tags' => 'method="post" action="'.qa_self_html().'"', 'tags' => 'method="post" action="' . qa_self_html() . '"',
'style' => 'tall', 'style' => 'tall',
'fields' => array( 'fields' => array(
'email_handle' => array( 'email_handle' => array(
'label' => qa_lang_html('users/email_handle_label'), 'label' => qa_lang_html('users/email_handle_label'),
'tags' => 'name="emailhandle" id="emailhandle"', 'tags' => 'name="emailhandle" id="emailhandle"',
'value' => qa_html(@$inemailhandle), 'value' => qa_html(@$inemailhandle),
'error' => qa_html(@$errors['emailhandle']), 'error' => qa_html(@$errors['emailhandle']),
'note' => qa_lang_html('users/send_reset_note'), 'note' => qa_lang_html('users/send_reset_note'),
),
), ),
),
'buttons' => array( 'buttons' => array(
'send' => array( 'send' => array(
'label' => qa_lang_html('users/send_reset_button'), 'label' => qa_lang_html('users/send_reset_button'),
),
), ),
),
'hidden' => array( 'hidden' => array(
'doforgot' => '1', 'doforgot' => '1',
'code' => qa_get_form_security_code('forgot'), 'code' => qa_get_form_security_code('forgot'),
), ),
); );
if (qa_opt('captcha_on_reset_password')) if (qa_opt('captcha_on_reset_password'))
qa_set_up_captcha_field($qa_content, $qa_content['form']['fields'], @$errors); qa_set_up_captcha_field($qa_content, $qa_content['form']['fields'], @$errors);
$qa_content['focusid']='emailhandle'; $qa_content['focusid'] = 'emailhandle';
return $qa_content; return $qa_content;
/*
Omit PHP closing tag to help avoid accidental output
*/
\ No newline at end of file
...@@ -20,106 +20,106 @@ ...@@ -20,106 +20,106 @@
More about this license: http://www.question2answer.org/license.php More about this license: http://www.question2answer.org/license.php
*/ */
if (!defined('QA_VERSION')) { // don't allow this page to be requested directly from browser if (!defined('QA_VERSION')) { // don't allow this page to be requested directly from browser
header('Location: ../'); header('Location: ../');
exit; exit;
} }
require_once QA_INCLUDE_DIR.'db/selects.php'; require_once QA_INCLUDE_DIR . 'db/selects.php';
require_once QA_INCLUDE_DIR.'app/users.php'; require_once QA_INCLUDE_DIR . 'app/users.php';
require_once QA_INCLUDE_DIR.'app/format.php'; require_once QA_INCLUDE_DIR . 'app/format.php';
require_once QA_INCLUDE_DIR.'app/limits.php'; require_once QA_INCLUDE_DIR . 'app/limits.php';
$loginUserId = qa_get_logged_in_userid(); $loginUserId = qa_get_logged_in_userid();
$loginUserHandle = qa_get_logged_in_handle(); $loginUserHandle = qa_get_logged_in_handle();
// Check which box we're showing (inbox/sent), we're not using Q2A's single-sign on integration and that we're logged in // Check which box we're showing (inbox/sent), we're not using Q2A's single-sign on integration and that we're logged in
$req = qa_request_part(1); $req = qa_request_part(1);
if ($req === null) if ($req === null)
$showOutbox = false; $showOutbox = false;
elseif ($req === 'sent') elseif ($req === 'sent')
$showOutbox = true; $showOutbox = true;
else else
return include QA_INCLUDE_DIR.'qa-page-not-found.php'; return include QA_INCLUDE_DIR . 'qa-page-not-found.php';
if (QA_FINAL_EXTERNAL_USERS) if (QA_FINAL_EXTERNAL_USERS)
qa_fatal_error('User accounts are handled by external code'); qa_fatal_error('User accounts are handled by external code');
if (!isset($loginUserId)) { if (!isset($loginUserId)) {
$qa_content = qa_content_prepare(); $qa_content = qa_content_prepare();
$qa_content['error'] = qa_insert_login_links(qa_lang_html('misc/message_must_login'), qa_request()); $qa_content['error'] = qa_insert_login_links(qa_lang_html('misc/message_must_login'), qa_request());
return $qa_content; return $qa_content;
} }
if (!qa_opt('allow_private_messages') || !qa_opt('show_message_history')) if (!qa_opt('allow_private_messages') || !qa_opt('show_message_history'))
return include QA_INCLUDE_DIR.'qa-page-not-found.php'; return include QA_INCLUDE_DIR . 'qa-page-not-found.php';
// Find the messages for this user // Find the messages for this user
$start = qa_get_start(); $start = qa_get_start();
$pagesize = qa_opt('page_size_pms'); $pagesize = qa_opt('page_size_pms');
// get number of messages then actual messages for this page // get number of messages then actual messages for this page
$func = $showOutbox ? 'qa_db_messages_outbox_selectspec' : 'qa_db_messages_inbox_selectspec'; $func = $showOutbox ? 'qa_db_messages_outbox_selectspec' : 'qa_db_messages_inbox_selectspec';
$pmSpecCount = qa_db_selectspec_count( $func('private', $loginUserId, true) ); $pmSpecCount = qa_db_selectspec_count($func('private', $loginUserId, true));
$pmSpec = $func('private', $loginUserId, true, $start, $pagesize); $pmSpec = $func('private', $loginUserId, true, $start, $pagesize);
list($numMessages, $userMessages) = qa_db_select_with_pending($pmSpecCount, $pmSpec); list($numMessages, $userMessages) = qa_db_select_with_pending($pmSpecCount, $pmSpec);
$count = $numMessages['count']; $count = $numMessages['count'];
// Prepare content for theme // Prepare content for theme
$qa_content = qa_content_prepare(); $qa_content = qa_content_prepare();
$qa_content['title'] = qa_lang_html( $showOutbox ? 'misc/pm_outbox_title' : 'misc/pm_inbox_title' ); $qa_content['title'] = qa_lang_html($showOutbox ? 'misc/pm_outbox_title' : 'misc/pm_inbox_title');
$qa_content['script_rel'][] = 'qa-content/qa-user.js?'.QA_VERSION; $qa_content['script_rel'][] = 'qa-content/qa-user.js?' . QA_VERSION;
$qa_content['message_list'] = array( $qa_content['message_list'] = array(
'tags' => 'id="privatemessages"', 'tags' => 'id="privatemessages"',
'messages' => array(), 'messages' => array(),
'form' => array( 'form' => array(
'tags' => 'name="pmessage" method="post" action="'.qa_self_html().'"', 'tags' => 'name="pmessage" method="post" action="' . qa_self_html() . '"',
'style' => 'tall', 'style' => 'tall',
'hidden' => array( 'hidden' => array(
'qa_click' => '', // for simulating clicks in Javascript 'qa_click' => '', // for simulating clicks in Javascript
'handle' => qa_html($loginUserHandle), 'handle' => qa_html($loginUserHandle),
'start' => qa_html($start), 'start' => qa_html($start),
'code' => qa_get_form_security_code('pm-'.$loginUserHandle), 'code' => qa_get_form_security_code('pm-' . $loginUserHandle),
),
),
);
$htmlDefaults = qa_message_html_defaults();
if ($showOutbox)
$htmlDefaults['towhomview'] = true;
foreach ($userMessages as $message) {
$msgFormat = qa_message_html_fields($message, $htmlDefaults);
$replyHandle = $showOutbox ? $message['tohandle'] : $message['fromhandle'];
$msgFormat['form'] = array(
'style' => 'light',
'buttons' => array(
'reply' => array(
'tags' => 'onclick="window.location.href=\'' . qa_path_html('message/' . $replyHandle) . '\';return false"',
'label' => qa_lang_html('question/reply_button'),
),
'delete' => array(
'tags' => 'name="m' . qa_html($message['messageid']) . '_dodelete" onclick="return qa_pm_click(' . qa_js($message['messageid']) . ', this, ' . qa_js($showOutbox ? 'outbox' : 'inbox') . ');"',
'label' => qa_lang_html('question/delete_button'),
'popup' => qa_lang_html('profile/delete_pm_popup'),
), ),
), ),
); );
$htmlDefaults = qa_message_html_defaults(); $qa_content['message_list']['messages'][] = $msgFormat;
if ($showOutbox) }
$htmlDefaults['towhomview'] = true;
foreach ($userMessages as $message) {
$msgFormat = qa_message_html_fields($message, $htmlDefaults);
$replyHandle = $showOutbox ? $message['tohandle'] : $message['fromhandle'];
$msgFormat['form'] = array(
'style' => 'light',
'buttons' => array(
'reply' => array(
'tags' => 'onclick="window.location.href=\''.qa_path_html('message/'.$replyHandle).'\';return false"',
'label' => qa_lang_html('question/reply_button'),
),
'delete' => array(
'tags' => 'name="m'.qa_html($message['messageid']).'_dodelete" onclick="return qa_pm_click('.qa_js($message['messageid']).', this, '.qa_js($showOutbox ? 'outbox' : 'inbox').');"',
'label' => qa_lang_html('question/delete_button'),
'popup' => qa_lang_html('profile/delete_pm_popup'),
),
),
);
$qa_content['message_list']['messages'][] = $msgFormat;
}
$qa_content['page_links'] = qa_html_page_links(qa_request(), $start, $pagesize, $count, qa_opt('pages_prev_next')); $qa_content['page_links'] = qa_html_page_links(qa_request(), $start, $pagesize, $count, qa_opt('pages_prev_next'));
$qa_content['navigation']['sub'] = qa_messages_sub_navigation($showOutbox ? 'outbox' : 'inbox'); $qa_content['navigation']['sub'] = qa_messages_sub_navigation($showOutbox ? 'outbox' : 'inbox');
return $qa_content; return $qa_content;
...@@ -20,134 +20,130 @@ ...@@ -20,134 +20,130 @@
More about this license: http://www.question2answer.org/license.php More about this license: http://www.question2answer.org/license.php
*/ */
if (!defined('QA_VERSION')) { // don't allow this page to be requested directly from browser if (!defined('QA_VERSION')) { // don't allow this page to be requested directly from browser
header('Location: ../'); header('Location: ../');
exit; exit;
} }
require_once QA_INCLUDE_DIR.'app/format.php'; require_once QA_INCLUDE_DIR . 'app/format.php';
require_once QA_INCLUDE_DIR.'app/options.php'; require_once QA_INCLUDE_DIR . 'app/options.php';
require_once QA_INCLUDE_DIR.'app/search.php'; require_once QA_INCLUDE_DIR . 'app/search.php';
// Perform the search if appropriate // Perform the search if appropriate
if (strlen(qa_get('q'))) { if (strlen(qa_get('q'))) {
// Pull in input parameters // Pull in input parameters
$inquery=trim(qa_get('q')); $inquery = trim(qa_get('q'));
$userid=qa_get_logged_in_userid(); $userid = qa_get_logged_in_userid();
$start=qa_get_start(); $start = qa_get_start();
$display=qa_opt_if_loaded('page_size_search'); $display = qa_opt_if_loaded('page_size_search');
$count=2*(isset($display) ? $display : QA_DB_RETRIEVE_QS_AS)+1; $count = 2 * (isset($display) ? $display : QA_DB_RETRIEVE_QS_AS) + 1;
// get enough results to be able to give some idea of how many pages of search results there are // get enough results to be able to give some idea of how many pages of search results there are
// Perform the search using appropriate module // Perform the search using appropriate module
$results=qa_get_search_results($inquery, $start, $count, $userid, false, false); $results = qa_get_search_results($inquery, $start, $count, $userid, false, false);
// Count and truncate results // Count and truncate results
$pagesize=qa_opt('page_size_search'); $pagesize = qa_opt('page_size_search');
$gotcount=count($results); $gotcount = count($results);
$results=array_slice($results, 0, $pagesize); $results = array_slice($results, 0, $pagesize);
// Retrieve extra information on users // Retrieve extra information on users
$fullquestions=array(); $fullquestions = array();
foreach ($results as $result) foreach ($results as $result) {
if (isset($result['question'])) if (isset($result['question']))
$fullquestions[]=$result['question']; $fullquestions[] = $result['question'];
}
$usershtml=qa_userids_handles_html($fullquestions); $usershtml = qa_userids_handles_html($fullquestions);
// Report the search event // Report the search event
qa_report_event('search', $userid, qa_get_logged_in_handle(), qa_cookie_get(), array( qa_report_event('search', $userid, qa_get_logged_in_handle(), qa_cookie_get(), array(
'query' => $inquery, 'query' => $inquery,
'start' => $start, 'start' => $start,
)); ));
} }
// Prepare content for theme // Prepare content for theme
$qa_content=qa_content_prepare(true); $qa_content = qa_content_prepare(true);
if (strlen(qa_get('q'))) {
$qa_content['search']['value']=qa_html($inquery);
if (count($results))
$qa_content['title']=qa_lang_html_sub('main/results_for_x', qa_html($inquery));
else
$qa_content['title']=qa_lang_html_sub('main/no_results_for_x', qa_html($inquery));
$qa_content['q_list']['form']=array(
'tags' => 'method="post" action="'.qa_self_html().'"',
'hidden' => array(
'code' => qa_get_form_security_code('vote'),
),
);
$qa_content['q_list']['qs']=array();
$qdefaults=qa_post_html_defaults('Q'); if (strlen(qa_get('q'))) {
$qa_content['search']['value'] = qa_html($inquery);
foreach ($results as $result) if (count($results))
if (!isset($result['question'])) { // if we have any non-question results, display with less statistics $qa_content['title'] = qa_lang_html_sub('main/results_for_x', qa_html($inquery));
$qdefaults['voteview']=false; else
$qdefaults['answersview']=false; $qa_content['title'] = qa_lang_html_sub('main/no_results_for_x', qa_html($inquery));
$qdefaults['viewsview']=false;
break;
}
foreach ($results as $result) { $qa_content['q_list']['form'] = array(
if (isset($result['question'])) 'tags' => 'method="post" action="' . qa_self_html() . '"',
$fields=qa_post_html_fields($result['question'], $userid, qa_cookie_get(),
$usershtml, null, qa_post_html_options($result['question'], $qdefaults));
elseif (isset($result['url'])) 'hidden' => array(
$fields=array( 'code' => qa_get_form_security_code('vote'),
'what' => qa_html($result['url']), ),
'meta_order' => qa_lang_html('main/meta_order'), );
);
else $qa_content['q_list']['qs'] = array();
continue; // nothing to show here
if (isset($qdefaults['blockwordspreg'])) $qdefaults = qa_post_html_defaults('Q');
$result['title']=qa_block_words_replace($result['title'], $qdefaults['blockwordspreg']);
$fields['title']=qa_html($result['title']); foreach ($results as $result) {
$fields['url']=qa_html($result['url']); if (!isset($result['question'])) { // if we have any non-question results, display with less statistics
$qdefaults['voteview'] = false;
$qdefaults['answersview'] = false;
$qdefaults['viewsview'] = false;
break;
}
}
$qa_content['q_list']['qs'][]=$fields; foreach ($results as $result) {
if (isset($result['question'])) {
$fields = qa_post_html_fields($result['question'], $userid, qa_cookie_get(),
$usershtml, null, qa_post_html_options($result['question'], $qdefaults));
} elseif (isset($result['url'])) {
$fields = array(
'what' => qa_html($result['url']),
'meta_order' => qa_lang_html('main/meta_order'),
);
} else {
continue; // nothing to show here
} }
$qa_content['page_links']=qa_html_page_links(qa_request(), $start, $pagesize, $start+$gotcount, if (isset($qdefaults['blockwordspreg']))
qa_opt('pages_prev_next'), array('q' => $inquery), $gotcount>=$count); $result['title'] = qa_block_words_replace($result['title'], $qdefaults['blockwordspreg']);
if (qa_opt('feed_for_search')) $fields['title'] = qa_html($result['title']);
$qa_content['feed']=array( $fields['url'] = qa_html($result['url']);
'url' => qa_path_html(qa_feed_request('search/'.$inquery)),
'label' => qa_lang_html_sub('main/results_for_x', qa_html($inquery)),
);
if (empty($qa_content['page_links'])) $qa_content['q_list']['qs'][] = $fields;
$qa_content['suggest_next']=qa_html_suggest_qs_tags(qa_using_tags()); }
} else $qa_content['page_links'] = qa_html_page_links(qa_request(), $start, $pagesize, $start + $gotcount,
$qa_content['error']=qa_lang_html('main/search_explanation'); qa_opt('pages_prev_next'), array('q' => $inquery), $gotcount >= $count);
if (qa_opt('feed_for_search')) {
$qa_content['feed'] = array(
'url' => qa_path_html(qa_feed_request('search/' . $inquery)),
'label' => qa_lang_html_sub('main/results_for_x', qa_html($inquery)),
);
}
if (empty($qa_content['page_links']))
$qa_content['suggest_next'] = qa_html_suggest_qs_tags(qa_using_tags());
return $qa_content; } else
$qa_content['error'] = qa_lang_html('main/search_explanation');
/* return $qa_content;
Omit PHP closing tag to help avoid accidental output
*/
\ No newline at end of file
...@@ -20,79 +20,77 @@ ...@@ -20,79 +20,77 @@
More about this license: http://www.question2answer.org/license.php More about this license: http://www.question2answer.org/license.php
*/ */
if (!defined('QA_VERSION')) { // don't allow this page to be requested directly from browser if (!defined('QA_VERSION')) { // don't allow this page to be requested directly from browser
header('Location: ../'); header('Location: ../');
exit; exit;
} }
require_once QA_INCLUDE_DIR.'db/selects.php'; require_once QA_INCLUDE_DIR . 'db/selects.php';
require_once QA_INCLUDE_DIR.'app/format.php'; require_once QA_INCLUDE_DIR . 'app/format.php';
require_once QA_INCLUDE_DIR.'app/updates.php'; require_once QA_INCLUDE_DIR . 'app/updates.php';
$tag=qa_request_part(1); // picked up from qa-page.php $tag = qa_request_part(1); // picked up from qa-page.php
$start=qa_get_start(); $start = qa_get_start();
$userid=qa_get_logged_in_userid(); $userid = qa_get_logged_in_userid();
// Find the questions with this tag // Find the questions with this tag
if (!strlen($tag)) if (!strlen($tag))
qa_redirect('tags'); qa_redirect('tags');
list($questions, $tagword)=qa_db_select_with_pending( list($questions, $tagword) = qa_db_select_with_pending(
qa_db_tag_recent_qs_selectspec($userid, $tag, $start, false, qa_opt_if_loaded('page_size_tag_qs')), qa_db_tag_recent_qs_selectspec($userid, $tag, $start, false, qa_opt_if_loaded('page_size_tag_qs')),
qa_db_tag_word_selectspec($tag) qa_db_tag_word_selectspec($tag)
); );
$pagesize=qa_opt('page_size_tag_qs'); $pagesize = qa_opt('page_size_tag_qs');
$questions=array_slice($questions, 0, $pagesize); $questions = array_slice($questions, 0, $pagesize);
$usershtml=qa_userids_handles_html($questions); $usershtml = qa_userids_handles_html($questions);
// Prepare content for theme // Prepare content for theme
$qa_content=qa_content_prepare(true); $qa_content = qa_content_prepare(true);
$qa_content['title']=qa_lang_html_sub('main/questions_tagged_x', qa_html($tag));
if (isset($userid) && isset($tagword)) {
$favoritemap=qa_get_favorite_non_qs_map();
$favorite=@$favoritemap['tag'][qa_strtolower($tagword['word'])];
$qa_content['favorite']=qa_favorite_form(QA_ENTITY_TAG, $tagword['wordid'], $favorite, $qa_content['title'] = qa_lang_html_sub('main/questions_tagged_x', qa_html($tag));
qa_lang_sub($favorite ? 'main/remove_x_favorites' : 'main/add_tag_x_favorites', $tagword['word']));
}
if (!count($questions)) if (isset($userid) && isset($tagword)) {
$qa_content['q_list']['title']=qa_lang_html('main/no_questions_found'); $favoritemap = qa_get_favorite_non_qs_map();
$favorite = @$favoritemap['tag'][qa_strtolower($tagword['word'])];
$qa_content['q_list']['form']=array( $qa_content['favorite'] = qa_favorite_form(QA_ENTITY_TAG, $tagword['wordid'], $favorite,
'tags' => 'method="post" action="'.qa_self_html().'"', qa_lang_sub($favorite ? 'main/remove_x_favorites' : 'main/add_tag_x_favorites', $tagword['word']));
}
'hidden' => array( if (!count($questions))
'code' => qa_get_form_security_code('vote'), $qa_content['q_list']['title'] = qa_lang_html('main/no_questions_found');
),
);
$qa_content['q_list']['qs']=array(); $qa_content['q_list']['form'] = array(
foreach ($questions as $postid => $question) 'tags' => 'method="post" action="' . qa_self_html() . '"',
$qa_content['q_list']['qs'][]=qa_post_html_fields($question, $userid, qa_cookie_get(), $usershtml, null, qa_post_html_options($question));
$qa_content['page_links']=qa_html_page_links(qa_request(), $start, $pagesize, $tagword['tagcount'], qa_opt('pages_prev_next')); 'hidden' => array(
'code' => qa_get_form_security_code('vote'),
),
);
if (empty($qa_content['page_links'])) $qa_content['q_list']['qs'] = array();
$qa_content['suggest_next']=qa_html_suggest_qs_tags(true); foreach ($questions as $postid => $question) {
$qa_content['q_list']['qs'][] =
qa_post_html_fields($question, $userid, qa_cookie_get(), $usershtml, null, qa_post_html_options($question));
}
if (qa_opt('feed_for_tag_qs')) $qa_content['page_links'] = qa_html_page_links(qa_request(), $start, $pagesize, $tagword['tagcount'], qa_opt('pages_prev_next'));
$qa_content['feed']=array(
'url' => qa_path_html(qa_feed_request('tag/'.$tag)),
'label' => qa_lang_html_sub('main/questions_tagged_x', qa_html($tag)),
);
if (empty($qa_content['page_links']))
$qa_content['suggest_next'] = qa_html_suggest_qs_tags(true);
return $qa_content; if (qa_opt('feed_for_tag_qs')) {
$qa_content['feed'] = array(
'url' => qa_path_html(qa_feed_request('tag/' . $tag)),
'label' => qa_lang_html_sub('main/questions_tagged_x', qa_html($tag)),
);
}
/* return $qa_content;
Omit PHP closing tag to help avoid accidental output
*/
\ No newline at end of file
...@@ -20,65 +20,60 @@ ...@@ -20,65 +20,60 @@
More about this license: http://www.question2answer.org/license.php More about this license: http://www.question2answer.org/license.php
*/ */
if (!defined('QA_VERSION')) { // don't allow this page to be requested directly from browser if (!defined('QA_VERSION')) { // don't allow this page to be requested directly from browser
header('Location: ../'); header('Location: ../');
exit; exit;
} }
require_once QA_INCLUDE_DIR.'db/selects.php'; require_once QA_INCLUDE_DIR . 'db/selects.php';
require_once QA_INCLUDE_DIR.'app/format.php'; require_once QA_INCLUDE_DIR . 'app/format.php';
// Get popular tags // Get popular tags
$start = qa_get_start(); $start = qa_get_start();
$userid = qa_get_logged_in_userid(); $userid = qa_get_logged_in_userid();
$populartags = qa_db_select_with_pending( $populartags = qa_db_select_with_pending(
qa_db_popular_tags_selectspec($start, qa_opt_if_loaded('page_size_tags')) qa_db_popular_tags_selectspec($start, qa_opt_if_loaded('page_size_tags'))
); );
$tagcount = qa_opt('cache_tagcount'); $tagcount = qa_opt('cache_tagcount');
$pagesize = qa_opt('page_size_tags'); $pagesize = qa_opt('page_size_tags');
// Prepare content for theme // Prepare content for theme
$qa_content = qa_content_prepare(); $qa_content = qa_content_prepare();
$qa_content['title'] = qa_lang_html('main/popular_tags');
$qa_content['ranking'] = array(
'items' => array(),
'rows' => ceil($pagesize/qa_opt('columns_tags')),
'type' => 'tags'
);
if (count($populartags)) { $qa_content['title'] = qa_lang_html('main/popular_tags');
$favoritemap = qa_get_favorite_non_qs_map();
$output = 0; $qa_content['ranking'] = array(
foreach ($populartags as $word => $count) { 'items' => array(),
$qa_content['ranking']['items'][] = array( 'rows' => ceil($pagesize / qa_opt('columns_tags')),
'label' => qa_tag_html($word, false, @$favoritemap['tag'][qa_strtolower($word)]), 'type' => 'tags'
'count' => qa_format_number($count, 0, true), );
);
if ((++$output) >= $pagesize) if (count($populartags)) {
break; $favoritemap = qa_get_favorite_non_qs_map();
}
} else $output = 0;
$qa_content['title'] = qa_lang_html('main/no_tags_found'); foreach ($populartags as $word => $count) {
$qa_content['ranking']['items'][] = array(
'label' => qa_tag_html($word, false, @$favoritemap['tag'][qa_strtolower($word)]),
'count' => qa_format_number($count, 0, true),
);
$qa_content['page_links'] = qa_html_page_links(qa_request(), $start, $pagesize, $tagcount, qa_opt('pages_prev_next')); if ((++$output) >= $pagesize)
break;
}
if (empty($qa_content['page_links'])) } else
$qa_content['suggest_next'] = qa_html_suggest_ask(); $qa_content['title'] = qa_lang_html('main/no_tags_found');
$qa_content['page_links'] = qa_html_page_links(qa_request(), $start, $pagesize, $tagcount, qa_opt('pages_prev_next'));
return $qa_content; if (empty($qa_content['page_links']))
$qa_content['suggest_next'] = qa_html_suggest_ask();
/* return $qa_content;
Omit PHP closing tag to help avoid accidental output
*/
\ No newline at end of file
...@@ -20,62 +20,58 @@ ...@@ -20,62 +20,58 @@
More about this license: http://www.question2answer.org/license.php More about this license: http://www.question2answer.org/license.php
*/ */
if (!defined('QA_VERSION')) { // don't allow this page to be requested directly from browser if (!defined('QA_VERSION')) { // don't allow this page to be requested directly from browser
header('Location: ../'); header('Location: ../');
exit; exit;
} }
require_once QA_INCLUDE_DIR.'db/users.php'; require_once QA_INCLUDE_DIR . 'db/users.php';
// Check we're not using single-sign on integration // Check we're not using single-sign on integration
if (QA_FINAL_EXTERNAL_USERS) if (QA_FINAL_EXTERNAL_USERS)
qa_fatal_error('User login is handled by external code'); qa_fatal_error('User login is handled by external code');
// Check the code and unsubscribe the user if appropriate // Check the code and unsubscribe the user if appropriate
$unsubscribed=false; $unsubscribed = false;
$loginuserid=qa_get_logged_in_userid(); $loginuserid = qa_get_logged_in_userid();
$incode=trim(qa_get('c')); // trim to prevent passing in blank values to match uninitiated DB rows $incode = trim(qa_get('c')); // trim to prevent passing in blank values to match uninitiated DB rows
$inhandle=qa_get('u'); $inhandle = qa_get('u');
if (!empty($inhandle)) { // match based on code and handle provided on URL if (!empty($inhandle)) { // match based on code and handle provided on URL
$userinfo=qa_db_select_with_pending(qa_db_user_account_selectspec($inhandle, false)); $userinfo = qa_db_select_with_pending(qa_db_user_account_selectspec($inhandle, false));
if (strtolower(trim(@$userinfo['emailcode']))==strtolower($incode)) { if (strtolower(trim(@$userinfo['emailcode'])) == strtolower($incode)) {
qa_db_user_set_flag($userinfo['userid'], QA_USER_FLAGS_NO_MAILINGS, true); qa_db_user_set_flag($userinfo['userid'], QA_USER_FLAGS_NO_MAILINGS, true);
$unsubscribed=true; $unsubscribed = true;
}
} }
}
if ( (!$unsubscribed) && isset($loginuserid)) { // as a backup, also unsubscribe logged in user if ((!$unsubscribed) && isset($loginuserid)) { // as a backup, also unsubscribe logged in user
qa_db_user_set_flag($loginuserid, QA_USER_FLAGS_NO_MAILINGS, true); qa_db_user_set_flag($loginuserid, QA_USER_FLAGS_NO_MAILINGS, true);
$unsubscribed=true; $unsubscribed = true;
} }
// Prepare content for theme // Prepare content for theme
$qa_content=qa_content_prepare(); $qa_content = qa_content_prepare();
$qa_content['title']=qa_lang_html('users/unsubscribe_title');
if ($unsubscribed) $qa_content['title'] = qa_lang_html('users/unsubscribe_title');
$qa_content['error']=strtr(qa_lang_html('users/unsubscribe_complete'), array(
'^0' => qa_html(qa_opt('site_title')),
'^1' => '<a href="'.qa_path_html('account').'">',
'^2' => '</a>',
));
else
$qa_content['error']=qa_insert_login_links(qa_lang_html('users/unsubscribe_wrong_log_in'), 'unsubscribe');
if ($unsubscribed) {
$qa_content['error'] = strtr(qa_lang_html('users/unsubscribe_complete'), array(
'^0' => qa_html(qa_opt('site_title')),
'^1' => '<a href="' . qa_path_html('account') . '">',
'^2' => '</a>',
));
} else {
$qa_content['error'] = qa_insert_login_links(qa_lang_html('users/unsubscribe_wrong_log_in'), 'unsubscribe');
}
return $qa_content;
return $qa_content;
/*
Omit PHP closing tag to help avoid accidental output
*/
\ No newline at end of file
...@@ -20,96 +20,91 @@ ...@@ -20,96 +20,91 @@
More about this license: http://www.question2answer.org/license.php More about this license: http://www.question2answer.org/license.php
*/ */
if (!defined('QA_VERSION')) { // don't allow this page to be requested directly from browser if (!defined('QA_VERSION')) { // don't allow this page to be requested directly from browser
header('Location: ../'); header('Location: ../');
exit; exit;
} }
require_once QA_INCLUDE_DIR.'db/selects.php'; require_once QA_INCLUDE_DIR . 'db/selects.php';
require_once QA_INCLUDE_DIR.'app/format.php'; require_once QA_INCLUDE_DIR . 'app/format.php';
require_once QA_INCLUDE_DIR.'app/q-list.php'; require_once QA_INCLUDE_DIR . 'app/q-list.php';
// Check that we're logged in // Check that we're logged in
$userid=qa_get_logged_in_userid(); $userid = qa_get_logged_in_userid();
if (!isset($userid)) if (!isset($userid))
qa_redirect('login'); qa_redirect('login');
// Find out which updates to show // Find out which updates to show
$forfavorites=qa_get('show')!='content'; $forfavorites = qa_get('show') != 'content';
$forcontent=qa_get('show')!='favorites'; $forcontent = qa_get('show') != 'favorites';
// Get lists of recent updates for this user // Get lists of recent updates for this user
$questions=qa_db_select_with_pending( $questions = qa_db_select_with_pending(
qa_db_user_updates_selectspec($userid, $forfavorites, $forcontent) qa_db_user_updates_selectspec($userid, $forfavorites, $forcontent)
); );
if ($forfavorites) {
if ($forcontent) {
$sometitle=qa_lang_html('misc/recent_updates_title');
$nonetitle=qa_lang_html('misc/no_recent_updates');
} else { if ($forfavorites) {
$sometitle=qa_lang_html('misc/recent_updates_favorites'); if ($forcontent) {
$nonetitle=qa_lang_html('misc/no_updates_favorites'); $sometitle = qa_lang_html('misc/recent_updates_title');
} $nonetitle = qa_lang_html('misc/no_recent_updates');
} else { } else {
$sometitle=qa_lang_html('misc/recent_updates_content'); $sometitle = qa_lang_html('misc/recent_updates_favorites');
$nonetitle=qa_lang_html('misc/no_updates_content'); $nonetitle = qa_lang_html('misc/no_updates_favorites');
} }
} else {
$sometitle = qa_lang_html('misc/recent_updates_content');
$nonetitle = qa_lang_html('misc/no_updates_content');
}
// Prepare and return content for theme
$qa_content=qa_q_list_page_content(
qa_any_sort_and_dedupe($questions),
null, // questions per page
0, // start offset
null, // total count (null to hide page links)
$sometitle, // title if some questions
$nonetitle, // title if no questions
null, // categories for navigation
null, // selected category id
null, // show question counts in category navigation
null, // prefix for links in category navigation
null, // prefix for RSS feed paths (null to hide)
$forfavorites ? strtr(qa_lang_html('misc/suggest_update_favorites'), array(
'^1' => '<a href="'.qa_path_html('favorites').'">',
'^2' => '</a>',
)) : null // suggest what to do next
);
$qa_content['navigation']['sub']=array(
'all' => array(
'label' => qa_lang_html('misc/nav_all_my_updates'),
'url' => qa_path_html('updates'),
'selected' => $forfavorites && $forcontent,
),
'favorites' => array(
'label' => qa_lang_html('misc/nav_my_favorites'),
'url' => qa_path_html('updates', array('show' => 'favorites')),
'selected' => $forfavorites && !$forcontent,
),
'myposts' => array(
'label' => qa_lang_html('misc/nav_my_content'),
'url' => qa_path_html('updates', array('show' => 'content')),
'selected' => $forcontent && !$forfavorites,
),
);
return $qa_content;
// Prepare and return content for theme
/* $qa_content = qa_q_list_page_content(
Omit PHP closing tag to help avoid accidental output qa_any_sort_and_dedupe($questions),
*/ null, // questions per page
\ No newline at end of file 0, // start offset
null, // total count (null to hide page links)
$sometitle, // title if some questions
$nonetitle, // title if no questions
null, // categories for navigation
null, // selected category id
null, // show question counts in category navigation
null, // prefix for links in category navigation
null, // prefix for RSS feed paths (null to hide)
$forfavorites ? strtr(qa_lang_html('misc/suggest_update_favorites'), array(
'^1' => '<a href="' . qa_path_html('favorites') . '">',
'^2' => '</a>',
)) : null // suggest what to do next
);
$qa_content['navigation']['sub'] = array(
'all' => array(
'label' => qa_lang_html('misc/nav_all_my_updates'),
'url' => qa_path_html('updates'),
'selected' => $forfavorites && $forcontent,
),
'favorites' => array(
'label' => qa_lang_html('misc/nav_my_favorites'),
'url' => qa_path_html('updates', array('show' => 'favorites')),
'selected' => $forfavorites && !$forcontent,
),
'myposts' => array(
'label' => qa_lang_html('misc/nav_my_content'),
'url' => qa_path_html('updates', array('show' => 'content')),
'selected' => $forcontent && !$forfavorites,
),
);
return $qa_content;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment