Exemplo n.º 1
0
require_once QA_INCLUDE_DIR . 'app/users.php';
require_once QA_INCLUDE_DIR . 'app/cookies.php';
require_once QA_INCLUDE_DIR . 'db/selects.php';
$message = qa_post_text('message');
$tohandle = qa_post_text('handle');
$morelink = qa_post_text('morelink');
$touseraccount = qa_db_select_with_pending(qa_db_user_account_selectspec($tohandle, false));
$loginuserid = qa_get_logged_in_userid();
$errorhtml = qa_wall_error_html($loginuserid, $touseraccount['userid'], $touseraccount['flags']);
if ($errorhtml || !strlen($message) || !qa_check_form_security_code('wall-' . $tohandle, qa_post_text('code'))) {
    echo "QA_AJAX_RESPONSE\n0";
} else {
    $messageid = qa_wall_add_post($loginuserid, qa_get_logged_in_handle(), qa_cookie_get(), $touseraccount['userid'], $touseraccount['handle'], $message, '');
    $touseraccount['wallposts']++;
    // won't have been updated
    $usermessages = qa_db_select_with_pending(qa_db_recent_messages_selectspec(null, null, $touseraccount['userid'], true, qa_opt('page_size_wall')));
    $usermessages = qa_wall_posts_add_rules($usermessages, 0);
    $themeclass = qa_load_theme_class(qa_get_site_theme(), 'wall', null, null);
    echo "QA_AJAX_RESPONSE\n1\n";
    echo 'm' . $messageid . "\n";
    // element in list to be revealed
    foreach ($usermessages as $message) {
        $themeclass->message_item(qa_wall_post_view($message));
    }
    if ($morelink && $touseraccount['wallposts'] > count($usermessages)) {
        $themeclass->message_item(qa_wall_view_more_link($tohandle, count($usermessages)));
    }
}
/*
	Omit PHP closing tag to help avoid accidental output
*/
$handle = qa_request_part(1);
$loginuserid = qa_get_logged_in_userid();
//	Check we have a handle, we're not using Q2A's single-sign on integration and that we're logged in
if (QA_FINAL_EXTERNAL_USERS) {
    qa_fatal_error('User accounts are handled by external code');
}
if (!strlen($handle)) {
    qa_redirect('users');
}
if (!isset($loginuserid)) {
    $qa_content = qa_content_prepare();
    $qa_content['error'] = qa_insert_login_links(qa_lang_html('misc/message_must_login'), qa_request());
    return $qa_content;
}
//	Find the user profile and questions and answers for this handle
list($toaccount, $torecent, $fromrecent) = qa_db_select_with_pending(qa_db_user_account_selectspec($handle, false), qa_db_recent_messages_selectspec($loginuserid, true, $handle, false), qa_db_recent_messages_selectspec($handle, false, $loginuserid, true));
//	Check the user exists and work out what can and can't be set (if not using single sign-on)
if (!qa_opt('allow_private_messages') || !is_array($toaccount) || $toaccount['flags'] & QA_USER_FLAGS_NO_MESSAGES) {
    return include QA_INCLUDE_DIR . 'qa-page-not-found.php';
}
//	Check that we have permission and haven't reached the limit
$errorhtml = null;
switch (qa_user_permit_error(null, QA_LIMIT_MESSAGES)) {
    case 'limit':
        $errorhtml = qa_lang_html('misc/message_limit');
        break;
    case false:
        break;
    default:
        $errorhtml = qa_lang_html('users/no_permission');
        break;
Exemplo n.º 3
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/selects.php';
require_once QA_INCLUDE_DIR . 'app/messages.php';
//	Check we're not using single-sign on integration, which doesn't allow walls
if (QA_FINAL_EXTERNAL_USERS) {
    qa_fatal_error('User accounts are handled by external code');
}
//	$handle, $userhtml are already set by qa-page-user.php
$start = qa_get_start();
//	Find the questions for this user
list($useraccount, $usermessages) = qa_db_select_with_pending(qa_db_user_account_selectspec($handle, false), qa_db_recent_messages_selectspec(null, null, $handle, false, qa_opt_if_loaded('page_size_wall'), $start));
if (!is_array($useraccount)) {
    // check the user exists
    return include QA_INCLUDE_DIR . 'qa-page-not-found.php';
}
//	Perform pagination
$pagesize = qa_opt('page_size_wall');
$count = $useraccount['wallposts'];
$loginuserid = qa_get_logged_in_userid();
$usermessages = array_slice($usermessages, 0, $pagesize);
$usermessages = qa_wall_posts_add_rules($usermessages, $start);
//	Process deleting or adding a wall post (similar but not identical code to qq-page-user-profile.php)
$errors = array();
$wallposterrorhtml = qa_wall_error_html($loginuserid, $useraccount['userid'], $useraccount['flags']);
foreach ($usermessages as $message) {
    if ($message['deleteable'] && qa_clicked('m' . $message['messageid'] . '_dodelete')) {
	as published by the Free Software Foundation; either version 2
	of the License, or (at your option) any later version.
	
	This program is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	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
*/
require_once QA_INCLUDE_DIR . 'qa-app-messages.php';
require_once QA_INCLUDE_DIR . 'qa-app-users.php';
require_once QA_INCLUDE_DIR . 'qa-app-cookies.php';
require_once QA_INCLUDE_DIR . 'qa-db-selects.php';
$tohandle = qa_post_text('handle');
$start = (int) qa_post_text('start');
$usermessages = qa_db_select_with_pending(qa_db_recent_messages_selectspec(null, null, $tohandle, false, null, $start));
$usermessages = qa_wall_posts_add_rules($usermessages, $start);
foreach ($usermessages as $message) {
    if (qa_clicked('m' . $message['messageid'] . '_dodelete') && $message['deleteable']) {
        if (qa_check_form_security_code('wall-' . $tohandle, qa_post_text('code'))) {
            qa_wall_delete_post(qa_get_logged_in_userid(), qa_get_logged_in_handle(), qa_cookie_get(), $message);
            echo "QA_AJAX_RESPONSE\n1\n";
            return;
        }
    }
}
echo "QA_AJAX_RESPONSE\n0\n";
/*
	Omit PHP closing tag to help avoid accidental output
*/
    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-limits.php';
require_once QA_INCLUDE_DIR . 'qa-app-updates.php';
//	$handle, $userhtml are already set by qa-page-user.php - also $userid if using external user integration
//	Redirect to 'My Account' page if button clicked
if (qa_clicked('doaccount')) {
    qa_redirect('account');
}
//	Find the user profile and questions and answers for this handle
$loginuserid = qa_get_logged_in_userid();
$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));
if (!QA_FINAL_EXTERNAL_USERS) {
    foreach ($userfields as $index => $userfield) {
        if (isset($userfield['permit']) && qa_permit_value_error($userfield['permit'], $loginuserid, qa_get_logged_in_level(), qa_get_logged_in_flags())) {
            unset($userfields[$index]);
        }
    }
}
// don't pay attention to user fields we're not allowed to view
//	Check the user exists and work out what can and can't be set (if not using single sign-on)
$errors = array();
$loginlevel = qa_get_logged_in_level();
if (!QA_FINAL_EXTERNAL_USERS) {
    // if we're using integrated user management, we can know and show more
    require_once QA_INCLUDE_DIR . 'qa-app-messages.php';
    if (!is_array($userpoints) && !is_array($useraccount)) {
Exemplo n.º 6
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();
 }