index 836e290197faccf0e0e1069c18df43d6c6927323..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'];
}
/* Connect to IMAP server. I don't want to see these warning here... */
$this->gosaMailServer= $gosaMailServer;
if (!isset($this->config[$gosaMailServer])){
- print_red(_("Warning: Account has an invalid mailserver string! Please check the mail server settings in the mail tab."));
+ print_red(_("Warning: Account has an invalid mailserver string!"));
} else {
$cfg= $this->config[$gosaMailServer];
}
if(is_array($quota_value)) {
if (isset($quota_value["STORAGE"]) && is_array($quota_value["STORAGE"])){
/* use for PHP >= 4.3 */
- $result['quotaUsage']= $quota_value["STORAGE"]['usage'];
- $result['gosaMailQuota']= $quota_value["STORAGE"]['limit'];
+ if($quota_value["STORAGE"]['limit'] == 2147483647){
+ $result['quotaUsage']= (int) ($quota_value["STORAGE"]['usage'] / 1024);
+ $result['gosaMailQuota']= (int) ($quota_value["STORAGE"]['limit'] );
+ }else{
+ $result['quotaUsage']= (int) ($quota_value["STORAGE"]['usage'] / 1024);
+ $result['gosaMailQuota']= (int) ($quota_value["STORAGE"]['limit'] / 1024);
+ }
} else {
/* backward icompatible */
- $result['quotaUsage']= $quota_value['usage'];
- $result['gosaMailQuota']= $quota_value['limit'];
+ if($quota_value['usage'] == 2147483647){
+ $result['quotaUsage']= (int) ($quota_value['usage'] / 1024);
+ $result['gosaMailQuota']= (int) ($quota_value['limit'] );
+ }else{
+ $result['quotaUsage']= (int) ($quota_value['usage'] / 1024);
+ $result['gosaMailQuota']= (int) ($quota_value['limit'] / 1024);
+ }
}
+ }elseif(!$quota_value){
+ /* If there is no quota defined for this account, the function imap_get_quota returns false. */
+ return(array("quotaUsage"=>"","gosaMailQuota"=>""));
}
+
error_reporting (E_ALL);
-
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 */
function setQuota($folder, $gosaMailQuota)
{
/* Workaround for the php imap extension */
- if ($gosaMailQuota == ""){
- $gosaMailQuota= "0";
+ if (($gosaMailQuota == "") || ($gosaMailQuota== "2147483647")){
+ $gosaMailQuota= "2147483647";
+ }elseif($gosaMailQuota > 0){
+ $gosaMailQuota = $gosaMailQuota *1024;
}
-
+
+
/* Write mail quota */
if (!imap_set_quota($this->mbox, $folder, $gosaMailQuota)){
print_red(sprintf(_("Can't write IMAP quota. Server says '%s'."), imap_last_error()));
if (function_exists('imap_getacl')){
/* Remove all acl's for this folder */
- $users= imap_getacl ($this->mbox, $subfolder);
- foreach ($users as $userid => $perms){
- imap_setacl ($this->mbox, $subfolder, $userid, "");
+ $users= @imap_getacl ($this->mbox, $subfolder);
+ if(is_array($users)){
+ foreach ($users as $userid => $perms){
+ imap_setacl ($this->mbox, $subfolder, $userid, "");
+ }
}
} else {
print_red (_("Warning: imap_getacl is not implemented, can't remove acl informations."));