[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'; |
---|
[2079] | 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'); |
---|
[2324] | 35 | $mbox_stream = @imap_open("{".$expressoMail->imap_server.":".$expressoMail->imap_port.$expressoMail->imap_options."}", |
---|
| 36 | $expressoMail->username, $expressoMail->password); |
---|
[2] | 37 | |
---|
[2324] | 38 | if($mbox_stream){ |
---|
| 39 | |
---|
| 40 | $messages= imap_sort($mbox_stream, SORTARRIVAL, true, SE_UID, UNSEEN); |
---|
| 41 | $num_new_messages = count($messages); |
---|
| 42 | $subjects = array(); |
---|
| 43 | foreach($messages as $idx => $message){ |
---|
| 44 | if($idx == 10){ |
---|
| 45 | break; |
---|
| 46 | } |
---|
| 47 | $header = @imap_headerinfo($mbox_stream, imap_msgno($mbox_stream,$message), 80, 255); |
---|
| 48 | if (!is_object($header)) |
---|
| 49 | return false; |
---|
| 50 | |
---|
| 51 | $date_msg = date("d/m/Y",$header->udate); |
---|
| 52 | if (date("d/m/Y") == $date_msg) |
---|
| 53 | $date = date("H:i",$header->udate); |
---|
| 54 | else |
---|
| 55 | $date = $date_msg; |
---|
| 56 | |
---|
| 57 | $subject = $expressoMail->decode_string($header->fetchsubject); |
---|
| 58 | $text = "<div style='overflow:hidden;white-space:nowrap'>".$date." .: ".$subject."</div>"; |
---|
| 59 | if(strlen($text) > 105) |
---|
| 60 | $text = substr($text,0,105).' ...'; |
---|
| 61 | |
---|
| 62 | $link_msg = $GLOBALS['phpgw']->link( |
---|
| 63 | '/'.$current_app.'/index.php', |
---|
| 64 | 'msgball[msgnum]='.$message.'&msgball[folder]=INBOX'); |
---|
| 65 | $data[] = array('text' => $text, 'link' => $link_msg); |
---|
| 66 | } |
---|
[2330] | 67 | $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"))); |
---|
[2324] | 68 | imap_close($mbox_stream); |
---|
[2] | 69 | } |
---|
[2324] | 70 | else{ |
---|
| 71 | $title = $current_name." <font color=red> [imap] ".imap_last_error()."</font>"; |
---|
| 72 | } |
---|
| 73 | |
---|
[2] | 74 | $GLOBALS['phpgw']->translation->add_app($current_app); |
---|
| 75 | |
---|
| 76 | if ((isset($prev_currentapp)) && ($prev_currentapp) && ($GLOBALS['phpgw_info']['flags']['currentapp'] != $prev_currentapp)) |
---|
| 77 | $GLOBALS['phpgw_info']['flags']['currentapp'] = $prev_currentapp; |
---|
| 78 | |
---|
| 79 | $portalbox = CreateObject('phpgwapi.listbox', |
---|
| 80 | Array( |
---|
| 81 | 'title' => $title, |
---|
| 82 | 'primary' => $GLOBALS['phpgw_info']['theme']['navbar_bg'], |
---|
| 83 | 'secondary' => $GLOBALS['phpgw_info']['theme']['navbar_bg'], |
---|
| 84 | 'tertiary' => $GLOBALS['phpgw_info']['theme']['navbar_bg'], |
---|
| 85 | 'width' => '100%', |
---|
| 86 | 'outerborderwidth' => '0', |
---|
| 87 | 'header_background_image' => $GLOBALS['phpgw']->common->image('phpgwapi/templates/phpgw_website','bg_filler') |
---|
| 88 | ) |
---|
| 89 | ); |
---|
| 90 | |
---|
| 91 | $app_id = $GLOBALS['phpgw']->applications->name2id('expressoMail'); |
---|
| 92 | $GLOBALS['portal_order'][] = $app_id; |
---|
| 93 | |
---|
| 94 | $var = Array( |
---|
| 95 | 'up' => Array('url' => '/set_box.php', 'app' => $app_id), |
---|
| 96 | 'down' => Array('url' => '/set_box.php', 'app' => $app_id), |
---|
| 97 | 'close' => Array('url' => '/set_box.php', 'app' => $app_id), |
---|
| 98 | 'question' => Array('url' => '/set_box.php', 'app' => $app_id), |
---|
| 99 | 'edit' => Array('url' => '/set_box.php', 'app' => $app_id) |
---|
| 100 | ); |
---|
| 101 | |
---|
| 102 | while(list($key,$value) = each($var)) |
---|
| 103 | $portalbox->set_controls($key,$value); |
---|
| 104 | |
---|
[139] | 105 | $portalbox->data = $data; |
---|
| 106 | |
---|
[2] | 107 | echo "\n".'<!-- BEGIN Mailbox info -->'."\n".$portalbox->draw($extra_data).'<!-- END Mailbox info -->'."\n"; |
---|
[1037] | 108 | } |
---|