[dev] cyrsql driver patch

Vilius Šumskas vilius at lnk.lt
Wed Apr 14 04:46:45 PDT 2004


sorry the patch. :)

-------------- next part --------------
Index: cyrsql.php
===================================================================
RCS file: /repository/framework/Auth/Auth/cyrsql.php,v
retrieving revision 1.27
diff -u -r1.27 cyrsql.php
--- cyrsql.php	19 Feb 2004 09:40:52 -0000	1.27
+++ cyrsql.php	14 Apr 2004 11:35:19 -0000
@@ -132,14 +132,22 @@
                                                                          $this->_params['encryption'],
                                                                          $this->_params['show_encryption'])));
             $dbresult = $this->_db->query($query);
+            $query = sprintf('INSERT INTO virtual (alias, dest, username, status) VALUES (%s, %s, %s, 1)',
+                             $this->_db->quote($userId),
+                             $this->_db->quote($name),
+                             $this->_db->quote($name));
+            $dbresult2 = $this->_db->query($query);
         } else {
             $dbresult = parent::addUser($userId, $credentials);
         }
         if (is_a($dbresult, 'PEAR_Error')) {
             return $dbresult;
         }
-
-        $name = imap_utf7_encode($userId);
+        if (is_a($dbresult2, 'PEAR_Error')) {
+            return $dbresult2;
+        }
+	
+        $name = imap_utf7_encode($name);
         if (@imap_createmailbox($this->_imapStream,
                                 imap_utf7_encode($this->_params['imap_dsn'] .
                                                  'user' . $this->_separator . $name))) {
@@ -187,6 +195,9 @@
                          $this->_params['domain_field'],
                          $this->_db->quote($domain));
             $dbresult = $this->_db->query($query);
+            $query = sprintf('DELETE FROM virtual WHERE dest = %s',
+                             $this->_db->quote($name));
+            $dbresult2 = $this->_db->query($query); 
         } else {
             $dbresult = parent::removeUser($userId);
         }
@@ -195,16 +206,20 @@
             return $dbresult;
         }
 
+        if (is_a($dbresult2, 'PEAR_Error')) {
+            return $dbresult2;
+        }
+
         /* Set ACL for mailbox deletion. */
         list($admin)=explode('@',$this->_params['cyradmin']);
         @imap_setacl($this->_imapStream,
-                     'user' . $this->_separator . $userId,
+                     'user' . $this->_separator . $name,
                      $admin, 'lrswipcda');
 
         /* Delete IMAP mailbox. */
         $imapresult = @imap_deletemailbox($this->_imapStream,
                                           $this->_params['imap_dsn'] .
-                                          'user' . $this->_separator . $userId);
+                                          'user' . $this->_separator . $name);
 
         if (!$imapresult) {
             return PEAR::raiseError(sprintf(_("IMAP mailbox deletion failed: %s"), imap_last_error()));


More information about the dev mailing list