Setting QUOTA through PHP ...

Marc G. Fournier scrappy at hub.org
Mon Feb 13 16:10:43 EST 2006


g'day ...

   I'm trying to fix up the mailadmin interface we are using for Cyrus, and 
the last thing I know to be broken is PHPs internal 'imap_set_quota' 
command ... namely, it no longer accept a non-integer value for the quota, 
so you can't pass 'none' to it ...

   So, I'm looking at the Pear Net_Cyrus module, which looks like it should 
work ...

   I'm trying to do:

   $quota = &new Net_Cyrus();
   $quota->connect("$username@$domain",
                           $password,
                           $mail_server_name,
                           $mail_server_port);
   $quota->setQuota("user.".$user, "none");

   but, its not removing the quota, altho changing none -> any #, it will 
set the quota properly ... so my syntax looks to be right ...

   tracing the code, it gets down to Net_IMAPProtocol.php, with the 
function being:

     function cmdSetQuota($mailbox_name, $storageQuota = null ,$messagesQuota = null )
     {
         //Check if the IMAP server has QUOTA support
         if( ! $this->hasQuotaSupport() ){
             return new PEAR_Error("This IMAP server does not support QUOTA's! ");
         }

         if( ($messagesQuota == null) && ( $storageQuota == null) ){
             return new PEAR_Error('$storageQuota and $messagesQuota parameters can\'t be both null if you want to use quota');
         }
         $mailbox_name=sprintf("\"%s\"",$this->utf_7_encode($mailbox_name) );
         //Make the command request
         $param=sprintf("%s (",$mailbox_name);
         if($storageQuota != null ){
             $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
                 $param=sprintf("%s ",$param);
             }
         }
         if($messagesQuota != null ){
             $param=sprintf("%sMESSAGES %s",$param,$messagesQuota);

         }
         $param=sprintf("%s)",$param);

         return $this->_genericCommand('SETQUOTA', $param );
     }


Putting a 'print $param' just before the _genericCommand, the output is:

"user.cotton" (STORAGE none)

So, it would be passing:

SETQUOTA "user.cotton" (STORAGE none)

to the backend ... again, if none == an integer #, the quota gets set, so 
it looks like the syntax itself is right, but 'none' is wrong ...

Is anyone doing this with PHP that has gotten around the above issue?  Is 
there something obviously wrong with the way the SETQUOTA is being 
generated?

Thanks ...


----
Marc G. Fournier           Hub.Org Networking Services (http://www.hub.org)
Email: scrappy at hub.org           Yahoo!: yscrappy              ICQ: 7615664


More information about the Info-cyrus mailing list