Commit 4932f19c by Scott

Coding style (misc)

parent c20678fb
...@@ -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
*/ */
return array( return array(
'1_chosen_as_best' => ' (1 chosen as best)', '1_chosen_as_best' => ' (1 chosen as best)',
'1_down_vote' => '1 down vote', '1_down_vote' => '1 down vote',
'1_up_vote' => '1 up vote', '1_up_vote' => '1 up vote',
'1_with_best_chosen' => ' (1 with best answer chosen)', '1_with_best_chosen' => ' (1 with best answer chosen)',
'activity_by_x' => 'Activity by ^', 'activity_by_x' => 'Activity by ^',
'answers' => 'Answers:', 'answers' => 'Answers:',
'answers_by_x' => 'Answers by ^', 'answers_by_x' => 'Answers by ^',
'bonus_points' => 'Bonus points:', 'bonus_points' => 'Bonus points:',
'comments' => 'Comments:', 'comments' => 'Comments:',
'delete_pm_popup' => 'Delete this private message', 'delete_pm_popup' => 'Delete this private message',
'delete_wall_post_popup' => 'Delete this wall post', 'delete_wall_post_popup' => 'Delete this wall post',
'extra_privileges' => 'Extra privileges:', 'extra_privileges' => 'Extra privileges:',
'gave_out' => 'Gave out:', 'gave_out' => 'Gave out:',
'my_account_title' => 'My account', 'my_account_title' => 'My account',
'no_answers_by_x' => 'No answers by ^', 'no_answers_by_x' => 'No answers by ^',
'no_posts_by_x' => 'No posts by ^', 'no_posts_by_x' => 'No posts by ^',
'no_questions_by_x' => 'No questions by ^', 'no_questions_by_x' => 'No questions by ^',
'permit_anon_view_ips' => 'Viewing IPs of anonymous posts', 'permit_anon_view_ips' => 'Viewing IPs of anonymous posts',
'permit_close_q' => 'Closing any question', 'permit_close_q' => 'Closing any question',
'permit_delete_hidden' => 'Deleting hidden posts', 'permit_delete_hidden' => 'Deleting hidden posts',
'permit_edit_a' => 'Editing any answer', 'permit_edit_a' => 'Editing any answer',
'permit_edit_c' => 'Editing any comment', 'permit_edit_c' => 'Editing any comment',
'permit_edit_q' => 'Editing any question', 'permit_edit_q' => 'Editing any question',
'permit_edit_silent' => 'Editing posts silently', 'permit_edit_silent' => 'Editing posts silently',
'permit_flag' => 'Flagging posts', 'permit_flag' => 'Flagging posts',
'permit_hide_show' => 'Hiding or showing any post', 'permit_hide_show' => 'Hiding or showing any post',
'permit_moderate' => 'Approving or rejecting posts', 'permit_moderate' => 'Approving or rejecting posts',
'permit_post_a' => 'Answering questions', 'permit_post_a' => 'Answering questions',
'permit_post_c' => 'Adding comments', 'permit_post_c' => 'Adding comments',
'permit_post_q' => 'Asking questions', 'permit_post_q' => 'Asking questions',
'permit_post_wall' => 'Posting on user walls', 'permit_post_wall' => 'Posting on user walls',
'permit_recat' => 'Recategorizing any question', 'permit_recat' => 'Recategorizing any question',
'permit_retag' => 'Retagging any question', 'permit_retag' => 'Retagging any question',
'permit_select_a' => 'Selecting answer for any question', 'permit_select_a' => 'Selecting answer for any question',
'permit_view_q_page' => 'Viewing question pages', 'permit_view_q_page' => 'Viewing question pages',
'permit_view_new_users_page' => 'Viewing the newest users page', 'permit_view_new_users_page' => 'Viewing the newest users page',
'permit_view_special_users_page' => 'Viewing the special users page', 'permit_view_special_users_page' => 'Viewing the special users page',
'permit_view_voters_flaggers' => 'Viewing who voted or flagged posts', 'permit_view_voters_flaggers' => 'Viewing who voted or flagged posts',
'permit_vote_a' => 'Voting on answers', 'permit_vote_a' => 'Voting on answers',
'permit_vote_down' => 'Voting posts down', 'permit_vote_down' => 'Voting posts down',
'permit_vote_q' => 'Voting on questions', 'permit_vote_q' => 'Voting on questions',
'post_wall_blocked' => 'This user has disallowed new posts on their wall', 'post_wall_blocked' => 'This user has disallowed new posts on their wall',
'post_wall_button' => 'Add wall post', 'post_wall_button' => 'Add wall post',
'post_wall_empty' => 'Please enter something to post on this wall', 'post_wall_empty' => 'Please enter something to post on this wall',
'post_wall_limit' => 'You cannot write more wall posts this hour', 'post_wall_limit' => 'You cannot write more wall posts this hour',
'post_wall_must_be_approved' => 'Your account must be approved to post on this wall.', 'post_wall_must_be_approved' => 'Your account must be approved to post on this wall.',
'post_wall_must_confirm' => 'Please ^5confirm your email address^6 to post on this wall.', 'post_wall_must_confirm' => 'Please ^5confirm your email address^6 to post on this wall.',
'post_wall_must_login' => 'Please ^1log in^2 or ^3register^4 to post on this wall.', 'post_wall_must_login' => 'Please ^1log in^2 or ^3register^4 to post on this wall.',
'questions' => 'Questions:', 'questions' => 'Questions:',
'questions_by_x' => 'Questions by ^', 'questions_by_x' => 'Questions by ^',
'ranked_x' => ' (ranked #^)', 'ranked_x' => ' (ranked #^)',
'received' => 'Received:', 'received' => 'Received:',
'recent_activity_by_x' => 'Recent activity by ^', 'recent_activity_by_x' => 'Recent activity by ^',
'score' => 'Score:', 'score' => 'Score:',
'send_private_message' => ' - ^1send private message^2', 'send_private_message' => ' - ^1send private message^2',
'set_bonus_button' => 'Update bonus', 'set_bonus_button' => 'Update bonus',
'title' => 'Title:', 'title' => 'Title:',
'user_x' => 'User ^', 'user_x' => 'User ^',
'user_x_disabled_pms' => 'User ^ has disabled private messages.', 'user_x_disabled_pms' => 'User ^ has disabled private messages.',
'voted_on' => 'Voted on:', 'voted_on' => 'Voted on:',
'wall_for_x' => 'Wall for ^', 'wall_for_x' => 'Wall for ^',
'wall_view_more' => 'View more wall posts...', 'wall_view_more' => 'View more wall posts...',
'x_chosen_as_best' => ' (^ chosen as best)', 'x_chosen_as_best' => ' (^ chosen as best)',
'x_down_votes' => '^ down votes', 'x_down_votes' => '^ down votes',
'x_up_votes' => '^ up votes', 'x_up_votes' => '^ up votes',
'x_with_best_chosen' => ' (^ with best answer chosen)', 'x_with_best_chosen' => ' (^ with best answer chosen)',
); );
/*
Omit PHP closing tag to help avoid accidental output
*/
\ No newline at end of file
...@@ -26,7 +26,7 @@ class qa_html_theme_layer extends qa_html_theme_base ...@@ -26,7 +26,7 @@ class qa_html_theme_layer extends qa_html_theme_base
private $qa_voters_flaggers_cache = array(); private $qa_voters_flaggers_cache = array();
// Collect up all required postids for the entire page to save DB queries - common case where whole page output // Collect up all required postids for the entire page to save DB queries - common case where whole page output
public function main() public function main()
{ {
...@@ -55,7 +55,7 @@ class qa_html_theme_layer extends qa_html_theme_base ...@@ -55,7 +55,7 @@ class qa_html_theme_layer extends qa_html_theme_base
} }
// Other functions which also collect up required postids for lists to save DB queries - helps with widget output and Ajax calls // Other functions which also collect up required postids for lists to save DB queries - helps with widget output and Ajax calls
public function q_list_items($q_items) public function q_list_items($q_items)
{ {
...@@ -79,7 +79,7 @@ class qa_html_theme_layer extends qa_html_theme_base ...@@ -79,7 +79,7 @@ class qa_html_theme_layer extends qa_html_theme_base
} }
// Actual output of the voters and flaggers // Actual output of the voters and flaggers
public function vote_count($post) public function vote_count($post)
{ {
...@@ -141,7 +141,7 @@ class qa_html_theme_layer extends qa_html_theme_base ...@@ -141,7 +141,7 @@ class qa_html_theme_layer extends qa_html_theme_base
} }
// Utility functions for this layer // Utility functions for this layer
/** /**
* @deprecated This function will become private in Q2A 1.8. It is specific to this plugin and * @deprecated This function will become private in Q2A 1.8. It is specific to this plugin and
......
...@@ -26,24 +26,24 @@ class qa_search_basic ...@@ -26,24 +26,24 @@ class qa_search_basic
{ {
require_once QA_INCLUDE_DIR.'db/post-create.php'; require_once QA_INCLUDE_DIR.'db/post-create.php';
// Get words from each textual element // Get words from each textual element
$titlewords=array_unique(qa_string_to_words($title)); $titlewords=array_unique(qa_string_to_words($title));
$contentcount=array_count_values(qa_string_to_words($text)); $contentcount=array_count_values(qa_string_to_words($text));
$tagwords=array_unique(qa_string_to_words($tagstring)); $tagwords=array_unique(qa_string_to_words($tagstring));
$wholetags=array_unique(qa_tagstring_to_tags($tagstring)); $wholetags=array_unique(qa_tagstring_to_tags($tagstring));
// Map all words to their word IDs // Map all words to their word IDs
$words=array_unique(array_merge($titlewords, array_keys($contentcount), $tagwords, $wholetags)); $words=array_unique(array_merge($titlewords, array_keys($contentcount), $tagwords, $wholetags));
$wordtoid=qa_db_word_mapto_ids_add($words); $wordtoid=qa_db_word_mapto_ids_add($words);
// Add to title words index // Add to title words index
$titlewordids=qa_array_filter_by_keys($wordtoid, $titlewords); $titlewordids=qa_array_filter_by_keys($wordtoid, $titlewords);
qa_db_titlewords_add_post_wordids($postid, $titlewordids); qa_db_titlewords_add_post_wordids($postid, $titlewordids);
// Add to content words index (including word counts) // Add to content words index (including word counts)
$contentwordidcounts=array(); $contentwordidcounts=array();
foreach ($contentcount as $word => $count) foreach ($contentcount as $word => $count)
...@@ -52,17 +52,17 @@ class qa_search_basic ...@@ -52,17 +52,17 @@ class qa_search_basic
qa_db_contentwords_add_post_wordidcounts($postid, $type, $questionid, $contentwordidcounts); qa_db_contentwords_add_post_wordidcounts($postid, $type, $questionid, $contentwordidcounts);
// Add to tag words index // Add to tag words index
$tagwordids=qa_array_filter_by_keys($wordtoid, $tagwords); $tagwordids=qa_array_filter_by_keys($wordtoid, $tagwords);
qa_db_tagwords_add_post_wordids($postid, $tagwordids); qa_db_tagwords_add_post_wordids($postid, $tagwordids);
// Add to whole tags index // Add to whole tags index
$wholetagids=qa_array_filter_by_keys($wordtoid, $wholetags); $wholetagids=qa_array_filter_by_keys($wordtoid, $wholetags);
qa_db_posttags_add_post_wordids($postid, $wholetagids); qa_db_posttags_add_post_wordids($postid, $wholetagids);
// Update counts cached in database (will be skipped if qa_suspend_update_counts() was called // Update counts cached in database (will be skipped if qa_suspend_update_counts() was called
qa_db_word_titlecount_update($titlewordids); qa_db_word_titlecount_update($titlewordids);
qa_db_word_contentcount_update(array_keys($contentwordidcounts)); qa_db_word_contentcount_update(array_keys($contentwordidcounts));
......
...@@ -20,147 +20,142 @@ ...@@ -20,147 +20,142 @@
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;
} }
function qa_get_mysql_user_column_type() function qa_get_mysql_user_column_type()
{ {
return 'BIGINT UNSIGNED'; return 'BIGINT UNSIGNED';
} }
function qa_get_login_links($relative_url_prefix, $redirect_back_to_url) function qa_get_login_links($relative_url_prefix, $redirect_back_to_url)
{ {
return array( return array(
'login' => wp_login_url(qa_opt('site_url').$redirect_back_to_url), 'login' => wp_login_url(qa_opt('site_url') . $redirect_back_to_url),
'register' => function_exists('wp_registration_url') ? wp_registration_url() : site_url('wp-login.php?action=register'), 'register' => function_exists('wp_registration_url') ? wp_registration_url() : site_url('wp-login.php?action=register'),
'logout' => strtr(wp_logout_url(), array('&' => '&')), 'logout' => strtr(wp_logout_url(), array('&' => '&')),
); );
} }
function qa_get_logged_in_user() function qa_get_logged_in_user()
{ {
$wordpressuser=wp_get_current_user(); $wordpressuser = wp_get_current_user();
if ($wordpressuser->ID==0)
return null;
else {
if (current_user_can('administrator'))
$level=QA_USER_LEVEL_ADMIN;
elseif (current_user_can('editor'))
$level=QA_USER_LEVEL_EDITOR;
elseif (current_user_can('contributor'))
$level=QA_USER_LEVEL_EXPERT;
else
$level=QA_USER_LEVEL_BASIC;
return array(
'userid' => $wordpressuser->ID,
'publicusername' => $wordpressuser->user_nicename,
'email' => $wordpressuser->user_email,
'level' => $level,
);
}
}
if ($wordpressuser->ID == 0)
return null;
function qa_get_user_email($userid) else {
{ if (current_user_can('administrator'))
$user=get_userdata($userid); $level = QA_USER_LEVEL_ADMIN;
elseif (current_user_can('editor'))
$level = QA_USER_LEVEL_EDITOR;
elseif (current_user_can('contributor'))
$level = QA_USER_LEVEL_EXPERT;
else
$level = QA_USER_LEVEL_BASIC;
return @$user->user_email; return array(
'userid' => $wordpressuser->ID,
'publicusername' => $wordpressuser->user_nicename,
'email' => $wordpressuser->user_email,
'level' => $level,
);
} }
}
function qa_get_userids_from_public($publicusernames) function qa_get_user_email($userid)
{ {
global $wpdb; $user = get_userdata($userid);
if (count($publicusernames)) return @$user->user_email;
return qa_db_read_all_assoc(qa_db_query_sub( }
'SELECT user_nicename, ID FROM '.$wpdb->base_prefix.'users WHERE user_nicename IN ($)',
$publicusernames
), 'user_nicename', 'ID');
else
return array();
}
function qa_get_public_from_userids($userids) function qa_get_userids_from_public($publicusernames)
{ {
global $wpdb, $qa_cache_wp_user_emails; global $wpdb;
if (count($userids)) { if (count($publicusernames))
$useridtopublic=array(); return qa_db_read_all_assoc(qa_db_query_sub(
$qa_cache_wp_user_emails=array(); 'SELECT user_nicename, ID FROM ' . $wpdb->base_prefix . 'users WHERE user_nicename IN ($)',
$publicusernames
), 'user_nicename', 'ID');
else
return array();
}
$userfields=qa_db_read_all_assoc(qa_db_query_sub(
'SELECT ID, user_nicename, user_email FROM '.$wpdb->base_prefix.'users WHERE ID IN (#)',
$userids
), 'ID');
foreach ($userfields as $id => $fields) { function qa_get_public_from_userids($userids)
$useridtopublic[$id]=$fields['user_nicename']; {
$qa_cache_wp_user_emails[$id]=$fields['user_email']; global $wpdb, $qa_cache_wp_user_emails;
}
return $useridtopublic; if (count($userids)) {
$useridtopublic = array();
$qa_cache_wp_user_emails = array();
} else $userfields = qa_db_read_all_assoc(qa_db_query_sub(
return array(); 'SELECT ID, user_nicename, user_email FROM ' . $wpdb->base_prefix . 'users WHERE ID IN (#)',
} $userids
), 'ID');
foreach ($userfields as $id => $fields) {
$useridtopublic[$id] = $fields['user_nicename'];
$qa_cache_wp_user_emails[$id] = $fields['user_email'];
}
function qa_get_logged_in_user_html($logged_in_user, $relative_url_prefix) return $useridtopublic;
{
$publicusername=$logged_in_user['publicusername'];
return '<a href="'.qa_path_html('user/'.$publicusername).'" class="qa-user-link">'.htmlspecialchars($publicusername).'</a>'; } else
} return array();
}
function qa_get_users_html($userids, $should_include_link, $relative_url_prefix) function qa_get_logged_in_user_html($logged_in_user, $relative_url_prefix)
{ {
$useridtopublic=qa_get_public_from_userids($userids); $publicusername = $logged_in_user['publicusername'];
$usershtml=array(); return '<a href="' . qa_path_html('user/' . $publicusername) . '" class="qa-user-link">' . htmlspecialchars($publicusername) . '</a>';
}
foreach ($userids as $userid) {
$publicusername=$useridtopublic[$userid];
$usershtml[$userid]=htmlspecialchars($publicusername); function qa_get_users_html($userids, $should_include_link, $relative_url_prefix)
{
$useridtopublic = qa_get_public_from_userids($userids);
if ($should_include_link) $usershtml = array();
$usershtml[$userid]='<a href="'.qa_path_html('user/'.$publicusername).'" class="qa-user-link">'.$usershtml[$userid].'</a>';
}
return $usershtml; foreach ($userids as $userid) {
} $publicusername = $useridtopublic[$userid];
$usershtml[$userid] = htmlspecialchars($publicusername);
if ($should_include_link)
$usershtml[$userid] = '<a href="' . qa_path_html('user/' . $publicusername) . '" class="qa-user-link">' . $usershtml[$userid] . '</a>';
}
function qa_avatar_html_from_userid($userid, $size, $padding) return $usershtml;
{ }
require_once QA_INCLUDE_DIR.'app/format.php';
global $qa_cache_wp_user_emails;
if (isset($qa_cache_wp_user_emails[$userid])) function qa_avatar_html_from_userid($userid, $size, $padding)
return qa_get_gravatar_html($qa_cache_wp_user_emails[$userid], $size); {
require_once QA_INCLUDE_DIR . 'app/format.php';
return null; global $qa_cache_wp_user_emails;
}
if (isset($qa_cache_wp_user_emails[$userid]))
return qa_get_gravatar_html($qa_cache_wp_user_emails[$userid], $size);
function qa_user_report_action($userid, $action) return null;
{ }
}
/* function qa_user_report_action($userid, $action)
Omit PHP closing tag to help avoid accidental output {
*/ }
...@@ -20,12 +20,7 @@ ...@@ -20,12 +20,7 @@
More about this license: http://www.question2answer.org/license.php More about this license: http://www.question2answer.org/license.php
*/ */
return array( return array(
'admin_title' => 'Administration Centre', 'admin_title' => 'Administration Centre',
'url_format_note' => 'Options with the ^ label are working for your site\'s configuration. For best search engine optimisation (SEO), use the first ^ option available.', 'url_format_note' => 'Options with the ^ label are working for your site\'s configuration. For best search engine optimisation (SEO), use the first ^ option available.',
); );
/*
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