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