index a3e03ef50be580682ae5270df36f35077d6186d7..6c822691b210e6088d12add1a88827abdec59e29 100644 (file)
var $mbox= "-";
var $config;
var $gosaMailServer= "";
+var $uattrib= "uid";
function mailMethodCyrus($config)
{
+ /* Check if the mail account identification attribute
+ is overridden in the configuration file
+ */
+ if(isset($config->current['MAIL_ATTRIB']) && !empty($config->current['MAIL_ATTRIB'])){
+ $new_uattrib= strtolower($config->current['MAIL_ATTRIB']);
+ if(in_array($new_uattrib,array("mail","uid"))){
+ $this->uattrib = $new_uattrib;
+ }else{
+ trigger_error(sprintf("Unsupported MAIL_ATTRIB in gosa configuration specified, use 'mail' or 'uid', instead of '%s'.", $new_uattrib));
+ }
+ }
+
$this->config= $config->data['SERVERS']['IMAP'];
}
return ($result);
}
+
+ /* return all folders of the users mailbox*/
function getMailboxList($folder, $uid= "")
{
- /* Initialize depending on group or user mode */
- if ($uid != ""){
- $result= array("INBOX");
- } else {
- $result= array();
+ global $config;
+ $result = array();
+
+ /* Get domain an mail address if uid is an mail address */
+ $domain = "";
+ if(preg_match("/@/",$folder)){
+ $domain = "@".preg_replace("/^.*@/","",$folder);
+ $folder = preg_replace("/@.*$/","",$folder);
}
/* Get list of mailboxes for combo box */
$cfg= $this->config[$this->gosaMailServer];
- $list = imap_listmailbox($this->mbox, $cfg["connect"], $folder.".*");
+
+ /* Create search pattern
+ (user/kekse*@domain.de
+ user.kekse*@domain.de
+ user.kekse* )
+ depending on given folder name) */
+ $q = $folder."*".$domain;
+ $list = imap_listmailbox($this->mbox, $cfg["connect"], $q);
+
+ /* Create list of returned folder names */
if (is_array($list)){
foreach ($list as $val){
- $result[]=preg_replace ("/.*user\.".$uid."\./",
- "INBOX.", imap_utf7_decode ($val));
+
+ /* Cut domain name */
+ $val = preg_replace("/@.*$/","",$val);
+ $result[]=preg_replace ("/^.*".normalizePreg($folder)."/","INBOX", mb_convert_encoding($val, "UTF-8", "UTF7-IMAP"));
}
}
+ /* Append "INBOX" to the folder array if result is empty and request comes from user dialog */
+ if(empty($result) && !empty($uid)){
+ $result[] = "INBOX";
+ }
+
return ($result);
}
+
function updateMailbox($folder)
{
/* Check if mailbox exists */