Changeset 3385


Ignore:
Timestamp:
10/21/10 10:11:01 (14 years ago)
Author:
eduardoalex
Message:

Ticket #1256 - Correcao do erro narrado no ticket em questão

Location:
branches/2.2
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/2.2/expressoMail1_2/inc/class.imap_functions.inc.php

    r3380 r3385  
    5050        } 
    5151        // BEGIN of functions. 
    52         function open_mbox($folder = False) 
     52        function open_mbox($folder = False,$force_die=true) 
    5353        { 
    5454                if (is_resource($this->mbox)) 
    5555                        return $this->mbox; 
    5656                $folder = mb_convert_encoding($folder, "UTF7-IMAP","ISO_8859-1"); 
    57                 $this->mbox = @imap_open("{".$this->imap_server.":".$this->imap_port.$this->imap_options."}".$folder, $this->username, $this->password) or die(serialize(array('imap_error' => $this->parse_error(imap_last_error())))); 
     57                                if($force_die)  
     58                        $this->mbox = @imap_open("{".$this->imap_server.":".$this->imap_port.$this->imap_options."}".$folder, $this->username, $this->password) or die(serialize(array('imap_error' => $this->parse_error(imap_last_error())))); 
     59                else  
     60                        $this->mbox = @imap_open("{".$this->imap_server.":".$this->imap_port.$this->imap_options."}".$folder, $this->username, $this->password); 
    5861                return $this->mbox; 
    5962         } 
  • branches/2.2/expressoMail1_2/inc/hook_home.inc.php

    r3018 r3385  
    3333                $_SESSION['phpgw_info']['expressomail']['server'] = $GLOBALS['phpgw_info']['server']; 
    3434                $expressoMail   = CreateObject($current_app.'.imap_functions'); 
    35                 $mbox_stream = $expressoMail-> open_mbox();              
    36                 $messages        = imap_sort($mbox_stream, SORTARRIVAL, true, SE_UID, UNSEEN); 
    37                 $num_new_messages = count($messages); 
    38                 $subjects = array(); 
    39                  
    40                 foreach($messages as $idx => $message){ 
    41                         if($idx == 10){ 
    42                                 break; 
     35                $mbox_stream = $expressoMail-> open_mbox(False,false);           
     36                if(!$mbox_stream) { 
     37                        $portalbox = CreateObject('phpgwapi.listbox', 
     38                                Array( 
     39                                        'title'     => "<font color=red>".lang('Connection failed with %1 Server. Try later.',lang('Mail'))."</font>", 
     40                                        'primary'   => $GLOBALS['phpgw_info']['theme']['navbar_bg'], 
     41                                        'secondary' => $GLOBALS['phpgw_info']['theme']['navbar_bg'], 
     42                                        'tertiary'  => $GLOBALS['phpgw_info']['theme']['navbar_bg'], 
     43                                        'width'     => '100%', 
     44                                        'outerborderwidth' => '0', 
     45                                        'header_background_image' => $GLOBALS['phpgw']->common->image('phpgwapi/templates/phpgw_website','bg_filler') 
     46                                ) 
     47                        ); 
     48                } 
     49                else { 
     50                        $messages        = imap_sort($mbox_stream, SORTARRIVAL, true, SE_UID, UNSEEN); 
     51                        $num_new_messages = count($messages); 
     52                        $subjects = array(); 
     53                         
     54                        foreach($messages as $idx => $message){ 
     55                                if($idx == 10){ 
     56                                        break; 
     57                                } 
     58                                $header = @imap_headerinfo($mbox_stream, imap_msgno($mbox_stream,$message), 80, 255); 
     59                                if (!is_object($header)) 
     60                                        return false;                    
     61         
     62                                $date_msg = date("d/m/Y",$header->udate); 
     63                                if (date("d/m/Y") == $date_msg) 
     64                                        $date = date("H:i",$header->udate); 
     65                                else 
     66                                        $date = $date_msg; 
     67                                         
     68                                $subject = $expressoMail->decode_string($header->fetchsubject);                          
     69                                $text = "<div style='overflow:hidden;white-space:nowrap'>".$date." .: ".$subject."</div>"; 
     70                                if(strlen($text) > 105) 
     71                                        $text = substr($text,0,105).' ...'; 
     72                         
     73                                $link_msg = $GLOBALS['phpgw']->link( 
     74                                                '/'.$current_app.'/index.php', 
     75                                                'msgball[msgnum]='.$message.'&msgball[folder]=INBOX'); 
     76                                $data[] = array('text' => $text, 'link' => $link_msg);                                   
    4377                        } 
    44                         $header = @imap_headerinfo($mbox_stream, imap_msgno($mbox_stream,$message), 80, 255); 
    45                         if (!is_object($header)) 
    46                                 return false;                    
    47  
    48                         $date_msg = date("d/m/Y",$header->udate); 
    49                         if (date("d/m/Y") == $date_msg) 
    50                                 $date = date("H:i",$header->udate); 
    51                         else 
    52                                 $date = $date_msg; 
    53                                  
    54                         $subject = $expressoMail->decode_string($header->fetchsubject);                          
    55                         $text = "<div style='overflow:hidden;white-space:nowrap'>".$date." .: ".$subject."</div>"; 
    56                         if(strlen($text) > 105) 
    57                                 $text = substr($text,0,105).' ...'; 
    58                  
    59                         $link_msg = $GLOBALS['phpgw']->link( 
    60                                         '/'.$current_app.'/index.php', 
    61                                         'msgball[msgnum]='.$message.'&msgball[folder]=INBOX'); 
    62                         $data[] = array('text' => $text, 'link' => $link_msg);                                   
    63                 } 
    64                                  
    65                 imap_close($mbox_stream); 
    66                  
    67                 $title = $current_name." - ".($num_new_messages > 1 ? lang("You have %1 new messages!","<font color=red>".$num_new_messages."</font>") : ($num_new_messages == 1 ? str_replace("1","<font color=red>1</font>",lang("you have 1 new message!")) : lang("you have no new messages")));                     
    68                 $GLOBALS['phpgw']->translation->add_app($current_app); 
    69  
    70                 if ((isset($prev_currentapp)) && ($prev_currentapp)     && ($GLOBALS['phpgw_info']['flags']['currentapp'] != $prev_currentapp))          
    71                         $GLOBALS['phpgw_info']['flags']['currentapp'] = $prev_currentapp; 
    72                  
    73                 $portalbox = CreateObject('phpgwapi.listbox', 
    74                         Array( 
    75                                 'title'     => $title, 
    76                                 'primary'   => $GLOBALS['phpgw_info']['theme']['navbar_bg'], 
    77                                 'secondary' => $GLOBALS['phpgw_info']['theme']['navbar_bg'], 
    78                                 'tertiary'  => $GLOBALS['phpgw_info']['theme']['navbar_bg'], 
    79                                 'width'     => '100%', 
    80                                 'outerborderwidth' => '0', 
    81                                 'header_background_image' => $GLOBALS['phpgw']->common->image('phpgwapi/templates/phpgw_website','bg_filler') 
    82                         ) 
    83                 ); 
    84  
    85                 $app_id = $GLOBALS['phpgw']->applications->name2id('expressoMail'); 
    86                 $GLOBALS['portal_order'][] = $app_id; 
    87  
    88                 $var = Array( 
    89                         'up'       => Array('url' => '/set_box.php', 'app' => $app_id), 
    90                         'down'     => Array('url' => '/set_box.php', 'app' => $app_id), 
    91                         'close'    => Array('url' => '/set_box.php', 'app' => $app_id), 
    92                         'question' => Array('url' => '/set_box.php', 'app' => $app_id), 
    93                         'edit'     => Array('url' => '/set_box.php', 'app' => $app_id) 
    94                 ); 
    95  
    96                 while(list($key,$value) = each($var))            
    97                         $portalbox->set_controls($key,$value); 
    98  
    99                 $portalbox->data = $data; 
    10078                                         
     79                        imap_close($mbox_stream); 
     80                         
     81                        $title = $current_name." - ".($num_new_messages > 1 ? lang("You have %1 new messages!","<font color=red>".$num_new_messages."</font>") : ($num_new_messages == 1 ? str_replace("1","<font color=red>1</font>",lang("you have 1 new message!")) : lang("you have no new messages")));                     
     82                        $GLOBALS['phpgw']->translation->add_app($current_app); 
     83         
     84                        if ((isset($prev_currentapp)) && ($prev_currentapp)     && ($GLOBALS['phpgw_info']['flags']['currentapp'] != $prev_currentapp))          
     85                                $GLOBALS['phpgw_info']['flags']['currentapp'] = $prev_currentapp; 
     86                         
     87                        $portalbox = CreateObject('phpgwapi.listbox', 
     88                                Array( 
     89                                        'title'     => $title, 
     90                                        'primary'   => $GLOBALS['phpgw_info']['theme']['navbar_bg'], 
     91                                        'secondary' => $GLOBALS['phpgw_info']['theme']['navbar_bg'], 
     92                                        'tertiary'  => $GLOBALS['phpgw_info']['theme']['navbar_bg'], 
     93                                        'width'     => '100%', 
     94                                        'outerborderwidth' => '0', 
     95                                        'header_background_image' => $GLOBALS['phpgw']->common->image('phpgwapi/templates/phpgw_website','bg_filler') 
     96                                ) 
     97                        ); 
     98         
     99                        $app_id = $GLOBALS['phpgw']->applications->name2id('expressoMail'); 
     100                        $GLOBALS['portal_order'][] = $app_id; 
     101         
     102                        $var = Array( 
     103                                'up'       => Array('url' => '/set_box.php', 'app' => $app_id), 
     104                                'down'     => Array('url' => '/set_box.php', 'app' => $app_id), 
     105                                'close'    => Array('url' => '/set_box.php', 'app' => $app_id), 
     106                                'question' => Array('url' => '/set_box.php', 'app' => $app_id), 
     107                                'edit'     => Array('url' => '/set_box.php', 'app' => $app_id) 
     108                        ); 
     109         
     110                        while(list($key,$value) = each($var))            
     111                                $portalbox->set_controls($key,$value); 
     112         
     113                        $portalbox->data = $data; 
     114                }                        
    101115                echo "\n".'<!-- BEGIN Mailbox info -->'."\n".$portalbox->draw($extra_data).'<!-- END Mailbox info -->'."\n"; 
    102116        } 
Note: See TracChangeset for help on using the changeset viewer.