index 2c5c532cb96e60ebccc4efc55ecd2a6dded10dcc..1c361877b8e18009fb6074399c9644ef078d8b52 100644 (file)
function connect($gosaMailServer)
{
function connect($gosaMailServer)
{
+ $cfg=array();
+
/* Connect to IMAP server. I don't want to see these warning here... */
$this->gosaMailServer= $gosaMailServer;
/* Connect to IMAP server. I don't want to see these warning here... */
$this->gosaMailServer= $gosaMailServer;
- $cfg= $this->config[$gosaMailServer];
-
+ if (!isset($this->config[$gosaMailServer])){
+ print_red(_("Warning: Account has an invalid mailserver string!"));
+ } else {
+ $cfg= $this->config[$gosaMailServer];
+ }
/* For some reason, hiding errors with @ does not wor here... */
/* For some reason, hiding errors with @ does not wor here... */
+ if(!isset($cfg['connect'])) $cfg['connect']="";
+ if(!isset($cfg['admin'])) $cfg['admin']="";
+ if(!isset($cfg['password'])) $cfg['password']="";
+
$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 {
} else {
- /* backward compatible */
- $result['quotaUsage']= $quota_value['usage'];
- $result['gosaMailQuota']= $quota_value['limit'];
+ /* backward icompatible */
+ 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);
-
return ($result);
}
return ($result);
}
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 */