Exemplo n.º 1
0
function it_q_list_page_content($questions, $pagesize, $start, $count, $sometitle, $nonetitle, $navcategories, $categoryid, $categoryqcount, $categorypathprefix, $feedpathprefix, $suggest, $pagelinkparams = null, $categoryparams = null, $dummy = null)
{
    require_once QA_INCLUDE_DIR . 'qa-app-format.php';
    require_once QA_INCLUDE_DIR . 'qa-app-updates.php';
    $userid = qa_get_logged_in_userid();
    //	Chop down to size, get user information for display
    if (isset($pagesize)) {
        $questions = array_slice($questions, 0, $pagesize);
    }
    $usershtml = qa_userids_handles_html(qa_any_get_userids_handles($questions));
    $qa_content['q_list']['form'] = array('tags' => 'method="post" action="' . qa_self_html() . '"', 'hidden' => array('code' => qa_get_form_security_code('vote')));
    $qa_content['q_list']['qs'] = array();
    if (count($questions)) {
        $qa_content['title'] = $sometitle;
        $defaults = qa_post_html_defaults('Q');
        foreach ($questions as $question) {
            $qa_content['q_list']['qs'][] = qa_any_to_q_html_fields($question, $userid, it_cookie_get(), $usershtml, null, qa_post_html_options($question, $defaults));
        }
    } else {
        $qa_content['title'] = $nonetitle;
    }
    if (isset($count) && isset($pagesize)) {
        $qa_content['page_links'] = qa_html_page_links(qa_request(), $start, $pagesize, $count, qa_opt('pages_prev_next'), $pagelinkparams);
    }
    return $qa_content;
}
Exemplo n.º 2
0
function qa_q_list_page_content($questions, $pagesize, $start, $count, $sometitle, $nonetitle, $navcategories, $categoryid, $categoryqcount, $categorypathprefix, $feedpathprefix, $suggest, $pagelinkparams = null, $categoryparams = null, $dummy = null)
{
    if (qa_to_override(__FUNCTION__)) {
        $args = func_get_args();
        return qa_call_override(__FUNCTION__, $args);
    }
    require_once QA_INCLUDE_DIR . 'app/format.php';
    require_once QA_INCLUDE_DIR . 'app/updates.php';
    $userid = qa_get_logged_in_userid();
    //	Chop down to size, get user information for display
    if (isset($pagesize)) {
        $questions = array_slice($questions, 0, $pagesize);
    }
    $usershtml = qa_userids_handles_html(qa_any_get_userids_handles($questions));
    //	Prepare content for theme
    $qa_content = qa_content_prepare(true, array_keys(qa_category_path($navcategories, $categoryid)));
    $qa_content['q_list']['form'] = array('tags' => 'method="post" action="' . qa_self_html() . '"', 'hidden' => array('code' => qa_get_form_security_code('vote')));
    $qa_content['q_list']['qs'] = array();
    if (count($questions)) {
        $qa_content['title'] = $sometitle;
        $defaults = qa_post_html_defaults('Q');
        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));
            if (!empty($fields['raw']['closedbyid'])) {
                $fields['closed'] = array('state' => qa_lang_html('main/closed'));
            }
            $qa_content['q_list']['qs'][] = $fields;
        }
    } else {
        $qa_content['title'] = $nonetitle;
    }
    if (isset($userid) && isset($categoryid)) {
        $favoritemap = qa_get_favorite_non_qs_map();
        $categoryisfavorite = @$favoritemap['category'][$navcategories[$categoryid]['backpath']];
        $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']));
    }
    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'])) {
        $qa_content['suggest_next'] = $suggest;
    }
    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))) {
        $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;
}
Exemplo n.º 3
0
 function get_user_activity($handle, $limit = 10)
 {
     $userid = qa_handle_to_userid($handle);
     require_once QA_INCLUDE_DIR . 'qa-db-selects.php';
     require_once QA_INCLUDE_DIR . 'qa-app-format.php';
     $identifier = QA_FINAL_EXTERNAL_USERS ? $userid : $handle;
     list($useraccount, $questions, $answerqs, $commentqs, $editqs) = qa_db_select_with_pending(QA_FINAL_EXTERNAL_USERS ? null : qa_db_user_account_selectspec($handle, false), qa_db_user_recent_qs_selectspec($userid, $identifier, $limit), qa_db_user_recent_a_qs_selectspec($userid, $identifier), qa_db_user_recent_c_qs_selectspec($userid, $identifier), qa_db_user_recent_edit_qs_selectspec($userid, $identifier));
     if (!QA_FINAL_EXTERNAL_USERS && !is_array($useraccount)) {
         // check the user exists
         return include QA_INCLUDE_DIR . 'qa-page-not-found.php';
     }
     //	Get information on user references
     $questions = qa_any_sort_and_dedupe(array_merge($questions, $answerqs, $commentqs, $editqs));
     $questions = array_slice($questions, 0, $limit);
     $usershtml = qa_userids_handles_html(qa_any_get_userids_handles($questions), false);
     $htmldefaults = qa_post_html_defaults('Q');
     $htmldefaults['whoview'] = false;
     $htmldefaults['voteview'] = false;
     $htmldefaults['avatarsize'] = 0;
     foreach ($questions as $question) {
         $qa_content[] = qa_any_to_q_html_fields($question, $userid, qa_cookie_get(), $usershtml, null, array('voteview' => false) + qa_post_html_options($question, $htmldefaults));
     }
     $output = '<div class="user-activities">';
     $output .= '<ul>';
     if (isset($qa_content)) {
         foreach ($qa_content as $qs) {
             $icon = 'icon-time undefined';
             $output .= '<li class="activity-item">';
             $output .= '<div class="list-right">';
             $output .= '<div class="type pull-left ' . $icon . '"></div>';
             $output .= '<div class="what"><a class="what-task" href="' . @$qs['url'] . '">' . $qs['what'] . '</a>';
             $output .= '<a href="' . $qs['url'] . '">' . $qs['title'] . '</a> </div>';
             $output .= '<strong class="when">' . implode(' ', $qs['when']) . '</strong>';
             $output .= '</div>';
             $output .= '</li>';
         }
     } else {
         $output .= '<li>' . qa_lang('cleanstrap/no_activity_yet') . '</li>';
     }
     $output .= '</ul>';
     $output .= '</div>';
     return $output;
 }
