function output_widget($region, $place, $themeobject, $template, $request, $qa_content) { /* $requestparts=qa_request_parts(); $requestlower=strtolower(qa_request()); $firstlower=strtolower($requestparts[0]); $routing=qa_page_routing(); // unanswered & questions pages may contain categories. unset($routing['activity/']); unset($routing['unanswered/']); unset($routing['questions/']); if ( (isset($routing[$requestlower])) or (isset($routing[$firstlower.'/'])) or (is_numeric($requestparts[0])) ) return; $explicitqa=(strtolower($requestparts[0])=='qa' or strtolower($requestparts[0])=='unanswered' or strtolower($requestparts[0])=='questions' or strtolower($requestparts[0])=='activity'); if ($explicitqa) $slugs=array_slice($requestparts, 1); elseif (strlen($requestparts[0])) $slugs=$requestparts; else $slugs=array(); */ $slugs = useo_get_current_category_slug(); $countslugs = count($slugs); list($categories, $categoryid) = qa_db_select_with_pending(qa_db_category_nav_selectspec($slugs, false, false, true), $countslugs ? qa_db_slugs_to_category_id_selectspec($slugs) : null); if ($countslugs && isset($categoryid)) { /* $categoryid is current categories ID $backpath = implode('/', array_reverse($slugs)); echo "countslugs: <pre>"; var_dump($countslugs); echo "</pre>"; $fullcategory=qa_db_select_with_pending(qa_db_full_category_selectspec($categoryid, true)); echo "fullcategory: <pre>"; var_dump($fullcategory); echo "</pre>"; echo "categoryid: <pre>"; var_dump($categoryid); echo "</pre>"; echo "slugs: <pre>"; var_dump($slugs); echo "</pre>"; echo "template: <pre>"; var_dump($template); echo "</pre>"; echo "request: <pre>"; var_dump($request); echo "</pre>"; */ require_once QA_INCLUDE_DIR . 'qa-db-metas.php'; $description = qa_db_categorymeta_get($categoryid, 'useo_cat_description'); if (!qa_opt('useo_cat_desc_format')) { $description = qa_html($description); } $editurlhtml = qa_path_html('category-edit/' . $categoryid); $allowediting = !qa_user_permit_error('useo_cat_desc_permit_edit'); if (strlen($description)) { echo '<SPAN CLASS="entry-content qa-category-description">'; echo $description; echo '</SPAN>'; if ($allowediting) { echo ' - <A HREF="' . $editurlhtml . '">edit</A>'; } } elseif ($allowediting) { echo '<A HREF="' . $editurlhtml . '">' . qa_lang_html('useo/create_desc_link') . '</A>'; } } }
function qa_create_event_for_category($categoryid, $questionid, $updatetype, $lastuserid, $timestamp = null) { if (isset($categoryid)) { require_once QA_INCLUDE_DIR . 'db/selects.php'; require_once QA_INCLUDE_DIR . 'app/format.php'; $categories = qa_category_path(qa_db_single_select(qa_db_category_nav_selectspec($categoryid, true)), $categoryid); foreach ($categories as $category) { qa_db_event_create_for_entity(QA_ENTITY_CATEGORY, $category['categoryid'], $questionid, $questionid, $updatetype, $lastuserid, $timestamp); } } }
function qa_feed_load_ifcategory($categoryslugs, $allkey, $catkey, &$title, $questionselectspec1 = null, $questionselectspec2 = null, $questionselectspec3 = null, $questionselectspec4 = null) { $countslugs = @count($categoryslugs); list($questions1, $questions2, $questions3, $questions4, $categories, $categoryid) = qa_db_select_with_pending($questionselectspec1, $questionselectspec2, $questionselectspec3, $questionselectspec4, $countslugs ? qa_db_category_nav_selectspec($categoryslugs, false) : null, $countslugs ? qa_db_slugs_to_category_id_selectspec($categoryslugs) : null); if ($countslugs && !isset($categoryid)) { qa_feed_not_found(); } if (isset($allkey)) { $title = isset($categoryid) && isset($catkey) ? qa_lang_sub($catkey, $categories[$categoryid]['title']) : qa_lang($allkey); } return array_merge(is_array($questions1) ? $questions1 : array(), is_array($questions2) ? $questions2 : array(), is_array($questions3) ? $questions3 : array(), is_array($questions4) ? $questions4 : array()); }
public function process_request($request) { $requestparts = explode('/', qa_request()); $slugs = array_slice($requestparts, 1); $countslugs = count($slugs); $userid = qa_get_logged_in_userid(); $start = qa_get_start(); $count = qa_opt_if_loaded('page_size_activity'); $totalcount = qa_opt('cache_qcount'); $qspec = qa_db_posts_basic_selectspec($userid, false); qa_db_add_selectspec_opost($qspec, 'ra', false, false); qa_db_add_selectspec_ousers($qspec, 'rau', 'raup'); $qspec['source'] .= " JOIN (SELECT questionid, childid FROM ^homepage ORDER BY ^homepage.updated DESC) AS rcaq ON ^posts.postid=rcaq.questionid" . " LEFT JOIN ^posts AS ra ON childid=ra.postid" . (QA_FINAL_EXTERNAL_USERS ? "" : " LEFT JOIN ^users AS rau ON ra.userid=rau.userid") . " LEFT JOIN ^userpoints AS raup ON ra.userid=raup.userid LIMIT #,#"; array_push($qspec['columns'], 'childid'); array_push($qspec['arguments'], $start, $count); $qspec['sortdesc'] = 'otime'; $query = 'SELECT '; foreach ($qspec['columns'] as $columnas => $columnfrom) { $query .= $columnfrom . (is_int($columnas) ? '' : ' AS ' . $columnas) . ', '; } $query = qa_db_apply_sub(substr($query, 0, -2) . (strlen(@$qspec['source']) ? ' FROM ' . $qspec['source'] : ''), @$qspec['arguments']); $results = qa_db_read_all_assoc(qa_db_query_raw($query)); qa_db_post_select($results, $qspec); list($categories, $categoryid) = qa_db_select_with_pending(qa_db_category_nav_selectspec($slugs, false, false, true), $countslugs ? qa_db_slugs_to_category_id_selectspec($slugs) : null); $questions = qa_any_sort_and_dedupe($results); // $questions=qa_any_sort_and_dedupe(array_merge($recentquestions,$recentanswers)); $pagesize = qa_opt('page_size_home'); if ($countslugs) { 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); $nonetitle = qa_lang_html_sub('main/no_questions_in_x', $categorytitlehtml); } else { $sometitle = qa_lang_html('main/recent_qs_as_title'); $nonetitle = qa_lang_html('main/no_questions_found'); } require_once QA_INCLUDE_DIR . 'qa-app-q-list.php'; $qa_content = qa_q_list_page_content($questions, $pagesize, $start, $totalcount, $sometitle, $nonetitle, $categories, $categoryid, true, qa_opt('eql_homepage_url'), qa_opt('feed_for_qa') ? qa_opt('eql_homepage_url') : null, count($questions) < $pagesize ? qa_html_suggest_ask($categoryid) : qa_html_suggest_qs_tags(qa_using_tags(), qa_category_path_request($categories, $categoryid)), null, null); return $qa_content; }
header('Location: ../'); exit; } require_once QA_INCLUDE_DIR . 'app/cookies.php'; require_once QA_INCLUDE_DIR . 'app/format.php'; require_once QA_INCLUDE_DIR . 'db/selects.php'; require_once QA_INCLUDE_DIR . 'util/sort.php'; require_once QA_INCLUDE_DIR . 'util/string.php'; require_once QA_INCLUDE_DIR . 'app/captcha.php'; require_once QA_INCLUDE_DIR . 'pages/question-view.php'; require_once QA_INCLUDE_DIR . 'app/updates.php'; $questionid = qa_request_part(0); $userid = qa_get_logged_in_userid(); $cookieid = qa_cookie_get(); // Get information about this question list($question, $childposts, $achildposts, $parentquestion, $closepost, $extravalue, $categories, $favorite) = qa_db_select_with_pending(qa_db_full_post_selectspec($userid, $questionid), qa_db_full_child_posts_selectspec($userid, $questionid), qa_db_full_a_child_posts_selectspec($userid, $questionid), qa_db_post_parent_q_selectspec($questionid), qa_db_post_close_post_selectspec($questionid), qa_db_post_meta_selectspec($questionid, 'qa_q_extra'), qa_db_category_nav_selectspec($questionid, true, true, true), isset($userid) ? qa_db_is_favorite_selectspec($userid, QA_ENTITY_QUESTION, $questionid) : null); if ($question['basetype'] != 'Q') { // don't allow direct viewing of other types of post $question = null; } if (isset($question)) { $question['extra'] = $extravalue; $answers = qa_page_q_load_as($question, $childposts); $commentsfollows = qa_page_q_load_c_follows($question, $childposts, $achildposts); $question = $question + qa_page_q_post_rules($question, null, null, $childposts); // array union if ($question['selchildid'] && @$answers[$question['selchildid']]['type'] != 'A') { $question['selchildid'] = null; } // if selected answer is hidden or somehow not there, consider it not selected foreach ($answers as $key => $answer) {
function qa_page_q_load_q() { global $qa_login_userid, $questionid, $question, $parentquestion, $answers, $commentsfollows, $relatedcount, $relatedquestions, $question, $categories; list($question, $childposts, $achildposts, $parentquestion, $relatedquestions, $categories) = qa_db_select_with_pending(qa_db_full_post_selectspec($qa_login_userid, $questionid), qa_db_full_child_posts_selectspec($qa_login_userid, $questionid), qa_db_full_a_child_posts_selectspec($qa_login_userid, $questionid), qa_db_post_parent_q_selectspec($questionid), qa_db_related_qs_selectspec($qa_login_userid, $questionid), qa_db_category_nav_selectspec($questionid, true, true)); if ($question['basetype'] != 'Q') { // don't allow direct viewing of other types of post $question = null; } $answers = array(); $commentsfollows = array(); foreach ($childposts as $postid => $post) { switch ($post['type']) { case 'Q': // never show follow-on Qs which have been hidden, even to admins // never show follow-on Qs which have been hidden, even to admins case 'C': case 'C_HIDDEN': $commentsfollows[$postid] = $post; break; case 'A': case 'A_HIDDEN': $answers[$postid] = $post; break; } } foreach ($achildposts as $postid => $post) { switch ($post['type']) { case 'Q': case 'Q_HIDDEN': case 'C': case 'C_HIDDEN': $commentsfollows[$postid] = $post; break; } } if (isset($question)) { $relatedcount = qa_opt('do_related_qs') ? 1 + qa_opt('page_size_related_qs') : 0; $relatedquestions = array_slice($relatedquestions, 0, $relatedcount); // includes question itself at this point qa_page_q_post_rules($question); if ($question['selchildid'] && @$answers[$question['selchildid']]['type'] != 'A') { $question['selchildid'] = null; } // if selected answer is hidden or somehow not there, consider it not selected foreach ($answers as $key => $answer) { $question['deleteable'] = false; qa_page_q_post_rules($answers[$key]); if ($answers[$key]['isbyuser'] && !qa_opt('allow_multi_answers')) { $question['answerbutton'] = false; } $answers[$key]['isselected'] = $answer['postid'] == $question['selchildid']; } foreach ($commentsfollows as $key => $commentfollow) { if ($commentfollow['parentid'] == $questionid) { $question['deleteable'] = false; } if (isset($answers[$commentfollow['parentid']])) { $answers[$commentfollow['parentid']]['deleteable'] = false; } qa_page_q_post_rules($commentsfollows[$key]); } } }
function doctype() { if (strpos($this->request, 'user/') !== false && strpos($this->request, 'articles') !== false) { $this->request = 'user-articles'; } /* ADAPT USER PAGES AND SUBPAGES */ if ($this->template == 'user' || $this->template == 'user-wall' || $this->template == 'user-activity' || $this->template == 'user-questions' || $this->template == 'user-answers' || $this->request == 'user-articles') { $handle = qa_request_part(1); if (!strlen($handle)) { $handle = qa_get_logged_in_handle(); qa_redirect(isset($handle) ? 'user/' . $handle : 'users'); } $identifier = QA_FINAL_EXTERNAL_USERS ? $userid : $handle; list($useraccount, $userprofile, $userfields, $usermessages, $userpoints, $userlevels, $navcategories, $userrank) = qa_db_select_with_pending(QA_FINAL_EXTERNAL_USERS ? null : qa_db_user_account_selectspec($handle, false), QA_FINAL_EXTERNAL_USERS ? null : qa_db_user_profile_selectspec($handle, false), QA_FINAL_EXTERNAL_USERS ? null : qa_db_userfields_selectspec(), QA_FINAL_EXTERNAL_USERS ? null : qa_db_recent_messages_selectspec(null, null, $handle, false, qa_opt_if_loaded('page_size_wall')), qa_db_user_points_selectspec($identifier), qa_db_user_levels_selectspec($identifier, QA_FINAL_EXTERNAL_USERS, true), qa_db_category_nav_selectspec(null, true), qa_db_user_rank_selectspec($identifier)); $userid = $useraccount['userid']; $loginuserid = qa_get_logged_in_userid(); if ($this->template == 'user') { // ADAPT FORM CONTENTS /*$this->content['form_activity']['fields']['activity'] = array('type'=>'static', 'label'=>'Recent Activity', 'value'=>'<a href="'.$handle.'/activity">show</a>');*/ // ADD PRIVATE MESSAGE LINK AFTER MEMBERSHIP DURATION if (qa_opt('allow_private_messages') && isset($loginuserid) && $loginuserid != $userid && !($useraccount['flags'] & QA_USER_FLAGS_NO_MESSAGES)) { $this->content['form_profile']['fields']['duration']['value'] .= strtr(qa_lang_html('profile/send_private_message'), array('^1' => '<a href="' . qa_path_html('message/' . $handle) . '">', '^2' => '</a>')); } } $site_url = qa_opt('site_url'); // RENEW THE SUB-NAVIGATION unset($this->content['navigation']['sub']); $this->content['navigation']['sub']['account'] = array('label' => 'User ' . $handle, 'url' => $site_url . '/user/' . $handle, 'selected' => $this->template == 'user' ? 1 : 0); $this->content['navigation']['sub']['wall'] = array('label' => $handle . '\'s Wall', 'url' => $site_url . '/user/' . $handle . '/wall', 'selected' => $this->template == 'user-wall' ? 1 : 0); $this->content['navigation']['sub']['activity'] = array('label' => qa_lang('qa_blog_lang/nav_activity'), 'url' => $site_url . '/user/' . $handle . '/activity', 'selected' => $this->template == 'user-activity' ? 1 : 0); $this->content['navigation']['sub']['questions'] = array('label' => qa_lang('qa_blog_lang/nav_questions'), 'url' => $site_url . '/user/' . $handle . '/questions', 'selected' => $this->template == 'user-questions' ? 1 : 0); $this->content['navigation']['sub']['answers'] = array('label' => qa_lang('qa_blog_lang/nav_answers'), 'url' => $site_url . '/user/' . $handle . '/answers', 'selected' => $this->template == 'user-answers' ? 1 : 0); $this->content['navigation']['sub']['articles'] = array('label' => qa_lang('qa_blog_lang/nav_articles'), 'url' => $site_url . '/user/' . $handle . '/articles', 'selected' => $this->request == 'user-articles' ? 1 : 0); $this->content['navigation']['sub']['newarticles'] = array('label' => qa_lang('qa_blog_lang/new_articles'), 'url' => $site_url . '/articles', 'selected' => $this->request == 'articles' ? 1 : 0); if ($this->request == 'user-articles') { unset($this->content['title']); $this->content['title'] = qa_lang('qa_blog_lang/title_recent') . " {$handle}"; unset($this->content['suggest_next']); unset($this->content['error']); if ($this->request == 'user-articles') { $qa_content['custom'] = ""; $html = ""; $result = qa_db_query_sub("SELECT * FROM ^blog_posts WHERE userid = '{$userid}' ORDER BY posted DESC"); $i = 0; while ($article = mysqli_fetch_array($result)) { $i++; $html .= article_item($article['title'], $site_url . '/blog/' . $article['postid'] . '/' . seoUrl2($article['title']) . '/', $article['posted'], $article['views']); } if ($i == 0) { $html = "<h3>" . qa_lang('qa_blog_lang/oops') . " {$handle} " . qa_lang('qa_blog_lang/no_post') . "</h3>"; } $this->content['custom'] = $html; } } } else { if ($this->template == 'account' || $this->template == 'favorites' || $this->template == 'updates' || $this->request == 'gallery' || $this->request == 'articles') { // ADAPT FORM FOR DETAILS SUBPAGE // RENEW THE SUB-NAVIGATION unset($this->content['navigation']['sub']); $this->content['navigation']['sub']['account'] = array('label' => 'My Details', 'url' => './account', 'selected' => $this->template == 'account' ? 1 : 0); $this->content['navigation']['sub']['favorites'] = array('label' => 'My Favorites', 'url' => './favorites', 'selected' => $this->template == 'favorites' ? 1 : 0); $this->content['navigation']['sub']['updates'] = array('label' => 'My Updates', 'url' => './updates', 'selected' => $this->template == 'updates' ? 1 : 0); $this->content['navigation']['sub']['articles'] = array('label' => 'My Articles', 'url' => './articles', 'selected' => $this->request == 'articles' ? 1 : 0); } else { if ($this->template == 'users') { require_once QA_INCLUDE_DIR . 'qa-db-users.php'; require_once QA_INCLUDE_DIR . 'qa-db-selects.php'; require_once QA_INCLUDE_DIR . 'qa-app-format.php'; $start = qa_get_start(); $users = qa_db_select_with_pending(qa_db_top_users_selectspec($start, qa_opt_if_loaded('page_size_users'))); $usercount = qa_opt('cache_userpointscount'); $pagesize = qa_opt('page_size_users'); $users = array_slice($users, 0, $pagesize); $usershtml = qa_userids_handles_html($users); // CHANGE TITLE $this->content['title'] = 'Users'; $this->content['ranking'] = array('items' => array(), 'rows' => ceil($pagesize / qa_opt('columns_users')), 'type' => 'users'); if (count($users)) { foreach ($users as $userid => $user) { $this->content['ranking']['items'][] = array('label' => (QA_FINAL_EXTERNAL_USERS ? qa_get_external_avatar_html($user['userid'], qa_opt('avatar_users_size'), true) : qa_get_user_avatar_html($user['flags'], $user['email'], $user['handle'], $user['avatarblobid'], $user['avatarwidth'], $user['avatarheight'], qa_opt('avatar_users_size'), true)) . ' ' . $usershtml[$user['userid']], 'score' => qa_html(number_format($user['points']))); } } else { $this->content['title'] = qa_lang_html('main/no_active_users'); } $this->content['page_links'] = qa_html_page_links(qa_request(), $start, $pagesize, $usercount, qa_opt('pages_prev_next')); // EMPTY SUB-NAVIGATION $this->content['navigation']['sub'] = null; } } } if ($this->template == 'questions') { unset($this->content['navigation']['sub']); $this->content['navigation']['sub']['account'] = array('label' => 'My Details', 'url' => './account', 'selected' => 0); //print_r ($this->content['navigation']); } if ($this->request == 'login') { $this->content['form']['fields']['password']['note'] = '<a href="/forgot">I forgot my password</a> - <a href="/register">Register</a>'; } qa_html_theme_base::doctype(); }
function ra_cat_list($limit = 15) { $categoryslugs = qa_request_parts(1); $cats = qa_db_select_with_pending(qa_db_category_nav_selectspec($categoryslugs, false, false, true)); $cats = qa_category_navigation($cats); $output = '<ul class="ra-cat-list clearfix">'; $i = 1; foreach ($cats as $k => $c) { if ($k != 'all') { $output .= '<li><a class="icon-folder-close" title="' . @$c['popup'] . '" href="' . $c['url'] . '">' . $c['label'] . '<span>' . filter_var($c['note'], FILTER_SANITIZE_NUMBER_INT) . '</span></a></li>'; if ($limit == $i) { break; } $i++; } } $output .= '</ul>'; echo $output; }
$countslugs = @count($categoryslugs); $by = qa_get('by'); $start = qa_get_start(); $userid = qa_get_logged_in_userid(); switch ($by) { case 'selected': $selectby = 'selchildid'; break; case 'upvotes': $selectby = 'amaxvote'; break; default: $selectby = 'acount'; break; } list($questions, $categories, $categoryid) = qa_db_select_with_pending(qa_db_unanswered_qs_selectspec($userid, $selectby, $start, $categoryslugs, false, false, qa_opt_if_loaded('page_size_una_qs')), QA_ALLOW_UNINDEXED_QUERIES ? qa_db_category_nav_selectspec($categoryslugs, false, false, true) : null, $countslugs ? qa_db_slugs_to_category_id_selectspec($categoryslugs) : null); if ($countslugs) { if (!isset($categoryid)) { return include QA_INCLUDE_DIR . 'qa-page-not-found.php'; } $categorytitlehtml = qa_html($categories[$categoryid]['title']); } $feedpathprefix = null; $linkparams = array('by' => $by); switch ($by) { case 'selected': if ($countslugs) { $sometitle = qa_lang_html_sub('main/unselected_qs_in_x', $categorytitlehtml); $nonetitle = qa_lang_html_sub('main/no_una_questions_in_x', $categorytitlehtml); } else { $sometitle = qa_lang_html('main/unselected_qs_title');
function qa_page_q_edit_q_submit($question, $answers, $commentsfollows, $closepost, &$in, &$errors) { $in = array(); if ($question['editable']) { $in['title'] = qa_post_text('q_title'); qa_get_post_content('q_editor', 'q_content', $in['editor'], $in['content'], $in['format'], $in['text']); $in['extra'] = qa_opt('extra_field_active') ? qa_post_text('q_extra') : null; } if ($question['retagcatable']) { if (qa_using_tags()) { $in['tags'] = qa_get_tags_field_value('q_tags'); } if (qa_using_categories()) { $in['categoryid'] = qa_get_category_field_value('q_category'); } } if (array_key_exists('categoryid', $in)) { // need to check if we can move it to that category, and if we need moderation $categories = qa_db_select_with_pending(qa_db_category_nav_selectspec($in['categoryid'], true)); $categoryids = array_keys(qa_category_path($categories, $in['categoryid'])); $userlevel = qa_user_level_for_categories($categoryids); } else { $userlevel = null; } if ($question['isbyuser']) { $in['name'] = qa_post_text('q_name'); $in['notify'] = qa_post_text('q_notify') ? true : false; $in['email'] = qa_post_text('q_email'); } if (!qa_user_post_permit_error('permit_edit_silent', $question)) { $in['silent'] = qa_post_text('q_silent'); } // here the $in array only contains values for parts of the form that were displayed, so those are only ones checked by filters $errors = array(); if (!qa_check_form_security_code('edit-' . $question['postid'], qa_post_text('code'))) { $errors['page'] = qa_lang_html('misc/form_security_again'); } else { $in['queued'] = qa_opt('moderate_edited_again') && qa_user_moderation_reason($userlevel); $filtermodules = qa_load_modules_with('filter', 'filter_question'); foreach ($filtermodules as $filtermodule) { $oldin = $in; $filtermodule->filter_question($in, $errors, $question); if ($question['editable']) { qa_update_post_text($in, $oldin); } } if (array_key_exists('categoryid', $in) && strcmp($in['categoryid'], $question['categoryid'])) { if (qa_user_permit_error('permit_post_q', null, $userlevel)) { $errors['categoryid'] = qa_lang_html('question/category_ask_not_allowed'); } } if (empty($errors)) { $userid = qa_get_logged_in_userid(); $handle = qa_get_logged_in_handle(); $cookieid = qa_cookie_get(); // now we fill in the missing values in the $in array, so that we have everything we need for qa_question_set_content() // we do things in this way to avoid any risk of a validation failure on elements the user can't see (e.g. due to admin setting changes) if (!$question['editable']) { $in['title'] = $question['title']; $in['content'] = $question['content']; $in['format'] = $question['format']; $in['text'] = qa_viewer_text($in['content'], $in['format']); $in['extra'] = $question['extra']; } if (!isset($in['tags'])) { $in['tags'] = qa_tagstring_to_tags($question['tags']); } if (!array_key_exists('categoryid', $in)) { $in['categoryid'] = $question['categoryid']; } if (!isset($in['silent'])) { $in['silent'] = false; } $setnotify = $question['isbyuser'] ? qa_combine_notify_email($question['userid'], $in['notify'], $in['email']) : $question['notify']; qa_question_set_content($question, $in['title'], $in['content'], $in['format'], $in['text'], qa_tags_to_tagstring($in['tags']), $setnotify, $userid, $handle, $cookieid, $in['extra'], @$in['name'], $in['queued'], $in['silent']); if (qa_using_categories() && strcmp($in['categoryid'], $question['categoryid'])) { qa_question_set_category($question, $in['categoryid'], $userid, $handle, $cookieid, $answers, $commentsfollows, $closepost, $in['silent']); } return true; } } return false; }
$qa_content['form_profile']['fields']['level']['suffix'] = strtr(qa_lang_html('users/category_level_add'), array('^1' => '<a href="' . qa_path_html(qa_request(), array('state' => 'edit', 'catleveladd' => 1)) . '">', '^2' => '</a>')); } else { $qa_content['form_profile']['fields']['level']['suffix'] = qa_lang_html('users/level_in_general'); } if ($catleveladd || count($userlevels)) { $userlevels[] = array('entitytype' => QA_ENTITY_CATEGORY); } $index = 0; foreach ($userlevels as $userlevel) { if ($userlevel['entitytype'] == QA_ENTITY_CATEGORY) { $index++; $id = 'ls_' . +$index; $qa_content['form_profile']['fields']['uc_' . $index . '_level'] = array('label' => qa_lang_html('users/category_level_label'), 'type' => 'select', 'tags' => 'name="uc_' . $index . '_level" id="' . qa_html($id) . '" onchange="this.qa_prev=this.options[this.selectedIndex].value;"', 'options' => $catleveloptions, 'value' => isset($userlevel['level']) ? qa_html(qa_user_level_string($userlevel['level'])) : '', 'suffix' => qa_lang_html('users/category_level_in')); $qa_content['form_profile']['fields']['uc_' . $index . '_cat'] = array(); if (isset($userlevel['entityid'])) { $fieldnavcategories = qa_db_select_with_pending(qa_db_category_nav_selectspec($userlevel['entityid'], true)); } else { $fieldnavcategories = $navcategories; } qa_set_up_category_field($qa_content, $qa_content['form_profile']['fields']['uc_' . $index . '_cat'], 'uc_' . $index . '_cat', $fieldnavcategories, @$userlevel['entityid'], true, true); unset($qa_content['form_profile']['fields']['uc_' . $index . '_cat']['note']); } } $qa_content['script_lines'][] = array("function qa_update_category_levels()", "{", "\tglob=document.getElementById('level_select');", "\tif (!glob)", "\t\treturn;", "\tvar opts=glob.options;", "\tvar lev=parseInt(opts[glob.selectedIndex].value);", "\tfor (var i=1; i<9999; i++) {", "\t\tvar sel=document.getElementById('ls_'+i);", "\t\tif (!sel)", "\t\t\tbreak;", "\t\tsel.qa_prev=sel.qa_prev || sel.options[sel.selectedIndex].value;", "\t\tsel.options.length=1;", "\t\tfor (var j=0; j<opts.length; j++)", "\t\t\tif (parseInt(opts[j].value)>lev)", "\t\t\t\tsel.options[sel.options.length]=new Option(opts[j].text, opts[j].value, false, (opts[j].value==sel.qa_prev));", "\t}", "}"); $qa_content['script_onloads'][] = array("qa_update_category_levels();"); $qa_content['form_profile']['fields']['level']['tags'] .= ' id="level_select" onchange="qa_update_category_levels();"'; } } } else { foreach ($userlevels as $userlevel) { if ($userlevel['entitytype'] == QA_ENTITY_CATEGORY && $userlevel['level'] > $useraccount['level']) {
qa_report_event('page_enter', qa_get_logged_in_userid(), qa_get_logged_in_handle(), qa_cookie_get(), array('params' => $_SERVER['QUERY_STRING'], 'path' => $_SERVER['SCRIPT_NAME'])); require_once QA_INCLUDE_DIR . 'qa-db-selects.php'; require_once QA_INCLUDE_DIR . 'qa-app-format.php'; // Determine whether path begins with qa or not (question and answer listing can be accessed either way) $explicitqa = $qa_request_lc_parts[0] == 'qa'; if ($explicitqa) { $slugs = array_slice($qa_request_parts, 1); } elseif (strlen($qa_request_parts[0])) { // $qa_request_parts[0] always present so we need to check its length $slugs = $qa_request_parts; } else { $slugs = array(); } $countslugs = count($slugs); // Get list of questions, other bits of information that might be @(list($questions1, $questions2, $categories, $categoryid, $custompage) = qa_db_select_with_pending(qa_db_qs_selectspec($qa_login_userid, 'created', 0, $slugs), qa_db_recent_a_qs_selectspec($qa_login_userid, 0, $slugs), qa_db_category_nav_selectspec($slugs, false), $countslugs ? qa_db_slugs_to_category_id_selectspec($slugs) : null, $countslugs == 1 && !$explicitqa ? qa_db_page_full_selectspec($slugs[0], false) : null)); // First, if this matches a custom page, return immediately with that page's content if (isset($custompage) && !($custompage['flags'] & QA_PAGE_FLAGS_EXTERNAL)) { $qa_template = 'custom'; $qa_content = qa_content_prepare(); $qa_content['title'] = qa_html($custompage['heading']); $qa_content['custom'] = $custompage['content']; if (qa_get_logged_in_level() >= QA_USER_LEVEL_ADMIN) { $qa_content['navigation']['sub'] = array('admin/pages' => array('label' => qa_lang('admin/edit_custom_page'), 'url' => qa_path_html('admin/pages', array('edit' => $custompage['pageid'])))); } return $qa_content; } // 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()) { qa_redirect(qa_category_path_request($categories, $categoryid), $_GET); }
} elseif (qa_post_text('dodelete')) { if (!$hassubcategory) { $inreassign = qa_get_category_field_value('reassign'); qa_db_category_reassign($editcategory['categoryid'], $inreassign); qa_db_category_delete($editcategory['categoryid']); qa_redirect(qa_request(), array('recalc' => 1, 'edit' => $editcategory['parentid'])); } } else { require_once QA_INCLUDE_DIR . 'util/string.php'; $inname = qa_post_text('name'); $incontent = qa_post_text('content'); $inparentid = $setparent ? qa_get_category_field_value('parent') : $editcategory['parentid']; $inposition = qa_post_text('position'); $errors = array(); // Check the parent ID $incategories = qa_db_select_with_pending(qa_db_category_nav_selectspec($inparentid, true)); // Verify the name is legitimate for that parent ID if (empty($inname)) { $errors['name'] = qa_lang('main/field_required'); } elseif (qa_strlen($inname) > QA_DB_MAX_CAT_PAGE_TITLE_LENGTH) { $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) && strcmp($category['categoryid'], @$editcategory['categoryid']) && qa_strtolower($category['title']) == qa_strtolower($inname)) { $errors['name'] = qa_lang('admin/category_already_used'); } } } // Verify the slug is legitimate for that parent ID for ($attempt = 0; $attempt < 100; $attempt++) { switch ($attempt) {
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 header('Location: ../'); exit; } require_once QA_INCLUDE_DIR . 'db/selects.php'; require_once QA_INCLUDE_DIR . 'app/format.php'; require_once QA_INCLUDE_DIR . 'app/q-list.php'; $categoryslugs = qa_request_parts(1); $countslugs = count($categoryslugs); $userid = qa_get_logged_in_userid(); // Get lists of recent activity in all its forms, plus category information list($questions1, $questions2, $questions3, $questions4, $categories, $categoryid) = qa_db_select_with_pending(qa_db_qs_selectspec($userid, 'created', 0, $categoryslugs, null, false, false, qa_opt_if_loaded('page_size_activity')), qa_db_recent_a_qs_selectspec($userid, 0, $categoryslugs), qa_db_recent_c_qs_selectspec($userid, 0, $categoryslugs), qa_db_recent_edit_qs_selectspec($userid, 0, $categoryslugs), qa_db_category_nav_selectspec($categoryslugs, false, false, true), $countslugs ? qa_db_slugs_to_category_id_selectspec($categoryslugs) : null); if ($countslugs) { 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_activity_in_x', $categorytitlehtml); $nonetitle = qa_lang_html_sub('main/no_questions_in_x', $categorytitlehtml); } else { $sometitle = qa_lang_html('main/recent_activity_title'); $nonetitle = qa_lang_html('main/no_questions_found'); } // Prepare and return content for theme return qa_q_list_page_content(qa_any_sort_and_dedupe(array_merge($questions1, $questions2, $questions3, $questions4)), qa_opt('page_size_activity'), 0, null, $sometitle, $nonetitle, $categories, $categoryid, true, 'activity/', qa_opt('feed_for_activity') ? 'activity' : null, qa_html_suggest_qs_tags(qa_using_tags(), qa_category_path_request($categories, $categoryid)), null, null); /* Omit PHP closing tag to help avoid accidental output
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 header('Location: ../'); exit; } // report that we entered this page qa_report_event('page_enter', qa_get_logged_in_userid(), qa_get_logged_in_handle(), qa_cookie_get(), array('params' => $_SERVER['QUERY_STRING'], 'path' => $_SERVER['SCRIPT_NAME'])); require_once QA_INCLUDE_DIR . 'qa-db-selects.php'; require_once QA_INCLUDE_DIR . 'qa-app-format.php'; require_once QA_INCLUDE_DIR . 'qa-app-q-list.php'; $categoryslugs = $pass_subrequests; $countslugs = count($categoryslugs); // Get lists of recent activity in all its forms, plus category information @(list($questions1, $questions2, $questions3, $questions4, $categories, $categoryid) = qa_db_select_with_pending(qa_db_qs_selectspec($qa_login_userid, 'created', 0, $categoryslugs), qa_db_recent_a_qs_selectspec($qa_login_userid, 0, $categoryslugs), qa_db_recent_c_qs_selectspec($qa_login_userid, 0, $categoryslugs), qa_db_recent_edit_qs_selectspec($qa_login_userid, 0, $categoryslugs), qa_db_category_nav_selectspec($categoryslugs, false), $countslugs ? qa_db_slugs_to_category_id_selectspec($categoryslugs) : null)); if ($countslugs) { 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_activity_in_x', $categorytitlehtml); $nonetitle = qa_lang_html_sub('main/no_questions_in_x', $categorytitlehtml); } else { $sometitle = qa_lang_html('main/recent_activity_title'); $nonetitle = qa_lang_html('main/no_questions_found'); } // Prepare and return content for theme return qa_q_list_page_content(qa_any_sort_and_dedupe(array_merge($questions1, $questions2, $questions3, $questions4)), qa_opt('page_size_activity'), 0, null, $sometitle, $nonetitle, $categories, $categoryid, true, 'activity/', qa_opt('feed_for_activity') ? 'activity' : null, qa_html_suggest_qs_tags(qa_using_tags(), qa_category_path_request($categories, $categoryid))); /* Omit PHP closing tag to help avoid accidental output
<?php require_once 'qa-include/qa-base.php'; require_once QA_INCLUDE_DIR . 'db/selects.php'; require_once QA_INCLUDE_DIR . 'app/q-list.php'; //require_once QA_INCLUDE_DIR.'app/users.php'; //$user = qa_get_logged_in_user(); //$userid=$user["userid"];//qa_get_logged_in_userid(); list($questions, $categories, $categoryid) = qa_db_select_with_pending(qa_db_qs_selectspec(null, 'hotness', 0, null, null, false, true), qa_db_category_nav_selectspec(null, false, false, true), null); foreach ($questions as $key => $question) { $questionid = $question["postid"]; $answers = array(); $childposts = qa_db_single_select(qa_db_full_child_posts_selectspec(null, $questionid)); foreach ($childposts as $postid => $post) { if ($post['basetype'] == 'A') { $answers[$postid] = $post; } } $questions[$key]["answers"] = $answers; } $salida = []; foreach ($questions as $pregunta) { $salida[$pregunta["postid"]] = ['userid' => $pregunta["userid"], 'contenido' => substr($pregunta["title"] . ". " . strip_tags($pregunta["content"]), 0, 100)]; foreach ($pregunta["answers"] as $resp) { //$u = Medico::where('user_id','=',$resp["userid"])->first(); //if($u){ $salida[$pregunta["postid"]]["respuestas"][] = ["userid" => $resp["userid"], "contenido" => substr(strip_tags($resp["content"]), 0, 100)]; //} } } header('Content-Type: application/json');
$selectsort = 'hotness'; break; case 'votes': $selectsort = 'netvotes'; break; case 'answers': $selectsort = 'acount'; break; case 'views': $selectsort = 'views'; break; default: $selectsort = 'created'; break; } @(list($questions, $categories, $categoryid, $favorite) = qa_db_select_with_pending(qa_db_qs_selectspec($userid, $selectsort, $start, $categoryslugs, null, false, false, qa_opt_if_loaded('page_size_qs')), qa_db_category_nav_selectspec($categoryslugs, false, false, true), $countslugs ? qa_db_slugs_to_category_id_selectspec($categoryslugs) : null, $countslugs && isset($userid) ? qa_db_is_favorite_selectspec($userid, QA_ENTITY_CATEGORY, $categoryslugs) : null)); if ($countslugs) { 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); } else { $nonetitle = qa_lang_html('main/no_questions_found'); } $categorypathprefix = QA_ALLOW_UNINDEXED_QUERIES ? 'questions/' : null; // this default is applied if sorted not by recent $feedpathprefix = null; $linkparams = array('sort' => $sort); switch ($sort) { case 'hot':
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 header('Location: ../'); exit; } require_once QA_INCLUDE_DIR . 'qa-db-admin.php'; require_once QA_INCLUDE_DIR . 'qa-db-maxima.php'; require_once QA_INCLUDE_DIR . 'qa-db-selects.php'; require_once QA_INCLUDE_DIR . 'qa-app-options.php'; require_once QA_INCLUDE_DIR . 'qa-app-admin.php'; $adminsection = strtolower(qa_request_part(1)); // Get list of categories and all options $categories = qa_db_select_with_pending(qa_db_category_nav_selectspec(null, true)); // See if we need to redirect if (empty($adminsection)) { $subnav = qa_admin_sub_navigation(); if (isset($subnav[@$_COOKIE['qa_admin_last']])) { qa_redirect($_COOKIE['qa_admin_last']); } elseif (count($subnav)) { reset($subnav); qa_redirect(key($subnav)); } } // Check admin privileges (do late to allow one DB query) if (!qa_admin_check_privileges($qa_content)) { return $qa_content; } // For non-text options, lists of option types, minima and maxima
function cs_full_categories_list($show_sub = false) { $level = 1; $navigation = @$this->content['navigation']['cat']; if (!isset($navigation)) { $categoryslugs = qa_request_parts(1); $cats = qa_db_select_with_pending(qa_db_category_nav_selectspec($categoryslugs, false, false, true)); $navigation = qa_category_navigation($cats); } if (count($navigation) > 1) { // if there are any categories (except 'all categories' navigation item) //$this->output( '<div class="qa-nav-cat">'); //$this->output( '<ul class="qa-nav-cat-list">'); $index = 0; if (isset($QA_CONST_PATH_MAP)) { $navigation['all']['url'] = qa_path_html($QA_CONST_PATH_MAP['categories']); } else { $navigation['all']['url'] = qa_path_html('categories'); } foreach ($navigation as $key => $navlink) { $this->set_context('nav_key', $key); $this->set_context('nav_index', $index++); $this->cs_full_categories_list_item($key, $navlink, '', $level, $show_sub); } $this->clear_context('nav_key'); $this->clear_context('nav_index'); //$this->output('</ul></div>'); } unset($navigation); }
GNU General Public License for more details. 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 header('Location: ../'); exit; } require_once QA_INCLUDE_DIR . 'db/selects.php'; require_once QA_INCLUDE_DIR . 'app/format.php'; $categoryslugs = qa_request_parts(1); $countslugs = count($categoryslugs); // Get information about appropriate categories and redirect to questions page if category has no sub-categories $userid = qa_get_logged_in_userid(); list($categories, $categoryid, $favoritecats) = qa_db_select_with_pending(qa_db_category_nav_selectspec($categoryslugs, false, false, true), $countslugs ? qa_db_slugs_to_category_id_selectspec($categoryslugs) : null, isset($userid) ? qa_db_user_favorite_categories_selectspec($userid) : null); if ($countslugs && !isset($categoryid)) { return include QA_INCLUDE_DIR . 'qa-page-not-found.php'; } // Function for recursive display of categories function qa_category_nav_to_browse(&$navigation, $categories, $categoryid, $favoritemap) { foreach ($navigation as $key => $navlink) { $category = $categories[$navlink['categoryid']]; if (!$category['childcount']) { unset($navigation[$key]['url']); } 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';
function get_single_question($data, $questionin) { $userid = qa_get_logged_in_userid(); $questionid = $questionin['postid']; $options = qa_post_html_defaults('Q', @$data['full']); if (@$data['full']) { require_once QA_INCLUDE_DIR . 'qa-page-question-view.php'; $cookieid = isset($userid) ? qa_cookie_get() : qa_cookie_get_create(); // create a new cookie if necessary $coptions = qa_post_html_defaults('C', true); @(list($childposts, $achildposts, $parentquestion, $closepost, $extravalue, $categories, $favorite) = qa_db_select_with_pending(qa_db_full_child_posts_selectspec($userid, $questionid), qa_db_full_a_child_posts_selectspec($userid, $questionid), qa_db_post_parent_q_selectspec($questionid), qa_db_post_close_post_selectspec($questionid), qa_db_post_meta_selectspec($questionid, 'qa_q_extra'), qa_db_category_nav_selectspec($questionid, true, true, true), isset($userid) ? qa_db_is_favorite_selectspec($userid, QA_ENTITY_QUESTION, $questionid) : null)); if ($questionin['basetype'] != 'Q') { // don't allow direct viewing of other types of post return null; } $questionin['extra'] = $extravalue; $answers = qa_page_q_load_as($questionin, $childposts); $allcomments = qa_page_q_load_c_follows($questionin, $childposts, $achildposts); $questionin = $questionin + qa_page_q_post_rules($questionin, null, null, $childposts); // array union if ($questionin['selchildid'] && @$answers[$questionin['selchildid']]['type'] != 'A') { $questionin['selchildid'] = null; } // if selected answer is hidden or somehow not there, consider it not selected foreach ($answers as $key => $answer) { $answers[$key] = $answer + qa_page_q_post_rules($answer, $questionin, $answers, $achildposts); $answers[$key]['isselected'] = $answer['postid'] == $questionin['selchildid']; } foreach ($allcomments as $key => $commentfollow) { $parent = $commentfollow['parentid'] == $questionid ? $questionin : @$answers[$commentfollow['parentid']]; $allcomments[$key] = $commentfollow + qa_page_q_post_rules($commentfollow, $parent, $allcomments, null); } $usershtml = qa_userids_handles_html(array_merge(array($questionin), $answers, $allcomments), true); $question = $this->get_full_post($questionin, $options, $usershtml); $qcomments = array(); foreach ($allcomments as $idx => $comment) { if ($comment['basetype'] == 'C') { $comment = $this->get_full_post($comment, $coptions, $usershtml); } else { $comment = $this->get_full_post($comment, $options, $usershtml); } $comment['username'] = $this->get_username($comment['raw']['userid']); if ($comment['raw']['parentid'] == $questionid) { $qcomments[] = $comment; } $allcomments[$idx] = $comment; } $aoptions = qa_post_html_defaults('A', true); $outanswers = array(); foreach ($answers as $answer) { $aoptions['isselected'] = @$answer['isselected']; $answer = $this->get_full_post($answer, $aoptions, $usershtml); if (!$answer) { continue; } $answer['username'] = $this->get_username($answer['raw']['userid']); $acomments = array(); foreach ($allcomments as $comment) { if ($comment['raw']['parentid'] == $answer['raw']['postid']) { $acomments[] = $comment; } } $answer['comments'] = $acomments; $outanswers[] = $answer; } $question['answers'] = $outanswers; $question['comments'] = $qcomments; $question['parentquestion'] = $parentquestion; $question['closepost'] = $closepost; $question['extravalue'] = $extravalue; $question['categories'] = $categories; $question['favorite'] = $favorite; } else { $questionin = qa_db_select_with_pending(qa_db_full_post_selectspec($userid, $questionid)); $usershtml = qa_userids_handles_html(array($questionin), true); $question = qa_any_to_q_html_fields($questionin, $userid, qa_cookie_get(), $usershtml, null, $options); } $question['username'] = $this->get_username($userid); return $question; }
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 header('Location: ../'); exit; } require_once QA_INCLUDE_DIR . 'qa-db-selects.php'; require_once QA_INCLUDE_DIR . 'qa-app-format.php'; require_once QA_INCLUDE_DIR . 'qa-app-q-list.php'; $categoryslugs = qa_request_parts(1); $countslugs = count($categoryslugs); $userid = qa_get_logged_in_userid(); // Get list of comments with related questions, plus category information list($questions, $categories, $categoryid) = qa_db_select_with_pending(qa_db_recent_c_qs_selectspec($userid, 0, $categoryslugs), qa_db_category_nav_selectspec($categoryslugs, false, false, true), $countslugs ? qa_db_slugs_to_category_id_selectspec($categoryslugs) : null); if ($countslugs) { 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_cs_in_x', $categorytitlehtml); $nonetitle = qa_lang_html_sub('main/no_comments_in_x', $categorytitlehtml); } else { $sometitle = qa_lang_html('main/recent_cs_title'); $nonetitle = qa_lang_html('main/no_comments_found'); } // Prepare and return content for theme return qa_q_list_page_content(qa_any_sort_and_dedupe($questions), qa_opt('page_size_activity'), 0, null, $sometitle, $nonetitle, $categories, $categoryid, false, 'comments/', qa_opt('feed_for_activity') ? 'comments' : null, qa_html_suggest_qs_tags(qa_using_tags(), qa_category_path_request($categories, $categoryid))); /* Omit PHP closing tag to help avoid accidental output
$selectsort = 'hotness'; break; case 'votes': $selectsort = 'netvotes'; break; case 'answers': $selectsort = 'acount'; break; case 'views': $selectsort = 'views'; break; default: $selectsort = 'created'; break; } list($questions, $categories, $categoryid) = qa_db_select_with_pending(qa_db_qs_selectspec($userid, $selectsort, $start, $categoryslugs, null, false, false, qa_opt_if_loaded('page_size_qs')), qa_db_category_nav_selectspec($categoryslugs, false, false, true), $countslugs ? qa_db_slugs_to_category_id_selectspec($categoryslugs) : null); if ($countslugs) { 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); } else { $nonetitle = qa_lang_html('main/no_questions_found'); } $categorypathprefix = QA_ALLOW_UNINDEXED_QUERIES ? 'questions/' : null; // this default is applied if sorted not by recent $feedpathprefix = null; $linkparams = array('sort' => $sort); switch ($sort) { case 'hot':
require_once QA_INCLUDE_DIR . 'db/selects.php'; require_once QA_INCLUDE_DIR . 'app/format.php'; // Determine whether path begins with qa or not (question and answer listing can be accessed either way) $requestparts = explode('/', qa_request()); $explicitqa = strtolower($requestparts[0]) == 'qa'; if ($explicitqa) { $slugs = array_slice($requestparts, 1); } elseif (strlen($requestparts[0])) { $slugs = $requestparts; } else { $slugs = array(); } $countslugs = count($slugs); // Get list of questions, other bits of information that might be useful $userid = qa_get_logged_in_userid(); list($questions1, $questions2, $categories, $categoryid, $custompage) = qa_db_select_with_pending(qa_db_qs_selectspec($userid, 'created', 0, $slugs, null, false, false, qa_opt_if_loaded('page_size_activity')), 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); // First, if this matches a custom page, return immediately with that page's content if (isset($custompage) && !($custompage['flags'] & QA_PAGE_FLAGS_EXTERNAL)) { qa_set_template('custom-' . $custompage['pageid']); $qa_content = qa_content_prepare(); $level = qa_get_logged_in_level(); if (!qa_permit_value_error($custompage['permit'], $userid, $level, qa_get_logged_in_flags()) || !isset($custompage['permit'])) { $qa_content['title'] = qa_html($custompage['heading']); $qa_content['custom'] = $custompage['content']; if ($level >= QA_USER_LEVEL_ADMIN) { $qa_content['navigation']['sub'] = array('admin/pages' => array('label' => qa_lang('admin/edit_custom_page'), 'url' => qa_path_html('admin/pages', array('edit' => $custompage['pageid'])))); } } else { $qa_content['error'] = qa_lang_html('users/no_permission'); } return $qa_content;
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 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 header('Location: ../'); exit; } require_once QA_INCLUDE_DIR . 'qa-db-selects.php'; require_once QA_INCLUDE_DIR . 'qa-app-format.php'; $categoryslugs = qa_request_parts(1); $countslugs = count($categoryslugs); // Get information about appropriate categories and redirect to questions page if category has no sub-categories @(list($categories, $categoryid) = qa_db_select_with_pending(qa_db_category_nav_selectspec($categoryslugs, false, false, true), $countslugs ? qa_db_slugs_to_category_id_selectspec($categoryslugs) : null)); if ($countslugs && !isset($categoryid)) { return include QA_INCLUDE_DIR . 'qa-page-not-found.php'; } // Function for recursive display of categories function qa_category_nav_to_browse(&$navigation, $categories, $categoryid) { foreach ($navigation as $key => $navlink) { $category = $categories[$navlink['categoryid']]; if (!$category['childcount']) { unset($navigation[$key]['url']); } 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';
header('Location: ../'); exit; } require_once QA_INCLUDE_DIR . 'qa-app-format.php'; require_once QA_INCLUDE_DIR . 'qa-app-limits.php'; require_once QA_INCLUDE_DIR . 'qa-db-selects.php'; require_once QA_INCLUDE_DIR . 'qa-util-sort.php'; // Check whether this is a follow-on question and get some info we need from the database $in = array(); $followpostid = qa_get('follow'); $in['categoryid'] = qa_get_category_field_value('category'); if (!isset($in['categoryid'])) { $in['categoryid'] = qa_get('cat'); } $userid = qa_get_logged_in_userid(); list($categories, $followanswer, $completetags) = qa_db_select_with_pending(qa_db_category_nav_selectspec($in['categoryid'], true), isset($followpostid) ? qa_db_full_post_selectspec($userid, $followpostid) : null, qa_db_popular_tags_selectspec(0, QA_DB_RETRIEVE_COMPLETE_TAGS)); if (!isset($categories[$in['categoryid']])) { $in['categoryid'] = null; } if (@$followanswer['basetype'] != 'A') { $followanswer = null; } // Check for permission error $permiterror = qa_user_maximum_permit_error('permit_post_q', QA_LIMIT_QUESTIONS); if ($permiterror) { $qa_content = qa_content_prepare(); // The 'approve', 'login', 'confirm', 'limit', 'userblock', 'ipblock' permission errors are reported to the user here // The other option ('level') prevents the menu option being shown, in qa_content_prepare(...) 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);
function getCustomChannelsId() { // List containing the custom channels: $channels = array(); if (qa_opt('adchat-expand-categories')) { $q2a_categories = qa_db_select_with_pending($this->getAllCategoriesSelectSpec()); } else { $q2a_categories = qa_db_select_with_pending(qa_db_category_nav_selectspec(false, false, false, true)); } foreach ($q2a_categories as $catID => $catDet) { $channels[] = $catID; } // Channel array structure should be: // ChannelName => ChannelID return $channels; }