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,15 +20,15 @@ ...@@ -20,15 +20,15 @@
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/limits.php'; require_once QA_INCLUDE_DIR . 'app/limits.php';
require_once QA_INCLUDE_DIR.'app/updates.php'; require_once QA_INCLUDE_DIR . 'app/updates.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
...@@ -36,17 +36,16 @@ ...@@ -36,17 +36,16 @@
// Redirect to 'My Account' page if button clicked // Redirect to 'My Account' page if button clicked
if (qa_clicked('doaccount')) if (qa_clicked('doaccount'))
qa_redirect('account'); qa_redirect('account');
// Find the user profile and questions and answers for this handle // Find the user profile and questions and answers for this handle
$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, $userprofile, $userfields, $usermessages, $userpoints, $userlevels, $navcategories, $userrank) = list($useraccount, $userprofile, $userfields, $usermessages, $userpoints, $userlevels, $navcategories, $userrank) = qa_db_select_with_pending(
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_FINAL_EXTERNAL_USERS ? null : qa_db_user_profile_selectspec($handle, false), QA_FINAL_EXTERNAL_USERS ? null : qa_db_user_profile_selectspec($handle, false),
QA_FINAL_EXTERNAL_USERS ? null : qa_db_userfields_selectspec(), QA_FINAL_EXTERNAL_USERS ? null : qa_db_userfields_selectspec(),
...@@ -55,27 +54,27 @@ ...@@ -55,27 +54,27 @@
qa_db_user_levels_selectspec($identifier, QA_FINAL_EXTERNAL_USERS, true), qa_db_user_levels_selectspec($identifier, QA_FINAL_EXTERNAL_USERS, true),
qa_db_category_nav_selectspec(null, true), qa_db_category_nav_selectspec(null, true),
qa_db_user_rank_selectspec($identifier) qa_db_user_rank_selectspec($identifier)
); );
if (!QA_FINAL_EXTERNAL_USERS) { if (!QA_FINAL_EXTERNAL_USERS) {
foreach ($userfields as $index => $userfield) { foreach ($userfields as $index => $userfield) {
if ( isset($userfield['permit']) && qa_permit_value_error($userfield['permit'], $loginuserid, qa_get_logged_in_level(), qa_get_logged_in_flags()) ) if (isset($userfield['permit']) && qa_permit_value_error($userfield['permit'], $loginuserid, qa_get_logged_in_level(), qa_get_logged_in_flags()))
unset($userfields[$index]); // don't pay attention to user fields we're not allowed to view unset($userfields[$index]); // don't pay attention to user fields we're not allowed to view
} }
} }
// Check the user exists and work out what can and can't be set (if not using single sign-on) // Check the user exists and work out what can and can't be set (if not using single sign-on)
$errors = array(); $errors = array();
$loginlevel = qa_get_logged_in_level(); $loginlevel = qa_get_logged_in_level();
if (!QA_FINAL_EXTERNAL_USERS) { // if we're using integrated user management, we can know and show more if (!QA_FINAL_EXTERNAL_USERS) { // if we're using integrated user management, we can know and show more
require_once QA_INCLUDE_DIR.'app/messages.php'; require_once QA_INCLUDE_DIR . 'app/messages.php';
if ((!is_array($userpoints)) && !is_array($useraccount)) if ((!is_array($userpoints)) && !is_array($useraccount))
return include QA_INCLUDE_DIR.'qa-page-not-found.php'; return include QA_INCLUDE_DIR . 'qa-page-not-found.php';
$userid = $useraccount['userid']; $userid = $useraccount['userid'];
$fieldseditable = false; $fieldseditable = false;
...@@ -85,19 +84,15 @@ ...@@ -85,19 +84,15 @@
foreach ($userlevels as $userlevel) foreach ($userlevels as $userlevel)
$maxuserlevel = max($maxuserlevel, $userlevel['level']); $maxuserlevel = max($maxuserlevel, $userlevel['level']);
if ( if (isset($loginuserid) && $loginuserid != $userid &&
isset($loginuserid) && ($loginlevel >= QA_USER_LEVEL_SUPER || $loginlevel > $maxuserlevel) &&
($loginuserid != $userid) && !qa_user_permit_error()
(($loginlevel >= QA_USER_LEVEL_SUPER) || ($loginlevel > $maxuserlevel)) &&
(!qa_user_permit_error())
) { // can't change self - or someone on your level (or higher, obviously) unless you're a super admin ) { // can't change self - or someone on your level (or higher, obviously) unless you're a super admin
if ($loginlevel >= QA_USER_LEVEL_SUPER) if ($loginlevel >= QA_USER_LEVEL_SUPER)
$maxlevelassign = QA_USER_LEVEL_SUPER; $maxlevelassign = QA_USER_LEVEL_SUPER;
elseif ($loginlevel >= QA_USER_LEVEL_ADMIN) elseif ($loginlevel >= QA_USER_LEVEL_ADMIN)
$maxlevelassign = QA_USER_LEVEL_MODERATOR; $maxlevelassign = QA_USER_LEVEL_MODERATOR;
elseif ($loginlevel >= QA_USER_LEVEL_MODERATOR) elseif ($loginlevel >= QA_USER_LEVEL_MODERATOR)
$maxlevelassign = QA_USER_LEVEL_EXPERT; $maxlevelassign = QA_USER_LEVEL_EXPERT;
...@@ -124,8 +119,8 @@ ...@@ -124,8 +119,8 @@
$usermessages = qa_wall_posts_add_rules($usermessages, 0); $usermessages = qa_wall_posts_add_rules($usermessages, 0);
foreach ($usermessages as $message) { foreach ($usermessages as $message) {
if ($message['deleteable'] && qa_clicked('m'.$message['messageid'].'_dodelete')) { if ($message['deleteable'] && qa_clicked('m' . $message['messageid'] . '_dodelete')) {
if (!qa_check_form_security_code('wall-'.$useraccount['handle'], qa_post_text('code'))) if (!qa_check_form_security_code('wall-' . $useraccount['handle'], qa_post_text('code')))
$errors['page'] = qa_lang_html('misc/form_security_again'); $errors['page'] = qa_lang_html('misc/form_security_again');
else { else {
qa_wall_delete_post($loginuserid, qa_get_logged_in_handle(), qa_cookie_get(), $message); qa_wall_delete_post($loginuserid, qa_get_logged_in_handle(), qa_cookie_get(), $message);
...@@ -133,42 +128,39 @@ ...@@ -133,42 +128,39 @@
} }
} }
} }
} }
// Process edit or save button for user, and other actions // Process edit or save button for user, and other actions
if (!QA_FINAL_EXTERNAL_USERS) { if (!QA_FINAL_EXTERNAL_USERS) {
$reloaduser = false; $reloaduser = false;
if ($usereditbutton) { if ($usereditbutton) {
if (qa_clicked('docancel')) if (qa_clicked('docancel')) {
qa_redirect(qa_request()); qa_redirect(qa_request());
} elseif (qa_clicked('doedit')) {
elseif (qa_clicked('doedit'))
qa_redirect(qa_request(), array('state' => 'edit')); qa_redirect(qa_request(), array('state' => 'edit'));
} elseif (qa_clicked('dosave')) {
elseif (qa_clicked('dosave')) { require_once QA_INCLUDE_DIR . 'app/users-edit.php';
require_once QA_INCLUDE_DIR.'app/users-edit.php'; require_once QA_INCLUDE_DIR . 'db/users.php';
require_once QA_INCLUDE_DIR.'db/users.php';
$inemail = qa_post_text('email'); $inemail = qa_post_text('email');
$inprofile = array(); $inprofile = array();
foreach ($userfields as $userfield) foreach ($userfields as $userfield)
$inprofile[$userfield['fieldid']] = qa_post_text('field_'.$userfield['fieldid']); $inprofile[$userfield['fieldid']] = qa_post_text('field_' . $userfield['fieldid']);
if (!qa_check_form_security_code('user-edit-'.$handle, qa_post_text('code'))) { if (!qa_check_form_security_code('user-edit-' . $handle, qa_post_text('code'))) {
$errors['page'] = qa_lang_html('misc/form_security_again'); $errors['page'] = qa_lang_html('misc/form_security_again');
$userediting = true; $userediting = true;
} } else {
else {
if (qa_post_text('removeavatar')) { if (qa_post_text('removeavatar')) {
qa_db_user_set_flag($userid, QA_USER_FLAGS_SHOW_AVATAR, false); qa_db_user_set_flag($userid, QA_USER_FLAGS_SHOW_AVATAR, false);
qa_db_user_set_flag($userid, QA_USER_FLAGS_SHOW_GRAVATAR, false); qa_db_user_set_flag($userid, QA_USER_FLAGS_SHOW_GRAVATAR, false);
if (isset($useraccount['avatarblobid'])) { if (isset($useraccount['avatarblobid'])) {
require_once QA_INCLUDE_DIR.'app/blobs.php'; require_once QA_INCLUDE_DIR . 'app/blobs.php';
qa_db_user_set($userid, 'avatarblobid', null); qa_db_user_set($userid, 'avatarblobid', null);
qa_db_user_set($userid, 'avatarwidth', null); qa_db_user_set($userid, 'avatarwidth', null);
...@@ -182,11 +174,12 @@ ...@@ -182,11 +174,12 @@
$errors = qa_handle_email_filter($filterhandle, $inemail, $useraccount); $errors = qa_handle_email_filter($filterhandle, $inemail, $useraccount);
unset($errors['handle']); // ...and we don't care about any errors in it unset($errors['handle']); // ...and we don't care about any errors in it
if (!isset($errors['email'])) if (!isset($errors['email'])) {
if ($inemail != $useraccount['email']) { if ($inemail != $useraccount['email']) {
qa_db_user_set($userid, 'email', $inemail); qa_db_user_set($userid, 'email', $inemail);
qa_db_user_set_flag($userid, QA_USER_FLAGS_EMAIL_CONFIRMED, false); qa_db_user_set_flag($userid, QA_USER_FLAGS_EMAIL_CONFIRMED, false);
} }
}
if (count($inprofile)) { if (count($inprofile)) {
$filtermodules = qa_load_modules_with('filter', 'filter_profile'); $filtermodules = qa_load_modules_with('filter', 'filter_profile');
...@@ -194,9 +187,10 @@ ...@@ -194,9 +187,10 @@
$filtermodule->filter_profile($inprofile, $errors, $useraccount, $userprofile); $filtermodule->filter_profile($inprofile, $errors, $useraccount, $userprofile);
} }
foreach ($userfields as $userfield) foreach ($userfields as $userfield) {
if (!isset($errors[$userfield['fieldid']])) if (!isset($errors[$userfield['fieldid']]))
qa_db_user_profile_set($userid, $userfield['title'], $inprofile[$userfield['fieldid']]); qa_db_user_profile_set($userid, $userfield['title'], $inprofile[$userfield['fieldid']]);
}
if (count($errors)) if (count($errors))
$userediting = true; $userediting = true;
...@@ -216,19 +210,20 @@ ...@@ -216,19 +210,20 @@
$inuserlevels = array(); $inuserlevels = array();
for ($index = 1; $index <= 999; $index++) { for ($index = 1; $index <= 999; $index++) {
$inlevel = qa_post_text('uc_'.$index.'_level'); $inlevel = qa_post_text('uc_' . $index . '_level');
if (!isset($inlevel)) if (!isset($inlevel))
break; break;
$categoryid = qa_get_category_field_value('uc_'.$index.'_cat'); $categoryid = qa_get_category_field_value('uc_' . $index . '_cat');
if (strlen($categoryid) && strlen($inlevel)) if (strlen($categoryid) && strlen($inlevel)) {
$inuserlevels[] = array( $inuserlevels[] = array(
'entitytype' => QA_ENTITY_CATEGORY, 'entitytype' => QA_ENTITY_CATEGORY,
'entityid' => $categoryid, 'entityid' => $categoryid,
'level' => min($maxlevelassign, (int)$inlevel), 'level' => min($maxlevelassign, (int)$inlevel),
); );
} }
}
qa_db_user_levels_set($userid, $inuserlevels); qa_db_user_levels_set($userid, $inuserlevels);
} }
...@@ -247,34 +242,34 @@ ...@@ -247,34 +242,34 @@
} }
if (qa_clicked('doapprove') || qa_clicked('doblock') || qa_clicked('dounblock') || qa_clicked('dohideall') || qa_clicked('dodelete')) { if (qa_clicked('doapprove') || qa_clicked('doblock') || qa_clicked('dounblock') || qa_clicked('dohideall') || qa_clicked('dodelete')) {
if (!qa_check_form_security_code('user-'.$handle, qa_post_text('code'))) if (!qa_check_form_security_code('user-' . $handle, 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 ($approvebutton && qa_clicked('doapprove')) { if ($approvebutton && qa_clicked('doapprove')) {
require_once QA_INCLUDE_DIR.'app/users-edit.php'; require_once QA_INCLUDE_DIR . 'app/users-edit.php';
qa_set_user_level($userid, $useraccount['handle'], QA_USER_LEVEL_APPROVED, $useraccount['level']); qa_set_user_level($userid, $useraccount['handle'], QA_USER_LEVEL_APPROVED, $useraccount['level']);
qa_redirect(qa_request()); qa_redirect(qa_request());
} }
if (isset($maxlevelassign) && ($maxuserlevel < QA_USER_LEVEL_MODERATOR)) { if (isset($maxlevelassign) && ($maxuserlevel < QA_USER_LEVEL_MODERATOR)) {
if (qa_clicked('doblock')) { if (qa_clicked('doblock')) {
require_once QA_INCLUDE_DIR.'app/users-edit.php'; require_once QA_INCLUDE_DIR . 'app/users-edit.php';
qa_set_user_blocked($userid, $useraccount['handle'], true); qa_set_user_blocked($userid, $useraccount['handle'], true);
qa_redirect(qa_request()); qa_redirect(qa_request());
} }
if (qa_clicked('dounblock')) { if (qa_clicked('dounblock')) {
require_once QA_INCLUDE_DIR.'app/users-edit.php'; require_once QA_INCLUDE_DIR . 'app/users-edit.php';
qa_set_user_blocked($userid, $useraccount['handle'], false); qa_set_user_blocked($userid, $useraccount['handle'], false);
qa_redirect(qa_request()); qa_redirect(qa_request());
} }
if (qa_clicked('dohideall') && !qa_user_permit_error('permit_hide_show')) { if (qa_clicked('dohideall') && !qa_user_permit_error('permit_hide_show')) {
require_once QA_INCLUDE_DIR.'db/admin.php'; require_once QA_INCLUDE_DIR . 'db/admin.php';
require_once QA_INCLUDE_DIR.'app/posts.php'; require_once QA_INCLUDE_DIR . 'app/posts.php';
$postids = qa_db_get_user_visible_postids($userid); $postids = qa_db_get_user_visible_postids($userid);
...@@ -285,7 +280,7 @@ ...@@ -285,7 +280,7 @@
} }
if (qa_clicked('dodelete') && ($loginlevel >= QA_USER_LEVEL_ADMIN)) { if (qa_clicked('dodelete') && ($loginlevel >= QA_USER_LEVEL_ADMIN)) {
require_once QA_INCLUDE_DIR.'app/users-edit.php'; require_once QA_INCLUDE_DIR . 'app/users-edit.php';
qa_delete_user($userid); qa_delete_user($userid);
...@@ -304,64 +299,61 @@ ...@@ -304,64 +299,61 @@
if (qa_clicked('dowallpost')) { if (qa_clicked('dowallpost')) {
$inmessage = qa_post_text('message'); $inmessage = qa_post_text('message');
if (!strlen($inmessage)) if (!strlen($inmessage)) {
$errors['message'] = qa_lang('profile/post_wall_empty'); $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(), $userid, $useraccount['handle'], $inmessage, ''); qa_wall_add_post($loginuserid, qa_get_logged_in_handle(), qa_cookie_get(), $userid, $useraccount['handle'], $inmessage, '');
qa_redirect(qa_request(), null, null, null, 'wall'); qa_redirect(qa_request(), null, null, null, 'wall');
} }
} }
} }
// Process bonus setting button // Process bonus setting button
if ( ($loginlevel >= QA_USER_LEVEL_ADMIN) && qa_clicked('dosetbonus') ) { if ($loginlevel >= QA_USER_LEVEL_ADMIN && qa_clicked('dosetbonus')) {
require_once QA_INCLUDE_DIR.'db/points.php'; require_once QA_INCLUDE_DIR . 'db/points.php';
$inbonus = (int)qa_post_text('bonus'); $inbonus = (int)qa_post_text('bonus');
if (!qa_check_form_security_code('user-activity-'.$handle, qa_post_text('code'))) if (!qa_check_form_security_code('user-activity-' . $handle, qa_post_text('code'))) {
$errors['page'] = qa_lang_html('misc/form_security_again'); $errors['page'] = qa_lang_html('misc/form_security_again');
} else {
else {
qa_db_points_set_bonus($userid, $inbonus); qa_db_points_set_bonus($userid, $inbonus);
qa_db_points_update_ifuser($userid, null); qa_db_points_update_ifuser($userid, null);
qa_redirect(qa_request(), null, null, null, 'activity'); qa_redirect(qa_request(), null, null, null, 'activity');
} }
} }
// 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/user_x', $userhtml); $qa_content['title'] = qa_lang_html_sub('profile/user_x', $userhtml);
$qa_content['error'] = @$errors['page']; $qa_content['error'] = @$errors['page'];
if (isset($loginuserid) && $loginuserid != $useraccount['userid'] && !QA_FINAL_EXTERNAL_USERS) { if (isset($loginuserid) && $loginuserid != $useraccount['userid'] && !QA_FINAL_EXTERNAL_USERS) {
$favoritemap = qa_get_favorite_non_qs_map(); $favoritemap = qa_get_favorite_non_qs_map();
$favorite = @$favoritemap['user'][$useraccount['userid']]; $favorite = @$favoritemap['user'][$useraccount['userid']];
$qa_content['favorite'] = qa_favorite_form(QA_ENTITY_USER, $useraccount['userid'], $favorite, $qa_content['favorite'] = qa_favorite_form(QA_ENTITY_USER, $useraccount['userid'], $favorite,
qa_lang_sub($favorite ? 'main/remove_x_favorites' : 'users/add_user_x_favorites', $handle)); qa_lang_sub($favorite ? 'main/remove_x_favorites' : 'users/add_user_x_favorites', $handle));
} }
$qa_content['script_rel'][] = 'qa-content/qa-user.js?'.QA_VERSION; $qa_content['script_rel'][] = 'qa-content/qa-user.js?' . QA_VERSION;
// General information about the user, only available if we're using internal user management // General information about the user, only available if we're using internal user management
if (!QA_FINAL_EXTERNAL_USERS) { if (!QA_FINAL_EXTERNAL_USERS) {
$membertime = qa_time_to_string(qa_opt('db_time') - $useraccount['created']); $membertime = qa_time_to_string(qa_opt('db_time') - $useraccount['created']);
$joindate = qa_when_to_html($useraccount['created'], 0); $joindate = qa_when_to_html($useraccount['created'], 0);
$qa_content['form_profile'] = array( $qa_content['form_profile'] = array(
'tags' => 'method="post" action="'.qa_self_html().'"', 'tags' => 'method="post" action="' . qa_self_html() . '"',
'style' => 'wide', 'style' => 'wide',
...@@ -380,7 +372,7 @@ ...@@ -380,7 +372,7 @@
'duration' => array( 'duration' => array(
'type' => 'static', 'type' => 'static',
'label' => qa_lang_html('users/member_for'), 'label' => qa_lang_html('users/member_for'),
'value' => qa_html( $membertime . ' (' . qa_lang_sub('main/since_x', $joindate['data']) . ')' ), 'value' => qa_html($membertime . ' (' . qa_lang_sub('main/since_x', $joindate['data']) . ')'),
'id' => 'duration', 'id' => 'duration',
), ),
...@@ -401,9 +393,9 @@ ...@@ -401,9 +393,9 @@
// Private message link // Private message link
if ( qa_opt('allow_private_messages') && isset($loginuserid) && ($loginuserid != $userid) && !($useraccount['flags'] & QA_USER_FLAGS_NO_MESSAGES) && !$userediting ) { if (qa_opt('allow_private_messages') && isset($loginuserid) && $loginuserid != $userid && !($useraccount['flags'] & QA_USER_FLAGS_NO_MESSAGES) && !$userediting) {
$qa_content['form_profile']['fields']['level']['value'] .= strtr(qa_lang_html('profile/send_private_message'), array( $qa_content['form_profile']['fields']['level']['value'] .= strtr(qa_lang_html('profile/send_private_message'), array(
'^1' => '<a href="'.qa_path_html('message/'.$handle).'">', '^1' => '<a href="' . qa_path_html('message/' . $handle) . '">',
'^2' => '</a>', '^2' => '</a>',
)); ));
} }
...@@ -443,12 +435,12 @@ ...@@ -443,12 +435,12 @@
if ((!$catleveladd) && !count($userlevels)) { if ((!$catleveladd) && !count($userlevels)) {
$qa_content['form_profile']['fields']['level']['suffix'] = strtr(qa_lang_html('users/category_level_add'), array( $qa_content['form_profile']['fields']['level']['suffix'] = strtr(qa_lang_html('users/category_level_add'), array(
'^1' => '<a href="'.qa_path_html(qa_request(), array('state' => 'edit', 'catleveladd' => 1)).'">', '^1' => '<a href="' . qa_path_html(qa_request(), array('state' => 'edit', 'catleveladd' => 1)) . '">',
'^2' => '</a>', '^2' => '</a>',
)); ));
} } else {
else
$qa_content['form_profile']['fields']['level']['suffix'] = qa_lang_html('users/level_in_general'); $qa_content['form_profile']['fields']['level']['suffix'] = qa_lang_html('users/level_in_general');
}
if ($catleveladd || count($userlevels)) if ($catleveladd || count($userlevels))
$userlevels[] = array('entitytype' => QA_ENTITY_CATEGORY); $userlevels[] = array('entitytype' => QA_ENTITY_CATEGORY);
...@@ -457,28 +449,28 @@ ...@@ -457,28 +449,28 @@
foreach ($userlevels as $userlevel) { foreach ($userlevels as $userlevel) {
if ($userlevel['entitytype'] == QA_ENTITY_CATEGORY) { if ($userlevel['entitytype'] == QA_ENTITY_CATEGORY) {
$index++; $index++;
$id = 'ls_'.+$index; $id = 'ls_' . +$index;
$qa_content['form_profile']['fields']['uc_'.$index.'_level'] = array( $qa_content['form_profile']['fields']['uc_' . $index . '_level'] = array(
'label' => qa_lang_html('users/category_level_label'), 'label' => qa_lang_html('users/category_level_label'),
'type' => 'select', 'type' => 'select',
'tags' => 'name="uc_'.$index.'_level" id="'.qa_html($id).'" onchange="this.qa_prev=this.options[this.selectedIndex].value;"', 'tags' => 'name="uc_' . $index . '_level" id="' . qa_html($id) . '" onchange="this.qa_prev=this.options[this.selectedIndex].value;"',
'options' => $catleveloptions, 'options' => $catleveloptions,
'value' => isset($userlevel['level']) ? qa_html(qa_user_level_string($userlevel['level'])) : '', 'value' => isset($userlevel['level']) ? qa_html(qa_user_level_string($userlevel['level'])) : '',
'suffix' => qa_lang_html('users/category_level_in'), 'suffix' => qa_lang_html('users/category_level_in'),
); );
$qa_content['form_profile']['fields']['uc_'.$index.'_cat'] = array(); $qa_content['form_profile']['fields']['uc_' . $index . '_cat'] = array();
if (isset($userlevel['entityid'])) if (isset($userlevel['entityid']))
$fieldnavcategories = qa_db_select_with_pending(qa_db_category_nav_selectspec($userlevel['entityid'], true)); $fieldnavcategories = qa_db_select_with_pending(qa_db_category_nav_selectspec($userlevel['entityid'], true));
else else
$fieldnavcategories = $navcategories; $fieldnavcategories = $navcategories;
qa_set_up_category_field($qa_content, $qa_content['form_profile']['fields']['uc_'.$index.'_cat'], qa_set_up_category_field($qa_content, $qa_content['form_profile']['fields']['uc_' . $index . '_cat'],
'uc_'.$index.'_cat', $fieldnavcategories, @$userlevel['entityid'], true, true); 'uc_' . $index . '_cat', $fieldnavcategories, @$userlevel['entityid'], true, true);
unset($qa_content['form_profile']['fields']['uc_'.$index.'_cat']['note']); unset($qa_content['form_profile']['fields']['uc_' . $index . '_cat']['note']);
} }
} }
...@@ -508,18 +500,16 @@ ...@@ -508,18 +500,16 @@
); );
$qa_content['form_profile']['fields']['level']['tags'] .= ' id="level_select" onchange="qa_update_category_levels();"'; $qa_content['form_profile']['fields']['level']['tags'] .= ' id="level_select" onchange="qa_update_category_levels();"';
} }
} }
} } else {
else {
foreach ($userlevels as $userlevel) { foreach ($userlevels as $userlevel) {
if ( $userlevel['entitytype'] == QA_ENTITY_CATEGORY && $userlevel['level'] > $useraccount['level'] ) { if ($userlevel['entitytype'] == QA_ENTITY_CATEGORY && $userlevel['level'] > $useraccount['level']) {
$qa_content['form_profile']['fields']['level']['value'] .= '<br/>'. $qa_content['form_profile']['fields']['level']['value'] .= '<br/>' .
strtr(qa_lang_html('users/level_for_category'), array( strtr(qa_lang_html('users/level_for_category'), array(
'^1' => qa_html(qa_user_level_string($userlevel['level'])), '^1' => qa_html(qa_user_level_string($userlevel['level'])),
'^2' => '<a href="'.qa_path_html(implode('/', array_reverse(explode('/', $userlevel['backpath'])))).'">'.qa_html($userlevel['title']).'</a>', '^2' => '<a href="' . qa_path_html(implode('/', array_reverse(explode('/', $userlevel['backpath'])))) . '">' . qa_html($userlevel['title']) . '</a>',
)); ));
} }
} }
...@@ -532,14 +522,15 @@ ...@@ -532,14 +522,15 @@
$permitoptions = qa_get_permit_options(); $permitoptions = qa_get_permit_options();
foreach ($permitoptions as $permitoption) { foreach ($permitoptions as $permitoption) {
if ( // if not available to approved and email confirmed users with no points, but yes available to the user, it's something special // if not available to approved and email confirmed users with no points, but yes available to the user, it's something special
if (
qa_permit_error($permitoption, $userid, QA_USER_LEVEL_APPROVED, QA_USER_FLAGS_EMAIL_CONFIRMED, 0) && qa_permit_error($permitoption, $userid, QA_USER_LEVEL_APPROVED, QA_USER_FLAGS_EMAIL_CONFIRMED, 0) &&
!qa_permit_error($permitoption, $userid, $useraccount['level'], $useraccount['flags'], $userpoints['points']) !qa_permit_error($permitoption, $userid, $useraccount['level'], $useraccount['flags'], $userpoints['points'])
) { ) {
if ($permitoption == 'permit_retag_cat') if ($permitoption == 'permit_retag_cat')
$showpermits[] = qa_lang(qa_using_categories() ? 'profile/permit_recat' : 'profile/permit_retag'); $showpermits[] = qa_lang(qa_using_categories() ? 'profile/permit_recat' : 'profile/permit_retag');
else else
$showpermits[] = qa_lang('profile/'.$permitoption); // then show it as an extra priviliege $showpermits[] = qa_lang('profile/' . $permitoption); // then show it as an extra priviliege
} }
} }
...@@ -556,7 +547,7 @@ ...@@ -556,7 +547,7 @@
// Show email address only if we're an administrator // Show email address only if we're an administrator
if (($loginlevel >= QA_USER_LEVEL_ADMIN) && !qa_user_permit_error()) { if ($loginlevel >= QA_USER_LEVEL_ADMIN && !qa_user_permit_error()) {
$doconfirms = qa_opt('confirm_user_emails') && $useraccount['level'] < QA_USER_LEVEL_EXPERT; $doconfirms = qa_opt('confirm_user_emails') && $useraccount['level'] < QA_USER_LEVEL_EXPERT;
$isconfirmed = ($useraccount['flags'] & QA_USER_FLAGS_EMAIL_CONFIRMED) > 0; $isconfirmed = ($useraccount['flags'] & QA_USER_FLAGS_EMAIL_CONFIRMED) > 0;
$htmlemail = qa_html(isset($inemail) ? $inemail : $useraccount['email']); $htmlemail = qa_html(isset($inemail) ? $inemail : $useraccount['email']);
...@@ -565,9 +556,9 @@ ...@@ -565,9 +556,9 @@
'type' => $userediting ? 'text' : 'static', 'type' => $userediting ? 'text' : 'static',
'label' => qa_lang_html('users/email_label'), 'label' => qa_lang_html('users/email_label'),
'tags' => 'name="email"', 'tags' => 'name="email"',
'value' => $userediting ? $htmlemail : ('<a href="mailto:'.$htmlemail.'">'.$htmlemail.'</a>'), 'value' => $userediting ? $htmlemail : ('<a href="mailto:' . $htmlemail . '">' . $htmlemail . '</a>'),
'error' => qa_html(@$errors['email']), 'error' => qa_html(@$errors['email']),
'note' => ($doconfirms ? (qa_lang_html($isconfirmed ? 'users/email_confirmed' : 'users/email_not_confirmed').' ') : ''). 'note' => ($doconfirms ? (qa_lang_html($isconfirmed ? 'users/email_confirmed' : 'users/email_not_confirmed') . ' ') : '') .
($userediting ? '' : qa_lang_html('users/only_shown_admins')), ($userediting ? '' : qa_lang_html('users/only_shown_admins')),
'id' => 'email', 'id' => 'email',
); );
...@@ -576,13 +567,13 @@ ...@@ -576,13 +567,13 @@
// Show IP addresses and times for last login or write - only if we're a moderator or higher // Show IP addresses and times for last login or write - only if we're a moderator or higher
if (($loginlevel >= QA_USER_LEVEL_MODERATOR) && !qa_user_permit_error()) { if ($loginlevel >= QA_USER_LEVEL_MODERATOR && !qa_user_permit_error()) {
$qa_content['form_profile']['fields']['lastlogin'] = array( $qa_content['form_profile']['fields']['lastlogin'] = array(
'type' => 'static', 'type' => 'static',
'label' => qa_lang_html('users/last_login_label'), 'label' => qa_lang_html('users/last_login_label'),
'value' => 'value' =>
strtr(qa_lang_html('users/x_ago_from_y'), array( strtr(qa_lang_html('users/x_ago_from_y'), array(
'^1' => qa_time_to_string(qa_opt('db_time')-$useraccount['loggedin']), '^1' => qa_time_to_string(qa_opt('db_time') - $useraccount['loggedin']),
'^2' => qa_ip_anchor_html(@inet_ntop($useraccount['loginip'])), '^2' => qa_ip_anchor_html(@inet_ntop($useraccount['loginip'])),
)), )),
'note' => $userediting ? null : qa_lang_html('users/only_shown_moderators'), 'note' => $userediting ? null : qa_lang_html('users/only_shown_moderators'),
...@@ -595,16 +586,16 @@ ...@@ -595,16 +586,16 @@
'label' => qa_lang_html('users/last_write_label'), 'label' => qa_lang_html('users/last_write_label'),
'value' => 'value' =>
strtr(qa_lang_html('users/x_ago_from_y'), array( strtr(qa_lang_html('users/x_ago_from_y'), array(
'^1' => qa_time_to_string(qa_opt('db_time')-$useraccount['written']), '^1' => qa_time_to_string(qa_opt('db_time') - $useraccount['written']),
'^2' => qa_ip_anchor_html(@inet_ntop($useraccount['writeip'])), '^2' => qa_ip_anchor_html(@inet_ntop($useraccount['writeip'])),
)), )),
'note' => $userediting ? null : qa_lang_html('users/only_shown_moderators'), 'note' => $userediting ? null : qa_lang_html('users/only_shown_moderators'),
'id' => 'lastwrite', 'id' => 'lastwrite',
); );
} } else {
else
unset($qa_content['form_profile']['fields']['lastwrite']); unset($qa_content['form_profile']['fields']['lastwrite']);
} }
}
// Show other profile fields // Show other profile fields
...@@ -612,10 +603,9 @@ ...@@ -612,10 +603,9 @@
$fieldsediting = $fieldseditable && $userediting; $fieldsediting = $fieldseditable && $userediting;
foreach ($userfields as $userfield) { foreach ($userfields as $userfield) {
if (($userfield['flags'] & QA_FIELD_FLAGS_LINK_URL) && !$fieldsediting) if (($userfield['flags'] & QA_FIELD_FLAGS_LINK_URL) && !$fieldsediting) {
$valuehtml = qa_url_to_html_link(@$userprofile[$userfield['title']], qa_opt('links_in_new_window')); $valuehtml = qa_url_to_html_link(@$userprofile[$userfield['title']], qa_opt('links_in_new_window'));
} else {
else {
$value = @$inprofile[$userfield['fieldid']]; $value = @$inprofile[$userfield['fieldid']];
if (!isset($value)) if (!isset($value))
$value = @$userprofile[$userfield['title']]; $value = @$userprofile[$userfield['title']];
...@@ -642,12 +632,12 @@ ...@@ -642,12 +632,12 @@
$qa_content['form_profile']['fields'][$userfield['title']] = array( $qa_content['form_profile']['fields'][$userfield['title']] = array(
'type' => $fieldsediting ? 'text' : 'static', 'type' => $fieldsediting ? 'text' : 'static',
'label' => qa_html($label), 'label' => qa_html($label),
'tags' => 'name="field_'.$userfield['fieldid'].'"', 'tags' => 'name="field_' . $userfield['fieldid'] . '"',
'value' => $valuehtml, 'value' => $valuehtml,
'error' => qa_html(@$errors[$userfield['fieldid']]), 'error' => qa_html(@$errors[$userfield['fieldid']]),
'note' => $notehtml, 'note' => $notehtml,
'rows' => ($userfield['flags'] & QA_FIELD_FLAGS_MULTI_LINE) ? 8 : null, 'rows' => ($userfield['flags'] & QA_FIELD_FLAGS_MULTI_LINE) ? 8 : null,
'id' => 'userfield-'.$userfield['fieldid'], 'id' => 'userfield-' . $userfield['fieldid'],
); );
} }
...@@ -680,11 +670,10 @@ ...@@ -680,11 +670,10 @@
$qa_content['form_profile']['hidden'] = array( $qa_content['form_profile']['hidden'] = array(
'dosave' => '1', 'dosave' => '1',
'code' => qa_get_form_security_code('user-edit-'.$handle), 'code' => qa_get_form_security_code('user-edit-' . $handle),
); );
} } elseif ($usereditbutton) {
elseif ($usereditbutton) {
$qa_content['form_profile']['buttons'] = array(); $qa_content['form_profile']['buttons'] = array();
if ($approvebutton) { if ($approvebutton) {
...@@ -720,8 +709,7 @@ ...@@ -720,8 +709,7 @@
); );
} }
} } else {
else {
$qa_content['form_profile']['buttons']['block'] = array( $qa_content['form_profile']['buttons']['block'] = array(
'tags' => 'name="doblock"', 'tags' => 'name="doblock"',
'label' => qa_lang_html('users/block_user_button'), 'label' => qa_lang_html('users/block_user_button'),
...@@ -729,12 +717,11 @@ ...@@ -729,12 +717,11 @@
} }
$qa_content['form_profile']['hidden'] = array( $qa_content['form_profile']['hidden'] = array(
'code' => qa_get_form_security_code('user-'.$handle), 'code' => qa_get_form_security_code('user-' . $handle),
); );
} }
} } elseif (isset($loginuserid) && ($loginuserid == $userid)) {
elseif (isset($loginuserid) && ($loginuserid == $userid)) {
$qa_content['form_profile']['buttons'] = array( $qa_content['form_profile']['buttons'] = array(
'account' => array( 'account' => array(
'tags' => 'name="doaccount"', 'tags' => 'name="doaccount"',
...@@ -749,13 +736,13 @@ ...@@ -749,13 +736,13 @@
$qa_content['raw']['account'] = $useraccount; // for plugin layers to access $qa_content['raw']['account'] = $useraccount; // for plugin layers to access
$qa_content['raw']['profile'] = $userprofile; $qa_content['raw']['profile'] = $userprofile;
} }
// Information about user activity, available also with single sign-on integration // Information about user activity, available also with single sign-on integration
$qa_content['form_activity'] = array( $qa_content['form_activity'] = array(
'title' => '<a name="activity">'.qa_lang_html_sub('profile/activity_by_x', $userhtml).'</a>', 'title' => '<a name="activity">' . qa_lang_html_sub('profile/activity_by_x', $userhtml) . '</a>',
'style' => 'wide', 'style' => 'wide',
...@@ -774,7 +761,7 @@ ...@@ -774,7 +761,7 @@
'label' => qa_lang_html('profile/score'), 'label' => qa_lang_html('profile/score'),
'value' => (@$userpoints['points'] == 1) 'value' => (@$userpoints['points'] == 1)
? qa_lang_html_sub('main/1_point', '<span class="qa-uf-user-points">1</span>', '1') ? qa_lang_html_sub('main/1_point', '<span class="qa-uf-user-points">1</span>', '1')
: qa_lang_html_sub('main/x_points', '<span class="qa-uf-user-points">'.qa_html(qa_format_number(@$userpoints['points'])).'</span>'), : qa_lang_html_sub('main/x_points', '<span class="qa-uf-user-points">' . qa_html(qa_format_number(@$userpoints['points'])) . '</span>'),
'id' => 'points', 'id' => 'points',
), ),
...@@ -788,21 +775,21 @@ ...@@ -788,21 +775,21 @@
'questions' => array( 'questions' => array(
'type' => 'static', 'type' => 'static',
'label' => qa_lang_html('profile/questions'), 'label' => qa_lang_html('profile/questions'),
'value' => '<span class="qa-uf-user-q-posts">'.qa_html(qa_format_number(@$userpoints['qposts'])).'</span>', 'value' => '<span class="qa-uf-user-q-posts">' . qa_html(qa_format_number(@$userpoints['qposts'])) . '</span>',
'id' => 'questions', 'id' => 'questions',
), ),
'answers' => array( 'answers' => array(
'type' => 'static', 'type' => 'static',
'label' => qa_lang_html('profile/answers'), 'label' => qa_lang_html('profile/answers'),
'value' => '<span class="qa-uf-user-a-posts">'.qa_html(qa_format_number(@$userpoints['aposts'])).'</span>', 'value' => '<span class="qa-uf-user-a-posts">' . qa_html(qa_format_number(@$userpoints['aposts'])) . '</span>',
'id' => 'answers', 'id' => 'answers',
), ),
), ),
); );
if ($loginlevel >= QA_USER_LEVEL_ADMIN) { if ($loginlevel >= QA_USER_LEVEL_ADMIN) {
$qa_content['form_activity']['tags'] = 'method="post" action="'.qa_self_html().'"'; $qa_content['form_activity']['tags'] = 'method="post" action="' . qa_self_html() . '"';
$qa_content['form_activity']['buttons'] = array( $qa_content['form_activity']['buttons'] = array(
'setbonus' => array( 'setbonus' => array(
...@@ -812,32 +799,32 @@ ...@@ -812,32 +799,32 @@
); );
$qa_content['form_activity']['hidden'] = array( $qa_content['form_activity']['hidden'] = array(
'code' => qa_get_form_security_code('user-activity-'.$handle), 'code' => qa_get_form_security_code('user-activity-' . $handle),
); );
} } else {
else
unset($qa_content['form_activity']['fields']['bonus']); unset($qa_content['form_activity']['fields']['bonus']);
}
if (!isset($qa_content['form_activity']['fields']['title']['value'])) if (!isset($qa_content['form_activity']['fields']['title']['value']))
unset($qa_content['form_activity']['fields']['title']); unset($qa_content['form_activity']['fields']['title']);
if (qa_opt('comment_on_qs') || qa_opt('comment_on_as')) { // only show comment count if comments are enabled if (qa_opt('comment_on_qs') || qa_opt('comment_on_as')) { // only show comment count if comments are enabled
$qa_content['form_activity']['fields']['comments'] = array( $qa_content['form_activity']['fields']['comments'] = array(
'type' => 'static', 'type' => 'static',
'label' => qa_lang_html('profile/comments'), 'label' => qa_lang_html('profile/comments'),
'value' => '<span class="qa-uf-user-c-posts">'.qa_html(qa_format_number(@$userpoints['cposts'])).'</span>', 'value' => '<span class="qa-uf-user-c-posts">' . qa_html(qa_format_number(@$userpoints['cposts'])) . '</span>',
'id' => 'comments', 'id' => 'comments',
); );
} }
if (qa_opt('voting_on_qs') || qa_opt('voting_on_as')) { // only show vote record if voting is enabled if (qa_opt('voting_on_qs') || qa_opt('voting_on_as')) { // only show vote record if voting is enabled
$votedonvalue = ''; $votedonvalue = '';
if (qa_opt('voting_on_qs')) { if (qa_opt('voting_on_qs')) {
$qvotes = @$userpoints['qupvotes']+@$userpoints['qdownvotes']; $qvotes = @$userpoints['qupvotes'] + @$userpoints['qdownvotes'];
$innervalue = '<span class="qa-uf-user-q-votes">'.qa_format_number($qvotes).'</span>'; $innervalue = '<span class="qa-uf-user-q-votes">' . qa_format_number($qvotes) . '</span>';
$votedonvalue .= ($qvotes == 1) ? qa_lang_html_sub('main/1_question', $innervalue, '1') $votedonvalue .= ($qvotes == 1) ? qa_lang_html_sub('main/1_question', $innervalue, '1')
: qa_lang_html_sub('main/x_questions', $innervalue); : qa_lang_html_sub('main/x_questions', $innervalue);
...@@ -846,9 +833,9 @@ ...@@ -846,9 +833,9 @@
} }
if (qa_opt('voting_on_as')) { if (qa_opt('voting_on_as')) {
$avotes = @$userpoints['aupvotes']+@$userpoints['adownvotes']; $avotes = @$userpoints['aupvotes'] + @$userpoints['adownvotes'];
$innervalue = '<span class="qa-uf-user-a-votes">'.qa_format_number($avotes).'</span>'; $innervalue = '<span class="qa-uf-user-a-votes">' . qa_format_number($avotes) . '</span>';
$votedonvalue .= ($avotes == 1) ? qa_lang_html_sub('main/1_answer', $innervalue, '1') $votedonvalue .= ($avotes == 1) ? qa_lang_html_sub('main/1_answer', $innervalue, '1')
: qa_lang_html_sub('main/x_answers', $innervalue); : qa_lang_html_sub('main/x_answers', $innervalue);
} }
...@@ -860,12 +847,12 @@ ...@@ -860,12 +847,12 @@
'id' => 'votedon', 'id' => 'votedon',
); );
$upvotes = @$userpoints['qupvotes']+@$userpoints['aupvotes']; $upvotes = @$userpoints['qupvotes'] + @$userpoints['aupvotes'];
$innervalue = '<span class="qa-uf-user-upvotes">'.qa_format_number($upvotes).'</span>'; $innervalue = '<span class="qa-uf-user-upvotes">' . qa_format_number($upvotes) . '</span>';
$votegavevalue = (($upvotes == 1) ? qa_lang_html_sub('profile/1_up_vote', $innervalue, '1') : qa_lang_html_sub('profile/x_up_votes', $innervalue)).', '; $votegavevalue = (($upvotes == 1) ? qa_lang_html_sub('profile/1_up_vote', $innervalue, '1') : qa_lang_html_sub('profile/x_up_votes', $innervalue)) . ', ';
$downvotes = @$userpoints['qdownvotes']+@$userpoints['adownvotes']; $downvotes = @$userpoints['qdownvotes'] + @$userpoints['adownvotes'];
$innervalue = '<span class="qa-uf-user-downvotes">'.qa_format_number($downvotes).'</span>'; $innervalue = '<span class="qa-uf-user-downvotes">' . qa_format_number($downvotes) . '</span>';
$votegavevalue .= ($downvotes == 1) ? qa_lang_html_sub('profile/1_down_vote', $innervalue, '1') : qa_lang_html_sub('profile/x_down_votes', $innervalue); $votegavevalue .= ($downvotes == 1) ? qa_lang_html_sub('profile/1_down_vote', $innervalue, '1') : qa_lang_html_sub('profile/x_down_votes', $innervalue);
$qa_content['form_activity']['fields']['votegave'] = array( $qa_content['form_activity']['fields']['votegave'] = array(
...@@ -875,11 +862,11 @@ ...@@ -875,11 +862,11 @@
'id' => 'votegave', 'id' => 'votegave',
); );
$innervalue = '<span class="qa-uf-user-upvoteds">'.qa_format_number(@$userpoints['upvoteds']).'</span>'; $innervalue = '<span class="qa-uf-user-upvoteds">' . qa_format_number(@$userpoints['upvoteds']) . '</span>';
$votegotvalue = ((@$userpoints['upvoteds'] == 1) ? qa_lang_html_sub('profile/1_up_vote', $innervalue, '1') $votegotvalue = ((@$userpoints['upvoteds'] == 1) ? qa_lang_html_sub('profile/1_up_vote', $innervalue, '1')
: qa_lang_html_sub('profile/x_up_votes', $innervalue)).', '; : qa_lang_html_sub('profile/x_up_votes', $innervalue)) . ', ';
$innervalue = '<span class="qa-uf-user-downvoteds">'.qa_format_number(@$userpoints['downvoteds']).'</span>'; $innervalue = '<span class="qa-uf-user-downvoteds">' . qa_format_number(@$userpoints['downvoteds']) . '</span>';
$votegotvalue .= (@$userpoints['downvoteds'] == 1) ? qa_lang_html_sub('profile/1_down_vote', $innervalue, '1') $votegotvalue .= (@$userpoints['downvoteds'] == 1) ? qa_lang_html_sub('profile/1_down_vote', $innervalue, '1')
: qa_lang_html_sub('profile/x_down_votes', $innervalue); : qa_lang_html_sub('profile/x_down_votes', $innervalue);
...@@ -889,60 +876,58 @@ ...@@ -889,60 +876,58 @@
'value' => $votegotvalue, 'value' => $votegotvalue,
'id' => 'votegot', 'id' => 'votegot',
); );
} }
if (@$userpoints['points']) { if (@$userpoints['points']) {
$qa_content['form_activity']['fields']['points']['value'] .= $qa_content['form_activity']['fields']['points']['value'] .=
qa_lang_html_sub('profile/ranked_x', '<span class="qa-uf-user-rank">'.qa_format_number($userrank).'</span>'); qa_lang_html_sub('profile/ranked_x', '<span class="qa-uf-user-rank">' . qa_format_number($userrank) . '</span>');
} }
if (@$userpoints['aselects']) { if (@$userpoints['aselects']) {
$qa_content['form_activity']['fields']['questions']['value'] .= ($userpoints['aselects'] == 1) $qa_content['form_activity']['fields']['questions']['value'] .= ($userpoints['aselects'] == 1)
? qa_lang_html_sub('profile/1_with_best_chosen', '<span class="qa-uf-user-q-selects">1</span>', '1') ? qa_lang_html_sub('profile/1_with_best_chosen', '<span class="qa-uf-user-q-selects">1</span>', '1')
: qa_lang_html_sub('profile/x_with_best_chosen', '<span class="qa-uf-user-q-selects">'.qa_format_number($userpoints['aselects']).'</span>'); : qa_lang_html_sub('profile/x_with_best_chosen', '<span class="qa-uf-user-q-selects">' . qa_format_number($userpoints['aselects']) . '</span>');
} }
if (@$userpoints['aselecteds']) { if (@$userpoints['aselecteds']) {
$qa_content['form_activity']['fields']['answers']['value'] .= ($userpoints['aselecteds'] == 1) $qa_content['form_activity']['fields']['answers']['value'] .= ($userpoints['aselecteds'] == 1)
? qa_lang_html_sub('profile/1_chosen_as_best', '<span class="qa-uf-user-a-selecteds">1</span>', '1') ? qa_lang_html_sub('profile/1_chosen_as_best', '<span class="qa-uf-user-a-selecteds">1</span>', '1')
: qa_lang_html_sub('profile/x_chosen_as_best', '<span class="qa-uf-user-a-selecteds">'.qa_format_number($userpoints['aselecteds']).'</span>'); : qa_lang_html_sub('profile/x_chosen_as_best', '<span class="qa-uf-user-a-selecteds">' . qa_format_number($userpoints['aselecteds']) . '</span>');
} }
// For plugin layers to access // For plugin layers to access
$qa_content['raw']['userid'] = $userid; $qa_content['raw']['userid'] = $userid;
$qa_content['raw']['points'] = $userpoints; $qa_content['raw']['points'] = $userpoints;
$qa_content['raw']['rank'] = $userrank; $qa_content['raw']['rank'] = $userrank;
// Wall posts // Wall posts
if (!QA_FINAL_EXTERNAL_USERS && qa_opt('allow_user_walls')) { if (!QA_FINAL_EXTERNAL_USERS && qa_opt('allow_user_walls')) {
$qa_content['message_list'] = array( $qa_content['message_list'] = array(
'title' => '<a name="wall">'.qa_lang_html_sub('profile/wall_for_x', $userhtml).'</a>', 'title' => '<a name="wall">' . qa_lang_html_sub('profile/wall_for_x', $userhtml) . '</a>',
'tags' => 'id="wallmessages"', 'tags' => 'id="wallmessages"',
'form' => array( 'form' => array(
'tags' => 'name="wallpost" method="post" action="'.qa_self_html().'#wall"', 'tags' => 'name="wallpost" method="post" action="' . qa_self_html() . '#wall"',
'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' => 0, 'start' => 0,
'code' => qa_get_form_security_code('wall-'.$useraccount['handle']), 'code' => qa_get_form_security_code('wall-' . $useraccount['handle']),
), ),
), ),
'messages' => array(), 'messages' => array(),
); );
if ($wallposterrorhtml) if ($wallposterrorhtml) {
$qa_content['message_list']['error'] = $wallposterrorhtml; // an error that means we are not allowed to post $qa_content['message_list']['error'] = $wallposterrorhtml; // an error that means we are not allowed to post
} else {
else {
$qa_content['message_list']['form']['fields'] = array( $qa_content['message_list']['form']['fields'] = array(
'message' => array( 'message' => array(
'tags' => 'name="message" id="message"', 'tags' => 'name="message" id="message"',
...@@ -965,18 +950,13 @@ ...@@ -965,18 +950,13 @@
if ($useraccount['wallposts'] > count($usermessages)) if ($useraccount['wallposts'] > count($usermessages))
$qa_content['message_list']['messages'][] = qa_wall_view_more_link($handle, count($usermessages)); $qa_content['message_list']['messages'][] = qa_wall_view_more_link($handle, count($usermessages));
} }
// 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, 'profile', $ismyuser); $qa_content['navigation']['sub'] = qa_user_sub_navigation($handle, 'profile', $ismyuser);
return $qa_content;
return $qa_content;
/*
Omit PHP closing tag to help avoid accidental output
*/
...@@ -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,112 +20,108 @@ ...@@ -20,112 +20,108 @@
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']); $wallposterrorhtml = qa_wall_error_html($loginuserid, $useraccount['userid'], $useraccount['flags']);
foreach ($usermessages as $message) { foreach ($usermessages as $message) {
if ($message['deleteable'] && qa_clicked('m'.$message['messageid'].'_dodelete')) { if ($message['deleteable'] && qa_clicked('m' . $message['messageid'] . '_dodelete')) {
if (!qa_check_form_security_code('wall-'.$useraccount['handle'], qa_post_text('code'))) if (!qa_check_form_security_code('wall-' . $useraccount['handle'], qa_post_text('code'))) {
$errors['page'] = qa_lang_html('misc/form_security_again'); $errors['page'] = qa_lang_html('misc/form_security_again');
} else {
else {
qa_wall_delete_post($loginuserid, qa_get_logged_in_handle(), qa_cookie_get(), $message); qa_wall_delete_post($loginuserid, qa_get_logged_in_handle(), qa_cookie_get(), $message);
qa_redirect(qa_request(), $_GET); qa_redirect(qa_request(), $_GET);
} }
} }
} }
if (qa_clicked('dowallpost')) { if (qa_clicked('dowallpost')) {
$inmessage = qa_post_text('message'); $inmessage = qa_post_text('message');
if (!strlen($inmessage)) if (!strlen($inmessage)) {
$errors['message'] = qa_lang('profile/post_wall_empty'); $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(), 'messages' => array(),
); );
if ($start == 0) { // only allow posting on first page if ($start == 0) { // only allow posting on first page
if ($wallposterrorhtml) if ($wallposterrorhtml) {
$qa_content['message_list']['error'] = $wallposterrorhtml; // an error that means we are not allowed to post $qa_content['message_list']['error'] = $wallposterrorhtml; // an error that means we are not allowed to post
} else {
else {
$qa_content['message_list']['form']['fields'] = array( $qa_content['message_list']['form']['fields'] = array(
'message' => array( 'message' => array(
'tags' => 'name="message" id="message"', 'tags' => 'name="message" id="message"',
...@@ -142,23 +138,19 @@ ...@@ -142,23 +138,19 @@
), ),
); );
} }
} }
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( $qa_content['ranking'] = array(
'items' => array(), 'items' => array(),
'rows' => ceil(count($users)/qa_opt('columns_users')), 'rows' => ceil(count($users) / qa_opt('columns_users')),
'type' => 'users' 'type' => 'users'
); );
foreach ($users as $user) { foreach ($users as $user) {
$qa_content['ranking']['items'][] = array( $qa_content['ranking']['items'][] = array(
'label' => $usershtml[$user['userid']], 'label' => $usershtml[$user['userid']],
'score' => qa_html(qa_user_level_string($user['level'])), 'score' => qa_html(qa_user_level_string($user['level'])),
'raw' => $user, 'raw' => $user,
); );
} }
$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_users_sub_navigation(); $qa_content['navigation']['sub'] = qa_users_sub_navigation();
return $qa_content; 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( $qa_content['ranking'] = array(
'items' => array(), 'items' => array(),
'rows' => ceil(qa_opt('page_size_users')/qa_opt('columns_users')), 'rows' => ceil(qa_opt('page_size_users') / qa_opt('columns_users')),
'type' => 'users' 'type' => 'users'
); );
foreach ($users as $user) { foreach ($users as $user) {
$qa_content['ranking']['items'][] = array( $qa_content['ranking']['items'][] = array(
'label' => $usershtml[$user['userid']], 'label' => $usershtml[$user['userid']],
'score' => qa_html(qa_user_level_string($user['level'])), 'score' => qa_html(qa_user_level_string($user['level'])),
'raw' => $user, 'raw' => $user,
); );
} }
$qa_content['navigation']['sub'] = qa_users_sub_navigation(); $qa_content['navigation']['sub'] = qa_users_sub_navigation();
return $qa_content; return $qa_content;
/*
Omit PHP closing tag to help avoid accidental output
*/
\ No newline at end of file
...@@ -20,40 +20,40 @@ ...@@ -20,40 +20,40 @@
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( $qa_content['ranking'] = array(
'items' => array(), 'items' => array(),
'rows' => ceil($pagesize/qa_opt('columns_users')), 'rows' => ceil($pagesize / qa_opt('columns_users')),
'type' => 'users' 'type' => 'users'
); );
if (count($users)) { if (count($users)) {
foreach ($users as $userid => $user) { foreach ($users as $userid => $user) {
if (QA_FINAL_EXTERNAL_USERS) if (QA_FINAL_EXTERNAL_USERS)
$avatarhtml = qa_get_external_avatar_html($user['userid'], qa_opt('avatar_users_size'), true); $avatarhtml = qa_get_external_avatar_html($user['userid'], qa_opt('avatar_users_size'), true);
...@@ -70,22 +70,17 @@ ...@@ -70,22 +70,17 @@
'raw' => $user, 'raw' => $user,
); );
} }
} } else {
else
$qa_content['title'] = qa_lang_html('main/no_active_users'); $qa_content['title'] = qa_lang_html('main/no_active_users');
}
// set the canonical url based on possible pagination // 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['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'));
$qa_content['navigation']['sub'] = qa_users_sub_navigation(); $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();
return $qa_content;
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