4 * ContribTracker plugin
6 * Copyright 2009, Roland Mas
7 * Copyright 2010 (c) Franck Villaume
8 * http://fusionforge.org/
10 * This file is part of FusionForge.
12 * FusionForge is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or
15 * (at your option) any later version.
17 * FusionForge is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
22 * You should have received a copy of the GNU General Public License along
23 * with this program; if not, write to the Free Software Foundation, Inc.,
24 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
27 require_once '../../env.inc.php';
28 require_once $gfcommon.'include/pre.php';
29 $plugin = plugin_get_object ('contribtracker');
31 function display_contribution ($c, $show_groups = false) {
33 print '<h2>'.$c->getName().'</h2>';
35 print '<strong>'._('Project')._(':').'</strong> ';
36 print util_make_link_g ($c->getGroup()->getUnixName(),
37 $c->getGroup()->getId(),
38 htmlspecialchars ($c->getGroup()->getPublicName()));
42 print '<strong>'._('Date')._(':').'</strong> ';
43 print strftime (_('%Y-%m-%d'), $c->getDate ());
46 print '<strong>'._('Description')._(':').'</strong> ';
47 print htmlspecialchars ($c->getDescription ());
50 $parts = $c->getParticipations ();
51 print '<strong>'.ngettext('Participant:',
53 count ($parts)).'</strong> ';
56 foreach ($parts as $p) {
58 printf (_('%s: %s (%s)'),
59 htmlspecialchars ($p->getRole()->getName()),
60 util_make_link ('/plugins/'.$plugin->name.'/?actor_id='.$p->getActor()->getId (),
61 htmlspecialchars ($p->getActor()->getName())),
62 htmlspecialchars ($p->getActor()->getLegalStructure()->getName()));
63 if ($p->getActor()->getLogo() != '') {
65 print util_make_link ('/plugins/'.$plugin->name.'/?actor_id='.$p->getActor()->getId (),
66 '<img type="image/png" src="'.util_make_url ('/plugins/'.$plugin->name.'/actor_logo.php?actor_id='.$p->getActor()->getId ()).'" />');
73 $group_id = getIntFromRequest('group_id');
74 $actor_id = getIntFromRequest('actor_id');
76 $group = group_get_object($group_id);
77 if(!$group || !is_object ($group)) {
80 session_require_perm ('project_read', $group_id);
82 $contrib_id = getIntFromRequest ('contrib_id');
83 if ($contrib_id) { // List only one particular contribution
84 $contrib = new ContribTrackerContribution ($contrib_id);
85 if (!$contrib || !is_object ($contrib)
86 || $contrib->getGroup()->getId() != $group_id) {
87 exit_permission_denied ('','home');
91 $params['toptab'] = 'contribtracker';
92 $params['group'] = $group_id;
93 $params['title'] = _('Contribution details');
94 $params['pagename'] = 'contribtracker';
95 $params['sectionvals'] = array($group->getPublicName());
97 site_project_header ($params);
99 display_contribution ($contrib);
100 } else { // List all contributions relevant to a group
102 $params['toptab'] = 'contribtracker';
103 $params['group'] = $group_id;
104 $params['title'] = sprintf (_('Contributions for project %s'),
105 htmlspecialchars ($group->getPublicName()));
106 $params['pagename'] = 'contribtracker';
107 $params['sectionvals'] = array($group->getPublicName());
109 site_project_header($params);
111 $contribs = $plugin->getContributionsByGroup ($group);
113 if (count ($contribs) == 0) {
114 print '<h1>'._('No contributions').'</h1>';
115 print _('No contributions have been recorded for this project yet.');
117 foreach ($contribs as $c) {
118 display_contribution ($c);
123 } elseif ($actor_id) {
124 $actor = new ContribTrackerActor ($actor_id);
125 if (!is_object ($actor) || $actor->isError()) {
126 exit_error (_('Invalid actor'),'contribtracker');
129 $HTML->header(array('title'=>_('Actor details'),'pagename'=>'contribtracker'));
131 print '<h1>'.sprintf(_('Actor details for %s'),
132 htmlspecialchars($actor->getName())).'</h1>';
134 print '<li><strong>'._('Name')._(':').'</strong> '.htmlspecialchars($actor->getName()).'</li>';
135 print '<li><strong>'._('URL')._(':').'</strong> ';
136 if ($actor->getUrl() != '') {
137 print '<a href="'.htmlspecialchars($actor->getUrl()).'">'.htmlspecialchars($actor->getUrl()).'</a>';
140 print '<li><strong>'._('Email')._(':').'</strong> '.htmlspecialchars($actor->getEmail()).'</li>';
141 print '<li><strong>'._('Legal structure')._(':').'</strong> '.htmlspecialchars($actor->getLegalStructure()->getName()).'</li>';
142 print '<li><strong>'._('Description')._(':').'</strong> '.htmlspecialchars($actor->getDescription()).'</li>';
144 if ($actor->getLogo() != '') {
145 if ($actor->getUrl() != '') {
146 print '<a href="'.htmlspecialchars($actor->getUrl()).'"><img type="image/png" src="'.util_make_url ('/plugins/'.$plugin->name.'/actor_logo.php?actor_id='.$actor->getId ()).'" /></a>';
148 print '<img type="image/png" src="'.util_make_url ('/plugins/'.$plugin->name.'/actor_logo.php?actor_id='.$actor->getId ()).'" />';
152 $participations = $actor->getParticipations ();
154 if (count ($participations) == 0) {
155 printf (_("%s hasn't been involved in any contributions yet"),
156 htmlspecialchars($actor->getName()));
158 print '<h1>'.sprintf(ngettext('Contribution by %s',
159 'Contributions by %s',
160 count($participations)),
161 htmlspecialchars($actor->getName())).'</h1>';
163 foreach ($participations as $p) {
164 $c = $p->getContribution ();
165 print '<h2>' . util_make_link ('/plugins/'.$plugin->name.'/?group_id='.$c->getGroup()->getId().'&contrib_id='.$c->getId (),
166 htmlspecialchars ($c->getName())) . '</h2>';
167 print '<strong>'._('Project')._(':').'</strong> ';
168 print util_make_link_g ($c->getGroup()->getUnixName(),
169 $c->getGroup()->getId(),
170 $c->getGroup()->getPublicName());
171 print '<br /><strong>'._('Role')._(':').'</strong> ';
172 print htmlspecialchars ($p->getRole()->getName());
176 } else { // Latest contributions, globally
177 $HTML->header(array('title'=>_('Contributions'),'pagename'=>'contribtracker'));
179 $contribs = $plugin->getContributions ();
181 if (count ($contribs) == 0) {
182 print '<h1>'._('No contributions').'</h1>';
183 print _('No contributions have been recorded yet.');
185 print '<h1>'._('Latest contributions').'</h1>';
188 foreach ($contribs as $c) {
189 display_contribution ($c, true);
199 site_project_footer(array());
203 // c-file-style: "bsd"