Commit cf6aef69 by Scott

Coding style (fix more CodeSniffer errors)

parent ac84dde7
......@@ -46,8 +46,7 @@ list($comment, $question, $parent, $children) = qa_db_select_with_pending(
// Check if there was an operation that succeeded
if (
@$comment['basetype'] == 'C' && @$question['basetype'] == 'Q' &&
if (@$comment['basetype'] == 'C' && @$question['basetype'] == 'Q' &&
(@$parent['basetype'] == 'Q' || @$parent['basetype'] == 'A')
) {
$comment = $comment + qa_page_q_post_rules($comment, $parent, $children, null); // array union
......
......@@ -40,8 +40,7 @@ list($question, $parent, $children) = qa_db_select_with_pending(
// Check if the question and parent exist, and whether the user has permission to do this
if (
@$question['basetype'] == 'Q' && (@$parent['basetype'] == 'Q' || @$parent['basetype'] == 'A') &&
if (@$question['basetype'] == 'Q' && (@$parent['basetype'] == 'Q' || @$parent['basetype'] == 'A') &&
!qa_user_post_permit_error('permit_post_c', $parent, QA_LIMIT_COMMENTS)
) {
require_once QA_INCLUDE_DIR . 'app/captcha.php';
......
......@@ -25,7 +25,6 @@ require_once QA_INCLUDE_DIR . 'app/recalc.php';
if (qa_get_logged_in_level() >= QA_USER_LEVEL_ADMIN) {
if (!qa_check_form_security_code('admin/recalc', qa_post_text('code'))) {
$state = '';
$message = qa_lang('misc/form_security_reload');
......
......@@ -602,9 +602,8 @@ function qa_post_html_fields($post, $userid, $cookieid, $usershtml, $dummy, $opt
// Updated when and by whom
if (
@$options['updateview'] && isset($post['updated']) &&
(($post['updatetype'] != QA_UPDATE_SELECTED) || $isselected) && // only show selected change if it's still selected
if (@$options['updateview'] && isset($post['updated']) &&
($post['updatetype'] != QA_UPDATE_SELECTED || $isselected) && // only show selected change if it's still selected
( // otherwise check if one of these conditions is fulfilled...
(!isset($post['created'])) || // ... we didn't show the created time (should never happen in practice)
($post['hidden'] && ($post['updatetype'] == QA_UPDATE_VISIBLE)) || // ... the post was hidden as the last action
......@@ -1567,9 +1566,7 @@ function qa_custom_page_url($page)
*/
function qa_navigation_add_page(&$navigation, $page)
{
if (
!isset($page['permit']) || !qa_permit_value_error($page['permit'], qa_get_logged_in_userid(), qa_get_logged_in_level(), qa_get_logged_in_flags())
) {
if (!isset($page['permit']) || !qa_permit_value_error($page['permit'], qa_get_logged_in_userid(), qa_get_logged_in_level(), qa_get_logged_in_flags())) {
$url = qa_custom_page_url($page);
$navigation[($page['flags'] & QA_PAGE_FLAGS_EXTERNAL) ? ('custom-' . $page['pageid']) : ($page['tags'] . '$')] = array(
......@@ -2201,8 +2198,7 @@ function qa_get_post_content($editorfield, $contentfield, &$ineditor, &$inconten
*/
function qa_update_post_text(&$fields, $oldfields)
{
if (
strcmp($oldfields['content'], $fields['content']) ||
if (strcmp($oldfields['content'], $fields['content']) ||
strcmp($oldfields['format'], $fields['format']) ||
strcmp($oldfields['text'], $fields['text'])
) {
......
......@@ -187,8 +187,7 @@ function qa_block_ips_explode($blockipstring)
function qa_block_ip_match($ip, $blockipclause)
{
// check if the input parameters use the same IP version
if (
(strpos($ip, ".") !== false && strpos($blockipclause, ".") === false) ||
if ((strpos($ip, ".") !== false && strpos($blockipclause, ".") === false) ||
(strpos($ip, ".") === false && strpos($blockipclause, ".") !== false)
) {
return false;
......
......@@ -642,11 +642,8 @@ function qa_content_prepare($voting = false, $categoryids = null)
}
if (
qa_get_logged_in_level() >= QA_USER_LEVEL_ADMIN ||
!qa_user_maximum_permit_error('permit_moderate') ||
!qa_user_maximum_permit_error('permit_hide_show') ||
!qa_user_maximum_permit_error('permit_delete_hidden')
if (qa_get_logged_in_level() >= QA_USER_LEVEL_ADMIN || !qa_user_maximum_permit_error('permit_moderate') ||
!qa_user_maximum_permit_error('permit_hide_show') || !qa_user_maximum_permit_error('permit_delete_hidden')
) {
$qa_content['navigation']['main']['admin'] = array(
'url' => qa_path_html('admin'),
......@@ -696,13 +693,11 @@ function qa_content_prepare($voting = false, $categoryids = null)
if (isset($region) && isset($place)) {
// region/place codes recognized
$module = qa_load_module('widget', $widget['title']);
$allowTmpl = (substr($qa_template, 0, 7) == 'custom-') ? 'custom' : $qa_template;
if (
isset($module) &&
method_exists($module, 'allow_template') &&
$module->allow_template((substr($qa_template, 0, 7) == 'custom-') ? 'custom' : $qa_template) &&
method_exists($module, 'allow_region') &&
$module->allow_region($region) &&
if (isset($module) &&
method_exists($module, 'allow_template') && $module->allow_template($allowTmpl) &&
method_exists($module, 'allow_region') && $module->allow_region($region) &&
method_exists($module, 'output_widget')
) {
// if module loaded and happy to be displayed here, tell theme about it
......
......@@ -277,7 +277,6 @@ function qa_recalc_perform_step(&$state)
$lastquestionid = max($questionids);
foreach ($questionids as $questionid) {
// Retrieve all posts relating to this question
list($question, $childposts, $achildposts) = qa_db_select_with_pending(
......
......@@ -53,7 +53,6 @@ define('QA_FIELD_FLAGS_ON_REGISTER', 4);
if (QA_FINAL_EXTERNAL_USERS) {
// If we're using single sign-on integration (WordPress or otherwise), load PHP file for that
if (defined('QA_FINAL_WORDPRESS_INTEGRATE_PATH')) {
......@@ -1134,19 +1133,15 @@ function qa_permit_value_error($permit, $userid, $userlevel, $userflags)
if ($permit >= QA_PERMIT_CONFIRMED) {
$confirmed = ($userflags & QA_USER_FLAGS_EMAIL_CONFIRMED);
if (
!QA_FINAL_EXTERNAL_USERS && // not currently supported by single sign-on integration
qa_opt('confirm_user_emails') && // if this option off, we can't ask it of the user
$userlevel < QA_USER_LEVEL_APPROVED && // if user approved or assigned to a higher level, no need
!$confirmed // actual confirmation
)
// not currently supported by single sign-on integration; approved users and above don't need confirmation
if (!QA_FINAL_EXTERNAL_USERS && qa_opt('confirm_user_emails') && $userlevel < QA_USER_LEVEL_APPROVED && !$confirmed) {
return 'confirm';
}
} elseif ($permit >= QA_PERMIT_APPROVED) {
if (
qa_opt('moderate_users') && // if this option off, we can't ask it of the user
$userlevel < QA_USER_LEVEL_APPROVED // user has not been approved
)
// check user is approved, only if we require it
if (qa_opt('moderate_users') && $userlevel < QA_USER_LEVEL_APPROVED) {
return 'approve';
}
}
return false;
......@@ -1225,10 +1220,8 @@ function qa_user_moderation_reason($userlevel = null)
if (!isset($userlevel))
$userlevel = qa_get_logged_in_level();
if (
($userlevel < QA_USER_LEVEL_EXPERT) && // experts and above aren't moderated
qa_user_permit_error('permit_moderate') // if the user can approve posts, no point in moderating theirs
) {
if ($userlevel < QA_USER_LEVEL_EXPERT && qa_user_permit_error('permit_moderate')) {
// experts and above aren't moderated; if the user can approve posts, no point in moderating theirs
$userid = qa_get_logged_in_userid();
if (isset($userid)) {
......
......@@ -45,9 +45,7 @@ function qa_vote_error_html($post, $vote, $userid, $topage)
require_once QA_INCLUDE_DIR . 'app/users.php';
require_once QA_INCLUDE_DIR . 'app/limits.php';
if (
is_array($post) &&
($post['basetype'] == 'Q' || $post['basetype'] == 'A') &&
if (is_array($post) && ($post['basetype'] == 'Q' || $post['basetype'] == 'A') &&
qa_opt(($post['basetype'] == 'Q') ? 'voting_on_qs' : 'voting_on_as') &&
(!isset($post['userid']) || !isset($userid) || $post['userid'] != $userid)
) {
......@@ -167,12 +165,9 @@ function qa_flag_error_html($post, $userid, $topage)
require_once QA_INCLUDE_DIR . 'app/users.php';
require_once QA_INCLUDE_DIR . 'app/limits.php';
if (
is_array($post) &&
qa_opt('flagging_of_posts') &&
if (is_array($post) && qa_opt('flagging_of_posts') &&
(!isset($post['userid']) || !isset($userid) || $post['userid'] != $userid)
) {
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);
......
......@@ -98,9 +98,7 @@ function qa_db_event_create_for_entity($entitytype, $entityid, $questionid, $las
), true);
if (isset($randomuserid)) {
// If one was found, this means we have one or more individual event streams, so update them all
qa_db_query_sub(
'INSERT INTO ^userevents (userid, entitytype, entityid, questionid, lastpostid, updatetype, lastuserid, updated) ' .
'SELECT userid, $, #, #, #, $, $, ' . $updatedsql . ' FROM ^userfavorites WHERE entitytype=$ AND entityid=# AND nouserevents=0',
......@@ -109,7 +107,6 @@ function qa_db_event_create_for_entity($entitytype, $entityid, $questionid, $las
// Now truncate the random individual event stream that was found earlier
// (in theory we should truncate them all, but truncation is just a 'housekeeping' activity, so it's not necessary)
qa_db_user_events_truncate($randomuserid, $questionid);
}
}
......
......@@ -143,7 +143,6 @@ function qa_db_favorite_create($userid, $entitytype, $entityid)
// If we're going to use the shared stream...
if ($useshared) {
// ... for all the people for whom we're switching this to a shared stream, find the highest number of other shared streams they have
$maxshared = qa_db_read_one_value(qa_db_query_sub(
......
......@@ -771,7 +771,6 @@ function qa_db_upgrade_tables()
qa_db_upgrade_progress(QA_DB_VERSION_CURRENT - $version . ' upgrade step/s remaining...');
switch ($newversion) {
// Up to here: Version 1.0 beta 1
case 2:
......
......@@ -148,8 +148,7 @@ if (qa_clicked('docancel')) {
$errors['name'] = qa_lang_sub('main/max_length_x', QA_DB_MAX_CAT_PAGE_TITLE_LENGTH);
else {
foreach ($incategories as $category) {
if (
!strcmp($category['parentid'], $inparentid) &&
if (!strcmp($category['parentid'], $inparentid) &&
strcmp($category['categoryid'], @$editcategory['categoryid']) &&
qa_strtolower($category['title']) == qa_strtolower($inname)
) {
......@@ -284,7 +283,6 @@ if ($setmissing) {
} elseif (isset($editcategory)) {
$qa_content['form'] = array(
'tags' => 'method="post" action="' . qa_path_html(qa_request()) . '"',
......
......@@ -712,9 +712,7 @@ else {
foreach ($getoptions as $optionname) {
$optionvalue = qa_post_text('option_' . $optionname);
if (
@$optiontype[$optionname] == 'number' ||
@$optiontype[$optionname] == 'checkbox' ||
if (@$optiontype[$optionname] == 'number' || @$optiontype[$optionname] == 'checkbox' ||
(@$optiontype[$optionname] == 'number-blank' && strlen($optionvalue))
)
$optionvalue = (int)$optionvalue;
......@@ -905,7 +903,6 @@ if ($recalchotness) {
);
} elseif ($startmailing) {
if (qa_post_text('has_js')) {
$qa_content['form']['ok'] = '<span id="mailing_ok">' . qa_html($mailingprogress) . '</span>';
......
......@@ -464,9 +464,7 @@ if (isset($editpage)) {
$qa_content['focusid'] = 'name';
} else {
// List of standard navigation links
$qa_content['form'] = array(
'tags' => 'method="post" action="' . qa_self_html() . '"',
......
......@@ -71,7 +71,6 @@ if (qa_clicked('doblock') || qa_clicked('dounblock') || qa_clicked('dohideall'))
$pageerror = qa_lang_html('misc/form_security_again');
elseif ($blockable) {
if (qa_clicked('doblock')) {
$oldblocked = qa_opt('block_ips_write');
qa_set_option('block_ips_write', (strlen($oldblocked) ? ($oldblocked . ' , ') : '') . $ip);
......
......@@ -429,7 +429,6 @@ function qa_page_q_question_view($question, $parentquestion, $closepost, $usersh
// Information about the question that this question is a duplicate of (if appropriate)
if (isset($closepost)) {
if ($closepost['basetype'] == 'Q') {
if ($closepost['hidden']) {
// don't show link for hidden questions
......
......@@ -455,18 +455,15 @@ if (isset($jumptoanchor))
// Determine whether this request should be counted for page view statistics.
// The lastviewip check is now in the hotness query in order to bypass caching.
if (
qa_opt('do_count_q_views') &&
(!$formrequested) &&
(!qa_is_http_post()) &&
qa_is_human_probably() &&
if (qa_opt('do_count_q_views') && !$formrequested && !qa_is_http_post() && qa_is_human_probably() &&
((!$question['views']) || ( // if it has more than zero views
((@inet_ntop($question['createip']) != qa_remote_ip_address()) || (!isset($question['createip']))) && // and different IP from the creator
(($question['userid'] != $userid) || (!isset($question['userid']))) && // and different user from the creator
(($question['cookieid'] != $cookieid) || (!isset($question['cookieid']))) // and different cookieid from the creator
))
)
(@inet_ntop($question['createip']) != qa_remote_ip_address() || !isset($question['createip'])) && // and different IP from the creator
($question['userid'] != $userid || !isset($question['userid'])) && // and different user from the creator
($question['cookieid'] != $cookieid || !isset($question['cookieid'])) // and different cookieid from the creator
))
) {
$qa_content['inc_views_postid'] = $questionid;
}
return $qa_content;
......@@ -33,9 +33,7 @@ require_once QA_INCLUDE_DIR . 'app/search.php';
// Perform the search if appropriate
if (strlen(qa_get('q'))) {
// Pull in input parameters
$inquery = trim(qa_get('q'));
$userid = qa_get_logged_in_userid();
$start = qa_get_start();
......
......@@ -406,7 +406,6 @@ if (!QA_FINAL_EXTERNAL_USERS) {
// Levels editing or viewing (add category-specific levels)
if ($userediting) {
if (isset($maxlevelassign)) {
$qa_content['form_profile']['fields']['level']['type'] = 'select';
......@@ -525,8 +524,7 @@ if (!QA_FINAL_EXTERNAL_USERS) {
foreach ($permitoptions as $permitoption) {
// 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) &&
if (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'])
) {
if ($permitoption == 'permit_retag_cat')
......@@ -647,8 +645,7 @@ if (!QA_FINAL_EXTERNAL_USERS) {
// Edit form or button, if appropriate
if ($userediting) {
if (
(qa_opt('avatar_allow_gravatar') && ($useraccount['flags'] & QA_USER_FLAGS_SHOW_GRAVATAR)) ||
if ((qa_opt('avatar_allow_gravatar') && ($useraccount['flags'] & QA_USER_FLAGS_SHOW_GRAVATAR)) ||
(qa_opt('avatar_allow_upload') && ($useraccount['flags'] & QA_USER_FLAGS_SHOW_AVATAR) && isset($useraccount['avatarblobid']))
) {
$qa_content['form_profile']['fields']['removeavatar'] = array(
......
......@@ -84,8 +84,7 @@ class qa_event_limits
'u_block', 'u_edit', 'u_level', 'u_message', 'u_password', 'u_save', 'u_unblock',
);
if (
is_numeric(array_search(strstr($event, '_'), $writeactions)) ||
if (is_numeric(array_search(strstr($event, '_'), $writeactions)) ||
is_numeric(array_search($event, $writeactions))
) {
if (isset($userid)) {
......
......@@ -303,9 +303,7 @@ $lines[] = '<link>' . qa_xml(qa_path($linkrequest, $linkparams, $siteurl)) . '</
$lines[] = '<description>Powered by Question2Answer</description>';
foreach ($questions as $question) {
// Determine whether this is a question, answer or comment, and act accordingly
$options = array('blockwordspreg' => @$blockwordspreg, 'showurllinks' => $showurllinks);
$time = null;
......
......@@ -42,9 +42,7 @@ elseif (isset($_GET['qa']) && $_GET['qa'] == 'blob') {
}
else {
// Otherwise, load the Q2A base file which sets up a bunch of crucial stuff
require 'qa-base.php';
/**
......
......@@ -173,9 +173,7 @@ class qa_event_logger
}
if (qa_opt('event_logger_to_files')) {
// Substitute some placeholders if certain information is missing
if (!strlen($userid))
$userid = 'no_userid';
......
......@@ -83,7 +83,6 @@ class qa_facebook_login
<div class="fb-login-button" style="display:inline; vertical-align:middle;" size="<?php echo $size?>" <?php echo $logout ? 'autologoutlink="true"' : 'scope="email,user_about_me,user_location,user_website"'?>>
</div>
<?php
}
......
......@@ -35,9 +35,7 @@ class qa_html_theme_layer extends qa_html_theme_base
}
if (!empty($postids)) {
// Retrieve the content for these questions from the database
$maxlength = qa_opt('mouseover_content_max_len');
$result = qa_db_query_sub('SELECT postid, content, format FROM ^posts WHERE postid IN (#)', $postids);
$postinfo = qa_db_read_all_assoc($result, 'postid');
......
......@@ -95,7 +95,6 @@ class qa_html_theme extends qa_html_theme_base
$this->output('<div class="qa-main-shadow">', '');
$this->output('<div class="qa-main-wrapper">', '');
$this->nav_main_sub();
}
// removes sidebar for user profile pages
......
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