[Fusionforge-commits] r8586 - trunk/gforge/plugins/contribtracker/www

Roland Mas lolando at libremir.placard.fr.eu.org
Fri Dec 18 18:41:53 CET 2009


Author: lolando
Date: 2009-12-18 18:41:53 +0100 (Fri, 18 Dec 2009)
New Revision: 8586

Modified:
   trunk/gforge/plugins/contribtracker/www/global_admin.php
Log:
Added safeguards to global admin page

Modified: trunk/gforge/plugins/contribtracker/www/global_admin.php
===================================================================
--- trunk/gforge/plugins/contribtracker/www/global_admin.php	2009-12-18 17:41:44 UTC (rev 8585)
+++ trunk/gforge/plugins/contribtracker/www/global_admin.php	2009-12-18 17:41:53 UTC (rev 8586)
@@ -191,225 +191,243 @@
 switch ($action) {
 case 'display':
 	print '<h1>'._('Existing actors').'</h1>' ;
-	print '<table><thead><tr>' ;
-	print '<td><strong>'._('Short name').'</strong></td>' ;
-	print '<td><strong>'._('Postal address').'</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>' ;
 	$actors = $plugin->getActors () ;
-	print '</tr></thead><tbody>' ;
-	foreach ($actors as $a) {
-		print '<tr>';
-		print '<td>'.htmlspecialchars($a->getName()).'</td>' ;
-		print '<td>'.htmlspecialchars($a->getAddress()).'</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>' ;
-?>
-<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
+	if (count ($actors)) {
+		print '<table><thead><tr>' ;
+		print '<td><strong>'._('Short name').'</strong></td>' ;
+		print '<td><strong>'._('Postal address').'</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>'.htmlspecialchars($a->getName()).'</td>' ;
+			print '<td>'.htmlspecialchars($a->getAddress()).'</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, can't define actors without them.") ;
+	}
+	
 	print '<h1>'._('Existing legal structures').'</h1>' ;
-	print '<table><thead><tr>' ;
-	print '<td><strong>'._('Short name').'</strong></td>' ;
-	print '<td><strong>'._('Actions').'</strong></td>' ;
 	$structs = $plugin->getLegalStructures () ;
-	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>' ;
-?>
-<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
+	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>' ;
-	print '<table><thead><tr>' ;
-	print '<td><strong>'._('Short name').'</strong></td>' ;
-	print '<td><strong>'._('Description').'</strong></td>' ;
-	print '<td><strong>'._('Actions').'</strong></td>' ;
+			 print '<h1>'._('Existing roles').'</h1>' ;
 	$roles = $plugin->getRoles () ;
-	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>' ;
-?>
-<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
+	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 ;
+			 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>
-<input type="submit" name="submit" value="<?php echo _('Submit') ?>" />
-</form>
+	?>
+		<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>
+			 <input type="submit" name="submit" value="<?php echo _('Submit') ?>" />
+			 </form>
 
-<?php
-	 break ;
+			 <?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>
-<input type="submit" name="submit" value="<?php echo _('Save') ?>" />
-</form>
-<?php
-	 break ;
+	?>
+		<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>
+			 <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>
+	?>
+		<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 ;
+			 <?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 ;
+	?>
+		<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">
-<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 _('Legal structure:') ?>
-<select name="structure_id">
-<?php
-	$structs = $plugin->getLegalStructures () ;
+	?>
+		<form action="<?php echo util_make_url ('/plugins/'.$plugin->name.'/global_admin.php') ?>" method="post">
+			 <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 _('Legal structure:') ?>
+			 <select name="structure_id">
+			 <?php
+			 $structs = $plugin->getLegalStructures () ;
 	foreach ($structs as $s) {
 		print '<option value="'.$s->getId().'">'.htmlspecialchars($s->getName()).'</option>' ;
 	}
-?>
-</select>
-<input type="submit" name="submit" value="<?php echo _('Submit') ?>" />
-</form>
+	?>
+		</select>
+			  <input type="submit" name="submit" value="<?php echo _('Submit') ?>" />
+			  </form>
 
-<?php
-	 break ;
+			  <?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">
-<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 address:') ?> <input type="text" name="actor_address" size="20" value="<?php echo htmlspecialchars ($actor->getAddress()) ?>" /><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 _('Legal structure:') ?>
-<select name="structure_id">
-<?php
-	$structs = $plugin->getLegalStructures () ;
+	?>
+		<form action="<?php echo util_make_url ('/plugins/'.$plugin->name.'/global_admin.php') ?>" method="post">
+			 <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 address:') ?> <input type="text" name="actor_address" size="20" value="<?php echo htmlspecialchars ($actor->getAddress()) ?>" /><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 _('Legal structure:') ?>
+			 <select name="structure_id">
+			 <?php
+			 $structs = $plugin->getLegalStructures () ;
 	foreach ($structs as $s) {
 		print '<option value="'.$s->getId().'">'.htmlspecialchars($s->getName()).'</option>' ;
 	}
-?>
-</select>
-<input type="submit" name="submit" value="<?php echo _('Save') ?>" />
-</form>
-<?php
-	 break ;
+	?>
+		</select>
+			  <input type="submit" name="submit" value="<?php echo _('Save') ?>" />
+			  </form>
+			  <?php
+			  break ;
 
 }
 




More information about the Fusionforge-commits mailing list