Home » Networking » Net_IMAP » Bug #2657
cmdSetQuota does not allow to remove quota
Details
| Request #2657 | cmdSetQuota does not allow to remove quota |
|---|---|
| Submitted | 2004-11-01 10:21 UTC |
| From | jan at jgc dot homeip dot net |
| Assigned | amistry |
| Status | No Feedback |
| Package | Net_IMAP |
| PHP Version | 4.3.9 |
| OS | Linux 2.6 |
| Roadmaps | (Not assigned) |
Comments
[2004-11-01 10:21 UTC] jan at jgc dot homeip dot net
Description:
------------
cmdSetQuota does not support unsetting quota. To remove quota, you have to supply this command: ". SETQUOTA mailbox ()"
[2006-02-14 16:00 UTC] bluecamel at imap dot cc
This patch to IMAPProtocol.php solves the following problems:
* remove quota by setting:
$ret = $imap->setStorageQuota('user.mailbox', -1);
* Cyrus IMAPd rmquota patch to delete the quota:
$ret = $imap->setStorageQuota('user.mailbox', 'remove');
* Don't spit protocol errors when the following happens
for $ret = $imap->getStorageQuota('user.mailbox');
C: A0004 GETQUOTA user.damian
S: * QUOTA user.damian ()
S: A0004 OK Completed
--- IMAPProtocol.php.orig 2006-02-14 10:38:00.833484319 -0500
+++ IMAPProtocol.php 2006-02-14 10:53:17.212881536 -0500
@@ -1466,7 +1466,16 @@
//Make the command request
$param=sprintf("%s (",$mailbox_name);
if($storageQuota != null ){
- $param=sprintf("%sSTORAGE %s",$param,$storageQuota);
+ if ($storageQuota == -1) {
+ // set -1 to remove a quota
+ $param = sprintf("%s", $param);
+ } elseif ($storageQuota == strtolower('remove')) {
+ // this is a cyrus rmquota specific feature
+ // see http://email.uoa.gr/projects/cyrus/quota-patches/rmquota/
+ $param = sprintf("%sREMOVE 1", $param);
+ } else {
+ $param = sprintf("%sSTORAGE %s", $param, $storageQuota);
+ }
if( $messagesQuota != null ){
//if we have both types of quota on the same call we must append an space between
// those parameters
@@ -2545,6 +2554,12 @@
C: A0004 GETQUOTA user.damian
S: * QUOTA user.damian (STORAGE 1781460 4000000)
S: A0004 OK Completed
+
+ RFC 2087 section 5.1 says the list could be empty:
+
+ C: A0004 GETQUOTA user.damian
+ S: * QUOTA user.damian ()
+ S: A0004 OK Completed
*/
$mailbox = $this->_parseOneStringResponse( $str,__LINE__ , __FILE__ );
@@ -2553,6 +2568,10 @@
$ret_aux = array("MAILBOX"=>$this->utf_7_decode($mailbox) );
$this->_getNextToken( $str , $quota_resp );
+ if ($quota_resp == ')' ) {
+ // empty list, apparently no STORAGE or MESSAGE quota set
+ return array($token => $ret_aux);
+ }
if( ( $ext = $this->_retrParsedResponse( $str , $quota_resp )) == false){
$this->_prot_error("bogus response!!!!" , __LINE__ , __FILE__ );
}
[2006-02-14 16:12 UTC] bluecamel at imap dot cc
Due to line wraps the above patch is also available from http://files.bluecamel.imap.cc/
[2006-03-22 05:00 UTC] amistry at php dot net
I've fixed this in the CVS. Please confirm it works for you.