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

Revision 2, 3.3 KB checked in by niltonneto, 17 years ago (diff)

Removida todas as tags usadas pelo CVS ($Id, $Source).
Primeira versão no CVS externo.

  • Property svn:eol-style set to native
  • Property svn:executable set to *
Line 
1<?php
2        $current_app = 'expressoMail1_2';
3        $current_name    = 'ExpressoMail 1.2';
4        $homedisplay = $GLOBALS['phpgw_info']['user']['preferences']['expressoMail']['mainscreen_showmail'];
5       
6        if($homedisplay=='True')
7        {
8                $homedisplay = 1;
9        }       
10        $homedisplay = intval($homedisplay);
11       
12        $prev_currentapp = $GLOBALS['phpgw_info']['flags']['currentapp'];
13        $GLOBALS['phpgw_info']['flags']['currentapp'] = $current_app;
14         
15        if(intval($homedisplay))
16        {
17                $boemailadmin   = CreateObject('emailadmin.bo');
18                $emailadmin_profile = $boemailadmin->getProfileList();
19                $_SESSION['phpgw_info']['expressomail']['email_server'] = $boemailadmin->getProfile($emailadmin_profile[0]['profileID']);
20                $_SESSION['phpgw_info']['expressomail']['user'] = $GLOBALS['phpgw_info']['user'];
21                $_SESSION['phpgw_info']['expressomail']['server'] = $GLOBALS['phpgw_info']['server'];
22                $expressoMail   = CreateObject($current_app.'.imap_functions');
23                $mbox_stream = $expressoMail-> open_mbox();             
24                $messages        = imap_sort($mbox_stream, SORTARRIVAL, false, SE_UID);
25                $num_new_messages = 0;
26                $subjects = array();
27                for ($i = 0; $i < count($messages);$i++)
28                {
29                        $msg_number = $messages[$i];
30                        $header = @imap_headerinfo($mbox_stream, imap_msgno($mbox_stream, $msg_number), 80, 255);
31                        if (!is_object($header))
32                                return false;                   
33
34                        if($header->Recent != 'N' && $header->Unseen != 'U')
35                                continue;
36                        $new_m++;
37                        if($new_m <= 10) {                             
38                                $subject = $expressoMail->decode_string($header->fetchsubject);                 
39                                if(strlen($subject) > 65)
40                                        $subject = substr($subject,0,65).' ...';
41                       
42                                $link_msg = $GLOBALS['phpgw']->link(
43                                                '/'.$current_app.'/index.php',
44                                                'msgball[msgnum]='.$msg_number.'&msgball[folder]=INBOX');
45                                $data[] = array('text' => $subject,     'link' => $link_msg     );             
46                        }
47                }
48               
49                imap_close($mbox_stream);
50               
51                $title = $current_name." - ".($new_m > 1 ? lang("you have %1 new messages!",$new_m) : ($new_m == 1 ? lang("you have 1 new message!") : lang("you have no new messages")));                     
52                $GLOBALS['phpgw']->translation->add_app($current_app);
53
54                if ((isset($prev_currentapp)) && ($prev_currentapp)     && ($GLOBALS['phpgw_info']['flags']['currentapp'] != $prev_currentapp))         
55                        $GLOBALS['phpgw_info']['flags']['currentapp'] = $prev_currentapp;
56               
57                $portalbox = CreateObject('phpgwapi.listbox',
58                        Array(
59                                'title'     => $title,
60                                'primary'   => $GLOBALS['phpgw_info']['theme']['navbar_bg'],
61                                'secondary' => $GLOBALS['phpgw_info']['theme']['navbar_bg'],
62                                'tertiary'  => $GLOBALS['phpgw_info']['theme']['navbar_bg'],
63                                'width'     => '100%',
64                                'outerborderwidth' => '0',
65                                'header_background_image' => $GLOBALS['phpgw']->common->image('phpgwapi/templates/phpgw_website','bg_filler')
66                        )
67                );
68
69                $app_id = $GLOBALS['phpgw']->applications->name2id('expressoMail');
70                $GLOBALS['portal_order'][] = $app_id;
71
72                $var = Array(
73                        'up'       => Array('url' => '/set_box.php', 'app' => $app_id),
74                        'down'     => Array('url' => '/set_box.php', 'app' => $app_id),
75                        'close'    => Array('url' => '/set_box.php', 'app' => $app_id),
76                        'question' => Array('url' => '/set_box.php', 'app' => $app_id),
77                        'edit'     => Array('url' => '/set_box.php', 'app' => $app_id)
78                );
79
80                while(list($key,$value) = each($var))           
81                        $portalbox->set_controls($key,$value);
82
83                $portalbox->data = $data;                       
84                echo "\n".'<!-- BEGIN Mailbox info -->'."\n".$portalbox->draw($extra_data).'<!-- END Mailbox info -->'."\n";
85        }
Note: See TracBrowser for help on using the repository browser.