Index: /pykota/trunk/pykota/storages/pgstorage.py
===================================================================
--- /pykota/trunk/pykota/storages/pgstorage.py (revision 1257)
+++ /pykota/trunk/pykota/storages/pgstorage.py (revision 1258)
@@ -22,4 +22,7 @@
 #
 # $Log$
+# Revision 1.29  2004/01/08 16:24:49  jalet
+# edpykota now supports adding printers to printer groups.
+#
 # Revision 1.28  2004/01/08 14:10:33  jalet
 # Copyright year changed.
@@ -505,4 +508,8 @@
         self.doModify("UPDATE grouppquota SET softlimit=%s, hardlimit=%s, datelimit=NULL WHERE id=%s" % (self.doQuote(softlimit), self.doQuote(hardlimit), self.doQuote(grouppquota.ident)))
 
+    def writePrinterToGroup(self, pgroup, printer) :
+        """Puts a printer into a printer group."""
+        self.doModify("INSERT INTO printergroupsmembers (groupid, printerid) VALUES (%s, %s);" % (self.doQuote(pgroup.ident), self.doQuote(printer.ident)))
+        
     def deleteUser(self, user) :    
         """Completely deletes an user from the Quota Storage."""
Index: /pykota/trunk/pykota/storages/ldapstorage.py
===================================================================
--- /pykota/trunk/pykota/storages/ldapstorage.py (revision 1257)
+++ /pykota/trunk/pykota/storages/ldapstorage.py (revision 1258)
@@ -22,4 +22,7 @@
 #
 # $Log$
+# Revision 1.45  2004/01/08 16:24:49  jalet
+# edpykota now supports adding printers to printer groups.
+#
 # Revision 1.44  2004/01/08 14:10:33  jalet
 # Copyright year changed.
@@ -361,5 +364,5 @@
         """Extracts printer information given its name."""
         printer = StoragePrinter(self, printername)
-        result = self.doSearch("(&(objectClass=pykotaPrinter)(|(pykotaPrinterName=%s)(%s=%s)))" % (printername, self.info["printerrdn"], printername), ["pykotaPricePerPage", "pykotaPricePerJob"], base=self.info["printerbase"])
+        result = self.doSearch("(&(objectClass=pykotaPrinter)(|(pykotaPrinterName=%s)(%s=%s)))" % (printername, self.info["printerrdn"], printername), ["pykotaPricePerPage", "pykotaPricePerJob", "uniqueMember"], base=self.info["printerbase"])
         if result :
             fields = result[0][1]
@@ -368,4 +371,5 @@
             printer.PricePerPage = float(fields.get("pykotaPricePerPage")[0] or 0.0)
             printer.LastJob = self.getPrinterLastJob(printer)
+            printer.uniqueMember = fields.get("uniqueMember", [])
             printer.Exists = 1
         return printer    
@@ -521,5 +525,5 @@
         printers = []
         # see comment at the same place in pgstorage.py
-        result = self.doSearch("(&(objectClass=pykotaPrinter)(|%s))" % "".join(["(pykotaPrinterName=%s)" % pname for pname in printerpattern.split(",")]), ["pykotaPrinterName", "pykotaPricePerPage", "pykotaPricePerJob"], base=self.info["printerbase"])
+        result = self.doSearch("(&(objectClass=pykotaPrinter)(|%s))" % "".join(["(pykotaPrinterName=%s)" % pname for pname in printerpattern.split(",")]), ["pykotaPrinterName", "pykotaPricePerPage", "pykotaPricePerJob", "uniqueMember"], base=self.info["printerbase"])
         if result :
             for (printerid, fields) in result :
@@ -529,4 +533,5 @@
                 printer.PricePerJob = float(fields.get("pykotaPricePerJob")[0] or 0.0)
                 printer.PricePerPage = float(fields.get("pykotaPricePerPage")[0] or 0.0)
+                printer.uniqueMember = fields.get("uniqueMember", [])
                 printer.LastJob = self.getPrinterLastJob(printer)
                 printer.Exists = 1
@@ -814,4 +819,12 @@
         self.doModify(grouppquota.ident, fields)
             
+    def writePrinterToGroup(self, pgroup, printer) :
+        """Puts a printer into a printer group."""
+        if (printer.ident not in pgroup.uniqueMember) and (printer.ident != pgroup.ident) :
+            fields = {
+                       "uniqueMember" : pgroup.uniqueMember + [printer.ident]
+                     }  
+            self.doModify(pgroup.ident, fields)         
+        
     def deleteUser(self, user) :    
         """Completely deletes an user from the Quota Storage."""
Index: /pykota/trunk/pykota/storage.py
===================================================================
--- /pykota/trunk/pykota/storage.py (revision 1257)
+++ /pykota/trunk/pykota/storage.py (revision 1258)
@@ -22,4 +22,7 @@
 #
 # $Log$
