aboutsummaryrefslogtreecommitdiff
path: root/mod/groups/views/default/groups/groupprofile.php
blob: 42928a12fbb1ebfd658d243ec7ce0abe8c3b2686 (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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
<?php
/**
 * Elgg groups plugin full profile view.
 *
 * @package ElggGroups
 */


$user = get_loggedin_user();
elgg_push_breadcrumb(elgg_echo('groups:all'), elgg_get_site_url()."pg/groups/world");

// action or page url => label
$actions = array();

if ($vars['entity']->canEdit()) {
	// breadcrumb trail
	elgg_push_breadcrumb(elgg_echo('groups:yours'), elgg_get_site_url()."pg/groups/member/{$user->username}");
	
	// edit and invite
	$url = elgg_get_site_url() . "mod/groups/edit.php?group_guid={$vars['entity']->getGUID()}";
	$actions[$url] = elgg_echo('groups:edit');
	$url = elgg_get_site_url() . "mod/groups/invite.php?group_guid={$vars['entity']->getGUID()}";
	$actions[$url] = elgg_echo('groups:invite');
} 

if ($vars['entity']->isMember($user)) {
	// breadcrumb trail
	elgg_push_breadcrumb(elgg_echo('groups:yours'), elgg_get_site_url()."pg/groups/member/{$user->username}");
	
	// leave
	$url = elgg_get_site_url() . "action/groups/leave?group_guid={$vars['entity']->getGUID()}";
	$url = elgg_add_action_tokens_to_url($url);
	$actions[$url] = elgg_echo('groups:leave');
} else {
	// join
	// admins can always join.
	if ($vars['entity']->isPublicMembership() || $vars['entity']->canEdit()) {
		$url = elgg_get_site_url() . "action/groups/join?group_guid={$vars['entity']->getGUID()}";
		$url = elgg_add_action_tokens_to_url($url);
		$actions[$url] = elgg_echo('groups:join');
	} else {
		// request membership
		$url = elgg_get_site_url() . "action/groups/joinrequest?group_guid={$vars['entity']->getGUID()}";
		$url = elgg_add_action_tokens_to_url($url);
		$actions[$url] = elgg_echo('groups:joinrequest');
	}
}


// build action buttons
$action_buttons = '';
if (!empty($actions)) {
	$action_buttons = '<div class="content-header-options">';
	foreach ($actions as $url => $action) {
		$action_buttons .= "<a class=\"action-button\" href=\"$url\">$action</a>";
	}
	$action_buttons .= '</div>';
}

// display breadcrumb
elgg_push_breadcrumb($vars['entity']->name);
echo elgg_view('navigation/breadcrumbs');

// build and display header
echo <<<__HTML
<div id="content_header" class="clearfix">
	<div class="content-header-title">
		<h2>{$vars['entity']->name}</h2>
	</div>
	$action_buttons
</div>
__HTML;

?>
<div class="group_profile clearfix">
	<div class="group_profile_column icon">
		<div class="group_profile_icon">
		<?php
		echo elgg_view(
			"groups/icon", array(
			'entity' => $vars['entity'],
			'size' => 'large',
			));
		?>
		</div>

		<div class="group_stats">
			<?php
				echo "<p><b>" . elgg_echo("groups:owner") . ": </b><a href=\"" . get_user($vars['entity']->owner_guid)->getURL() . "\">" . get_user($vars['entity']->owner_guid)->name . "</a></p>";
			?>
			<p><?php
				$count = $vars['entity']->getMembers(0, 0, TRUE);
				echo elgg_echo('groups:members') . ": " . $count;

			?></p>
		</div>
	</div>

	<div class="group_profile_column info">
		<?php
			if ($vars['full'] == true) {
				if (is_array($vars['config']->group) && sizeof($vars['config']->group) > 0){

					foreach($vars['config']->group as $shortname => $valtype) {
						if ($shortname != "name") {
							$value = $vars['entity']->$shortname;

							if (!empty($value)) {
								//This function controls the alternating class
								$even_odd = ( 'odd' != $even_odd ) ? 'odd' : 'even';
							}

							echo "<p class=\"{$even_odd}\">";
							echo "<b>";
							echo elgg_echo("groups:{$shortname}");
							echo ": </b>";

							$options = array(
								'value' => $vars['entity']->$shortname
							);

							if ($valtype == 'tags') {
								$options['tag_names'] = $shortname;
							}

							echo elgg_view("output/{$valtype}", $options);

							echo "</p>";
						}
					}
				}
			}
		?>
	</div>
</div>