Exemplo n.º 4
0
function qa_q_list_page_content($questions, $pagesize, $start, $count, $sometitle, $nonetitle, $navcategories, $categoryid, $categoryqcount, $categorypathprefix, $feedpathprefix, $suggest, $pagelinkparams = array())
{
    require_once QA_INCLUDE_DIR . 'qa-app-format.php';
    global $qa_login_userid, $qa_cookieid, $qa_request;
    // get globals from qa-page.php
    //	Chop down to size, get user information for display
    if (isset($pagesize)) {
        $questions = array_slice($questions, 0, $pagesize);
    }
    $usershtml = qa_userids_handles_html(qa_any_get_userids_handles($questions));
    //	Prepare content for theme
    $qa_content = qa_content_prepare(true, array_keys(qa_category_path($navcategories, $categoryid)));
    $qa_content['q_list']['form'] = array('tags' => 'METHOD="POST" ACTION="' . qa_self_html() . '"');
    $qa_content['q_list']['qs'] = array();
    if (count($questions)) {
        $qa_content['title'] = $sometitle;
        $options = qa_post_html_defaults('Q');
        if (isset($categorypathprefix)) {
            $options['categorypathprefix'] = $categorypathprefix;
        }
        foreach ($questions as $question) {
            $qa_content['q_list']['qs'][] = qa_any_to_q_html_fields($question, $qa_login_userid, $qa_cookieid, $usershtml, null, $options);
        }
    } else {
        $qa_content['title'] = $nonetitle;
    }
    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'])) {
        $qa_content['suggest_next'] = $suggest;
    }
    if (qa_using_categories() && count($navcategories) && isset($categorypathprefix)) {
        $qa_content['navigation']['cat'] = qa_category_navigation($navcategories, $categoryid, $categorypathprefix, $categoryqcount);
    }
    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;
}
Exemplo n.º 5
0
 public function output_widget($region, $place, $themeobject, $template, $request, $qa_content)
 {
     require_once QA_INCLUDE_DIR . 'db/selects.php';
     if (!isset($qa_content['q_view']['raw']['type']) || $qa_content['q_view']['raw']['type'] != 'Q') {
         // question might not be visible, etc...
         return;
     }
     $questionid = $qa_content['q_view']['raw']['postid'];
     $userid = qa_get_logged_in_userid();
     $cookieid = qa_cookie_get();
     $questions = qa_db_single_select(qa_db_related_qs_selectspec($userid, $questionid, qa_opt('page_size_related_qs')));
     $minscore = qa_match_to_min_score(qa_opt('match_related_qs'));
     foreach ($questions as $key => $question) {
         if ($question['score'] < $minscore) {
             unset($questions[$key]);
         }
     }
     $titlehtml = qa_lang_html(count($questions) ? 'main/related_qs_title' : 'main/no_related_qs_title');
     if ($region == 'side') {
         $themeobject->output('<div class="qa-related-qs">', '<h2 style="margin-top:0; padding-top:0;">', $titlehtml, '</h2>');
         $themeobject->output('<ul class="qa-related-q-list">');
         foreach ($questions as $question) {
             $themeobject->output('<li class="qa-related-q-item">' . '<a href="' . qa_q_path_html($question['postid'], $question['title']) . '">' . qa_html($question['title']) . '</a>' . '</li>');
         }
         $themeobject->output('</ul>', '</div>');
     } else {
         $themeobject->output('<h2>', $titlehtml, '</h2>');
         $q_list = array('form' => array('tags' => 'method="post" action="' . qa_self_html() . '"', 'hidden' => array('code' => qa_get_form_security_code('vote'))), 'qs' => array());
         $defaults = qa_post_html_defaults('Q');
         $usershtml = qa_userids_handles_html($questions);
         foreach ($questions as $question) {
             $q_list['qs'][] = qa_post_html_fields($question, $userid, $cookieid, $usershtml, null, qa_post_html_options($question, $defaults));
         }
         $themeobject->q_list_and_form($q_list);
     }
 }
Exemplo n.º 6
0
 function output_widget($region, $place, $themeobject, $template, $request, $qa_content)
 {
     require_once QA_INCLUDE_DIR . 'qa-db-selects.php';
     if (@$qa_content['q_view']['raw']['type'] != 'Q') {
         // question might not be visible, etc...
         return;
     }
     $questionid = $qa_content['q_view']['raw']['postid'];
     $userid = qa_get_logged_in_userid();
     $cookieid = qa_cookie_get();
     $questions = qa_db_single_select(qa_db_related_qs_selectspec($userid, $questionid, qa_opt('page_size_related_qs')));
     $minscore = qa_match_to_min_score(qa_opt('match_related_qs'));
     foreach ($questions as $key => $question) {
         if ($question['score'] < $minscore) {
             unset($questions[$key]);
         }
     }
     $titlehtml = qa_lang_html(count($questions) ? 'main/related_qs_title' : 'main/no_related_qs_title');
     if ($region == 'side') {
         $themeobject->output('<DIV CLASS="qa-related-qs">', '<H2 STYLE="margin-top:0; padding-top:0;">', $titlehtml, '</H2>');
         $themeobject->output('<UL CLASS="qa-related-q-list">');
         foreach ($questions as $question) {
             $themeobject->output('<LI CLASS="qa-related-q-item"><A HREF="' . qa_q_path_html($question['postid'], $question['title']) . '">' . qa_html($question['title']) . '</A></LI>');
         }
         $themeobject->output('</UL>', '</DIV>');
     } else {
         $themeobject->output('<H2>', $titlehtml, '</H2>');
         $q_list = array('form' => array('tags' => 'METHOD="POST" ACTION="' . qa_self_html() . '"'), 'qs' => array());
         $options = qa_post_html_defaults('Q');
         $usershtml = qa_userids_handles_html($questions);
         foreach ($questions as $question) {
             $q_list['qs'][] = qa_post_html_fields($question, $userid, $cookieid, $usershtml, null, $options);
         }
         $themeobject->q_list_and_form($q_list);
     }
 }
