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

Revision 1261, 4.0 KB checked in by amuller, 15 years ago (diff)

Ticket #601 - Correção de problema tirando código inflexível

  • 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    = 'ExpressoMail 1.2';
13        $preferences = $GLOBALS['phpgw']->preferences->read();
14        $_SESSION['phpgw_info']['user']['preferences']['expressoMail'] = $preferences['expressoMail'];
15        $homedisplay = $_SESSION['phpgw_info']['user']['preferences']['expressoMail']['mainscreen_showmail'];
16        if($homedisplay=='True')
17        {
18                $homedisplay = 1;
19        }       
20        $homedisplay = intval($homedisplay);
21       
22        $prev_currentapp = $GLOBALS['phpgw_info']['flags']['currentapp'];
23        $GLOBALS['phpgw_info']['flags']['currentapp'] = $current_app;
24         
25        if(intval($homedisplay))
26        {
27                $boemailadmin   = CreateObject('emailadmin.bo');
28                $emailadmin_profile = $boemailadmin->getProfileList();
29                $_SESSION['phpgw_info']['expressomail']['email_server'] = $boemailadmin->getProfile($emailadmin_profile[0]['profileID']);
30                $_SESSION['phpgw_info']['expressomail']['user'] = $GLOBALS['phpgw_info']['user'];
31                $_SESSION['phpgw_info']['expressomail']['server'] = $GLOBALS['phpgw_info']['server'];
32                $expressoMail   = CreateObject($current_app.'.imap_functions');
33                $mbox_stream = $expressoMail-> open_mbox();             
34                $messages        = imap_sort($mbox_stream, SORTARRIVAL, true, SE_UID);
35                $num_new_messages = 0;
36                $subjects = array();
37               
38                for ($i = 0; $i < count($messages);$i++)
39                {
40                        $msg_number = $messages[$i];
41                        $header = @imap_headerinfo($mbox_stream, imap_msgno($mbox_stream, $msg_number), 80, 255);
42                        if (!is_object($header))
43                                return false;                   
44
45                        if($header->Recent != 'N' && $header->Unseen != 'U')
46                                continue;
47                        $new_m++;
48                        if($new_m <= 10) {                             
49                                $date_msg = date("d/m/Y",$header->udate);
50                                if (date("d/m/Y") == $date_msg)
51                                        $date = date("H:i",$header->udate);
52                                else
53                                        $date = $date_msg;
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]='.$msg_number.'&msgball[folder]=INBOX');
62                                $data[] = array('text' => $text, 'link' => $link_msg);         
63                        }                       
64                }
65                               
66                imap_close($mbox_stream);
67                               
68                $title = $current_name." - ".($new_m > 1 ? lang("You have %1 new messages!","<font color=red>".$new_m."</font>") : ($new_m == 1 ? str_replace("1","<font color=red>1</font>",lang("you have 1 new message!")) : lang("you have no new messages")));                     
69                $GLOBALS['phpgw']->translation->add_app($current_app);
70
71                if ((isset($prev_currentapp)) && ($prev_currentapp)     && ($GLOBALS['phpgw_info']['flags']['currentapp'] != $prev_currentapp))         
72                        $GLOBALS['phpgw_info']['flags']['currentapp'] = $prev_currentapp;
73               
74                $portalbox = CreateObject('phpgwapi.listbox',
75                        Array(
76                                'title'     => $title,
77                                'primary'   => $GLOBALS['phpgw_info']['theme']['navbar_bg'],
78                                'secondary' => $GLOBALS['phpgw_info']['theme']['navbar_bg'],
79                                'tertiary'  => $GLOBALS['phpgw_info']['theme']['navbar_bg'],
80                                'width'     => '100%',
81                                'outerborderwidth' => '0',
82                                'header_background_image' => $GLOBALS['phpgw']->common->image('phpgwapi/templates/phpgw_website','bg_filler')
83                        )
84                );
85
86                $app_id = $GLOBALS['phpgw']->applications->name2id('expressoMail');
87                $GLOBALS['portal_order'][] = $app_id;
88
89                $var = Array(
90                        'up'       => Array('url' => '/set_box.php', 'app' => $app_id),
91                        'down'     => Array('url' => '/set_box.php', 'app' => $app_id),
92                        'close'    => Array('url' => '/set_box.php', 'app' => $app_id),
93                        'question' => Array('url' => '/set_box.php', 'app' => $app_id),
94                        'edit'     => Array('url' => '/set_box.php', 'app' => $app_id)
95                );
96
97                while(list($key,$value) = each($var))           
98                        $portalbox->set_controls($key,$value);
99
100                $portalbox->data = $data;
101                                       
102                echo "\n".'<!-- BEGIN Mailbox info -->'."\n".$portalbox->draw($extra_data).'<!-- END Mailbox info -->'."\n";
103        }
Note: See TracBrowser for help on using the repository browser.