r4905 - trunk/src/perl

walbridge at ecoinformatics.org walbridge at ecoinformatics.org
Mon Apr 6 15:28:47 PDT 2009


Author: walbridge
Date: 2009-04-06 15:28:46 -0700 (Mon, 06 Apr 2009)
New Revision: 4905

Modified:
   trunk/src/perl/register-dataset.cgi
Log:
Display helpful error message when user lacks permissions to edit a document, supress the 'use Morpho' message (closes Bug #3928 [ http://bugzilla.ecoinformatics.org/show_bug.cgi?id=3928 ])


Modified: trunk/src/perl/register-dataset.cgi
===================================================================
--- trunk/src/perl/register-dataset.cgi	2009-04-06 20:51:22 UTC (rev 4904)
+++ trunk/src/perl/register-dataset.cgi	2009-04-06 22:28:46 UTC (rev 4905)
@@ -2568,6 +2568,7 @@
 
     $results = $doc->findnodes('/eml:eml/access/allow');
     my $accessError = 0;
+    my $docOwner;
 
     foreach $node ($results->get_nodelist) {
         my @children = $node->childNodes;
@@ -2582,12 +2583,18 @@
             }
         }
         # if the principal is any one of the moderators, the script will handle it
-        my @admins = $moderators;
+        my @admins;
+        foreach (split(":", $moderators)) {
+            push(@admins, $_);
+        }
         push(@admins, $adminUsername);
 
         if ($principal eq 'public' && $permission ne 'read') { $accessError = 1; }
         if ($principal eq $adminUsername && $permission ne 'all') { $accessError = 2; }
-        if ($principal ne 'public' && !grep {$_ eq $principal} @admins && $permission ne 'all') { $accessError = 3; }
+        if ($principal ne 'public' && !grep {$_ eq $principal} @admins && $permission ne 'all') { 
+            $accessError = 3;
+            $docOwner = $principal;
+        }
         # TODO: FIXME for 1.9.1
         # The ESA skin has a separate concept of 'moderator', which is defined by a property
         # within the configuration. This should be updated to check the user against the groups.
@@ -2612,8 +2619,13 @@
     }
 
     if ($accessError != 0) {
-        my $error = "The ACL for this document has been changed outside the registry. Please use Morpho to edit this document (Access Error #$accessError).";
-        push(@errorMessages, $error."\n");
+        my $error;
+        if ($accessError == 3) {
+            $error = "You don't have permission to edit this document, which is owned by $docOwner. (Access Error #3)\n";
+        } else {
+            my $error = "The ACL for this document has been changed outside the registry. Please use Morpho to edit this document (Access Error #$accessError).\n";
+        }
+        push(@errorMessages, $error);
     }
 
     # handle otherEntity objects, by populating the relevant file form elements
@@ -3486,7 +3498,7 @@
                     if ($response != '1') {
                         return " Unable to set access for the review document in Metacat for the docid:".$docid;
                     }
-                    foreach (split(":",$moderators)) {
+                    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;



More information about the Metacat-cvs mailing list