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

Revision 5509, 5.7 KB checked in by gustavo, 12 years ago (diff)

Ticket #2488 - Adicionar cabecalho de licenca em arquivos que nao o possuem

  • Property svn:eol-style set to native
  • Property svn:executable set to *
Line 
1<?php
2                /***************************************************************************
3                * Expresso Livre                                                           *
4                * http://www.expressolivre.org                                             *
5                * --------------------------------------------                             *
6                *  This program is free software; you can redistribute it and/or modify it *
7                *  under the terms of the GNU General Public License as published by the   *
8                *  Free Software Foundation; either version 2 of the License, or (at your  *
9                *  option) any later version.                                              *
10                \**************************************************************************/
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 = $expressoMail-> open_mbox(False,false);         
46                if(!$mbox_stream) {
47                        $portalbox = CreateObject('phpgwapi.listbox',
48                                Array(
49                                        'title'     => "<font color=red>".lang('Connection failed with %1 Server. Try later.',lang('Mail'))."</font>",
50                                        'primary'   => $GLOBALS['phpgw_info']['theme']['navbar_bg'],
51                                        'secondary' => $GLOBALS['phpgw_info']['theme']['navbar_bg'],
52                                        'tertiary'  => $GLOBALS['phpgw_info']['theme']['navbar_bg'],
53                                        'width'     => '100%',
54                                        'outerborderwidth' => '0',
55                                        'header_background_image' => $GLOBALS['phpgw']->common->image('phpgwapi/templates/phpgw_website','bg_filler')
56                                )
57                        );
58                }
59                else {
60                        $messages        = imap_sort($mbox_stream, SORTARRIVAL, true, SE_UID, UNSEEN);
61                        $num_new_messages = count($messages);
62                        $subjects = array();
63                       
64                        foreach($messages as $idx => $message){
65                                if($idx == 10){
66                                        break;
67                                }
68                                $header = @imap_headerinfo($mbox_stream, imap_msgno($mbox_stream,$message), 80, 255);
69                                if (!is_object($header))
70                                        return false;                   
71       
72                                $date_msg = date("d/m/Y",$header->udate);
73                                if (date("d/m/Y") == $date_msg)
74                                        $date = date("H:i",$header->udate);
75                                else
76                                        $date = $date_msg;
77
78                                $subject = $expressoMail->decode_string($header->fetchsubject);
79
80                                $text=$date." .: ".$subject;
81                                if(strlen($text) > 55){
82                                    $text = html_entity_decode($text);
83                                    $text = substr($text,0,55).' ...';
84                                    $text = htmlentities($text);                                     
85                                }
86                                $text = "<div style='overflow:hidden;white-space:nowrap'>".$text."</div>";
87                               
88                                $link_msg = $GLOBALS['phpgw']->link(
89                                                '/'.$current_app.'/index.php',
90                                                'msgball[msgnum]='.$message.'&msgball[folder]=INBOX');
91                                $data[] = array('text' => $text, 'link' => $link_msg);                                 
92                        }
93                                       
94                        imap_close($mbox_stream);
95                       
96                        $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")));                   
97                        $GLOBALS['phpgw']->translation->add_app($current_app);
98       
99                        if ((isset($prev_currentapp)) && ($prev_currentapp)     && ($GLOBALS['phpgw_info']['flags']['currentapp'] != $prev_currentapp))         
100                                $GLOBALS['phpgw_info']['flags']['currentapp'] = $prev_currentapp;
101                       
102                        $portalbox = CreateObject('phpgwapi.listbox',
103                                Array(
104                                        'title'     => $title,
105                                        'primary'   => $GLOBALS['phpgw_info']['theme']['navbar_bg'],
106                                        'secondary' => $GLOBALS['phpgw_info']['theme']['navbar_bg'],
107                                        'tertiary'  => $GLOBALS['phpgw_info']['theme']['navbar_bg'],
108                                        'width'     => '100%',
109                                        'outerborderwidth' => '0',
110                                        'header_background_image' => $GLOBALS['phpgw']->common->image('phpgwapi/templates/phpgw_website','bg_filler')
111                                )
112                        );
113       
114                        $app_id = $GLOBALS['phpgw']->applications->name2id('expressoMail');
115                        $GLOBALS['portal_order'][] = $app_id;
116       
117                        $var = Array(
118                                'up'       => Array('url' => '/set_box.php', 'app' => $app_id),
119                                'down'     => Array('url' => '/set_box.php', 'app' => $app_id),
120                                'close'    => Array('url' => '/set_box.php', 'app' => $app_id),
121                                'question' => Array('url' => '/set_box.php', 'app' => $app_id),
122                                'edit'     => Array('url' => '/set_box.php', 'app' => $app_id)
123                        );
124       
125                        while(list($key,$value) = each($var))           
126                                $portalbox->set_controls($key,$value);
127       
128                        $portalbox->data = $data;
129                }                       
130                echo "\n".'<!-- BEGIN Mailbox info -->'."\n".$portalbox->draw($extra_data).'<!-- END Mailbox info -->'."\n";
131        }
Note: See TracBrowser for help on using the repository browser.