[pisa-src] r1246 - in trunk/pairing/pisaum: admin/index.php include/util.php index.php

  • From: Jan Marten <jan.marten@xxxxxxxxxxxxxx>
  • To: pisa-src@xxxxxxxxxxxxx
  • Date: Wed, 21 Oct 2009 12:38:03 +0200

Author: marten
Date: Wed Oct 21 12:38:02 2009
New Revision: 1246

Log:
Added further documentation to the management website

Modified:
   trunk/pairing/pisaum/admin/index.php
   trunk/pairing/pisaum/include/util.php
   trunk/pairing/pisaum/index.php

Modified: trunk/pairing/pisaum/admin/index.php
==============================================================================
--- trunk/pairing/pisaum/admin/index.php        Wed Oct 21 12:31:35 2009        
(r1245)
+++ trunk/pairing/pisaum/admin/index.php        Wed Oct 21 12:38:02 2009        
(r1246)
@@ -12,12 +12,17 @@
 include "../include/util.php";
 include "../include/config.php";
 
+// Initialize management object with the specified paths
 $m = new 
Management(AUTHORIZED_CFG,USERS_CFG,MANAGEMENT_PATH,RELAY_CFG,PISA_CONF);
 
+// Form was submitted
 if(isset($_POST["action"]))
 {
+       // An entry should be edited 
+       // Show edit form
        if($_POST["action"]=="edit")
        {
+               // A user entry should be edited
                if(isset($_POST["username"]) && $_POST["username"]!="")
                {
                        $entry = $m->getUserByUsername($_POST["username"]);
@@ -34,6 +39,7 @@
                                showError("Username was not found.");
                        }
                }else
+               // Only a HIT entry should be edited
                {
                        $entry = $m->getHitEntry($_POST["hit"]);
                        // Result was found
@@ -45,13 +51,16 @@
                                showError("HIT was not found.");
                        }
                }
+       // An entry should be removed
        }else if($_POST["action"]=="remove")
        {
                if(!isset($_POST["username"]) && !isset($_POST["username"]))
                {
                        showError("No Username or HIT was given.");
                }else
+               // A username of hit was given
                {
+                       // Remove a user
                        if(isset($_POST["username"]) && $_POST["username"]!="")
                        {
                                try
@@ -63,6 +72,7 @@
                                        printException($e);
                                }
                        }else
+                       // Remove just a HIT entry
                        {
                                try
                                {
@@ -74,11 +84,13 @@
                                }
                        }
                }
-
+       // The edit form was submitted
        }else if($_POST["action"]=="editsubmit")
        {
+               // A user entry is edited
                if(isset($_POST["username"]) && $_POST["username"]!="")
                {
+                       // Check if the active status of a user was changed
                        if(isset($_POST["oldactive"]))
                        {
                                if(isset($_POST["active"]) && 
$_POST["active"]==1)
@@ -91,11 +103,13 @@
                                        $newactive = 0;
                                }
                        }
+                       // The active status did not change
                        if(!$activechange)
                        {
                                // Just change expiration date
                                if(isset($_POST["expiration"]))
                                {
+                                       // Use given expiration date
                                        if($_POST["expiration"]!="")
                                        {
                                                try
@@ -108,7 +122,7 @@
                                                        printException($e);
                                                }
                                        }else
-                                       // default expiration
+                                       // Use default expiration
                                        {
                                                try
                                                {
@@ -121,12 +135,13 @@
                                                }
                                        }
                                }
-
+                       // The active status of a user was changed
                        }else
                        {
                                // Change active status
                                if(isset($_POST["expiration"]))
                                {
+                                       // Use given expiration date
                                        if($_POST["expiration"]!="")
                                        {
                                                try
@@ -138,7 +153,7 @@
                                                        printException($e);
                                                }
                                        }else
-                                       // default expiration
+                                       // Use default expiration
                                        {
                                                try
                                                {
@@ -152,11 +167,13 @@
                                        }
                                }
                        }
+               // Only a HIT entry is edited
                }else if(isset($_POST["hit"]) && $_POST["hit"]!="")
                {
                        // Just change expiration date
                        if(isset($_POST["expiration"]))
                        {
+                               // Use given expiration date
                                if($_POST["expiration"]!="")
                                {
                                        try
@@ -168,7 +185,7 @@
                                                printException($e);
                                        }
                                }else
-                               // default expiration
+                               // Use default expiration
                                {
                                        try
                                        {
@@ -180,29 +197,36 @@
                                        }
                                }
                        }
+               // No username or HIT was given
                }else
                {
                        showError("No Username or HIT was given.");
                }
