Author: jfthomps
Date: Mon Apr 12 12:35:23 2010
New Revision: 933215

URL: http://svn.apache.org/viewvc?rev=933215&view=rev
Log:
VCL-227

groups.php:
-modified checkForGroupUsage: added checks for user group being used in 
resourcegroup, blockRequest, imagemeta, and usergroup tables
-modified confirmDeleteGroup: changed text stating a user group can't be 
deleted due to it being in use to be more generic instead of just about the 
privlege tree

errors.php: added errors 311, 312, 313, and 314, all of which are about which 
query was a problem in checkForGroupUsage

Modified:
    incubator/vcl/trunk/web/.ht-inc/errors.php
    incubator/vcl/trunk/web/.ht-inc/groups.php

Modified: incubator/vcl/trunk/web/.ht-inc/errors.php
URL: 
http://svn.apache.org/viewvc/incubator/vcl/trunk/web/.ht-inc/errors.php?rev=933215&r1=933214&r2=933215&view=diff
==============================================================================
--- incubator/vcl/trunk/web/.ht-inc/errors.php (original)
+++ incubator/vcl/trunk/web/.ht-inc/errors.php Mon Apr 12 12:35:23 2010
@@ -159,6 +159,10 @@ $ERRORS = array (
        "306" => "Failed to execute query 2 in updateNisNetGroups",
        "307" => "Failed to execute query 3 in updateNisNetGroups",
        "310" => "Failed to execute query 1 in checkForGroupUsage",
+       "311" => "Failed to execute query 2 in checkForGroupUsage",
+       "312" => "Failed to execute query 3 in checkForGroupUsage",
+       "313" => "Failed to execute query 4 in checkForGroupUsage",
+       "314" => "Failed to execute query 5 in checkForGroupUsage",
        "315" => "Failed to execute query 1 in submitDeleteGroup",
        "320" => "Failed to execute query 1 in getUserImages",
        "325" => "Failed to execute query 1 in getChildNodes",

Modified: incubator/vcl/trunk/web/.ht-inc/groups.php
URL: 
http://svn.apache.org/viewvc/incubator/vcl/trunk/web/.ht-inc/groups.php?rev=933215&r1=933214&r2=933215&view=diff
==============================================================================
--- incubator/vcl/trunk/web/.ht-inc/groups.php (original)
+++ incubator/vcl/trunk/web/.ht-inc/groups.php Mon Apr 12 12:35:23 2010
@@ -774,14 +774,36 @@ function addGroup($data) {
 ///
 
////////////////////////////////////////////////////////////////////////////////
 function checkForGroupUsage($groupid, $type) {
-       if($type == "user")
+       if($type == "user") {
+               $query = "SELECT id FROM resourcegroup WHERE ownerusergroupid = 
$groupid";
+               $qh = doQuery($query, 310);
+               if(mysql_num_rows($qh))
+                       return 1;
+               $query = "SELECT id "
+                      . "FROM blockRequest "
+                      . "WHERE groupid = $groupid "
+                      .    "OR admingroupid = $groupid";
+               $qh = doQuery($query, 311);
+               if(mysql_num_rows($qh))
+                       return 1;
+               $query = "SELECT id FROM imagemeta WHERE usergroupid = 
$groupid";
+               $qh = doQuery($query, 312);
+               if(mysql_num_rows($qh))
+                       return 1;
+               $query = "SELECT id "
+                      . "FROM usergroup "
+                                . "WHERE editusergroupid = $groupid "
+                                .   "AND id != $groupid";
+               $qh = doQuery($query, 313);
+               if(mysql_num_rows($qh))
+                       return 1;
                $query = "SELECT id FROM userpriv WHERE usergroupid = $groupid";
+       }
        else
                $query = "SELECT id FROM resourcepriv WHERE resourcegroupid = 
$groupid";
-       $qh = doQuery($query, 310);
-       if(mysql_num_rows($qh)) {
+       $qh = doQuery($query, 314);
+       if(mysql_num_rows($qh))
                return 1;
-       }
        return 0;
 }
 
@@ -969,12 +991,17 @@ function confirmDeleteGroup() {
 
        if($type == "user") {
                $title = "Delete User Group";
+               $usemsg = "This group is currently in use.  You cannot delete 
it until "
+                       . "it is no longer being used.";
                $question = "Delete the following user group?";
                $name = $usergroups[$groupid]["name"];
                $target = "";
        }
        else {
                $title = "Delete Resource Group";
+               $usemsg = "This group is currently assigned to at least one 
node in the "
+                       . "privilege tree.  You cannot delete it until it is no 
longer "
+                       . "in use.";
                $question = "Delete the following resource group?";
                list($resourcetype, $name) = 
                        split('/', $resourcegroups[$groupid]["name"]);
@@ -983,9 +1010,7 @@ function confirmDeleteGroup() {
 
        if(checkForGroupUsage($groupid, $type)) {
                print "<H2 align=center>$title</H2>\n";
-               print "This group is currently assigned to at least one node in 
the ";
-               print "privilege tree.  You cannot delete it until it is no 
longer ";
-               print "in use.";
+               print $usemsg;
                return;
        }
 


Reply via email to