r4577 - trunk/src/perl

walbridge at ecoinformatics.org walbridge at ecoinformatics.org
Wed Nov 19 10:58:01 PST 2008


Author: walbridge
Date: 2008-11-19 10:58:00 -0800 (Wed, 19 Nov 2008)
New Revision: 4577

Modified:
   trunk/src/perl/register-dataset.cgi
Log:
CODE FORMATTING ONLY: Fix all the inconsistencies I found within the script to follow the standards used within 80% of the code: No tabs, 'if (eval) {' operator spacing, four spaces indentation, replace exit(0) with exit().


Modified: trunk/src/perl/register-dataset.cgi
===================================================================
--- trunk/src/perl/register-dataset.cgi	2008-11-19 18:24:56 UTC (rev 4576)
+++ trunk/src/perl/register-dataset.cgi	2008-11-19 18:58:00 UTC (rev 4577)
@@ -54,7 +54,7 @@
 unless (open (METACAT_PROPERTIES, $metacatProps)) {
     print "Content-type: text/html\n\n";
     print "Unable to locate Metacat properties. Working directory is set as '$workingDirectory', is this correct?";
-    exit(0);
+    exit();
 }
 
 $properties->load(*METACAT_PROPERTIES);
@@ -116,7 +116,7 @@
     unless (open (SKIN_PROPERTIES, $skinProps)) {
         print "Content-type: text/html\n\n";
         print "Unable to locate skin properties at $skinProps.  Is this path correct?";
-        exit(0);
+        exit();
     }
     $skinProperties->load(*SKIN_PROPERTIES);
 }
@@ -147,7 +147,7 @@
 my %siteLatDMS;
 my %siteLongDMS;
 
