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