Commit 8c7ee30b by Scott

Switch bool castings for expressions

parent 5c2fc047
...@@ -149,7 +149,7 @@ ...@@ -149,7 +149,7 @@
$favoritenonqs=qa_db_get_pending_result('favoritenonqs', qa_db_user_favorite_non_qs_selectspec($loginuserid)); $favoritenonqs=qa_db_get_pending_result('favoritenonqs', qa_db_user_favorite_non_qs_selectspec($loginuserid));
foreach ($favoritenonqs as $favorite) foreach ($favoritenonqs as $favorite) {
switch ($favorite['type']) { switch ($favorite['type']) {
case QA_ENTITY_USER: case QA_ENTITY_USER:
$qa_favorite_non_qs_map['user'][$favorite['userid']]=true; $qa_favorite_non_qs_map['user'][$favorite['userid']]=true;
...@@ -163,6 +163,7 @@ ...@@ -163,6 +163,7 @@
$qa_favorite_non_qs_map['category'][$favorite['categorybackpath']]=true; $qa_favorite_non_qs_map['category'][$favorite['categorybackpath']]=true;
break; break;
} }
}
} }
} }
...@@ -1455,7 +1456,7 @@ ...@@ -1455,7 +1456,7 @@
*/ */
{ {
$pathcategories = qa_category_path($navcategories, $categoryid); $pathcategories = qa_category_path($navcategories, $categoryid);
$startpath = ''; $startpath = '';
foreach ($pathcategories as $category) foreach ($pathcategories as $category)
$startpath .= '/' . $category['categoryid']; $startpath .= '/' . $category['categoryid'];
...@@ -1467,14 +1468,14 @@ ...@@ -1467,14 +1468,14 @@
$qa_content['script_rel'][] = 'qa-content/qa-ask.js?' . QA_VERSION; $qa_content['script_rel'][] = 'qa-content/qa-ask.js?' . QA_VERSION;
$qa_content['script_onloads'][] = sprintf('qa_category_select(%s, %s);', qa_js($fieldname), qa_js($startpath)); $qa_content['script_onloads'][] = sprintf('qa_category_select(%s, %s);', qa_js($fieldname), qa_js($startpath));
$qa_content['script_var'] = array( $qa_content['script_var'] = array(
'qa_cat_exclude' => $excludecategoryid, 'qa_cat_exclude' => $excludecategoryid,
'qa_cat_allownone' => (int) $allownone, 'qa_cat_allownone' => (int) $allownone,
'qa_cat_allownosub' => (int) $allownosub, 'qa_cat_allownosub' => (int) $allownosub,
'qa_cat_maxdepth' => $maxdepth, 'qa_cat_maxdepth' => $maxdepth,
); );
$field['type'] = 'select'; $field['type'] = 'select';
$field['tags'] = sprintf('name="%s_0" id="%s_0" onchange="qa_category_select(%s);"', $fieldname, $fieldname, qa_js($fieldname)); $field['tags'] = sprintf('name="%s_0" id="%s_0" onchange="qa_category_select(%s);"', $fieldname, $fieldname, qa_js($fieldname));
$field['options'] = array(); $field['options'] = array();
...@@ -1496,7 +1497,7 @@ ...@@ -1496,7 +1497,7 @@
} }
$keycategoryids = array_reverse($keycategoryids, true); $keycategoryids = array_reverse($keycategoryids, true);
$depth = count($keycategoryids); // number of levels above $depth = count($keycategoryids); // number of levels above
if (isset($category)) { if (isset($category)) {
...@@ -1506,7 +1507,7 @@ ...@@ -1506,7 +1507,7 @@
if (!strcmp($navcategory['parentid'], $category['parentid'])) if (!strcmp($navcategory['parentid'], $category['parentid']))
$keycategoryids[$navcategory['categoryid']] = true; $keycategoryids[$navcategory['categoryid']] = true;
} }
if ($depth < $maxdepth) if ($depth < $maxdepth)
foreach ($navcategories as $navcategory) // now get children, if not too deep foreach ($navcategories as $navcategory) // now get children, if not too deep
if (!strcmp($navcategory['parentid'], $categoryid)) if (!strcmp($navcategory['parentid'], $categoryid))
...@@ -1528,7 +1529,7 @@ ...@@ -1528,7 +1529,7 @@
foreach ($keycategoryids as $keycategoryid => $dummy) foreach ($keycategoryids as $keycategoryid => $dummy)
if (strcmp($keycategoryid, $excludecategoryid)) if (strcmp($keycategoryid, $excludecategoryid))
$field['options'][$keycategoryid] = qa_category_path_html($navcategories, $keycategoryid); $field['options'][$keycategoryid] = qa_category_path_html($navcategories, $keycategoryid);
$field['value'] = @$field['options'][$categoryid]; $field['value'] = @$field['options'][$categoryid];
$field['note'] = $field['note'] =
'<div id="' . $fieldname . '_note">' . '<div id="' . $fieldname . '_note">' .
......
...@@ -390,19 +390,19 @@ ...@@ -390,19 +390,19 @@
break; break;
case 'show_custom_sidebar': case 'show_custom_sidebar':
$value = (bool) strlen(qa_opt('custom_sidebar')); $value = strlen(qa_opt('custom_sidebar')) > 0;
break; break;
case 'show_custom_header': case 'show_custom_header':
$value = (bool) strlen(qa_opt('custom_header')); $value = strlen(qa_opt('custom_header')) > 0;
break; break;
case 'show_custom_footer': case 'show_custom_footer':
$value = (bool) strlen(qa_opt('custom_footer')); $value = strlen(qa_opt('custom_footer')) > 0;
break; break;
case 'show_custom_in_head': case 'show_custom_in_head':
$value = (bool) strlen(qa_opt('custom_in_head')); $value = strlen(qa_opt('custom_in_head')) > 0;
break; break;
case 'custom_sidebar': case 'custom_sidebar':
......
...@@ -54,11 +54,11 @@ ...@@ -54,11 +54,11 @@
{ {
qa_post_unindex($oldquestion['postid']); qa_post_unindex($oldquestion['postid']);
$wasqueued=($oldquestion['type']=='Q_QUEUED'); $wasqueued = ($oldquestion['type'] == 'Q_QUEUED');
$titlechanged = (bool) strcmp($oldquestion['title'], $title); $titlechanged = strcmp($oldquestion['title'], $title) !== 0;
$contentchanged=strcmp($oldquestion['content'], $content) || strcmp($oldquestion['format'], $format); $contentchanged = strcmp($oldquestion['content'], $content) !== 0 || strcmp($oldquestion['format'], $format) !== 0;
$tagschanged = (bool) strcmp($oldquestion['tags'], $tagstring); $tagschanged = strcmp($oldquestion['tags'], $tagstring) !== 0;
$setupdated=($titlechanged || $contentchanged || $tagschanged) && (!$wasqueued) && !$silent; $setupdated = ($titlechanged || $contentchanged || $tagschanged) && (!$wasqueued) && !$silent;
qa_db_post_set_content($oldquestion['postid'], $title, $content, $format, $tagstring, $notify, qa_db_post_set_content($oldquestion['postid'], $title, $content, $format, $tagstring, $notify,
$setupdated ? $userid : null, $setupdated ? qa_remote_ip_address() : null, $setupdated ? $userid : null, $setupdated ? qa_remote_ip_address() : null,
...@@ -72,18 +72,19 @@ ...@@ -72,18 +72,19 @@
if ($setupdated && $remoderate) { if ($setupdated && $remoderate) {
require_once QA_INCLUDE_DIR.'qa-app-posts.php'; require_once QA_INCLUDE_DIR.'qa-app-posts.php';
$answers=qa_post_get_question_answers($oldquestion['postid']); $answers = qa_post_get_question_answers($oldquestion['postid']);
$commentsfollows=qa_post_get_question_commentsfollows($oldquestion['postid']); $commentsfollows = qa_post_get_question_commentsfollows($oldquestion['postid']);
$closepost=qa_post_get_question_closepost($oldquestion['postid']); $closepost = qa_post_get_question_closepost($oldquestion['postid']);
foreach ($answers as $answer) foreach ($answers as $answer)
qa_post_unindex($answer['postid']); qa_post_unindex($answer['postid']);
foreach ($commentsfollows as $comment) foreach ($commentsfollows as $comment) {
if ($comment['basetype']=='C') if ($comment['basetype'] == 'C')
qa_post_unindex($comment['postid']); qa_post_unindex($comment['postid']);
}
if (@$closepost['parentid']==$oldquestion['postid']) if (@$closepost['parentid'] == $oldquestion['postid'])
qa_post_unindex($closepost['postid']); qa_post_unindex($closepost['postid']);
qa_db_post_set_type($oldquestion['postid'], 'Q_QUEUED'); qa_db_post_set_type($oldquestion['postid'], 'Q_QUEUED');
...@@ -94,7 +95,8 @@ ...@@ -94,7 +95,8 @@
if ($oldquestion['flagcount']) if ($oldquestion['flagcount'])
qa_db_flaggedcount_update(); qa_db_flaggedcount_update();
} elseif ($oldquestion['type']=='Q') { // not hidden or queued }
else if ($oldquestion['type'] == 'Q') { // not hidden or queued
qa_post_index($oldquestion['postid'], 'Q', $oldquestion['postid'], $oldquestion['parentid'], $title, $content, $format, $text, $tagstring, $oldquestion['categoryid']); qa_post_index($oldquestion['postid'], 'Q', $oldquestion['postid'], $oldquestion['parentid'], $title, $content, $format, $text, $tagstring, $oldquestion['categoryid']);
} }
......
...@@ -93,7 +93,7 @@ ...@@ -93,7 +93,7 @@
if (isset($userid) && isset($categoryid)) { if (isset($userid) && isset($categoryid)) {
$favoritemap=qa_get_favorite_non_qs_map(); $favoritemap=qa_get_favorite_non_qs_map();
$categoryisfavorite = (bool) @$favoritemap['category'][$navcategories[$categoryid]['backpath']]; $categoryisfavorite = @$favoritemap['category'][$navcategories[$categoryid]['backpath']];
$qa_content['favorite']=qa_favorite_form(QA_ENTITY_CATEGORY, $categoryid, $categoryisfavorite, $qa_content['favorite']=qa_favorite_form(QA_ENTITY_CATEGORY, $categoryid, $categoryisfavorite,
qa_lang_sub($categoryisfavorite ? 'main/remove_x_favorites' : 'main/add_category_x_favorites', $navcategories[$categoryid]['title'])); qa_lang_sub($categoryisfavorite ? 'main/remove_x_favorites' : 'main/add_category_x_favorites', $navcategories[$categoryid]['title']));
......
...@@ -60,7 +60,7 @@ ...@@ -60,7 +60,7 @@
$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) ? true : false; $isconfirmed=($useraccount['flags'] & QA_USER_FLAGS_EMAIL_CONFIRMED) ? true : false;
$haspassword=isset($useraccount['passsalt']) && isset($useraccount['passcheck']); $haspassword=isset($useraccount['passsalt']) && isset($useraccount['passcheck']);
$isblocked = (bool) qa_user_permit_error(); $isblocked = qa_user_permit_error() !== false;
// Process profile if saved // Process profile if saved
......
...@@ -110,9 +110,9 @@ ...@@ -110,9 +110,9 @@
$userlevel=qa_user_level_for_categories($categoryids); $userlevel=qa_user_level_for_categories($categoryids);
$in['name']=qa_post_text('name'); $in['name']=qa_post_text('name');
$in['notify'] = (bool) qa_post_text('notify'); $in['notify'] = strlen(qa_post_text('notify')) > 0;
$in['email']=qa_post_text('email'); $in['email']=qa_post_text('email');
$in['queued'] = (bool) qa_user_moderation_reason($userlevel); $in['queued'] = qa_user_moderation_reason($userlevel) !== false;
qa_get_post_content('editor', 'content', $in['editor'], $in['content'], $in['format'], $in['text']); qa_get_post_content('editor', 'content', $in['editor'], $in['content'], $in['format'], $in['text']);
......
...@@ -75,7 +75,7 @@ ...@@ -75,7 +75,7 @@
if (strtolower(qa_db_calc_passcheck($inpassword, $userinfo['passsalt'])) == strtolower($userinfo['passcheck'])) { // login and redirect if (strtolower(qa_db_calc_passcheck($inpassword, $userinfo['passsalt'])) == strtolower($userinfo['passcheck'])) { // login and redirect
require_once QA_INCLUDE_DIR.'qa-app-users.php'; require_once QA_INCLUDE_DIR.'qa-app-users.php';
qa_set_logged_in_user($inuserid, $userinfo['handle'], (bool) $inremember); qa_set_logged_in_user($inuserid, $userinfo['handle'], !empty($inremember));
$topath=qa_get('to'); $topath=qa_get('to');
...@@ -143,7 +143,7 @@ ...@@ -143,7 +143,7 @@
'type' => 'checkbox', 'type' => 'checkbox',
'label' => qa_lang_html('users/remember_label'), 'label' => qa_lang_html('users/remember_label'),
'tags' => 'name="remember"', 'tags' => 'name="remember"',
'value' => (bool) @$inremember, 'value' => !empty(@$inremember),
), ),
), ),
......
...@@ -450,7 +450,7 @@ ...@@ -450,7 +450,7 @@
if ($question['isbyuser']) { if ($question['isbyuser']) {
$in['name']=qa_post_text('q_name'); $in['name']=qa_post_text('q_name');
$in['notify'] = (bool) qa_post_text('q_notify'); $in['notify'] = !empty(qa_post_text('q_notify'));
$in['email']=qa_post_text('q_email'); $in['email']=qa_post_text('q_email');
} }
...@@ -781,7 +781,7 @@ ...@@ -781,7 +781,7 @@
if ($answer['isbyuser']) { if ($answer['isbyuser']) {
$in['name']=qa_post_text($prefix.'name'); $in['name']=qa_post_text($prefix.'name');
$in['notify'] = (bool) qa_post_text($prefix.'notify'); $in['notify'] = !empty(qa_post_text($prefix.'notify'));
$in['email']=qa_post_text($prefix.'email'); $in['email']=qa_post_text($prefix.'email');
} }
...@@ -982,7 +982,7 @@ ...@@ -982,7 +982,7 @@
if ($comment['isbyuser']) { if ($comment['isbyuser']) {
$in['name']=qa_post_text($prefix.'name'); $in['name']=qa_post_text($prefix.'name');
$in['notify'] = (bool) qa_post_text($prefix.'notify'); $in['notify'] = !empty(qa_post_text($prefix.'notify'));
$in['email']=qa_post_text($prefix.'email'); $in['email']=qa_post_text($prefix.'email');
} }
......
...@@ -324,9 +324,9 @@ ...@@ -324,9 +324,9 @@
{ {
$in=array( $in=array(
'name' => qa_post_text('a_name'), 'name' => qa_post_text('a_name'),
'notify' => (bool) qa_post_text('a_notify'), 'notify' => !empty(qa_post_text('a_notify')),
'email' => qa_post_text('a_email'), 'email' => qa_post_text('a_email'),
'queued' => (bool) qa_user_moderation_reason(qa_user_level_for_post($question)), 'queued' => qa_user_moderation_reason(qa_user_level_for_post($question)) !== false,
); );
qa_get_post_content('a_editor', 'a_content', $in['editor'], $in['content'], $in['format'], $in['text']); qa_get_post_content('a_editor', 'a_content', $in['editor'], $in['content'], $in['format'], $in['text']);
...@@ -386,9 +386,9 @@ ...@@ -386,9 +386,9 @@
$in=array( $in=array(
'name' => qa_post_text($prefix.'name'), 'name' => qa_post_text($prefix.'name'),
'notify' => (bool) qa_post_text($prefix.'notify'), 'notify' => !empty(qa_post_text($prefix.'notify')),
'email' => qa_post_text($prefix.'email'), 'email' => qa_post_text($prefix.'email'),
'queued' => (bool) qa_user_moderation_reason(qa_user_level_for_post($parent)), 'queued' => qa_user_moderation_reason(qa_user_level_for_post($parent)) !== false,
); );
qa_get_post_content($prefix.'editor', $prefix.'content', $in['editor'], $in['content'], $in['format'], $in['text']); qa_get_post_content($prefix.'editor', $prefix.'content', $in['editor'], $in['content'], $in['format'], $in['text']);
...@@ -445,7 +445,7 @@ ...@@ -445,7 +445,7 @@
'text' => qa_viewer_text($post['content'], $post['format']), 'text' => qa_viewer_text($post['content'], $post['format']),
'notify' => isset($post['notify']), 'notify' => isset($post['notify']),
'email' => qa_email_validate($post['notify']) ? $post['notify'] : null, 'email' => qa_email_validate($post['notify']) ? $post['notify'] : null,
'queued' => (bool) qa_user_moderation_reason(qa_user_level_for_post($post)), 'queued' => qa_user_moderation_reason(qa_user_level_for_post($post)) !== false,
); );
if ($post['basetype']=='Q') { if ($post['basetype']=='Q') {
......
...@@ -435,7 +435,7 @@ ...@@ -435,7 +435,7 @@
// Category-specific levels // Category-specific levels
if (qa_using_categories()) { if (qa_using_categories()) {
$catleveladd = (bool) qa_get('catleveladd'); $catleveladd = strlen(qa_get('catleveladd')) > 0;
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(
...@@ -545,10 +545,10 @@ ...@@ -545,10 +545,10 @@
// 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 = (bool) ($useraccount['flags'] & QA_USER_FLAGS_EMAIL_CONFIRMED); $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']);
$qa_content['form_profile']['fields']['email']=array( $qa_content['form_profile']['fields']['email']=array(
'type' => $userediting ? 'text' : 'static', 'type' => $userediting ? 'text' : 'static',
......
...@@ -646,7 +646,7 @@ ...@@ -646,7 +646,7 @@
{ {
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); }
return (bool) preg_match("/^[\-\!\#\$\%\&\'\*\+\/\=\?\_\`\{\|\}\~a-zA-Z0-9\.\^]+\@[a-zA-Z0-9\-]+\.[a-zA-Z0-9\.\-]+$/", $email); return preg_match("/^[\-\!\#\$\%\&\'\*\+\/\=\?\_\`\{\|\}\~a-zA-Z0-9\.\^]+\@[a-zA-Z0-9\-]+\.[a-zA-Z0-9\.\-]+$/", $email) === 1;
} }
......
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