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