/*
 * This patch is for vqadmin 2.3.7 ( http://www.inter7.com/vqadmin ).
 * Adds the 'enable/disable' maildrop feature and some Italian strings
 * in the 'it' translations file.
 * Corrects the incorrect disable_spamassassin management in domain
 * modification page.
 * The spamassassin/maildrop processing has to be enabled in vpopmail.
 *
 * Questa patch è per vqadmin 2.3.7 ( http://www.inter7.com/vqadmin ).
 * Aggiunge la possibilita' di attivare/disattivare l'utilizzo di
 * maildrop e alcune stringhe italiane che mancavano nel file 'it'.
 * Corregge il mancato funzionamento del flag disable_spamassassin
 * nella pagina di modifica dominio.
 * L'utilizzo di spamassassin o maildrop deve essere abilitato nel
 * vpopmail.
 *
 * 2008-05-17 Valerio Granato <valerio [at] grana [dot] to>
 */

diff -ur vqadmin-2.3.7/domain.c vqadmin-2.3.7-maildrop/domain.c
--- vqadmin-2.3.7/domain.c  2005-01-11 21:48:03.000000000 +0100
+++ vqadmin-2.3.7-maildrop/domain.c 2008-05-17 12:51:04.000000000 +0200
@@ -59,7 +59,12 @@
  char *upassc = NULL;
  char *uweb = NULL;
  char *urelay = NULL;
+#ifdef SPAMASSASSIN
  char *uspam = NULL;
+#endif
+#ifdef MAILDROP
+ char *umaildrop = NULL;
+#endif
  int   ret;
  char dir[156];
  uid_t uid;
@@ -87,7 +92,12 @@
   upassc  = cgi_is_var("upassc");
   uweb    = cgi_is_var("uweb");
   urelay  = cgi_is_var("urelay");
+#ifdef SPAMASSASSIN
   uspam  = cgi_is_var("uspam");
