4 * ContribTracker plugin
6 * Copyright 2009, Roland Mas
10 require_once('../../env.inc.php');
11 require_once $gfwww.'include/pre.php';
12 $plugin = plugin_get_object ('contribtracker') ;
14 function display_contribution ($c, $show_groups = false) {
16 print '<h2>'.$c->getName().'</h2>' ;
18 print '<strong>'._('Project:').'</strong> ' ;
19 print util_make_link_g ($c->getGroup()->getUnixName(),
20 $c->getGroup()->getId(),
21 htmlspecialchars ($c->getGroup()->getPublicName())) ;
25 print '<strong>'._('Date:').'</strong> ' ;
26 print strftime (_('%Y-%m-%d'), $c->getDate ()) ;
29 print '<strong>'._('Description:').'</strong> ' ;
30 print htmlspecialchars ($c->getDescription ()) ;
33 $parts = $c->getParticipations () ;
34 print '<strong>'.ngettext('Participant:',
36 count ($parts)).'</strong> ' ;
39 foreach ($parts as $p) {
41 printf (_('%s: %s (%s)'),
42 htmlspecialchars ($p->getRole()->getName()),
43 util_make_link ('/plugins/'.$plugin->name.'/?actor_id='.$p->getActor()->getId (),
44 htmlspecialchars ($p->getActor()->getName())),
45 htmlspecialchars ($p->getActor()->getLegalStructure()->getName())) ;
46 if ($p->getActor()->getLogo() != '') {
48 print util_make_link ('/plugins/'.$plugin->name.'/?actor_id='.$p->getActor()->getId (),
49 '<img type="image/png" src="'.util_make_url ('/plugins/'.$plugin->name.'/actor_logo.php?actor_id='.$p->getActor()->getId ()).'" />') ;
56 $group_id = getIntFromRequest ('group_id') ;
57 $actor_id = getIntFromRequest ('actor_id') ;
59 $group = group_get_object ($group_id) ;
60 if(!$group || !is_object ($group)) {
63 if (!$group->isPublic()) {
64 $perm =& $group->getPermission(session_get_user());
66 if (!$perm || !is_object($perm) || !$perm->isMember()) {
71 $contrib_id = getIntFromRequest ('contrib_id') ;
72 if ($contrib_id) { // List only one particular contribution
73 $contrib = new ContribTrackerContribution ($contrib_id) ;
74 if (!$contrib || !is_object ($contrib)
75 || $contrib->getGroup()->getId() != $group_id) {
76 exit_permission_denied () ;
80 $params['toptab'] = 'contribtracker' ;
81 $params['group'] = $group_id ;
82 $params['title'] = _('Contribution details') ;
83 $params['pagename'] = 'contribtracker' ;
84 $params['sectionvals'] = array($group->getPublicName());
86 site_project_header ($params) ;
88 display_contribution ($contrib) ;
89 } else { // List all contributions relevant to a group
91 $params['toptab'] = 'contribtracker' ;
92 $params['group'] = $group_id ;
93 $params['title'] = sprintf (_('Contributions for project %s'),
94 htmlspecialchars ($group->getPublicName()));
95 $params['pagename'] = 'contribtracker' ;
96 $params['sectionvals'] = array($group->getPublicName());
98 site_project_header ($params) ;
100 $contribs = $plugin->getContributionsByGroup ($group) ;
102 if (count ($contribs) == 0) {
103 print '<h1>'._('No contributions').'</h1>' ;
104 print _('No contributions have been recorded for this project yet.') ;
106 print '<h1>'.sprintf (_('Contributions for project %s'),
107 htmlspecialchars ($group->getPublicName())).'</h1>' ;
109 foreach ($contribs as $c) {
110 display_contribution ($c) ;
115 } elseif ($actor_id) {
116 $actor = new ContribTrackerActor ($actor_id) ;
117 if (!is_object ($actor) || $actor->isError()) {
118 exit_error (_('Invalid actor'),
119 _('Invalid actor specified.')) ;
122 $HTML->header(array('title'=>_('Actor details'),'pagename'=>'contribtracker'));
124 print '<h1>'.sprintf(_('Actor details for %s'),
125 htmlspecialchars($actor->getName())).'</h1>' ;
127 print '<li><strong>'._('Name:').'</strong> '.htmlspecialchars($actor->getName()).'</li>' ;
128 print '<li><strong>'._('URL:').'</strong> ' ;
129 if ($actor->getUrl() != '') {
130 print '<a href="'.htmlspecialchars($actor->getUrl()).'">'.htmlspecialchars($actor->getUrl()).'</a>';
133 print '<li><strong>'._('Email:').'</strong> '.htmlspecialchars($actor->getEmail()).'</li>' ;
134 print '<li><strong>'._('Legal structure:').'</strong> '.htmlspecialchars($actor->getLegalStructure()->getName()).'</li>' ;
135 print '<li><strong>'._('Description:').'</strong> '.htmlspecialchars($actor->getDescription()).'</li>' ;
137 if ($actor->getLogo() != '') {
138 if ($actor->getUrl() != '') {
139 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>' ;
141 print '<img type="image/png" src="'.util_make_url ('/plugins/'.$plugin->name.'/actor_logo.php?actor_id='.$actor->getId ()).'" />' ;
145 $participations = $actor->getParticipations () ;
147 if (count ($participations) == 0) {
148 printf (_("%s hasn't been involved in any contributions yet"),
149 htmlspecialchars($actor->getName())) ;
151 print '<h1>'.sprintf(ngettext('Contribution by %s',
152 'Contributions by %s',
153 count($participations)),
154 htmlspecialchars($actor->getName())).'</h1>' ;
156 foreach ($participations as $p) {
157 $c = $p->getContribution () ;
158 print '<h2>' . util_make_link ('/plugins/'.$plugin->name.'/?group_id='.$c->getGroup()->getId().'&contrib_id='.$c->getId (),
159 htmlspecialchars ($c->getName())) . '</h2>' ;
160 print '<strong>'._('Project:').'</strong> ' ;
161 print util_make_link_g ($c->getGroup()->getUnixName(),
162 $c->getGroup()->getId(),
163 $c->getGroup()->getPublicName()) ;
164 print '<br /><strong>'._('Role:').'</strong> ' ;
165 print htmlspecialchars ($p->getRole()->getName()) ;
169 } else { // Latest contributions, globally
170 $HTML->header(array('title'=>_('Contributions'),'pagename'=>'contribtracker'));
172 $contribs = $plugin->getContributions () ;
174 if (count ($contribs) == 0) {
175 print '<h1>'._('No contributions').'</h1>' ;
176 print _('No contributions have been recorded yet.') ;
178 print '<h1>'._('Latest contributions').'</h1>' ;
181 foreach ($contribs as $c) {
182 display_contribution ($c, true) ;
192 site_project_footer(array());
196 // c-file-style: "bsd"