/usr/share/gforge/plugins/contribtracker/www/global_admin.php is in fusionforge-plugin-contribtracker 5.3.2+20141104-3+deb8u3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 | <?php
/**
* ContribTracker plugin
*
* Copyright 2009, Roland Mas
* Copyright 2010 (c) Franck Villaume
* http://fusionforge.org/
*
* This file is 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 this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
require_once '../../env.inc.php';
require_once $gfcommon.'include/pre.php';
require_once $gfwww.'admin/admin_utils.php';
$plugin = plugin_get_object ('contribtracker') ;
$max_logo_size = 50 ; // In kibibytes
session_require_global_perm ('forge_admin') ;
$action = getStringFromRequest ('action') ;
$action = util_ensure_value_in_set ($action, array ('display',
'add_role',
'add_actor',
'add_structure',
'post_add_role',
'post_add_actor',
'post_add_structure',
'edit_role',
'edit_actor',
'edit_structure',
'post_edit_role',
'post_edit_actor',
'post_edit_structure',
'del_role',
'del_actor',
'del_structure')) ;
function check_role_id ($r_id) {
$role = new ContribTrackerRole ($r_id) ;
if (!$role || !is_object ($role)) {
exit_permission_denied ('','home') ;
}
}
function check_actor_id ($a_id) {
$actor = new ContribTrackerActor ($a_id) ;
if (!$actor || !is_object ($actor)) {
exit_permission_denied ('','home') ;
}
}
function check_structure_id ($s_id) {
$structure = new ContribTrackerLegalStructure ($s_id) ;
if (!$structure || !is_object ($structure)) {
exit_permission_denied ('','home') ;
}
}
function check_logo ($arr, $a_id=false) {
global $max_logo_size ;
if ($a_id) {
$actor = new ContribTrackerActor ($a_id) ;
$default = $actor->getLogo() ;
} else {
$default = '' ;
}
if ($arr['tmp_name'] == '') {
$logo = $default ;
} else {
if ($arr['size'] > 1024 * $max_logo_size) {
$logo = $default ;
} else {
$logo = file_get_contents ($arr['tmp_name'], 0, NULL, -1, 1024 * $max_logo_size) ;
}
unlink ($arr['tmp_name']) ;
}
return $logo ;
}
// Get and validate parameters, error if tampered with
switch ($action) {
case 'display':
break ;
case 'add_role':
break ;
case 'post_add_role':
$name = getStringFromRequest ('role_name') ;
$desc = getStringFromRequest ('role_desc') ;
break ;
case 'edit_role':
case 'del_role':
$role_id = getIntFromRequest ('role_id') ;
check_role_id ($role_id) ;
break ;
case 'post_edit_role':
$role_id = getIntFromRequest ('role_id') ;
check_role_id ($role_id) ;
$name = getStringFromRequest ('role_name') ;
$desc = getStringFromRequest ('role_desc') ;
break ;
case 'add_structure':
break ;
case 'post_add_structure':
$name = getStringFromRequest ('structure_name') ;
$desc = getStringFromRequest ('structure_desc') ;
break ;
case 'edit_structure':
case 'del_structure':
$structure_id = getIntFromRequest ('structure_id') ;
check_structure_id ($structure_id) ;
break ;
case 'post_edit_structure':
$structure_id = getIntFromRequest ('structure_id') ;
check_structure_id ($structure_id) ;
$name = getStringFromRequest ('structure_name') ;
$desc = getStringFromRequest ('structure_desc') ;
break ;
case 'add_actor':
break ;
case 'post_add_actor':
$name = getStringFromRequest ('actor_name') ;
$url = getStringFromRequest ('actor_url') ;
$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 ;
case 'edit_actor':
case 'del_actor':
$actor_id = getIntFromRequest ('actor_id') ;
check_actor_id ($actor_id) ;
break ;
case 'post_edit_actor':
$actor_id = getIntFromRequest ('actor_id') ;
check_actor_id ($actor_id) ;
$name = getStringFromRequest ('actor_name') ;
$url = getStringFromRequest ('actor_url') ;
$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 ;
}
// Do the required action
switch ($action) {
case 'post_add_role':
$role = new ContribTrackerRole () ;
if (!$role->create ($name, $desc)) {
exit_error ($role->getErrorMessage(),'contribtracker') ;
}
$role_id = $role->getId() ;
$action = 'display' ;
break ;
case 'del_role':
$role = new ContribTrackerRole ($role_id) ;
$role->delete () ;
$action = 'display' ;
break ;
case 'post_edit_role':
$role = new ContribTrackerRole ($role_id) ;
$role->update ($name, $desc) ;
$action = 'display' ;
break ;
case 'post_add_structure':
$structure = new ContribTrackerLegalStructure () ;
if (!$structure->create ($name, $desc)) {
exit_error ($structure->getErrorMessage(),'contribtracker') ;
}
$structure_id = $structure->getId() ;
$action = 'display' ;
break ;
case 'del_structure':
$structure = new ContribTrackerLegalStructure ($structure_id) ;
$structure->delete () ;
$action = 'display' ;
break ;
case 'post_edit_structure':
$structure = new ContribTrackerLegalStructure ($structure_id) ;
$structure->update ($name, $desc) ;
$action = 'display' ;
break ;
case 'post_add_actor':
$actor = new ContribTrackerActor () ;
$structure = new ContribTrackerLegalStructure ($structure_id) ;
if (!$actor->create ($name, $url, $email, $desc, $logo, $structure)) {
exit_error ($actor->getErrorMessage(),'contribtracker') ;
}
$actor_id = $actor->getId() ;
$action = 'display' ;
break ;
case 'del_actor':
$actor = new ContribTrackerActor ($actor_id) ;
$actor->delete () ;
$action = 'display' ;
break ;
case 'post_edit_actor':
$actor = new ContribTrackerActor ($actor_id) ;
$structure = new ContribTrackerLegalStructure ($structure_id) ;
$actor->update ($name, $url, $email, $desc, $logo, $structure) ;
$action = 'display' ;
break ;
}
// Display appropriate forms
site_admin_header (array ('title' => _('Contribution tracker administration'))) ;
switch ($action) {
case 'display':
print '<h1>'._('Existing actors').'</h1>' ;
$actors = $plugin->getActors () ;
if (count ($actors)) {
print '<table><thead><tr>' ;
print '<td><strong>'._('Logo').'</strong></td>' ;
print '<td><strong>'._('Short name').'</strong></td>' ;
print '<td><strong>'._('URL').'</strong></td>' ;
print '<td><strong>'._('Email').'</strong></td>' ;
print '<td><strong>'._('Description').'</strong></td>' ;
print '<td><strong>'._('Legal structure').'</strong></td>' ;
print '<td><strong>'._('Actions').'</strong></td>' ;
print '</tr></thead><tbody>' ;
foreach ($actors as $a) {
print '<tr>';
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->getName()).'</td>' ;
print '<td>' ;
if ($a->getUrl() != '') {
print '<a href="'.htmlspecialchars($a->getUrl()).'">'.htmlspecialchars($a->getUrl()).'</a>';
}
print '</td>' ;
print '<td>'.htmlspecialchars($a->getEmail()).'</td>' ;
print '<td>'.htmlspecialchars($a->getDescription()).'</td>' ;
print '<td>'.htmlspecialchars($a->getLegalStructure()->getName()).'</td>' ;
?>
<td>
<form action="<?php echo util_make_url ('/plugins/'.$plugin->name.'/global_admin.php') ?>" method="post">
<input type="hidden" name="action" value="edit_actor" />
<input type="hidden" name="actor_id" value="<?php echo $a->getId () ?>" />
<input type="submit" name="submit" value="<?php echo _('Edit') ?>" />
</form>
<form action="<?php echo util_make_url ('/plugins/'.$plugin->name.'/global_admin.php') ?>" method="post">
<input type="hidden" name="action" value="del_actor" />
<input type="hidden" name="actor_id" value="<?php echo $a->getId () ?>" />
<input type="submit" name="submit" value="<?php echo _('Delete') ?>" />
</form>
</td>
<?php
print '</tr>';
}
print '</tbody></table>' ;
} else {
print _('No legal structures currently defined.') ;
}
$structs = $plugin->getLegalStructures () ;
if (count ($structs)) {
?>
<form action="<?php echo util_make_url ('/plugins/'.$plugin->name.'/global_admin.php') ?>" method="post">
<input type="hidden" name="action" value="add_actor" />
<input type="submit" name="submit" value="<?php echo _('Register new actor') ?>" />
</form>
<?php
} else {
print _("No legal structures yet, cannot define actors without them.") ;
}
print '<h1>'._('Existing legal structures').'</h1>' ;
$structs = $plugin->getLegalStructures () ;
if (count ($structs)) {
print '<table><thead><tr>' ;
print '<td><strong>'._('Short name').'</strong></td>' ;
print '<td><strong>'._('Actions').'</strong></td>' ;
print '</tr></thead><tbody>' ;
foreach ($structs as $s) {
print '<tr>';
print '<td>'.htmlspecialchars($s->getName()).'</td>' ;
?>
<td>
<form action="<?php echo util_make_url ('/plugins/'.$plugin->name.'/global_admin.php') ?>" method="post">
<input type="hidden" name="action" value="edit_structure" />
<input type="hidden" name="structure_id" value="<?php echo $s->getId () ?>" />
<input type="submit" name="submit" value="<?php echo _('Edit') ?>" />
</form>
<form action="<?php echo util_make_url ('/plugins/'.$plugin->name.'/global_admin.php') ?>" method="post">
<input type="hidden" name="action" value="del_structure" />
<input type="hidden" name="structure_id" value="<?php echo $s->getId () ?>" />
<input type="submit" name="submit" value="<?php echo _('Delete') ?>" />
</form>
</td>
<?php
print '</tr>';
}
print '</tbody></table>' ;
} else {
print _('No legal structures currently defined.') ;
}
?>
<form action="<?php echo util_make_url ('/plugins/'.$plugin->name.'/global_admin.php') ?>" method="post">
<input type="hidden" name="action" value="add_structure" />
<input type="submit" name="submit" value="<?php echo _('Register new legal structure') ?>" />
</form>
<?php
print '<h1>'._('Existing roles').'</h1>' ;
$roles = $plugin->getRoles () ;
if (count ($roles)) {
print '<table><thead><tr>' ;
print '<td><strong>'._('Short name').'</strong></td>' ;
print '<td><strong>'._('Description').'</strong></td>' ;
print '<td><strong>'._('Actions').'</strong></td>' ;
print '</tr></thead><tbody>' ;
foreach ($roles as $r) {
print '<tr>';
print '<td>'.htmlspecialchars($r->getName()).'</td>' ;
print '<td>'.htmlspecialchars($r->getDescription()).'</td>' ;
?>
<td>
<form action="<?php echo util_make_url ('/plugins/'.$plugin->name.'/global_admin.php') ?>" method="post">
<input type="hidden" name="action" value="edit_role" />
<input type="hidden" name="role_id" value="<?php echo $r->getId () ?>" />
<input type="submit" name="submit" value="<?php echo _('Edit') ?>" />
</form>
<form action="<?php echo util_make_url ('/plugins/'.$plugin->name.'/global_admin.php') ?>" method="post">
<input type="hidden" name="action" value="del_role" />
<input type="hidden" name="role_id" value="<?php echo $r->getId () ?>" />
<input type="submit" name="submit" value="<?php echo _('Delete') ?>" />
</form>
</td>
<?php
print '</tr>';
}
print '</tbody></table>' ;
} else {
print _('No roles currently defined.') ;
}
?>
<form action="<?php echo util_make_url ('/plugins/'.$plugin->name.'/global_admin.php') ?>" method="post">
<input type="hidden" name="action" value="add_role" />
<input type="submit" name="submit" value="<?php echo _('Register new role') ?>" />
</form>
<?php
break ;
case 'add_role':
print '<h1>'._('Register a new role').'</h1>' ;
?>
<form action="<?php echo util_make_url ('/plugins/'.$plugin->name.'/global_admin.php') ?>" method="post">
<input type="hidden" name="action" value="post_add_role" />
<?php echo _('Role Name')._(':') ?> <input type="text" name="role_name" size="20" /><br />
<?php echo _('Role description')._(':') ?><br />
<textarea name="role_desc" rows="20" cols="80"></textarea><br />
<input type="submit" name="submit" value="<?php echo _('Submit') ?>" />
</form>
<?php
break ;
case 'edit_role':
print '<h1>'._('Edit a role').'</h1>' ;
$role = new ContribTrackerRole ($role_id) ;
?>
<form action="<?php echo util_make_url ('/plugins/'.$plugin->name.'/global_admin.php') ?>" method="post">
<input type="hidden" name="action" value="post_edit_role" />
<input type="hidden" name="role_id" value="<?php echo $role->getId() ?>" />
<?php echo _('Role Name')._(':') ?> <input type="text" name="role_name" size="20" value="<?php echo htmlspecialchars ($role->getName()) ?>" /><br />
<?php echo _('Role description')._(':') ?><br />
<textarea name="role_desc" rows="20" cols="80"><?php echo htmlspecialchars ($role->getDescription()) ?></textarea><br />
<input type="submit" name="submit" value="<?php echo _('Save') ?>" />
</form>
<?php
break ;
case 'add_structure':
print '<h1>'._('Register a new legal structure').'</h1>' ;
?>
<form action="<?php echo util_make_url ('/plugins/'.$plugin->name.'/global_admin.php') ?>" method="post">
<input type="hidden" name="action" value="post_add_structure" />
<?php echo _('Structure name')._(':') ?> <input type="text" name="structure_name" size="20" /><br />
<input type="submit" name="submit" value="<?php echo _('Submit') ?>" />
</form>
<?php
break ;
case 'edit_structure':
print '<h1>'._('Edit a legal structure').'</h1>' ;
$structure = new ContribTrackerLegalStructure ($structure_id) ;
?>
<form action="<?php echo util_make_url ('/plugins/'.$plugin->name.'/global_admin.php') ?>" method="post">
<input type="hidden" name="action" value="post_edit_structure" />
<input type="hidden" name="structure_id" value="<?php echo $structure->getId() ?>" />
<?php echo _('Structure name')._(':') ?> <input type="text" name="structure_name" size="20" value="<?php echo htmlspecialchars ($structure->getName()) ?>" /><br />
<input type="submit" name="submit" value="<?php echo _('Save') ?>" />
</form>
<?php
break ;
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" 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 URL')._(':') ?> <input type="text" name="actor_url" 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 printf (_('Actor logo (PNG, %d kB max)')._(':'), $max_logo_size) ?> <input type="file" name="actor_logo" /><br />
<?php
echo _('Legal structure')._(':') ?>
<select name="structure_id">
<?php
$structs = $plugin->getLegalStructures () ;
foreach ($structs as $s) {
print '<option value="'.$s->getId().'">'.htmlspecialchars($s->getName()).'</option>' ;
}
?>
</select><br />
<input type="submit" name="submit" value="<?php echo _('Submit') ?>" />
</form>
<?php
break ;
case 'edit_actor':
print '<h1>'._('Edit an actor').'</h1>' ;
$actor = new ContribTrackerActor ($actor_id) ;
?>
<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 URL')._(':') ?> <input type="text" name="actor_url" size="20" value="<?php echo htmlspecialchars ($actor->getUrl()) ?>" /><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 printf (_('Actor logo (PNG, %d kB max)')._(':'), $max_logo_size) ?> <input type="file" name="actor_logo" /><br />
<?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
$structs = $plugin->getLegalStructures () ;
foreach ($structs as $s) {
print '<option value="'.$s->getId().'".' ;
if ($s->getId() == $actor->getLegalStructure()->getId()) {
print ' selected' ;
}
print '>'.htmlspecialchars($s->getName()).'</option>' ;
}
?>
</select><br />
<input type="submit" name="submit" value="<?php echo _('Save') ?>" />
</form>
<?php
break ;
}
site_project_footer(array());
// Local Variables:
// mode: php
// c-file-style: "bsd"
// End:
|