+# Revision 1.34  2004/01/08 16:24:49  jalet
+# edpykota now supports adding printers to printer groups.
+#
 # Revision 1.33  2004/01/08 14:10:32  jalet
 # Copyright year changed.
@@ -239,4 +242,9 @@
         self.parent.writeJobNew(self, user, jobid, pagecounter, action, jobsize, jobprice, filename, title, copies, options)
         # TODO : update LastJob object ? Probably not needed.
+        
+    def addPrinterToGroup(self, printer) :    
+        """Adds a printer to a printer group."""
+        if printer not in self.parent.getParentPrinters(self) :
+            self.parent.writePrinterToGroup(self, printer)
         
     def setPrices(self, priceperpage = None, priceperjob = None) :    
Index: /pykota/trunk/pykota/version.py
===================================================================
--- /pykota/trunk/pykota/version.py (revision 1257)
+++ /pykota/trunk/pykota/version.py (revision 1258)
@@ -22,5 +22,5 @@
 #
 
-__version__ = "1.16alpha21_unofficial"
+__version__ = "1.16alpha22_unofficial"
 
 __doc__ = """PyKota : a complete Printing Quota Solution for CUPS and LPRng."""
Index: /pykota/trunk/bin/edpykota
===================================================================
--- /pykota/trunk/bin/edpykota (revision 1257)
+++ /pykota/trunk/bin/edpykota (revision 1258)
@@ -24,4 +24,7 @@
 #
 # $Log$
+# Revision 1.65  2004/01/08 16:24:49  jalet
+# edpykota now supports adding printers to printer groups.
+#
 # Revision 1.64  2004/01/08 14:10:32  jalet
 # Copyright year changed.
@@ -276,5 +279,17 @@
                        by separating them with commas.
   
-  -g | --groups        Edit groups print quotas instead of users.
+  -G | --pgroups pg1[,pg2...] Adds the printer(s) to the printer groups
+                       pg1, pg2, etc... which must already exist.
+                       A printer group is just like a normal printer,
+                       only that it is usually unknown from the printing
+                       system. Create printer groups exactly the same
+                       way that you create printers, then add other 
+                       printers to them with this option.
+                       Accounting is done on a printer and on all
+                       the printer groups it belongs to, quota checking
+                       is done on a printer and on all the printer groups
+                       it belongs to.
+  
+  -g | --groups        Edit users groups print quotas instead of users.
                           
   -p | --prototype u|g Uses user u or group g as a prototype to set
@@ -366,4 +381,10 @@
   This will set the page price for printer lp to 0.1. Job price
   will not be changed.
+  
+  $ edpykota --printer hplj1,hplj2 --pgroups Laser,HP
+  
+  This will put printers hplj1 and hplj2 in printers groups Laser and HP.
+  When printing either on hplj1 or hplj2, print quota will also be 
+  checked and accounted for on virtual printers Laser and HP.
 
 This program is free software; you can redistribute it and/or modify
@@ -464,6 +485,13 @@
                 names = [ "*" ] # all users
                 
+        printersgroups = []        
+        if options["pgroups"] :        
+            printersgroups = self.storage.getMatchingPrinters(options["pgroups"])
+            
         changed = {} # tracks changes made at the user/group level
         for printer in printers :
+            for pgroup in printersgroups :
+                pgroup.addPrinterToGroup(printer)    
+                
             if options["charge"] :
                 (perpage, perjob) = charges
@@ -576,6 +604,6 @@
                      "printer" : "*", \
                    }
-        short_options = "vhdc:l:b:i:naugrp:P:S:H:"
-        long_options = ["help", "version", "charge=", "delete", "limitby=", "balance=", "ingroups=", "noquota", "add", "users", "groups", "reset", "prototype=", "printer=", "softlimit=", "hardlimit="]
+        short_options = "vhdc:l:b:i:naugrp:P:S:H:G:"
+        long_options = ["help", "version", "charge=", "delete", "limitby=", "balance=", "ingroups=", "noquota", "add", "users", "groups", "reset", "prototype=", "printer=", "softlimit=", "hardlimit=", "pgroups="]
         
         # Initializes the command line tool
@@ -602,4 +630,5 @@
         options["ingroups"] = options["i"] or options["ingroups"]
         options["charge"] = options["c"] or options["charge"]
+        options["pgroups"] = options["G"] or options["pgroups"]
         
         if options["help"] :
Index: /pykota/trunk/NEWS
===================================================================
--- /pykota/trunk/NEWS (revision 1257)
+++ /pykota/trunk/NEWS (revision 1258)
@@ -22,4 +22,8 @@
 PyKota NEWS :
 
+    - 1.16alpha22 :
+    
+        - edpykota now allows adding printers to printer groups
+        
     - 1.16alpha21 :
     
