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

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/expressoMail1_2/inc/class.db_functions.inc.php

    r3018 r5134  
    210210         
    211211        function get_dropdown_contacts(){ 
    212                  
    213                 $contacts = $this -> get_cc_contacts(); 
    214                 $groups = $this -> get_cc_groups(); 
     212                $contacts = $this->get_cc_contacts(); 
     213                $groups = $this->get_cc_groups(); 
    215214                 
    216215                if(($contacts) && ($groups)) 
     
    223222                        $stringDropDownContacts = $groups; 
    224223                                         
    225                 if($_SESSION['phpgw_info']['user']['preferences']['expressoMail']['number_of_contacts'] && 
    226                         $_SESSION['phpgw_info']['user']['preferences']['expressoMail']['use_dynamic_contacts']) { 
     224                if($_SESSION['phpgw_info']['user']['preferences']['expressoMail']['use_dynamic_contacts']) { 
    227225                        // Free others requests  
    228226                        session_write_close();  
     
    270268        {                                
    271269                // Pesquisa os emails e ultima inserção nos contatos dinamicos. 
    272                 if(!$this->db->select('phpgw_expressomail_contacts','data', 
    273                                                   'id_owner ='.$this -> user_id, 
    274                                                   __LINE__,__FILE__)) 
     270                if(!$this->db->select('phpgw_expressomail_contacts','data','id_owner ='.$this->user_id,__LINE__,__FILE__)) 
    275271                { 
    276272                return $this->db->Error; 
     
    295291        function update_contacts($contacts=array()) 
    296292        {                        
     293                 
     294         
     295                if(!$this->db->select('phpgw_expressomail_contacts','data','id_owner ='.$this->user_id,__LINE__,__FILE__)) 
     296        { 
     297            $result['dberr1'] = $this->db->Error; 
     298        } 
     299                $regs = array(); 
     300                while($this->db->next_record()) 
     301        { 
     302            $regs[] = $this->db->row(); 
     303        } 
     304                $old_contatacts = array(); 
     305                foreach($regs as $old){ 
     306                        $old_contatacts = unserialize($old['data']); 
     307                } 
     308                  
     309                foreach($old_contatacts as $i => $v) 
     310                        foreach($contacts as $ii => $vv) 
     311                                if(trim($v['email']) == trim($vv['email'])) 
     312                                        unset($old_contatacts[$i]); 
     313                 
     314                  
     315                 $old_contatacts = array_merge( $old_contatacts , $contacts);            
    297316                // Atualiza um email nos contatos dinamicos. 
    298                 if(!$this->db->update('phpgw_expressomail_contacts ','data=\''.serialize($contacts).'\'', 
    299                         'id_owner ='.$this -> user_id, 
    300                         __LINE__,__FILE__)) 
     317                if(!$this->db->update('phpgw_expressomail_contacts ','data=\''.serialize($old_contatacts).'\'','id_owner ='.$this->user_id,__LINE__,__FILE__)) 
    301318                { 
    302319                        return $this->db->Error; 
     
    344361                $msg_part = $params['msg_part']; 
    345362                $msg_folder = $params['msg_folder']; 
     363            $from_ajax = $params['from_ajax']; 
    346364                $encoding = strtolower($params['encoding']); 
    347365                $fileContent = ""; 
    348  
    349                 if($msg_number && $msg_part && $msg_folder && (intval($idx_file == '0' ? '1' : $idx_file))) { 
    350                         $mbox_stream = $objImap->open_mbox($msg_folder);         
    351                         $fileContent = imap_fetchbody($mbox_stream, $msg_number, $msg_part, FT_UID); 
    352                         include_once('class.imap_attachment.inc.php'); 
    353                         $imap_attachment = new imap_attachment(); 
    354                         $a = $imap_attachment->download_attachment($mbox_stream, $msg_number); 
    355                         $filename = $a[$idx_file]['name']; 
     366            $cirus_delimiter = $params['cirus_delimiter']; 
     367            $expFolder = explode($cirus_delimiter, $msg_folder); 
     368 
     369            if($msg_number != null && $msg_part != null && $msg_folder != null && (intval($idx_file == '0' ? '1' : $idx_file))) 
     370            { 
     371                require_once $_SESSION['rootPath'].'/expressoMail1_2/inc/class.attachment.inc.php'; 
     372                $attachmentObj = new attachment(); 
     373                $attachmentObj->setStructureFromMail($msg_folder,$msg_number); 
     374                $fileContent = $attachmentObj->getAttachment($msg_part); 
     375                $info = $attachmentObj->getAttachmentInfo($msg_part); 
     376                $filename = $info['name']; 
    356377                } 
    357378                else 
    358379                        $filename = $idx_file; 
    359380                                         
    360                 if($fileContent) { 
    361                         if($encoding == 'base64') 
    362                                 $calendar = imap_base64($fileContent); 
    363                         else if($encoding == 'quoted-printable') 
    364                                 $calendar = quoted_printable_decode($fileContent); 
    365                         else 
    366                                 $calendar = $fileContent; 
    367                 } 
    368381                // It's necessary to access calendar method.  
     382            $GLOBALS['phpgw_info']['flags']['noappheader'] = True; 
     383            $GLOBALS['phpgw_info']['flags']['noappfooter'] = True; 
     384            $GLOBALS['phpgw_info']['flags']['currentapp'] = 'calendar'; 
    369385                include_once(PHPGW_INCLUDE_ROOT.'/header.inc.php');  
    370                          
    371386                $uiicalendar = CreateObject("calendar.uiicalendar"); 
    372                 return $uiicalendar = $uiicalendar->import_from_mail($calendar); 
     387 
     388            if(strtoupper($expFolder[0]) == 'USER' && $expFolder[1]) // IF se a conta o ical estiver em uma conta compartilhada 
     389            { 
     390                include_once('class.ldap_functions.inc.php'); 
     391                $ldap = new ldap_functions(); 
     392                $account['uid'] = $expFolder[1]; 
     393                $account['uidnumber']  = $ldap->uid2uidnumber($expFolder[1]); 
     394                $account['mail']  = $ldap->getMailByUid($expFolder[1]); 
     395 
     396                return $uiicalendar->import_from_mail($fileContent, $from_ajax,$account); 
     397            } 
     398            else 
     399                return $uiicalendar->import_from_mail($fileContent, $from_ajax); 
     400             
     401             
    373402        } 
    374403 
     
    439468        } 
    440469 
     470         
     471        /** 
     472     * @abstract Recupera o valor da regra padrão. 
     473     * @return retorna o valor da regra padrão. 
     474     */ 
     475        function get_default_max_size_rule() 
     476        { 
     477                $query = "SELECT config_value FROM phpgw_config WHERE config_name = 'expressoAdmin_default_max_size'"; 
     478                if(!$this->db->query($query)) 
     479            return false; 
     480 
     481        $return = array(); 
     482                         
     483                while($this->db->next_record()) 
     484            array_push($return, $this->db->row()); 
     485                         
     486                return $return; 
     487        } 
     488         
     489        /** 
     490     * @abstract Recupera a regra de um usuário. 
     491     * @return retorna a regra que o usuário pertence. Caso o usuário não participe de nenhuma regra, retorna false. 
     492     */ 
     493        function get_rule_by_user($id_user)  
     494        { 
     495                $return = array();       
     496                $query = "SELECT email_max_recipient FROM phpgw_expressoadmin_configuration WHERE email_user='$id_user' AND configuration_type='MessageMaxSize'"; 
     497                 
     498                if(!$this->db->query($query)) 
     499            return false; 
     500                 
     501                while($this->db->next_record()) 
     502            array_push($return, $this->db->row()); 
     503                         
     504                return $return; 
     505        } 
     506         
     507         
     508        function get_rule_by_user_in_groups($id_group) 
     509        { 
     510                $return = array(); 
     511                $query = "SELECT email_max_recipient FROM phpgw_expressoadmin_configuration WHERE configuration_type='MessageMaxSize' AND email_user_type='G' AND email_user='".$id_group."'"; 
     512 
     513                if(!$this->db->query($query))    
     514                        return false;    
     515                         
     516                while($this->db->next_record()) 
     517                        array_push($return, $this->db->row()); 
     518 
     519                return $return;  
     520        } 
     521        function getMaximumRecipientsUser($pUserUID) 
     522        { 
     523 
     524           $query = 'SELECT email_max_recipient FROM phpgw_expressoadmin_configuration WHERE email_user = \''.$pUserUID.'\' AND configuration_type = \'LimitRecipient\' AND email_user_type = \'U\' '; 
     525           $this->db->query($query); 
     526 
     527           $return = array(); 
     528 
     529            while($this->db->next_record()) 
     530              $return =  $this->db->row(); 
     531 
     532            return $return['email_max_recipient']; 
     533        } 
     534 
     535        function getMaximumRecipientsGroup($pGroupsGuidnumbers) 
     536        { 
     537           $groupsGuidNumbers = ''; 
     538 
     539           foreach ($pGroupsGuidnumbers as $guidNumber => $cn) 
     540             $groupsGuidNumbers .= $guidNumber.', '; 
     541 
     542           $groupsGuidNumbers = substr($groupsGuidNumbers,0,-2); 
     543 
     544           $query = 'SELECT email_max_recipient FROM phpgw_expressoadmin_configuration WHERE email_user IN ('.$groupsGuidNumbers.') AND configuration_type = \'LimitRecipient\' AND email_user_type = \'G\' '; 
     545           $this->db->query($query); 
     546 
     547           $return = array(); 
     548 
     549            while($this->db->next_record()) 
     550              $return[] =  $this->db->row(); 
     551 
     552            $maxSenderReturn = 0; 
     553 
     554            foreach ($return as $maxSender) 
     555            { 
     556                if($maxSender['email_max_recipient'] > $maxSenderReturn) 
     557                    $maxSenderReturn = $maxSender['email_max_recipient']; 
     558            } 
     559 
     560            return $maxSenderReturn; 
     561        } 
     562 
     563        function validadeSharedAccounts($user,$grups,$accountsMails) 
     564        { 
     565 
     566             $arrayMailsBlocked = array(); 
     567 
     568             $query = 'SELECT * FROM phpgw_expressoadmin_configuration WHERE email_user = \''.$user.'\' AND email_recipient = \'*\'  AND configuration_type = \'InstitutionalAccountException\' AND email_user_type = \'U\' '; 
     569             $this->db->query($query); 
     570             $this->db->next_record(); 
     571                 if($this->db->row()) 
     572                   return $arrayMailsBlocked; 
     573 
     574            foreach ($grups as $guidNumber => $cn) 
     575            { 
     576                 $query = 'SELECT * FROM phpgw_expressoadmin_configuration WHERE email_user = \''.$guidNumber.'\' AND email_recipient = \'*\'  AND configuration_type = \'InstitutionalAccountException\' AND email_user_type = \'G\' '; 
     577                 $this->db->query($query); 
     578                 $this->db->next_record(); 
     579                 if($this->db->row()) 
     580                     return $arrayMailsBlocked; 
     581 
     582            } 
     583 
     584            foreach ($accountsMails as $mail) 
     585            { 
     586                
     587               $blocked = true; 
     588 
     589               $query = 'SELECT * FROM phpgw_expressoadmin_configuration WHERE email_recipient = \''.$mail.'\' AND configuration_type = \'InstitutionalAccountException\' '; 
     590               $this->db->query($query); 
     591            
     592                while($this->db->next_record()) 
     593                { 
     594                    $row =  $this->db->row(); 
     595                     
     596                    if(($row['email_user'] == '*' ||  $row['email_user'] == $user) && ($row['email_user_type'] == 'T' || $row['email_user_type'] == 'U')) 
     597                        $blocked = false; 
     598                    else if(array_key_exists($row['email_user'], $grups) && $row['email_user_type'] == 'G') 
     599                         $blocked = false;  
     600 
     601                } 
     602 
     603                if($blocked == true) 
     604                    array_push ($arrayMailsBlocked, $mail); 
     605            } 
     606 
     607            return $arrayMailsBlocked; 
     608        } 
     609 
    441610} 
    442611?> 
Note: See TracChangeset for help on using the changeset viewer.