index 15c3c53c3a8fc128654e31136942f831f6cdea8d..580c18c346a0ff8e0ec8f8885784c7bb29b732bf 100644 (file)
var $mbox= "-";
var $config;
var $gosaMailServer= "";
var $mbox= "-";
var $config;
var $gosaMailServer= "";
+ var $uattrib= "uid";
- function mailMethodCyrus($config)
+ function mailMethodCyrus(&$config)
{
$this->config= $config->data['SERVERS']['IMAP'];
}
{
$this->config= $config->data['SERVERS']['IMAP'];
}
function connect($gosaMailServer)
{
$cfg=array();
function connect($gosaMailServer)
{
$cfg=array();
+
/* Connect to IMAP server. I don't want to see these warning here... */
$this->gosaMailServer= $gosaMailServer;
if (!isset($this->config[$gosaMailServer])){
/* 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];
}
} else {
$cfg= $this->config[$gosaMailServer];
}
if(!isset($cfg['admin'])) $cfg['admin']="";
if(!isset($cfg['password'])) $cfg['password']="";
if(!isset($cfg['admin'])) $cfg['admin']="";
if(!isset($cfg['password'])) $cfg['password']="";
+ /* Setting connect timeout to 10 seconds,
+ else the GOsa UI may freeze for 60 seconds.
+ (PHP default is 'default_socket_timeout = 60') */
+ imap_timeout(1, 10 );
+
$this->mbox = @imap_open($cfg['connect'], $cfg['admin'], $cfg['password'], OP_HALFOPEN);
/* Mailbox reachable? */
$this->mbox = @imap_open($cfg['connect'], $cfg['admin'], $cfg['password'], OP_HALFOPEN);
/* Mailbox reachable? */
if(is_array($quota_value)) {
if (isset($quota_value["STORAGE"]) && is_array($quota_value["STORAGE"])){
/* use for PHP >= 4.3 */
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 */
} 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);
-
+
+ error_reporting (E_ALL | E_STRICT);
return ($result);
}
return ($result);
}
- function getMailboxList($folder, $uid= "")
+
+ /* 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];
}
/* 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){
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);
}
return ($result);
}
+
function updateMailbox($folder)
{
/* Check if mailbox exists */
function updateMailbox($folder)
{
/* Check if mailbox exists */
function setQuota($folder, $gosaMailQuota)
{
/* Workaround for the php imap extension */
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()));
/* 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()));
function setSharedFolderPermissions($folder, $permissions)
{
function setSharedFolderPermissions($folder, $permissions)
{
- /* Show warning message in case of missing imap_getacl */
- if (!function_exists('imap_getacl')){
- print_red (_("Warning: imap_getacl is not implemented, wouldn't modify acl informations."));
- return;
- }
-
/* Get list of subfolders */
$folders= $this->getMailboxList($folder, "");
$folders[]= $folder;
/* Get list of subfolders */
$folders= $this->getMailboxList($folder, "");
$folders[]= $folder;
if (function_exists('imap_getacl')){
/* Remove all acl's for this folder */
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."));
}
/* Set permissions for this folder */
}
/* Set permissions for this folder */