diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 09dd4889d..2e5844727 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,20 +1,20 @@ # How to contribute -As of version 1.6.3, all development of [Question2Answer][Home] will take place through GitHub. Bug reports and pull requests are encouraged, provided they follow these guidelines. +As of version 1.6.3, all development of [Question2Answer](http://www.question2answer.org/) will take place through GitHub. Bug reports and pull requests are encouraged, provided they follow these guidelines. ## Bug reports (issues) -If you find a bug (error) with Question2Answer, please [submit an issue here][Issues]. Be as descriptive as possible: include exactly what you did to make the bug appear, what you expect to happen, and what happened instead. Also include your PHP version and MySQL version. Remember to check for similar issues already reported. +If you find a bug (error) with Question2Answer, please [submit an issue here](https://github.com/q2a/question2answer/issues). Be as descriptive as possible: include exactly what you did to make the bug appear, what you expect to happen, and what happened instead. Also include your PHP version and MySQL version. Remember to check for similar issues already reported. If you think you've found a security issue, you can responsibly disclose it to us using the [contact form here](http://www.question2answer.org/feedback.php). -Note that general troubleshooting issues such as installation or how to use a feature should continue to be asked on the [Question2Answer Q&A][QA]. +Note that general troubleshooting issues such as installation or how to use a feature should continue to be asked on the [Question2Answer Q&A](http://www.question2answer.org/qa/). ## Pull requests -If you have found the cause of the bug in the Q2A code, you can submit the patch back to the Q2A repository. Create a fork of the repo, make the changes in your fork, then submit a pull request. Bug fix pull requessts must be made to the `dev` branch. PRs for new features must be made to the next version branch, for example `1.8`. +If you have found the cause of the bug in the Q2A code, you can submit the patch back to the Q2A repository. Create a fork of the repo, make the changes in your fork, then submit a pull request. Bug fix pull requests must be targeted to the **`bugfix`** branch. PRs for new features or large code changes must be made to the **`dev`** branch. If you wish to implement a feature, you should start a discussion on the [Question2Answer Q&A][QA] first. We welcome all ideas but they may not be appropriate for the Q2A core. Consider whether your idea could be developed as a plugin. @@ -23,7 +23,7 @@ If you wish to implement a feature, you should start a discussion on the [Questi From 1.7 onwards a new coding style has been implemented that is more in line with other projects. All PHP code should use these guidelines: -- PHP code should start with `` should be omitted to avoid accidental output. +- PHP code should start with `` should be omitted to avoid accidental whitespace output. - PHP files should use UTF-8 encoding without BOM (this is usually default in most text editors). - Trailing whitespace (tabs or spaces at the end of lines) should not be present. Any advanced text editor should be able to do this automatically when saving. (For Sublime Text you can add the option `"trim_trailing_white_space_on_save": true` to your preferences. In Notepad++ you can press Alt+Shift+S.) - Use tabs for indenting. Each file should start at level 0 (i.e. no indentation). @@ -39,9 +39,3 @@ If in doubt, follow the style of the surrounding code. Code examples can be foun ## Documentation Please see the repository [q2a.github.io](https://github.com/q2a/q2a.github.io/) which automatically produces the documentation website [docs.question2answer.org](http://docs.question2answer.org/). - - -[Home]: http://www.question2answer.org/ -[QA]: http://www.question2answer.org/qa/ -[Issues]: https://github.com/q2a/question2answer/issues -[PSR0]: https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-0.md diff --git a/qa-include/app/captcha.php b/qa-include/app/captcha.php index 0827bca17..bf57079a8 100644 --- a/qa-include/app/captcha.php +++ b/qa-include/app/captcha.php @@ -47,7 +47,7 @@ function qa_captcha_reason_note($captchareason) switch ($captchareason) { case 'login': - $notehtml = qa_insert_login_links(qa_lang_html('misc/captcha_login_fix')); + $notehtml = qa_insert_login_links(qa_lang_html(qa_opt('suspend_register_users') ? 'misc/captcha_login_fix_no_register' : 'misc/captcha_login_fix')); break; case 'confirm': diff --git a/qa-include/app/emails.php b/qa-include/app/emails.php index 5761ef397..561935c90 100644 --- a/qa-include/app/emails.php +++ b/qa-include/app/emails.php @@ -132,8 +132,7 @@ function qa_send_email($params) // @error_log(print_r($params, true)); - require_once QA_INCLUDE_DIR . 'vendor/PHPMailer/class.phpmailer.php'; - require_once QA_INCLUDE_DIR . 'vendor/PHPMailer/class.smtp.php'; + require_once QA_INCLUDE_DIR . 'vendor/PHPMailer/PHPMailerAutoload.php'; $mailer = new PHPMailer(); $mailer->CharSet = 'utf-8'; diff --git a/qa-include/app/format.php b/qa-include/app/format.php index cf354619a..4649a90f6 100644 --- a/qa-include/app/format.php +++ b/qa-include/app/format.php @@ -381,7 +381,7 @@ function qa_post_html_fields($post, $userid, $cookieid, $usershtml, $dummy, $opt if (@$options['categoryview'] && isset($post['categoryname']) && isset($post['categorybackpath'])) { $favoriteclass = ''; - if (count(@$favoritemap['category'])) { + if (!empty($favoritemap['category']) && count($favoritemap['category'])) { if (@$favoritemap['category'][$post['categorybackpath']]) { $favoriteclass = ' qa-cat-favorited'; } else { diff --git a/qa-include/app/messages.php b/qa-include/app/messages.php index 9d85bcea7..c35394f22 100644 --- a/qa-include/app/messages.php +++ b/qa-include/app/messages.php @@ -37,7 +37,10 @@ function qa_wall_error_html($fromuserid, $touserid, $touserflags) { require_once QA_INCLUDE_DIR . 'app/limits.php'; - if (qa_to_override(__FUNCTION__)) { $args=func_get_args(); return qa_call_override(__FUNCTION__, $args); } + if (qa_to_override(__FUNCTION__)) { + $args = func_get_args(); + return qa_call_override(__FUNCTION__, $args); + } if (!QA_FINAL_EXTERNAL_USERS && qa_opt('allow_user_walls')) { if (($touserflags & QA_USER_FLAGS_NO_WALL_POSTS) && !(isset($fromuserid) && $fromuserid == $touserid)) @@ -50,7 +53,10 @@ function qa_wall_error_html($fromuserid, $touserid, $touserflags) break; case 'login': - return qa_insert_login_links(qa_lang_html('profile/post_wall_must_login'), qa_request()); + return qa_insert_login_links(qa_lang_html( + qa_opt('suspend_register_users') ? 'profile/post_wall_must_login_no_register' : 'profile/post_wall_must_login'), + qa_request() + ); break; case 'confirm': @@ -89,7 +95,10 @@ function qa_wall_error_html($fromuserid, $touserid, $touserflags) */ function qa_wall_add_post($userid, $handle, $cookieid, $touserid, $tohandle, $content, $format) { - if (qa_to_override(__FUNCTION__)) { $args=func_get_args(); return qa_call_override(__FUNCTION__, $args); } + if (qa_to_override(__FUNCTION__)) { + $args = func_get_args(); + return qa_call_override(__FUNCTION__, $args); + } require_once QA_INCLUDE_DIR . 'app/format.php'; require_once QA_INCLUDE_DIR . 'db/messages.php'; @@ -142,7 +151,10 @@ function qa_wall_delete_post($userid, $handle, $cookieid, $message) */ function qa_wall_posts_add_rules($usermessages, $start) { - if (qa_to_override(__FUNCTION__)) { $args=func_get_args(); return qa_call_override(__FUNCTION__, $args); } + if (qa_to_override(__FUNCTION__)) { + $args = func_get_args(); + return qa_call_override(__FUNCTION__, $args); + } $userid = qa_get_logged_in_userid(); // reuse "Hiding or showing any post" and "Deleting hidden posts" permissions diff --git a/qa-include/app/page.php b/qa-include/app/page.php index 27a61d215..6ba7b6677 100644 --- a/qa-include/app/page.php +++ b/qa-include/app/page.php @@ -777,7 +777,7 @@ function qa_content_prepare($voting = false, $categoryids = array()) ); } - if (!empty($userlinks['register'])) { + if (!empty($userlinks['register']) && !qa_opt('suspend_register_users')) { $qa_content['navigation']['user']['register'] = array( 'url' => qa_html(@$userlinks['register']), 'label' => qa_lang_html('main/nav_register'), diff --git a/qa-include/app/post-create.php b/qa-include/app/post-create.php index 03ed15fb6..a69a23f01 100644 --- a/qa-include/app/post-create.php +++ b/qa-include/app/post-create.php @@ -124,6 +124,7 @@ function qa_update_counts_for_q($postid) qa_db_unaqcount_update(); qa_db_unselqcount_update(); qa_db_unupaqcount_update(); + qa_db_tagcount_update(); } diff --git a/qa-include/app/post-update.php b/qa-include/app/post-update.php index 63fa95036..5806c1f83 100644 --- a/qa-include/app/post-update.php +++ b/qa-include/app/post-update.php @@ -106,6 +106,9 @@ function qa_question_set_content($oldquestion, $title, $content, $format, $text, } elseif ($oldquestion['type'] == 'Q') { // not hidden or queued qa_post_index($oldquestion['postid'], 'Q', $oldquestion['postid'], $oldquestion['parentid'], $title, $content, $format, $text, $tagstring, $oldquestion['categoryid']); + if ($tagschanged) { + qa_db_tagcount_update(); + } } $eventparams = array( diff --git a/qa-include/app/users.php b/qa-include/app/users.php index 3df963f8a..8d7c064ce 100644 --- a/qa-include/app/users.php +++ b/qa-include/app/users.php @@ -456,6 +456,17 @@ function qa_get_logged_in_user_cache() require_once QA_INCLUDE_DIR . 'db/selects.php'; $qa_cached_logged_in_user = qa_db_get_pending_result('loggedinuser', qa_db_user_account_selectspec($userid, true)); + // If the site is configured to share the ^users table then there might not be a record in the + // ^userpoints table so this creates it + if ($qa_cached_logged_in_user['points'] === null) { + require_once QA_INCLUDE_DIR . 'db/points.php'; + require_once QA_INCLUDE_DIR . 'db/users.php'; + + qa_db_points_update_ifuser($userid, null); + qa_db_uapprovecount_update(); + $qa_cached_logged_in_user = qa_db_single_select(qa_db_user_account_selectspec($userid, true)); + } + if (!isset($qa_cached_logged_in_user)) { // the user can no longer be found (should only apply to deleted users) qa_clear_session_user(); diff --git a/qa-include/app/votes.php b/qa-include/app/votes.php index 420a3ffad..c06952443 100644 --- a/qa-include/app/votes.php +++ b/qa-include/app/votes.php @@ -36,7 +36,10 @@ */ function qa_vote_error_html($post, $vote, $userid, $topage) { - if (qa_to_override(__FUNCTION__)) { $args=func_get_args(); return qa_call_override(__FUNCTION__, $args); } + if (qa_to_override(__FUNCTION__)) { + $args = func_get_args(); + return qa_call_override(__FUNCTION__, $args); + } // The 'login', 'confirm', 'limit', 'userblock' and 'ipblock' permission errors are reported to the user here. // Others ('approve', 'level') prevent the buttons being clickable in the first place, in qa_get_vote_view(...) @@ -51,8 +54,7 @@ function qa_vote_error_html($post, $vote, $userid, $topage) return qa_lang_html('main/vote_disabled_queued'); } - switch($post['basetype']) - { + switch ($post['basetype']) { case 'Q': $allowVoting = qa_opt('voting_on_qs'); break; @@ -85,7 +87,7 @@ function qa_vote_error_html($post, $vote, $userid, $topage) break; case 'login': - return qa_insert_login_links(qa_lang_html('main/vote_must_login'), $topage); + return qa_insert_login_links(qa_lang_html(qa_opt('suspend_register_users') ? 'main/vote_must_login_no_register' : 'main/vote_must_login'), $topage); break; case 'confirm': @@ -115,7 +117,10 @@ function qa_vote_error_html($post, $vote, $userid, $topage) */ function qa_vote_set($post, $userid, $handle, $cookieid, $vote) { - if (qa_to_override(__FUNCTION__)) { $args=func_get_args(); return qa_call_override(__FUNCTION__, $args); } + if (qa_to_override(__FUNCTION__)) { + $args = func_get_args(); + return qa_call_override(__FUNCTION__, $args); + } require_once QA_INCLUDE_DIR . 'db/points.php'; require_once QA_INCLUDE_DIR . 'db/hotness.php'; @@ -185,7 +190,10 @@ function qa_vote_set($post, $userid, $handle, $cookieid, $vote) */ function qa_flag_error_html($post, $userid, $topage) { - if (qa_to_override(__FUNCTION__)) { $args=func_get_args(); return qa_call_override(__FUNCTION__, $args); } + if (qa_to_override(__FUNCTION__)) { + $args = func_get_args(); + return qa_call_override(__FUNCTION__, $args); + } // The 'login', 'confirm', 'limit', 'userblock' and 'ipblock' permission errors are reported to the user here. // Others ('approve', 'level') prevent the flag button being shown, in qa_page_q_post_rules(...) @@ -200,7 +208,10 @@ function qa_flag_error_html($post, $userid, $topage) ) { switch (qa_user_post_permit_error('permit_flag', $post, QA_LIMIT_FLAGS)) { case 'login': - return qa_insert_login_links(qa_lang_html('question/flag_must_login'), $topage); + return qa_insert_login_links( + qa_lang_html(qa_opt('suspend_register_users') ? 'question/flag_must_login_no_register' : 'question/flag_must_login'), + $topage + ); break; case 'confirm': @@ -237,7 +248,10 @@ function qa_flag_error_html($post, $userid, $topage) */ function qa_flag_set_tohide($oldpost, $userid, $handle, $cookieid, $question) { - if (qa_to_override(__FUNCTION__)) { $args=func_get_args(); return qa_call_override(__FUNCTION__, $args); } + if (qa_to_override(__FUNCTION__)) { + $args = func_get_args(); + return qa_call_override(__FUNCTION__, $args); + } require_once QA_INCLUDE_DIR . 'db/votes.php'; require_once QA_INCLUDE_DIR . 'app/limits.php'; @@ -286,7 +300,10 @@ function qa_flag_set_tohide($oldpost, $userid, $handle, $cookieid, $question) */ function qa_flag_clear($oldpost, $userid, $handle, $cookieid) { - if (qa_to_override(__FUNCTION__)) { $args=func_get_args(); return qa_call_override(__FUNCTION__, $args); } + if (qa_to_override(__FUNCTION__)) { + $args = func_get_args(); + return qa_call_override(__FUNCTION__, $args); + } require_once QA_INCLUDE_DIR . 'db/votes.php'; require_once QA_INCLUDE_DIR . 'app/limits.php'; @@ -328,7 +345,10 @@ function qa_flag_clear($oldpost, $userid, $handle, $cookieid) */ function qa_flags_clear_all($oldpost, $userid, $handle, $cookieid) { - if (qa_to_override(__FUNCTION__)) { $args=func_get_args(); return qa_call_override(__FUNCTION__, $args); } + if (qa_to_override(__FUNCTION__)) { + $args = func_get_args(); + return qa_call_override(__FUNCTION__, $args); + } require_once QA_INCLUDE_DIR . 'db/votes.php'; require_once QA_INCLUDE_DIR . 'app/limits.php'; diff --git a/qa-include/db/install.php b/qa-include/db/install.php index 0a401ed5e..f7bd7d81b 100644 --- a/qa-include/db/install.php +++ b/qa-include/db/install.php @@ -1587,18 +1587,20 @@ function qa_db_upgrade_tables() case 67: // ensure we don't have old userids lying around - qa_db_upgrade_query('ALTER TABLE ^messages MODIFY fromuserid ' . $definitions['messages']['fromuserid']); - qa_db_upgrade_query('ALTER TABLE ^messages MODIFY touserid ' . $definitions['messages']['touserid']); - qa_db_upgrade_query('UPDATE ^messages SET fromuserid=NULL WHERE fromuserid NOT IN (SELECT userid FROM ^users)'); - qa_db_upgrade_query('UPDATE ^messages SET touserid=NULL WHERE touserid NOT IN (SELECT userid FROM ^users)'); - // set up foreign key on messages table - qa_db_upgrade_query('ALTER TABLE ^messages ADD CONSTRAINT ^messages_ibfk_1 FOREIGN KEY (fromuserid) REFERENCES ^users(userid) ON DELETE SET NULL'); - qa_db_upgrade_query('ALTER TABLE ^messages ADD CONSTRAINT ^messages_ibfk_2 FOREIGN KEY (touserid) REFERENCES ^users(userid) ON DELETE SET NULL'); + if (!QA_FINAL_EXTERNAL_USERS) { + qa_db_upgrade_query('ALTER TABLE ^messages MODIFY fromuserid ' . $definitions['messages']['fromuserid']); + qa_db_upgrade_query('ALTER TABLE ^messages MODIFY touserid ' . $definitions['messages']['touserid']); + qa_db_upgrade_query('UPDATE ^messages SET fromuserid=NULL WHERE fromuserid NOT IN (SELECT userid FROM ^users)'); + qa_db_upgrade_query('UPDATE ^messages SET touserid=NULL WHERE touserid NOT IN (SELECT userid FROM ^users)'); + // set up foreign key on messages table + qa_db_upgrade_query('ALTER TABLE ^messages ADD CONSTRAINT ^messages_ibfk_1 FOREIGN KEY (fromuserid) REFERENCES ^users(userid) ON DELETE SET NULL'); + qa_db_upgrade_query('ALTER TABLE ^messages ADD CONSTRAINT ^messages_ibfk_2 FOREIGN KEY (touserid) REFERENCES ^users(userid) ON DELETE SET NULL'); + } qa_db_upgrade_query($locktablesquery); break; - // Up to here: Version 1.8 beta1 + // Up to here: Version 1.8 } qa_db_set_db_version($newversion); diff --git a/qa-include/db/selects.php b/qa-include/db/selects.php index a356b866f..030fb2706 100644 --- a/qa-include/db/selects.php +++ b/qa-include/db/selects.php @@ -1523,9 +1523,17 @@ function qa_db_top_users_selectspec($start, $count = null) ); } + // If the site is configured to share the ^users table then there might not be a record in the ^userpoints table + if (defined('QA_MYSQL_USERS_PREFIX')) { + $basePoints = (int)qa_opt('points_base'); + $source = '^users JOIN (SELECT ^users.userid, COALESCE(points,' . $basePoints . ') AS points FROM ^users LEFT JOIN ^userpoints ON ^users.userid=^userpoints.userid ORDER BY points DESC LIMIT #,#) y ON ^users.userid=y.userid'; + } else { + $source = '^users JOIN (SELECT userid FROM ^userpoints ORDER BY points DESC LIMIT #,#) y ON ^users.userid=y.userid JOIN ^userpoints ON ^users.userid=^userpoints.userid';; + } + return array( 'columns' => array('^users.userid', 'handle', 'points', 'flags', '^users.email', 'avatarblobid' => 'BINARY avatarblobid', 'avatarwidth', 'avatarheight'), - 'source' => '^users JOIN (SELECT userid FROM ^userpoints ORDER BY points DESC LIMIT #,#) y ON ^users.userid=y.userid JOIN ^userpoints ON ^users.userid=^userpoints.userid', + 'source' => $source, 'arguments' => array($start, $count), 'arraykey' => 'userid', 'sortdesc' => 'points', diff --git a/qa-include/lang/qa-lang-main.php b/qa-include/lang/qa-lang-main.php index 94679b9b4..9fec4ba9d 100644 --- a/qa-include/lang/qa-lang-main.php +++ b/qa-include/lang/qa-lang-main.php @@ -184,6 +184,7 @@ 'view_q_must_be_approved' => 'Your account must be approved to view question pages. Please wait or ^1add more information^2.', 'view_q_must_confirm' => 'Please ^5confirm your email address^6 to view question pages.', 'view_q_must_login' => 'Please ^1log in^2 or ^3register^4 to view question pages.', + 'view_q_must_login_no_register' => 'Please ^1log in^2 to view question pages.', 'viewed_qs_in_x' => 'Most viewed questions in ^', 'viewed_qs_title' => 'Most viewed questions', 'vote_disabled_approve' => 'Your account must be approved before you can vote', @@ -203,6 +204,7 @@ 'vote_limit' => 'Too many votes received - please try again in an hour', 'vote_must_confirm' => 'Please ^5confirm your email address^6 to vote.', 'vote_must_login' => 'Please ^1log in^2 or ^3register^4 to vote.', + 'vote_must_login_no_register' => 'Please ^1log in^2 to vote.', 'vote_not_allowed' => 'Voting on this is not allowed', 'vote_up_popup' => 'Click to vote up', 'voted_down_popup' => 'You have voted this down - click to remove vote', diff --git a/qa-include/lang/qa-lang-misc.php b/qa-include/lang/qa-lang-misc.php index 5dc13c623..81504df9b 100644 --- a/qa-include/lang/qa-lang-misc.php +++ b/qa-include/lang/qa-lang-misc.php @@ -27,6 +27,7 @@ 'captcha_error' => 'Please complete the anti-spam verification', 'captcha_label' => 'Anti-spam verification:', 'captcha_login_fix' => 'To avoid this verification in future, please ^1log in^2 or ^3register^4.', + 'captcha_login_fix_no_register' => 'To avoid this verification in future, please ^1log in^2.', 'feed_a_edited_prefix' => 'Answer edited: ', 'feed_a_prefix' => 'Answered: ', 'feed_a_reshown_prefix' => 'Answer reshown: ', @@ -60,6 +61,7 @@ 'message_for_x' => 'Your message for ^:', 'message_limit' => 'You cannot send more private messages this hour', 'message_must_login' => 'Please ^1log in^2 or ^3register^4 to send private messages.', + 'message_must_login_no_register' => 'Please ^1log in^2 to send private messages.', 'message_recent_history' => 'Recent correspondence with ^', 'message_sent' => 'Your private message below was sent', 'more_favorite_qs' => 'More favorite questions...', diff --git a/qa-include/lang/qa-lang-profile.php b/qa-include/lang/qa-lang-profile.php index 3c2a027b1..0a63affde 100644 --- a/qa-include/lang/qa-lang-profile.php +++ b/qa-include/lang/qa-lang-profile.php @@ -69,6 +69,7 @@ 'post_wall_must_be_approved' => 'Your account must be approved to post on this wall. Please wait or ^1add more information^2.', '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_no_register' => 'Please ^1log in^2 to post on this wall.', 'questions' => 'Questions:', 'questions_by_x' => 'Questions by ^', 'ranked_x' => ' (ranked #^)', diff --git a/qa-include/lang/qa-lang-question.php b/qa-include/lang/qa-lang-question.php index b869aae30..1823e5a2f 100644 --- a/qa-include/lang/qa-lang-question.php +++ b/qa-include/lang/qa-lang-question.php @@ -39,6 +39,7 @@ 'answer_must_be_approved' => 'Your account must be approved before you answer a question. Please wait or ^1add more information^2.', 'answer_must_confirm' => 'Please ^5confirm your email address^6 to answer this question.', 'answer_must_login' => 'Please ^1log in^2 or ^3register^4 to answer this question.', + 'answer_must_login_no_register' => 'Please ^1log in^2 to answer this question.', 'answer_q_popup' => 'Answer this question', 'approve_a_popup' => 'Approve this answer', 'approve_button' => 'approve', @@ -51,6 +52,7 @@ 'ask_must_be_approved' => 'Your account must be approved before you ask a question. Please wait or ^1add more information^2.', 'ask_must_confirm' => 'Please ^5confirm your email address^6 to ask a question.', 'ask_must_login' => 'Please ^1log in^2 or ^3register^4 to ask a question.', + 'ask_must_login_no_register' => 'Please ^1log in^2 to ask a question.', 'ask_same_q' => 'Before proceeding, please check your question was not asked already:', 'ask_title' => 'Ask a question', 'c_notify_email' => 'Email me at this address if a comment is added after mine:', @@ -84,6 +86,7 @@ 'comment_must_be_approved' => 'Your account must be approved before you add a comment. Please wait or ^1add more information^2.', 'comment_must_confirm' => 'Please ^5confirm your email address^6 to add a comment.', 'comment_must_login' => 'Please ^1log in^2 or ^3register^4 to add a comment.', + 'comment_must_login_no_register' => 'Please ^1log in^2 to add a comment.', 'comment_on_a' => 'On answer: ', 'comment_on_q' => 'On question: ', 'comment_q_popup' => 'Add a comment on this question', @@ -99,6 +102,7 @@ 'edit_c_title' => 'Edit comment', 'edit_must_confirm' => 'Please ^5confirm your email address^6 to edit this.', 'edit_must_login' => 'Please ^1log in^2 or ^3register^4 to edit this.', + 'edit_must_login_no_register' => 'Please ^1log in^2 to edit this.', 'edit_q_popup' => 'Edit this question', 'edit_q_title' => 'Edit Question', 'example_tags' => 'Example tags: ', @@ -109,6 +113,7 @@ 'flag_limit' => 'Too many posts flagged - please try again in an hour', 'flag_must_confirm' => 'Please ^5confirm your email address^6 to flag posts.', 'flag_must_login' => 'Please ^1log in^2 or ^3register^4 to flag posts.', + 'flag_must_login_no_register' => 'Please ^1log in^2 to flag posts.', 'flag_not_allowed' => 'Flagging this is not allowed', 'flag_q_popup' => 'Flag this question as spam or inappropriate', 'follow_a_popup' => 'Ask a new question relating to this answer', diff --git a/qa-include/pages/account.php b/qa-include/pages/account.php index b9497e2d3..e29aedb7a 100644 --- a/qa-include/pages/account.php +++ b/qa-include/pages/account.php @@ -63,7 +63,7 @@ } $permit_error = qa_user_permit_error(); $isblocked = $permit_error !== false; -$pending_confirmation = $doconfirms && $permit_error == 'confirm'; +$pending_confirmation = $doconfirms && !$isconfirmed; // Process profile if saved diff --git a/qa-include/pages/ask.php b/qa-include/pages/ask.php index 4f11c2438..a7ef85f49 100644 --- a/qa-include/pages/ask.php +++ b/qa-include/pages/ask.php @@ -25,10 +25,10 @@ } -require_once QA_INCLUDE_DIR.'app/format.php'; -require_once QA_INCLUDE_DIR.'app/limits.php'; -require_once QA_INCLUDE_DIR.'db/selects.php'; -require_once QA_INCLUDE_DIR.'util/sort.php'; +require_once QA_INCLUDE_DIR . 'app/format.php'; +require_once QA_INCLUDE_DIR . 'app/limits.php'; +require_once QA_INCLUDE_DIR . 'db/selects.php'; +require_once QA_INCLUDE_DIR . 'util/sort.php'; // Check whether this is a follow-on question and get some info we need from the database @@ -66,7 +66,11 @@ switch ($permiterror) { case 'login': - $qa_content['error'] = qa_insert_login_links(qa_lang_html('question/ask_must_login'), qa_request(), isset($followpostid) ? array('follow' => $followpostid) : null); + $qa_content['error'] = qa_insert_login_links( + qa_lang_html(qa_opt('suspend_register_users') ? 'question/ask_must_login_no_register' : 'question/ask_must_login'), + qa_request(), + isset($followpostid) ? array('follow' => $followpostid) : null + ); break; case 'confirm': @@ -105,8 +109,8 @@ } if (qa_clicked('doask')) { - require_once QA_INCLUDE_DIR.'app/post-create.php'; - require_once QA_INCLUDE_DIR.'util/string.php'; + require_once QA_INCLUDE_DIR . 'app/post-create.php'; + require_once QA_INCLUDE_DIR . 'util/string.php'; $categoryids = array_keys(qa_category_path($categories, @$in['categoryid'])); $userlevel = qa_user_level_for_categories($categoryids); @@ -122,8 +126,7 @@ if (!qa_check_form_security_code('ask', qa_post_text('code'))) { $errors['page'] = qa_lang_html('misc/form_security_again'); - } - else { + } else { $filtermodules = qa_load_modules_with('filter', 'filter_question'); foreach ($filtermodules as $filtermodule) { $oldin = $in; @@ -134,13 +137,12 @@ if (qa_using_categories() && count($categories) && (!qa_opt('allow_no_category')) && !isset($in['categoryid'])) { // check this here because we need to know count($categories) $errors['categoryid'] = qa_lang_html('question/category_required'); - } - elseif (qa_user_permit_error('permit_post_q', null, $userlevel)) { + } elseif (qa_user_permit_error('permit_post_q', null, $userlevel)) { $errors['categoryid'] = qa_lang_html('question/category_ask_not_allowed'); } if ($captchareason) { - require_once QA_INCLUDE_DIR.'app/captcha.php'; + require_once QA_INCLUDE_DIR . 'app/captcha.php'; qa_captcha_validate_post($errors); } @@ -193,7 +195,7 @@ $custom = qa_opt('show_custom_ask') ? trim(qa_opt('custom_ask')) : ''; $qa_content['form'] = array( - 'tags' => 'name="ask" method="post" action="'.qa_self_html().'"', + 'tags' => 'name="ask" method="post" action="' . qa_self_html() . '"', 'style' => 'tall', @@ -220,8 +222,8 @@ 'buttons' => array( 'ask' => array( - 'tags' => 'onclick="qa_show_waiting_after(this, false); '. - (method_exists($editor, 'update_script') ? $editor->update_script('content') : '').'"', + 'tags' => 'onclick="qa_show_waiting_after(this, false); ' . + (method_exists($editor, 'update_script') ? $editor->update_script('content') : '') . '"', 'label' => qa_lang_html('question/ask_button'), ), ), @@ -241,7 +243,7 @@ $qa_content['form']['fields']['title']['tags'] .= ' onchange="qa_title_change(this.value);"'; if (strlen(@$in['title'])) { - $qa_content['script_onloads'][] = 'qa_title_change('.qa_js($in['title']).');'; + $qa_content['script_onloads'][] = 'qa_title_change(' . qa_js($in['title']) . ');'; } } @@ -301,7 +303,7 @@ isset($in['notify']) ? $in['notify'] : qa_opt('notify_users_default'), @$in['email'], @$errors['email']); if ($captchareason) { - require_once QA_INCLUDE_DIR.'app/captcha.php'; + require_once QA_INCLUDE_DIR . 'app/captcha.php'; qa_set_up_captcha_field($qa_content, $qa_content['form']['fields'], @$errors, qa_captcha_reason_note($captchareason)); } diff --git a/qa-include/pages/message.php b/qa-include/pages/message.php index ce734becd..e535a9c4a 100644 --- a/qa-include/pages/message.php +++ b/qa-include/pages/message.php @@ -45,7 +45,10 @@ qa_redirect('users'); if (!isset($loginuserid)) { - $qa_content['error'] = qa_insert_login_links(qa_lang_html('misc/message_must_login'), qa_request()); + $qa_content['error'] = qa_insert_login_links( + qa_lang_html(qa_opt('suspend_register_users') ? 'misc/message_must_login_no_register' : 'misc/message_must_login'), + qa_request() + ); return $qa_content; } diff --git a/qa-include/pages/messages.php b/qa-include/pages/messages.php index c08846018..b2c00cc4b 100644 --- a/qa-include/pages/messages.php +++ b/qa-include/pages/messages.php @@ -48,7 +48,10 @@ if (!isset($loginUserId)) { $qa_content = qa_content_prepare(); - $qa_content['error'] = qa_insert_login_links(qa_lang_html('misc/message_must_login'), qa_request()); + $qa_content['error'] = qa_insert_login_links( + qa_lang_html(qa_opt('suspend_register_users') ? 'misc/message_must_login_no_register' : 'misc/message_must_login'), + qa_request() + ); return $qa_content; } @@ -77,9 +80,9 @@ $qa_content['custom'] = '