#
# Patch applies to qmailadmin 1.06 sources.
# James Raftery <james@now.ie> 12 Dec. 2002
#
# Please use qmailadmin-mailbox.flags.1012.patch for qmailadmin 1.0.12.
# The 1.0.12 patch is much more sophisticated and is strongly preferred.
#

--- user.c.orig	Thu Dec 12 12:09:04 2002
+++ user.c	Thu Dec 12 12:36:01 2002
@@ -784,6 +784,49 @@
     vauth_setpw(vpw, Domain);
   }
 
+  /* check for the V_USERx flags and set accordingly */
+  /* James Raftery <james@now.ie>, 12 Dec. 2002 */
+  GetValue(TmpCGI,box, "zeroflag=", MAX_BUFF);
+  if ( strcmp(box,"on") == 0 ) {
+    vpw = vauth_getpw(ActionUser, Domain); 
+    vpw->pw_gid |= V_USER0;
+    vauth_setpw(vpw, Domain);
+  } else {
+    vpw = vauth_getpw(ActionUser, Domain); 
+    vpw->pw_gid &= ~V_USER0;
+    vauth_setpw(vpw, Domain);
+  }
+  GetValue(TmpCGI,box, "oneflag=", MAX_BUFF);
+  if ( strcmp(box,"on") == 0 ) {
+    vpw = vauth_getpw(ActionUser, Domain); 
+    vpw->pw_gid |= V_USER1;
+    vauth_setpw(vpw, Domain);
+  } else {
+    vpw = vauth_getpw(ActionUser, Domain); 
+    vpw->pw_gid &= ~V_USER1;
+    vauth_setpw(vpw, Domain);
+  }
+  GetValue(TmpCGI,box, "twoflag=", MAX_BUFF);
+  if ( strcmp(box,"on") == 0 ) {
+    vpw = vauth_getpw(ActionUser, Domain); 
+    vpw->pw_gid |= V_USER2;
+    vauth_setpw(vpw, Domain);
+  } else {
+    vpw = vauth_getpw(ActionUser, Domain); 
+    vpw->pw_gid &= ~V_USER2;
+    vauth_setpw(vpw, Domain);
+  }
+  GetValue(TmpCGI,box, "threeflag=", MAX_BUFF);
+  if ( strcmp(box,"on") == 0 ) {
+    vpw = vauth_getpw(ActionUser, Domain); 
+    vpw->pw_gid |= V_USER3;
+    vauth_setpw(vpw, Domain);
+  } else {
+    vpw = vauth_getpw(ActionUser, Domain); 
+    vpw->pw_gid &= ~V_USER3;
+    vauth_setpw(vpw, Domain);
+  }
+
   /* get the value of the cforward radio button */
   GetValue(TmpCGI,box, "cforward=", MAX_BUFF);

--- template.c.orig	Thu Dec 12 12:46:14 2002
+++ template.c	Thu Dec 12 13:10:55 2002
@@ -34,6 +34,7 @@
 
 static char dchar[4];
 void check_user_forward_vacation(char newchar);
+void check_mailbox_flags(char newchar);
 
 static char NTmpBuf[500];
 
@@ -389,6 +390,12 @@
             fprintf(actout,"%s", StatusMessage);
             break;
 
+          /* show mailbox flag status */
+          /* James Raftery <james@now.ie> 12 Dec. 2002 */
+          case 'J':
+            check_mailbox_flags(fgetc(fs));
+            break;
+
           /* show the catchall name */
           case 's':
             get_catchall();
@@ -487,6 +494,29 @@
   vclose();
 
   return 0;
+}
+
+/* Display status of mailbox flags */
+/* James Raftery <james@now.ie> 12 Dec. 2002 */
+void check_mailbox_flags(char newchar)
+{
+ static struct vqpasswd *vpw = NULL;
+
+  if (vpw==NULL) vpw = vauth_getpw(ActionUser, Domain); 
+
+  if (newchar=='0' && (vpw->pw_gid & V_USER0)) {
+    printf("checked ");
+  }
+  if (newchar=='1' && (vpw->pw_gid & V_USER1)) {
+    printf("checked ");
+  }
+  if (newchar=='2' && (vpw->pw_gid & V_USER2)) {
+    printf("checked ");
+  }
+  if (newchar=='3' && (vpw->pw_gid & V_USER3)) {
+    printf("checked ");
+  }
+  return;
 }
 
 void check_user_forward_vacation(char newchar)

--- html/mod_user.html.orig	Thu Dec 12 12:27:23 2002
+++ html/mod_user.html	Thu Dec 12 13:00:08 2002
@@ -76,6 +76,10 @@
                                                     </table>
                                                 </td>
                                             </tr>
+                                            <tr>
+                                                <td align="left">Set V_USER2 flag&nbsp;</td>
+                                                <td align="left"><input type="checkbox" name="twoflag" ##J2></td>
+                                            </tr>
                                         </table>
                                         <input type="hidden" name="modu" value="##A">
                                         <input type="hidden" name="do.login" value="ChangePassword">
