[dev] update for cyrsql (new option to set subfolders on creation and
some cleanup)
Ilya
mail@krel.org
Wed, 4 Sep 2002 23:50:37 -0400
---------------------- multipart/mixed attachment
file attached
---------------------- multipart/mixed attachment
--- cyrsql.php.orig Wed Sep 4 22:42:54 2002
+++ cyrsql.php Wed Sep 4 23:46:21 2002
@@ -20,11 +20,21 @@
* 'database' The name of the database.
* 'cyradmin' The username of cyrus administrator
* 'cyrpass' The password associated woth cyrus administrator
- * 'impas' The full imap hostname (ie {localhost:993/imap/ssl/novalidate-cert} )
+ * 'imaps' The full imap hostname (ie {localhost:993/imap/ssl/novalidate-cert} )
*
* Optional values:
- * 'table' The name of the auth table in 'database'. Defaults to
- * 'horde_users'.
+ * 'table' The name of the auth table in 'database'.
+ * Defaults to 'horde_users'.
+ * 'username_field' The name of the username field in the auth table.
+ * Defaults to 'user_uid'.
+ * 'password_field' The name of the password field in the auth table.
+ * Defaults to 'user_pass'.
+ * 'folders()' An array of folders to create under username.
+ * Doesnt create subfolders by default
+ *
+ *
+ *
+ *
*
* Required by some database implementations:
* 'options' Additional options to pass to the database.
@@ -61,6 +71,7 @@
*/
var $_mbox;
+
/**
* Add a set of authentication credentials.
*
@@ -81,11 +92,9 @@
}
$name = imap_utf7_encode($userID);
- if (@imap_createmailbox($this->_mbox, imap_utf7_encode($this->_params['imaps'] . "user.$name"))) {
- @imap_createmailbox($this->_mbox, imap_utf7_encode($this->_params['imaps'] . "user.$name.saved"));
- @imap_createmailbox($this->_mbox, imap_utf7_encode($this->_params['imaps'] . "user.$name.sent-mail"));
- @imap_createmailbox($this->_mbox, imap_utf7_encode($this->_params['imaps'] . "user.$name.drafts"));
- @imap_createmailbox($this->_mbox, imap_utf7_encode($this->_params['imaps'] . "user.$name.trash"));
+ if (@imap_createmailbox($this->_mbox, imap_utf7_encode($this->_params['imaps'] .
+ "user.$name"))) {
+ @array_walk( $this->_params['folders'], array($this,'_createSubFolders'), $name );
} else {
Horde::logMessage('IMAP mailbox creation for ' . $name . ' failed ',
__FILE__, __LINE__, LOG_ERR);
@@ -142,7 +151,8 @@
// opened everything.
$this->_connected = false;
- $this->_mbox = @imap_open($this->_params['imaps'], $this->_params['cyradmin'], $this->_params['cyrpass'], OP_HALFOPEN);
+ $this->_mbox = @imap_open($this->_params['imaps'], $this->_params['cyradmin'],
+ $this->_params['cyrpass'], OP_HALFOPEN);
if (!$this->_mbox) {
Horde::fatal(new PEAR_Error(sprintf(_("Can't connect to IMAP server: %s"),
imap_last_error())), __FILE__, __LINE__);
@@ -171,5 +181,15 @@
return true;
}
+
+ /**
+ * Creates all mailboxes supllied in configuration
+ * @access private
+ *
+ */
+ function _createSubFolders( $value , $key, $userName){
+ @imap_createmailbox($this->_mbox, imap_utf7_encode($this->_params['imaps'] .
+ "user.$userName.$value"));
+ }
}
---------------------- multipart/mixed attachment--