Changeset 508


Ignore:
Timestamp:
10/07/08 14:57:50 (16 years ago)
Author:
niltonneto
Message:

Melhorado função rename_user.
As mensagens de erro estão mais claras e agora é possível
renomear contas com a quota estourada sem problemas.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/expressoAdmin1_2/inc/class.imap_functions.inc.php

    r438 r508  
    128128                { 
    129129                        $result['status'] = false; 
    130                         $result['msg'] = $this->functions->lang('Error on function') . " imap_functions->delete_user.\n" . $this->functions->lang('Server returns') . ': ' . imap_last_error(); 
     130                        $result['msg'] = $this->functions->lang('it was not possible to delete users mailbox') . ".\n"; 
     131                        $result['msg'] .= $this->functions->lang('Server returns') . ': ' . imap_last_error(); 
    131132                } 
    132133                 
     
    136137        function rename_mailbox($old_mailbox, $new_mailbox) 
    137138        { 
    138                 $quota = @imap_get_quotaroot($this->imap, '{'.$this->imap_server.':'.$this->imap_port.'}user' . $this->imapDelimiter . $old_mailbox); 
     139                $result['status'] = true; 
     140 
     141                if (!$quota = @imap_get_quotaroot($this->imap, 'user' . $this->imapDelimiter . $old_mailbox)) 
     142                { 
     143                                $result['status'] = false; 
     144                                $result['msg'] = $this->functions->lang("Error getting user quota. Process aborted.\n") . $this->functions->lang('Server returns') . ': ' . imap_last_error(); 
     145                                return $result; 
     146                } 
    139147                $limit = $quota['STORAGE']['limit']; 
    140                  
    141                 @imap_set_quota($this->imap, '{'.$this->imap_server.':'.$this->imap_port.'}user' . $this->imapDelimiter . $old_mailbox, -1); 
    142                          
    143                 $result_rename = @imap_renamemailbox($this->imap, 
     148                $usage = $quota['STORAGE']['usage']; 
     149                 
     150                if ($usage >= $limit) 
     151                { 
     152                        if (! @imap_set_quota($this->imap, 'user' . $this->imapDelimiter . $old_mailbox, (int)($usage+10240)) ) 
     153                        { 
     154                                $result['status'] = false; 
     155                                $result['msg'] = $this->functions->lang("Error increasing user quota. Process aborted.\n") . $this->functions->lang('Server returns') . ': ' . imap_last_error(); 
     156                                return $result; 
     157                        } 
     158                } 
     159 
     160                 
     161                if (! @imap_renamemailbox($this->imap, 
    144162                                                '{'.$this->imap_server.':'.$this->imap_port.'}user' . $this->imapDelimiter . $old_mailbox, 
    145                                                 '{'.$this->imap_server.':'.$this->imap_port.'}user' . $this->imapDelimiter . $new_mailbox); 
    146                  
    147                 @imap_set_quota($this->imap, '{'.$this->imap_server.':'.$this->imap_port.'}user' . $this->imapDelimiter . $new_mailbox, $limit); 
    148                  
    149                 if (!$result_rename) 
    150                 { 
    151                         $result['status'] = false; 
    152                         $result['msg'] = $this->functions->lang('Error on function') . " imap_functions->rename_mailbox.\n" . $this->functions->lang('Server returns') . ': ' . imap_last_error(); 
    153                 } 
    154                 else 
    155                 { 
    156                         $result['status'] = true; 
    157                 } 
    158                  
     163                                                '{'.$this->imap_server.':'.$this->imap_port.'}user' . $this->imapDelimiter . $new_mailbox) ) 
     164                { 
     165                        $result['status'] = false; 
     166                        $result['msg'] = $this->functions->lang('Server returns') . ': ' . imap_last_error(); 
     167 
     168                } 
     169 
     170 
     171                if ($usage >= $limit) 
     172                { 
     173                        if (! @imap_set_quota($this->imap, 'user' . $this->imapDelimiter . $new_mailbox, (int)($limit)) ) 
     174                        { 
     175                                $result['status'] = false; 
     176                                $result['msg'] .= $this->functions->lang("Error returning user quota.\n") . $this->functions->lang('Server returns') . ': ' . imap_last_error(); 
     177                                 
     178                                @imap_renamemailbox($this->imap, 
     179                                        '{'.$this->imap_server.':'.$this->imap_port.'}user' . $this->imapDelimiter . $new_mailbox, 
     180                                        '{'.$this->imap_server.':'.$this->imap_port.'}user' . $this->imapDelimiter . $old_mailbox); 
     181                        } 
     182                } 
     183 
    159184                return $result; 
    160185        } 
Note: See TracChangeset for help on using the changeset viewer.