Hi all,

In follow-up to Klas' auto_create_mailbox patch for mysql, I've updated said patch to apply to the current CVS version of dbpgsql.c


Works great.



--
  ________________________________________________________________
  Paul Stevens                                  mailto:[EMAIL PROTECTED]
  NET FACILITIES GROUP                     PGP: finger [EMAIL PROTECTED]
  The Netherlands________________________________http://www.nfg.nl
Index: pgsql/dbpgsql.c
===================================================================
RCS file: /cvsroot-dbmail/dbmail/pgsql/dbpgsql.c,v
retrieving revision 1.92
diff -c -r1.92 dbpgsql.c
*** pgsql/dbpgsql.c     2002/12/13 11:05:15     1.92
--- pgsql/dbpgsql.c     2002/12/24 09:29:42
***************
*** 470,476 ****
--- 470,499 ----
        trace(TRACE_ERROR, "db_get_mailboxid(): query failed");
        return 0;
      }
+ #ifdef AUTO_CREATE_MAILBOX
+   if (PQntuples(res)<1) 
+     {
+        trace (TRACE_DEBUG,"db_get_mailboxid(): user has no mailbox named 
[%s]", mailbox);
+        PQclear(res);
+        db_createmailbox(mailbox,useridnr);
+        snprintf (query, DEF_QUERYSIZE,"SELECT mailbox_idnr FROM mailboxes 
WHERE "
+                "lower(name) = lower('%s') AND owner_idnr=%llu::bigint",
+                mailbox, useridnr);
  
+        if (db_query(query)==-1)
+        {
+           trace(TRACE_ERROR, "db_get_mailboxid(): query failed");
+           return 0;
+        }
+        
+        if (PQntuples(res)<1) 
+        {
+           trace (TRACE_DEBUG,"db_get_mailboxid(): user has no mailbox named 
[%s]. Couldn't create.", mailbox);
+           PQclear(res);
+           return 0; 
+        } 
+     }
+ #else
    if (PQntuples(res)<1) 
      {
        trace (TRACE_DEBUG,"db_get_mailboxid(): user has no mailbox named 
[%s]", mailbox);
***************
*** 478,483 ****
--- 501,508 ----
  
        return 0; 
      } 
+    
+ #endif   
  
    value = PQgetvalue(res, 0, 0);
    inboxid = (value) ? strtoull(value, NULL, 10) : 0; 

Reply via email to