aboutsummaryrefslogtreecommitdiff
path: root/mod/profile/profile_lib.php
blob: d92ad29b3ea3ec0fd0c32b8898d2eb063969fea0 (plain)
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
<?php
/**
 * Elgg profile index
 *
 * @package ElggProfile
 * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
 * @author Curverider Ltd <info@elgg.com>
 * @copyright Curverider Ltd 2008-2010
 * @link http://elgg.com/
 */

/**
 * Returns the html for a user profile.
 *
 * @param string $username The username of the profile to display
 * @param string $section Which section is currently selected.
 *
 * return mixed FALSE or html for the profile.
 */
function profile_get_user_profile_html($user, $section = 'activity') {
	$body = elgg_view('profile/profile_navigation', array('section' => $section, 'entity' => $user));
	$view_options = array('entity' => $user);

	switch($section){
		case 'widgets':
			$body .= elgg_view_layout('widgets', $view_options);
			break;

		case 'friends':
			$body .= elgg_view('profile/profile_contents/friends', $view_options);
			break;

		case 'twitter':
			$body .= elgg_view('profile/profile_contents/twitter', $view_options);
			break;

		case 'details':
			$body .= elgg_view('profile/profile_contents/details', $view_options);
			break;

		default:
		case 'activity':
			$body .= elgg_view('profile/profile_contents/activity', $view_options);
			break;
	}

	$body .= elgg_view('profile/profile_contents/sidebar');
	return $body;
}

/**
 * Dispatch the html for the edit section
 *
 * @param unknown_type $user
 * @param unknown_type $page
 * @return string
 */
function profile_get_user_edit_content($user, $page) {
	$section = (isset($page[2])) ? $page[2] : 'details';
	$content = elgg_view('profile/profile_navigation', array('section' => $section, 'entity' => $user));

	switch ($section) {
		case 'icon':
			$content .= elgg_view_title(elgg_echo('profile:edit'));
			$content .= elgg_view("profile/editicon", array('entity' => $user));
			break;
		default:
		case 'details':
			$content = elgg_view_title(elgg_echo('profile:edit'));
			$content .= elgg_view("profile/edit", array('entity' => $user));
			break;
	}

	return $content;
}