Exemplo n.º 7
0
*/
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';
//	Check that we're logged in
$userid = qa_get_logged_in_userid();
if (!isset($userid)) {
    qa_redirect('login');
}
//	Get lists of favorites for this user
@(list($questions, $users, $tags, $categories) = qa_db_select_with_pending(qa_db_user_favorite_qs_selectspec($userid), QA_FINAL_EXTERNAL_USERS ? null : qa_db_user_favorite_users_selectspec($userid), qa_db_user_favorite_tags_selectspec($userid), qa_db_user_favorite_categories_selectspec($userid)));
$usershtml = qa_userids_handles_html(QA_FINAL_EXTERNAL_USERS ? $questions : array_merge($questions, $users));
//	Prepare and return content for theme
$qa_content = qa_content_prepare(true);
$qa_content['title'] = qa_lang_html('misc/my_favorites_title');
//	Favorite questions
$qa_content['q_list'] = array('title' => count($questions) ? qa_lang_html('main/nav_qs') : qa_lang_html('misc/no_favorite_qs'), 'qs' => array());
if (count($questions)) {
    $qa_content['q_list']['form'] = array('tags' => 'METHOD="POST" ACTION="' . qa_self_html() . '"');
    $options = qa_post_html_defaults('Q');
    foreach ($questions as $question) {
        $qa_content['q_list']['qs'][] = qa_post_html_fields($question, $userid, qa_cookie_get(), $usershtml, null, $options);
    }
}
//	Favorite users
if (!QA_FINAL_EXTERNAL_USERS) {
    $qa_content['ranking_users'] = array('title' => count($users) ? qa_lang_html('main/nav_users') : qa_lang_html('misc/no_favorite_users'), 'items' => array(), 'rows' => ceil(count($users) / qa_opt('columns_users')), 'type' => 'users');
Exemplo n.º 8
0
        }
    }
}
if (qa_is_http_post() || strlen($pagestate)) {
    require QA_INCLUDE_DIR . 'pages/question-post.php';
}
$formrequested = isset($formtype);
if (!$formrequested && $question['answerbutton']) {
    $immedoption = qa_opt('show_a_form_immediate');
    if ($immedoption == 'always' || $immedoption == 'if_no_as' && !$question['isbyuser'] && !$question['acount']) {
        $formtype = 'a_add';
    }
    // show answer form by default
}
//	Get information on the users referenced
$usershtml = qa_userids_handles_html(array_merge(array($question), $answers, $commentsfollows), true);
//	Prepare content for theme
$qa_content = qa_content_prepare(true, array_keys(qa_category_path($categories, $question['categoryid'])));
if (isset($userid) && !$formrequested) {
    $qa_content['favorite'] = qa_favorite_form(QA_ENTITY_QUESTION, $questionid, $favorite, qa_lang($favorite ? 'question/remove_q_favorites' : 'question/add_q_favorites'));
}
$qa_content['script_rel'][] = 'qa-content/qa-question.js?' . QA_VERSION;
if (isset($pageerror)) {
    $qa_content['error'] = $pageerror;
} elseif ($question['queued']) {
    $qa_content['error'] = $question['isbyuser'] ? qa_lang_html('question/q_your_waiting_approval') : qa_lang_html('question/q_waiting_your_approval');
}
if ($question['hidden']) {
    $qa_content['hidden'] = true;
}
qa_sort_by($commentsfollows, 'created');
Exemplo n.º 9
0
require_once QA_INCLUDE_DIR . 'app/format.php';
//	$handle, $userhtml are already set by qa-page-user.php - also $userid if using external user integration
$start = qa_get_start();
//	Find the questions for this user
$loginuserid = qa_get_logged_in_userid();
$identifier = QA_FINAL_EXTERNAL_USERS ? $userid : $handle;
list($useraccount, $userpoints, $questions) = qa_db_select_with_pending(QA_FINAL_EXTERNAL_USERS ? null : qa_db_user_account_selectspec($handle, false), qa_db_user_points_selectspec($identifier), qa_db_user_recent_a_qs_selectspec($loginuserid, $identifier, qa_opt_if_loaded('page_size_activity'), $start));
if (!QA_FINAL_EXTERNAL_USERS && !is_array($useraccount)) {
    // check the user exists
    return include QA_INCLUDE_DIR . 'qa-page-not-found.php';
}
//	Get information on user questions
$pagesize = qa_opt('page_size_activity');
$count = (int) @$userpoints['aposts'];
$questions = array_slice($questions, 0, $pagesize);
$usershtml = qa_userids_handles_html($questions, false);
//	Prepare content for theme
$qa_content = qa_content_prepare(true);
if (count($questions)) {
    $qa_content['title'] = qa_lang_html_sub('profile/answers_by_x', $userhtml);
} else {
    $qa_content['title'] = qa_lang_html_sub('profile/no_answers_by_x', $userhtml);
}
//	Recent questions by this user
$qa_content['q_list']['form'] = array('tags' => 'method="post" action="' . qa_self_html() . '"', 'hidden' => array('code' => qa_get_form_security_code('vote')));
$qa_content['q_list']['qs'] = array();
$htmldefaults = qa_post_html_defaults('Q');
$htmldefaults['whoview'] = false;
$htmldefaults['avatarsize'] = 0;
$htmldefaults['ovoteview'] = true;
$htmldefaults['answersview'] = false;
Exemplo n.º 10
0
 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();
 }
    $count = 2 * (isset($display) ? $display : QA_DB_RETRIEVE_QS_AS) + 1;
    // get enough results to be able to give some idea of how many pages of search results there are
    //	Perform the search using appropriate module
    $results = qa_get_search_results($inquery, $start, $count, $userid, false, false);
    //	Count and truncate results
    $pagesize = qa_opt('page_size_search');
    $gotcount = count($results);
    $results = array_slice($results, 0, $pagesize);
    //	Retrieve extra information on users
    $fullquestions = array();
    foreach ($results as $result) {
        if (isset($result['question'])) {
            $fullquestions[] = $result['question'];
        }
    }
    $usershtml = qa_userids_handles_html($fullquestions);
    //	Report the search event
    qa_report_event('search', $userid, qa_get_logged_in_handle(), qa_cookie_get(), array('query' => $inquery, 'start' => $start));
}
//	Prepare content for theme
$qa_content = qa_content_prepare(true);
if (strlen(qa_get('q'))) {
    $qa_content['search']['value'] = qa_html($inquery);
    if (count($results)) {
        $qa_content['title'] = qa_lang_html_sub('main/results_for_x', qa_html($inquery));
    } else {
        $qa_content['title'] = qa_lang_html_sub('main/no_results_for_x', qa_html($inquery));
    }
    $qa_content['q_list']['form'] = array('tags' => 'method="post" action="' . qa_self_html() . '"', 'hidden' => array('code' => qa_get_form_security_code('vote')));
    $qa_content['q_list']['qs'] = array();
    $qdefaults = qa_post_html_defaults('Q');
Exemplo n.º 12
0
    function ranking($ranking)
    {
        $class = @$ranking['type'] == 'users' ? 'qa-top-users' : 'qa-top-tags';
        $item_count = min($ranking['rows'], count($ranking['items']));
        if (@$ranking['type'] == 'users') {
            if (count($ranking['items'])) {
                $this->output('<div class="page-users-list clearfix"><div class="row">');
                $columns = qa_opt('columns_users');
                $pagesize = qa_opt('page_size_users');
                $start = qa_get_start();
                $users = qa_db_select_with_pending(qa_db_top_users_selectspec($start, qa_opt_if_loaded('page_size_users')));
                $users = array_slice($users, 0, $pagesize);
                $usershtml = qa_userids_handles_html($users);
                foreach ($ranking['items'] as $user) {
                    $this->output('<div class="user-box col-sm-' . ceil(12 / $columns) . ' col-xs-12">');
                    $user_raw = !empty($user['raw']) ? $user['raw'] : $user;
                    $handle = @$user_raw['handle'];
                    $handle_html = @$usershtml[$user_raw['userid']];
                    if (defined('QA_WORDPRESS_INTEGRATE_PATH')) {
                        $level_html = $user['score'];
                        unset($user['score']);
                    } else {
                        if (is_numeric($user['score'])) {
                            $user_level = donut_get_user_level($user_raw['userid']);
                            $level_html = qa_user_level_string($user_level);
                        } else {
                            $level_html = $user['score'];
                            unset($user['score']);
                        }
                    }
                    if (empty($handle_html)) {
                        $handle_html = $user['label'];
                    }
                    $avatar = QA_FINAL_EXTERNAL_USERS ? qa_get_external_avatar_html(@$user_raw['userid'], qa_opt('avatar_users_size'), true) : qa_get_user_avatar_html(@$user_raw['flags'], @$user_raw['email'], @$user_raw['handle'], @$user_raw['avatarblobid'], @$user_raw['avatarwidth'], @$user_raw['avatarheight'], 70, true);
                    if (isset($user['score'])) {
                        $userpoints = $user['score'];
                        $pointshtml = $userpoints === 1 ? qa_lang_html_sub('main/1_point', '1', '1') : qa_lang_html_sub('main/x_points', qa_html($userpoints));
                        if (!empty($pointshtml)) {
                            $pointshtml = '<p class="score">' . $pointshtml . '</p>';
                        }
                    }
                    $this->output('
								<div class="user-box-inner">
									<div class="user-avatar">
										' . $avatar . '
									</div>
									<div class="user-data">
										' . $handle_html . '
										<div class="user-level">
											' . $level_html . '
										</div>
										<div class="counts clearfix">
											' . @$pointshtml . '
										</div>
								</div>');
                    if (qa_opt('badge_active') && function_exists('qa_get_badge_list')) {
                        $this->output('<div class="badge-list">' . donut_user_badge($handle) . '</div>');
                    }
                    $this->output('</div>');
                    $this->output('</div>');
                }
                $this->output('</div>');
                $this->output('</div>');
            } else {
                $title = isset($this->content['ranking_users']['title']) ? $this->content['ranking_users']['title'] : @$this->content['title'];
                $this->output('
								<div class="no-items">
									<div class="alert alert-info"><span class="fa fa-warning"></span> ' . $title . '</div>
								</div>');
            }
        } elseif (@$ranking['type'] == 'tags') {
            if (count($ranking['items'])) {
                $this->output('<div id="tags-list" class="row ' . $class . '">');
                $columns = qa_opt('columns_tags');
                for ($column = 0; $column < $columns; $column++) {
                    $this->set_context('ranking_column', $column);
                    $this->output('<div class="col-md-' . ceil(12 / $columns) . ' col-xs-12" >');
                    $this->output('<ul class="donut-tags-list">');
                    for ($row = 0; $row < $item_count; $row++) {
                        $this->set_context('ranking_row', $row);
                        $this->donut_tags_item(@$ranking['items'][$column * $item_count + $row], $class, $column > 0);
                    }
                    $this->clear_context('ranking_column');
                    $this->output('</ul>');
                    $this->output('</div>');
                }
                $this->clear_context('ranking_row');
                $this->output('</div>');
            } else {
                $this->output('
						<div class="no-items">
						<div class="alert alert-info"><span class="fa fa-warning"></span> ' . $this->content['ranking_tags']['title'] . '</div>
						</div>');
            }
        } else {
            parent::ranking($ranking);
        }
    }
Exemplo n.º 13
0
//	Data for functions to run
$favswitch = array('questions' => array('page_opt' => 'page_size_qs', 'fn_spec' => 'qa_db_user_favorite_qs_selectspec', 'fn_view' => 'qa_favorite_q_list_view', 'key' => 'q_list'), 'users' => array('page_opt' => 'page_size_users', 'fn_spec' => 'qa_db_user_favorite_users_selectspec', 'fn_view' => 'qa_favorite_users_view', 'key' => 'ranking_users'), 'tags' => array('page_opt' => 'page_size_tags', 'fn_spec' => 'qa_db_user_favorite_tags_selectspec', 'fn_view' => 'qa_favorite_tags_view', 'key' => 'ranking_tags'));
//	Check that we're logged in
$userid = qa_get_logged_in_userid();
if (!isset($userid)) {
    qa_redirect('login');
}
//	Get lists of favorites of this type
$favtype = qa_request_part(1);
$start = qa_get_start();
if (!array_key_exists($favtype, $favswitch) || $favtype === 'users' && QA_FINAL_EXTERNAL_USERS) {
    return include QA_INCLUDE_DIR . 'qa-page-not-found.php';
}
extract($favswitch[$favtype]);
// get switch variables
$pagesize = qa_opt($page_opt);
list($totalItems, $items) = qa_db_select_with_pending(qa_db_selectspec_count($fn_spec($userid)), $fn_spec($userid, $pagesize, $start));
$count = $totalItems['count'];
$usershtml = qa_userids_handles_html($items);
//	Prepare and return content for theme
$qa_content = qa_content_prepare(true);
$qa_content['title'] = qa_lang_html('misc/my_favorites_title');
$qa_content[$key] = $fn_view($items, $usershtml);
//	Sub navigation for account pages and suggestion
$qa_content['suggest_next'] = qa_lang_html_sub('misc/suggest_favorites_add', '<span class="qa-favorite-image">&nbsp;</span>');
$qa_content['page_links'] = qa_html_page_links(qa_request(), $start, $pagesize, $count, qa_opt('pages_prev_next'));
$qa_content['navigation']['sub'] = qa_user_sub_navigation(qa_get_logged_in_handle(), 'favorites', true);
return $qa_content;
/*
	Omit PHP closing tag to help avoid accidental output
*/
    function ranking($ranking)
    {
        $class = @$ranking['type'] == 'users' ? 'qa-top-users' : 'qa-top-tags';
        $rows = min($ranking['rows'], count($ranking['items']));
        if (!$rows) {
            $rows = 1;
        }
        if (@$ranking['type'] == 'users') {
            $this->output('<div class="page-users-list clearfix"><div class="row">');
            if (isset($ranking['items'])) {
                $columns = ceil(count($ranking['items']) / $rows);
            }
            if (isset($ranking['items'])) {
                $pagesize = qa_opt('page_size_users');
                $start = qa_get_start();
                $users = qa_db_select_with_pending(qa_db_top_users_selectspec($start, qa_opt_if_loaded('page_size_users')));
                $users = array_slice($users, 0, $pagesize);
                $usershtml = qa_userids_handles_html($users);
                foreach ($ranking['items'] as $user) {
                    $this->output('<div class="user-box col-sm-' . ceil(12 / $columns) . ' col-xs-12">');
                    $user_raw = !empty($user['raw']) ? $user['raw'] : $user;
                    $handle = @$user_raw['handle'];
                    $handle_html = @$usershtml[$user_raw['userid']];
                    if (isset($user_raw['userid'])) {
                        $user_rank = qa_db_select_with_pending(qa_db_user_rank_selectspec($user_raw['userid'], true));
                        $level_html = qa_user_level_string($user_rank);
                    } else {
                        $level_html = $user['score'];
                        unset($user['score']);
                    }
                    if (empty($handle_html)) {
                        $handle_html = $user['label'];
                    }
                    $avatar = QA_FINAL_EXTERNAL_USERS ? qa_get_external_avatar_html(@$user_raw['userid'], qa_opt('avatar_users_size'), true) : qa_get_user_avatar_html(@$user_raw['flags'], @$user_raw['email'], @$user_raw['handle'], @$user_raw['avatarblobid'], @$user_raw['avatarwidth'], @$user_raw['avatarheight'], 70, true);
                    if (isset($user['score'])) {
                        $userpoints = $user['score'];
                        $pointshtml = $userpoints === 1 ? qa_lang_html_sub('main/1_point', '1', '1') : qa_lang_html_sub('main/x_points', qa_html($userpoints));
                        if (!empty($pointshtml)) {
                            $pointshtml = '<p class="score">' . $pointshtml . '</p>';
                        }
                    }
                    $this->output('
								<div class="user-box-inner">
									<div class="user-avatar">
										' . $avatar . '
									</div>
									<div class="user-data">
										' . $handle_html . '
										<div class="user-level">
											' . $level_html . '
										</div>
										<div class="counts clearfix">
											' . @$pointshtml . '
										</div>
								</div>');
                    if (qa_opt('badge_active') && function_exists('qa_get_badge_list')) {
                        $this->output('<div class="badge-list">' . donut_user_badge($handle) . '</div>');
                    }
                    $this->output('</div>');
                    $this->output('</div>');
                }
            } else {
                $this->output('
								<div class="no-items">
									<h3 class="">' . qa_lang_html('main/no_active_users') . '</h3>
								</div>');
            }
            $this->output('</div>');
            $this->output('</div>');
        } elseif (@$ranking['type'] == 'tags') {
            if ($rows > 0) {
                $this->output('<div id="tags-list" class="row ' . $class . '">');
                $tags = array();
                foreach (@$ranking['items'] as $item) {
                    $tags[] = strip_tags($item['label']);
                }
                $columns = ceil(count($ranking['items']) / $rows);
                for ($column = 0; $column < $columns; $column++) {
                    $this->set_context('ranking_column', $column);
                    $this->output('<div class="col-md-' . ceil(12 / $columns) . ' col-xs-12" >');
                    $this->output('<ul class="donut-tags-list">');
                    for ($row = 0; $row < $rows; $row++) {
                        $this->set_context('ranking_row', $row);
                        $this->donut_tags_item(@$ranking['items'][$column * $rows + $row], $class, $column > 0);
                    }
                    $this->clear_context('ranking_column');
                    $this->output('</ul>');
                    $this->output('</div>');
                }
                $this->clear_context('ranking_row');
                $this->output('</div>');
            } else {
                $this->output('
						<div class="no-items">
						<h3 class="icon-warning">' . qa_lang('cleanstrap/no_tags') . '</h3>
						<p>' . qa_lang('cleanstrap/no_results_detail') . '</p>
						</div>');
            }
        } else {
            if ($rows > 0) {
                $this->output('<table class="' . $class . '-table">');
                $columns = ceil(count($ranking['items']) / $rows);
                for ($row = 0; $row < $rows; $row++) {
                    $this->set_context('ranking_row', $row);
                    $this->output('<tr>');
                    for ($column = 0; $column < $columns; $column++) {
                        $this->set_context('ranking_column', $column);
                        $this->ranking_item(@$ranking['items'][$column * $rows + $row], $class, $column > 0);
                    }
                    $this->clear_context('ranking_column');
                    $this->output('</tr>');
                }
                $this->clear_context('ranking_row');
                $this->output('</table>');
            } else {
                $this->output('
							<div class="no-items">
								<h3 class="icon-warning">' . qa_lang_html('cleanstrap/no_results') . '</h3>
								<p>' . qa_lang_html('cleanstrap/no_results_detail') . '</p>
							</div>');
            }
        }
    }
        //	Send back new count of answers
        $countanswers = $question['acount'];
        if ($countanswers == 1) {
            echo qa_lang_html('question/1_answer_title');
        } else {
            echo qa_lang_html_sub('question/x_answers_title', $countanswers);
        }
        //	If the answer was not deleted....
        if (isset($answer)) {
            $question = $question + qa_page_q_post_rules($question, null, null, $qchildposts);
            // array union
            $answer = $answer + qa_page_q_post_rules($answer, $question, $qchildposts, $achildposts);
            foreach ($achildposts as $key => $achildpost) {
                $achildposts[$key] = $achildpost + qa_page_q_post_rules($achildpost, $answer, $achildposts, null);
            }
            $usershtml = qa_userids_handles_html(array_merge(array($answer), $achildposts), true);
            $a_view = qa_page_q_answer_view($question, $answer, $answer['postid'] == $question['selchildid'] && $answer['type'] == 'A', $usershtml, false);
            $a_view['c_list'] = qa_page_q_comment_follow_list($question, $answer, $achildposts, false, $usershtml, false, null);
            $themeclass = qa_load_theme_class(qa_get_site_theme(), 'ajax-answer', null, null);
            //	... send back the HTML for it
            echo "\n";
            $themeclass->a_list_item($a_view);
        }
        return;
    }
}
echo "QA_AJAX_RESPONSE\n0\n";
// fall back to non-Ajax submission if something failed
/*
	Omit PHP closing tag to help avoid accidental output
*/
Exemplo n.º 16
0
 $usecaptcha = qa_user_use_captcha();
 $questionid = qa_post_text('a_questionid');
 $userid = qa_get_logged_in_userid();
 list($question, $childposts) = qa_db_select_with_pending(qa_db_full_post_selectspec($userid, $questionid), qa_db_full_child_posts_selectspec($userid, $questionid));
 if (@$question['basetype'] == 'Q' && !isset($question['closedbyid'])) {
     $answers = qa_page_q_load_as($question, $childposts);
     //	Try to create the new answer
     $answerid = qa_page_q_add_a_submit($question, $answers, $usecaptcha, $in, $errors);
     $countanswers = $question['acount'] + 1;
     if (isset($answerid)) {
         //	If successful, page content will be updated via Ajax
         $answer = qa_db_select_with_pending(qa_db_full_post_selectspec($userid, $answerid));
         $question = $question + qa_page_q_post_rules($question, null, null, $childposts);
         // array union
         $answer = $answer + qa_page_q_post_rules($answer, $question, $answers, null);
         $usershtml = qa_userids_handles_html(array($answer), true);
         $a_view = qa_page_q_answer_view($question, $answer, false, $usershtml, false);
         $themeclass = qa_load_theme_class(qa_get_site_theme(), 'ajax-answer', null, null);
         echo "QA_AJAX_RESPONSE\n1\n";
         //	Send back whether the 'answer' button should still be visible
         echo (int) qa_opt('allow_multi_answers') . "\n";
         //	Send back the count of answers
         if ($countanswers == 1) {
             echo qa_lang_html('question/1_answer_title') . "\n";
         } else {
             echo qa_lang_html_sub('question/x_answers_title', $countanswers) . "\n";
         }
         //	Send back the HTML
         $themeclass->a_list_item($a_view);
         return;
     }
Exemplo n.º 17
0
function get_user_activity($handle)
{
    $userid = qa_handle_to_userid($handle);
    require_once QA_INCLUDE_DIR . 'qa-db-selects.php';
    require_once QA_INCLUDE_DIR . 'qa-app-format.php';
    $loginuserid = qa_get_logged_in_userid();
    $identifier = QA_FINAL_EXTERNAL_USERS ? $userid : $handle;
    list($useraccount, $questions, $answerqs, $commentqs, $editqs) = qa_db_select_with_pending(QA_FINAL_EXTERNAL_USERS ? null : qa_db_user_account_selectspec($handle, false), qa_db_user_recent_qs_selectspec($loginuserid, $identifier, qa_opt_if_loaded('page_size_activity')), qa_db_user_recent_a_qs_selectspec($loginuserid, $identifier), qa_db_user_recent_c_qs_selectspec($loginuserid, $identifier), qa_db_user_recent_edit_qs_selectspec($loginuserid, $identifier));
    if (!QA_FINAL_EXTERNAL_USERS && !is_array($useraccount)) {
        // check the user exists
        return include QA_INCLUDE_DIR . 'qa-page-not-found.php';
    }
    //	Get information on user references
    $questions = qa_any_sort_and_dedupe(array_merge($questions, $answerqs, $commentqs, $editqs));
    $questions = array_slice($questions, 0, qa_opt('page_size_activity'));
    $usershtml = qa_userids_handles_html(qa_any_get_userids_handles($questions), false);
    $htmldefaults = qa_post_html_defaults('Q');
    $htmldefaults['whoview'] = false;
    $htmldefaults['voteview'] = false;
    $htmldefaults['avatarsize'] = 0;
    foreach ($questions as $question) {
        $qa_content[] = qa_any_to_q_html_fields($question, $loginuserid, qa_cookie_get(), $usershtml, null, array('voteview' => false) + qa_post_html_options($question, $htmldefaults));
    }
    $output = '<div class="widget user-activities">';
    $output .= '<h3 class="widget-title">' . ra_name($handle) . '\'s ' . _ra_lang('activities') . '</h3>';
    $output .= '<ul class="question-list">';
    if (isset($qa_content)) {
        foreach ($qa_content as $qs) {
            if ($qs['what'] == 'answered') {
                $icon = 'icon-chat-3 answered';
            } elseif ($qs['what'] == 'asked') {
                $icon = 'icon-question asked';
            } elseif ($qs['what'] == 'commented') {
                $icon = 'icon-chat-2 commented';
            } elseif ($qs['what'] == 'edited' || $qs['what'] == 'answer edited') {
                $icon = 'icon-edit edited';
            } elseif ($qs['what'] == 'closed') {
                $icon = 'icon-error closed';
            } elseif ($qs['what'] == 'answer selected') {
                $icon = 'icon-checked selected';
            } elseif ($qs['what'] == 'recategorized') {
                $icon = 'icon-folder-close recategorized';
            } else {
                $icon = 'icon-pin undefined';
            }
            $output .= '<li class="activity-item">';
            $output .= '<div class="type pull-left ' . $icon . '"></div>';
            $output .= '<div class="list-right">';
            $output .= '<h5 class="when"><a href="' . @$qs['what_url'] . '">' . $qs['what'] . '</a> ' . implode(' ', $qs['when']) . '</h5>';
            $output .= '<h5 class="what"><a href="' . $qs['url'] . '">' . $qs['title'] . '</a></h5>';
            $output .= '</div>';
            $output .= '</li>';
        }
    } else {
        $output .= '<li>' . _ra_lang('No activity yet.') . '</li>';
    }
    $output .= '</ul>';
    $output .= '</div>';
    return $output;
}
Exemplo n.º 18
0
*/
if (!defined('QA_VERSION')) {
    // don't allow this page to be requested directly from browser
    header('Location: ../');
    exit;
}
require_once QA_INCLUDE_DIR . 'db/users.php';
require_once QA_INCLUDE_DIR . 'db/selects.php';
require_once QA_INCLUDE_DIR . 'app/format.php';
//	Get list of all users
$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);
//	Prepare content for theme
$qa_content = qa_content_prepare();
$qa_content['title'] = qa_lang_html('main/highest_users');
$qa_content['ranking'] = array('items' => array(), 'rows' => ceil($pagesize / qa_opt('columns_users')), 'type' => 'users');
if (count($users)) {
    foreach ($users as $userid => $user) {
        if (QA_FINAL_EXTERNAL_USERS) {
            $avatarhtml = qa_get_external_avatar_html($user['userid'], qa_opt('avatar_users_size'), true);
        } else {
            $avatarhtml = qa_get_user_avatar_html($user['flags'], $user['email'], $user['handle'], $user['avatarblobid'], $user['avatarwidth'], $user['avatarheight'], qa_opt('avatar_users_size'), true);
        }
        // avatar and handle now listed separately for use in themes
        $qa_content['ranking']['items'][] = array('avatar' => $avatarhtml, 'label' => $usershtml[$user['userid']], 'score' => qa_html(number_format($user['points'])), 'raw' => $user);
    }
} else {
Exemplo n.º 19
0
    require_once QA_INCLUDE_DIR . 'app/cookies.php';
    require_once QA_INCLUDE_DIR . 'pages/question-view.php';
    require_once QA_INCLUDE_DIR . 'pages/question-submit.php';
    require_once QA_INCLUDE_DIR . 'util/sort.php';
    //	Try to create the new comment
    $usecaptcha = qa_user_use_captcha(qa_user_level_for_post($question));
    $commentid = qa_page_q_add_c_submit($question, $parent, $children, $usecaptcha, $in, $errors);
    //	If successful, page content will be updated via Ajax
    if (isset($commentid)) {
        $children = qa_db_select_with_pending(qa_db_full_child_posts_selectspec($userid, $parentid));
        $parent = $parent + qa_page_q_post_rules($parent, $questionid == $parentid ? null : $question, null, $children);
        // in theory we should retrieve the parent's siblings for the above, but they're not going to be relevant
        foreach ($children as $key => $child) {
            $children[$key] = $child + qa_page_q_post_rules($child, $parent, $children, null);
        }
        $usershtml = qa_userids_handles_html($children, true);
        qa_sort_by($children, 'created');
        $c_list = qa_page_q_comment_follow_list($question, $parent, $children, true, $usershtml, false, null);
        $themeclass = qa_load_theme_class(qa_get_site_theme(), 'ajax-comments', null, null);
        echo "QA_AJAX_RESPONSE\n1\n";
        //	Send back the ID of the new comment
        echo qa_anchor('C', $commentid) . "\n";
        //	Send back the HTML
        $themeclass->c_list_items($c_list['cs']);
        return;
    }
}
echo "QA_AJAX_RESPONSE\n0\n";
// fall back to non-Ajax submission if there were any problems
/*
	Omit PHP closing tag to help avoid accidental output
Exemplo n.º 20
0
    return $qa_content;
}
//	Check to see if any have been reshown or deleted
$pageerror = qa_admin_check_clicks();
//	Combine sets of questions and remove those this user has no permissions for
$questions = qa_any_sort_by_date(array_merge($hiddenquestions, $hiddenanswers, $hiddencomments));
if (qa_user_permit_error('permit_hide_show') && qa_user_permit_error('permit_delete_hidden')) {
    // not allowed to see all hidden posts
    foreach ($questions as $index => $question) {
        if (qa_user_post_permit_error('permit_hide_show', $question) && qa_user_post_permit_error('permit_delete_hidden', $question)) {
            unset($questions[$index]);
        }
    }
}
//	Get information for users
$usershtml = qa_userids_handles_html(qa_any_get_userids_handles($questions));
//	Create list of actual hidden postids and see which ones have dependents
$qhiddenpostid = array();
foreach ($questions as $key => $question) {
    $qhiddenpostid[$key] = isset($question['opostid']) ? $question['opostid'] : $question['postid'];
}
$dependcounts = qa_db_postids_count_dependents($qhiddenpostid);
//	Prepare content for theme
$qa_content = qa_content_prepare();
$qa_content['title'] = qa_lang_html('admin/recent_hidden_title');
$qa_content['error'] = isset($pageerror) ? $pageerror : qa_admin_page_error();
$qa_content['q_list'] = array('form' => array('tags' => 'method="post" action="' . qa_self_html() . '"', 'hidden' => array('code' => qa_get_form_security_code('admin/click'))), 'qs' => array());
if (count($questions)) {
    foreach ($questions as $key => $question) {
        $elementid = 'p' . $qhiddenpostid[$key];
        $htmloptions = qa_post_html_options($question);
Exemplo n.º 21
0
 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;
 }
Exemplo n.º 22
0
$parentid = qa_post_text('parentid');
$userid = qa_get_logged_in_userid();
list($comment, $question, $parent, $children) = qa_db_select_with_pending(qa_db_full_post_selectspec($userid, $commentid), qa_db_full_post_selectspec($userid, $questionid), qa_db_full_post_selectspec($userid, $parentid), qa_db_full_child_posts_selectspec($userid, $parentid));
//	Check if there was an operation that succeeded
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
    if (qa_page_q_single_click_c($comment, $question, $parent, $error)) {
        $comment = qa_db_select_with_pending(qa_db_full_post_selectspec($userid, $commentid));
        //	If so, page content to be updated via Ajax
        echo "QA_AJAX_RESPONSE\n1";
        //	If the comment was not deleted...
        if (isset($comment)) {
            $parent = $parent + qa_page_q_post_rules($parent, $questionid == $parentid ? null : $question, null, $children);
            // in theory we should retrieve the parent's siblings for the above, but they're not going to be relevant
            $comment = $comment + qa_page_q_post_rules($comment, $parent, $children, null);
            $usershtml = qa_userids_handles_html(array($comment), true);
            $c_view = qa_page_q_comment_view($question, $parent, $comment, $usershtml, false);
            $themeclass = qa_load_theme_class(qa_get_site_theme(), 'ajax-comment', null, null);
            //	... send back the HTML for it
            echo "\n";
            $themeclass->c_list_item($c_view);
        }
        return;
    }
}
echo "QA_AJAX_RESPONSE\n0\n";
// fall back to non-Ajax submission if something failed
/*
	Omit PHP closing tag to help avoid accidental output
*/
Exemplo n.º 23
0
 function process_request($request)
 {
     require_once QA_INCLUDE_DIR . 'qa-db-selects.php';
     require_once QA_INCLUDE_DIR . 'qa-app-format.php';
     $userid = qa_get_logged_in_userid();
     if (!isset($userid)) {
         qa_redirect('login');
     }
     if (!QA_FINAL_EXTERNAL_USERS) {
         $users = qa_db_select_with_pending($this->qa_db_user_followers_selectspec($userid));
     } else {
         $users = null;
     }
     $usershtml = qa_userids_handles_html($users);
     $qa_content = qa_content_prepare();
     $qa_content['title'] = count($users) ? qa_lang_html(self::PLUGIN . '/' . self::PAGE_TITLE) : qa_lang_html(self::PLUGIN . '/' . self::PAGE_TITLE_NON);
     if (!QA_FINAL_EXTERNAL_USERS) {
         $qa_content['ranking_users'] = array('items' => array(), 'rows' => ceil(count($users) / qa_opt('columns_users')), 'type' => 'users');
         foreach ($users as $user) {
             $qa_content['ranking_users']['items'][] = array('label' => 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'])));
         }
     }
     return $qa_content;
 }