user.php 2.3 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 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
<?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
*/

	if (!defined('QA_VERSION')) { // don't allow this page to be requested directly from browser
		header('Location: ../');
		exit;
	}


//	Determine the identify of the user

	$handle = qa_request_part(1);

	if (!strlen($handle)) {
		$handle = qa_get_logged_in_handle();
		qa_redirect(isset($handle) ? 'user/'.$handle : 'users');
	}


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

	if (QA_FINAL_EXTERNAL_USERS) {
		$userid = qa_handle_to_userid($handle);
		if (!isset($userid))
			return include QA_INCLUDE_DIR.'qa-page-not-found.php';

		$usershtml = qa_get_users_html(array($userid), false, qa_path_to_root(), true);
		$userhtml = @$usershtml[$userid];

	}
	else
		$userhtml = qa_html($handle);


//	Display the appropriate page based on the request

	switch (qa_request_part(2)) {
		case 'wall':
			qa_set_template('user-wall');
59
			$qa_content = include QA_INCLUDE_DIR.'pages/user-wall.php';
Scott committed
60 61 62 63
			break;

		case 'activity':
			qa_set_template('user-activity');
64
			$qa_content = include QA_INCLUDE_DIR.'pages/user-activity.php';
Scott committed
65 66 67 68
			break;

		case 'questions':
			qa_set_template('user-questions');
69
			$qa_content = include QA_INCLUDE_DIR.'pages/user-questions.php';
Scott committed
70 71 72 73
			break;

		case 'answers':
			qa_set_template('user-answers');
74
			$qa_content = include QA_INCLUDE_DIR.'pages/user-answers.php';
Scott committed
75 76 77
			break;

		case null:
78
			$qa_content = include QA_INCLUDE_DIR.'pages/user-profile.php';
Scott committed
79 80 81 82 83 84 85 86 87 88 89
			break;

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

	return $qa_content;

/*
	Omit PHP closing tag to help avoid accidental output
Gideon Greenspan committed
90
*/