Commit e6f8efb5 by Scott

Coding style (user profile pages)

parent e449b233
...@@ -20,13 +20,13 @@ ...@@ -20,13 +20,13 @@
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';
// $handle, $userhtml are already set by qa-page-user.php - also $userid if using external user integration // $handle, $userhtml are already set by qa-page-user.php - also $userid if using external user integration
...@@ -34,70 +34,65 @@ ...@@ -34,70 +34,65 @@
// Find the recent activity for this user // Find the recent activity for this user
$loginuserid = qa_get_logged_in_userid(); $loginuserid = qa_get_logged_in_userid();
$identifier = QA_FINAL_EXTERNAL_USERS ? $userid : $handle; $identifier = QA_FINAL_EXTERNAL_USERS ? $userid : $handle;
list($useraccount, $questions, $answerqs, $commentqs, $editqs) = qa_db_select_with_pending( list($useraccount, $questions, $answerqs, $commentqs, $editqs) = qa_db_select_with_pending(
QA_FINAL_EXTERNAL_USERS ? null : qa_db_user_account_selectspec($handle, false), QA_FINAL_EXTERNAL_USERS ? null : qa_db_user_account_selectspec($handle, false),
qa_db_user_recent_qs_selectspec($loginuserid, $identifier, qa_opt_if_loaded('page_size_activity')), qa_db_user_recent_qs_selectspec($loginuserid, $identifier, qa_opt_if_loaded('page_size_activity')),
qa_db_user_recent_a_qs_selectspec($loginuserid, $identifier), qa_db_user_recent_a_qs_selectspec($loginuserid, $identifier),
qa_db_user_recent_c_qs_selectspec($loginuserid, $identifier), qa_db_user_recent_c_qs_selectspec($loginuserid, $identifier),
qa_db_user_recent_edit_qs_selectspec($loginuserid, $identifier) qa_db_user_recent_edit_qs_selectspec($loginuserid, $identifier)
); );
if (!QA_FINAL_EXTERNAL_USERS && !is_array($useraccount)) // check the user exists if (!QA_FINAL_EXTERNAL_USERS && !is_array($useraccount)) // check the user exists
return include QA_INCLUDE_DIR.'qa-page-not-found.php'; return include QA_INCLUDE_DIR . 'qa-page-not-found.php';
// Get information on user references // Get information on user references
$questions = qa_any_sort_and_dedupe(array_merge($questions, $answerqs, $commentqs, $editqs)); $questions = qa_any_sort_and_dedupe(array_merge($questions, $answerqs, $commentqs, $editqs));
$questions = array_slice($questions, 0, qa_opt('page_size_activity')); $questions = array_slice($questions, 0, qa_opt('page_size_activity'));
$usershtml = qa_userids_handles_html(qa_any_get_userids_handles($questions), false); $usershtml = qa_userids_handles_html(qa_any_get_userids_handles($questions), false);
// Prepare content for theme // Prepare content for theme
$qa_content = qa_content_prepare(true); $qa_content = qa_content_prepare(true);
if (count($questions)) if (count($questions))
$qa_content['title'] = qa_lang_html_sub('profile/recent_activity_by_x', $userhtml); $qa_content['title'] = qa_lang_html_sub('profile/recent_activity_by_x', $userhtml);
else else
$qa_content['title'] = qa_lang_html_sub('profile/no_posts_by_x', $userhtml); $qa_content['title'] = qa_lang_html_sub('profile/no_posts_by_x', $userhtml);
// Recent activity by this user // Recent activity by this user
$qa_content['q_list']['form'] = array( $qa_content['q_list']['form'] = array(
'tags' => 'method="post" action="'.qa_self_html().'"', 'tags' => 'method="post" action="' . qa_self_html() . '"',
'hidden' => array( 'hidden' => array(
'code' => qa_get_form_security_code('vote'), 'code' => qa_get_form_security_code('vote'),
), ),
); );
$qa_content['q_list']['qs'] = array(); $qa_content['q_list']['qs'] = array();
$htmldefaults = qa_post_html_defaults('Q'); $htmldefaults = qa_post_html_defaults('Q');
$htmldefaults['whoview'] = false; $htmldefaults['whoview'] = false;
$htmldefaults['voteview'] = false; $htmldefaults['voteview'] = false;
$htmldefaults['avatarsize'] = 0; $htmldefaults['avatarsize'] = 0;
foreach ($questions as $question) { foreach ($questions as $question) {
$qa_content['q_list']['qs'][] = qa_any_to_q_html_fields($question, $loginuserid, qa_cookie_get(), $qa_content['q_list']['qs'][] = qa_any_to_q_html_fields($question, $loginuserid, qa_cookie_get(),
$usershtml, null, array('voteview' => false) + qa_post_html_options($question, $htmldefaults)); $usershtml, null, array('voteview' => false) + qa_post_html_options($question, $htmldefaults));
} }
// Sub menu for navigation in user pages // Sub menu for navigation in user pages
$ismyuser = isset($loginuserid) && $loginuserid == (QA_FINAL_EXTERNAL_USERS ? $userid : $useraccount['userid']); $ismyuser = isset($loginuserid) && $loginuserid == (QA_FINAL_EXTERNAL_USERS ? $userid : $useraccount['userid']);
$qa_content['navigation']['sub'] = qa_user_sub_navigation($handle, 'activity', $ismyuser); $qa_content['navigation']['sub'] = qa_user_sub_navigation($handle, 'activity', $ismyuser);
return $qa_content; return $qa_content;
/*
Omit PHP closing tag to help avoid accidental output
*/
\ No newline at end of file
...@@ -20,91 +20,86 @@ ...@@ -20,91 +20,86 @@
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';
// $handle, $userhtml are already set by qa-page-user.php - also $userid if using external user integration // $handle, $userhtml are already set by qa-page-user.php - also $userid if using external user integration
$start = qa_get_start(); $start = qa_get_start();
// Find the questions for this user // Find the questions for this user
$loginuserid = qa_get_logged_in_userid(); $loginuserid = qa_get_logged_in_userid();
$identifier = QA_FINAL_EXTERNAL_USERS ? $userid : $handle; $identifier = QA_FINAL_EXTERNAL_USERS ? $userid : $handle;
list($useraccount, $userpoints, $questions) = qa_db_select_with_pending( list($useraccount, $userpoints, $questions) = qa_db_select_with_pending(
QA_FINAL_EXTERNAL_USERS ? null : qa_db_user_account_selectspec($handle, false), QA_FINAL_EXTERNAL_USERS ? null : qa_db_user_account_selectspec($handle, false),
qa_db_user_points_selectspec($identifier), qa_db_user_points_selectspec($identifier),
qa_db_user_recent_a_qs_selectspec($loginuserid, $identifier, qa_opt_if_loaded('page_size_activity'), $start) qa_db_user_recent_a_qs_selectspec($loginuserid, $identifier, qa_opt_if_loaded('page_size_activity'), $start)
); );
if (!QA_FINAL_EXTERNAL_USERS && !is_array($useraccount)) // check the user exists if (!QA_FINAL_EXTERNAL_USERS && !is_array($useraccount)) // check the user exists
return include QA_INCLUDE_DIR.'qa-page-not-found.php'; return include QA_INCLUDE_DIR . 'qa-page-not-found.php';
// Get information on user questions // Get information on user questions
$pagesize = qa_opt('page_size_activity'); $pagesize = qa_opt('page_size_activity');
$count = (int)@$userpoints['aposts']; $count = (int)@$userpoints['aposts'];
$questions = array_slice($questions, 0, $pagesize); $questions = array_slice($questions, 0, $pagesize);
$usershtml = qa_userids_handles_html($questions, false); $usershtml = qa_userids_handles_html($questions, false);
// Prepare content for theme // Prepare content for theme
$qa_content = qa_content_prepare(true); $qa_content = qa_content_prepare(true);
if (count($questions)) if (count($questions))
$qa_content['title'] = qa_lang_html_sub('profile/answers_by_x', $userhtml); $qa_content['title'] = qa_lang_html_sub('profile/answers_by_x', $userhtml);
else else
$qa_content['title'] = qa_lang_html_sub('profile/no_answers_by_x', $userhtml); $qa_content['title'] = qa_lang_html_sub('profile/no_answers_by_x', $userhtml);
// Recent questions by this user // Recent questions by this user
$qa_content['q_list']['form'] = array( $qa_content['q_list']['form'] = array(
'tags' => 'method="post" action="'.qa_self_html().'"', 'tags' => 'method="post" action="' . qa_self_html() . '"',
'hidden' => array( 'hidden' => array(
'code' => qa_get_form_security_code('vote'), 'code' => qa_get_form_security_code('vote'),
), ),
); );
$qa_content['q_list']['qs'] = array(); $qa_content['q_list']['qs'] = array();
$htmldefaults = qa_post_html_defaults('Q'); $htmldefaults = qa_post_html_defaults('Q');
$htmldefaults['whoview'] = false; $htmldefaults['whoview'] = false;
$htmldefaults['avatarsize'] = 0; $htmldefaults['avatarsize'] = 0;
$htmldefaults['ovoteview'] = true; $htmldefaults['ovoteview'] = true;
$htmldefaults['answersview'] = false; $htmldefaults['answersview'] = false;
foreach ($questions as $question) { foreach ($questions as $question) {
$options = qa_post_html_options($question, $htmldefaults); $options = qa_post_html_options($question, $htmldefaults);
$options['voteview'] = qa_get_vote_view('A', false, false); $options['voteview'] = qa_get_vote_view('A', false, false);
$qa_content['q_list']['qs'][] = qa_other_to_q_html_fields($question, $loginuserid, qa_cookie_get(), $qa_content['q_list']['qs'][] = qa_other_to_q_html_fields($question, $loginuserid, qa_cookie_get(),
$usershtml, null, $options); $usershtml, null, $options);
} }
$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'));
// Sub menu for navigation in user pages // Sub menu for navigation in user pages
$ismyuser = isset($loginuserid) && $loginuserid == (QA_FINAL_EXTERNAL_USERS ? $userid : $useraccount['userid']); $ismyuser = isset($loginuserid) && $loginuserid == (QA_FINAL_EXTERNAL_USERS ? $userid : $useraccount['userid']);
$qa_content['navigation']['sub'] = qa_user_sub_navigation($handle, 'answers', $ismyuser); $qa_content['navigation']['sub'] = qa_user_sub_navigation($handle, 'answers', $ismyuser);
return $qa_content; return $qa_content;
/*
Omit PHP closing tag to help avoid accidental output
*/
\ No newline at end of file
...@@ -20,86 +20,81 @@ ...@@ -20,86 +20,81 @@
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';
// $handle, $userhtml are already set by qa-page-user.php - also $userid if using external user integration // $handle, $userhtml are already set by qa-page-user.php - also $userid if using external user integration
$start = qa_get_start(); $start = qa_get_start();
// Find the questions for this user // Find the questions for this user
$loginuserid = qa_get_logged_in_userid(); $loginuserid = qa_get_logged_in_userid();
$identifier = QA_FINAL_EXTERNAL_USERS ? $userid : $handle; $identifier = QA_FINAL_EXTERNAL_USERS ? $userid : $handle;
list($useraccount, $userpoints, $questions) = qa_db_select_with_pending( list($useraccount, $userpoints, $questions) = qa_db_select_with_pending(
QA_FINAL_EXTERNAL_USERS ? null : qa_db_user_account_selectspec($handle, false), QA_FINAL_EXTERNAL_USERS ? null : qa_db_user_account_selectspec($handle, false),
qa_db_user_points_selectspec($identifier), qa_db_user_points_selectspec($identifier),
qa_db_user_recent_qs_selectspec($loginuserid, $identifier, qa_opt_if_loaded('page_size_qs'), $start) qa_db_user_recent_qs_selectspec($loginuserid, $identifier, qa_opt_if_loaded('page_size_qs'), $start)
); );
if ((!QA_FINAL_EXTERNAL_USERS) && !is_array($useraccount)) // check the user exists if (!QA_FINAL_EXTERNAL_USERS && !is_array($useraccount)) // check the user exists
return include QA_INCLUDE_DIR.'qa-page-not-found.php'; return include QA_INCLUDE_DIR . 'qa-page-not-found.php';
// Get information on user questions // Get information on user questions
$pagesize = qa_opt('page_size_qs'); $pagesize = qa_opt('page_size_qs');
$count = (int)@$userpoints['qposts']; $count = (int)@$userpoints['qposts'];
$questions = array_slice($questions, 0, $pagesize); $questions = array_slice($questions, 0, $pagesize);
$usershtml = qa_userids_handles_html($questions, false); $usershtml = qa_userids_handles_html($questions, false);
// Prepare content for theme // Prepare content for theme
$qa_content = qa_content_prepare(true); $qa_content = qa_content_prepare(true);
if (count($questions)) if (count($questions))
$qa_content['title'] = qa_lang_html_sub('profile/questions_by_x', $userhtml); $qa_content['title'] = qa_lang_html_sub('profile/questions_by_x', $userhtml);
else else
$qa_content['title'] = qa_lang_html_sub('profile/no_questions_by_x', $userhtml); $qa_content['title'] = qa_lang_html_sub('profile/no_questions_by_x', $userhtml);
// Recent questions by this user // Recent questions by this user
$qa_content['q_list']['form'] = array( $qa_content['q_list']['form'] = array(
'tags' => 'method="post" action="'.qa_self_html().'"', 'tags' => 'method="post" action="' . qa_self_html() . '"',
'hidden' => array( 'hidden' => array(
'code' => qa_get_form_security_code('vote'), 'code' => qa_get_form_security_code('vote'),
), ),
); );
$qa_content['q_list']['qs'] = array(); $qa_content['q_list']['qs'] = array();
$htmldefaults = qa_post_html_defaults('Q'); $htmldefaults = qa_post_html_defaults('Q');
$htmldefaults['whoview'] = false; $htmldefaults['whoview'] = false;
$htmldefaults['avatarsize'] = 0; $htmldefaults['avatarsize'] = 0;
foreach ($questions as $question) { foreach ($questions as $question) {
$qa_content['q_list']['qs'][] = qa_post_html_fields($question, $loginuserid, qa_cookie_get(), $qa_content['q_list']['qs'][] = qa_post_html_fields($question, $loginuserid, qa_cookie_get(),
$usershtml, null, qa_post_html_options($question, $htmldefaults)); $usershtml, null, qa_post_html_options($question, $htmldefaults));
} }
$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'));
// Sub menu for navigation in user pages // Sub menu for navigation in user pages
$ismyuser = isset($loginuserid) && $loginuserid == (QA_FINAL_EXTERNAL_USERS ? $userid : $useraccount['userid']); $ismyuser = isset($loginuserid) && $loginuserid == (QA_FINAL_EXTERNAL_USERS ? $userid : $useraccount['userid']);
$qa_content['navigation']['sub'] = qa_user_sub_navigation($handle, 'questions', $ismyuser); $qa_content['navigation']['sub'] = qa_user_sub_navigation($handle, 'questions', $ismyuser);
return $qa_content; return $qa_content;
/*
Omit PHP closing tag to help avoid accidental output
*/
\ No newline at end of file
...@@ -20,145 +20,137 @@ ...@@ -20,145 +20,137 @@
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/messages.php'; require_once QA_INCLUDE_DIR . 'app/messages.php';
// Check we're not using single-sign on integration, which doesn't allow walls // Check we're not using single-sign on integration, which doesn't allow walls
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');
// $handle, $userhtml are already set by qa-page-user.php // $handle, $userhtml are already set by qa-page-user.php
$start = qa_get_start(); $start = qa_get_start();
// Find the questions for this user // Find the questions for this user
list($useraccount, $usermessages) = qa_db_select_with_pending( list($useraccount, $usermessages) = qa_db_select_with_pending(
qa_db_user_account_selectspec($handle, false), qa_db_user_account_selectspec($handle, false),
qa_db_recent_messages_selectspec(null, null, $handle, false, qa_opt_if_loaded('page_size_wall'), $start) qa_db_recent_messages_selectspec(null, null, $handle, false, qa_opt_if_loaded('page_size_wall'), $start)
); );
if (!is_array($useraccount)) // check the user exists if (!is_array($useraccount)) // check the user exists
return include QA_INCLUDE_DIR.'qa-page-not-found.php'; return include QA_INCLUDE_DIR . 'qa-page-not-found.php';
// Perform pagination // Perform pagination
$pagesize = qa_opt('page_size_wall'); $pagesize = qa_opt('page_size_wall');
$count = $useraccount['wallposts']; $count = $useraccount['wallposts'];
$loginuserid = qa_get_logged_in_userid(); $loginuserid = qa_get_logged_in_userid();
$usermessages = array_slice($usermessages, 0, $pagesize); $usermessages = array_slice($usermessages, 0, $pagesize);
$usermessages = qa_wall_posts_add_rules($usermessages, $start); $usermessages = qa_wall_posts_add_rules($usermessages, $start);
// Process deleting or adding a wall post (similar but not identical code to qq-page-user-profile.php) // Process deleting or adding a wall post (similar but not identical code to qq-page-user-profile.php)
$errors = array(); $errors = array();
$wallposterrorhtml = qa_wall_error_html($loginuserid, $useraccount['userid'], $useraccount['flags']);
foreach ($usermessages as $message) { $wallposterrorhtml = qa_wall_error_html($loginuserid, $useraccount['userid'], $useraccount['flags']);
if ($message['deleteable'] && qa_clicked('m'.$message['messageid'].'_dodelete')) {
if (!qa_check_form_security_code('wall-'.$useraccount['handle'], qa_post_text('code')))
$errors['page'] = qa_lang_html('misc/form_security_again');
else { foreach ($usermessages as $message) {
qa_wall_delete_post($loginuserid, qa_get_logged_in_handle(), qa_cookie_get(), $message); if ($message['deleteable'] && qa_clicked('m' . $message['messageid'] . '_dodelete')) {
qa_redirect(qa_request(), $_GET); if (!qa_check_form_security_code('wall-' . $useraccount['handle'], qa_post_text('code'))) {
} $errors['page'] = qa_lang_html('misc/form_security_again');
} else {
qa_wall_delete_post($loginuserid, qa_get_logged_in_handle(), qa_cookie_get(), $message);
qa_redirect(qa_request(), $_GET);
} }
} }
}
if (qa_clicked('dowallpost')) {
$inmessage = qa_post_text('message'); if (qa_clicked('dowallpost')) {
$inmessage = qa_post_text('message');
if (!strlen($inmessage))
$errors['message'] = qa_lang('profile/post_wall_empty'); if (!strlen($inmessage)) {
$errors['message'] = qa_lang('profile/post_wall_empty');
elseif (!qa_check_form_security_code('wall-'.$useraccount['handle'], qa_post_text('code'))) } elseif (!qa_check_form_security_code('wall-' . $useraccount['handle'], qa_post_text('code'))) {
$errors['message'] = qa_lang_html('misc/form_security_again'); $errors['message'] = qa_lang_html('misc/form_security_again');
} elseif (!$wallposterrorhtml) {
elseif (!$wallposterrorhtml) { qa_wall_add_post($loginuserid, qa_get_logged_in_handle(), qa_cookie_get(), $useraccount['userid'], $useraccount['handle'], $inmessage, '');
qa_wall_add_post($loginuserid, qa_get_logged_in_handle(), qa_cookie_get(), $useraccount['userid'], $useraccount['handle'], $inmessage, ''); qa_redirect(qa_request());
qa_redirect(qa_request());
}
} }
}
// Prepare content for theme // Prepare content for theme
$qa_content = qa_content_prepare(); $qa_content = qa_content_prepare();
$qa_content['title'] = qa_lang_html_sub('profile/wall_for_x', $userhtml); $qa_content['title'] = qa_lang_html_sub('profile/wall_for_x', $userhtml);
$qa_content['error'] = @$errors['page']; $qa_content['error'] = @$errors['page'];
$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="wallmessages"', 'tags' => 'id="wallmessages"',
'form' => array( 'form' => array(
'tags' => 'name="wallpost" method="post" action="'.qa_self_html().'"', 'tags' => 'name="wallpost" 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($useraccount['handle']), 'handle' => qa_html($useraccount['handle']),
'start' => qa_html($start), 'start' => qa_html($start),
'code' => qa_get_form_security_code('wall-'.$useraccount['handle']), 'code' => qa_get_form_security_code('wall-' . $useraccount['handle']),
),
), ),
),
'messages' => array(),
);
if ($start == 0) { // only allow posting on first page
if ($wallposterrorhtml) {
$qa_content['message_list']['error'] = $wallposterrorhtml; // an error that means we are not allowed to post
} else {
$qa_content['message_list']['form']['fields'] = array(
'message' => array(
'tags' => 'name="message" id="message"',
'value' => qa_html(@$inmessage, false),
'rows' => 2,
'error' => qa_html(@$errors['message']),
),
);
'messages' => array(), $qa_content['message_list']['form']['buttons'] = array(
); 'post' => array(
'tags' => 'name="dowallpost" onclick="return qa_submit_wall_post(this, false);"',
if ($start == 0) { // only allow posting on first page 'label' => qa_lang_html('profile/post_wall_button'),
if ($wallposterrorhtml) ),
$qa_content['message_list']['error'] = $wallposterrorhtml; // an error that means we are not allowed to post );
else {
$qa_content['message_list']['form']['fields'] = array(
'message' => array(
'tags' => 'name="message" id="message"',
'value' => qa_html(@$inmessage, false),
'rows' => 2,
'error' => qa_html(@$errors['message']),
),
);
$qa_content['message_list']['form']['buttons'] = array(
'post' => array(
'tags' => 'name="dowallpost" onclick="return qa_submit_wall_post(this, false);"',
'label' => qa_lang_html('profile/post_wall_button'),
),
);
}
} }
}
foreach ($usermessages as $message) foreach ($usermessages as $message) {
$qa_content['message_list']['messages'][] = qa_wall_post_view($message); $qa_content['message_list']['messages'][] = qa_wall_post_view($message);
}
$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'));
// Sub menu for navigation in user pages // Sub menu for navigation in user pages
$ismyuser = isset($loginuserid) && $loginuserid == (QA_FINAL_EXTERNAL_USERS ? $userid : $useraccount['userid']); $ismyuser = isset($loginuserid) && $loginuserid == (QA_FINAL_EXTERNAL_USERS ? $userid : $useraccount['userid']);
$qa_content['navigation']['sub'] = qa_user_sub_navigation($handle, 'wall', $ismyuser); $qa_content['navigation']['sub'] = qa_user_sub_navigation($handle, 'wall', $ismyuser);
return $qa_content; return $qa_content;
/*
Omit PHP closing tag to help avoid accidental output
*/
\ No newline at end of file
...@@ -20,71 +20,66 @@ ...@@ -20,71 +20,66 @@
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;
} }
// Determine the identify of the user // Determine the identify of the user
$handle = qa_request_part(1); $handle = qa_request_part(1);
if (!strlen($handle)) { if (!strlen($handle)) {
$handle = qa_get_logged_in_handle(); $handle = qa_get_logged_in_handle();
qa_redirect(!empty($handle) ? 'user/'.$handle : 'users'); qa_redirect(!empty($handle) ? 'user/' . $handle : 'users');
} }
// Get the HTML to display for the handle, and if we're using external users, determine the userid // Get the HTML to display for the handle, and if we're using external users, determine the userid
if (QA_FINAL_EXTERNAL_USERS) { if (QA_FINAL_EXTERNAL_USERS) {
$userid = qa_handle_to_userid($handle); $userid = qa_handle_to_userid($handle);
if (!isset($userid)) if (!isset($userid))
return include QA_INCLUDE_DIR.'qa-page-not-found.php'; return include QA_INCLUDE_DIR . 'qa-page-not-found.php';
$usershtml = qa_get_users_html(array($userid), false, qa_path_to_root(), true); $usershtml = qa_get_users_html(array($userid), false, qa_path_to_root(), true);
$userhtml = @$usershtml[$userid]; $userhtml = @$usershtml[$userid];
} } else
else $userhtml = qa_html($handle);
$userhtml = qa_html($handle);
// Display the appropriate page based on the request // Display the appropriate page based on the request
switch (qa_request_part(2)) { switch (qa_request_part(2)) {
case 'wall': case 'wall':
qa_set_template('user-wall'); qa_set_template('user-wall');
$qa_content = include QA_INCLUDE_DIR.'pages/user-wall.php'; $qa_content = include QA_INCLUDE_DIR . 'pages/user-wall.php';
break; break;
case 'activity': case 'activity':
qa_set_template('user-activity'); qa_set_template('user-activity');
$qa_content = include QA_INCLUDE_DIR.'pages/user-activity.php'; $qa_content = include QA_INCLUDE_DIR . 'pages/user-activity.php';
break; break;
case 'questions': case 'questions':
qa_set_template('user-questions'); qa_set_template('user-questions');
$qa_content = include QA_INCLUDE_DIR.'pages/user-questions.php'; $qa_content = include QA_INCLUDE_DIR . 'pages/user-questions.php';
break; break;
case 'answers': case 'answers':
qa_set_template('user-answers'); qa_set_template('user-answers');
$qa_content = include QA_INCLUDE_DIR.'pages/user-answers.php'; $qa_content = include QA_INCLUDE_DIR . 'pages/user-answers.php';
break; break;
case null: case null:
$qa_content = include QA_INCLUDE_DIR.'pages/user-profile.php'; $qa_content = include QA_INCLUDE_DIR . 'pages/user-profile.php';
break; break;
default: default:
$qa_content = include QA_INCLUDE_DIR.'qa-page-not-found.php'; $qa_content = include QA_INCLUDE_DIR . 'qa-page-not-found.php';
break; break;
} }
return $qa_content; return $qa_content;
/*
Omit PHP closing tag to help avoid accidental output
*/
\ No newline at end of file
...@@ -20,76 +20,71 @@ ...@@ -20,76 +20,71 @@
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';
// 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 accounts are handled by external code'); qa_fatal_error('User accounts are handled by external code');
// Get list of blocked users // Get list of blocked users
$start = qa_get_start(); $start = qa_get_start();
$pagesize = qa_opt('page_size_users'); $pagesize = qa_opt('page_size_users');
$userSpecCount = qa_db_selectspec_count( qa_db_users_with_flag_selectspec(QA_USER_FLAGS_USER_BLOCKED) ); $userSpecCount = qa_db_selectspec_count(qa_db_users_with_flag_selectspec(QA_USER_FLAGS_USER_BLOCKED));
$userSpec = qa_db_users_with_flag_selectspec(QA_USER_FLAGS_USER_BLOCKED, $start, $pagesize); $userSpec = qa_db_users_with_flag_selectspec(QA_USER_FLAGS_USER_BLOCKED, $start, $pagesize);
list($numUsers, $users) = qa_db_select_with_pending($userSpecCount, $userSpec); list($numUsers, $users) = qa_db_select_with_pending($userSpecCount, $userSpec);
$count = $numUsers['count']; $count = $numUsers['count'];
// Check we have permission to view this page (moderator or above) // Check we have permission to view this page (moderator or above)
if (qa_get_logged_in_level() < QA_USER_LEVEL_MODERATOR) { if (qa_get_logged_in_level() < QA_USER_LEVEL_MODERATOR) {
$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;
} }
// Get userids and handles of retrieved users // Get userids and handles of retrieved users
$usershtml = qa_userids_handles_html($users); $usershtml = qa_userids_handles_html($users);
// Prepare content for theme // Prepare content for theme
$qa_content = qa_content_prepare(); $qa_content = qa_content_prepare();
$qa_content['title'] = $count > 0 ? qa_lang_html('users/blocked_users') : qa_lang_html('users/no_blocked_users'); $qa_content['title'] = $count > 0 ? qa_lang_html('users/blocked_users') : qa_lang_html('users/no_blocked_users');
$qa_content['ranking'] = array(
'items' => array(),
'rows' => ceil(count($users)/qa_opt('columns_users')),
'type' => 'users'
);
foreach ($users as $user) { $qa_content['ranking'] = array(
$qa_content['ranking']['items'][] = array( 'items' => array(),
'label' => $usershtml[$user['userid']], 'rows' => ceil(count($users) / qa_opt('columns_users')),
'score' => qa_html(qa_user_level_string($user['level'])), 'type' => 'users'
'raw' => $user, );
);
}
$qa_content['page_links'] = qa_html_page_links(qa_request(), $start, $pagesize, $count, qa_opt('pages_prev_next')); foreach ($users as $user) {
$qa_content['ranking']['items'][] = array(
$qa_content['navigation']['sub'] = qa_users_sub_navigation(); 'label' => $usershtml[$user['userid']],
'score' => qa_html(qa_user_level_string($user['level'])),
'raw' => $user,
);
}
$qa_content['page_links'] = qa_html_page_links(qa_request(), $start, $pagesize, $count, qa_opt('pages_prev_next'));
return $qa_content; $qa_content['navigation']['sub'] = qa_users_sub_navigation();
/* return $qa_content;
Omit PHP closing tag to help avoid accidental output
*/
\ No newline at end of file
...@@ -20,67 +20,62 @@ ...@@ -20,67 +20,62 @@
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';
// 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 accounts are handled by external code'); qa_fatal_error('User accounts are handled by external code');
// Get list of special users // Get list of special users
$users = qa_db_select_with_pending(qa_db_users_from_level_selectspec(QA_USER_LEVEL_EXPERT)); $users = qa_db_select_with_pending(qa_db_users_from_level_selectspec(QA_USER_LEVEL_EXPERT));
// Check we have permission to view this page (moderator or above) // Check we have permission to view this page (moderator or above)
if (qa_get_logged_in_level() < QA_USER_LEVEL_MODERATOR) { if (qa_get_logged_in_level() < QA_USER_LEVEL_MODERATOR) {
$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;
} }
// Get userids and handles of retrieved users // Get userids and handles of retrieved users
$usershtml = qa_userids_handles_html($users); $usershtml = qa_userids_handles_html($users);
// 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/special_users'); $qa_content['title'] = qa_lang_html('users/special_users');
$qa_content['ranking'] = array(
'items' => array(),
'rows' => ceil(qa_opt('page_size_users')/qa_opt('columns_users')),
'type' => 'users'
);
foreach ($users as $user) { $qa_content['ranking'] = array(
$qa_content['ranking']['items'][] = array( 'items' => array(),
'label' => $usershtml[$user['userid']], 'rows' => ceil(qa_opt('page_size_users') / qa_opt('columns_users')),
'score' => qa_html(qa_user_level_string($user['level'])), 'type' => 'users'
'raw' => $user, );
);
}
$qa_content['navigation']['sub'] = qa_users_sub_navigation();
foreach ($users as $user) {
$qa_content['ranking']['items'][] = array(
'label' => $usershtml[$user['userid']],
'score' => qa_html(qa_user_level_string($user['level'])),
'raw' => $user,
);
}
return $qa_content; $qa_content['navigation']['sub'] = qa_users_sub_navigation();
/* return $qa_content;
Omit PHP closing tag to help avoid accidental output
*/
\ No newline at end of file
...@@ -20,72 +20,67 @@ ...@@ -20,72 +20,67 @@
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.'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 list of all users // Get list of all users
$start = qa_get_start(); $start = qa_get_start();
$users = qa_db_select_with_pending(qa_db_top_users_selectspec($start, qa_opt_if_loaded('page_size_users'))); $users = qa_db_select_with_pending(qa_db_top_users_selectspec($start, qa_opt_if_loaded('page_size_users')));
$usercount = qa_opt('cache_userpointscount'); $usercount = qa_opt('cache_userpointscount');
$pagesize = qa_opt('page_size_users'); $pagesize = qa_opt('page_size_users');
$users = array_slice($users, 0, $pagesize); $users = array_slice($users, 0, $pagesize);
$usershtml = qa_userids_handles_html($users); $usershtml = qa_userids_handles_html($users);
// 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/highest_users'); $qa_content['title'] = qa_lang_html('main/highest_users');
$qa_content['ranking'] = array(
'items' => array(),
'rows' => ceil($pagesize/qa_opt('columns_users')),
'type' => 'users'
);
if (count($users)) {
foreach ($users as $userid => $user) {
if (QA_FINAL_EXTERNAL_USERS)
$avatarhtml = qa_get_external_avatar_html($user['userid'], qa_opt('avatar_users_size'), true);
else {
$avatarhtml = qa_get_user_avatar_html($user['flags'], $user['email'], $user['handle'],
$user['avatarblobid'], $user['avatarwidth'], $user['avatarheight'], qa_opt('avatar_users_size'), true);
}
// avatar and handle now listed separately for use in themes
$qa_content['ranking']['items'][] = array(
'avatar' => $avatarhtml,
'label' => $usershtml[$user['userid']],
'score' => qa_html(qa_format_number($user['points'], 0, true)),
'raw' => $user,
);
}
}
else
$qa_content['title'] = qa_lang_html('main/no_active_users');
$qa_content['ranking'] = array(
'items' => array(),
'rows' => ceil($pagesize / qa_opt('columns_users')),
'type' => 'users'
);
// set the canonical url based on possible pagination if (count($users)) {
$qa_content['canonical'] = qa_path_html(qa_request(), ($start > 0 ? array('start' => $start) : null), qa_opt('site_url')); foreach ($users as $userid => $user) {
if (QA_FINAL_EXTERNAL_USERS)
$avatarhtml = qa_get_external_avatar_html($user['userid'], qa_opt('avatar_users_size'), true);
else {
$avatarhtml = qa_get_user_avatar_html($user['flags'], $user['email'], $user['handle'],
$user['avatarblobid'], $user['avatarwidth'], $user['avatarheight'], qa_opt('avatar_users_size'), true);
}
// avatar and handle now listed separately for use in themes
$qa_content['ranking']['items'][] = array(
'avatar' => $avatarhtml,
'label' => $usershtml[$user['userid']],
'score' => qa_html(qa_format_number($user['points'], 0, true)),
'raw' => $user,
);
}
} else {
$qa_content['title'] = qa_lang_html('main/no_active_users');
}
$qa_content['page_links'] = qa_html_page_links(qa_request(), $start, $pagesize, $usercount, qa_opt('pages_prev_next'));
$qa_content['navigation']['sub'] = qa_users_sub_navigation(); // set the canonical url based on possible pagination
$qa_content['canonical'] = qa_path_html(qa_request(), ($start > 0 ? array('start' => $start) : null), qa_opt('site_url'));
$qa_content['page_links'] = qa_html_page_links(qa_request(), $start, $pagesize, $usercount, qa_opt('pages_prev_next'));
return $qa_content; $qa_content['navigation']['sub'] = qa_users_sub_navigation();
/* return $qa_content;
Omit PHP closing tag to help avoid accidental output
*/
\ No newline at end of file
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