+#endif
+#ifdef MAILDROP
+  umaildrop  = cgi_is_var("maildrop");
+#endif

   /* get the domain name */
   if (domain==NULL || strlen(domain)==0) {
@@ -142,7 +152,12 @@
   if (upassc!=NULL) fprintf(fs, "disable_password_changing\n");
   if (uweb!=NULL) fprintf(fs, "disable_webmail\n");
   if (urelay!=NULL) fprintf(fs, "disable_external_relay\n");
-  if (uspam!=NULL) fprintf(fs, "disable_spamassasin\n");
+#ifdef SPAMASSASSIN
+  if (uspam!=NULL) fprintf(fs, "disable_spamassassin\n");
+#endif
+#ifdef MAILDROP
+  if (umaildrop!=NULL) fprintf(fs, "disable_maildrop\n");
+#endif
   fclose(fs);
   chown(dir,uid, gid);
   chmod(dir, S_IRUSR | S_IWUSR);
@@ -229,6 +244,12 @@
  char *upassc = NULL;
  char *uweb = NULL;
  char *urelay = NULL;
+#ifdef SPAMASSASSIN
+ char *uspam = NULL;
+#endif
+#ifdef MAILDROP
+ char *umaildrop = NULL;
+#endif
  int   ret;
  char dir[156];
  uid_t uid;
@@ -260,6 +281,12 @@
   upassc  = cgi_is_var("upassc");
   uweb    = cgi_is_var("uweb");
   urelay  = cgi_is_var("urelay");
+#ifdef SPAMASSASSIN
+  uspam   = cgi_is_var("uspam");
+#endif
+#ifdef MAILDROP
+  umaildrop  = cgi_is_var("umaildrop");
+#endif

   vget_assign(domain,dir,156,&uid,&gid);
   strncat(dir,"/.qmailadmin-limits", 156);
@@ -286,6 +313,12 @@
   if (upassc!=NULL) fprintf(fs, "disable_password_changing\n");
   if (uweb!=NULL) fprintf(fs, "disable_webmail\n");
   if (urelay!=NULL) fprintf(fs, "disable_external_relay\n");
+#ifdef SPAMASSASSIN
+  if (uspam!=NULL) fprintf(fs, "disable_spamassassin\n");
+#endif
+#ifdef MAILDROP
+  if (umaildrop!=NULL) fprintf(fs, "disable_maildrop\n");
+#endif

   fclose(fs);
   chown(dir,uid, gid);
@@ -397,9 +430,15 @@

       } else if ( strcmp(tmpstr1, "disable_external_relay") == 0 ) {
         global_par("MS", "checked");
-
-     } else if ( strcmp(tmpstr1, "disable_spamassassin") == 0 ) {
-       global_par("MZ", "checked");
+#ifdef SPAMASSASSIN
+      } else if ( strcmp(tmpstr1, "disable_spamassassin") == 0 ) {
+   global_par("MZ", "checked");
+#endif
+
+#ifdef MAILDROP
+      } else if ( strcmp(tmpstr1, "disable_maildrop") == 0 ) {
+   global_par("MM", "checked");
+#endif

       } else if ( strcmp(tmpstr1, "disable_webmail") == 0 ) {
         global_par("MW", "checked");
diff -ur vqadmin-2.3.7/html/add_user.html vqadmin-2.3.7-maildrop/html/add_user.html
--- vqadmin-2.3.7/html/add_user.html    2005-01-11 21:43:10.000000000 +0100
+++ vqadmin-2.3.7-maildrop/html/add_user.html   2008-05-17 12:04:59.000000000 +0200
@@ -35,6 +35,8 @@
    <label for="urelay" title="#-047">#-047</label></td> </tr>
 <tr><td><INPUT TYPE="CHECKBOX" NAME="uspam" id="uspam" $-UF>
    <label for="uspam" title="#-069">#-069</label></td> </tr>
+<tr><td><INPUT TYPE="CHECKBOX" NAME="umaildrop" id="umaildrop" $-UM>
+   <label for="umaildrop" title="#-070">#-070</label></td> </tr>
 <tr><td><INPUT TYPE="CHECKBOX" NAME="uqadmin" id="uqadmin" $-UK>
    <label for="uqadmin" title="#-048">#-048</label></td></tr>
 <tr><td><br>
diff -ur vqadmin-2.3.7/html/en vqadmin-2.3.7-maildrop/html/en
--- vqadmin-2.3.7/html/en   2005-01-11 21:24:52.000000000 +0100
+++ vqadmin-2.3.7-maildrop/html/en  2008-05-17 12:03:57.000000000 +0200
@@ -65,4 +65,4 @@
 067 user:
 068 permission:
 069 Disable SpamAssassin
-
+070 Disable Maildrop
diff -ur vqadmin-2.3.7/html/en-us vqadmin-2.3.7-maildrop/html/en-us
--- vqadmin-2.3.7/html/en-us    2003-01-09 21:15:21.000000000 +0100
+++ vqadmin-2.3.7-maildrop/html/en-us   2008-05-17 12:04:14.000000000 +0200
@@ -59,6 +59,11 @@
 058 3
 059 Add Alias Domain
 060 Alias Domain Name
-061 Qmail Control Files
-062 Modify Control File
-063 Modify File
+061 Qmail Control Files
+062 Modify Control File
+063 Modify File
+067 user:
+068 permission:
+069 Disable SpamAssassin
+070 Disable Maildrop
+
diff -ur vqadmin-2.3.7/html/it vqadmin-2.3.7-maildrop/html/it
--- vqadmin-2.3.7/html/it   2002-08-02 19:12:55.000000000 +0200
+++ vqadmin-2.3.7-maildrop/html/it  2008-05-17 12:03:49.000000000 +0200
@@ -62,3 +62,7 @@
 061 Qmail Control Files
 062 Modify Control File
 063 Modify File
+067 utente:
+068 permessi:
+069 Disabilita SpamAssassin
+070 Disabilita Maildrop
diff -ur vqadmin-2.3.7/html/mod_domain.html vqadmin-2.3.7-maildrop/html/mod_domain.html
--- vqadmin-2.3.7/html/mod_domain.html  2005-01-11 21:47:51.000000000 +0100
+++ vqadmin-2.3.7-maildrop/html/mod_domain.html 2008-05-17 12:06:11.000000000 +0200
@@ -62,6 +62,7 @@
 <tr><td><input TYPE="checkbox" NAME="uweb" id="uweb" $-MW title="#-043"><label for="uweb" title="#-043">#-043</label></td></tr>
 <tr><td><input TYPE="checkbox" NAME="urelay" id="urelay"$-MS title="#-047"><label for="urelay" title="#-047">#-047</label></td></tr>
 <tr><td><input TYPE="checkbox" NAME="uspam" id="uspam"$-MZ title="#-069"><label for="uspam" title="#-069">#-069</label></td></tr>
+<tr><td><input TYPE="checkbox" NAME="umaildrop" id="umaildrop"$-MM title="#-070"><label for="umaildrop" title="#-070">#-070</label></td></tr>
 <tr>
 <td><BR><INPUT TYPE="SUBMIT" NAME="Submit" VALUE="#-033">
 <INPUT TYPE="HIDDEN" NAME="nav" VALUE="mod_domain">
diff -ur vqadmin-2.3.7/html/mod_user.html vqadmin-2.3.7-maildrop/html/mod_user.html
--- vqadmin-2.3.7/html/mod_user.html    2005-01-11 21:42:28.000000000 +0100
+++ vqadmin-2.3.7-maildrop/html/mod_user.html   2008-05-17 12:05:30.000000000 +0200
@@ -36,6 +36,7 @@
 <tr><td><INPUT TYPE="CHECKBOX" NAME="ubounce" id="ubounce" $-UB title="#-046"><label for="ubounce" title="#-046">#-046</label></td> </tr>
 <tr><td><INPUT TYPE="CHECKBOX" NAME="urelay" id="urelay" $-US title="#-047"><label for="urelay" title="#-047">#-047</label></td> </tr>
 <tr><td><INPUT TYPE="CHECKBOX" NAME="uspam" id="uspam" $-UF title="#-069"><label for="uspam" title="#-069">#-069</label></td> </tr>
+<tr><td><INPUT TYPE="CHECKBOX" NAME="umaildrop" id="umaildrop" $-UM title="#-070"><label for="umaildrop" title="#-070">#-070</label></td> </tr>
 <tr><td><INPUT TYPE="CHECKBOX" NAME="uqadmin" id="uqadmin" $-UK title="#-048"><label for="uqadmin" title="#-048">#-048</label></td></tr>
 </tr>
 <tr><td>
diff -ur vqadmin-2.3.7/user.c vqadmin-2.3.7-maildrop/user.c
--- vqadmin-2.3.7/user.c    2005-01-11 22:10:35.000000000 +0100
+++ vqadmin-2.3.7-maildrop/user.c   2008-05-17 12:46:25.000000000 +0200
@@ -123,7 +123,12 @@
  char *upassc;
  char *ubounce;
  char *urelay;
+#ifdef SPAMASSASSIN
  char *uspam;
+#endif
+#ifdef MAILDROP
+ char *umaildrop;
+#endif
  char *uqadmin;
  int   ret;
  int   i;
@@ -146,6 +151,7 @@
   ubounce = cgi_is_var("ubounce");
   urelay = cgi_is_var("urelay");
   uspam = cgi_is_var("uspam");
+  umaildrop = cgi_is_var("umaildrop");
   uqadmin = cgi_is_var("uqadmin");

   if ( eaddr==NULL || strlen(eaddr)==0 ) {
@@ -192,6 +198,9 @@
 #ifdef SPAMASSASSIN
   if (uspam!=NULL) GidFlag |= NO_SPAMASSASSIN;
 #endif
+#ifdef MAILDROP
+  if (umaildrop!=NULL) GidFlag |= NO_MAILDROP;
+#endif
   if (uqadmin!=NULL) GidFlag |= QA_ADMIN;

   vpw->pw_gid = GidFlag;
@@ -244,6 +253,10 @@
   if (vpw->pw_gid & NO_SPAMASSASSIN) global_par("UF", "CHECKED");
 #endif

+#ifdef MAILDROP
+  if (vpw->pw_gid & NO_MAILDROP) global_par("UM", "CHECKED");
+#endif
+
   if (vpw->pw_gid & QA_ADMIN) global_par("UK", "CHECKED");

 #ifdef ENABLE_AUTH_LOGGING
