*
* -------------------------------------------- *
* This program is free software; you can redistribute it and/or modify it *
* under the terms of the GNU General Public License as published by the *
* Free Software Foundation; either version 2 of the License, or (at your *
* option) any later version. *
\**************************************************************************/
//TODO: Criar a Classe Widget.
include_once(PHPGW_INCLUDE_ROOT.'/expressoMail1_2/inc/class.imap_functions.inc.php');
// Classe principal do Mini Mail
class ui_mobilemail{
// Define as funções públicas
var $public_functions = array(
'mail_list' => True,
'change_folder' => True,
'change_page' => True,
'show_msg' => True,
'send_mail' => True,
//'reply_msg' => True,
'new_msg' => True,
);
var $folders; // Pastas imap
var $current_folder; // Pasta corrente
var $current_page; // Página corrente da lista de e-mails da pasta corrente
var $imap_functions; // Variável que recebe um objeto do tipo class.imap_functions.inc.php
var $allowed_tags = '
'; // Tags html que não serão removidas
// ao mostrar corpo do e-mail
/*
* @function mobilemail
* @abstract Método construtor da classe principal do Mini Mail
* @author Mário César Kolling
*/
function ui_mobilemail()
{
$this-> load_session();
// Recupera atributos da classe gravados na sessão
$folders = $GLOBALS['phpgw']->session->appsession('mobilemail.folders','mobile');
$current_folder = $GLOBALS['phpgw']->session->appsession('mobilemail.current_folder','mobile');
$current_page = $GLOBALS['phpgw']->session->appsession('mobilemail.current_page','mobile');
// Inicializa a classe class.imap_functions.inc.php
$this->imap_functions = new imap_functions();
// Testa a existência dos atributos da classe recuperadas da sessão, e as carrega ou inicializa.
if ($folders)
{
$this->folders = $folders;
}
else
{
$this->folders = $this->imap_functions->get_folders_list();
}
if ($current_folder)
{
$this->current_folder = $current_folder;
}
else
{
$this->current_folder = 0; // Define o folder INBOX como o folder corrente
}
if ($current_page)
{
$this->current_page = $current_page;
}
else
{
$this->current_page = 1; // Define a primeira página como página padrão
}
}
/*
* @function save_session
* @abstract Salva os atributos da classe na sessão
* @author Mário César Kolling
*/
function save_session()
{
$GLOBALS['phpgw']->session->appsession('mobilemail.folders','mobile',$this->folders);
$GLOBALS['phpgw']->session->appsession('mobilemail.current_folder','mobile',$this->current_folder);
$GLOBALS['phpgw']->session->appsession('mobilemail.current_page','mobile',$this->current_page);
}
/*
* @function change_page
* @abstract Troca a página de exibição da lista de e-mails, e mostra a nova página
* @author Mário César Kolling
*/
function change_page()
{
if (isset($_GET['page']))
{
$this->current_page = $_GET['page'];
}
$this->mail_list();
$this->save_session();
}
/*
* @function change_folder
* @abstract Troca a pasta do imap, e mostra a primeira página da nova pasta
* @author Mário César Kolling
*/
function change_folder()
{
$folder = $_GET['folder'];
if (isset($folder))
{
$this->current_folder = $folder;
$this->current_page = 1;
}
$this->mail_list();
$this->save_session();
}
/*
* @function show_msg
* @abstract Mostra a mensagem de e-mail requisitada
* @author Mário César Kolling
*/
// TODO: retirar msg_folder dos parâmentros necessários no GET e usar $this->current_folder
function show_msg()
{
$params = array();
//TODO: testar chamar sem parâmetros para determinar se ocorre algum problema
if (isset($_GET['msg_number']) && isset($_GET['msg_folder']))
{
$params = array(
'msg_number' => $_GET['msg_number'],
'msg_folder' => $_GET['msg_folder'],
);
}
$msg = $this->imap_functions->get_info_msg($params);
// Carrega o template
$p = CreateObject('phpgwapi.Template', PHPGW_SERVER_ROOT . '/mobile/templates/'.$GLOBALS['phpgw_info']['server']['template_set']);
$p->set_file(
Array(
'view_msg_t' => 'view_msg.tpl'
)
);
$p->set_block('view_msg_t', 'mail_header');
$p->set_block('view_msg_t', 'mail_body');
$p->set_block('view_msg_t', 'mail_footer');
$p->set_block('view_msg_t', 'reply_msg');
$p->set_block('view_msg_t', 'attachment_list');
$p->set_block('view_msg_t', 'begin_anchor');
$p->set_block('view_msg_t', 'end_anchor');
// Define o cabeçalho do e-mail
$p->set_var('from_label', lang("From"));
$p->set_var('from', $msg['from']['full']);
$p->set_var('to_label', lang("To"));
$p->set_var('subject_label', lang("Subject"));
$p->set_var('subject', $msg['subject']);
$p->set_var('date_label', lang("Date"));
$p->set_var('date', $msg['fulldate']);
// Mostra o corpo do e-mail
$p->set_var('body', strip_tags($msg['body'], $this->allowed_tags)); // Usa a função strip_tags() para filtrar
// as tags que estão presentes no corpo do e-mail.
$p->set_var('link_text', lang("Return"));
$p->set_var('link', "index.php?menuaction=mobile.ui_mobilemail.mail_list");
$p->set_var('reply_text', lang("Reply"));
$msg_number = $_GET['msg_number'];
$msg_folder = $_GET['msg_folder'];
$p->set_var('reply', "index.php?menuaction=mobile.ui_mobilemail.new_msg&msg_number=$msg_number&msg_folder=$msg_folder");
if (!empty($msg['attachments']) && !empty($msg['attachments']['names']))
{
$attachs = "
".lang("This message has the follow attachments:")."
";
foreach($msg['attachments'] as $key => $attach) {
if(is_array($attach)) {
$attachs.=$attach['name']." ";
if($GLOBALS['phpgw_info']['user']['preferences']['mobile']['download_attach']==1)
$attachs.="".
lang('Download')."
";
else
$attachs.="
";
}
$p->set_var('attachment_message', $attachs);
}
//$p->set_var('attachment_message', lang('This message have attachment(s)'));
}
else
{
$p->set_var('attachment_message', lang('This message don\'t have attachment(s)'));
}
$p->parse('view_msg_t', 'end_anchor');
$p->parse('view_msg_t', 'begin_anchor');
//$p->pfp('view_msg_t', 'mail_header');
/*$p->pfp('out', 'mail_header');
//$p->pfp('view_msg_t', 'mail_body');
$p->pfp('out', 'mail_body');
//$p->pfp('view_msg_t', 'attachment_list');
$p->pfp('out', 'attachment_list');
//$p->pfp('view_msg_t', 'mail_footer');
$p->pfp('out', 'reply_msg');
//$p->pfp('out', 'mail_footer');*/
//$p->pfp('view_msg_t', 'mail_header');
$GLOBALS['phpgw_info']['mobiletemplate']->set_content($p->fp('out', 'mail_header'));
$GLOBALS['phpgw_info']['mobiletemplate']->set_content($p->fp('out', 'mail_body'));
$GLOBALS['phpgw_info']['mobiletemplate']->set_content($p->fp('out', 'attachment_list'));
$GLOBALS['phpgw_info']['mobiletemplate']->set_content($p->fp('out', 'reply_msg'));
}
/*
* @function index
* @abstract Página inicial da aplicação mobilemail, mantém o estado atual. Ou seja, mostra lista de e-mails
* do folder e página definidos pelos parâmetros current_folder e current_page.
* @author Mário César Kolling
*/
// TODO: Talvez seja melhor voltar sempre para o Inbox e primeira página
function index()
{
$this->print_folder_selection();
$this->mail_list();
$this->save_session();
}
function load_session(){
/************************************\
* Inicialização do expressoMail1_2 *
\************************************/
// Get Data from ldap_manager and emailadmin.
$ldap_manager = CreateObject('contactcenter.bo_ldap_manager');
$boemailadmin = CreateObject('emailadmin.bo');
$emailadmin_profile = $boemailadmin->getProfileList();
$_SESSION['phpgw_info']['expressomail']['email_server'] = $boemailadmin->getProfile($emailadmin_profile[0]['profileID']);
$_SESSION['phpgw_info']['expressomail']['user'] = $GLOBALS['phpgw_info']['user'];
$_SESSION['phpgw_info']['expressomail']['server'] = $GLOBALS['phpgw_info']['server'];
$_SESSION['phpgw_info']['expressomail']['ldap_server'] = $ldap_manager ? $ldap_manager->srcs[1] : null;
$_SESSION['phpgw_info']['expressomail']['user']['email'] = $GLOBALS['phpgw']->preferences->values['email'];
// Fix problem with cyrus delimiter changes in preferences.
// Dots in names: enabled/disabled.
$save_in_folder = @eregi_replace("INBOX/", "INBOX".$_SESSION['phpgw_info']['expressomail']['email_server']['imapDelimiter'], $_SESSION['phpgw_info']['user']['preferences']['expressoMail']['save_in_folder']);
$save_in_folder = @eregi_replace("INBOX.", "INBOX".$_SESSION['phpgw_info']['expressomail']['email_server']['imapDelimiter'], $save_in_folder);
$_SESSION['phpgw_info']['user']['preferences']['expressoMail']['save_in_folder'] = $save_in_folder;
// End Fix.
// Loading Admin Config Module
$c = CreateObject('phpgwapi.config','expressoMail1_2');
$c->read_repository();
$current_config = $c->config_data;
$_SESSION['phpgw_info']['server']['expressomail']['expressoMail_enable_log_messages'] = $current_config['expressoMail_enable_log_messages'];
// Begin Set Anti-Spam options.
$_SESSION['phpgw_info']['server']['expressomail']['expressoMail_command_for_ham'] = $current_config['expressoMail_command_for_ham'];
$_SESSION['phpgw_info']['server']['expressomail']['expressoMail_command_for_spam'] = $current_config['expressoMail_command_for_spam'];
$_SESSION['phpgw_info']['server']['expressomail']['expressoMail_use_spam_filter'] = $current_config['expressoMail_use_spam_filter'];
echo '';
// End Set Anti-Spam options.
// Set Imap Folder names options
$_SESSION['phpgw_info']['expressomail']['email_server']['imapDefaultTrashFolder'] = $_SESSION['phpgw_info']['expressomail']['email_server']['imapDefaultTrashFolder'] ? $_SESSION['phpgw_info']['expressomail']['email_server']['imapDefaultTrashFolder'] : "Trash";
$_SESSION['phpgw_info']['expressomail']['email_server']['imapDefaultDraftsFolder'] = $_SESSION['phpgw_info']['expressomail']['email_server']['imapDefaultDraftsFolder'] ? $_SESSION['phpgw_info']['expressomail']['email_server']['imapDefaultDraftsFolder'] : "Drafts";
$_SESSION['phpgw_info']['expressomail']['email_server']['imapDefaultSpamFolder'] = $_SESSION['phpgw_info']['expressomail']['email_server']['imapDefaultSpamFolder'] ? $_SESSION['phpgw_info']['expressomail']['email_server']['imapDefaultSpamFolder'] : "Spam";
$_SESSION['phpgw_info']['expressomail']['email_server']['imapDefaultSentFolder'] = $_SESSION['phpgw_info']['expressomail']['email_server']['imapDefaultSentFolder'] ? $_SESSION['phpgw_info']['expressomail']['email_server']['imapDefaultSentFolder'] : "Sent";
include("../expressoMail1_2/inc/load_lang.php");
}
/*
* @function print_folder_selection
* @abstract Imprime o folder corrente (INBOX)
* @author Mário César Kolling
*/
function print_folder_selection()
{
$p = CreateObject('phpgwapi.Template', PHPGW_SERVER_ROOT . '/mobile/templates/'.$GLOBALS['phpgw_info']['server']['template_set']);
$p->set_file(
Array(
'mobilemail_t' => 'mobilemail.tpl'
)
);
$p->set_block('mobilemail_t', 'inbox_folder_list');
$p->set_var('lang_folder', lang('Folder'));
$p->set_var('lang_inbox', lang('Inbox'));
//$p->set_var('folder_items', $folder_items);
$p->parse('mobilemail_t', 'inbox_folder_list');
//$p->fpf('out', 'mobilemail_t');
$GLOBALS['phpgw_info']['mobiletemplate']->set_content($p->fp('out', 'mobilemail_t'));
}
/*
* @function old_print_folder_selection
* @abstract Imprime na tela a caixa de seleção de folders
* @author Mário César Kolling
*/
function old_print_folder_selection()
{
// Processa as options
$folder_items = '';
foreach ($this->folders as $i => $j)
{
$option_selected = '';
$p = CreateObject('phpgwapi.Template', PHPGW_SERVER_ROOT . '/mobile/templates/'.$GLOBALS['phpgw_info']['server']['template_set']);
$p->set_file(
Array(
'mobilemail_t' => 'mobilemail.tpl'
)
);
$p->set_block('mobilemail_t', 'folder_item');
if (is_numeric($i))
{
if ($i == $this->current_folder)
{
$option_selected = 'selected="selected"';
}
$p->set_var('option_selected', $option_selected);
$p->set_var('folder_id', $j['folder_id']);
$p->set_var('folder_name', $j['folder_id']); // Mudar... provavelmente usar preg_replace
// para substituir cpf pelo nome do usuário.
if ($j['folder_unseen'] > 0)
{
$p->set_var('folder_unseen', ' - ('.$j['folder_unseen'].')');
}
$folder_items .= $p->fp('mobile_t', 'folder_item');
}
}
// Processa o select
$p = CreateObject('phpgwapi.Template', PHPGW_SERVER_ROOT . '/mobile/templates/'.$GLOBALS['phpgw_info']['server']['template_set']);
$p->set_file(
Array(
'mobilemail_t' => 'mobilemail.tpl'
)
);
$p->set_block('mobilemail_t', 'folder_list');
$p->set_var('folder_items', $folder_items);
$p->parse('mobilemail_t', 'folder_list');
//$p->pfp('out', 'mobilemail_t');
$GLOBALS['phpgw_info']['mobiletemplate']->set_content($p->fp('out', 'mobilemail_t'));
}
/*
* @function mail_list
* @abstract Imprime a lista de e-mails
* @author Mário César Kolling
*/
function mail_list()
{
$this->messages_per_page =
isset($GLOBALS['phpgw_info']['user']['preferences']['mobile']['max_message_per_page'])?
$GLOBALS['phpgw_info']['user']['preferences']['mobile']['max_message_per_page']:10;
// var $pages;
// var $actual_page;
// var $number_of_messages;
if (!isset($this->number_of_messages))
{
$params = array(
'folder' => $this->folders[$this->current_folder]['folder_id'],
);
$this->number_of_messages = $this->imap_functions->get_num_msgs($params);
}
// Recalcular as páginas
$this->pages = ceil($this->number_of_messages/$this->messages_per_page);
$page = $this->current_page;
$params = array(
'folder' => $this->folders[$this->current_folder]['folder_id'],
'msg_range_begin' => $this->current_page * $this->messages_per_page - ($this->messages_per_page - 1),
'msg_range_end' => $this->current_page * $this->messages_per_page,
'sort_box_type' => 'SORTARRIVAL',
'sort_box_reverse' => 1
);
$messages = $this->imap_functions->get_range_msgs2($params);
$this->print_mails_list($messages);
$this->print_page_navigation($this->pages, $this->current_page);
}
/*
* @function print_mails_list
* @abstract Imprime a lista de mensagens
* @author Mário César Kolling
* @param array Um array com a lista de mensagens recuperado por $this->imap_functions->get_range_msgs2($params)
*/
function print_mails_list($messages)
{
// Cria a lista de e-mails
$mail_rows = '';
if ($this->number_of_messages != 0)
{
foreach ($messages as $index => $msg)
{
$p = CreateObject('phpgwapi.Template', PHPGW_SERVER_ROOT . '/mobile/templates/'.$GLOBALS['phpgw_info']['server']['template_set']);
$p->set_file(
Array(
'mobilemail_t' => 'mobilemail.tpl'
)
);
$p->set_block('mobilemail_t', 'mail_row');
$p->set_block('mobilemail_t', 'end_strong');
$p->set_block('mobilemail_t', 'begin_strong');
$p->set_var('unseen_bkg', "#FFFFFF");
if (is_numeric($index))
{
!empty($msg['from']['name']) ? $from = $msg['from']['name'] : $from = $msg['from']['email'];
!empty($msg['subject']) ? $subject = $msg['subject'] : $subject = lang('[empty subject]');
if ($msg['Unseen'] == 'U'){ //Setando as mensagens nao lidas
$p->set_var('strong_unseen_begin', trim($p->fp('mobilemail_t', 'begin_strong')));
$p->set_var('strong_unseen_end', trim($p->fp('mobilemail_t', 'end_strong')));
$p->set_var('unseen_bkg', "#E0ECFF");
//$p->set_var('unseen_bkg', "#E8EEF7");
}
$p->set_var('from', $from);
$p->set_var('subject', $subject);
$p->set_var('msg_number', $msg['msg_number']);
$p->set_var('date', $msg['udate']);
$p->set_var('msg_folder', $this->folders[$this->current_folder]['folder_id']);
$p->set_var('from_label', lang('From'));
$mail_rows .= $p->fp('mobilemail_t', 'mail_row');
}
}
// Imprime a lista de e-mails
$p = CreateObject('phpgwapi.Template', PHPGW_SERVER_ROOT . '/mobile/templates/'.$GLOBALS['phpgw_info']['server']['template_set']);
$p->set_file(
Array(
'mobilemail_t' => 'mobilemail.tpl'
)
);
$p->set_block('mobilemail_t', 'mail_list');
$p->set_var('mail_rows', $mail_rows);
//$p->pfp('out', 'mail_list');
$GLOBALS['phpgw_info']['mobiletemplate']->set_content($p->fp('out', 'mail_list'));
}
else
{
// Lista de e-mails vazia
$p = CreateObject('phpgwapi.Template', PHPGW_SERVER_ROOT . '/mobile/templates/'.$GLOBALS['phpgw_info']['server']['template_set']);
$p->set_file(
Array(
'mobilemail_t' => 'mobilemail.tpl'
)
);
$p->set_block('mobilemail_t', 'empty_list');
$p->set_var('empty_message', lang('Empty folder'));
//$p->pfp('out', 'empty_list');
$GLOBALS['phpgw_info']['mobiletemplate']->set_content($p->fp('out', 'empty_list'));
}
}
/*
* @funtion print_page_navigation
* @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.
* @author Mário César Kolling
* @param integer Número de páginas que serão geradas
* @param integer Página corrente
*/
// TODO: mover este método para a classe page_navigation subclasse de widget
function print_page_navigation($number_of_pages, $page = 1)
{
$pages = '';
if ($number_of_pages != 0)
{
// Geração das páginas
for ($i = 1; $i <= $number_of_pages ; $i++)
{
$p = CreateObject('phpgwapi.Template', PHPGW_SERVER_ROOT . '/mobile/templates/'.$GLOBALS['phpgw_info']['server']['template_set']);
$p->set_file(
Array(
'mobilemail_t' => 'mobilemail.tpl'
)
);
$p->set_block('mobilemail_t', 'space');
$p->set_block('mobilemail_t', 'begin_anchor');
$p->set_block('mobilemail_t', 'end_anchor');
$p->set_block('mobilemail_t', 'page_item');
$p->set_block('mobilemail_t', 'begin_strong');
$p->set_block('mobilemail_t', 'end_strong');
if ($i == $page)
{
// Se for a página sendo gerada for a página corrente,
// não gera a âncora e destaca o número (negrito)
$p->set_var('end_anchor', '');
$p->set_var('begin_anchor', '');
$p->set_var('begin_strong', trim($p->fp('mobilemail_t', 'begin_strong')));
$p->set_var('end_strong', trim($p->fp('mobilemail_t', 'end_strong')));
}
else
{
// Senão, gera a âncora
$p->set_var('begin_strong', '');
$p->set_var('end_strong', '');
$p->set_var('end_anchor', trim($p->fp('mobilemail_t', 'end_anchor')));
$p->set_var('begin_anchor_href', "index.php?menuaction=mobile.ui_mobilemail.change_page&page=$i");
$p->set_var('begin_anchor', trim($p->fp('mobilemail_t', 'begin_anchor')));
}
$p->set_var('page', $i);
//$pages .= trim($p->fp('mobilemail_t', 'page_item'));
}
$pages .= " ".$page." ".lang("of")." ".$number_of_pages." ";
// Geração dos links "anterior" e "próximo"
$p = CreateObject('phpgwapi.Template', PHPGW_SERVER_ROOT . '/mobile/templates/'.$GLOBALS['phpgw_info']['server']['template_set']);
$p->set_file(
Array(
'mobilemail_t' => 'mobilemail.tpl'
)
);
//$p->set_block('mobilemail_t', 'space');
$p->set_block('mobilemail_t', 'mail_footer');
$p->set_block('mobilemail_t', 'previous');
$p->set_block('mobilemail_t', 'next');
$next_page = $page + 1;
$previous_page = $page - 1;
if ($page == 1)
{
// Se for a primeira página, não imprime o link "anterior""
$p->set_var('previous', '');
if ($page == $number_of_pages)
{
// Se só existir uma página, não imprime o link "próximo"
$p->set_var('next', '');
}
else
{
$p->set_var('next_href', "index.php?menuaction=mobile.ui_mobilemail.change_page&page=$next_page");
$p->set_var('next', trim($p->fp('mobilemail_t', 'next')));
}
}
else if ($page == $number_of_pages)
{
// Se for a última página, não imprime o link "próximo"
$p->set_var('next', '');
$p->set_var('previous_href', "index.php?menuaction=mobile.ui_mobilemail.change_page&page=$previous_page");
$p->set_var('previous', trim($p->fp('mobilemail_t', 'previous')));
}
else
{
// Senão, imprime os links "anterior" e "próximo"
$p->set_var('previous_href', "index.php?menuaction=mobile.ui_mobilemail.change_page&page=$previous_page");
$p->set_var('previous', trim($p->fp('mobilemail_t', 'previous')));
$p->set_var('next_href', "index.php?menuaction=mobile.ui_mobilemail.change_page&page=$next_page");
$p->set_var('next', trim($p->fp('mobilemail_t', 'next')));
}
$p->set_var('pages', $pages);
//$p->pfp('out', 'mail_footer');
$GLOBALS['phpgw_info']['mobiletemplate']->set_content($p->fp('out', 'mail_footer'));
}
}
/*
* @function new_msg()
* @abstract Gera o formulário para criar novo e-mail.
* @author Rommel de Brito Cysne
function new_msg()
{
$p = CreateObject('phpgwapi.Template', PHPGW_SERVER_ROOT . '/mobile/templates/'.$GLOBALS['phpgw_info']['server']['template_set']);
$p->set_file(
Array(
'new_msg_t' => 'new_msg.tpl'
)
);
$p->set_block('new_msg_t', 'msg_header');
$p->set_block('new_msg_t', 'text');
$p->set_block('new_msg_t', 'begin_form');
$p->set_block('new_msg_t', 'end_form');
$p->set_block('new_msg_t', 'hidden_area');
$p->set_var('to_label', lang("To"));
$p->set_var('to', "");
$p->set_var('to_mail', "");
$p->set_var('subject_label', lang("Subject"));
$p->set_var('subject', "");
$p->set_var('msg_number', $_GET['msg_number']);
$p->set_var('msg_folder', $_GET['msg_folder']);
$p->set_var('send_label', lang("Send"));
$p->set_var('form_action', "index.php?menuaction=mobile.ui_mobilemail.send_mail");
$p->pfp('out', 'begin_form');
$p->pfp('out', 'msg_header');
$p->pfp('out', 'text');
$p->pfp('out', 'hidden_area');
$p->pfp('out', 'end_form');
}
*/
/*
* @function new_msg()
* @abstract Gera o formulário para criar/enviar novo e-mail ou resposta de e-mail.
* @author Rommel de Brito Cysne
*/
function new_msg()
{
$p = CreateObject('phpgwapi.Template', PHPGW_SERVER_ROOT . '/mobile/templates/'.$GLOBALS['phpgw_info']['server']['template_set']);
$p->set_file(
Array(
'new_msg_t' => 'new_msg.tpl'
)
);
if (isset($_GET['msg_number']))
{
$params = array(
'msg_number' => $_GET['msg_number'],
);
$msg_number = $_GET['msg_number'];
}
if($params)
$msg = $this->imap_functions->get_info_msg($params);
$p->set_block('new_msg_t', 'msg_header');
$p->set_block('new_msg_t', 'text');
$p->set_block('new_msg_t', 'begin_form');
$p->set_block('new_msg_t', 'end_form');
$p->set_block('new_msg_t', 'hidden_area');
if($_GET['clk'])
{
$p->set_var('to_label', lang("To"));
$p->set_var('to', "");
$p->set_var('to_mail', "");
$p->set_var('subject_label', lang("Subject"));
$p->set_var('subject', "");
}
else if($_GET['cc_mob'])
{
$p->set_var('to_label', lang("To"));
$p->set_var('to', $_GET['input_to']);
$p->set_var('to_mail', $_GET['input_to_mail']);
$p->set_var('subject_label', lang("Subject"));
$p->set_var('subject', "");
$p->set_var('msg_number', $_GET['msg_number']);
$p->set_var('msg_folder', $_GET['msg_folder']);
$p->set_var('read_only', 'readonly');
}
else
{
$p->set_var('from_label', lang("From"));
$p->set_var('from', $msg['toaddress2']);
$p->set_var('to_label', lang("To"));
$mail_to = $msg['from']['full'];
$p->set_var('to', $msg['from']['name']);
$p->set_var('to_mail', $msg['from']['email']);
$p->set_var('subject_label', lang("Subject"));
$p->set_var('subject', "Re:" . $msg['subject']);
$p->set_var('msg_number', $_GET['msg_number']);
$p->set_var('msg_folder', $_GET['msg_folder']);
$p->set_var('read_only', "readonly");
}
$p->set_var('send_label', lang("Send"));
$p->set_var('form_action', "index.php?menuaction=mobile.ui_mobilemail.send_mail");
/*$p->pfp('out', 'begin_form');
$p->pfp('out', 'msg_header');
$p->pfp('out', 'text');
$p->pfp('out', 'hidden_area');
$p->pfp('out', 'end_form');
*/
$GLOBALS['phpgw_info']['mobiletemplate']->set_content($p->fp('out', 'begin_form'));
$GLOBALS['phpgw_info']['mobiletemplate']->set_content($p->fp('out', 'msg_header'));
$GLOBALS['phpgw_info']['mobiletemplate']->set_content($p->fp('out', 'text'));
$GLOBALS['phpgw_info']['mobiletemplate']->set_content($p->fp('out', 'hidden_area'));
$GLOBALS['phpgw_info']['mobiletemplate']->set_content($p->fp('out', 'end_form'));
}
/*
* @function send_mail()
* @abstract Função que realiza o envio de e-mails.
* @author Rommel de Brito Cysne
*/
function send_mail()
{
//Chamada da classe phpmailer
include_once(PHPGW_SERVER_ROOT."/phpgwapi/inc/class.phpmailer.inc.php");
//Recebe os dados do form (passados pelo POST)
$userName = $_POST['input_to']; //"User Someone";
$userMail = $_POST['input_to_mail']; //"user.someone@mail.com.br";
$subject = $_POST['input_subject']; //"Mail Subject";
$body = $_POST['body']; //"Mail body. Any text.";
if($userMail == "")
{
$userMail = $userName;
}
//Cria objeto
$mail = new PHPMailer();
if(!$this->imap_functions->add_recipients("to", $userMail, &$mail))
{
$error_msg = lang("Some addresses in the To field were not recognized. Please make sure that all addresses are properly formed");
}
$mail->IsSMTP();
$mail->Host = $_SESSION['phpgw_info']['expressomail']['email_server']['smtpServer'];
$mail->Port = $_SESSION['phpgw_info']['expressomail']['email_server']['smtpPort'];
//Envia os emails em formato HTML; se false -> desativa.
$mail->IsHTML(true);
//Email do remetente da mensagem
$mail->Sender = $mail->From = $_SESSION['phpgw_info']['expressomail']['user']['email'];
//Nome do remetente do email
$mail->SenderName = $mail->FromName = $_SESSION['phpgw_info']['expressomail']['user']['fullname'];
//Endereço de destino do email, ou seja, pra onde a mensagem vai
//$mail->AddAddress("$userMail");
//Assunto da mensagem
$mail->Subject = $subject;
//Corpo da mensagem
$mail->Body .= "
$body
";
//Cria um objeto template
$p = CreateObject('phpgwapi.Template', PHPGW_SERVER_ROOT . '/mobile/templates/'.$GLOBALS['phpgw_info']['server']['template_set']);
//Define o template para mensagens de retorno da funcao
$p->set_file(
Array(
'sent_msg_t' => 'sent_msg.tpl'
)
);
$p->set_block('sent_msg_t','retorno');
@header('Refresh: 1; url=./');
//Se o e-mail nao for enviado por qualquer motivo...
if(!$mail->Send())
{
//... é exibida a mensagem abaixo e o respectivo erro...
$p->set_var('msg', lang("Message not sent"));
$p->set_var('erro', lang("error") . $mail->ErrorInfo);
//... caso contrário...
}else {
//... mostra mensagem de sucesso e link de retorno à lista de e-mail
$p->set_var('msg', lang("Message sent successfully"));
//$p->set_var('link_text', lang("Return"));
//$p->set_var('link', "mobilemail_index.php");
}
//$p->pfp('out','retorno');
$GLOBALS['phpgw_info']['mobiletemplate']->set_content($p->fp('out','retorno'));
}
//PAREI
function delete_msg()
{
$this->username = $_SESSION['phpgw_info']['expressomail']['user']['userid'];
$this->password = $_SESSION['phpgw_info']['expressomail']['user']['passwd'];
$this->imap_server = $_SESSION['phpgw_info']['expressomail']['email_server']['imapServer'];
$this->imap_port = $_SESSION['phpgw_info']['expressomail']['email_server']['imapPort'];
$this->imap_delimiter = $_SESSION['phpgw_info']['expressomail']['email_server']['imapDelimiter'];
$mbox_stream = @imap_open("{".$this->imap_server.":".$this->imap_port.$this->imap_options."}".$folder, $this->username, $this->password) or die(serialize(array('imap_error' => imap_last_error())));
}
function retorna()
{
}
}
?>