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

Revision 2360, 5.0 KB checked in by amuller, 14 years ago (diff)

Ticket #1008 - Adicionando informações sobre licenças

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