File: Widget_ProjectMembers.class.php

package info (click to toggle)
fusionforge 5.3.2%2B20141104-3
  • links: PTS, VCS
  • area: main
  • in suites: jessie-kfreebsd
  • size: 60,472 kB
  • sloc: php: 271,846; sql: 36,817; python: 14,575; perl: 6,406; sh: 5,980; xml: 4,294; pascal: 1,411; makefile: 911; cpp: 52; awk: 27
file content (126 lines) | stat: -rw-r--r-- 4,005 bytes parent folder | download | duplicates (4)
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
<?php
/**
 * Copyright (c) Xerox Corporation, Codendi Team, 2001-2009. All rights reserved
 * Copyright (C) 2012 Alain Peyrat - Alcatel-Lucent
 *
 * This file is a part of Fusionforge.
 *
 * Fusionforge 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.
 *
 * Fusionforge 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.
 *
 * You should have received a copy of the GNU General Public License
 * along with Codendi. If not, see <http://www.gnu.org/licenses/>.
 */

require_once 'Widget.class.php';

/**
 * Widget_ProjectMembers
 */
class Widget_ProjectMembers extends Widget {
	public function __construct() {
		$this->Widget('projectmembers');
	}

	public function getTitle() {
		return _('Project Members');
	}

	public function getContent() {
		$request =& HTTPRequest::instance();
		$group_id = $request->get('group_id');
		$pm = ProjectManager::instance();
		$project = $pm->getProject($group_id);

		$admins = $project->getAdmins() ;
		$members = $project->getUsers() ;
		$seen = array () ;

		$iam_member = false ;
		if (count($admins) > 0) {
			echo '<span class="develtitle">'._('Project Admins').'</span><br />';
			foreach ($admins as $u) {
				echo '<div rel="doap:maintainer">'."\n";
				// A foaf:Person that holds an account on the forge
				$developer_url = util_make_url_u ($u->getUnixName(),$u->getID());
				echo '<div typeof="foaf:Person" about="'.
					$developer_url.'#person' .'" >'."\n";
				echo '<div rel="foaf:account">'."\n";
				echo '<div typeof="sioc:UserAccount" about="'.
					$developer_url.
					'">'."\n";
				echo util_display_user($u->getUnixName(),$u->getID(),$u->getRealName())."\n";
				echo "</div>\n"; // /sioc:UserAccount
				echo "</div>\n"; // /foaf:holdsAccount
				echo "</div>\n"; // /foaf:Person
				echo "</div>\n"; // /doap:maintainer|developer
				if ($u->getID() == user_getid()) {
					$iam_member = true ;
				}
				$seen[] = $u->getID() ;
			}
		}
		$seen_member = false ;
		if (count($members) > 0) {
			foreach ($members as $u) {
				if (in_array ($u->getID(), $seen)) {
					continue ;
				}
				if (!$seen_member) {
					echo '<span class="develtitle">'. _('Members')._(':').'</span><br />';
					$seen_member = true ;
				}
				echo '<div rel="doap:developer">'."\n";
				// A foaf:Person that holds an account on the forge
				$developer_url = util_make_url_u ($u->getUnixName(),$u->getID());
				echo '<div typeof="foaf:Person" about="'.
					$developer_url.'#person' .'" >'."\n";
				echo '<div rel="foaf:account">'."\n";
				echo '<div typeof="sioc:UserAccount" about="'.
					$developer_url.
					'">'."\n";
				echo util_display_user($u->getUnixName(),$u->getID(),$u->getRealName())."\n";
				echo "</div>\n"; // /sioc:UserAccount
				echo "</div>\n"; // /foaf:holdsAccount
				echo "</div>\n"; // /foaf:Person
				echo "</div>\n"; // /doap:maintainer|developer
				if ($u->getID() == user_getid()) {
					$iam_member = true ;
				}
			}
		}

		echo '<p><span rel="sioc:has_usergroup">';
		echo '<span about="members/" typeof="sioc:UserGroup">';
		echo '<span rel="http://www.w3.org/2002/07/owl#sameAs">';
		echo util_make_link ('/project/memberlist.php?group_id='.$group_id,sprintf(_('View the %d Member(s)'),count($members)));
		echo '</span>';
		echo '</span>';
		echo '</span></p>';
		// end of project usergroup description

		if (!$iam_member) {
			echo '<p>'.util_make_link ('/project/request.php?group_id='.$group_id,_('Request to join')).'</p>';
		}
	}

	public function canBeUsedByProject(&$project) {
		return true;
	}

	function getDescription() {
		return _('List the project members.');
	}
}

// Local Variables:
// mode: php
// c-file-style: "bsd"
// End: