gforge/plugins/contribtracker/common/ContribTrackerPlugin.class.php -text
gforge/plugins/contribtracker/common/contribtracker-init.php -text
gforge/plugins/contribtracker/lib/contribtracker-init.sql -text
+gforge/plugins/contribtracker/www/actor_logo.php -text
gforge/plugins/contribtracker/www/global_admin.php -text
gforge/plugins/contribtracker/www/index.php -text
gforge/plugins/contribtracker/www/project_admin.php -text
usort ($contribs, array ($this, "ContribComparator")) ;
if (count ($contribs) == 0) {
- echo '<tr><td colspan="5"><strong>'._('This Project Has Not Released Any Files').'</strong></td></tr>';
+ echo '<tr><td colspan="5"><strong>'._('No contributions have been recorded for this project yet.').'</strong></td></tr>';
} else {
$max_displayed_contribs = 3 ;
$i = 1 ;
util_make_link ('/plugins/'.$this->name.'/?actor_id='.$p->getActor()->getId (),
htmlspecialchars ($p->getActor()->getName())),
htmlspecialchars ($p->getActor()->getLegalStructure()->getName())) ;
+ if ($p->getActor()->getLogo() != '') {
+ print ' <img type="image/png" src="'.util_make_url ('/plugins/'.$this->name.'/actor_logo.php?actor_id='.$p->getActor()->getId ()).'" />' ;
+ }
echo '</li>' ;
}
echo '</ul></td></tr>' ;
return true ;
}
- function create ($name, $address, $email, $description, $structure) {
+ function create ($name, $address, $email, $description, $logo, $structure) {
if ($this->getId ()) {
$this->setError(_('Object already exists')) ;
return false ;
}
db_begin () ;
- $res = db_query_params ('INSERT INTO plugin_contribtracker_actor (name,address,email,description,struct_id) VALUES ($1,$2,$3,$4,$5)',
+ $res = db_query_params ('INSERT INTO plugin_contribtracker_actor (name,address,email,description,logo,struct_id) VALUES ($1,$2,$3,$4,$5,$6)',
array ($name,
$address,
$email,
$description,
+ base64_encode ($logo),
$structure->getID())) ;
if (!$res || db_affected_rows ($res) < 1) {
$this->setError (sprintf(_('Could not create object in database: %s'),
return $this->fetchData ($id) ;
}
- function update ($name, $address, $email, $description, $structure) {
+ function update ($name, $address, $email, $description, $logo, $structure) {
if (! $this->getId ()) {
$this->setError(_('Object does not exist')) ;
return false ;
$id = $this->getId () ;
db_begin () ;
- $res = db_query_params ('UPDATE plugin_contribtracker_actor SET (name,address,email,description,struct_id) = ($1,$2,$3,$4,$5) WHERE actor_id = $6',
+ $res = db_query_params ('UPDATE plugin_contribtracker_actor SET (name,address,email,description,logo,struct_id) = ($1,$2,$3,$4,$5,$6) WHERE actor_id = $7',
array ($name,
$address,
$email,
$description,
+ base64_encode ($logo),
$structure->getID(),
$id)) ;
if (!$res || db_affected_rows ($res) < 1) {
function getLegalStructure () {
return new ContribTrackerLegalStructure ($this->data_array['struct_id']) ;
}
+ function getLogo () { return base64_decode ($this->data_array['logo']) ; }
function getParticipations () {
$res = db_query_params ('SELECT participation_id FROM plugin_contribtracker_participation WHERE actor_id = $1',
address text DEFAULT '' NOT NULL,
email text DEFAULT '' NOT NULL,
description text DEFAULT '' NOT NULL,
+ logo text DEFAULT '' NOT NULL,
struct_id integer NOT NULL REFERENCES plugin_contribtracker_legal_structure
) ;
--- /dev/null
+<?php
+
+/*
+ * ContribTracker plugin
+ *
+ * Copyright 2009, Roland Mas
+ *
+ */
+
+require_once('../../env.inc.php');
+require_once $gfwww.'include/pre.php';
+$plugin = plugin_get_object ('contribtracker') ;
+
+$actor_id = getIntFromRequest ('actor_id') ;
+
+if ($actor_id) {
+ $actor = new ContribTrackerActor ($actor_id) ;
+ if (!is_object ($actor) || $actor->isError()) {
+ exit_error (_('Invalid actor'),
+ _('Invalid actor specified')) ;
+ }
+ Header ("Content-type: image/png");
+ echo $actor->getLogo();
+} else {
+ exit_error (_('Invalid actor'),
+ _('Invalid actor specified')) ;
+}
+
+// Local Variables:
+// mode: php
+// c-file-style: "bsd"
+// End:
+
+?>
exit_permission_denied () ;
}
}
-
+function check_logo ($arr, $a_id=false) {
+ if ($a_id) {
+ $actor = new ContribTrackerActor ($a_id) ;
+ $default = $actor->getLogo() ;
+ } else {
+ $default = '' ;
+ }
+ if ($arr['tmp_name'] == '') {
+ $logo = $default ;
+ } else {
+ if ($arr['size'] > 10240) {
+ $logo = $default ;
+ } else {
+ $logo = file_get_contents ($arr['tmp_name'], 0, NULL, -1, 10240) ;
+ }
+ unlink ($arr['tmp_name']) ;
+ }
+ return $logo ;
+}
// Get and validate parameters, error if tampered with
switch ($action) {
$address = getStringFromRequest ('actor_address') ;
$email = getStringFromRequest ('actor_email') ;
$desc = getStringFromRequest ('actor_desc') ;
+ $logoarr = getUploadedFile ('actor_logo') ;
+ $logo = check_logo ($logoarr) ;
$structure_id = getIntFromRequest ('structure_id') ;
check_structure_id ($structure_id) ;
break ;
$address = getStringFromRequest ('actor_address') ;
$email = getStringFromRequest ('actor_email') ;
$desc = getStringFromRequest ('actor_desc') ;
+ $logoarr = getUploadedFile ('actor_logo') ;
+ $logo = check_logo ($logoarr, $actor_id) ;
$structure_id = getIntFromRequest ('structure_id') ;
check_structure_id ($structure_id) ;
break ;
case 'post_add_actor':
$actor = new ContribTrackerActor () ;
$structure = new ContribTrackerLegalStructure ($structure_id) ;
- if (!$actor->create ($name, $address, $email, $desc, $structure)) {
+ if (!$actor->create ($name, $address, $email, $desc, $logo, $structure)) {
exit_error ($actor->getErrorMessage()) ;
}
$actor_id = $actor->getId() ;
case 'post_edit_actor':
$actor = new ContribTrackerActor ($actor_id) ;
$structure = new ContribTrackerLegalStructure ($structure_id) ;
- $actor->update ($name, $address, $email, $desc, $structure) ;
+ $actor->update ($name, $address, $email, $desc, $logo, $structure) ;
$action = 'display' ;
break ;
}
print '<td><strong>'._('Postal address').'</strong></td>' ;
print '<td><strong>'._('Email').'</strong></td>' ;
print '<td><strong>'._('Description').'</strong></td>' ;
+ print '<td><strong>'._('Logo').'</strong></td>' ;
print '<td><strong>'._('Legal structure').'</strong></td>' ;
print '<td><strong>'._('Actions').'</strong></td>' ;
print '</tr></thead><tbody>' ;
print '<td>'.htmlspecialchars($a->getAddress()).'</td>' ;
print '<td>'.htmlspecialchars($a->getEmail()).'</td>' ;
print '<td>'.htmlspecialchars($a->getDescription()).'</td>' ;
+ print '<td>' ;
+ if ($a->getLogo() != '') {
+ print '<img type="image/png" src="'.util_make_url ('/plugins/'.$plugin->name.'/actor_logo.php?actor_id='.$a->getId ()).'" />' ;
+ }
+ print '</td>' ;
print '<td>'.htmlspecialchars($a->getLegalStructure()->getName()).'</td>' ;
?>
<td>
case 'add_actor':
print '<h1>'._('Register a new actor').'</h1>' ;
?>
- <form action="<?php echo util_make_url ('/plugins/'.$plugin->name.'/global_admin.php') ?>" method="post">
+ <form action="<?php echo util_make_url ('/plugins/'.$plugin->name.'/global_admin.php') ?>" method="post" enctype="multipart/form-data">
<input type="hidden" name="action" value="post_add_actor" />
<?php echo _('Actor name:') ?> <input type="text" name="actor_name" size="20" /><br />
<?php echo _('Actor address:') ?> <input type="text" name="actor_address" size="20" /><br />
<?php echo _('Actor email:') ?> <input type="text" name="actor_email" size="20" /><br />
<?php echo _('Actor description:') ?><br />
<textarea name="actor_desc" rows="20" cols="80"></textarea><br />
+ <?php echo _('Actor logo (PNG, 10 kB max.):') ?> <input type="file" name="actor_logo" /><br />
<?php
echo _('Legal structure:') ?>
<select name="structure_id">
$actor = new ContribTrackerActor ($actor_id) ;
?>
- <form action="<?php echo util_make_url ('/plugins/'.$plugin->name.'/global_admin.php') ?>" method="post">
+ <form action="<?php echo util_make_url ('/plugins/'.$plugin->name.'/global_admin.php') ?>" method="post" enctype="multipart/form-data">
<input type="hidden" name="action" value="post_edit_actor" />
<input type="hidden" name="actor_id" value="<?php echo $actor->getId() ?>" />
<?php echo _('Actor name:') ?> <input type="text" name="actor_name" size="20" value="<?php echo htmlspecialchars ($actor->getName()) ?>" /><br />
<?php echo _('Actor email:') ?> <input type="text" name="actor_email" size="20" value="<?php echo htmlspecialchars ($actor->getEmail()) ?>" /><br />
<?php echo _('Actor description:') ?><br />
<textarea name="actor_desc" rows="20" cols="80"><?php echo htmlspecialchars ($actor->getDescription()) ?></textarea><br />
+ <?php echo _('Actor logo (PNG, 10 kB max.):') ?> <input type="file" name="actor_logo" />
<?php
+ if ($actor->getLogo() != '') {
+ print '<img type="image/png" src="'.util_make_url ('/plugins/'.$plugin->name.'/actor_logo.php?actor_id='.$actor->getId ()).'" />' ;
+ }
+ print '<br />' ;
echo _('Legal structure:') ?>
<select name="structure_id">
<?php
util_make_link ('/plugins/'.$plugin->name.'/?actor_id='.$p->getActor()->getId (),
htmlspecialchars ($p->getActor()->getName())),
htmlspecialchars ($p->getActor()->getLegalStructure()->getName())) ;
+ if ($p->getActor()->getLogo() != '') {
+ print ' <img type="image/png" src="'.util_make_url ('/plugins/'.$plugin->name.'/actor_logo.php?actor_id='.$p->getActor()->getId ()).'" />' ;
+ }
print '</li>' ;
}
print '</ul>' ;
print '<li><strong>'._('Legal structure:').'</strong> '.htmlspecialchars($actor->getLegalStructure()->getName()).'</li>' ;
print '<li><strong>'._('Description:').'</strong> '.htmlspecialchars($actor->getDescription()).'</li>' ;
print '</ul>' ;
+ if ($actor->getLogo() != '') {
+ print '<img type="image/png" src="'.util_make_url ('/plugins/'.$plugin->name.'/actor_logo.php?actor_id='.$actor->getId ()).'" />' ;
+ }
$participations = $actor->getParticipations () ;