source: trunk/expressoMail1_2/inc/hook_home.inc.php @ 2043

Revision 2043, 4.2 KB checked in by eduardoalex, 14 years ago (diff)

Ticket #918 - Correção do problema descrito no ticket em questão.

  • Property svn:eol-style set to native
  • Property svn:executable set to *
Line 
1<?php
2        if(!isset($GLOBALS['phpgw_info'])){
3                $GLOBALS['phpgw_info']['flags'] = array(
4                        'currentapp' => 'expressoMail1_2',
5                        'nonavbar'   => true,
6                        'noheader'   => true
7                );
8        }
9
10       
11        $current_app = 'expressoMail1_2';
12        $current_name    = 'Expresso Mail';
13        $preferences = $GLOBALS['phpgw']->preferences->read();
14    $_SESSION['phpgw_info']['user']['preferences']['expressoMail'] = $preferences['expressoMail'];
15        $_SESSION['phpgw_info']['user']['preferences']['expressoMail']['max_attachment_size'] = $current_config['expressoMail_Max_attachment_size'] ? $current_config['expressoMail_Max_attachment_size']."M" : ini_get('upload_max_filesize');
16        $homedisplay = $_SESSION['phpgw_info']['user']['preferences']['expressoMail']['mainscreen_showmail'];
17        if($homedisplay=='True')
18        {
19                $homedisplay = 1;
20        }       
21        $homedisplay = intval($homedisplay);
22       
23        $prev_currentapp = $GLOBALS['phpgw_info']['flags']['currentapp'];
24        $GLOBALS['phpgw_info']['flags']['currentapp'] = $current_app;
25         
26        if(intval($homedisplay))
27        {
28                $boemailadmin   = CreateObject('emailadmin.bo');
29                $emailadmin_profile = $boemailadmin->getProfileList();
30                $_SESSION['phpgw_info']['expressomail']['email_server'] = $boemailadmin->getProfile($emailadmin_profile[0]['profileID']);
31                $_SESSION['phpgw_info']['expressomail']['user'] = $GLOBALS['phpgw_info']['user'];
32                $_SESSION['phpgw_info']['expressomail']['server'] = $GLOBALS['phpgw_info']['server'];
33                $expressoMail   = CreateObject($current_app.'.imap_functions');
34                $mbox_stream = $expressoMail-> open_mbox();             
35                $messages        = imap_sort($mbox_stream, SORTARRIVAL, true, SE_UID, UNSEEN);
36                $num_new_messages = count($messages);
37                $subjects = array();
38               
39                foreach($messages as $idx => $message){
40                        if($idx == 10){
41                                break;
42                        }
43                        $header = @imap_headerinfo($mbox_stream, imap_msgno($mbox_stream,$message), 80, 255);
44                        if (!is_object($header))
45                                return false;                   
46
47                        $date_msg = date("d/m/Y",$header->udate);
48                        if (date("d/m/Y") == $date_msg)
49                                $date = date("H:i",$header->udate);
50                        else
51                                $date = $date_msg;
52                               
53                        $subject = $expressoMail->decode_string($header->fetchsubject);                         
54                        $text = "<div style='overflow:hidden;white-space:nowrap'>".$date." .: ".$subject."</div>";
55                        if(strlen($text) > 105)
56                                $text = substr($text,0,105).' ...';
57               
58                        $link_msg = $GLOBALS['phpgw']->link(
59                                        '/'.$current_app.'/index.php',
60                                        'msgball[msgnum]='.$message.'&msgball[folder]=INBOX');
61                        $data[] = array('text' => $text, 'link' => $link_msg);                                 
62                }
63                               
64                imap_close($mbox_stream);
65               
66                $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")));                   
67                $GLOBALS['phpgw']->translation->add_app($current_app);
68
69                if ((isset($prev_currentapp)) && ($prev_currentapp)     && ($GLOBALS['phpgw_info']['flags']['currentapp'] != $prev_currentapp))         
70                        $GLOBALS['phpgw_info']['flags']['currentapp'] = $prev_currentapp;
71               
72                $portalbox = CreateObject('phpgwapi.listbox',
73                        Array(
74                                'title'     => $title,
75                                'primary'   => $GLOBALS['phpgw_info']['theme']['navbar_bg'],
76                                'secondary' => $GLOBALS['phpgw_info']['theme']['navbar_bg'],
77                                'tertiary'  => $GLOBALS['phpgw_info']['theme']['navbar_bg'],
78                                'width'     => '100%',
79                                'outerborderwidth' => '0',
80                                'header_background_image' => $GLOBALS['phpgw']->common->image('phpgwapi/templates/phpgw_website','bg_filler')
81                        )
82                );
83
84                $app_id = $GLOBALS['phpgw']->applications->name2id('expressoMail');
85                $GLOBALS['portal_order'][] = $app_id;
86
87                $var = Array(
88                        'up'       => Array('url' => '/set_box.php', 'app' => $app_id),
89                        'down'     => Array('url' => '/set_box.php', 'app' => $app_id),
90                        'close'    => Array('url' => '/set_box.php', 'app' => $app_id),
91                        'question' => Array('url' => '/set_box.php', 'app' => $app_id),
92                        'edit'     => Array('url' => '/set_box.php', 'app' => $app_id)
93                );
94
95                while(list($key,$value) = each($var))           
96                        $portalbox->set_controls($key,$value);
97
98                $portalbox->data = $data;
99                                       
100                echo "\n".'<!-- BEGIN Mailbox info -->'."\n".$portalbox->draw($extra_data).'<!-- END Mailbox info -->'."\n";
101        }
Note: See TracBrowser for help on using the repository browser.