-while ( my ($key, $value) = each (%$spatial)) {
+while (my ($key, $value) = each (%$spatial)) {
     my ($name, $lon, $lat) = split(/\|/, $value);
     my ($latd, $latm, $lats, $latdir) = split(/\|/, $lat);
     my ($lond, $lonm, $lons, $londir) = split(/\|/, $lon);
@@ -192,130 +192,130 @@
     # Send back the login form.....
     my $session = CGI::Session->load() or die CGI::Session->errstr();
 
-    if($FORM::submission eq 'true'){
-    	$$templateVars{'message'} = 'You must login to view your submissions.';
-    }	
+    if ($FORM::submission eq 'true') {
+        $$templateVars{'message'} = 'You must login to view your submissions.';
+    }
 
-    if ( $session->is_empty ) {
-	# no session found ... redirect to login page template
-        $template->process( $templates->{'login'}, $templateVars);
+    if ($session->is_empty) {
+    # no session found ... redirect to login page template
+        $template->process($templates->{'login'}, $templateVars);
     } else {
-	# session found ... delete the session....
-	$session->delete();
-	$template->process( $templates->{'login'}, $templateVars);
+        # session found ... delete the session....
+        $session->delete();
+        $template->process($templates->{'login'}, $templateVars);
     }
-	exit(0);
+    exit();
 } elsif ($FORM::stage =~ "logout") {
-	handleLogoutRequest();
-  	exit(0);
+    handleLogoutRequest();
+    exit();
 } elsif ($FORM::stage =~ "login") {
-	handleLoginRequest();
-  	exit(0);
+    handleLoginRequest();
+    exit();
 } elsif ($FORM::stage =~ "mod_accept") {
-	handleModAccept();
-  	exit(0);
+    handleModAccept();
+    exit();
 } elsif ($FORM::stage =~ "mod_decline") {
-	handleModDecline();
-  	exit(0);
+    handleModDecline();
+    exit();
 } elsif ($FORM::stage =~ "mod_revise") {
-	handleModRevise();
-  	exit(0);
+    handleModRevise();
+    exit();
 } elsif ($FORM::stage =~ "read") {
-	handleRead();
-	exit(0);
-} elsif ($FORM::stage =~ "review_frame"){
- 	handleReviewFrame();	
-	exit(0);
-} 
+    handleRead();
+    exit();
+} elsif ($FORM::stage =~ "review_frame") {
+    handleReviewFrame();
+    exit();
+}
 
 print "Content-type: text/html\n\n";
 
 if ($FORM::stage =~ "guide") {
     # Send back the information on how to fill the form
     $$templateVars{'section'} = "Guide on How to Complete Registry Entries";
-    $template->process( $template->{'guide'}, $templateVars);
-    exit(0);
+    $template->process($template->{'guide'}, $templateVars);
+    exit();
 
 } elsif ($FORM::stage =~ "insert") {
     # The user has entered the data. Do data validation and send back data 
     # to confirm the data that has been entered. 
     toConfirmData();
-    exit(0);
+    exit();
 
-}elsif ($FORM::dataWrong =~ "No, go back to editing" && $FORM::stage =~ "confirmed") {
+} elsif ($FORM::dataWrong =~ "No, go back to editing" && $FORM::stage =~ "confirmed") {
     # The user wants to correct the data that he has entered. 
     # Hence show the data again in entryData form. 
     confirmDataToReEntryData();
-    exit(0);
+    exit();
 
-}elsif ($FORM::stage =~ "modify") {
+} elsif ($FORM::stage =~ "modify") {
     # Modification of a file has been requested. 
     # check if the user is logged in...
     my $session = CGI::Session->load() or die CGI::Session->errstr();
-    if ( $session->is_empty ) {
+    if ($session->is_empty) {
         # no session found ... redirect to login page template
-    	$$templateVars{'message'} = 'You must login to modify your dataset.';
-        $template->process( $templates->{'login'}, $templateVars);
+        $$templateVars{'message'} = 'You must login to modify your dataset.';
+        $template->process($templates->{'login'}, $templateVars);
     } else {
-    	# Show the form will all the values filled in.
-    	my @sortedSites;
-    	foreach my $site (sort @sitelist) {
-        	push(@sortedSites, $site);
-    	}
-    	$$templateVars{'siteList'} = \@sortedSites;
-    	$$templateVars{'section'} = "Modification Form";
-    	$$templateVars{'docid'} = $FORM::docid;
-    	modifyData();
+        # Show the form will all the values filled in.
+        my @sortedSites;
+        foreach my $site (sort @sitelist) {
+            push(@sortedSites, $site);
+        }
+        $$templateVars{'siteList'} = \@sortedSites;
+        $$templateVars{'section'} = "Modification Form";
+        $$templateVars{'docid'} = $FORM::docid;
+        modifyData();
     }
-    exit(0);
+    exit();
 
-}elsif ($FORM::stage =~ "delete_confirm") {
+} elsif ($FORM::stage =~ "delete_confirm") {
 
     # Result from deleteData form. 
-    if($FORM::deleteData =~ "Delete document"){
-    # delete Data
-    deleteData(1);    
-    exit(0);
+    if ($FORM::deleteData =~ "Delete document") {
+        # delete Data
+        deleteData(1);
+        exit();
     } else {
-    $$templateVars{'status'} = "Cancel";
-    $$templateVars{'function'} = "cancel";
-    $template->process( $templates->{'response'}, $templateVars);
-    exit(0);
+        $$templateVars{'status'} = "Cancel";
+        $$templateVars{'function'} = "cancel";
+        $template->process($templates->{'response'}, $templateVars);
+        exit();
     }
 
-}elsif ($FORM::stage =~ "delete") {
+} elsif ($FORM::stage =~ "delete") {
     # Deletion of a file has been requested. 
     # Ask for username and password using deleteDataForm
     $$templateVars{'docid'} = $FORM::docid;
-    $template->process( $templates->{'deleteData'}, $templateVars);
-    exit(0);
+    $template->process($templates->{'deleteData'}, $templateVars);
+    exit();
 
-}elsif ($FORM::stage !~ "confirmed") {
+} elsif ($FORM::stage !~ "confirmed") {
     # None of the stages have been reached and data is not being confirmed. 
-    
+
     # check if the user is logged in...
     my $session = CGI::Session->load() or die CGI::Session->errstr();
-    if ( $session->is_empty ) {
+    if ($session->is_empty) {
         # no session found ... redirect to login page template
         $$templateVars{'showInstructions'} = 'true';
         $$templateVars{'message'} = 'You must login to register your dataset.';
         debug($templates->{'login'});
-        $template->process( $templates->{'login'}, $templateVars);
+        $template->process($templates->{'login'}, $templateVars);
     } else {
 
-    	# Hence, send back entry form for entry of data.  
-    	debug("Registry: Sending form");
-    	my @sortedSites;
-    	foreach my $site (sort @sitelist) {
-        	push(@sortedSites, $site);
-    	}
+        # Hence, send back entry form for entry of data.  
+        debug("Registry: Sending form");
+        my @sortedSites;
+        foreach my $site (sort @sitelist) {
+            push(@sortedSites, $site);
+        }
 
-    	if ($skinName eq 'nceas') {
-        	my $projects = getProjectList($properties);
-        	$$templateVars{'projects'} = $projects;
-        	$$templateVars{'wg'} = \@FORM::wg;
-    	}
-        
+        if ($skinName eq 'nceas') {
+            my $projects = getProjectList($properties);
+            $$templateVars{'projects'} = $projects;
+            $$templateVars{'wg'} = \@FORM::wg;
+        }
+
         $$templateVars{'modules'} = $modules;
         $$templateVars{'required'} = $required;
         $$templateVars{'templates'} = $templates;
@@ -326,10 +326,10 @@
         $$templateVars{'section'} = "Entry Form";
         $$templateVars{'docid'} = "";
         debug("Registry: Sending form: ready to process template");
-        $template->process( $templates->{'entry'}, $templateVars);
+        $template->process($templates->{'entry'}, $templateVars);
         debug("Registry: Sending form: template processed");
    }
-   exit(0);
+   exit();
 }
 
 # Confirm stage has been reached. Enter the data into metacat. 
@@ -393,11 +393,11 @@
         $$templateVars{'cfg'} = $skinName;
         $$templateVars{'function'} = "submitted";
         $$templateVars{'section'} = "Submission Status";
-        $template->process( $templates->{'response'}, $templateVars);
-        exit(0);
+        $template->process($templates->{'response'}, $templateVars);
+        exit();
     } else {
 
-    if($config->{'adminIsDocOwner'} eq 'true'){
+    if ($config->{'adminIsDocOwner'} eq 'true') {
         debug("Registry: adminIsDocOwner is set.");
         $response = $metacat->login($username, $password);
         if (! $response) {
@@ -409,14 +409,14 @@
             $$templateVars{'cfg'} = $skinName;
             $$templateVars{'function'} = "submitted";
             $$templateVars{'section'} = "Submission Status";
-            $template->process( $templates->{'response'}, $templateVars);
-            exit(0);
+            $template->process($templates->{'response'}, $templateVars);
+            exit();
         }
     }
 
-        debug( "Registry: A");
+        debug("Registry: A");
         if ($FORM::docid eq "") {
-            debug( "Registry: B1");
+            debug("Registry: B1");
             # document is being inserted 
             my $docStatus = "INCOMPLETE";
             while ($docStatus eq "INCOMPLETE") {
@@ -472,9 +472,9 @@
             # Create our HTML response and send it back
             $$templateVars{'function'} = "modified";
             $$templateVars{'section'} = "Modification Status";
-            $template->process( $templates->{'response'}, $templateVars);
+            $template->process($templates->{'response'}, $templateVars);
 
-            exit(0);
+            exit();
         }
     }
 }
@@ -505,9 +505,9 @@
 $$templateVars{'function'} = "submitted";
 $$templateVars{'section'} = "Submission Status";
 
-$template->process( $templates->{'response'}, $templateVars);
+$template->process($templates->{'response'}, $templateVars);
 
-exit(0);
+exit();
 
 ################################################################################
 #
@@ -590,153 +590,132 @@
         unless hasContent($FORM::origNamelast0);
     push(@invalidParams, "Dataset abstract is missing.")
         unless hasContent($FORM::abstract);
-    if($modules->{'temporal'} eq 'true'){
-	push(@invalidParams, "Year of start date is missing.")
-	    unless (hasContent($FORM::beginningYear) || $required->{'temporal'} ne 'true');
-	push(@invalidParams, "Year of stop date has been specified but year of start date is missing.")
-	    if ((!hasContent($FORM::beginningYear)) && hasContent($FORM::endingYear));
+    if ($modules->{'temporal'} eq 'true') {
+        push(@invalidParams, "Year of start date is missing.")
+            unless (hasContent($FORM::beginningYear) || $required->{'temporal'} ne 'true');
+        push(@invalidParams, "Year of stop date has been specified but year of start date is missing.")
+            if ((!hasContent($FORM::beginningYear)) && hasContent($FORM::endingYear));
     }
     push(@invalidParams, "Geographic description is missing.")
         unless (hasContent($FORM::geogdesc) || $required->{'spatial'} ne 'true');
 
-    if($FORM::beginningMonth eq "MM"){
-	#if (hasContent($FORM::beginningYear)){
-	#    $FORM::beginningMonth = "01";
-	#} else {
-	    $FORM::beginningMonth = "";
-	#}
+    if ($FORM::beginningMonth eq "MM") {
+        $FORM::beginningMonth = "";
     }
-    if($FORM::beginningDay eq "DD"){
-	#if (hasContent($FORM::beginningYear)){
-	#    $FORM::beginningDay = "01";
-	#} else {
-	    $FORM::beginningDay = "";
-	#}
+    if ($FORM::beginningDay eq "DD") {
+        $FORM::beginningDay = "";
     }
-    if($FORM::endingMonth eq "MM"){
-	#if (hasContent($FORM::endingYear)){
-	#    $FORM::endingMonth = "01";
-	#} else {
-	    $FORM::endingMonth = "";
-	#}
-    }    
-    if($FORM::endingDay eq "DD"){
-	#if (hasContent($FORM::endingYear)){
-	#    $FORM::endingDay = "01";
-	#} else {
-	    $FORM::endingDay = "";
-	#}
+    if ($FORM::endingMonth eq "MM") {
+        $FORM::endingMonth = "";
     }
+    if ($FORM::endingDay eq "DD") {
+        $FORM::endingDay = "";
+    }
 
-    if (hasContent($FORM::beginningYear) && !($FORM::beginningYear =~ /[0-9]{4}/)){
-	push(@invalidParams, "Invalid year of start date specified.")
+    if (hasContent($FORM::beginningYear) && !($FORM::beginningYear =~ /[0-9]{4}/)) {
+        push(@invalidParams, "Invalid year of start date specified.")
     }
 
-    if (hasContent($FORM::endingYear) && !($FORM::endingYear =~ /[0-9]{4}/)){
-	push(@invalidParams, "Invalid year of stop date specified.")
+    if (hasContent($FORM::endingYear) && !($FORM::endingYear =~ /[0-9]{4}/)) {
+        push(@invalidParams, "Invalid year of stop date specified.")
     }
-    
+
     # If the "use site" coord. box is checked and if the site is in 
     # the longitude hash ...  && ($siteLatDMS{$FORM::site})
-    
-    if($modules->{'spatial'} eq 'true'){
-	if (($FORM::useSiteCoord) && ($siteLatDMS{$FORM::site}) ) {
-        
-	    $latDeg1 = $siteLatDMS{$FORM::site}[0];
-	    $latMin1 = $siteLatDMS{$FORM::site}[1];
-	    $latSec1 = $siteLatDMS{$FORM::site}[2];
-	    $hemisphLat1 = $siteLatDMS{$FORM::site}[3];
-	    $longDeg1 = $siteLongDMS{$FORM::site}[0];
-	    $longMin1 = $siteLongDMS{$FORM::site}[1];
-	    $longSec1 = $siteLongDMS{$FORM::site}[2];
-	    $hemisphLong1 = $siteLongDMS{$FORM::site}[3];
-	    
-	}  else {
-	    
-	    $latDeg1 = $FORM::latDeg1;
-	    $latMin1 = $FORM::latMin1;
-	    $latSec1 = $FORM::latSec1;
-	    $hemisphLat1 = $FORM::hemisphLat1;
-	    $longDeg1 = $FORM::longDeg1;
-	    $longMin1 = $FORM::longMin1;
-	    $longSec1 = $FORM::longSec1;
-	    $hemisphLong1 = $FORM::hemisphLong1;
-	}
 
-	if($latDeg1 > 90 || $latDeg1 < 0){
-	    push(@invalidParams, "Invalid first latitude degrees specified.");
-	}
-	if($latMin1 > 59 || $latMin1 < 0){
-	    push(@invalidParams, "Invalid first latitude minutes specified.");
-	}
-	if($latSec1 > 59 || $latSec1 < 0){
-	    push(@invalidParams, "Invalid first latitude seconds specified.");
-	}
-	if($longDeg1 > 180 || $longDeg1 < 0){
-	    push(@invalidParams, "Invalid first longitude degrees specified.");
-	}
-	if($longMin1 > 59 || $longMin1 < 0){
-	    push(@invalidParams, "Invalid first longitude minutes specified.");
-	}
-	if($longSec1 > 59 || $longSec1 < 0){
-	    push(@invalidParams, "Invalid first longitude seconds specified.");
-	}
+    if ($modules->{'spatial'} eq 'true') {
+        if (($FORM::useSiteCoord) && ($siteLatDMS{$FORM::site})) {
+            $latDeg1 = $siteLatDMS{$FORM::site}[0];
+            $latMin1 = $siteLatDMS{$FORM::site}[1];
+            $latSec1 = $siteLatDMS{$FORM::site}[2];
+            $hemisphLat1 = $siteLatDMS{$FORM::site}[3];
+            $longDeg1 = $siteLongDMS{$FORM::site}[0];
+            $longMin1 = $siteLongDMS{$FORM::site}[1];
+            $longSec1 = $siteLongDMS{$FORM::site}[2];
+            $hemisphLong1 = $siteLongDMS{$FORM::site}[3];
+        }  else {
+            $latDeg1 = $FORM::latDeg1;
+            $latMin1 = $FORM::latMin1;
+            $latSec1 = $FORM::latSec1;
+            $hemisphLat1 = $FORM::hemisphLat1;
+            $longDeg1 = $FORM::longDeg1;
+            $longMin1 = $FORM::longMin1;
+            $longSec1 = $FORM::longSec1;
+            $hemisphLong1 = $FORM::hemisphLong1;
+        }
 
-	if(hasContent($FORM::latDeg2) && ($FORM::latDeg2 > 90 || $FORM::latDeg2 < 0)){
-	    push(@invalidParams, "Invalid second latitude degrees specified.");
-	}
-	if(hasContent($FORM::latMin2) && ($FORM::latMin2 > 59 || $FORM::latMin2 < 0)){
-	    push(@invalidParams, "Invalid second latitude minutes specified.");
-	}
-	if(hasContent($FORM::latSec2) && ($FORM::latSec2 > 59 || $FORM::latSec2 < 0)){
-	    push(@invalidParams, "Invalid second latitude seconds specified.");
-	}
-	if(hasContent($FORM::latDeg2) && ($FORM::longDeg2 > 180 || $FORM::longDeg2 < 0)){
-	    push(@invalidParams, "Invalid second longitude degrees specified.");
-	}
-	if(hasContent($FORM::latMin2) && ($FORM::longMin2 > 59 || $FORM::longMin2 < 0)){
-	    push(@invalidParams, "Invalid second longitude minutes specified.");
-	}
-	if(hasContent($FORM::latSec2) && ($FORM::longSec2 > 59 || $FORM::longSec2 < 0)){
-	    push(@invalidParams, "Invalid second longitude seconds specified.");
-	}
+        if ($latDeg1 > 90 || $latDeg1 < 0) {
+            push(@invalidParams, "Invalid first latitude degrees specified.");
+        }
+        if ($latMin1 > 59 || $latMin1 < 0) {
+            push(@invalidParams, "Invalid first latitude minutes specified.");
+        }
+        if ($latSec1 > 59 || $latSec1 < 0) {
+            push(@invalidParams, "Invalid first latitude seconds specified.");
+        }
+        if ($longDeg1 > 180 || $longDeg1 < 0) {
+            push(@invalidParams, "Invalid first longitude degrees specified.");
+        }
+        if ($longMin1 > 59 || $longMin1 < 0) {
+            push(@invalidParams, "Invalid first longitude minutes specified.");
+        }
+        if ($longSec1 > 59 || $longSec1 < 0) {
+            push(@invalidParams, "Invalid first longitude seconds specified.");
+        }
+
+        if (hasContent($FORM::latDeg2) && ($FORM::latDeg2 > 90 || $FORM::latDeg2 < 0)) {
+            push(@invalidParams, "Invalid second latitude degrees specified.");
+        }
+        if (hasContent($FORM::latMin2) && ($FORM::latMin2 > 59 || $FORM::latMin2 < 0)) {
+            push(@invalidParams, "Invalid second latitude minutes specified.");
+        }
+        if (hasContent($FORM::latSec2) && ($FORM::latSec2 > 59 || $FORM::latSec2 < 0)) {
+            push(@invalidParams, "Invalid second latitude seconds specified.");
+        }
+        if (hasContent($FORM::latDeg2) && ($FORM::longDeg2 > 180 || $FORM::longDeg2 < 0)) {
+            push(@invalidParams, "Invalid second longitude degrees specified.");
+        }
+        if (hasContent($FORM::latMin2) && ($FORM::longMin2 > 59 || $FORM::longMin2 < 0)) {
+            push(@invalidParams, "Invalid second longitude minutes specified.");
+        }
+        if (hasContent($FORM::latSec2) && ($FORM::longSec2 > 59 || $FORM::longSec2 < 0)) {
+            push(@invalidParams, "Invalid second longitude seconds specified.");
+        }
     }
-    
+
     # Check if latDeg1 and longDeg1 has values if useSiteCoord is used. 
     # This check is required because some of the sites dont have lat 
     # and long mentioned in the config file. 
 
 
-    if($modules->{'spatial'} eq 'true' && $required->{'spatial'} eq 'true'){
-	if ($FORM::useSiteCoord ) {
-	    push(@invalidParams, "The Data Registry doesn't have latitude and longitude information for the site that you chose. Please go back and enter the spatial information.")
-		unless(hasContent($latDeg1) && hasContent($longDeg1));
-	}else{
-	    push(@invalidParams, "Latitude degrees are missing.")
-		unless (hasContent($latDeg1) || $required->{'spatial'} ne 'true');
-	    push(@invalidParams, "Longitude degrees are missing.")
-		unless (hasContent($longDeg1) || $required->{'spatial'} ne 'true');
-	}
-	push(@invalidParams, 
-	     "You must provide a geographic description if you provide latitude and longitude information.")
-	    if ((hasContent($latDeg1) || (hasContent($longDeg1))) && (!hasContent($FORM::geogdesc)));
+    if ($modules->{'spatial'} eq 'true' && $required->{'spatial'} eq 'true') {
+        if ($FORM::useSiteCoord) {
+            push(@invalidParams, "The Data Registry doesn't have latitude and longitude information for the site that you chose. Please go back and enter the spatial information.")
+                unless(hasContent($latDeg1) && hasContent($longDeg1));
+        } else {
+            push(@invalidParams, "Latitude degrees are missing.")
+                unless (hasContent($latDeg1) || $required->{'spatial'} ne 'true');
+            push(@invalidParams, "Longitude degrees are missing.")
+                unless (hasContent($longDeg1) || $required->{'spatial'} ne 'true');
+        }
+        push(@invalidParams, 
+            "You must provide a geographic description if you provide latitude and longitude information.")
+            if ((hasContent($latDeg1) || (hasContent($longDeg1))) && (!hasContent($FORM::geogdesc)));
     }
 
-    if($modules->{'method'} eq 'true'){
-	push(@invalidParams, 
-	     "You must provide a method description if you provide a method title.")
-	    if (hasContent($FORM::methodTitle) && ( !(scalar(@FORM::methodPara) > 0) 
-						    || (! hasContent($FORM::methodPara[0]))));
-	push(@invalidParams, 
-	     "You must provide a method description if you provide an extent of study description.")
-	    if (hasContent($FORM::studyExtentDescription) && (!(scalar(@FORM::methodPara) > 0) 
-							      || (! hasContent($FORM::methodPara[0]))));
-	push(@invalidParams, 
-	     "You must provide both an extent of study description and a sampling description, or neither.")
-	    if (
-                (hasContent($FORM::studyExtentDescription) && !hasContent($FORM::samplingDescription)) ||
-                (!hasContent($FORM::studyExtentDescription) && hasContent($FORM::samplingDescription))
-		);
+    if ($modules->{'method'} eq 'true') {
+    push (@invalidParams, 
+        "You must provide a method description if you provide a method title.")
+        if (hasContent($FORM::methodTitle) && (!(scalar(@FORM::methodPara) > 0) 
+            || (! hasContent($FORM::methodPara[0]))));
+    push(@invalidParams, 
+        "You must provide a method description if you provide an extent of study description.")
+        if (hasContent($FORM::studyExtentDescription) && (!(scalar(@FORM::methodPara) > 0) 
+            || (! hasContent($FORM::methodPara[0]))));
+    push(@invalidParams, 
+        "You must provide both an extent of study description and a sampling description, or neither.")
+        if ((hasContent($FORM::studyExtentDescription) && !hasContent($FORM::samplingDescription)) ||
+            (!hasContent($FORM::studyExtentDescription) && hasContent($FORM::samplingDescription)));
     }
 
     push(@invalidParams, "First name of data set contact is missing.")
@@ -745,22 +724,16 @@
     push(@invalidParams, "Last name of data set contact is missing.")
     unless (hasContent($FORM::origNamelastContact) || 
         $FORM::useOrigAddress);
-    if($required->{'contactEmailAddress'} eq 'true'){
-        if($FORM::useOrigAddress){
-    		push(@invalidParams, "Email address of data set owner is missing. This is required as it will be used as contact email address as specified by you.")
-    			unless (hasContent($FORM::origEmail));
-	} else {
-    		push(@invalidParams, "Email address of data set contact is missing.")
-    			unless (hasContent($FORM::origEmailContact));
-	}
+    if ($required->{'contactEmailAddress'} eq 'true') {
+        if ($FORM::useOrigAddress) {
+        push(@invalidParams, "Email address of data set owner is missing. This is required as it will be used as contact email address as specified by you.")
+            unless (hasContent($FORM::origEmail));
+        } else {
+            push(@invalidParams, "Email address of data set contact is missing.")
+                unless (hasContent($FORM::origEmailContact));
+        }
     }
-    
-    # scw: commented these out, don't seem to be matched to cfg setting
-    #push(@invalidParams, "Data medium is missing.")
-    #unless (hasContent($FORM::dataMedium) || $FORM::dataMedium =~ /elect/);
-    #push(@invalidParams, "Usage rights are missing.")
-    #unless (hasContent($FORM::useConstraints));
-    
+
     return \@invalidParams;
 }
 
@@ -798,28 +771,26 @@
  
     my $returnVal = "";
     
-    foreach (split(//,$val)){
-	my $var = unpack "C*", $_; 
-	
-	if($var<128 && $var>31){
-	    $returnVal=$returnVal.$_;
-	} elsif ($var<32){
-	    if($var == 10){
-		$returnVal=$returnVal.$_;
-	    }
-	    if($var == 13){
-		$returnVal=$returnVal.$_;
-	    }
-	    if($var == 9){
-		$returnVal=$returnVal.$_;
-	    }
-	} else { 
-	    #$returnVal=$returnVal."&#".$var.";";
-	    $returnVal=$returnVal.$_;
-	}
+    foreach (split(//,$val)) {
+        my $var = unpack "C*", $_; 
+
+        if ($var < 128 && $var > 31) {
+            $returnVal = $returnVal.$_;
+        } elsif ($var < 32) {
+            if ($var == 10) {
+                $returnVal = $returnVal.$_;
+            }
+            if ($var == 13) {
+                $returnVal = $returnVal.$_;
+            }
+            if ($var == 9) {
+                $returnVal = $returnVal.$_;
+            }
+        } else { 
+            $returnVal=$returnVal.$_;
+        }
     }
-    
-    #$returnVal =~ s/&/%26/g;    
+
     return $returnVal;
 }
 
@@ -839,19 +810,19 @@
 
     my $returnVal = "";
 
-    foreach (split(//,$val)){
+    foreach (split(//,$val)) {
         my $var = unpack "C*", $_;
 
-        if($var<128 && $var>31){
+        if($var < 128 && $var > 31) {
             $returnVal=$returnVal.$_;
-        } elsif ($var<32){
-            if($var == 10){
+        } elsif ($var < 32) {
+            if($var == 10) {
                 $returnVal=$returnVal.$_;
             }
-            if($var == 13){
+            if ($var == 13) {
                 $returnVal=$returnVal.$_;
             }
-            if($var == 9){
+            if ($var == 9) {
                 $returnVal=$returnVal.$_;
             }
         } else {
@@ -919,21 +890,21 @@
     my $fileSize = stat($outFile)->size;
     if ($fileSize == 0) {
         push(@errorMessages, "file $fileName is zero bytes!");
-        debug( "Registry: file $fileName is zero bytes!");
+        debug("Registry: file $fileName is zero bytes!");
     }
 
     # Now the file is on disk, send the object to Metacat
     my $session = CGI::Session->load();
-    if ( $session->is_empty ) {
+    if ($session->is_empty) {
         push(@errorMessages, "Must be logged in to upload files.");
-        debug( "Not logged in, cannot upload files.");
+        debug("Not logged in, cannot upload files.");
         return 0;
     }
 
     my $docid = newAccessionNumber($config->{'scope'});
     my $uploadReturn = uploadData($outFile, $docid);
     if (!$uploadReturn) {
-        debug( "Registry: uploading the data failed.");
+        debug("Registry: uploading the data failed.");
     }
 
     my $entityid = $fileHash."001";
@@ -974,7 +945,7 @@
     my $fileSize = stat($outFile)->size;
     if ($fileSize == 0) {
         push(@errorMessages, "file $fileName is zero bytes!");
-        debug( "Registry: file $fileName is zero bytes!");
+        debug("Registry: file $fileName is zero bytes!");
     }
 
     # file is in Metacat, generate the pertinent EML elements
@@ -1148,7 +1119,7 @@
     foreach my $origName (param()) {
         my $origNum = $origName;
         $origNum =~ s/origNamelast//; # get the index of the parameter 0 to 10
-        if ( $origNum =~ /^([0-9]+)$/) {
+        if ($origNum =~ /^([0-9]+)$/) {
             # do not generate EML for empty originator fields
             if (hasContent(param("origNamefirst" . $origNum))) {
                 my $first = normalize(param("origNamefirst" . $origNum));
@@ -1202,7 +1173,7 @@
     my $entityList = "";
 
     my $access = fileAccessElement(\%entityObjects);
-    while ( my ($docid, $data) = each(%entityObjects) ) {
+    while (my ($docid, $data) = each(%entityObjects)) {
         my $entityStub = qq|<otherEntity id="$data->{'entityid'}" scope="document">
             <entityName>$data->{'fileName'}</entityName>
             <physical scope="document">
@@ -1243,7 +1214,7 @@
         'private' => 'deny',
     );
 
-    while ( my ($docid, $data) = each(%entityObjects) ) {
+    while (my ($docid, $data) = each(%entityObjects)) {
         my $defaultAccess = $accessRoles{$data->{'filePerm'}};
         $accessList = qq|
                 <access authSystem="knb" order="denyFirst">
@@ -1267,7 +1238,7 @@
     foreach my $kwName (param()) {
         my $kwNum = $kwName;
         $kwNum =~ s/keyword//; # get the index of the parameter 0, ..., 10
-        if ( $kwNum =~ /^([0-9]+)$/ ){
+        if ($kwNum =~ /^([0-9]+)$/) {
             # don't generate xml for empty keyword fields
             # don't generate taxonomic keyword fields, those go in taxonomic coverage
             if (hasContent(param($kwName))) {
@@ -1656,9 +1627,9 @@
             my $taxIndex = $trn;
             $taxIndex =~ s/taxonRankName//; # get the index of the parameter 0, ..., 10
             my $trv = "taxonRankValue".$taxIndex;
-            if ( $taxIndex =~ /[0-9]+/ ){
+            if ($taxIndex =~ /[0-9]+/) {
                 if (hasContent(param($trn)) && hasContent(param($trv))) {
-                    if (! $foundFirstTaxon) {
+                    if (!$foundFirstTaxon) {
                         $cov .= "<taxonomicCoverage>\n";
                         $foundFirstTaxon = 1;
                         if (hasContent($FORM::taxaAuth)) {
@@ -1735,7 +1706,7 @@
         $access .= allowElement(getUsername(), 'read', 'write'); 
     }
 
-    if($config->{'publicReadable'} eq "true"){
+    if ($config->{'publicReadable'} eq "true") {
         $access .= allowElement('public', 'read');
     }
     $access .= "</access>\n";
@@ -1762,7 +1733,7 @@
         $username = "uid=$FORM::username,o=$FORM::organization,dc=ecoinformatics,dc=org";    
     } else {
         my $session = CGI::Session->load();
-        if ( !$session->is_empty ) {
+        if (!$session->is_empty) {
             $username = $session->param("username");
         }
     }
@@ -1789,7 +1760,7 @@
     my $tempfile;
 
     my $session = CGI::Session->load();
-    if ( !$session->is_empty ) {
+    if (!$session->is_empty) {
         my $username = $session->param("username");
         my $password = $session->param("password");
         $metacat->login($username, $password);
@@ -1804,7 +1775,7 @@
         $error ="Error in parsing the eml document";
         push(@errorMessages, $error);
     } elsif ($doc=~ /<error/) {
-        if ( $doc=~ /public/){
+        if ($doc=~ /public/) {
             $error ="Error in reading the eml document. Please check if you are logged in.";
             push(@errorMessages, $error);
         } else {
@@ -1822,7 +1793,7 @@
     return $xmldoc;
 }   
 
-    
+
 ################################################################################
 # 
 # read the eml document and send back a form with values filled in. 
@@ -1842,10 +1813,10 @@
         $error = 1;
         $$templateVars{'function'} = "modification";
         $$templateVars{'section'} = "Modification Status";
-        $template->process( $templates->{'response'}, $templateVars); 
+        $template->process($templates->{'response'}, $templateVars); 
     } else {
         $$templateVars{'form'} = 're_entry';
-        $template->process( $templates->{'entry'}, $templateVars);
+        $template->process($templates->{'entry'}, $templateVars);
     }
 }
 
@@ -1927,7 +1898,6 @@
     } elsif ($results->size() < 1) {
         $error ="Following tag not found: title. Please use Morpho to edit this document";
         push(@errorMessages, $error."\n");
-        #if ($DEBUG == 1){ print $error;}
     } else {
         foreach $node ($results->get_nodelist) {
             $$templateVars{'title'} = findValue($node, '../title');
@@ -2038,10 +2008,10 @@
 
     $results = $doc->findnodes('//dataset/metadataProvider');
     foreach $node ($results->get_nodelist) {
-            dontOccur($node, "./organizationName|./positionName|./onlineURL|./userId|./electronicMailAddress|./phone|./address", 
+        dontOccur($node, "./organizationName|./positionName|./onlineURL|./userId|./electronicMailAddress|./phone|./address", 
                 "organizationName, positionName, onlineURL, userId, electronicMailAddress, phone, address in metadataProvider");
         
-	    $tempResult = $node->findnodes('./individualName');
+        $tempResult = $node->findnodes('./individualName');
             if ($tempResult->size > 1) {
                 errMoreThanOne("metadataProvider/indvidualName");
             } else {
@@ -2141,7 +2111,7 @@
         $count++;
     }
     $$templateVars{'keyCount'} = $count;
-    if($count > 0 ){
+    if ($count > 0) {
        $$templateVars{'hasKeyword'} = "true";
     }
 
@@ -2172,7 +2142,6 @@
                     if ($childNodes->size() > 1) {
                         $error ="The tag para in intellectualRights has children which cannot be shown using the form. Please use Morpho to edit this document";    
                         push(@errorMessages, $error);
-                        #if ($DEBUG == 1){ print $error."\n";}
                     } else {
                         #print $tempNode->nodeName().":".$tempNode->textContent();
                         #print "\n";
@@ -2191,7 +2160,7 @@
     if ($results->size() > 1) {
         errMoreThanOne("distribution/online");
     } else {
-        foreach my $tempNode ($results->get_nodelist){
+        foreach my $tempNode ($results->get_nodelist) {
             $$templateVars{'url'} = findValue($tempNode, "url");
             dontOccur($tempNode, "./connection", "/distribution/online/connection");
             dontOccur($tempNode, "./connectionDefinition", "/distribution/online/connectionDefinition");
@@ -2204,7 +2173,7 @@
     } else {
         foreach my $tempNode ($results->get_nodelist) {
             my $temp = findValue($tempNode, "mediumName");
-            if(substr($temp, 0, 5) eq "other"){
+            if (substr($temp, 0, 5) eq "other") {
                 $$templateVars{'dataMedium'} = substr($temp, 0, 5);
                 $$templateVars{'dataMediumOther'} = substr($temp, 5);
             } else {
@@ -2240,7 +2209,7 @@
                     $$templateVars{'beginningYear'} = $x;
                     $$templateVars{'beginningMonth'} = $y;
                     $$templateVars{'beginningDay'} = $z;
-    
+
                     $tempdate = findValue($tempNode, "rangeOfDates/endDate/calendarDate");
                     ($x, $y, $z) = split("-", $tempdate);
                     $$templateVars{'endingYear'} = $x;
@@ -2249,14 +2218,14 @@
 
                     $tempdate = "";
                     $tempdate = findValue($tempNode, "singleDateTime/calendarDate");
-                    if($tempdate ne ""){
+                    if ($tempdate ne "") {
                         ($x, $y, $z) = split("-", $tempdate);
                         $$templateVars{'beginningYear'} = $x;
                         $$templateVars{'beginningMonth'} = $y;
                         $$templateVars{'beginningDay'} = $z;
-                    }  
-		    
-		    $$templateVars{'hasTemporal'} = "true";
+                    }
+
+                    $$templateVars{'hasTemporal'} = "true";
                 }
             }
 
@@ -2491,12 +2460,12 @@
         if ($principal eq 'public' && $permission ne 'read') { $accessError = 1; }
         if ($principal eq $username && $permission ne 'all') { $accessError = 2; }
         if ($principal ne 'public' && $principal ne $username && $principal ne $moderators && $permission ne 'all') { $accessError = 3; }
-        if ($accessError == 3){
+        if ($accessError == 3) {
             my $session = CGI::Session->load();
-            if ( !$session->is_empty ) {
+            if (!$session->is_empty) {
                 my $username = $session->param("username");
                 my $password = $session->param("password");
-                if($principal eq $username){
+                if ($principal eq $username) {
                     $accessError = 0;
                 }
             }
@@ -2531,8 +2500,8 @@
     dontOccur($doc, "//protocol", "protocol");
     $results = $doc->findnodes(
             '//additionalMetadata/moderatorComment');
-    if($results->size == 0){
-        dontOccur($doc, "//additionalMetadata", "additionalMetadata");    
+    if ($results->size == 0) {
+        dontOccur($doc, "//additionalMetadata", "additionalMetadata");
     }
 }
 
@@ -2591,65 +2560,62 @@
     } else {
 
         $findType = $xmldoc->findnodes('//dataset/identifier');
-        if($findType->size() > 0){
-        # This is a eml beta6 document
-        # Delete the documents mentioned in triples also
-        
-        $findType = $xmldoc->findnodes('//dataset/triple');
-        if($findType->size() > 0){
-            foreach $node ($findType->get_nodelist){
-            $pushDoc = findValue($node, 'subject');
-            
-            # If the file is already in the @fileArray then do not add it 
-            $alreadyInArray = 0;
-            foreach $element (@fileArray){
-                if($element eq $pushDoc){
-                $alreadyInArray = 1;
+        if ($findType->size() > 0) {
+            # This is a eml beta6 document
+            # Delete the documents mentioned in triples also
+
+            $findType = $xmldoc->findnodes('//dataset/triple');
+            if ($findType->size() > 0) {
+                foreach $node ($findType->get_nodelist) {
+                    $pushDoc = findValue($node, 'subject');
+
+                    # If the file is already in the @fileArray then do not add it 
+                    $alreadyInArray = 0;
+                    foreach $element (@fileArray) {
+                        if ($element eq $pushDoc) {
+                            $alreadyInArray = 1;
+                        }
+                    }
+
+                    if (!$alreadyInArray) {
+                        # If not already in array then delete the file. 
+                        push (@fileArray, $pushDoc);
+                        $response = $metacat->delete($pushDoc);
+                        
+                        if (!$response) {
+                            # Could not delete
+                            push(@errorMessages, $metacat->getMessage());
+                            push(@errorMessages, "Failed during deleting $pushDoc. Please check if you are authorized to delete this document.\n");
+                        }
+                    }
                 }
             }
-            
-            if(!$alreadyInArray){
-                # If not already in array then delete the file. 
-                push (@fileArray, $pushDoc);
-                $response = $metacat->delete($pushDoc);
-                
-                if (! $response) {
-                # Could not delete
-                #push(@errorMessages, $response);
-                push(@errorMessages, $metacat->getMessage());
-                push(@errorMessages, "Failed during deleting $pushDoc. Please check if you are authorized to delete this document.\n");
-                }
-            }
-            }
         }
-        }
     }
-    
+
     # Delete the main document. 
-    if($deleteAll){
-        $response = $metacat->delete($docid);  
+    if ($deleteAll) {
+        $response = $metacat->delete($docid);
         if (! $response) {
-        # Could not delete
-        #push(@errorMessages, $response);
-        push(@errorMessages, $metacat->getMessage());
-        push(@errorMessages, "Failed during deleting $docid. Please check if you are authorized to delete this document.\n");
+            # Could not delete
+            push(@errorMessages, $metacat->getMessage());
+            push(@errorMessages, "Failed during deleting $docid. Please check if you are authorized to delete this document.\n");
         }
     }
     }
-    
+
     if (scalar(@errorMessages)) {
-    # If any errors, print them in the response template 
-    $$templateVars{'status'} = 'failure';
-    $$templateVars{'errorMessages'} = \@errorMessages;
-    $error = 1;
+        # If any errors, print them in the response template 
+        $$templateVars{'status'} = 'failure';
+        $$templateVars{'errorMessages'} = \@errorMessages;
+        $error = 1;
     }
-    
-    # Process the response template
-    if($deleteAll){
 
-    $$templateVars{'function'} = "deleted";
-    $$templateVars{'section'} = "Deletion Status";
-    $template->process( $templates->{'response'}, $templateVars);
+    # Process the response template
+    if ($deleteAll) {
+        $$templateVars{'function'} = "deleted";
+        $$templateVars{'section'} = "Deletion Status";
+        $template->process($templates->{'response'}, $templateVars);
     }
 }
 
@@ -2662,23 +2628,23 @@
     #debug("Registry: handling login request");
     # Check if a session already exists
     my $session = CGI::Session->load() or die CGI::Session->errstr();
-    if ( $session->is_empty ) {
+    if ($session->is_empty) {
         # no session found ... check if the login is correct
-		my $username = $FORM::username;
-		my $password = $FORM::password;
-   
+        my $username = $FORM::username;
+        my $password = $FORM::password;
+
         my $metacat = Metacat->new($metacatUrl);
         my $returnVal = $metacat->login($username,$password);
         debug("Registry: Login was $returnVal for login attempt to $metacatUrl, with $username");
-        if($returnVal > 0){
+        if ($returnVal > 0) {
             # valid username and passwd
             # create a new session and store username and passswd
             $session = new CGI::Session();
 
             $session->param('username', $username);
             $session->param('password', $password);
-    
-            if($returnVal == 2 || $returnVal == 4){
+
+            if ($returnVal == 2 || $returnVal == 4) {
                 # is a moderator. store this information in the session
                 $session->param('moderator', 'true'); 
             }
@@ -2703,15 +2669,15 @@
             $$templateVars{'errorMessages'} = \@errorMessages;
             $$templateVars{'cfg'} = $skinName;
             $$templateVars{'section'} = "Login Status";
-            $template->process( $templates->{'response'}, $templateVars);
+            $template->process($templates->{'response'}, $templateVars);
         }
 
-    exit(0);
+        exit();
     } else {
         # session found ... redirect to index page
         my $url = "$skinsDir/$skinName/index.html";
         redirect($url);
-        exit(0);
+        exit();
    }
 }
 
@@ -2722,10 +2688,10 @@
 ################################################################################
 sub handleLogoutRequest(){
     print "Content-type: text/html\n\n";
-	# Check if the session exists
-	debug("Stage is logout");
+    # Check if the session exists
+    debug("Stage is logout");
     my $session = CGI::Session->load();
-    if ( $session->is_empty || $session->is_expired) {
+    if ($session->is_empty || $session->is_expired) {
         # no session found ... send back to index.html page ... 
         debug("Session empty or not found");
         my $url = "$skinsDir/$skinName/index.html";
@@ -2759,9 +2725,9 @@
     my $userPass = $FORM::password;
     my $dname = "uid=$userDN,o=$userOrg,dc=ecoinformatics,dc=org";
 
-    if($FORM::userLoggedIn eq 'true'){
+    if ($FORM::userLoggedIn eq 'true') {
         my $session = CGI::Session->load();
-        if (!( $session->is_empty || $session->is_expired)) {
+        if (!($session->is_empty || $session->is_expired)) {
             $dname = $session->param("username");
             $userPass = $session->param("password");
         }
@@ -2783,7 +2749,7 @@
 
     # Check if the session exists
     my $session = CGI::Session->load();
-    if ( $session->is_empty || $session->is_expired) {
+    if ($session->is_empty || $session->is_expired) {
         # no session found ... send back to index.html page ... 
         processResultTemplate($stage, 'failure', "Moderator is not logged in.\n");
         $returnValue = -1;
@@ -2791,14 +2757,14 @@
 
     # check if logged in user is moderator
     my $moderator = $session->param("moderator");
-    if ( $moderator ne 'true') {
+    if ($moderator ne 'true') {
         # no session found ... send back to index.html page ... 
         debug("Logged in user is not moderator");
         processResultTemplate($stage, 'failure', "Logged in user is not moderator.\n");
         $returnValue = -1;
-    } 
+    }
 
-    if($returnValue eq 1){
+    if ($returnValue eq 1) {
         $modUsername = $session->param("username");
         $modPassword = $session->param("password");
     }
@@ -2814,72 +2780,73 @@
 
     # Check if the session exists
     my $session = CGI::Session->load();
-        if ( $session->is_empty || $session->is_expired) {
-            # no session found ... send back the regular read page ...
-       	    my $url = "$skinsDir/$skinName/index.html";
-       	    redirect($url);
-        } else {
-       	    my $htmldoc = "";
-       	    $htmldoc .= "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Frameset//EN\" \"http://www.w3.org/TR/html4/frameset.dtd\">";
-       	    $htmldoc .= "<html><head><title>Dataset Description: ".$docid."</title><meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\"></head>";
-       	    $htmldoc .= "<frameset rows=\"150,*\" cols=\"*\" frameborder=\"NO\" border=\"0\" framespacing=\"0\">";
-       	    $htmldoc .= "<frame src=\"$skinsDir/$skinName/header.jsp\" marginwidth=\"40\" name=\"topFrame\" scrolling=\"NO\" noresize>";
-       	    $htmldoc .= "<frameset cols=\"200,*\" frameborder=\"NO\" border=\"0\" framespacing=\"0\">";
-       	    $htmldoc .= "<body></body><frame src=\"$cgiUrl?cfg=$skinName&stage=review_frame&docid=".$docid."\" name=\"rightFrame\" scrolling=\"NO\" noresize></frame>";
-       	    $htmldoc .= "<frame src=\"". $metacatUrl ."?action=read&qformat=".$skinName."&docid=".$docid."&insertTemplate=0\" name=\"mainFrame\">";
-            $htmldoc .= "</frameset></frameset></html>";
+    if ($session->is_empty || $session->is_expired) {
+        # no session found ... send back the regular read page ...
+        my $url = "$skinsDir/$skinName/index.html";
+        redirect($url);
+    } else {
+        my $htmldoc = qq|<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">
+        <html><head><title>Dataset Description: $docid</title><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"></head>
+          <frameset rows="150,*" cols="*" frameborder="NO" border="0" framespacing="0">
+            <frame src="$skinsDir/$skinName/header.jsp" marginwidth="40" name="topFrame" scrolling="NO" noresize>
+            <frameset cols="200,*" frameborder="NO" border="0" framespacing="0">
+              <body></body><frame src="$cgiUrl?cfg=$skinName&stage=review_frame&docid="$docid"" name="rightFrame" scrolling="NO" noresize></frame>
+              <frame src="$metacatUrl?action=read&qformat=$skinName&docid=$docid&insertTemplate=0" name="mainFrame">
+            </frameset>
+          </frameset>
+        </html>
+|;
+        print $htmldoc;    
+    }
+}
 
-       	    print $htmldoc;	
-	}
-} 
-
 sub handleReviewFrame {
-	print "Content-type: text/html\n\n";
-	my $session = CGI::Session->load();
-        if ( $session->is_empty || $session->is_expired) {
-		return;
-	}
+    print "Content-type: text/html\n\n";
+    my $session = CGI::Session->load();
+        if ($session->is_empty || $session->is_expired) {
+        return;
+    }
 
-	my $moderator = $session->param("moderator");
+    my $moderator = $session->param("moderator");
 
-	$$templateVars{'reviewdocid'} = getReviewHistoryHTML($session->param("username"),  $session->param("password"));
-	$$templateVars{'docid'} = $FORM::docid;
-	if ( $moderator eq 'true') {
-		$$templateVars{'isModerator'} = "true";
-	}
-	$template->process( $templates->{'getReviews'}, $templateVars);
+    $$templateVars{'reviewdocid'} = getReviewHistoryHTML($session->param("username"),  $session->param("password"));
+    $$templateVars{'docid'} = $FORM::docid;
+    if ($moderator eq 'true') {
+        $$templateVars{'isModerator'} = "true";
+    }
+    $template->process($templates->{'getReviews'}, $templateVars);
 }
 
 sub getReviewHistoryHTML {
-	my $username = shift;
-	my $password = shift;
+    my $username = shift;
+    my $password = shift;
 
     my $metacat = Metacat->new($metacatUrl);
-	$metacat->login($username, $password);
-    	my $parser = XML::LibXML->new();
-        my $docid = $FORM::docid;
-        my ($x, $y, $z) = split(/\./, $docid);
-        my $docidWithoutRev = $x.".".$y;
-        my $reviewDocumentId = '';
-        my $response = $metacat->squery("<pathquery><querytitle>Moderator-Search</querytitle><querygroup operator='INTERSECT'><queryterm searchmode='contains' casesensitive='false'><value>$docidWithoutRev</value><pathexpr>/reviewHistory/review/packageId</pathexpr></queryterm></querygroup></pathquery>");
-        my $doc = $response->content();
-        my $xmldoc = $parser->parse_string($doc);
-	my $reviewHTML = '';
+    $metacat->login($username, $password);
+    my $parser = XML::LibXML->new();
+    my $docid = $FORM::docid;
+    my ($x, $y, $z) = split(/\./, $docid);
+    my $docidWithoutRev = $x.".".$y;
+    my $reviewDocumentId = '';
+    my $response = $metacat->squery("<pathquery><querytitle>Moderator-Search</querytitle><querygroup operator='INTERSECT'><queryterm searchmode='contains' casesensitive='false'><value>$docidWithoutRev</value><pathexpr>/reviewHistory/review/packageId</pathexpr></queryterm></querygroup></pathquery>");
+    my $doc = $response->content();
+    my $xmldoc = $parser->parse_string($doc);
+    my $reviewHTML = '';
 
-        if ($xmldoc eq "" || $doc=~ /<error/) {
-                # not able to parse
-                return " Unable to search for review for the docid:".$docid;
-        } else {
-            my $findNodes = $xmldoc->findnodes('//resultset/document');
-            if($findNodes->size() > 0){
-                # found contact email address
-                my $node = '';
-                foreach $node ($findNodes->get_nodelist) {
-                    $reviewDocumentId = findValue($node,'docid');
-                }
+    if ($xmldoc eq "" || $doc=~ /<error/) {
+        # not able to parse
+        return " Unable to search for review for the docid:".$docid;
+    } else {
+        my $findNodes = $xmldoc->findnodes('//resultset/document');
+        if ($findNodes->size() > 0) {
+            # found contact email address
+            my $node = '';
+            foreach $node ($findNodes->get_nodelist) {
+                $reviewDocumentId = findValue($node,'docid');
             }
-	}
-	return $reviewDocumentId;
+        }
+    }
+    return $reviewDocumentId;
 }
 
 ################################################################################
@@ -2897,8 +2864,8 @@
     debug("Stage is mod_accept");
 
     my $isMod = isModerator("accept");
-    if($isMod < 0){
-    	return;
+    if ($isMod < 0) {
+        return;
     }
     # change the access rules
     ## create the access block
@@ -2909,7 +2876,7 @@
     $accessblock .= "<permission>all</permission>\n";
     $accessblock .= "</allow>\n";
 
-    foreach(split(":",$moderators)){
+    foreach (split(":",$moderators)) {
         $accessblock .= "<allow>\n";
         $accessblock .= "<principal>".$_."</principal>\n";
         $accessblock .= "<permission>all</permission>\n";
@@ -2931,7 +2898,7 @@
     # Log into metacat
     my $response = $metacat->login($modUsername, $modPassword);
 
-    if (! $response) {
+    if (!$response) {
         # Could not login
         $errorMessage = $errorMessage." Failed during moderator login.";
 
@@ -2942,103 +2909,103 @@
         my $docFromMetacat = $response->content();
         my $xmldoc = $parser->parse_string($docFromMetacat);
 
-	if ($xmldoc eq "" || $docFromMetacat=~ /<error/) {
-                # not able to parse
-                $errorMessage = $errorMessage." Error in reading the following docid:".$docid;
+        if ($xmldoc eq "" || $docFromMetacat=~ /<error/) {
+            # not able to parse
+            $errorMessage = $errorMessage." Error in reading the following docid:".$docid;
         } else {
-		my ($emldoc, $temp) = split('<access authSystem=', $docFromMetacat);
-		$emldoc .= $accessblock;
-    		$emldoc .= "</dataset>\n</eml:eml>\n";
+            my ($emldoc, $temp) = split('<access authSystem=', $docFromMetacat);
+            $emldoc .= $accessblock;
+            $emldoc .= "</dataset>\n</eml:eml>\n";
 
-    		#debug("Document created by handleModAccept is " . $emldoc);
-    		# update the document
-    		my $docid = $FORM::docid;
-    
-    		my $x;
-    		my $y;
-    		my $z;
-        
-    		($x, $y, $z) = split(/\./, $docid); 
-    		$z++;
-    		my $newDocid = "$x.$y.$z";
-    
-    		$emldoc =~ s/packageId=\"$docid\"/packageId=\"$newDocid\"/;
-   		$response = $metacat->update($newDocid, $emldoc);
+            #debug("Document created by handleModAccept is " . $emldoc);
+            # update the document
+            my $docid = $FORM::docid;
 
-    		if (! $response) {
-        		debug("Error while updating in handleModAccept.");
-    			#push(@errorMessages, $metacat->getMessage());
-        		$errorMessage = $errorMessage." Failed while updating the document with new access rules.";  
-		}
+            my $x;
+            my $y;
+            my $z;
 
-		# get the contact email address from the 
-   		$xmldoc = $parser->parse_string($emldoc);
+            ($x, $y, $z) = split(/\./, $docid); 
+            $z++;
+            my $newDocid = "$x.$y.$z";
 
-   		if ($xmldoc eq "" || $xmldoc=~ /<error/) {
-			# not able to parse
-       			$errorMessage = $errorMessage." Error in reading the docid:".$docid;
-		} else {
-	    		my $findNodes = $xmldoc->findnodes('//dataset/contact');
-	    		if($findNodes->size() > 0){
-				# found contact email address
-				my $node = '';
-				foreach $node ($findNodes->get_nodelist) {
-					$contactEmailAddress = findValue($node,'electronicMailAddress');
-					my $surName = findValue($node,'individualName/surName');
-					my $givenName = findValue($node,'individualName/givenName');
-					my $organizationName = findValue($node,'organizaitionName');
-	
-					if($surName ne ''){
-						$contactName = $givenName.' '.$surName;
-					} else {
-						$contactName = $organizationName;
-					}
-				}
-			} else {
-				$contactEmailAddress = '';
-			}
-    			$findNodes = $xmldoc->findnodes('//dataset/title');
-			if($findNodes->size() > 0){
-				# found title
-				my $node = '';
-				foreach $node ($findNodes->get_nodelist) {
-					$title = findValue($node,'../title');
-				}
-			} else {
-				$title = '';
-			}
+            $emldoc =~ s/packageId=\"$docid\"/packageId=\"$newDocid\"/;
+            $response = $metacat->update($newDocid, $emldoc);
 
-			$findNodes = $xmldoc->findnodes('//dataset/access/allow');
-			if($findNodes->size() > 0){
-			# found title
-                                my $node = '';
-                                foreach $node ($findNodes->get_nodelist) {
-                                        my $perm = findValue($node,'permission');
-					if($perm ne 'all'){
-						$userDN = findValue($node,'principal');
-					}
-                                }
+            if (! $response) {
+                debug("Error while updating in handleModAccept.");
+                #push(@errorMessages, $metacat->getMessage());
+                $errorMessage = $errorMessage." Failed while updating the document with new access rules.";  
+            }
+
+            # get the contact email address from the 
+            $xmldoc = $parser->parse_string($emldoc);
+
+            if ($xmldoc eq "" || $xmldoc=~ /<error/) {
+                # not able to parse
+                $errorMessage = $errorMessage." Error in reading the docid:".$docid;
+            } else {
+                my $findNodes = $xmldoc->findnodes('//dataset/contact');
+                if ($findNodes->size() > 0) {
+                    # found contact email address
+                    my $node = '';
+                    foreach $node ($findNodes->get_nodelist) {
+                        $contactEmailAddress = findValue($node,'electronicMailAddress');
+                        my $surName = findValue($node,'individualName/surName');
+                        my $givenName = findValue($node,'individualName/givenName');
+                        my $organizationName = findValue($node,'organizaitionName');
+
+                        if ($surName ne '') {
+                            $contactName = $givenName.' '.$surName;
                         } else {
-                                $userDN = '';
+                            $contactName = $organizationName;
                         }
+                    }
+                } else {
+                    $contactEmailAddress = '';
+                }
+                $findNodes = $xmldoc->findnodes('//dataset/title');
+                if ($findNodes->size() > 0) {
+                    # found title
+                    my $node = '';
+                    foreach $node ($findNodes->get_nodelist) {
+                        $title = findValue($node,'../title');
+                    }
+                } else {
+                    $title = '';
+                }
 
-		}	
-	}
+                $findNodes = $xmldoc->findnodes('//dataset/access/allow');
+                if ($findNodes->size() > 0) {
+                    # found title
+                    my $node = '';
+                    foreach $node ($findNodes->get_nodelist) {
+                        my $perm = findValue($node,'permission');
+                        if ($perm ne 'all') {
+                            $userDN = findValue($node,'principal');
+                        }
+                    }
+                } else {
+                    $userDN = '';
+                }
+            }
+        }
     }
+
     # send notification to the user and the moderator
     if ($errorMessage eq '') {
-    	mod_sendNotification($title, $contactEmailAddress, $contactName, 'Document '.$FORM::docid.' Accepted');
-        if($FORM::review ne ''){
-                $errorMessage = mod_storeReview('accept', $metacat, $userDN);
-                if ($errorMessage ne '') {
-                        processResultTemplate('accept', 'failure', $errorMessage);
-                        return;
-                }
+        modSendNotification($title, $contactEmailAddress, $contactName, 'Document '.$FORM::docid.' Accepted');
+        if ($FORM::review ne '') {
+            $errorMessage = modStoreReview('accept', $metacat, $userDN);
+            if ($errorMessage ne '') {
+                processResultTemplate('accept', 'failure', $errorMessage);
+                return;
+            }
         }
-    	# send notifications
-	processResultTemplate('accept', 'success', $errorMessage);		
+        # send notifications
+        processResultTemplate('accept', 'success', $errorMessage);
     } else {
-	processResultTemplate('accept', 'failure', $errorMessage);		
+        processResultTemplate('accept', 'failure', $errorMessage);
     }
 }
 
@@ -3057,8 +3024,8 @@
 
     debug("Stage is mod_decline");
 
-    if(isModerator('decline')<0){
-    	return;
+    if (isModerator('decline') < 0) {
+        return;
     }
 
     # variables for contact information
@@ -3074,86 +3041,86 @@
         #push(@errorMessages, $metacat->getMessage());
         $errorMessage = $errorMessage." Failed during moderator login.";
     } else {
-		# read the document and get the contact name and address
-	my $parser = XML::LibXML->new();
-    	my $docid = $FORM::docid;
+        # read the document and get the contact name and address
+        my $parser = XML::LibXML->new();
+        my $docid = $FORM::docid;
 
-	$response = $metacat->read($docid);
- 	my $doc = $response->content();
-    	my $xmldoc = $parser->parse_string($doc);
+        $response = $metacat->read($docid);
+        my $doc = $response->content();
+        my $xmldoc = $parser->parse_string($doc);
 
-    	if ($xmldoc eq "" || $doc=~ /<error/) {
-	    # not able to parse
-	    $errorMessage = $errorMessage." Error in reading the docid:".$docid;
-	} else {
-	    my $findNodes = $xmldoc->findnodes('//dataset/contact');
-	    if($findNodes->size() > 0){
-		# found contact email address
-		my $node = '';
-		foreach $node ($findNodes->get_nodelist) {
-			$contactEmailAddress = findValue($node,'electronicMailAddress');
-			my $surName = findValue($node,'individualName/surName');
-			my $givenName = findValue($node,'individualName/givenName');
-			my $organizationName = findValue($node,'organizaitionName');
-	
-			if($surName ne ''){
-				$contactName = $givenName.' '.$surName;
-			} else {
-				$contactName = $organizationName;
-			}
-		}
-	    } else {
-		$contactEmailAddress = '';
-	    }
-	    $findNodes = $xmldoc->findnodes('//dataset/title');
-	    if($findNodes->size() > 0){
-		# found title
-		my $node = '';
-		foreach $node ($findNodes->get_nodelist) {
-			$title = findValue($node,'../title');
-		}
-	    } else {
-		$title = '';
-	    }
+        if ($xmldoc eq "" || $doc=~ /<error/) {
+            # not able to parse
+            $errorMessage = $errorMessage." Error in reading the docid:".$docid;
+        } else {
+            my $findNodes = $xmldoc->findnodes('//dataset/contact');
+            if ($findNodes->size() > 0) {
+                # found contact email address
+                my $node = '';
+                foreach $node ($findNodes->get_nodelist) {
+                    $contactEmailAddress = findValue($node,'electronicMailAddress');
+                    my $surName = findValue($node,'individualName/surName');
+                    my $givenName = findValue($node,'individualName/givenName');
+                    my $organizationName = findValue($node,'organizaitionName');
 
-	    $findNodes = $xmldoc->findnodes('//dataset/access/allow');
-            if($findNodes->size() > 0){
-            	# found title
+                    if ($surName ne '') {
+                        $contactName = $givenName.' '.$surName;
+                    } else {
+                        $contactName = $organizationName;
+                    }
+                }
+            } else {
+                $contactEmailAddress = '';
+            }
+            $findNodes = $xmldoc->findnodes('//dataset/title');
+            if ($findNodes->size() > 0) {
+                # found title
                 my $node = '';
                 foreach $node ($findNodes->get_nodelist) {
+                    $title = findValue($node,'../title');
+                }
+            } else {
+                $title = '';
+            }
+
+            $findNodes = $xmldoc->findnodes('//dataset/access/allow');
+            if ($findNodes->size() > 0) {
+                # found title
+                my $node = '';
+                foreach $node ($findNodes->get_nodelist) {
                      my $perm = findValue($node,'permission');
-                     if($perm ne 'all'){
+                     if ($perm ne 'all') {
                           $userDN = findValue($node,'principal');
                      }
                 }
             } else {
                 $userDN = '';
             }
-	}
+        }
 
-	$response = $metacat->delete($docid);
-	if (!$response) {
-	       	debug("Error while deleting document in handleModDecline.");
-	    	#push(@errorMessages, $metacat->getMessage());
-	       	$errorMessage = $errorMessage." Failed during deleting $docid. Please check if you are authorized to delete this document or if the document is not already deleted."; 
-	} else {
-		debug("Document deleted by handleModDecline is " . $docid);	
-	}
+        $response = $metacat->delete($docid);
+        if (!$response) {
+            debug("Error while deleting document in handleModDecline.");
+            #push(@errorMessages, $metacat->getMessage());
+            $errorMessage = $errorMessage." Failed during deleting $docid. Please check if you are authorized to delete this document or if the document is not already deleted."; 
+        } else {
+            debug("Document deleted by handleModDecline is " . $docid);
+        }
     }
 
     if ($errorMessage eq '') {
-	mod_sendNotification($title, $contactEmailAddress, $contactName, 'Document '.$FORM::docid.' Rejected');
-        if($FORM::review ne ''){
-                $errorMessage = mod_storeReview('decline', $metacat, $userDN);
-                if ($errorMessage ne '') {
-                        processResultTemplate('decline', 'failure', $errorMessage);
-			return;
-                }
+        modSendNotification($title, $contactEmailAddress, $contactName, 'Document '.$FORM::docid.' Rejected');
+        if ($FORM::review ne '') {
+            $errorMessage = modStoreReview('decline', $metacat, $userDN);
+            if ($errorMessage ne '') {
+                processResultTemplate('decline', 'failure', $errorMessage);
+                return;
+            }
         }
         # send notifications
-	processResultTemplate('decline', 'success', $errorMessage);		
+        processResultTemplate('decline', 'success', $errorMessage);
     } else {
-	processResultTemplate('decline', 'failure', $errorMessage);		
+        processResultTemplate('decline', 'failure', $errorMessage);
     }
 }
 
@@ -3170,233 +3137,231 @@
 
     debug("Stage is mod_revise");
 
-    if(isModerator('revise')<0){
-    	return;
+    if (isModerator('revise') < 0) {
+        return;
     }
-	
+
     # variables for contact information
     my $contactEmailAddress;
     my $contactName;
     my $title;
     my $userDN = '';
- 
+
     # Log into metacat
     my $response = $metacat->login($modUsername, $modPassword);
-    
+
     if (! $response) {
-    # Could not login
+        # Could not login
         #push(@errorMessages, $metacat->getMessage());
         $errorMessage = $errorMessage." Failed during moderator login.";
 
     } else {
-	# read the document and get the contact name and address
-	my $parser = XML::LibXML->new();
-    	my $docid = $FORM::docid;
+        # read the document and get the contact name and address
+        my $parser = XML::LibXML->new();
+        my $docid = $FORM::docid;
 
-	$response = $metacat->read($docid);
- 	my $doc = $response->content();
-    	my $xmldoc = $parser->parse_string($doc);
+        $response = $metacat->read($docid);
+        my $doc = $response->content();
+        my $xmldoc = $parser->parse_string($doc);
 
-    	if ($xmldoc eq "" || $doc=~ /<error/) {
-			# not able to parse
-	       	$errorMessage = $errorMessage." Error in reading the docid:".$docid;
-	} else {
-		    my $findNodes = $xmldoc->findnodes('//dataset/contact');
-		    if($findNodes->size() > 0){
-				# found contact email address
-				my $node = '';
-				foreach $node ($findNodes->get_nodelist) {
-					$contactEmailAddress = findValue($node,'electronicMailAddress');
+        if ($xmldoc eq "" || $doc=~ /<error/) {
+            # not able to parse
+            $errorMessage = $errorMessage." Error in reading the docid:".$docid;
+        } else {
+            my $findNodes = $xmldoc->findnodes('//dataset/contact');
+            if ($findNodes->size() > 0) {
+                # found contact email address
+                my $node = '';
+                foreach $node ($findNodes->get_nodelist) {
+                    $contactEmailAddress = findValue($node,'electronicMailAddress');
 
-					my $surName = findValue($node,'individualName/surName');
-					my $givenName = findValue($node,'individualName/givenName');
-					my $organizationName = findValue($node,'organizaitionName');
-		
-					if($surName ne ''){
-						$contactName = $givenName.' '.$surName;
-					} else {
-						$contactName = $organizationName;
-					}
-				}
-			} else {
-				$contactEmailAddress = '';
-			}
+                    my $surName = findValue($node,'individualName/surName');
+                    my $givenName = findValue($node,'individualName/givenName');
+                    my $organizationName = findValue($node,'organizaitionName');
 
-  	    	        $findNodes = $xmldoc->findnodes('//dataset/title');
-			if($findNodes->size() > 0){
-				# found title
-				my $node = '';
-				foreach $node ($findNodes->get_nodelist) {
-					$title = findValue($node,'../title');
-				}
-			} else {
-				$title = '';
-			}
+                    if ($surName ne '') {
+                        $contactName = $givenName.' '.$surName;
+                    } else {
+                        $contactName = $organizationName;
+                    }
+                }
+            } else {
+                $contactEmailAddress = '';
+            }
 
-			$findNodes = $xmldoc->findnodes('//dataset/access/allow');
-                        if($findNodes->size() > 0){
-                        # found title
-                                my $node = '';
-                                foreach $node ($findNodes->get_nodelist) {
-                                        my $perm = findValue($node,'permission');
-                                        if($perm ne 'all'){
-                                                $userDN = findValue($node,'principal');
-                                        }
-                                }
-                        } else {
-                                $userDN = '';
-                        }
+            $findNodes = $xmldoc->findnodes('//dataset/title');
+            if ($findNodes->size() > 0) {
+                # found title
+                my $node = '';
+                foreach $node ($findNodes->get_nodelist) {
+                    $title = findValue($node,'../title');
+                }
+            } else {
+                $title = '';
+            }
 
-		}
+            $findNodes = $xmldoc->findnodes('//dataset/access/allow');
+            if ($findNodes->size() > 0) {
+                # found title
+                my $node = '';
+                foreach $node ($findNodes->get_nodelist) {
+                    my $perm = findValue($node,'permission');
+                    if ($perm ne 'all') {
+                        $userDN = findValue($node,'principal');
+                    }
+                }
+            } else {
+                $userDN = '';
+            }
+        }
 
- 		my ($emldoc, $temp) = split('</dataset>', $doc);
-                $emldoc .= "</dataset>\n<additionalMetadata>\n<moderatorComment>Revision Requested</moderatorComment>\n</additionalMetadata>";
-                $emldoc .= "\n</eml:eml>\n";
-                #debug("Document created by handleModAccept is " . $emldoc);
-                # update the document
-                my $docid = $FORM::docid;
+        my ($emldoc, $temp) = split('</dataset>', $doc);
+        $emldoc .= "</dataset>\n<additionalMetadata>\n<moderatorComment>Revision Requested</moderatorComment>\n</additionalMetadata>";
+        $emldoc .= "\n</eml:eml>\n";
+        #debug("Document created by handleModAccept is " . $emldoc);
+        # update the document
+        my $docid = $FORM::docid;
 
-                my $x;
-                my $y;
-                my $z;
+        my $x;
+        my $y;
+        my $z;
 
-                ($x, $y, $z) = split(/\./, $docid);
-                $z++;
-                my $newDocid = "$x.$y.$z";
+        ($x, $y, $z) = split(/\./, $docid);
+        $z++;
+        my $newDocid = "$x.$y.$z";
 
-		$emldoc =~ s/packageId=\"$docid\"/packageId=\"$newDocid\"/;
-                $response = $metacat->update($newDocid, $emldoc);
+        $emldoc =~ s/packageId=\"$docid\"/packageId=\"$newDocid\"/;
+        $response = $metacat->update($newDocid, $emldoc);
 
-                if (! $response) {
-                        debug("Error while updating in handleModAccept.".$metacat->getMessage());
-                        #push(@errorMessages, $metacat->getMessage());
-			$errorMessage = $errorMessage." Failed while updating the document with additional Metadata.";
-                }
+        if (!$response) {
+            debug("Error while updating in handleModAccept.".$metacat->getMessage());
+            #push(@errorMessages, $metacat->getMessage());
+            $errorMessage = $errorMessage." Failed while updating the document with additional Metadata.";
+        }
 
-	}
+    }
     if ($errorMessage eq '') {
-	mod_sendNotification($title, $contactEmailAddress, $contactName, "Revise document: ".$FORM::docid);
-        if($FORM::review ne ''){
-        	$errorMessage = mod_storeReview('revise', $metacat, $userDN);
-    		if ($errorMessage ne '') {
-			processResultTemplate('revise', 'failure', $errorMessage);		
-			return;
-		}
-	}
-	# send notifications
-	processResultTemplate('revise', 'success', $errorMessage);		
+        modSendNotification($title, $contactEmailAddress, $contactName, "Revise document: ".$FORM::docid);
+        if ($FORM::review ne '') {
+            $errorMessage = modStoreReview('revise', $metacat, $userDN);
+            if ($errorMessage ne '') {
+                processResultTemplate('revise', 'failure', $errorMessage);
+                return;
+            }
+        }
+        # send notifications
+        processResultTemplate('revise', 'success', $errorMessage);
     } else {
-	processResultTemplate('revise', 'failure', $errorMessage);		
+        processResultTemplate('revise', 'failure', $errorMessage);
     }
 }
 
-sub mod_storeReview {
-	my $action = shift;
-	my $metacat = shift;
-	my $userDN = shift;
+sub modStoreReview {
+    my $action = shift;
+    my $metacat = shift;
+    my $userDN = shift;
 
-        my $gmt = gmtime($now);
-	my $parser = XML::LibXML->new();
- 	
-	# create the xml part that has to be inserted
-	my $review = '';
-        $review .= '<review>';
-        $review .= '<packageId>'.$FORM::docid.'</packageId>';
-        $review .= '<action>'.$action.'</action>';
-        $review .= '<datetime>'.$gmt.'</datetime>';
-        $review .= '<text>'.$FORM::review.'</text>';
-        $review .= '</review>';
+    my $gmt = gmtime($now);
+    my $parser = XML::LibXML->new();
 
-	# find out if a docid already exists...
-        my $docid = $FORM::docid;
-        my ($x, $y, $z) = split(/\./, $docid);
-        my $docidWithoutRev = $x.$y;
-	my $reviewDocumentId = '';
-        my $response = $metacat->squery("<pathquery><querytitle>Moderator-Search</querytitle><querygroup operator='INTERSECT'><queryterm searchmode='contains' casesensitive='false'><value>".$x.".".$y."</value><pathexpr>/reviewHistory/review/packageId</pathexpr></queryterm></querygroup></pathquery>"); 
+    # create the xml part that has to be inserted
+    my $review = '';
+    $review .= '<review>';
+    $review .= '<packageId>'.$FORM::docid.'</packageId>';
+    $review .= '<action>'.$action.'</action>';
+    $review .= '<datetime>'.$gmt.'</datetime>';
+    $review .= '<text>'.$FORM::review.'</text>';
+    $review .= '</review>';
 
-        my $doc = $response->content();
-        my $xmldoc = $parser->parse_string($doc);
+    # find out if a docid already exists...
+    my $docid = $FORM::docid;
+    my ($x, $y, $z) = split(/\./, $docid);
+    my $docidWithoutRev = $x.$y;
+    my $reviewDocumentId = '';
+    my $response = $metacat->squery("<pathquery><querytitle>Moderator-Search</querytitle><querygroup operator='INTERSECT'><queryterm searchmode='contains' casesensitive='false'><value>".$x.".".$y."</value><pathexpr>/reviewHistory/review/packageId</pathexpr></queryterm></querygroup></pathquery>"); 
 
-        if ($xmldoc eq "" || $doc=~ /<error/) {
-                # not able to parse
-                return " Unable to store review for the docid:".$docid;
-        } else {
-                    my $findNodes = $xmldoc->findnodes('//resultset/document');
-                    if($findNodes->size() > 0){
-                        # found contact email address
-                        my $node = '';
-                        foreach $node ($findNodes->get_nodelist) {
-                              $reviewDocumentId = findValue($node,'docid');
-                        }
-			
-			#update the old document
-			$response = $metacat->read($reviewDocumentId);
-                        $doc = $response->content();
-                        $xmldoc = $parser->parse_string($doc);
+    my $doc = $response->content();
+    my $xmldoc = $parser->parse_string($doc);
 
+    if ($xmldoc eq "" || $doc=~ /<error/) {
+        # not able to parse
+        return " Unable to store review for the docid:".$docid;
+    } else {
+        my $findNodes = $xmldoc->findnodes('//resultset/document');
+        if ($findNodes->size() > 0) {
+            # found contact email address
+            my $node = '';
+            foreach $node ($findNodes->get_nodelist) {
+                $reviewDocumentId = findValue($node,'docid');
+            }
 
-                        if ($xmldoc eq "" || $doc=~ /<error/){
-                                return " Unable to read the document from Metacat which has the old reviews for the docid:".$docid;
-                        } else {
-                                my ($reviewdoc, $temp) = split('</reviewHistory>', $doc);
-                                $reviewdoc .= $review."\n</reviewHistory>\n";
-                                ($x, $y, $z) = split(/\./, $reviewDocumentId);
-                                $z++;
-                                $reviewDocumentId = "$x.$y.$z";
-                                $response = $metacat->update($reviewDocumentId, $reviewdoc);
-                                if ($response != '1') {
-                                        return " Unable to update the review on Metacat for the docid:".$docid;
-                                } else {
-					$response = $metacat->setaccess($reviewDocumentId, $userDN, "read", "allow", "denyFirst");
-        			        if ($response != '1') {
-                                		return " Unable to set access for the review document in Metacat for the docid:".$docid;
-                        		}
-				foreach(split(":",$moderators)){
-					$response = $metacat->setaccess($reviewDocumentId, $_, "all", "allow", "denyFirst");
- 					if ($response != '1') {
-                                		return " Unable to set access for the review document in Metacat for the docid:".$docid;
-                        		}
-    				}
-				}
+            # update the old document
+            $response = $metacat->read($reviewDocumentId);
+            $doc = $response->content();
+            $xmldoc = $parser->parse_string($doc);
+
+            if ($xmldoc eq "" || $doc=~ /<error/) {
+                return " Unable to read the document from Metacat which has the old reviews for the docid:".$docid;
+            } else {
+                my ($reviewdoc, $temp) = split('</reviewHistory>', $doc);
+                $reviewdoc .= $review."\n</reviewHistory>\n";
+                ($x, $y, $z) = split(/\./, $reviewDocumentId);
+                $z++;
+                $reviewDocumentId = "$x.$y.$z";
+                $response = $metacat->update($reviewDocumentId, $reviewdoc);
+                if ($response != '1') {
+                    return " Unable to update the review on Metacat for the docid:".$docid;
+                } else {
+                    $response = $metacat->setaccess($reviewDocumentId, $userDN, "read", "allow", "denyFirst");
+                    if ($response != '1') {
+                        return " Unable to set access for the review document in Metacat for the docid:".$docid;
+                    }
+                    foreach (split(":",$moderators)) {
+                        $response = $metacat->setaccess($reviewDocumentId, $_, "all", "allow", "denyFirst");
+                        if ($response != '1') {
+                            return " Unable to set access for the review document in Metacat for the docid:".$docid;
                         }
-                    } else {
-			#insert a new document
-			my $id = $metacat->getLastId('esa_reviews');
-			if ($id eq "null"){
-				$id = 'esa_reviews.1.1'; 
-			} else {
-                              	($x, $y, $z) = split(/\./, $id);
-                                $y++;
-                                $id = "$x.$y.1";
-			}
-			
-			my $reviewDoc = '';
-			$reviewDoc .= "<?xml version=\"1.0\"?>";
-			$reviewDoc .= "<reviewHistory registryName=\"".$skinName."\">";
-			$reviewDoc .= $review;
-			$reviewDoc .= "</reviewHistory>";
-	                $response = $metacat->insert($id, $reviewDoc);
-        	        if ($response != '1') {
-                		return " Unable to insert the review on Metacat for the docid:".$docid;
-                        } else {
-				# set access
-				$response = $metacat->setaccess($id, $userDN, "read", "allow", "denyFirst");
- 				if ($response != '1') {
-                                	return " Unable to set access for the review document in Metacat for the docid:".$docid;
-                        	}
-				foreach(split(":",$moderators)){
-					$response = $metacat->setaccess($id, $_, "all", "allow", "denyFirst");
- 					if ($response != '1') {
-                                		return " Unable to set access for the review document in Metacat for the docid:".$docid;
-                        		}
-    				}
-			}
-		    }		   
-	} 
-	
-	return '';
-	# find out if a document already exist. if not then insert a new one. otherwise update the old one	
-	# the owner of the document is the moderator 
+                    }
+                }
+            }
+        } else {
+            #insert a new document
+            my $id = $metacat->getLastId('esa_reviews');
+            if ($id eq "null") {
+                $id = 'esa_reviews.1.1'; 
+            } else {
+                ($x, $y, $z) = split(/\./, $id);
+                $y++;
+                $id = "$x.$y.1";
+            }
+
+            my $reviewDoc = '';
+            $reviewDoc .= "<?xml version=\"1.0\"?>";
+            $reviewDoc .= "<reviewHistory registryName=\"".$skinName."\">";
+            $reviewDoc .= $review;
+            $reviewDoc .= "</reviewHistory>";
+            $response = $metacat->insert($id, $reviewDoc);
+            if ($response != '1') {
+                return " Unable to insert the review on Metacat for the docid:".$docid;
+            } else {
+                # set access
+                $response = $metacat->setaccess($id, $userDN, "read", "allow", "denyFirst");
+                if ($response != '1') {
+                    return " Unable to set access for the review document in Metacat for the docid:".$docid;
+                }
+                foreach (split(":",$moderators)) {
+                    $response = $metacat->setaccess($id, $_, "all", "allow", "denyFirst");
+                    if ($response != '1') {
+                        return " Unable to set access for the review document in Metacat for the docid:".$docid;
+                    }
+                }
+            }
+        }
+    }
+
+    return '';
+    # find out if a document already exist. if not then insert a new one. otherwise update the old one    
+    # the owner of the document is the moderator 
 }
 
 ################################################################################
@@ -3404,31 +3369,31 @@
 # send an email message to the moderator and the contact 
 #
 ################################################################################
-sub mod_sendNotification {
-	my $title = shift;
-	my $contactEmailAddress = shift;
-	my $contactName = shift;
-	my $subject = shift;
+sub modSendNotification {
+    my $title = shift;
+    my $contactEmailAddress = shift;
+    my $contactName = shift;
+    my $subject = shift;
 
-	debug($subject);
+    debug($subject);
     # send notification to the user and the moderator
-	my $templateVars = { 'stage' => $FORM::stage };
-	my ($x, $y, $z) = split(/\./, $FORM::docid);
-        my $docidWithoutRev = $x.".".$y;
-	$$templateVars{'docid'} = $docidWithoutRev;
-	$$templateVars{'comment'} = $FORM::review;
-	$$templateVars{'contactName'} = $contactName;
-	$$templateVars{'dpTitle'} = $title;
+    my $templateVars = { 'stage' => $FORM::stage };
+    my ($x, $y, $z) = split(/\./, $FORM::docid);
+    my $docidWithoutRev = $x.".".$y;
+    $$templateVars{'docid'} = $docidWithoutRev;
+    $$templateVars{'comment'} = $FORM::review;
+    $$templateVars{'contactName'} = $contactName;
+    $$templateVars{'dpTitle'} = $title;
 
-	$$templateVars{'recipient_status'} = 'moderator';
-	sendNotification($email->{'sender'}, $email->{'recipient'}, $subject, 
-							$templates->{'modEmailNotification'}, $templateVars);
-	if($contactEmailAddress ne ''){
-		# send notification to contact email address specified in cfg   
-		$$templateVars{'recipient_status'} = 'user';
-		sendNotification($email->{'sender'}, $contactEmailAddress, 
-				$subject, $templates->{'modEmailNotification'}, $templateVars);
-	}
+    $$templateVars{'recipient_status'} = 'moderator';
+    sendNotification($email->{'sender'}, $email->{'recipient'}, $subject, 
+                            $templates->{'modEmailNotification'}, $templateVars);
+    if ($contactEmailAddress ne '') {
+        # send notification to contact email address specified in cfg   
+        $$templateVars{'recipient_status'} = 'user';
+        sendNotification($email->{'sender'}, $contactEmailAddress, 
+            $subject, $templates->{'modEmailNotification'}, $templateVars);
+    }
 }
 
 ################################################################################
@@ -3470,23 +3435,23 @@
     my $stage = shift;
     my $result = shift;
     my $message = shift;
-   
-    if($result eq 'success'){
-	if($stage eq 'accept'){
-		$message = "Dataset (docid:".$FORM::docid.") accepted ";
-        } elsif($stage eq 'decline'){
-		$message = "Dataset (docid:".$FORM::docid.") declined ";
+
+    if ($result eq 'success') {
+        if ($stage eq 'accept') {
+            $message = "Dataset (docid:".$FORM::docid.") accepted ";
+        } elsif ($stage eq 'decline') {
+            $message = "Dataset (docid:".$FORM::docid.") declined ";
         } else {
-		$message = "Revision requested for dataset (docid:".$FORM::docid.") ";
+            $message = "Revision requested for dataset (docid:".$FORM::docid.") ";
         }
     } else {
-	if($stage eq 'accept'){
-		$message = "Failure in accepting docid: ".$FORM::docid." (".$message.")";
-        } elsif($stage eq 'decline'){
-		$message = "Failure in declining docid: ".$FORM::docid." (".$message.")";
+        if ($stage eq 'accept') {
+            $message = "Failure in accepting docid: ".$FORM::docid." (".$message.")";
+        } elsif($stage eq 'decline') {
+            $message = "Failure in declining docid: ".$FORM::docid." (".$message.")";
         } else {
-		$message = "Failure in requesting revision of docid: ".$FORM::docid." (".$message.")";
-	}
+            $message = "Failure in requesting revision of docid: ".$FORM::docid." (".$message.")";
+        }
     }
     $$templateVars{'message'} = $message;
     $template->process($templates->{'modResult'}, $templateVars);
@@ -3513,12 +3478,12 @@
 
     $$templateVars{'providerGivenName'} = normalizeCD($FORM::providerGivenName);
     $$templateVars{'providerSurName'} = normalizeCD($FORM::providerSurName);
-    if($FORM::site eq "Select your station here."){
+    if ($FORM::site eq "Select your station here.") {
         $$templateVars{'site'} = "";
-    }else{
+    } else {
         $$templateVars{'site'} = $FORM::site;
     }
-    if($skinName eq "nceas"){
+    if ($skinName eq "nceas") {
         $$templateVars{'wg'} = \@FORM::wg;
     }
     $$templateVars{'identifier'} = normalizeCD($FORM::identifier);
@@ -3540,17 +3505,16 @@
     $$templateVars{'origFAX'} = normalizeCD($FORM::origFAX);
     $$templateVars{'origEmail'} = normalizeCD($FORM::origEmail);
     $$templateVars{'useOrigAddress'} = normalizeCD($FORM::useOrigAddress);
-    if($FORM::useOrigAddress eq "on"){
-      
+    if ($FORM::useOrigAddress eq "on") {
         $$templateVars{'origNamefirstContact'} = normalizeCD($FORM::origNamefirst0);
         $$templateVars{'origNamelastContact'} = normalizeCD($FORM::origNamelast0);
         $$templateVars{'origNameOrgContact'} = normalizeCD($FORM::origNameOrg);
         $$templateVars{'origDeliveryContact'} = normalizeCD($FORM::origDelivery); 
         $$templateVars{'origCityContact'} = normalizeCD($FORM::origCity);
-        if($FORM::origState =~ /select state/i){
-        $$templateVars{'origStateContact'} = "";
-        }else{
-        $$templateVars{'origStateContact'} = $FORM::origState;
+        if ($FORM::origState =~ /select state/i) {
+            $$templateVars{'origStateContact'} = "";
+        } else {
+            $$templateVars{'origStateContact'} = $FORM::origState;
         }
         $$templateVars{'origStateOtherContact'} = normalizeCD($FORM::origStateOther);
         $$templateVars{'origZIPContact'} = normalizeCD($FORM::origZIP);
@@ -3558,16 +3522,16 @@
         $$templateVars{'origPhoneContact'} = normalizeCD($FORM::origPhone);
         $$templateVars{'origFAXContact'} = normalizeCD($FORM::origFAX);
         $$templateVars{'origEmailContact'} = normalizeCD($FORM::origEmail);
-    }else{
+    } else {
         $$templateVars{'origNamefirstContact'} = normalizeCD($FORM::origNamefirstContact);
         $$templateVars{'origNamelastContact'} = normalizeCD($FORM::origNamelastContact);
         $$templateVars{'origNameOrgContact'} = normalizeCD($FORM::origNameOrgContact);
         $$templateVars{'origDeliveryContact'} = normalizeCD($FORM::origDeliveryContact); 
         $$templateVars{'origCityContact'} = normalizeCD($FORM::origCityContact);
-        if($FORM::origStateContact =~ /select state/i){
-        $$templateVars{'origStateContact'} = "";
-        }else{
-        $$templateVars{'origStateContact'} = $FORM::origStateContact;
+        if ($FORM::origStateContact =~ /select state/i) {
+            $$templateVars{'origStateContact'} = "";
+        } else {
+            $$templateVars{'origStateContact'} = $FORM::origStateContact;
         }
         $$templateVars{'origStateOtherContact'} = normalizeCD($FORM::origStateOtherContact);
         $$templateVars{'origZIPContact'} = normalizeCD($FORM::origZIPContact);
@@ -3582,7 +3546,7 @@
     my $aoRoleArray = \@FORM::aoRole;
     my $aoCount = 1;
 
-    for(my $i = 0; $i <= $#$aoRoleArray; $i++){
+    for (my $i = 0; $i <= $#$aoRoleArray; $i++) {
         if (hasContent($aoFNArray->[$i]) && hasContent($aoLNArray->[$i])) {
             debug("Registry processing Associated Party: origName = ".$aoFNArray->[$i]
                   ." origNamelast = ".$aoLNArray->[$i]." origRole = "
@@ -3603,7 +3567,7 @@
     my $keywordThArray = \@FORM::keywordTh;
     my $keyCount = 1;
 
-    for(my $i = 0; $i <= $#$keywordArray; $i++){
+    for (my $i = 0; $i <= $#$keywordArray; $i++) {
         if (hasContent($keywordArray->[$i])) {
             debug("Registry processing keyword: keyword = ".$keywordArray->[$i]."
                   keywordType = ".$keywordTypeArray->[$i]."
@@ -3618,12 +3582,12 @@
 
     $$templateVars{'addComments'} = normalizeCD($FORM::addComments);
     $$templateVars{'useConstraints'} = $FORM::useConstraints;
-    if($FORM::useConstraints eq "other"){
+    if ($FORM::useConstraints eq "other") {
         $$templateVars{'useConstraintsOther'} = $FORM::useConstraintsOther;
     }
     $$templateVars{'url'} = $FORM::url;
     $$templateVars{'dataMedium'} = $FORM::dataMedium;
-    if($FORM::dataMedium eq "other"){
+    if ($FORM::dataMedium eq "other") {
         $$templateVars{'dataMediumOther'} = normalizeCD($FORM::dataMediumOther);
     }
     $$templateVars{'beginningYear'} = $FORM::beginningYear;
@@ -3655,7 +3619,7 @@
     my $taxonNameArray = \@FORM::taxonName;
     my $taxonCount = 1;
 
-    for(my $i = 0; $i <= $#$taxonNameArray; $i++){
+    for (my $i = 0; $i <= $#$taxonNameArray; $i++) {
         if (hasContent($taxonRankArray->[$i]) && hasContent($taxonNameArray->[$i])) {
             debug("Registry processing keyword: trv = ".$taxonRankArray->[$i]
                     ." trn = ".$taxonNameArray->[$i]);
@@ -3724,16 +3688,16 @@
 
     # Check if the session exists
     my $session = CGI::Session->load();
-    if ( !($session->is_empty || $session->is_expired)) {
+    if (!($session->is_empty || $session->is_expired)) {
         $$templateVars{'userLoggedIn'} = 'true';
     }
 
     if (! $error) {
         # If no errors, then print out data in confirm Data template
         $$templateVars{'section'} = "Confirm Data";
-        $template->process( $templates->{'confirmData'}, $templateVars);
+        $template->process($templates->{'confirmData'}, $templateVars);
 
-    } else{    
+    } else {    
     # Errors from validation function. print the errors out using the response template
     if (scalar(@errorMessages)) {
         $$templateVars{'status'} = 'failure';
@@ -3743,7 +3707,7 @@
         # Create our HTML response and send it back
     $$templateVars{'function'} = "submitted";
     $$templateVars{'section'} = "Submission Status";
-    $template->process( $templates->{'response'}, $templateVars);
+    $template->process($templates->{'response'}, $templateVars);
     }
 }
 
@@ -3765,7 +3729,7 @@
     $$templateVars{'docid'} = $FORM::docid;
 
     $$templateVars{'form'} = 're_entry';
-    $template->process( $templates->{'entry'}, $templateVars);
+    $template->process($templates->{'entry'}, $templateVars);
 }
 
 
@@ -3799,7 +3763,7 @@
     $$templateVars{'origEmail'} = $FORM::origEmail;
     if ($FORM::useSiteCoord ne "") {
         $$templateVars{'useOrigAddress'} = "CHECKED";
-    }else{
+    } else {
         $$templateVars{'useOrigAddress'} = $FORM::useOrigAddress;
     }
     $$templateVars{'origNamefirstContact'} = $FORM::origNamefirstContact;
@@ -3817,42 +3781,43 @@
     
     $$templateVars{'aoCount'} = $FORM::aoCount;
     foreach my $origName (param()) {
-	if ($origName =~ /origNamefirst/) {
-	    my $origNameIndex = $origName;
-	    $origNameIndex =~ s/origNamefirst//; # get the index of the parameter 0, ..., 10
-	    my $origNamelast = "origNamelast".$origNameIndex;
-	    my $origRole = "origRole".$origNameIndex;
-	    if ( $origNameIndex =~ /[0-9]+/  && $origNameIndex > 0){
-		if (hasContent(param($origName)) && hasContent(param($origNamelast)) && hasContent(param($origRole))) {
-		    debug("Registry processing keyword: $origName = ".param($origName)." $origNamelast = ".param($origNamelast)." $origRole = ".param($origRole));
-		    $$templateVars{$origName} = normalizeCD(param($origName));
-		    $$templateVars{$origNamelast} = normalizeCD(param($origNamelast));
-		    $$templateVars{$origRole} = normalizeCD(param($origRole));
-		}
-	    }
-	}
+    if ($origName =~ /origNamefirst/) {
+        my $origNameIndex = $origName;
+        $origNameIndex =~ s/origNamefirst//; # get the index of the parameter 0, ..., 10
+        my $origNamelast = "origNamelast".$origNameIndex;
+        my $origRole = "origRole".$origNameIndex;
+        if ($origNameIndex =~ /[0-9]+/  && $origNameIndex > 0) {
+        if (hasContent(param($origName)) && hasContent(param($origNamelast)) && hasContent(param($origRole))) {
+            debug("Registry processing keyword: $origName = ".param($origName)." $origNamelast = ".param($origNamelast)." $origRole = ".param($origRole));
+            $$templateVars{$origName} = normalizeCD(param($origName));
+            $$templateVars{$origNamelast} = normalizeCD(param($origNamelast));
+            $$templateVars{$origRole} = normalizeCD(param($origRole));
+        }
+        }
     }
+    }
 
     $$templateVars{'abstract'} = $FORM::abstract;
     $$templateVars{'keyCount'} = $FORM::keyCount;
     foreach my $kyd (param()) {
-	if ($kyd =~ /keyword/) {
-	    my $keyIndex = $kyd;
-	    $keyIndex =~ s/keyword//; # get the index of the parameter 0, ..., 10
-	    my $keyType = "kwType".$keyIndex;
-	    my $keyTh = "kwTh".$keyIndex;
-	    if ( $keyIndex =~ /[0-9]+/ ){
-		if (hasContent(param($kyd)) && hasContent(param($keyType)) && hasContent(param($keyTh))) {
-		    debug("Registry processing keyword: $kyd = ".param($kyd)." $keyType = ".param($keyType)." $keyTh = ".param($keyTh));
-		    $$templateVars{$kyd} = param($kyd); 
+        if ($kyd =~ /keyword/) {
+            my $keyIndex = $kyd;
+            $keyIndex =~ s/keyword//; # get the index of the parameter 0, ..., 10
+            my $keyType = "kwType".$keyIndex;
+            my $keyTh = "kwTh".$keyIndex;
+            if ($keyIndex =~ /[0-9]+/) {
+                if (hasContent(param($kyd)) && hasContent(param($keyType)) && hasContent(param($keyTh))) {
+                    debug("Registry processing keyword: $kyd = ".param($kyd)." $keyType = ".param($keyType)." $keyTh = ".param($keyTh));
+                    $$templateVars{$kyd} = param($kyd);
                     my $tmp = param($keyType);  #convert the first letter to upper case
-		    $tmp =~ s/\b(\w)/\U$1/g;
+                    $tmp =~ s/\b(\w)/\U$1/g;
                     $$templateVars{$keyType} = $tmp;
-		    $$templateVars{$keyTh} = param($keyTh);
-		}
-	    }
-	}
+                    $$templateVars{$keyTh} = param($keyTh);
+                }
+            }
+        }
     }
+
     $$templateVars{'addComments'} = $FORM::addComments;
     $$templateVars{'useConstraints'} = $FORM::useConstraints;
     $$templateVars{'useConstraintsOther'} = $FORM::useConstraintsOther;
@@ -3866,10 +3831,10 @@
     $$templateVars{'endingMonth'} = $FORM::endingMonth;
     $$templateVars{'endingDay'} = $FORM::endingDay;
     $$templateVars{'geogdesc'} = $FORM::geogdesc;
-    if($FORM::useSiteCoord ne ""){
-    $$templateVars{'useSiteCoord'} = "CHECKED";
-    }else{
-    $$templateVars{'useSiteCoord'} = "";
+    if ($FORM::useSiteCoord ne "") {
+        $$templateVars{'useSiteCoord'} = "CHECKED";
+    } else {
+        $$templateVars{'useSiteCoord'} = "";
     }
     $$templateVars{'latDeg1'} = $FORM::latDeg1;
     $$templateVars{'latMin1'} = $FORM::latMin1;
@@ -3893,7 +3858,7 @@
             my $taxIndex = $trn;
             $taxIndex =~ s/taxonRankName//; # get the index of the parameter 0, ..., 10
             my $trv = "taxonRankValue".$taxIndex;
-            if ( $taxIndex =~ /[0-9]+/ ){
+            if ($taxIndex =~ /[0-9]+/) {
                 if (hasContent(param($trn)) && hasContent(param($trv))) {
                     debug("Registry processing taxon: $trn = ".param($trn)." $trv = ".param($trv));
                     $$templateVars{$trn} = param($trn);
@@ -3919,7 +3884,7 @@
         if ($upload =~ /upload_/) {
             my $fileIndex = $upload;
             $fileIndex =~ s/upload_//;
-            if ( $fileIndex =~ /[0-9]+/ ) {
+            if ($fileIndex =~ /[0-9]+/) {
                 if (hasContent(param($upload))) {
                     debug("Registry: returning filename: " . param($upload));
                     $$templateVars{"upload_$fileIndex"} = param($upload);
@@ -3951,7 +3916,7 @@
     if ($result->size > 1) {
         errMoreThanOne("$value");
     } else {
-        foreach $tempNode ($result->get_nodelist){
+        foreach $tempNode ($result->get_nodelist) {
             #print $tempNode->nodeName().":".$tempNode->textContent();
             #print "\n";
             return $tempNode->textContent();
@@ -3974,7 +3939,7 @@
     my $error;
 
     $result = $node->findnodes("./$value");
-    if($result->size > 1){
+    if ($result->size > 1) {
        errMoreThanOne("$value");
     } else {
         foreach $tempNode ($result->get_nodelist) {
@@ -3982,10 +3947,7 @@
             if ($childNodes->size() > 1) {
                 $error ="The tag $value has children which cannot be shown using the form. Please use Morpho to edit this document";    
                 push(@errorMessages, $error);
-                #if ($DEBUG == 1){ print $error."\n";}
             } else {
-                #print $tempNode->nodeName().":".$tempNode->textContent();
-                #print "\n";
                 return $tempNode->textContent();
             }
         }
@@ -4004,10 +3966,9 @@
     my $errVal = shift;
 
     my $result = $node->findnodes("$value");
-    if($result->size > 0){
+    if ($result->size > 0) {
         $error ="One of the following tags found: $errVal. Please use Morpho to edit this document";
         push(@errorMessages, $error."\n");
-        #if ($DEBUG == 1){ print $error;}
     } 
 }
 
@@ -4021,7 +3982,6 @@
     my $value = shift;
     my $error ="More than one occurence of the tag $value found. Please use Morpho to edit this document";
     push(@errorMessages, $error."\n");
-    # if ($DEBUG == 1){ print $error;}
 }
 
 
@@ -4034,7 +3994,6 @@
     my $value = shift;
     my $error ="More occurences of the tag $value found than that can be shown in the form. Please use Morpho to edit this document";
     push(@errorMessages, $error);
-    #if ($DEBUG == 1){ print $error."\n";}
 }
 
 



More information about the Metacat-cvs mailing list