user.php 2.22 KB
Newer Older
Scott committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
<?php
/*
	Question2Answer by Gideon Greenspan and contributors
	http://www.question2answer.org/

	File: qa-include/qa-page-user.php
	Description: Controller for user profile page


	This program is free software; you can redistribute it and/or
	modify it under the terms of the GNU General Public License
	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
*/

23 24 25 26
if (!defined('QA_VERSION')) { // don't allow this page to be requested directly from browser
	header('Location: ../');
	exit;
}
Scott committed
27 28


Scott committed
29
// Determine the identify of the user
Scott committed
30

31
$handle = qa_request_part(1);
Scott committed
32

33 34 35 36
if (!strlen($handle)) {
	$handle = qa_get_logged_in_handle();
	qa_redirect(!empty($handle) ? 'user/' . $handle : 'users');
}
Scott committed
37 38


Scott committed
39
// Get the HTML to display for the handle, and if we're using external users, determine the userid
Scott committed
40

41 42 43 44
if (QA_FINAL_EXTERNAL_USERS) {
	$userid = qa_handle_to_userid($handle);
	if (!isset($userid))
		return include QA_INCLUDE_DIR . 'qa-page-not-found.php';
Scott committed
45

46 47
	$usershtml = qa_get_users_html(array($userid), false, qa_path_to_root(), true);
	$userhtml = @$usershtml[$userid];
Scott committed
48

49 50
} else
	$userhtml = qa_html($handle);
Scott committed
51 52


Scott committed
53
// Display the appropriate page based on the request
Scott committed
54

55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85
switch (qa_request_part(2)) {
	case 'wall':
		qa_set_template('user-wall');
		$qa_content = include QA_INCLUDE_DIR . 'pages/user-wall.php';
		break;

	case 'activity':
		qa_set_template('user-activity');
		$qa_content = include QA_INCLUDE_DIR . 'pages/user-activity.php';
		break;

	case 'questions':
		qa_set_template('user-questions');
		$qa_content = include QA_INCLUDE_DIR . 'pages/user-questions.php';
		break;

	case 'answers':
		qa_set_template('user-answers');
		$qa_content = include QA_INCLUDE_DIR . 'pages/user-answers.php';
		break;

	case null:
		$qa_content = include QA_INCLUDE_DIR . 'pages/user-profile.php';
		break;

	default:
		$qa_content = include QA_INCLUDE_DIR . 'qa-page-not-found.php';
		break;
}

return $qa_content;