Skip to content
GitLab
Explore
Projects
Groups
Topics
Snippets
Projects
Groups
Topics
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Bachelot Xavier
fusiondirectory-plugins
Commits
a203a0d0
Unverified
Commit
a203a0d0
authored
4 years ago
by
Côme Chilliet
Browse files
Options
Download
Patches
Plain Diff
fix(zimbra) Correctly support quota from COS in zimbra plugin
issue #6104
parent
39cd61bc
6104-mail-methods-refactor
No related merge requests found
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
mail/personal/mail/class_MailQuotaAttribute.inc
+16
-5
mail/personal/mail/class_MailQuotaAttribute.inc
mail/personal/mail/class_mail-methods.inc
+9
-1
mail/personal/mail/class_mail-methods.inc
mail/personal/mail/class_mailTabPlugin.inc
+1
-1
mail/personal/mail/class_mailTabPlugin.inc
zimbra/personal/mail/mail-methods/class_mail-methods-zimbra.inc
+46
-2
.../personal/mail/mail-methods/class_mail-methods-zimbra.inc
zimbra/personal/mail/mail-methods/zimbraSoap.php
+1
-1
zimbra/personal/mail/mail-methods/zimbraSoap.php
with
73 additions
and
10 deletions
+73
-10
mail/personal/mail/class_MailQuotaAttribute.inc
+
16
−
5
View file @
a203a0d0
...
...
@@ -21,7 +21,16 @@
class
MailQuotaAttribute
extends
UnitIntAttribute
{
/**
* @var int Quota usage in MiB, -1 if unknown
*/
private
$quotaUsage
;
/**
* @var string Quota limit in MiB, empty string if unlimited
*
* The same as $this->value, unless there is an inherited group limit
*/
private
$quotaLimit
;
function
__construct
(
$label
,
$description
,
$ldapName
,
$required
,
$min
=
FALSE
,
$max
=
FALSE
,
$defaultValue
=
""
,
$acl
=
""
)
{
...
...
@@ -39,6 +48,7 @@ class MailQuotaAttribute extends UnitIntAttribute
/* Read quota */
$this
->
setValue
((
string
)
$mailMethod
->
getQuota
(
$this
->
getValue
()));
$this
->
quotaUsage
=
$mailMethod
->
getQuotaUsage
();
$this
->
quotaLimit
=
$mailMethod
->
getQuotaLimit
(
$this
->
getValue
());
}
catch
(
MailMethodError
$e
)
{
$error
=
new
SimplePluginError
(
$this
,
...
...
@@ -60,7 +70,7 @@ class MailQuotaAttribute extends UnitIntAttribute
'htmlid'
=>
$this
->
getHtmlId
()
.
'_usage'
,
'label'
=>
'{literal}'
.
_
(
'Quota usage'
)
.
'{/literal}'
,
'description'
=>
_
(
'Part of the quota which is used'
),
'input'
=>
static
::
quotaToImage
(
$this
->
quotaUsage
,
$this
->
getValue
()
),
'input'
=>
static
::
quotaToImage
(
$this
->
quotaUsage
,
$this
->
quotaLimit
),
'subattribute'
=>
FALSE
,
'required'
=>
FALSE
,
'readable'
=>
$readable
,
...
...
@@ -68,15 +78,16 @@ class MailQuotaAttribute extends UnitIntAttribute
];
}
static
function
quotaToImage
(
$use
,
$quota
):
string
static
function
quotaToImage
(
int
$use
,
string
$quota
):
string
{
if
(
$use
==
-
1
)
{
return
' '
.
_
(
'Unknown'
);
return
' '
.
htmlescape
(
_
(
'Unknown'
)
)
;
}
elseif
(
empty
(
$quota
))
{
return
' '
.
_
(
'Unlimited'
);
return
' '
.
htmlescape
(
sprintf
(
_
(
'Unlimited (%dMiB used)'
),
$use
)
);
}
else
{
$usage
=
round
((
$use
/
$quota
)
*
100
);
return
'<img src="progress.php?x=100&y=17&p='
.
$usage
.
'" alt="'
.
$usage
.
'%"/>'
;
$alt
=
htmlescape
(
sprintf
(
_
(
'%d%% (%dMiB)'
),
$usage
,
$use
));
return
'<img src="progress.php?x=100&y=17&p='
.
$usage
.
'" alt="'
.
$alt
.
'" title="'
.
$alt
.
'"/>'
;
}
}
}
This diff is collapsed.
Click to expand it.
mail/personal/mail/class_mail-methods.inc
+
9
−
1
View file @
a203a0d0
...
...
@@ -269,7 +269,7 @@ class mailMethod
return
-
1
;
}
/*! \brief Returns the quota restrictions.
/*! \brief Returns the quota restrictions
specific to this user
.
@return string quota value, numeric string or empty string
*/
public
function
getQuota
(
string
$quotaValue
):
string
...
...
@@ -277,6 +277,14 @@ class mailMethod
return
$quotaValue
;
}
/*! \brief Returns the quota restrictions specific or inherited by this user.
@return string quota value, numeric string or empty string
*/
public
function
getQuotaLimit
(
string
$quotaValue
):
string
{
return
$quotaValue
;
}
/*! \brief Sets the mail quota
*/
public
function
setQuota
(
string
$number
)
...
...
This diff is collapsed.
Click to expand it.
mail/personal/mail/class_mailTabPlugin.inc
+
1
−
1
View file @
a203a0d0
...
...
@@ -70,7 +70,7 @@ class mailTabPlugin extends simplePlugin
public
function
mailServerChanged
()
{
$this
->
mailMethod
=
mailMethod
::
getInstanceFromServer
(
$this
->
gosaMailServer
,
$this
);
$this
->
mailMethod
=
mailMethod
::
getInstanceFromServer
(
$this
->
attributesAccess
[
$this
->
serverAttr
]
->
getValue
()
,
$this
);
if
(
$this
->
initialMailMethod
===
NULL
)
{
$this
->
initialMailMethod
=
$this
->
mailMethod
;
}
...
...
This diff is collapsed.
Click to expand it.
zimbra/personal/mail/mail-methods/class_mail-methods-zimbra.inc
+
46
−
2
View file @
a203a0d0
...
...
@@ -682,8 +682,11 @@ class mailMethodZimbra extends mailMethod
public
function
getQuota
(
string
$quotaValue
):
string
{
if
(
$this
->
cacheAccount
())
{
/* Server sends quota in bytes */
if
(
isset
(
$this
->
cachedAccount
[
'account'
][
'zimbraMailQuota'
])
&&
is_numeric
(
$this
->
cachedAccount
[
'account'
][
'zimbraMailQuota'
]))
{
if
(
isset
(
$this
->
cachedAccount
[
'account'
][
'zimbraMailQuota'
])
&&
is_numeric
(
$this
->
cachedAccount
[
'account'
][
'zimbraMailQuota'
])
)
{
/* Server sends quota in bytes */
return
(
string
)
floor
(
$this
->
cachedAccount
[
'account'
][
'zimbraMailQuota'
]
/
(
1024
*
1024
));
}
else
{
return
''
;
...
...
@@ -692,6 +695,35 @@ class mailMethodZimbra extends mailMethod
return
$quotaValue
;
}
/*! \brief Returns the quota restrictions specific or inherited by this user.
@return string quota value, numeric string or empty string
*/
public
function
getQuotaLimit
(
string
$quotaValue
):
string
{
if
(
empty
(
$quotaValue
)
&&
$this
->
cacheAccount
())
{
if
(
isset
(
$this
->
cachedAccount
[
'account'
][
'zimbraCOSId'
])
&&
(
$this
->
cachedAccount
[
'account'
][
'zimbraCOSId'
]
!==
''
)
)
{
$cosOptions
=
$this
->
getCosOptions
();
foreach
(
$cosOptions
as
$cosOption
)
{
if
(
$cosOption
[
'id'
]
===
$this
->
cachedAccount
[
'account'
][
'zimbraCOSId'
])
{
if
(
isset
(
$cosOption
[
'attributes'
][
'zimbraMailQuota'
])
&&
is_numeric
(
$cosOption
[
'attributes'
][
'zimbraMailQuota'
])
&&
(
$cosOption
[
'attributes'
][
'zimbraMailQuota'
]
>
0
)
)
{
/* Server sends quota in bytes */
return
(
string
)
floor
(
$cosOption
[
'attributes'
][
'zimbraMailQuota'
]
/
(
1024
*
1024
));
}
break
;
}
}
}
}
return
$quotaValue
;
}
public
function
additionalAttributes
(
string
$acl
):
array
{
$attributes
=
[];
...
...
@@ -716,6 +748,18 @@ class mailMethodZimbra extends mailMethod
(
isset
(
$this
->
cachedAccount
[
'account'
][
'zimbraAccountStatus'
])
?
$this
->
cachedAccount
[
'account'
][
'zimbraAccountStatus'
]
:
_
(
'Unknown'
)),
$acl
);
$cosLimit
=
$this
->
getQuotaLimit
(
''
);
if
(
$cosLimit
!==
''
)
{
array_unshift
(
$attributes
,
new
DisplayAttribute
(
_
(
'COS quota'
),
_
(
'Quota limit set in the class of service'
),
'zimbraCOSQuota'
,
FALSE
,
sprintf
(
_
(
'%sMiB'
),
$cosLimit
),
$acl
)
);
}
}
$cosOptions
=
$this
->
getCosOptions
();
$choices
=
[];
...
...
This diff is collapsed.
Click to expand it.
zimbra/personal/mail/mail-methods/zimbraSoap.php
+
1
−
1
View file @
a203a0d0
...
...
@@ -390,7 +390,7 @@ class getAllCosResponse extends Response {
{
return
array_map
(
function
(
$cos
)
{
return
[
'id'
=>
$cos
->
id
,
'name'
=>
$cos
->
name
];
return
[
'id'
=>
$cos
->
id
,
'name'
=>
$cos
->
name
,
'attributes'
=>
static
::
attributesListToArray
(
$cos
->
a
)
];
},
$this
->
cos
);
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment
Menu
Explore
Projects
Groups
Topics
Snippets