-
+       // A new entry should be added
        }else if($_POST["action"]=="add")
        {
+               // No HIT was given
                if(!isset($_POST["hit"]) || $_POST["hit"]=="")
                {
                        showError("HIT must be given.");
                }else
                {
+                       // A user entry should be added
                        if(isset($_POST["username"]) && $_POST["username"]!="")
                        {
+                               // The user should be active
                                if(isset($_POST["active"]) && 
$_POST["active"]==1)
                                {
                                        $active = 1;
                                }else
+                               // The user should be inactive
                                {
                                        $active = 0;
                                }
+                               // Payment information was given
                                if(isset($_POST["creditcard"]) && 
$m->isValidCreditCard($_POST["creditcard"]))
                                {
+                                       // Use given expiration date
                                        if(isset($_POST["expiration"]) && 
$_POST["expiration"]!="")
                                        {
                                                try
@@ -214,6 +238,7 @@
                                                        printException($e);
                                                }
                                        }else
+                                       // Use default expiration
                                        {
                                                try
                                                {
@@ -225,11 +250,14 @@
                                                }
                                        }
                                }else
+                               // No payment information was given
                                {
                                        showError("No valid credit card 
given.");
                                }
+                       // Only a HIT entry should be added
                        }else
                        {
+                               // Use given expiration date
                                if(isset($_POST["expiration"]) && 
$_POST["expiration"]!="")
                                {
                                        try
@@ -241,6 +269,7 @@
                                                printException($e);
                                        }
                                }else
+                               // Use default expiration
                                {
                                        try
                                        {
@@ -255,7 +284,7 @@
                }
 
        }
-
+// No form was submitted just display all entries
 }else
 {
        // List all entries
@@ -279,6 +308,10 @@
  * showEntriesTable($entries)
  * showAddHitForm()
  */
+
+/**
+ * Shows a success message and tries to redirect to the main page
+ */
 function showSuccess(){
        ?>
        Success! <br /> 
@@ -287,6 +320,10 @@
        redirect("index.php");
 }
 
+/**
+ * Shows the HIT edit form for the given HIT-entry
+ *@param entry The HIT-entry that should be edited
+ */
 function showHitEditForm($entry)
 {
        ?>
@@ -310,6 +347,10 @@
        showBack("index.php");
 }
 
+/**
+ * Shows the user edit form for the given user
+ *@param entry The user that should be edited
+ */
 function showUserEditForm($entry)
 {
        ?>
@@ -345,6 +386,10 @@
                        showBack("index.php");
 }
 
+/**
+ * Displays all User and HIT-entries in a table
+ * @param entries The entries that should be displayed
+ */
 function showEntriesTable($entries)
 {
        ?>
@@ -390,6 +435,9 @@
        <?
 }
 
+/**
+ * Displays the form to add a new Entry
+ */
 function showAddHitForm()
 {
        ?>

Modified: trunk/pairing/pisaum/include/util.php
==============================================================================
--- trunk/pairing/pisaum/include/util.php       Wed Oct 21 12:31:35 2009        
(r1245)
+++ trunk/pairing/pisaum/include/util.php       Wed Oct 21 12:38:02 2009        
(r1246)
@@ -1,16 +1,28 @@
 <?php
 
+/**
+ * Prints out the given exception
+ * @param e The exception that should be printed out
+ */
 function printException($e)
 {
        echo "Caught exception: ",  $e->getMessage(), "<br />";
 }
 
+/**
+ * Shows the given Error message and a back button to the index page
+ * @param errorMessage The error message that should be printed out
+ */
 function showError($errorMessage)
 {
        echo "Error: " . $errorMessage;
        showBack("index.php");
 }
 
+/**
+ * Shows a back button to the given URL
+ * @param url The url that should be linked
+ */
 function showBack($url)
 {
        ?>
@@ -19,6 +31,11 @@
        <?
 }
 
+/**
+ * Redirects the user to the given url using javascript
+ * @param url The url to which the user should be redirected
+ * @param seconds The number of seconds to pass before the user is redirected
+ */
 function redirect($url, $seconds=3) {
        echo "<br />";
        echo "Redirecting in " . $seconds . " seconds.";

Modified: trunk/pairing/pisaum/index.php
==============================================================================
--- trunk/pairing/pisaum/index.php      Wed Oct 21 12:31:35 2009        (r1245)
+++ trunk/pairing/pisaum/index.php      Wed Oct 21 12:38:02 2009        (r1246)
@@ -11,12 +11,14 @@
 include "include/util.php";
 include "include/config.php";
 
+// The register form was submitted
 if(isset($_POST["action"]) && $_POST["action"]=="register")
 {
        
        if(isset($_POST["hit"]) && isset($_POST["username"]) && 
isset($_POST["creditcard"])
           && $_POST["hit"]!="" && $_POST["username"]!="" && 
$_POST["creditcard"])
        {
+               // Initialize management object with the specified paths
                $m = new 
Management(AUTHORIZED_CFG,USERS_CFG,MANAGEMENT_PATH,RELAY_CFG,PISA_CONF);
                
                // Check credit card
@@ -26,7 +28,7 @@
                        echo "You did not enter a valid credit-card number.";
                        showBack("index.php");
                }else{
-
+                       // Add new user
                        try
                        {
                                
$m->addEntry($_POST["hit"],1,$_POST["username"],1,$_POST["creditcard"]);
@@ -46,12 +48,14 @@
                                showBack("index.php");
                        }
                }
+       // Not all fields were entered
        }else{
                echo "All fields are required.";
                showBack("index.php");
        }
 
 }else
+// Display normal register form
 {
 ?>
 <h2>User Registration</h2>

Other related posts:

  • » [pisa-src] r1246 - in trunk/pairing/pisaum: admin/index.php include/util.php index.php - Jan Marten