user.php 2.19 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
<?php
/*
	Question2Answer by Gideon Greenspan and contributors
	http://www.question2answer.org/

	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
*/

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


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

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

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


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

40 41 42 43
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
44

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

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


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

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
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;