Commit d7b2c7f0 by Scott

Coding style

parent 5b11d31a
......@@ -69,8 +69,9 @@ function qa_q_list_page_content($questions, $pagesize, $start, $count, $sometitl
// Chop down to size, get user information for display
if (isset($pagesize))
if (isset($pagesize)) {
$questions = array_slice($questions, 0, $pagesize);
}
$usershtml = qa_userids_handles_html(qa_any_get_userids_handles($questions));
......@@ -93,8 +94,9 @@ function qa_q_list_page_content($questions, $pagesize, $start, $count, $sometitl
$qa_content['title'] = $sometitle;
$defaults = qa_post_html_defaults('Q');
if (isset($categorypathprefix))
if (isset($categorypathprefix)) {
$defaults['categorypathprefix'] = $categorypathprefix;
}
foreach ($questions as $question) {
$fields = qa_any_to_q_html_fields($question, $userid, qa_cookie_get(), $usershtml, null, qa_post_html_options($question, $defaults));
......@@ -107,9 +109,9 @@ function qa_q_list_page_content($questions, $pagesize, $start, $count, $sometitl
$qa_content['q_list']['qs'][] = $fields;
}
} else
} else {
$qa_content['title'] = $nonetitle;
}
if (isset($userid) && isset($categoryid)) {
$favoritemap = qa_get_favorite_non_qs_map();
......@@ -119,20 +121,24 @@ function qa_q_list_page_content($questions, $pagesize, $start, $count, $sometitl
qa_lang_sub($categoryisfavorite ? 'main/remove_x_favorites' : 'main/add_category_x_favorites', $navcategories[$categoryid]['title']));
}
if (isset($count) && isset($pagesize))
if (isset($count) && isset($pagesize)) {
$qa_content['page_links'] = qa_html_page_links(qa_request(), $start, $pagesize, $count, qa_opt('pages_prev_next'), $pagelinkparams);
}
if (empty($qa_content['page_links']))
if (empty($qa_content['page_links'])) {
$qa_content['suggest_next'] = $suggest;
}
if (qa_using_categories() && count($navcategories) && isset($categorypathprefix))
if (qa_using_categories() && count($navcategories) && isset($categorypathprefix)) {
$qa_content['navigation']['cat'] = qa_category_navigation($navcategories, $categoryid, $categorypathprefix, $categoryqcount, $categoryparams);
}
if (isset($feedpathprefix) && (qa_opt('feed_per_category') || !isset($categoryid)))
if (isset($feedpathprefix) && (qa_opt('feed_per_category') || !isset($categoryid))) {
$qa_content['feed'] = array(
'url' => qa_path_html(qa_feed_request($feedpathprefix . (isset($categoryid) ? ('/' . qa_category_path_request($navcategories, $categoryid)) : ''))),
'label' => strip_tags($sometitle),
);
}
return $qa_content;
}
......@@ -181,13 +187,15 @@ function qa_qs_sub_navigation($sort, $categoryslugs)
),
);
if (isset($navigation[$sort]))
if (isset($navigation[$sort])) {
$navigation[$sort]['selected'] = true;
else
} else {
$navigation['recent']['selected'] = true;
}
if (!qa_opt('do_count_q_views'))
if (!qa_opt('do_count_q_views')) {
unset($navigation['views']);
}
return $navigation;
}
......@@ -226,13 +234,15 @@ function qa_unanswered_sub_navigation($by, $categoryslugs)
),
);
if (isset($navigation['by-' . $by]))
if (isset($navigation['by-' . $by])) {
$navigation['by-' . $by]['selected'] = true;
else
} else {
$navigation['by-answers']['selected'] = true;
}
if (!qa_opt('voting_on_as'))
if (!qa_opt('voting_on_as')) {
unset($navigation['by-upvotes']);
}
return $navigation;
}
......@@ -52,8 +52,9 @@ function qa_db_select_with_pending() // any number of parameters read via func_g
if (is_array($qa_db_pending_selectspecs)) {
foreach ($qa_db_pending_selectspecs as $pendingid => $selectspec) {
if (!isset($qa_db_pending_results[$pendingid]))
if (!isset($qa_db_pending_results[$pendingid])) {
$selectspecs['pending_' . $pendingid] = $selectspec;
}
}
}
......@@ -96,13 +97,15 @@ function qa_db_get_pending_result($pendingid, $selectspec = null)
{
global $qa_db_pending_selectspecs, $qa_db_pending_results;
if (isset($selectspec))
if (isset($selectspec)) {
qa_db_queue_pending_select($pendingid, $selectspec);
elseif (!isset($qa_db_pending_selectspecs[$pendingid]))
} elseif (!isset($qa_db_pending_selectspecs[$pendingid])) {
qa_fatal_error('Pending query was never set up: ' . $pendingid);
}
if (!isset($qa_db_pending_results[$pendingid]))
if (!isset($qa_db_pending_results[$pendingid])) {
qa_db_select_with_pending();
}
return $qa_db_pending_results[$pendingid];
}
......@@ -240,16 +243,18 @@ function qa_db_add_selectspec_opost(&$selectspec, $poststable, $fromupdated = fa
$selectspec['columns']['otime'] = 'UNIX_TIMESTAMP(' . $poststable . ($fromupdated ? '.updated' : '.created') . ')';
$selectspec['columns']['oflagcount'] = $poststable . '.flagcount';
if ($fromupdated)
if ($fromupdated) {
$selectspec['columns']['oupdatetype'] = $poststable . '.updatetype';
}
if ($full) {
$selectspec['columns']['ocontent'] = $poststable . '.content';
$selectspec['columns']['oformat'] = $poststable . '.format';
}
if ($fromupdated || $full)
if ($fromupdated || $full) {
$selectspec['columns']['oupdated'] = 'UNIX_TIMESTAMP(' . $poststable . '.updated)';
}
}
......@@ -285,8 +290,10 @@ function qa_db_add_selectspec_ousers(&$selectspec, $userstable, $pointstable)
*/
function qa_db_slugs_to_backpath($categoryslugs)
{
if (!is_array($categoryslugs)) // accept old-style string arguments for one category deep
if (!is_array($categoryslugs)) {
// accept old-style string arguments for one category deep
$categoryslugs = array($categoryslugs);
}
return implode('/', array_reverse($categoryslugs));
}
......@@ -300,8 +307,10 @@ function qa_db_slugs_to_backpath($categoryslugs)
*/
function qa_db_categoryslugs_sql_args($categoryslugs, &$arguments)
{
if (!is_array($categoryslugs)) // accept old-style string arguments for one category deep
if (!is_array($categoryslugs)) {
// accept old-style string arguments for one category deep
$categoryslugs = strlen($categoryslugs) ? array($categoryslugs) : array();
}
$levels = count($categoryslugs);
......@@ -331,10 +340,11 @@ function qa_db_categoryslugs_sql_args($categoryslugs, &$arguments)
*/
function qa_db_qs_selectspec($voteuserid, $sort, $start, $categoryslugs = null, $createip = null, $specialtype = false, $full = false, $count = null)
{
if ($specialtype == 'Q' || $specialtype == 'Q_QUEUED')
if ($specialtype == 'Q' || $specialtype == 'Q_QUEUED') {
$type = $specialtype;
else
} else {
$type = $specialtype ? 'Q_HIDDEN' : 'Q'; // for backwards compatibility
}
$count = isset($count) ? min($count, QA_DB_RETRIEVE_QS_AS) : QA_DB_RETRIEVE_QS_AS;
......@@ -358,13 +368,15 @@ function qa_db_qs_selectspec($voteuserid, $sort, $start, $categoryslugs = null,
$selectspec = qa_db_posts_basic_selectspec($voteuserid, $full);
$selectspec['source'] .= " JOIN (SELECT postid FROM ^posts WHERE " .
$selectspec['source'] .=
" JOIN (SELECT postid FROM ^posts WHERE " .
qa_db_categoryslugs_sql_args($categoryslugs, $selectspec['arguments']) .
(isset($createip) ? "createip=$ AND " : "") .
"type=$ " . $sortsql . " LIMIT #,#) y ON ^posts.postid=y.postid";
if (isset($createip))
if (isset($createip)) {
$selectspec['arguments'][] = @inet_pton($createip);
}
array_push($selectspec['arguments'], $type, $start, $count);
......@@ -391,10 +403,11 @@ function qa_db_qs_selectspec($voteuserid, $sort, $start, $categoryslugs = null,
*/
function qa_db_unanswered_qs_selectspec($voteuserid, $by, $start, $categoryslugs = null, $specialtype = false, $full = false, $count = null)
{
if ($specialtype == 'Q' || $specialtype == 'Q_QUEUED')
if ($specialtype == 'Q' || $specialtype == 'Q_QUEUED') {
$type = $specialtype;
else
} else {
$type = $specialtype ? 'Q_HIDDEN' : 'Q'; // for backwards compatibility
}
$count = isset($count) ? min($count, QA_DB_RETRIEVE_QS_AS) : QA_DB_RETRIEVE_QS_AS;
......@@ -441,10 +454,11 @@ function qa_db_unanswered_qs_selectspec($voteuserid, $by, $start, $categoryslugs
*/
function qa_db_recent_a_qs_selectspec($voteuserid, $start, $categoryslugs = null, $createip = null, $specialtype = false, $fullanswers = false, $count = null)
{
if ($specialtype == 'A' || $specialtype == 'A_QUEUED')
if ($specialtype == 'A' || $specialtype == 'A_QUEUED') {
$type = $specialtype;
else
} else {
$type = $specialtype ? 'A_HIDDEN' : 'A'; // for backwards compatibility
}
$count = isset($count) ? min($count, QA_DB_RETRIEVE_QS_AS) : QA_DB_RETRIEVE_QS_AS;
......@@ -453,7 +467,8 @@ function qa_db_recent_a_qs_selectspec($voteuserid, $start, $categoryslugs = null
qa_db_add_selectspec_opost($selectspec, 'aposts', false, $fullanswers);
qa_db_add_selectspec_ousers($selectspec, 'ausers', 'auserpoints');
$selectspec['source'] .= " JOIN ^posts AS aposts ON ^posts.postid=aposts.parentid" .
$selectspec['source'] .=
" JOIN ^posts AS aposts ON ^posts.postid=aposts.parentid" .
(QA_FINAL_EXTERNAL_USERS ? "" : " LEFT JOIN ^users AS ausers ON aposts.userid=ausers.userid") .
" LEFT JOIN ^userpoints AS auserpoints ON aposts.userid=auserpoints.userid" .
" JOIN (SELECT postid FROM ^posts WHERE " .
......@@ -462,8 +477,9 @@ function qa_db_recent_a_qs_selectspec($voteuserid, $start, $categoryslugs = null
"type=$ ORDER BY ^posts.created DESC LIMIT #,#) y ON aposts.postid=y.postid" .
($specialtype ? '' : " WHERE ^posts.type='Q'");
if (isset($createip))
if (isset($createip)) {
$selectspec['arguments'][] = @inet_pton($createip);
}
array_push($selectspec['arguments'], $type, $start, $count);
......@@ -490,10 +506,11 @@ function qa_db_recent_a_qs_selectspec($voteuserid, $start, $categoryslugs = null
*/
function qa_db_recent_c_qs_selectspec($voteuserid, $start, $categoryslugs = null, $createip = null, $specialtype = false, $fullcomments = false, $count = null)
{
if ($specialtype == 'C' || $specialtype == 'C_QUEUED')
if ($specialtype == 'C' || $specialtype == 'C_QUEUED') {
$type = $specialtype;
else
} else {
$type = $specialtype ? 'C_HIDDEN' : 'C'; // for backwards compatibility
}
$count = isset($count) ? min($count, QA_DB_RETRIEVE_QS_AS) : QA_DB_RETRIEVE_QS_AS;
......@@ -502,7 +519,8 @@ function qa_db_recent_c_qs_selectspec($voteuserid, $start, $categoryslugs = null
qa_db_add_selectspec_opost($selectspec, 'cposts', false, $fullcomments);
qa_db_add_selectspec_ousers($selectspec, 'cusers', 'cuserpoints');
$selectspec['source'] .= " JOIN ^posts AS parentposts ON" .
$selectspec['source'] .=
" JOIN ^posts AS parentposts ON" .
" ^posts.postid=(CASE LEFT(parentposts.type, 1) WHEN 'A' THEN parentposts.parentid ELSE parentposts.postid END)" .
" JOIN ^posts AS cposts ON parentposts.postid=cposts.parentid" .
(QA_FINAL_EXTERNAL_USERS ? "" : " LEFT JOIN ^users AS cusers ON cposts.userid=cusers.userid") .
......@@ -513,8 +531,9 @@ function qa_db_recent_c_qs_selectspec($voteuserid, $start, $categoryslugs = null
"type=$ ORDER BY ^posts.created DESC LIMIT #,#) y ON cposts.postid=y.postid" .
($specialtype ? '' : " WHERE ^posts.type='Q' AND ((parentposts.type='Q') OR (parentposts.type='A'))");
if (isset($createip))
if (isset($createip)) {
$selectspec['arguments'][] = @inet_pton($createip);
}
array_push($selectspec['arguments'], $type, $start, $count);
......@@ -548,7 +567,8 @@ function qa_db_recent_edit_qs_selectspec($voteuserid, $start, $categoryslugs = n
qa_db_add_selectspec_opost($selectspec, 'editposts', true, $fulledited);
qa_db_add_selectspec_ousers($selectspec, 'editusers', 'edituserpoints');
$selectspec['source'] .= " JOIN ^posts AS parentposts ON" .
$selectspec['source'] .=
" JOIN ^posts AS parentposts ON" .
" ^posts.postid=IF(LEFT(parentposts.type, 1)='Q', parentposts.postid, parentposts.parentid)" .
" JOIN ^posts AS editposts ON parentposts.postid=IF(LEFT(editposts.type, 1)='Q', editposts.postid, editposts.parentid)" .
(QA_FINAL_EXTERNAL_USERS ? "" : " LEFT JOIN ^users AS editusers ON editposts.lastuserid=editusers.userid") .
......@@ -560,8 +580,9 @@ function qa_db_recent_edit_qs_selectspec($voteuserid, $start, $categoryslugs = n
" ORDER BY ^posts.updated DESC LIMIT #,#) y ON editposts.postid=y.postid" .
($onlyvisible ? " WHERE parentposts.type IN ('Q', 'A', 'C') AND ^posts.type IN ('Q', 'A', 'C')" : "");
if (isset($lastip))
if (isset($lastip)) {
$selectspec['arguments'][] = @inet_pton($lastip);
}
array_push($selectspec['arguments'], $start, $count);
......@@ -591,7 +612,8 @@ function qa_db_flagged_post_qs_selectspec($voteuserid, $start, $fullflagged = fa
qa_db_add_selectspec_opost($selectspec, 'flagposts', false, $fullflagged);
qa_db_add_selectspec_ousers($selectspec, 'flagusers', 'flaguserpoints');
$selectspec['source'] .= " JOIN ^posts AS parentposts ON" .
$selectspec['source'] .=
" JOIN ^posts AS parentposts ON" .
" ^posts.postid=IF(LEFT(parentposts.type, 1)='Q', parentposts.postid, parentposts.parentid)" .
" JOIN ^posts AS flagposts ON parentposts.postid=IF(LEFT(flagposts.type, 1)='Q', flagposts.postid, flagposts.parentid)" .
(QA_FINAL_EXTERNAL_USERS ? "" : " LEFT JOIN ^users AS flagusers ON flagposts.userid=flagusers.userid") .
......@@ -657,7 +679,8 @@ function qa_db_posts_to_qs_selectspec($voteuserid, $postids, $full = false)
$selectspec['columns']['obasetype'] = 'LEFT(childposts.type, 1)';
$selectspec['columns']['opostid'] = 'childposts.postid';
$selectspec['source'] .= " JOIN ^posts AS parentposts ON" .
$selectspec['source'] .=
" JOIN ^posts AS parentposts ON" .
" ^posts.postid=IF(LEFT(parentposts.type, 1)='Q', parentposts.postid, parentposts.parentid)" .
" JOIN ^posts AS childposts ON parentposts.postid=IF(LEFT(childposts.type, 1)='Q', childposts.postid, childposts.parentid)" .
" WHERE childposts.postid IN (#)";
......@@ -789,10 +812,11 @@ function qa_db_post_meta_selectspec($postid, $title)
'arrayvalue' => 'content',
);
if (is_array($title))
if (is_array($title)) {
$selectspec['arraykey'] = 'title';
else
} else {
$selectspec['single'] = true;
}
return $selectspec;
}
......@@ -946,8 +970,9 @@ function qa_db_search_posts_selectspec($voteuserid, $titlewords, $contentwords,
}
}
if ($selectparts == 0)
if ($selectparts == 0) {
$selectspec['source'] .= '(SELECT NULL as questionid, 0 AS score, NULL AS matchposttype, NULL AS matchpostid FROM ^posts WHERE postid IS NULL)';
}
$selectspec['source'] .= ") x LEFT JOIN ^posts ON ^posts.postid=questionid GROUP BY questionid ORDER BY score DESC LIMIT #,#) y ON ^posts.postid=y.questionid";
......@@ -995,9 +1020,9 @@ function qa_search_set_max_match($question, &$type, &$postid)
*/
function qa_db_full_category_selectspec($slugsorid, $isid)
{
if ($isid)
if ($isid) {
$identifiersql = 'categoryid=#';
else {
} else {
$identifiersql = 'backpath=$';
$slugsorid = qa_db_slugs_to_backpath($slugsorid);
}
......@@ -1026,11 +1051,11 @@ function qa_db_full_category_selectspec($slugsorid, $isid)
function qa_db_category_nav_selectspec($slugsorid, $isid, $ispostid = false, $full = false)
{
if ($isid) {
if ($ispostid)
if ($ispostid) {
$identifiersql = 'categoryid=(SELECT categoryid FROM ^posts WHERE postid=#)';
else
} else {
$identifiersql = 'categoryid=#';
}
} else {
$identifiersql = 'backpath=$';
$slugsorid = qa_db_slugs_to_backpath($slugsorid);
......@@ -1115,13 +1140,12 @@ function qa_db_pages_selectspec($onlynavin = null, $onlypageids = null)
if (isset($onlypageids)) {
$selectspec['source'] = '^pages WHERE pageid IN (#)';
$selectspec['arguments'] = array($onlypageids);
} elseif (isset($onlynavin)) {
$selectspec['source'] = '^pages WHERE nav IN ($) ORDER BY position';
$selectspec['arguments'] = array($onlynavin);
} else
} else {
$selectspec['source'] = '^pages ORDER BY position';
}
return $selectspec;
}
......@@ -1249,7 +1273,8 @@ function qa_db_user_recent_a_qs_selectspec($voteuserid, $identifier, $count = nu
$selectspec['columns']['odownvotes'] = 'aposts.downvotes';
$selectspec['columns']['onetvotes'] = 'aposts.netvotes';
$selectspec['source'] .= " JOIN ^posts AS aposts ON ^posts.postid=aposts.parentid" .
$selectspec['source'] .=
" JOIN ^posts AS aposts ON ^posts.postid=aposts.parentid" .
" JOIN (SELECT postid FROM ^posts WHERE " .
" userid=" . (QA_FINAL_EXTERNAL_USERS ? "$" : "(SELECT userid FROM ^users WHERE handle=$ LIMIT 1)") .
" AND type='A' ORDER BY created DESC LIMIT #,#) y ON aposts.postid=y.postid WHERE ^posts.type='Q'";
......@@ -1279,7 +1304,8 @@ function qa_db_user_recent_c_qs_selectspec($voteuserid, $identifier, $count = nu
qa_db_add_selectspec_opost($selectspec, 'cposts');
$selectspec['source'] .= " JOIN ^posts AS parentposts ON" .
$selectspec['source'] .=
" JOIN ^posts AS parentposts ON" .
" ^posts.postid=(CASE parentposts.type WHEN 'A' THEN parentposts.parentid ELSE parentposts.postid END)" .
" JOIN ^posts AS cposts ON parentposts.postid=cposts.parentid" .
" JOIN (SELECT postid FROM ^posts WHERE " .
......@@ -1311,7 +1337,8 @@ function qa_db_user_recent_edit_qs_selectspec($voteuserid, $identifier, $count =
qa_db_add_selectspec_opost($selectspec, 'editposts', true);
$selectspec['source'] .= " JOIN ^posts AS parentposts ON" .
$selectspec['source'] .=
" JOIN ^posts AS parentposts ON" .
" ^posts.postid=IF(LEFT(parentposts.type, 1)='Q', parentposts.postid, parentposts.parentid)" .
" JOIN ^posts AS editposts ON parentposts.postid=IF(LEFT(editposts.type, 1)='Q', editposts.postid, editposts.parentid)" .
" JOIN (SELECT postid FROM ^posts WHERE " .
......@@ -1470,7 +1497,7 @@ function qa_db_top_users_selectspec($start, $count = null)
{
$count = isset($count) ? min($count, QA_DB_RETRIEVE_USERS) : QA_DB_RETRIEVE_USERS;
if (QA_FINAL_EXTERNAL_USERS)
if (QA_FINAL_EXTERNAL_USERS) {
return array(
'columns' => array('userid', 'points'),
'source' => '^userpoints ORDER BY points DESC LIMIT #,#',
......@@ -1478,15 +1505,15 @@ function qa_db_top_users_selectspec($start, $count = null)
'arraykey' => 'userid',
'sortdesc' => 'points',
);
}
else
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',
'arguments' => array($start, $count),
'arraykey' => 'userid',
'sortdesc' => 'points',
);
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',
'arguments' => array($start, $count),
'arraykey' => 'userid',
'sortdesc' => 'points',
);
}
......@@ -1595,8 +1622,9 @@ function qa_db_recent_messages_selectspec($fromidentifier, $fromisuserid, $toide
if (isset($fromidentifier)) {
$fromsub = $fromisuserid ? '$' : '(SELECT userid FROM ^users WHERE handle=$ LIMIT 1)';
$where = 'fromuserid=' . $fromsub . " AND type='PRIVATE'";
} else
} else {
$where = "type='PUBLIC'";
}
$tosub = $toisuserid ? '$' : '(SELECT userid FROM ^users WHERE handle=$ LIMIT 1)';
$source = '^messages LEFT JOIN ^users ufrom ON fromuserid=ufrom.userid LEFT JOIN ^users uto ON touserid=uto.userid WHERE ' . $where . ' AND touserid=' . $tosub . ' ORDER BY ^messages.created DESC LIMIT #,#';
......
......@@ -42,8 +42,9 @@ list($categories, $categoryid, $favoritecats) = qa_db_select_with_pending(
isset($userid) ? qa_db_user_favorite_categories_selectspec($userid) : null
);
if ($countslugs && !isset($categoryid))
if ($countslugs && !isset($categoryid)) {
return include QA_INCLUDE_DIR . 'qa-page-not-found.php';
}
// Function for recursive display of categories
......@@ -53,16 +54,17 @@ function qa_category_nav_to_browse(&$navigation, $categories, $categoryid, $favo
foreach ($navigation as $key => $navlink) {
$category = $categories[$navlink['categoryid']];
if (!$category['childcount'])
if (!$category['childcount']) {
unset($navigation[$key]['url']);
elseif ($navlink['selected']) {
} elseif ($navlink['selected']) {
$navigation[$key]['state'] = 'open';
$navigation[$key]['url'] = qa_path_html('categories/' . qa_category_path_request($categories, $category['parentid']));
} else
$navigation[$key]['state'] = 'closed';
if (@$favoritemap[$navlink['categoryid']])
if (@$favoritemap[$navlink['categoryid']]) {
$navigation[$key]['favorited'] = true;
}
$navigation[$key]['note'] =
' - <a href="'.qa_path_html('questions/'.implode('/', array_reverse(explode('/', $category['backpath'])))).'">'.( ($category['qcount']==1)
......@@ -91,9 +93,11 @@ if (count($categories)) {
unset($navigation['all']);
$favoritemap = array();
if (isset($favoritecats))
foreach ($favoritecats as $category)
if (isset($favoritecats)) {
foreach ($favoritecats as $category) {
$favoritemap[$category['categoryid']] = true;
}
}
qa_category_nav_to_browse($navigation, $categories, $categoryid, $favoritemap);
......
......@@ -34,12 +34,13 @@ require_once QA_INCLUDE_DIR . 'app/format.php';
$requestparts = explode('/', qa_request());
$explicitqa = (strtolower($requestparts[0]) == 'qa');
if ($explicitqa)
if ($explicitqa) {
$slugs = array_slice($requestparts, 1);
elseif (strlen($requestparts[0]))
} elseif (strlen($requestparts[0])) {
$slugs = $requestparts;
else
} else {
$slugs = array();
}
$countslugs = count($slugs);
......@@ -53,7 +54,7 @@ list($questions1, $questions2, $categories, $categoryid, $custompage) = qa_db_se
qa_db_recent_a_qs_selectspec($userid, 0, $slugs),
qa_db_category_nav_selectspec($slugs, false, false, true),
$countslugs ? qa_db_slugs_to_category_id_selectspec($slugs) : null,
(($countslugs == 1) && !$explicitqa) ? qa_db_page_full_selectspec($slugs[0], false) : null
($countslugs == 1 && !$explicitqa) ? qa_db_page_full_selectspec($slugs[0], false) : null
);
......@@ -79,8 +80,9 @@ if (isset($custompage) && !($custompage['flags'] & QA_PAGE_FLAGS_EXTERNAL)) {
);
}
} else
} else {
$qa_content['error'] = qa_lang_html('users/no_permission');
}
return $qa_content;
}
......@@ -88,8 +90,9 @@ if (isset($custompage) && !($custompage['flags'] & QA_PAGE_FLAGS_EXTERNAL)) {
// Then, see if we should redirect because the 'qa' page is the same as the home page
if ($explicitqa && (!qa_is_http_post()) && !qa_has_custom_home())
if ($explicitqa && !qa_is_http_post() && !qa_has_custom_home()) {
qa_redirect(qa_category_path_request($categories, $categoryid), $_GET);
}
// Then, if there's a slug that matches no category, check page modules provided by plugins
......@@ -128,8 +131,9 @@ $questions = qa_any_sort_and_dedupe(array_merge($questions1, $questions2));
$pagesize = qa_opt('page_size_home');
if ($countslugs) {
if (!isset($categoryid))
if (!isset($categoryid)) {
return include QA_INCLUDE_DIR . 'qa-page-not-found.php';
}
$categorytitlehtml = qa_html($categories[$categoryid]['title']);
$sometitle = qa_lang_html_sub('main/recent_qs_as_in_x', $categorytitlehtml);
......
......@@ -68,8 +68,9 @@ list($questions, $categories, $categoryid) = qa_db_select_with_pending(
);
if ($countslugs) {
if (!isset($categoryid))
if (!isset($categoryid)) {
return include QA_INCLUDE_DIR . 'qa-page-not-found.php';
}
$categorytitlehtml = qa_html($categories[$categoryid]['title']);
$nonetitle = qa_lang_html_sub('main/no_questions_in_x', $categorytitlehtml);
......
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