[623] | 1 | <?php |
---|
| 2 | /**************************************************************************\ |
---|
| 3 | * eGroupWare * |
---|
| 4 | * http://www.egroupware.org * |
---|
| 5 | * The file written by Mário César Kolling <mario.kolling@serpro.gov.br> * |
---|
| 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 | |
---|
| 13 | //TODO: Criar a Classe Widget. |
---|
| 14 | |
---|
| 15 | include_once(PHPGW_INCLUDE_ROOT.'/expressoMail1_2/inc/class.imap_functions.inc.php'); |
---|
| 16 | |
---|
| 17 | // Classe principal do Mini Mail |
---|
| 18 | class ui_mobilemail{ |
---|
| 19 | |
---|
| 20 | // Define as funções públicas |
---|
| 21 | var $public_functions = array( |
---|
| 22 | 'mail_list' => True, |
---|
| 23 | 'change_folder' => True, |
---|
| 24 | 'change_page' => True, |
---|
| 25 | 'show_msg' => True, |
---|
| 26 | 'send_mail' => True, |
---|
| 27 | //'reply_msg' => True, |
---|
| 28 | 'new_msg' => True, |
---|
[1453] | 29 | 'delete_msg' => True, |
---|
[1474] | 30 | 'init_schedule' => true, |
---|
| 31 | 'add_recipients' => true, |
---|
| 32 | 'add_recipient' => true, |
---|
[3571] | 33 | 'list_folders' => true, |
---|
[3576] | 34 | 'save_draft' => true, |
---|
[3579] | 35 | 'mark_message_with_flag' => true, |
---|
[3589] | 36 | 'change_search_box_type' => true, |
---|
| 37 | 'index' => true |
---|
[623] | 38 | ); |
---|
[4002] | 39 | |
---|
| 40 | var $bo_mobilemail; |
---|
[3571] | 41 | var $template; |
---|
[3576] | 42 | var $common; |
---|
[623] | 43 | var $folders; // Pastas imap |
---|
[3579] | 44 | var $current_search_box_type; |
---|
[623] | 45 | var $current_folder; // Pasta corrente |
---|
| 46 | var $current_page; // Página corrente da lista de e-mails da pasta corrente |
---|
| 47 | var $imap_functions; // Variável que recebe um objeto do tipo class.imap_functions.inc.php |
---|
| 48 | var $allowed_tags = '<p><a><br><em><strong><ol><li><ul><div><font>'; // Tags html que não serão removidas |
---|
| 49 | // ao mostrar corpo do e-mail |
---|
| 50 | |
---|
| 51 | |
---|
| 52 | /* |
---|
| 53 | * @function mobilemail |
---|
| 54 | * @abstract Método construtor da classe principal do Mini Mail |
---|
| 55 | * @author Mário César Kolling <mario.kolling@serpro.gov.br> |
---|
| 56 | */ |
---|
| 57 | function ui_mobilemail() |
---|
| 58 | { |
---|
[4002] | 59 | $this-> load_session(); |
---|
[3571] | 60 | $this->template = CreateObject('phpgwapi.Template', PHPGW_SERVER_ROOT . '/mobile/templates/'.$GLOBALS['phpgw_info']['server']['template_set']); |
---|
[3576] | 61 | $this->common = CreateObject('mobile.common_functions'); |
---|
[4002] | 62 | $this->bo_mobilemail = CreateObject('mobile.bo_mobilemail'); |
---|
[3571] | 63 | |
---|
[623] | 64 | // Recupera atributos da classe gravados na sessão |
---|
| 65 | $folders = $GLOBALS['phpgw']->session->appsession('mobilemail.folders','mobile'); |
---|
| 66 | $current_folder = $GLOBALS['phpgw']->session->appsession('mobilemail.current_folder','mobile'); |
---|
| 67 | $current_page = $GLOBALS['phpgw']->session->appsession('mobilemail.current_page','mobile'); |
---|
[3579] | 68 | $current_search_box_type = $GLOBALS['phpgw']->session->appsession('mobilemail.current_search_box_type','mobile'); |
---|
| 69 | |
---|
[623] | 70 | // Inicializa a classe class.imap_functions.inc.php |
---|
| 71 | $this->imap_functions = new imap_functions(); |
---|
| 72 | |
---|
| 73 | // Testa a existência dos atributos da classe recuperadas da sessão, e as carrega ou inicializa. |
---|
| 74 | if ($folders) |
---|
| 75 | { |
---|
| 76 | $this->folders = $folders; |
---|
| 77 | } |
---|
| 78 | else |
---|
| 79 | { |
---|
[1848] | 80 | $this->folders = $this->imap_functions->get_folders_list(array('noSharedFolders' => true)); |
---|
[623] | 81 | } |
---|
| 82 | |
---|
| 83 | if ($current_folder) |
---|
| 84 | { |
---|
| 85 | $this->current_folder = $current_folder; |
---|
[3346] | 86 | $current_page = 1; |
---|
[623] | 87 | } |
---|
| 88 | else |
---|
| 89 | { |
---|
| 90 | $this->current_folder = 0; // Define o folder INBOX como o folder corrente |
---|
| 91 | } |
---|
| 92 | |
---|
| 93 | if ($current_page) |
---|
| 94 | { |
---|
| 95 | $this->current_page = $current_page; |
---|
| 96 | } |
---|
| 97 | else |
---|
| 98 | { |
---|
| 99 | $this->current_page = 1; // Define a primeira página como página padrão |
---|
| 100 | } |
---|
[3579] | 101 | |
---|
| 102 | if($current_search_box_type) |
---|
| 103 | { |
---|
| 104 | $this->current_search_box_type = $current_search_box_type; |
---|
| 105 | } |
---|
| 106 | else { |
---|
| 107 | $this->current_search_box_type = "all"; |
---|
| 108 | } |
---|
[623] | 109 | |
---|
| 110 | } |
---|
| 111 | |
---|
| 112 | /* |
---|
| 113 | * @function save_session |
---|
| 114 | * @abstract Salva os atributos da classe na sessão |
---|
| 115 | * @author Mário César Kolling <mario.kolling@serpro.gov.br> |
---|
| 116 | */ |
---|
| 117 | function save_session() |
---|
| 118 | { |
---|
| 119 | $GLOBALS['phpgw']->session->appsession('mobilemail.folders','mobile',$this->folders); |
---|
| 120 | $GLOBALS['phpgw']->session->appsession('mobilemail.current_folder','mobile',$this->current_folder); |
---|
| 121 | $GLOBALS['phpgw']->session->appsession('mobilemail.current_page','mobile',$this->current_page); |
---|
[3579] | 122 | $GLOBALS['phpgw']->session->appsession('mobilemail.current_search_box_type','mobile',$this->current_search_box_type); |
---|
[623] | 123 | } |
---|
| 124 | |
---|
| 125 | /* |
---|
| 126 | * @function change_page |
---|
| 127 | * @abstract Troca a página de exibição da lista de e-mails, e mostra a nova página |
---|
| 128 | * @author Mário César Kolling <mario.kolling@serpro.gov.br> |
---|
| 129 | */ |
---|
[3579] | 130 | function change_page($params) |
---|
[623] | 131 | { |
---|
[3579] | 132 | if (isset($params['page'])) |
---|
[623] | 133 | { |
---|
[3579] | 134 | $this->current_page = $params['page']; |
---|
[623] | 135 | } |
---|
| 136 | $this->mail_list(); |
---|
| 137 | $this->save_session(); |
---|
| 138 | } |
---|
| 139 | |
---|
[3579] | 140 | function change_search_box_type($params) { |
---|
| 141 | if (isset($params['search_box_type'])) |
---|
| 142 | { |
---|
| 143 | $this->current_search_box_type = $params['search_box_type']; |
---|
| 144 | $this->current_page = 1; |
---|
| 145 | } |
---|
| 146 | $this->mail_list(); |
---|
| 147 | $this->save_session(); |
---|
| 148 | } |
---|
| 149 | |
---|
[623] | 150 | /* |
---|
| 151 | * @function change_folder |
---|
| 152 | * @abstract Troca a pasta do imap, e mostra a primeira página da nova pasta |
---|
| 153 | * @author Mário César Kolling <mario.kolling@serpro.gov.br> |
---|
| 154 | */ |
---|
[3576] | 155 | function change_folder($params) |
---|
[623] | 156 | { |
---|
[3576] | 157 | $folder = $params['folder']; |
---|
[623] | 158 | if (isset($folder)) |
---|
| 159 | { |
---|
| 160 | $this->current_folder = $folder; |
---|
| 161 | $this->current_page = 1; |
---|
[3579] | 162 | $this->current_search_box_type = "all"; |
---|
[623] | 163 | } |
---|
[3576] | 164 | |
---|
[3579] | 165 | |
---|
[3576] | 166 | $GLOBALS['phpgw_info']['mobiletemplate']->set_error_msg($params["error_message"]); |
---|
[3589] | 167 | $GLOBALS['phpgw_info']['mobiletemplate']->set_success_msg($params["success_message"]); |
---|
[3579] | 168 | $this->mail_list(); |
---|
[623] | 169 | $this->save_session(); |
---|
| 170 | } |
---|
[3576] | 171 | |
---|
| 172 | function mark_message_with_flag($params=array()) |
---|
| 173 | { |
---|
[3589] | 174 | |
---|
[3655] | 175 | if(isset($params['msgs'])) |
---|
[3589] | 176 | $params["msgs_to_set"] = implode(",",$params["msgs"]); |
---|
| 177 | |
---|
[3655] | 178 | if (isset($params["msgs_to_set"])){ |
---|
[3576] | 179 | |
---|
[3655] | 180 | $return = $this->imap_functions->set_messages_flag($params); |
---|
[3576] | 181 | |
---|
[3655] | 182 | if($return) |
---|
| 183 | header('Location: index.php?menuaction=menuaction=mobile.ui_mobilemail.index&success_message='.lang("The messages were marked as seen")); |
---|
| 184 | else |
---|
| 185 | header('Location: index.php?menuaction=menuaction=mobile.ui_mobilemail.show_msg&msg_number='.$params["msgs_to_set"].'&msg_folder='.$return["msg_folder"].'&error_message='.$return["msg"]); |
---|
| 186 | |
---|
| 187 | } else { |
---|
[3658] | 188 | header('Location: index.php?menuaction=menuaction=mobile.ui_mobilemail.index&error_message='.lang("please select one e-mail")); |
---|
[3655] | 189 | } |
---|
| 190 | |
---|
[3576] | 191 | exit; |
---|
| 192 | } |
---|
| 193 | |
---|
[623] | 194 | /* |
---|
| 195 | * @function show_msg |
---|
| 196 | * @abstract Mostra a mensagem de e-mail requisitada |
---|
| 197 | * @author Mário César Kolling <mario.kolling@serpro.gov.br> |
---|
| 198 | */ |
---|
| 199 | // TODO: retirar msg_folder dos parâmentros necessários no GET e usar $this->current_folder |
---|
[3576] | 200 | function show_msg($params = array()) |
---|
[623] | 201 | { |
---|
| 202 | $msg = $this->imap_functions->get_info_msg($params); |
---|
| 203 | |
---|
[3602] | 204 | $msg_number = $params['msg_number']; |
---|
| 205 | $msg_folder = $params['msg_folder']; |
---|
| 206 | |
---|
[623] | 207 | // Carrega o template |
---|
[3576] | 208 | $this->template->set_file(array('view_msg' => 'view_msg.tpl')); |
---|
| 209 | $this->template->set_block('view_msg', 'page'); |
---|
[3602] | 210 | $this->template->set_block('view_msg', 'operation_block'); |
---|
[3697] | 211 | $this->template->set_block('view_msg', 'attachment_alert_block'); |
---|
[3576] | 212 | $this->template->set_var('lang_back', lang("back")); |
---|
[3829] | 213 | $this->template->set_var('href_back',$GLOBALS['phpgw_info']['mobiletemplate']->get_back_link()); |
---|
[4040] | 214 | $this->template->set_var('lang_reading_message', lang("Reading Message")); |
---|
| 215 | $this->template->set_var('lang_confirm_delete_message', lang("Do you like to delete this message?")); |
---|
[3697] | 216 | $this->template->set_var('theme', $GLOBALS['phpgw_info']['server']['template_set']); |
---|
[4040] | 217 | $this->template->set_var('msg_folder', $msg_folder); |
---|
| 218 | $this->template->set_var('msg_number', $msg_number); |
---|
[623] | 219 | |
---|
| 220 | // Define o cabeçalho do e-mail |
---|
[3576] | 221 | $this->template->set_var('lang_from', lang("From")); |
---|
[3571] | 222 | $this->template->set_var('from', $msg['from']['full']); |
---|
[3697] | 223 | $this->template->set_var('lang_to', lang("To")); |
---|
| 224 | $this->template->set_var('to', $msg['toaddress2']); |
---|
[3576] | 225 | $this->template->set_var('lang_cc', lang("cc")); |
---|
| 226 | $this->template->set_var('cc', $msg['cc']); |
---|
| 227 | $this->template->set_var('size', $this->common->borkb($msg['Size'])); |
---|
[623] | 228 | |
---|
[3576] | 229 | $this->template->set_var('lang_subject', lang("Subject")); |
---|
[3571] | 230 | $this->template->set_var('subject', $msg['subject']); |
---|
[3576] | 231 | $this->template->set_var('date', $msg['msg_day']." ".$msg['msg_hour']); |
---|
[623] | 232 | |
---|
| 233 | // Mostra o corpo do e-mail |
---|
[3571] | 234 | $this->template->set_var('body', strip_tags($msg['body'], $this->allowed_tags)); // Usa a função strip_tags() para filtrar |
---|
[3907] | 235 | |
---|
[3602] | 236 | $operations = array(); |
---|
[3907] | 237 | |
---|
[3602] | 238 | if($msg["Draft"] === "X") { |
---|
[4040] | 239 | $operations["edit_draft"]["link"] = "location.href='index.php?menuaction=mobile.ui_mobilemail.new_msg&msg_number=$msg_number&msg_folder=$msg_folder&type=use_draft'"; |
---|
[3602] | 240 | $operations["edit_draft"]["lang"] = lang("edit draft"); |
---|
| 241 | } else { |
---|
[4040] | 242 | $operations["mark_as_unread"]["link"] = "location.href='index.php?menuaction=mobile.ui_mobilemail.mark_message_with_flag&flag=unseen&msgs_to_set=$msg_number&msg_folder=$msg_folder'"; |
---|
[3602] | 243 | $operations["mark_as_unread"]["lang"] = lang("mark as unread"); |
---|
[4040] | 244 | $operations["forward"]["link"] = "location.href='index.php?menuaction=mobile.ui_mobilemail.new_msg&msg_number=$msg_number&msg_folder=$msg_folder&type=forward'"; |
---|
[3602] | 245 | $operations["forward"]["lang"] = lang("Forward"); |
---|
[4040] | 246 | $operations["reply"]["link"] = "location.href='index.php?menuaction=mobile.ui_mobilemail.new_msg&msg_number=$msg_number&msg_folder=$msg_folder&type=reply'"; |
---|
[3602] | 247 | $operations["reply"]["lang"] = lang("Reply"); |
---|
[4040] | 248 | $operations["reply_all"]["link"] = "location.href='index.php?menuaction=mobile.ui_mobilemail.new_msg&msg_number=$msg_number&msg_folder=$msg_folder&type=reply_all'"; |
---|
[3602] | 249 | $operations["reply_all"]["lang"] = lang("Reply to all"); |
---|
| 250 | } |
---|
[3907] | 251 | |
---|
[4040] | 252 | $operations["delete"]["link"] = "delete_msg()"; |
---|
[3907] | 253 | $operations["delete"]["lang"] = lang("Delete"); |
---|
| 254 | |
---|
[3602] | 255 | foreach($operations as $index=>$operation) { |
---|
| 256 | $this->template->set_var('operation_link', $operation["link"]); |
---|
| 257 | $this->template->set_var('operation_id', $index); |
---|
[3907] | 258 | $this->template->set_var('lang_operation', $operation["lang"]); |
---|
| 259 | $this->template->parse('operation_box','operation_block', true); |
---|
[3602] | 260 | } |
---|
[3907] | 261 | |
---|
[3289] | 262 | if (!empty($msg['attachments'])) |
---|
[623] | 263 | { |
---|
[691] | 264 | $attachs = "<br>".lang("This message has the follow attachments:")."<br>"; |
---|
| 265 | foreach($msg['attachments'] as $key => $attach) { |
---|
| 266 | if(is_array($attach)) { |
---|
[3501] | 267 | //$attachs.=$attach['name']." "; |
---|
| 268 | $attachs.="<a href='../expressoMail1_2/inc/gotodownload.php?msg_folder=".$msg_folder. |
---|
| 269 | "&msg_number=".$msg_number."&idx_file=".$key."&msg_part=".$attach['pid']. |
---|
| 270 | "&newfilename=".$attach['name']."&encoding=".$attach['encoding']."'>". |
---|
| 271 | lang('Download').": ".$attach['name']."</a><br>"; |
---|
[691] | 272 | } |
---|
| 273 | } |
---|
[3907] | 274 | |
---|
[3697] | 275 | $this->template->parse('attachment_alert_box','attachment_alert_block', true); |
---|
[3576] | 276 | $this->template->set_var('attachment_message', $attachs); |
---|
[623] | 277 | } |
---|
| 278 | else |
---|
| 279 | { |
---|
[3571] | 280 | $this->template->set_var('attachment_message', lang('This message don\'t have attachment(s)')); |
---|
[623] | 281 | } |
---|
| 282 | |
---|
[3576] | 283 | $GLOBALS['phpgw_info']['mobiletemplate']->set_error_msg($params["error_message"]); |
---|
| 284 | $GLOBALS['phpgw_info']['mobiletemplate']->set_content($this->template->fp('out', 'page')); |
---|
[623] | 285 | } |
---|
| 286 | |
---|
| 287 | /* |
---|
| 288 | * @function index |
---|
| 289 | * @abstract Página inicial da aplicação mobilemail, mantém o estado atual. Ou seja, mostra lista de e-mails |
---|
| 290 | * do folder e página definidos pelos parâmetros current_folder e current_page. |
---|
| 291 | * @author Mário César Kolling <mario.kolling@serpro.gov.br> |
---|
| 292 | */ |
---|
| 293 | // TODO: Talvez seja melhor voltar sempre para o Inbox e primeira página |
---|
[3589] | 294 | function index($params) |
---|
[1474] | 295 | { |
---|
[3589] | 296 | $GLOBALS['phpgw_info']['mobiletemplate']->set_error_msg($params["error_message"]); |
---|
| 297 | $GLOBALS['phpgw_info']['mobiletemplate']->set_success_msg($params["success_message"]); |
---|
[623] | 298 | $this->mail_list(); |
---|
| 299 | $this->save_session(); |
---|
| 300 | |
---|
| 301 | } |
---|
| 302 | |
---|
[1474] | 303 | function load_session(){ |
---|
[623] | 304 | /************************************\ |
---|
| 305 | * Inicialização do expressoMail1_2 * |
---|
| 306 | \************************************/ |
---|
| 307 | // Get Data from ldap_manager and emailadmin. |
---|
| 308 | $ldap_manager = CreateObject('contactcenter.bo_ldap_manager'); |
---|
| 309 | $boemailadmin = CreateObject('emailadmin.bo'); |
---|
| 310 | $emailadmin_profile = $boemailadmin->getProfileList(); |
---|
| 311 | $_SESSION['phpgw_info']['expressomail']['email_server'] = $boemailadmin->getProfile($emailadmin_profile[0]['profileID']); |
---|
| 312 | $_SESSION['phpgw_info']['expressomail']['user'] = $GLOBALS['phpgw_info']['user']; |
---|
| 313 | $_SESSION['phpgw_info']['expressomail']['server'] = $GLOBALS['phpgw_info']['server']; |
---|
| 314 | $_SESSION['phpgw_info']['expressomail']['ldap_server'] = $ldap_manager ? $ldap_manager->srcs[1] : null; |
---|
| 315 | $_SESSION['phpgw_info']['expressomail']['user']['email'] = $GLOBALS['phpgw']->preferences->values['email']; |
---|
| 316 | |
---|
| 317 | // Fix problem with cyrus delimiter changes in preferences. |
---|
| 318 | // Dots in names: enabled/disabled. |
---|
| 319 | $save_in_folder = @eregi_replace("INBOX/", "INBOX".$_SESSION['phpgw_info']['expressomail']['email_server']['imapDelimiter'], $_SESSION['phpgw_info']['user']['preferences']['expressoMail']['save_in_folder']); |
---|
| 320 | $save_in_folder = @eregi_replace("INBOX.", "INBOX".$_SESSION['phpgw_info']['expressomail']['email_server']['imapDelimiter'], $save_in_folder); |
---|
| 321 | $_SESSION['phpgw_info']['user']['preferences']['expressoMail']['save_in_folder'] = $save_in_folder; |
---|
| 322 | // End Fix. |
---|
| 323 | |
---|
| 324 | // Loading Admin Config Module |
---|
| 325 | $c = CreateObject('phpgwapi.config','expressoMail1_2'); |
---|
| 326 | $c->read_repository(); |
---|
| 327 | $current_config = $c->config_data; |
---|
| 328 | $_SESSION['phpgw_info']['server']['expressomail']['expressoMail_enable_log_messages'] = $current_config['expressoMail_enable_log_messages']; |
---|
| 329 | // Begin Set Anti-Spam options. |
---|
| 330 | $_SESSION['phpgw_info']['server']['expressomail']['expressoMail_command_for_ham'] = $current_config['expressoMail_command_for_ham']; |
---|
| 331 | $_SESSION['phpgw_info']['server']['expressomail']['expressoMail_command_for_spam'] = $current_config['expressoMail_command_for_spam']; |
---|
| 332 | $_SESSION['phpgw_info']['server']['expressomail']['expressoMail_use_spam_filter'] = $current_config['expressoMail_use_spam_filter']; |
---|
[3609] | 333 | $_SESSION['phpgw_info']['user']['preferences']['expressoMail']['max_attachment_size'] = $current_config['expressoMail_Max_attachment_size'] ? $current_config['expressoMail_Max_attachment_size']."M" : ini_get('upload_max_filesize'); |
---|
[691] | 334 | |
---|
[3576] | 335 | // echo '<script> var array_lang = new Array();var use_spam_filter = \''.$current_config['expressoMail_use_spam_filter'].'\' </script>'; |
---|
[691] | 336 | |
---|
[623] | 337 | // End Set Anti-Spam options. |
---|
| 338 | |
---|
| 339 | // Set Imap Folder names options |
---|
| 340 | $_SESSION['phpgw_info']['expressomail']['email_server']['imapDefaultTrashFolder'] = $_SESSION['phpgw_info']['expressomail']['email_server']['imapDefaultTrashFolder'] ? $_SESSION['phpgw_info']['expressomail']['email_server']['imapDefaultTrashFolder'] : "Trash"; |
---|
| 341 | $_SESSION['phpgw_info']['expressomail']['email_server']['imapDefaultDraftsFolder'] = $_SESSION['phpgw_info']['expressomail']['email_server']['imapDefaultDraftsFolder'] ? $_SESSION['phpgw_info']['expressomail']['email_server']['imapDefaultDraftsFolder'] : "Drafts"; |
---|
| 342 | $_SESSION['phpgw_info']['expressomail']['email_server']['imapDefaultSpamFolder'] = $_SESSION['phpgw_info']['expressomail']['email_server']['imapDefaultSpamFolder'] ? $_SESSION['phpgw_info']['expressomail']['email_server']['imapDefaultSpamFolder'] : "Spam"; |
---|
| 343 | $_SESSION['phpgw_info']['expressomail']['email_server']['imapDefaultSentFolder'] = $_SESSION['phpgw_info']['expressomail']['email_server']['imapDefaultSentFolder'] ? $_SESSION['phpgw_info']['expressomail']['email_server']['imapDefaultSentFolder'] : "Sent"; |
---|
[691] | 344 | |
---|
[3576] | 345 | // include("../expressoMail1_2/inc/load_lang.php"); |
---|
[623] | 346 | } |
---|
| 347 | |
---|
| 348 | /* |
---|
| 349 | * @function print_folder_selection |
---|
| 350 | * @abstract Imprime o folder corrente (INBOX) |
---|
| 351 | * @author Mário César Kolling <mario.kolling@serpro.gov.br> |
---|
| 352 | */ |
---|
| 353 | function print_folder_selection() |
---|
| 354 | { |
---|
[3571] | 355 | $this->template->set_file(array('mobilemail_t' => 'mobilemail.tpl')); |
---|
| 356 | $this->template->set_block('mobilemail_t', 'inbox_folder_list'); |
---|
| 357 | $this->template->set_var('lang_folder', lang('Folder')); |
---|
[1714] | 358 | $folder = str_replace("*","",lang($this->folders[$this->current_folder]['folder_name'])); |
---|
[1474] | 359 | if(!$this->current_folder == 0){ |
---|
[3571] | 360 | $this->template->set_var('lang_inbox', $folder.' :: <a title="'.lang('Inbox').'" href="index.php?menuaction=mobile.ui_mobilemail.mail_list&folder=0">'.lang('Inbox').'</a>'); |
---|
[1474] | 361 | }else{ |
---|
[3571] | 362 | $this->template->set_var('lang_inbox', lang('Inbox')); |
---|
[1474] | 363 | } |
---|
| 364 | |
---|
[3571] | 365 | //$this->template->set_var('folder_items', $folder_items); |
---|
| 366 | $this->template->parse('mobilemail_t', 'inbox_folder_list'); |
---|
| 367 | //$this->template->fpf('out', 'mobilemail_t'); |
---|
| 368 | $GLOBALS['phpgw_info']['mobiletemplate']->set_content($this->template->fp('out', 'mobilemail_t')); |
---|
[623] | 369 | } |
---|
| 370 | |
---|
| 371 | /* |
---|
| 372 | * @function old_print_folder_selection |
---|
| 373 | * @abstract Imprime na tela a caixa de seleção de folders |
---|
| 374 | * @author Mário César Kolling <mario.kolling@serpro.gov.br> |
---|
| 375 | */ |
---|
| 376 | function old_print_folder_selection() |
---|
| 377 | { |
---|
| 378 | // Processa as options |
---|
| 379 | $folder_items = ''; |
---|
| 380 | |
---|
| 381 | foreach ($this->folders as $i => $j) |
---|
| 382 | { |
---|
| 383 | |
---|
| 384 | $option_selected = ''; |
---|
[3571] | 385 | $this->template->set_file(array('mobilemail_t' => 'mobilemail.tpl')); |
---|
| 386 | $this->template->set_block('mobilemail_t', 'folder_item'); |
---|
[623] | 387 | |
---|
| 388 | if (is_numeric($i)) |
---|
| 389 | { |
---|
| 390 | if ($i == $this->current_folder) |
---|
| 391 | { |
---|
| 392 | $option_selected = 'selected="selected"'; |
---|
| 393 | } |
---|
| 394 | |
---|
[3571] | 395 | $this->template->set_var('option_selected', $option_selected); |
---|
| 396 | $this->template->set_var('folder_id', $j['folder_id']); |
---|
| 397 | $this->template->set_var('folder_name', $j['folder_id']); // Mudar... provavelmente usar preg_replace |
---|
[4002] | 398 | // para substituir cpf pelo nome do usuário. |
---|
[623] | 399 | if ($j['folder_unseen'] > 0) |
---|
[3571] | 400 | $this->template->set_var('folder_unseen', ' - ('.$j['folder_unseen'].')'); |
---|
[623] | 401 | |
---|
[3571] | 402 | $folder_items .= $this->template->fp('mobile_t', 'folder_item'); |
---|
[623] | 403 | } |
---|
| 404 | } |
---|
| 405 | |
---|
| 406 | // Processa o select |
---|
[3571] | 407 | $this->template->set_file(array('mobilemail_t' => 'mobilemail.tpl')); |
---|
| 408 | $this->template->set_block('mobilemail_t', 'folder_list'); |
---|
| 409 | $this->template->set_var('folder_items', $folder_items); |
---|
| 410 | $this->template->parse('mobilemail_t', 'folder_list'); |
---|
| 411 | //$this->template->pfp('out', 'mobilemail_t'); |
---|
| 412 | $GLOBALS['phpgw_info']['mobiletemplate']->set_content($this->template->fp('out', 'mobilemail_t')); |
---|
[623] | 413 | |
---|
| 414 | } |
---|
| 415 | |
---|
| 416 | /* |
---|
| 417 | * @function mail_list |
---|
| 418 | * @abstract Imprime a lista de e-mails |
---|
| 419 | * @author Mário César Kolling <mario.kolling@serpro.gov.br> |
---|
| 420 | */ |
---|
[3579] | 421 | function mail_list() |
---|
[1474] | 422 | { |
---|
[4051] | 423 | |
---|
[3609] | 424 | $p = $this->template; |
---|
[4002] | 425 | $p->set_file( array( 'mail_t' => 'mobilemail.tpl', 'home_search_bar' => 'search_bar.tpl' ) ); |
---|
[3641] | 426 | |
---|
| 427 | $p->set_block('home_search_bar','search_bar'); |
---|
| 428 | |
---|
[3579] | 429 | $p->set_var("page",$this->current_page+1); |
---|
[3589] | 430 | $p->set_var("lang_new_message",lang("new message")); |
---|
| 431 | $p->set_var("lang_new",strtoupper(lang("new"))); |
---|
| 432 | $p->set_var("folder_id",$this->folders[$this->current_folder]['folder_id']); |
---|
[4002] | 433 | //translate name of the default folders |
---|
| 434 | $translated_folder_name = $this->bo_mobilemail->get_translate_default_folder_name_from_id($this->folders[$this->current_folder]["folder_id"]); |
---|
| 435 | $p->set_var("folder", (($translated_folder_name == "") ? $this->folders[$this->current_folder]["folder_name"] : $translated_folder_name) ); |
---|
| 436 | |
---|
[3579] | 437 | $p->set_var("selected_".$this->current_search_box_type,"selected"); |
---|
| 438 | $p->set_var("lang_back",lang("back")); |
---|
[3829] | 439 | $p->set_var('href_back',$GLOBALS['phpgw_info']['mobiletemplate']->get_back_link()); |
---|
[3691] | 440 | $p->set_var("selecteds",ucfirst(lang("Selecteds"))); |
---|
| 441 | $p->set_var("filter_by",lang("filter by")); |
---|
[4051] | 442 | $p->set_var("refresh",lang("refresh")); |
---|
[3579] | 443 | $p->set_var("lang_new_message",lang("new message")); |
---|
[3641] | 444 | $p->set_var('lang_search',lang('search')); |
---|
[3579] | 445 | $p->set_var("lang_more",lang("more")); |
---|
| 446 | $p->set_var("lang_messages",lang("messages")); |
---|
| 447 | |
---|
[3731] | 448 | if($GLOBALS['phpgw']->session->appsession('mobile.layout','mobile')!="mini_desktop") |
---|
| 449 | $p->set_var('search',$p->fp('out','search_bar')); |
---|
| 450 | |
---|
[3579] | 451 | $max_per_page = |
---|
[691] | 452 | isset($GLOBALS['phpgw_info']['user']['preferences']['mobile']['max_message_per_page'])? |
---|
| 453 | $GLOBALS['phpgw_info']['user']['preferences']['mobile']['max_message_per_page']:10; |
---|
[3579] | 454 | |
---|
| 455 | $params = array( |
---|
| 456 | 'folder' => $this->folders[$this->current_folder]['folder_id'], |
---|
| 457 | 'msg_range_begin' => 1, |
---|
| 458 | 'msg_range_end' => $this->current_page * $max_per_page, |
---|
| 459 | 'search_box_type' => $this->current_search_box_type, |
---|
| 460 | 'sort_box_type' => 'SORTARRIVAL', |
---|
| 461 | 'sort_box_reverse' => 1 |
---|
| 462 | ); |
---|
[1709] | 463 | |
---|
[3579] | 464 | $messages = $this->imap_functions->get_range_msgs2($params); |
---|
[3589] | 465 | if($params['msg_range_end']<$messages[num_msgs]) |
---|
| 466 | $p->set_var("show_more","block"); |
---|
| 467 | else |
---|
| 468 | $p->set_var("show_more","none"); |
---|
[3579] | 469 | $this->number_of_messages = $messages[num_msgs]; |
---|
| 470 | |
---|
| 471 | unset($messages["offsetToGMT"]); |
---|
| 472 | unset($messages["tot_unseen"]); |
---|
| 473 | |
---|
| 474 | $p->set_var('mails',$this->print_mails_list($messages,true)); |
---|
| 475 | |
---|
| 476 | $GLOBALS['phpgw_info']['mobiletemplate']->set_content($p->fp('out','mail_t')); |
---|
| 477 | |
---|
[623] | 478 | |
---|
| 479 | } |
---|
| 480 | |
---|
| 481 | /* |
---|
| 482 | * @function print_mails_list |
---|
| 483 | * @abstract Imprime a lista de mensagens |
---|
| 484 | * @author Mário César Kolling <mario.kolling@serpro.gov.br> |
---|
| 485 | * @param array Um array com a lista de mensagens recuperado por $this->imap_functions->get_range_msgs2($params) |
---|
| 486 | */ |
---|
[3579] | 487 | function print_mails_list($messages,$print_checkbox=false) |
---|
[623] | 488 | { |
---|
[3573] | 489 | |
---|
[3609] | 490 | $functions = $this->common; |
---|
| 491 | $p = $this->template; |
---|
[3791] | 492 | $p->set_file( array( 'mobilemail_t' => 'mails_list.tpl' ) ); |
---|
[3573] | 493 | $p->set_block('mobilemail_t', 'rows_mails'); |
---|
| 494 | $p->set_block('mobilemail_t', 'row_mails'); |
---|
| 495 | $p->set_block('mobilemail_t', 'no_messages'); |
---|
[623] | 496 | |
---|
[3573] | 497 | if(count($messages)>1) { //O array de emails tem pelo menos uma posição com o total de mensagens. |
---|
[3691] | 498 | $bg = "bg-azul"; |
---|
[3573] | 499 | foreach($messages as $id => $message) { |
---|
| 500 | |
---|
[3923] | 501 | if(($id==='num_msgs') ||($id==='total_msgs') || ($id==='has_more_msg')) |
---|
[3573] | 502 | continue; |
---|
| 503 | if($message['from']['name']) |
---|
[3590] | 504 | $from_name = $message['from']['name']; |
---|
[3573] | 505 | else |
---|
[3590] | 506 | $from_name = $message['from']['email']; |
---|
[3691] | 507 | $bg = $bg=="bg-azul"?"bg-branco":"bg-azul"; |
---|
| 508 | $p->set_var('bg',"email-geral $bg"); |
---|
[3573] | 509 | |
---|
[3691] | 510 | $flag=""; |
---|
[3589] | 511 | |
---|
[3691] | 512 | if($message["Unseen"]==="U") |
---|
| 513 | $flag="email-nao-lido "; |
---|
| 514 | else |
---|
| 515 | $flag="email-lido "; |
---|
[3579] | 516 | |
---|
[3589] | 517 | if($message["Flagged"]==="F") |
---|
[3691] | 518 | $flag.="email-importante"; |
---|
[3579] | 519 | |
---|
[3589] | 520 | $p->set_var("flag",$flag); |
---|
[3579] | 521 | if($print_checkbox) |
---|
| 522 | $p->set_var('show_check','inline'); |
---|
| 523 | else |
---|
| 524 | $p->set_var('show_check','none'); |
---|
| 525 | |
---|
[3691] | 526 | if($print_checkbox) |
---|
| 527 | $p->set_var("details","email-corpo"); |
---|
| 528 | else |
---|
| 529 | $p->set_var("details","limpar_div margin-geral"); |
---|
| 530 | |
---|
[3579] | 531 | $p->set_var('pre_type',$pre); |
---|
| 532 | $p->set_var('pos_type',$pos); |
---|
[3573] | 533 | $p->set_var('from',$from_name); |
---|
[3691] | 534 | $p->set_var('url_images','templates/'.$GLOBALS['phpgw_info']['server']['template_set'].'/images'); |
---|
[3589] | 535 | $p->set_var('msg_number',$message["msg_number"]); |
---|
[3573] | 536 | $p->set_var('mail_time',$message['smalldate']); |
---|
[3651] | 537 | $p->set_var('mail_from',$message['from']['email']); |
---|
[3691] | 538 | $p->set_var('subject',$message['subject']?$message['subject']:"(".lang("no subject").")"); |
---|
[3573] | 539 | $p->set_var('size',$functions->borkb($message['Size'])); |
---|
[3695] | 540 | $p->set_var('lang_attachment',lang('attachment')); |
---|
[3573] | 541 | $p->set_var('msg_number', $message['msg_number']); |
---|
[3791] | 542 | $p->set_var('msg_folder', isset($message['msg_folder']) ? $message['msg_folder'] : $this->folders[$this->current_folder]['folder_id']); |
---|
| 543 | $p->set_var('show_attach', ($message['attachment']['number_attachments']>0) ? '' : 'none'); |
---|
[3573] | 544 | $p->fp('rows','row_mails',True); |
---|
[623] | 545 | } |
---|
| 546 | } |
---|
[3573] | 547 | else { |
---|
| 548 | $p->set_var("lang_no_results",lang("no results found")); |
---|
| 549 | $p->parse("rows","no_messages"); |
---|
[623] | 550 | } |
---|
[3573] | 551 | return $p->fp('out','rows_mails'); |
---|
[3579] | 552 | |
---|
[623] | 553 | } |
---|
| 554 | |
---|
| 555 | /* |
---|
| 556 | * @funtion print_page_navigation |
---|
| 557 | * @abstract Imprime a barra de navegação da lista de e-mails da pasta corrente. Quem chama essa função é quem faz o controle do modelo. |
---|
| 558 | * @author Mário César Kolling <mario.kolling@serpro.gov.br> |
---|
| 559 | * @param integer Número de páginas que serão geradas |
---|
| 560 | * @param integer Página corrente |
---|
| 561 | */ |
---|
| 562 | // TODO: mover este método para a classe page_navigation subclasse de widget |
---|
| 563 | function print_page_navigation($number_of_pages, $page = 1) |
---|
| 564 | { |
---|
| 565 | |
---|
| 566 | $pages = ''; |
---|
| 567 | |
---|
| 568 | if ($number_of_pages != 0) |
---|
| 569 | { |
---|
| 570 | // Geração das páginas |
---|
| 571 | for ($i = 1; $i <= $number_of_pages ; $i++) |
---|
| 572 | { |
---|
| 573 | |
---|
[3571] | 574 | $p = CreateObject('phpgwapi.Template', PHPGW_SERVER_ROOT . '/mobile/templates/'.$GLOBALS['phpgw_info']['server']['template_set']); |
---|
| 575 | $p->set_file(array('mobilemail_t' => 'mobilemail.tpl')); |
---|
[623] | 576 | $p->set_block('mobilemail_t', 'space'); |
---|
| 577 | $p->set_block('mobilemail_t', 'begin_anchor'); |
---|
| 578 | $p->set_block('mobilemail_t', 'end_anchor'); |
---|
| 579 | $p->set_block('mobilemail_t', 'page_item'); |
---|
| 580 | $p->set_block('mobilemail_t', 'begin_strong'); |
---|
| 581 | $p->set_block('mobilemail_t', 'end_strong'); |
---|
| 582 | |
---|
| 583 | if ($i == $page) |
---|
| 584 | { |
---|
| 585 | // Se for a página sendo gerada for a página corrente, |
---|
| 586 | // não gera a âncora e destaca o número (negrito) |
---|
| 587 | $p->set_var('end_anchor', ''); |
---|
| 588 | $p->set_var('begin_anchor', ''); |
---|
| 589 | $p->set_var('begin_strong', trim($p->fp('mobilemail_t', 'begin_strong'))); |
---|
| 590 | $p->set_var('end_strong', trim($p->fp('mobilemail_t', 'end_strong'))); |
---|
| 591 | } |
---|
| 592 | else |
---|
| 593 | { |
---|
| 594 | // Senão, gera a âncora |
---|
| 595 | $p->set_var('begin_strong', ''); |
---|
| 596 | $p->set_var('end_strong', ''); |
---|
| 597 | $p->set_var('end_anchor', trim($p->fp('mobilemail_t', 'end_anchor'))); |
---|
[3346] | 598 | $p->set_var('begin_anchor_href', "index.php?menuaction=mobile.ui_mobilemail.change_page&folder=$this->current_folder&page=$i"); |
---|
[623] | 599 | $p->set_var('begin_anchor', trim($p->fp('mobilemail_t', 'begin_anchor'))); |
---|
| 600 | } |
---|
| 601 | |
---|
| 602 | $p->set_var('page', $i); |
---|
| 603 | //$pages .= trim($p->fp('mobilemail_t', 'page_item')); |
---|
| 604 | |
---|
| 605 | } |
---|
| 606 | $pages .= " ".$page." ".lang("of")." ".$number_of_pages." "; |
---|
| 607 | |
---|
| 608 | // Geração dos links "anterior" e "próximo" |
---|
| 609 | $p = CreateObject('phpgwapi.Template', PHPGW_SERVER_ROOT . '/mobile/templates/'.$GLOBALS['phpgw_info']['server']['template_set']); |
---|
[3571] | 610 | $p->set_file(array('mobilemail_t' => 'mobilemail.tpl')); |
---|
[623] | 611 | |
---|
| 612 | //$p->set_block('mobilemail_t', 'space'); |
---|
| 613 | $p->set_block('mobilemail_t', 'mail_footer'); |
---|
| 614 | $p->set_block('mobilemail_t', 'previous'); |
---|
| 615 | $p->set_block('mobilemail_t', 'next'); |
---|
| 616 | |
---|
| 617 | $next_page = $page + 1; |
---|
| 618 | $previous_page = $page - 1; |
---|
| 619 | |
---|
| 620 | if ($page == 1) |
---|
| 621 | { |
---|
| 622 | // Se for a primeira página, não imprime o link "anterior"" |
---|
| 623 | $p->set_var('previous', ''); |
---|
| 624 | if ($page == $number_of_pages) |
---|
| 625 | { |
---|
| 626 | // Se só existir uma página, não imprime o link "próximo" |
---|
| 627 | $p->set_var('next', ''); |
---|
| 628 | } |
---|
| 629 | else |
---|
| 630 | { |
---|
[3346] | 631 | $p->set_var('next_href', "index.php?menuaction=mobile.ui_mobilemail.change_page&folder=$this->current_folder&page=$next_page"); |
---|
[623] | 632 | $p->set_var('next', trim($p->fp('mobilemail_t', 'next'))); |
---|
| 633 | } |
---|
| 634 | |
---|
| 635 | } |
---|
| 636 | else if ($page == $number_of_pages) |
---|
| 637 | { |
---|
| 638 | // Se for a última página, não imprime o link "próximo" |
---|
| 639 | $p->set_var('next', ''); |
---|
[3346] | 640 | $p->set_var('previous_href', "index.php?menuaction=mobile.ui_mobilemail.change_page&folder=$this->current_folder&page=$previous_page"); |
---|
[623] | 641 | $p->set_var('previous', trim($p->fp('mobilemail_t', 'previous'))); |
---|
| 642 | } |
---|
| 643 | else |
---|
| 644 | { |
---|
| 645 | // Senão, imprime os links "anterior" e "próximo" |
---|
[3346] | 646 | $p->set_var('previous_href', "index.php?menuaction=mobile.ui_mobilemail.change_page&folder=$this->current_folder&page=$previous_page"); |
---|
[623] | 647 | $p->set_var('previous', trim($p->fp('mobilemail_t', 'previous'))); |
---|
| 648 | |
---|
[3346] | 649 | $p->set_var('next_href', "index.php?menuaction=mobile.ui_mobilemail.change_page&folder=$this->current_folder&page=$next_page"); |
---|
[623] | 650 | $p->set_var('next', trim($p->fp('mobilemail_t', 'next'))); |
---|
| 651 | } |
---|
| 652 | |
---|
| 653 | $p->set_var('pages', $pages); |
---|
| 654 | //$p->pfp('out', 'mail_footer'); |
---|
| 655 | $GLOBALS['phpgw_info']['mobiletemplate']->set_content($p->fp('out', 'mail_footer')); |
---|
| 656 | } |
---|
| 657 | |
---|
| 658 | } |
---|
| 659 | |
---|
[3571] | 660 | function define_action_message($type) { |
---|
| 661 | switch($type) { |
---|
| 662 | case "clk": |
---|
[3600] | 663 | case "from_mobilecc": |
---|
[3602] | 664 | case "use_draft": |
---|
[3571] | 665 | $this->template->set_var('action_msg', lang("New message")); |
---|
| 666 | break; |
---|
| 667 | case "reply_all": |
---|
[3600] | 668 | $this->template->set_var('action_msg', lang("Reply to All")); |
---|
[3571] | 669 | break; |
---|
| 670 | case "forward": |
---|
| 671 | $this->template->set_var('action_msg', lang("Forward")); |
---|
| 672 | break; |
---|
| 673 | } |
---|
[623] | 674 | } |
---|
[3571] | 675 | |
---|
[623] | 676 | /* |
---|
| 677 | * @function new_msg() |
---|
| 678 | * @abstract Gera o formulário para criar/enviar novo e-mail ou resposta de e-mail. |
---|
| 679 | * @author Rommel de Brito Cysne <rommel.cysne@serpro.gov.br> |
---|
| 680 | */ |
---|
[3571] | 681 | function new_msg($params) |
---|
[623] | 682 | { |
---|
[3571] | 683 | $this->template->set_file(array('new_msg_t' => 'new_msg.tpl')); |
---|
| 684 | $this->template->set_block('new_msg_t', 'page'); |
---|
| 685 | $this->template->set_var('lang_back', lang("back")); |
---|
[3829] | 686 | $this->template->set_var('href_back',$GLOBALS['phpgw_info']['mobiletemplate']->get_back_link()); |
---|
[3571] | 687 | $this->template->set_var('lang_calendar', strtoupper(lang("Calendar"))); |
---|
| 688 | $this->template->set_var('lang_send', strtoupper(lang("Send"))); |
---|
[3695] | 689 | $this->template->set_var('lang_attachment', lang("attachment")); |
---|
| 690 | $this->template->set_var('lang_more_attachment', lang("more attachment")); |
---|
[3571] | 691 | $this->template->set_var('lang_cancel', strtoupper(lang("cancel"))); |
---|
| 692 | $this->template->set_var('lang_save_draft', strtoupper(lang("save draft"))); |
---|
| 693 | $this->template->set_var('lang_to', lang("To")); |
---|
| 694 | $this->template->set_var('lang_cc', lang("cc")); |
---|
| 695 | $this->template->set_var('lang_subject', lang("Subject")); |
---|
| 696 | $this->template->set_var('lang_mark_as_important', lang("mark as important")); |
---|
| 697 | $this->template->set_var('lang_read_confirmation', lang("read confirmation")); |
---|
| 698 | $this->template->set_var('lang_add_history', lang("add history")); |
---|
[3609] | 699 | $this->template->set_var("show_forward_attachment","none"); |
---|
[3935] | 700 | $this->template->set_var("show_check_add_history","none"); |
---|
[3571] | 701 | |
---|
| 702 | if(isset($params["error_message"])) { |
---|
[3600] | 703 | $this->template->set_var('input_to', $_POST['input_to']); |
---|
| 704 | $this->template->set_var('input_cc', $_POST['input_cc']); |
---|
[3571] | 705 | $this->template->set_var('subject', $_POST['input_subject']); |
---|
| 706 | $this->template->set_var('msg_number', $_POST['msg_number']); |
---|
| 707 | $this->template->set_var('msg_folder', $_POST['msg_folder']); |
---|
| 708 | $this->template->set_var('body_value', $_POST['body']); |
---|
| 709 | $this->template->set_var('msg_folder', $_POST['folder']); |
---|
| 710 | $this->template->set_var('msg_number', $_POST['reply_msg_number']); |
---|
| 711 | $this->template->set_var('from', $_POST['reply_from']); |
---|
| 712 | $this->template->set_var('check_important', ( ( $_POST['check_important'] ) ? "checked" : "" ) ); |
---|
| 713 | $this->template->set_var('check_read_confirmation', ( ( $_POST['check_read_confirmation'] ) ? "checked" : "" ) ); |
---|
[3935] | 714 | $this->template->set_var('check_add_history', ( ( $_POST['check_add_history'] ) ? "checked" : "" ) ); |
---|
[1474] | 715 | |
---|
[3571] | 716 | $GLOBALS['phpgw_info']['mobiletemplate']->set_error_msg($params["error_message"]); |
---|
| 717 | } else { |
---|
[3602] | 718 | if (isset($params['msg_number'])) $msg = $this->imap_functions->get_info_msg(array('msg_number' => $params['msg_number'], 'msg_folder' => $params['msg_folder'] ) ); |
---|
[3571] | 719 | |
---|
[3609] | 720 | |
---|
[3600] | 721 | if($params['type']=="clk") |
---|
[3571] | 722 | { |
---|
[3600] | 723 | $this->template->set_var('input_to', ""); |
---|
| 724 | $this->template->set_var('input_cc', ""); |
---|
[3571] | 725 | $this->template->set_var('subject', ""); |
---|
[1474] | 726 | } |
---|
[3600] | 727 | else if($params['type']=="from_mobilecc") |
---|
[3571] | 728 | { |
---|
[3600] | 729 | $this->template->set_var('input_to', $_GET['input_to']); |
---|
| 730 | $this->template->set_var('input_cc', $_GET['input_cc']); |
---|
[3571] | 731 | } |
---|
[3600] | 732 | else if($params['type']=="reply_all"){ |
---|
| 733 | $reply_to_all = $msg['from']['email']; |
---|
| 734 | if($msg['toaddress2']) $reply_to_all .= ','.$msg['toaddress2']; |
---|
| 735 | if($msg['cc']) $reply_to_all .= ','.$msg['cc']; |
---|
[3935] | 736 | if($msg['bcc']) $reply_to_all .= ','.$msg['bcc']; |
---|
[3571] | 737 | |
---|
| 738 | $array_emails = explode(',',$reply_to_all); |
---|
[3600] | 739 | $reply_to_all = ''; |
---|
[3571] | 740 | |
---|
[3600] | 741 | foreach ($array_emails as $index => $email) { |
---|
[3571] | 742 | $flag = preg_match('/<(.*?)>/',$email,$reply); |
---|
[3600] | 743 | $email_to_add = $flag == 0 ? $email.',' : $reply[1].','; |
---|
| 744 | |
---|
| 745 | if( strpos($reply_to_all, $email_to_add) === false) |
---|
| 746 | $reply_to_all .= $email_to_add; |
---|
[3571] | 747 | } |
---|
[3600] | 748 | |
---|
| 749 | $reply_to_all = substr_replace($reply_to_all, "", strrpos($reply_to_all, ","), strlen($reply_to_all)); |
---|
| 750 | |
---|
| 751 | $this->template->set_var('input_to', $reply_to_all); |
---|
[3571] | 752 | $this->template->set_var('subject', "Re:" . $msg['subject']); |
---|
| 753 | |
---|
| 754 | $this->template->set_var('msg_number', $_GET['msg_number']); |
---|
| 755 | $this->template->set_var('msg_folder', $_GET['msg_folder']); |
---|
| 756 | } |
---|
[3600] | 757 | else if($params['type']=="user_add"){ |
---|
| 758 | $this->template->set_var('input_to', $params['mobile_add_contact']['mobile_mail']); |
---|
[3935] | 759 | $this->template->set_var('input_cc', $params['mobile_add_contact']['mobile_mail_cc']); |
---|
[3600] | 760 | $this->template->set_var('subject', $params['mobile_add_contact']['subject_mail']); |
---|
| 761 | $this->template->set_var('body_value', $params['mobile_add_contact']['body_mail']); |
---|
[3571] | 762 | |
---|
[3600] | 763 | $this->template->set_var('check_important', ( ( $params['mobile_add_contact']['check_important'] ) ? "checked" : "" ) ); |
---|
| 764 | $this->template->set_var('check_read_confirmation', ( ( $params['mobile_add_contact']['check_read_confirmation'] ) ? "checked" : "" ) ); |
---|
| 765 | $this->template->set_var('check_add_history', ( ( $params['mobile_add_contact']['check_add_history'] ) ? "checked" : "" ) ); |
---|
| 766 | $this->template->set_var('msg_number', $params['msg_number']); |
---|
| 767 | $this->template->set_var('msg_folder', $params['msg_folder']); |
---|
| 768 | |
---|
[3935] | 769 | $params["type"] = $params['mobile_add_contact']['type']; |
---|
[3571] | 770 | } |
---|
[3600] | 771 | else if($params['type']=="forward"){ |
---|
[3571] | 772 | $this->template->set_var('from', $msg['toaddress2']); |
---|
| 773 | |
---|
| 774 | $this->template->set_var('subject', "Enc:" . $msg['subject']); |
---|
| 775 | $this->template->set_var('body_value', strip_tags($msg['body'])); // Usa a função strip_tags() para filtrar |
---|
| 776 | // as tags que estão presentes no corpo do e-mail. |
---|
| 777 | |
---|
| 778 | $this->template->set_var('msg_number', $_GET['msg_number']); |
---|
[3609] | 779 | $this->template->set_var('msg_folder', $_GET['msg_folder']); |
---|
| 780 | if(count($msg['attachments'])>0) { |
---|
| 781 | $this->template->set_var("lang_forward_attachment",lang("forward attachments")); |
---|
| 782 | $this->template->set_var("show_forward_attachment","block"); |
---|
| 783 | $this->template->set_block("new_msg_t","forward_attach_block"); |
---|
| 784 | foreach($msg['attachments'] as $forward_attach) { |
---|
| 785 | $value = rawurlencode(serialize(array(0=>$msg['msg_folder'], |
---|
| 786 | 1=>$msg['msg_number'], |
---|
| 787 | 3=>$forward_attach['pid'], |
---|
| 788 | 2=>$forward_attach['name'], |
---|
| 789 | 4=>$forward_attach['encoding']))); |
---|
| 790 | $this->template->set_var("value_forward_attach",$value); |
---|
| 791 | $this->template->set_var("label_forward_attach",$forward_attach['name']); |
---|
| 792 | $this->template->fp("forwarding_attachments","forward_attach_block",true); |
---|
| 793 | } |
---|
| 794 | } |
---|
[3571] | 795 | } |
---|
[3602] | 796 | else if($params['type']=="use_draft"){ |
---|
| 797 | $this->template->set_var('input_to', $msg['toaddress2']); |
---|
| 798 | $this->template->set_var('input_cc', $msg['cc']); |
---|
| 799 | $this->template->set_var('subject', $msg['subject']); |
---|
| 800 | $this->template->set_var('body_value', strip_tags($msg['body'])); // Usa a função strip_tags() para filtrar |
---|
| 801 | $this->template->set_var('msg_number', $_GET['msg_number']); |
---|
[3609] | 802 | $this->template->set_var('msg_folder', $_GET['msg_folder']); |
---|
[3602] | 803 | } |
---|
[3935] | 804 | else if($params['type']=="reply"){ |
---|
[3571] | 805 | $this->template->set_var('from', $msg['toaddress2']); |
---|
[3600] | 806 | $this->template->set_var('input_to', $msg['from']['email']); |
---|
[3571] | 807 | |
---|
| 808 | $this->template->set_var('subject', "Re:" . $msg['subject']); |
---|
| 809 | |
---|
| 810 | $this->template->set_var('msg_number', $_GET['msg_number']); |
---|
| 811 | $this->template->set_var('msg_folder', $_GET['msg_folder']); |
---|
[3935] | 812 | } else { |
---|
| 813 | $this->template->set_var('input_to', ""); |
---|
| 814 | $this->template->set_var('input_cc', ""); |
---|
| 815 | $this->template->set_var('subject', ""); |
---|
| 816 | } |
---|
[1474] | 817 | } |
---|
| 818 | |
---|
[3935] | 819 | if($params['type']=="reply" || $params['type']=="forward" || $params['type']=="reply_all" ) |
---|
| 820 | $this->template->set_var("show_check_add_history","block"); |
---|
| 821 | |
---|
[3600] | 822 | //tem que ser realizado no final, pois o tipo user_add é modificado para o tipo que o originou |
---|
| 823 | $this->template->set_var('type', $params['type']); |
---|
| 824 | $this->define_action_message($params['type']); |
---|
[3571] | 825 | |
---|
[3600] | 826 | unset($_SESSION['mobile_add_contact']); |
---|
[3571] | 827 | $GLOBALS['phpgw_info']['mobiletemplate']->set_content($this->template->fp('out', 'page')); |
---|
[623] | 828 | } |
---|
| 829 | |
---|
[3571] | 830 | /* |
---|
| 831 | * @function save_draft() |
---|
| 832 | * @abstract Função que salva o email como rascunho |
---|
| 833 | * @author Thiago Antonius |
---|
| 834 | */ |
---|
| 835 | function save_draft($params) |
---|
| 836 | { |
---|
| 837 | $params["folder"] = "INBOX/".$_SESSION['phpgw_info']['expressomail']['email_server']['imapDefaultDraftsFolder']; |
---|
[3609] | 838 | $params["FILES"] = $_FILES["FILES"]; |
---|
| 839 | $this->common->fixFilesArray($params["FILES"]); |
---|
| 840 | $params['forwarding_attachments'] = $params["forward_attachments"]; |
---|
[3571] | 841 | $return = $this->imap_functions->save_msg($params); |
---|
| 842 | if($return["has_error"]) { |
---|
| 843 | $params["error_message"] = lang("draft not save")."<br>".lang("error") . $return["append"]; |
---|
| 844 | $this->new_msg( $params ); |
---|
| 845 | }else { |
---|
[4046] | 846 | header('Location: index.php?menuaction=menuaction=mobile.ui_home.index&success_message='.lang("draft saved").'&ignore_trace_url=true'); |
---|
[4040] | 847 | } |
---|
[3571] | 848 | } |
---|
| 849 | |
---|
[623] | 850 | /* |
---|
| 851 | * @function send_mail() |
---|
| 852 | * @abstract Função que realiza o envio de e-mails. |
---|
| 853 | * @author Rommel de Brito Cysne <rommel.cysne@serpro.gov.br> |
---|
| 854 | */ |
---|
| 855 | function send_mail() |
---|
| 856 | { |
---|
| 857 | //Chamada da classe phpmailer |
---|
[1848] | 858 | include_once(PHPGW_SERVER_ROOT."/expressoMail1_2/inc/class.phpmailer.php"); |
---|
[3609] | 859 | include_once(PHPGW_SERVER_ROOT."/expressoMail1_2/inc/class.imap_functions.inc.php"); |
---|
| 860 | |
---|
[623] | 861 | //Recebe os dados do form (passados pelo POST) |
---|
[3602] | 862 | $toaddress = $_POST['input_to']; |
---|
| 863 | $ccaddress = $_POST['input_cc']; |
---|
[623] | 864 | $subject = $_POST['input_subject']; //"Mail Subject"; |
---|
[3609] | 865 | $body = nl2br($_POST['body']); //"Mail body. Any text."; |
---|
[3571] | 866 | $isImportant = $_POST['check_important']; |
---|
| 867 | $addHistory = $_POST['check_add_history']; |
---|
| 868 | $readConfirmation = $_POST['check_read_confirmation']; |
---|
| 869 | $msgNumber = $_POST['reply_msg_number']; |
---|
[3609] | 870 | $attachments = $_FILES['FILES']; |
---|
| 871 | $this->common->fixFilesArray($attachments); |
---|
| 872 | $forwarding_attachments = $_POST["forward_attachments"]; |
---|
| 873 | |
---|
[623] | 874 | |
---|
| 875 | //Cria objeto |
---|
| 876 | $mail = new PHPMailer(); |
---|
[3602] | 877 | |
---|
| 878 | $db_functions = CreateObject('expressoMail1_2.db_functions'); |
---|
| 879 | |
---|
| 880 | //chama o getAddrs para carregar os emails caso seja um grupo |
---|
| 881 | $toaddress = implode(',',$db_functions->getAddrs(explode(',',$toaddress))); |
---|
| 882 | $ccaddress = implode(',',$db_functions->getAddrs(explode(',',$ccaddress))); |
---|
| 883 | |
---|
| 884 | if(!$this->imap_functions->add_recipients("to", $toaddress, &$mail)) |
---|
[623] | 885 | { |
---|
| 886 | $error_msg = lang("Some addresses in the To field were not recognized. Please make sure that all addresses are properly formed"); |
---|
| 887 | } |
---|
[3571] | 888 | |
---|
[3602] | 889 | if(!$this->imap_functions->add_recipients("cc", $ccaddress, &$mail)) |
---|
[3571] | 890 | { |
---|
| 891 | $error_msg = lang("Some addresses in the CC field were not recognized. Please make sure that all addresses are properly formed"); |
---|
[3814] | 892 | } |
---|
[623] | 893 | |
---|
| 894 | $mail->IsSMTP(); |
---|
| 895 | $mail->Host = $_SESSION['phpgw_info']['expressomail']['email_server']['smtpServer']; |
---|
| 896 | $mail->Port = $_SESSION['phpgw_info']['expressomail']['email_server']['smtpPort']; |
---|
| 897 | |
---|
[1848] | 898 | $mail->SaveMessageInFolder = $_SESSION['phpgw_info']['user']['preferences']['expressoMail']['save_in_folder']; |
---|
[623] | 899 | //Envia os emails em formato HTML; se false -> desativa. |
---|
| 900 | $mail->IsHTML(true); |
---|
| 901 | //Email do remetente da mensagem |
---|
| 902 | $mail->Sender = $mail->From = $_SESSION['phpgw_info']['expressomail']['user']['email']; |
---|
| 903 | //Nome do remetente do email |
---|
| 904 | $mail->SenderName = $mail->FromName = $_SESSION['phpgw_info']['expressomail']['user']['fullname']; |
---|
| 905 | //Assunto da mensagem |
---|
| 906 | $mail->Subject = $subject; |
---|
| 907 | //Corpo da mensagem |
---|
| 908 | $mail->Body .= "<br />$body<br />"; |
---|
[3571] | 909 | //Important message |
---|
| 910 | if($isImportant) $mail->isImportant(); |
---|
| 911 | //add history |
---|
| 912 | if($addHistory && $msgNumber) { |
---|
| 913 | $msg = $this->imap_functions->get_info_msg(array('msg_number' => $msgNumber ) ); |
---|
[3814] | 914 | $mail->Body .= "<br />".$msg['body']."<br />"; |
---|
[3571] | 915 | } |
---|
| 916 | //read confirmation |
---|
| 917 | if ($readConfirmation) $mail->ConfirmReadingTo = $_SESSION['phpgw_info']['expressomail']['user']['email']; |
---|
[623] | 918 | |
---|
[3609] | 919 | $imap_functions = new imap_functions(); |
---|
| 920 | if (count($attachments)>0) //Attachment |
---|
| 921 | { |
---|
| 922 | |
---|
| 923 | $total_uploaded_size = 0; |
---|
| 924 | $upload_max_filesize = str_replace("M","",$_SESSION['phpgw_info']['user']['preferences']['expressoMail']['max_attachment_size']) * 1024 * 1024; |
---|
| 925 | |
---|
| 926 | foreach ($attachments as $attach) |
---|
| 927 | { |
---|
| 928 | $mail->AddAttachment($attach['tmp_name'], $attach['name'], "base64", $imap_functions->get_file_type($attach['name'])); // optional name |
---|
| 929 | $total_uploaded_size = $total_uploaded_size + $attach['size']; |
---|
| 930 | } |
---|
| 931 | if( $total_uploaded_size > $upload_max_filesize){ |
---|
| 932 | |
---|
| 933 | return $imap_functions->parse_error("message file too big"); |
---|
| 934 | } |
---|
| 935 | } |
---|
| 936 | if (count($forwarding_attachments) > 0) { //forward attachment |
---|
| 937 | foreach($forwarding_attachments as $forwarding_attachment) |
---|
| 938 | { |
---|
| 939 | $file_description = unserialize(rawurldecode($forwarding_attachment)); |
---|
| 940 | $fileContent = $imap_functions->get_forwarding_attachment( |
---|
[3814] | 941 | $file_description[0], |
---|
| 942 | $file_description[1], |
---|
| 943 | $file_description[3], |
---|
| 944 | $file_description[4]); |
---|
[3609] | 945 | $fileName = $file_description[2]; |
---|
| 946 | $mail->AddStringAttachment($fileContent,html_entity_decode(rawurldecode($fileName)), $file_description[4], $imap_functions->get_file_type($file_description[2])); |
---|
| 947 | } |
---|
| 948 | } |
---|
[3814] | 949 | |
---|
[3571] | 950 | if(!$mail->Send()) { |
---|
| 951 | $params["error_message"] = lang("Message not sent")."<br>".lang("error") . $mail->ErrorInfo; |
---|
| 952 | $this->new_msg( $params ); |
---|
[623] | 953 | }else { |
---|
[3814] | 954 | if($GLOBALS['phpgw']->session->appsession('mobile.layout','mobile')=="mini_desktop") { |
---|
[4046] | 955 | header('Location: index.php?menuaction=mobile.ui_mobilemail.index&success_message='.lang("Message sent successfully").'&ignore_trace_url=true'); |
---|
[3814] | 956 | } else { |
---|
[4046] | 957 | header('Location: index.php?menuaction=mobile.ui_home.index&success_message='.lang("Message sent successfully").'&ignore_trace_url=true'); |
---|
[3814] | 958 | } |
---|
[623] | 959 | } |
---|
| 960 | } |
---|
| 961 | |
---|
[3579] | 962 | function delete_msg($params) |
---|
[623] | 963 | { |
---|
[3589] | 964 | |
---|
[3656] | 965 | if ( isset($params['msgs']) || isset($params['msg_number']) ) |
---|
[1453] | 966 | { |
---|
[3589] | 967 | $params_messages = array( |
---|
[3656] | 968 | 'msgs_number' => isset($params['msgs'])?implode(",",$params['msgs']):$params['msg_number'], |
---|
[3589] | 969 | 'folder' => $this->folders[$this->current_folder]['folder_name'], |
---|
[1453] | 970 | 'new_folder_name' => 'Trash', |
---|
| 971 | 'new_folder' => 'INBOX/Trash' |
---|
| 972 | ); |
---|
| 973 | } |
---|
[623] | 974 | |
---|
[3656] | 975 | if (isset($params['msg_number'])){ |
---|
| 976 | |
---|
| 977 | $this->imap_functions->move_messages($params_messages); |
---|
| 978 | |
---|
[4046] | 979 | header("Location: index.php?menuaction=mobile.ui_mobilemail.index&success_message=".lang("The messages were moved to trash").'&ignore_trace_url=true'); |
---|
[3656] | 980 | |
---|
| 981 | }else{ |
---|
| 982 | header("Location: index.php?menuaction=mobile.ui_mobilemail.index&error_message=".lang("please select one e-mail")); |
---|
| 983 | } |
---|
[1453] | 984 | |
---|
[623] | 985 | } |
---|
[1474] | 986 | |
---|
| 987 | function get_folder_number($folder_name){ |
---|
[1848] | 988 | foreach($this->folders as $folderNumber => $folder){ |
---|
[1474] | 989 | if($folder['folder_id'] == $folder_name){ |
---|
[1848] | 990 | return $folderNumber; |
---|
[1474] | 991 | } |
---|
| 992 | } |
---|
| 993 | return 0; |
---|
| 994 | } |
---|
| 995 | |
---|
| 996 | function init_schedule() { |
---|
[3600] | 997 | $_SESSION['mobile_add_contact'] = array(); |
---|
| 998 | $_SESSION['mobile_add_contact']['mobile_mail'] = $_POST['input_to']; |
---|
| 999 | $_SESSION['mobile_add_contact']['mobile_mail_cc'] = $_POST['input_cc']; |
---|
| 1000 | $_SESSION['mobile_add_contact']['add_to'] = $_POST['add_to']; |
---|
| 1001 | $_SESSION['mobile_add_contact']['type'] = $_POST['type']; |
---|
| 1002 | $_SESSION['mobile_add_contact']['msg_number'] = $_POST['reply_msg_number']; |
---|
| 1003 | $_SESSION['mobile_add_contact']['msg_folder'] = $_POST['folder']; |
---|
| 1004 | $_SESSION['mobile_add_contact']['subject_mail'] = $_POST['input_subject']; |
---|
| 1005 | $_SESSION['mobile_add_contact']['body_mail'] = $_POST['body']; |
---|
| 1006 | $_SESSION['mobile_add_contact']['check_important'] = $_POST['check_important']; |
---|
| 1007 | $_SESSION['mobile_add_contact']['check_read_confirmation'] = $_POST['check_read_confirmation']; |
---|
| 1008 | $_SESSION['mobile_add_contact']['check_add_history'] = $_POST['check_add_history']; |
---|
[3571] | 1009 | |
---|
[1474] | 1010 | $ui_cc = CreateObject('mobile.ui_mobilecc'); |
---|
[3600] | 1011 | $ui_cc->choose_contact(array("request_from" => "ui_mobilemail.new_msg")); |
---|
[1474] | 1012 | } |
---|
| 1013 | |
---|
| 1014 | function add_recipient() { |
---|
[3600] | 1015 | if($_SESSION['mobile_add_contact']['add_to'] == "to") |
---|
| 1016 | $arr_key_name = "mobile_mail"; |
---|
| 1017 | else |
---|
| 1018 | $arr_key_name = "mobile_mail_cc"; |
---|
[1474] | 1019 | |
---|
[3600] | 1020 | $arr_mobile_add_contact = $_SESSION['mobile_add_contact']; |
---|
[1474] | 1021 | |
---|
[3600] | 1022 | if(strpos($arr_mobile_add_contact[$arr_key_name], $_GET['mail']) === false) |
---|
| 1023 | $arr_mobile_add_contact[$arr_key_name] .= ( (trim($arr_mobile_add_contact[$arr_key_name]) == "") ? $_GET['mail'] : ",".$_GET['mail']); |
---|
[1474] | 1024 | |
---|
[3600] | 1025 | unset($_SESSION['mobile_add_contact']); |
---|
| 1026 | |
---|
| 1027 | $this->new_msg( array( |
---|
| 1028 | 'mobile_add_contact' => $arr_mobile_add_contact, |
---|
| 1029 | 'type' => 'user_add', |
---|
| 1030 | 'msg_number' => $arr_mobile_add_contact['msg_number'], |
---|
| 1031 | 'msg_folder' => $arr_mobile_add_contact['msg_folder'])); |
---|
[1474] | 1032 | } |
---|
| 1033 | |
---|
[1714] | 1034 | function list_folders(){ |
---|
| 1035 | //Define o template para mensagens de retorno da funcao |
---|
[3571] | 1036 | $this->template->set_file(array('folders_t' => 'folders.tpl')); |
---|
| 1037 | $this->template->set_block('folders_t','retorno'); |
---|
[1714] | 1038 | |
---|
| 1039 | $folders_list = ''; |
---|
[1848] | 1040 | $array_folders = Array(); |
---|
| 1041 | $this->folders = $this->imap_functions->get_folders_list(array('noSharedFolders' => true)); |
---|
| 1042 | |
---|
| 1043 | foreach($this->folders as $id => $folder) |
---|
[1714] | 1044 | { |
---|
[1848] | 1045 | if((strpos($folder['folder_id'],'user')===true && !is_array($folder)) || !is_numeric($id)) |
---|
| 1046 | continue; |
---|
| 1047 | $array_folders[$folder['folder_id']]['id'] = $id; |
---|
| 1048 | $array_folders[$folder['folder_id']]['folder_name'] = $folder['folder_name']; |
---|
| 1049 | } |
---|
| 1050 | |
---|
| 1051 | foreach($array_folders as $folder_id => $folder) |
---|
| 1052 | { |
---|
| 1053 | if(($folder_id != $_SESSION['phpgw_info']['user']['preferences']['expressoMail']['save_in_folder']) && ($folder['id'] != 0)){ |
---|
| 1054 | $folder_name = str_replace('*','',lang($folder['folder_name'])); |
---|
| 1055 | $folder_link = "index.php?menuaction=mobile.ui_mobilemail.mail_list&folder=".$folder['id']; |
---|
| 1056 | $folders_list .= "<br>:: <a href=".$folder_link.">".$folder_name."</a>"; |
---|
[1714] | 1057 | } |
---|
| 1058 | } |
---|
[3571] | 1059 | $this->template->set_var('folders_list', $folders_list); |
---|
| 1060 | $this->template->pfp('out','retorno'); |
---|
[1848] | 1061 | |
---|
[1714] | 1062 | } |
---|
[623] | 1063 | |
---|
| 1064 | } |
---|
| 1065 | ?> |
---|