Ignore:
Timestamp:
11/03/11 13:24:14 (12 years ago)
Author:
wmerlotto
Message:

Ticket #2305 - Enviando alteracoes, desenvolvidas internamente na Prognus, do modulo ExpressoAdmin.

File:
1 edited

Legend:

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

    r4059 r5133  
    2323                $this->imap_server      = $_SESSION['phpgw_info']['expresso']['email_server']['imapServer']; 
    2424                $this->imap_port        = $_SESSION['phpgw_info']['expresso']['email_server']['imapPort']; 
    25                 $this->imap_createspamfolder    = $_SESSION['phpgw_info']['expresso']['email_server']['imapCreateSpamFolder']; 
    26                 $this->imap_cyrususerspam = $_SESSION['phpgw_info']['expresso']['email_server']['imapCyrusUserPostSpam'] ? $_SESSION['phpgw_info']['expresso']['email_server']['imapCyrusUserPostSpam'] : "anonymous"; 
    2725                $this->imap_trashfolder  = $_SESSION['phpgw_info']['expresso']['email_server']['imapDefaultTrashFolder']  ? $_SESSION['phpgw_info']['expresso']['email_server']['imapDefaultTrashFolder']  : str_replace("*","", $this->functions->lang("trash")); 
    2826                $this->imap_sentfolder   = $_SESSION['phpgw_info']['expresso']['email_server']['imapDefaultSentFolder']   ? $_SESSION['phpgw_info']['expresso']['email_server']['imapDefaultSentFolder']   : str_replace("*","", $this->functions->lang("sent")); 
     
    7068                        return $result; 
    7169                } 
    72                 if (!empty($this->imap_spamfolder) && $this->imap_createspamfolder == 'yes') 
     70                /* Esperando correção do william (prognus) sobre a utilização do DSPAM 
     71                if (!empty($this->imap_sentfolder)) 
    7372                { 
    7473                    if (!imap_createmailbox($this->imap, '{'.$this->imap_server.'}' . "user" . $this->imapDelimiter . $uid . $this->imapDelimiter . $this->imap_spamfolder)) 
     
    7877                            $result['msg'] = $this->functions->lang('Error on function') . " imap_functions->create(".$this->imap_spamfolder."):" . $error[0]; 
    7978                            return $result; 
    80                         } else { 
    81                                 imap_setacl($this->imap, "user" . $this->imapDelimiter . $uid.  $this->imapDelimiter . $this->imap_spamfolder , $this->imap_cyrususerspam, 'p');                         
    8279         } 
    8380                }                
     81                */ 
    8482 
    8583                if (!imap_set_quota($this->imap,"user" . $this->imapDelimiter . $uid, ($mailquota*1024)))  
     
    9795        function get_user_info($uid) 
    9896        { 
    99                 $get_quota = @imap_get_quota($this->imap,"user" . $this->imapDelimiter . $uid); 
     97                $get_quota = @imap_get_quotaroot($this->imap,"user" . $this->imapDelimiter . $uid); 
    10098                 
    10199                if (count($get_quota) == 0) 
     
    148146                $result['status'] = true; 
    149147 
    150                 if (!$quota = @imap_get_quota($this->imap, 'user' . $this->imapDelimiter . $old_mailbox)) 
     148                if (!$quota = @imap_get_quotaroot($this->imap, 'user' . $this->imapDelimiter . $old_mailbox)) 
    151149                { 
    152150                                $result['status'] = false; 
     
    253251                                $result['inbox_size'] = $inbox_size; 
    254252                                 
    255                                 $get_user_quota = @imap_get_quota($this->imap,"user" . $this->imapDelimiter . $uid); 
     253                                $get_user_quota = @imap_get_quotaroot($this->imap,"user" . $this->imapDelimiter . $uid); 
    256254                                $result['mailquota_used'] = (string)(round(($get_user_quota['usage']/1024), 2)); 
    257255                        } 
     
    317315                        } 
    318316                } 
     317 
     318                if( $result['status'] ) 
     319                    $this->sendACLAdvice( $user, $acl, $mailbox ); 
     320 
    319321                return $result; 
    320322        } 
     
    373375                                return $result; 
    374376            } 
    375             file_put_contents("/tmp/saida", "old ".print_r($owners_acl_old, true)."remove ".print_r($owners_to_remove, true)."add ".print_r($owners_to_add, true)."update ".print_r($owners_to_update, true)); 
     377            //file_put_contents("/tmp/saida", "old ".print_r($owners_acl_old, true)."remove ".print_r($owners_to_remove, true)."add ".print_r($owners_to_add, true)."update ".print_r($owners_to_update, true)); 
    376378            if( is_array($owners_acl_new)){ 
    377379                foreach($owners_to_remove as $user => $acl){ 
     
    397399            return $result; 
    398400        } 
     401         
     402        function sendACLAdvice( $user, $acls, $shared_account ) 
     403        { 
     404            //acl treat 
     405            $acl_labels = array( 'lrs' => 'read messages from this shared account', 
     406                                 'd' => 'delete/move messages from this shared account', 
     407                                 'wi' => 'create/add messages in this shared account', 
     408                                 'a' => 'send message by this shared account', 
     409                                 'p' => 'save sent messages in this shared account', 
     410                                 'c' => 'create or delete folders on this shared account' ); 
     411 
     412            $acl_found = array(); 
     413 
     414            foreach( $acl_labels as $acl => $label ) 
     415            { 
     416                if( strpos( $acls, $acl ) !== false ) 
     417                { 
     418                    $acl_found[] = $this->functions->lang( $label ); 
     419                } 
     420            } 
     421 
     422            $acl = implode( "<br/>", $acl_found ); 
     423 
     424            if( empty( $acl ) ) 
     425            return; 
     426 
     427            //body mail template generation 
     428            $body = $this->getTemplate( "body_email.tpl", array( "user" => $user, 
     429                                                                 "acl" => $acl, 
     430                                                                 "shared_account" => $shared_account ) ); 
     431 
     432            //ldap fetch mail to 
     433            require_once('class.ldap_functions.inc.php'); 
     434 
     435            if( !$ldap ) 
     436            { 
     437                $ldap = new ldap_functions(); 
     438            } 
     439 
     440            $to = $ldap->uid2mailforwardingaddress( $user ); 
     441            $to = $to['mail']; 
     442 
     443            //mail send service 
     444            $mail = ServiceLocator::getService( 'mail' ); 
     445            $mail->sendMail( $to, false, $this->functions->lang("Your user was add/updated in the shared account"), $body ); 
     446        } 
     447 
     448        function getTemplate( $tpls, $macros, $target = false ) 
     449        { 
     450            require_once( ROOT.'header.inc.php' ); 
     451 
     452            $template = CreateObject( 'phpgwapi.Template', PHPGW_APP_TPL ); 
     453 
     454            if( !is_array( $tpls ) ) 
     455            { 
     456                $tpls = array( $tpls ); 
     457            } 
     458 
     459            $keys = array_keys( $tpls ); 
     460 
     461            if( !array_diff_key( $tpl, array_keys( $keys ) ) ) 
     462            { 
     463                $newTpls = array(); 
     464 
     465                foreach( $tpls as $tpl ) 
     466                { 
     467                    $key = basename( $tpl ); 
     468 
     469                    $dot = strrpos( $key, '.' ); 
     470 
     471                    if( $dot !== false ) 
     472                    { 
     473                        $key = substr( $key, 0, $dot ); 
     474                    } 
     475 
     476                    $newTpls[ $key ] = $tpl; 
     477                } 
     478 
     479                $tpls = $newTpls; 
     480 
     481                $keys = array_keys( $tpls ); 
     482            } 
     483 
     484            $template->set_file( $tpls ); 
     485 
     486            $target = $target ? $tpls[ $target ] : $keys[0]; 
     487 
     488            $template->set_var( $this->functions->make_dinamic_lang( $template, $target ) ); 
     489            $template->set_var( $macros ); 
     490 
     491            return $template->fp( 'out', $target ); 
     492        } 
    399493} 
Note: See TracChangeset for help on using the changeset viewer.