Example #1
0
	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';
//	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) {
Example #2
0
    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/favorites.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
$pagesize_qs = qa_opt('page_size_qs');
$pagesize_users = qa_opt('page_size_users');
$pagesize_tags = qa_opt('page_size_tags');
list($numQs, $questions, $numUsers, $users, $numTags, $tags, $categories) = qa_db_select_with_pending(qa_db_selectspec_count(qa_db_user_favorite_qs_selectspec($userid)), qa_db_user_favorite_qs_selectspec($userid, $pagesize_qs), QA_FINAL_EXTERNAL_USERS ? null : qa_db_selectspec_count(qa_db_user_favorite_users_selectspec($userid)), QA_FINAL_EXTERNAL_USERS ? null : qa_db_user_favorite_users_selectspec($userid, $pagesize_users), qa_db_selectspec_count(qa_db_user_favorite_tags_selectspec($userid)), qa_db_user_favorite_tags_selectspec($userid, $pagesize_tags), 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'] = qa_favorite_q_list_view($questions, $usershtml);
$qa_content['q_list']['title'] = count($questions) ? qa_lang_html('main/nav_qs') : qa_lang_html('misc/no_favorite_qs');
if ($numQs['count'] > count($questions)) {
    $url = qa_path_html('favorites/questions', array('start' => $pagesize_qs));
    $qa_content['q_list']['footer'] = '<p class="qa-link-next"><a href="' . $url . '">' . qa_lang_html('misc/more_favorite_qs') . '</a></p>';
}
//	Favorite users
if (!QA_FINAL_EXTERNAL_USERS) {
    $qa_content['ranking_users'] = qa_favorite_users_view($users, $usershtml);
    $qa_content['ranking_users']['title'] = count($users) ? qa_lang_html('main/nav_users') : qa_lang_html('misc/no_favorite_users');