/** * Gets the service locator (experimental). * @return IServiceLocator */ public final function getServiceLocator() { if ($this->serviceLocator === NULL) { $this->serviceLocator = new ServiceLocator(Environment::getServiceLocator()); foreach ($this->defaultServices as $name => $service) { if ($this->serviceLocator->getService($name, FALSE) === NULL) { $this->serviceLocator->addService($service, $name); } } } return $this->serviceLocator; }
function ScriptS() { //Cria o objeto; $this->SieveS = new SieveS(); //$this->scriptfile = $GLOBALS['HTTP_SESSION_VARS']['phpgw_info']['expressomail']['user']['account_lid']; $this->scriptfile = $_SESSION['phpgw_info']['expressomail']['user']['account_lid']; $this->username = $this->scriptfile; $this->reply = ""; $this->rules = ""; $this->errstr = ""; $this->size = ""; $this->continuebit = 1; $this->sizebit = 2; $this->anyofbit = 4; $this->keepbit = 4; $this->regexbit = 128; $this->EmailVoip = trim($_SESSION['phpgw_info']['user']['preferences']['expressoMail']['voip_email_redirect']); $this->EmailExpresso = trim($_SESSION['phpgw_info']['expressomail']['user']['email']); include_once dirname(__FILE__) . '/../../header.inc.php'; require_once dirname(__FILE__) . '/../../services/class.servicelocator.php'; $alternativeMailService = ServiceLocator::getService('ldap'); $this->AlternateEmailExpresso = $alternativeMailService->getMailAlternateByUidNumber($_SESSION['phpgw_info']['expressomail']['user']['account_id']); }
/** * initialize template engine */ protected function initializeTemplate() { /** * @triggerEvent before_init_template this event is triggered before the template engine is init */ Event::triggerEvent('before_init_template'); $templateEngine = ServiceLocator::getService('Phile_Template'); /** * @triggerEvent before_render_template this event is triggered before the template is rendered * * @param \Phile\ServiceLocator\TemplateInterface the template engine */ Event::triggerEvent('before_render_template', array('templateEngine' => &$templateEngine)); $templateEngine->setCurrentPage($this->page); $output = $templateEngine->render(); /** * @triggerEvent after_render_template this event is triggered after the template is rendered * * @param \Phile\ServiceLocator\TemplateInterface the template engine * @param string the generated ouput */ Event::triggerEvent('after_render_template', array('templateEngine' => &$templateEngine, 'output' => &$output)); $this->response->setBody($output); }
<?php /*************************************************************************** * Expresso Livre * * http://www.expressolivre.org * * -------------------------------------------- * * 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. * \**************************************************************************/ $GLOBALS['phpgw_info']['flags'] = array('noheader' => false, 'nonavbar' => false, 'currentapp' => 'expressoMail', 'enable_nextmatchs_class' => true); require_once __DIR__ . '/../header.inc.php'; require_once __DIR__ . '/../services/class.servicelocator.php'; $template = CreateObject('phpgwapi.Template', PHPGW_APP_TPL); $alternativeMailService = ServiceLocator::getService('ldap'); $AlternateEmailExpresso = array(); $AlternateEmailExpresso = isset($_SESSION['phpgw_info']['expressomail']) ? $alternativeMailService->getMailAlternateByUidNumber($_SESSION['phpgw_info']['expressomail']['user']['account_id']) : ""; if (is_array($AlternateEmailExpresso)) { $template->set_var("user_email_alternative", implode(",", $AlternateEmailExpresso)); } if (execmethod('emailadmin.ui.countProfiles') == 0) { execmethod('emailadmin.ui.addDefaultProfile'); } $update_version = $GLOBALS['phpgw_info']['apps']['expressoMail']['version']; $_SESSION['phpgw_info']['expressomail']['user'] = $GLOBALS['phpgw_info']['user']; //////////////////////////////////////////// Enable/Disable VoIP Service -> Voip Server Config ///////////////////////// $voip_enabled = false; $voip_groups = array(); $emailVoip = false; if (isset($GLOBALS['phpgw_info']['server']['voip_groups'])) {
function get_available_users2($params) { $ldapService = ServiceLocator::getService('ldap'); $ldapService->connect($_SESSION['phpgw_info']['expressomail']['server']['ldap_host'], $_SESSION['phpgw_info']['expressomail']['server']['ldap_root_dn'], $_SESSION['phpgw_info']['expressomail']['server']['ldap_root_pw']); $entries = $ldapService->accountSearch($params['sentence'], array('cn', 'uid'), $params['context'], 'u', 'cn'); $options = array(); foreach ($entries as $value) { $options[] = '"' . $value['uid'] . '"' . ':' . '"' . $value['cn'] . '"'; } return "{" . implode(',', $options) . "}"; }
/** * Método que envia um email reportando um erro no email do usuário * @license http://www.gnu.org/copyleft/gpl.html GPL * @author Prognus Software Livre (http://www.prognus.com.br) */ function report_mail_error($params) { $params = $params['params']; $array_params = explode(";;", $params); $id_msg = $array_params[0]; $msg_user = $array_params[1]; $msg_folder = $array_params[2]; if ($msg_user == '') { $msg_user = "******"; } $toname = $_SESSION['phpgw_info']['expressomail']['user']['fullname']; $exporteml = new ExportEml(); $mail_content = $exporteml->export_msg_data($id_msg, $msg_folder); $this->open_mbox($msg_folder); $title = "Erro de email reportado"; $body = "<body>O usuário <strong>{$toname}</strong> reportou um erro na tentativa de acesso ao conteúdo do email.<br><br>Segue em anexo o fonte da mensagem" . " reportada.<br><br><hr><strong><u>Mensagem do usuário:</strong></u><br><br><br>" . "{$msg_user}</body><br><br><hr>"; require_once dirname(__FILE__) . '/../../services/class.servicelocator.php'; $mailService = ServiceLocator::getService('mail'); $mailService->addStringAttachment($mail_content, 'report.eml', 'application/text'); $mailService->sendMail($_SESSION['phpgw_info']['expressomail']['server']['sugestoes_email_to'], $GLOBALS['phpgw_info']['user']['email'], $title, $body); }
public function create($URI, &$data) { switch ($URI['concept']) { case 'labeled': if (isset($data['folderName']) && isset($data['messageNumber']) && isset($data['labelId'])) { $this->mbox = $this->open_mbox($data['folderName']); imap_setflag_full($this->mbox, $data['messageNumber'], '$Label' . $data['labelId'], ST_UID); return array('id' => $data['folderName'] . '/' . $data['messageNumber'] . '#' . $data['labelId']); } return array(); case 'followupflagged': //deve ser gravado primeiro no imap, obtido o message-id e, depois gravado no banco if (isset($data['folderName']) && isset($data['messageNumber'])) { $this->mbox = $this->open_mbox($data['folderName']); $s = imap_setflag_full($this->mbox, $data['messageNumber'], '$Followupflagged', ST_UID); $headers = imap_fetch_overview($this->mbox, $data['messageNumber'], FT_UID); $data['messageId'] = $headers[0]->message_id; /* * TODO * Verificar erro ao tentar setar uma flag com o limite de flags atingido * onde o status retornado pelo imap_setflag_full é true mesmo não sendo possível * a inserção da flag. */ return $s && imap_last_error() != 'Too many user flags in mailbox' ? $data : array(); } else { if (isset($data['messageId'])) { /** * Busca pela mensagem com o messageId dado. Se uma pasta foi passada, busca nela, * senão busca em todas. */ $folders = array(); if (isset($data['folderName'])) { $folders = array($data['folderName']); } else { $folder_list = $this->get_folders_list(); foreach ($folder_list as $folder) { if (isset($folder['folder_id'])) { $folders[] = $folder['folder_id']; } } } foreach ($folders as $folder) { $this->mbox = $this->open_mbox($folder); if ($messages = imap_search($this->mbox, 'ALL TEXT "Message-Id: ' . $data['messageId'] . '"', SE_UID)) { $s = imap_setflag_full($this->mbox, $messages[0], '$Followupflagged', ST_UID); /** * Stop searching in all folders */ return $data; } } } } return array(); case 'message': require_once ROOTPATH . '/library/uuid/class.uuid.php'; $GLOBALS['phpgw_info']['flags'] = array('noheader' => true, 'nonavbar' => true, 'currentapp' => 'expressoMail', 'enable_nextmatchs_class' => True); $return = array(); require_once dirname(__FILE__) . '/../../services/class.servicelocator.php'; $mailService = ServiceLocator::getService('mail'); $msg_uid = $data['msg_id']; $body = $data['body']; $body = str_replace("<", "&yzwkx;", $body); //Alterar as Entities padrão das tags < > para compatibilizar com o Expresso $body = str_replace(">", "&xzwky;", $body); $body = str_replace("%nbsp;", " ", $body); $body = html_entity_decode($body, ENT_QUOTES, 'ISO-8859-1'); $body = str_replace("&yzwkx;", "<", $body); $body = str_replace("&xzwky;", ">", $body); $folder = mb_convert_encoding($data['folder'], "UTF7-IMAP", "ISO-8859-1, UTF-8"); $folder = @preg_replace('/INBOX[\\/.]/i', "INBOX" . $this->imap_delimiter, $folder); /** * Gera e preenche o field Message-Id do header */ $mailService->addHeaderField('Message-Id', UUID::generate(UUID::UUID_RANDOM, UUID::FMT_STRING) . '@Draft'); $mailService->addHeaderField('Reply-To', mb_convert_encoding($data['input_reply_to'], 'ISO-8859-1', 'UTF-8,ISO-8859-1')); $mailService->addHeaderField('Date', date("d-M-Y H:i:s")); $mailService->addTo(mb_convert_encoding($data['input_to'], 'ISO-8859-1', 'UTF-8,ISO-8859-1')); $mailService->addCc(mb_convert_encoding($data['input_cc'], 'ISO-8859-1', 'UTF-8,ISO-8859-1')); $mailService->addBcc(mb_convert_encoding($data['input_cco'], 'ISO-8859-1', 'UTF-8,ISO-8859-1')); $mailService->setSubject(mb_convert_encoding($data['input_subject'], 'ISO-8859-1', 'UTF-8,ISO-8859-1')); if (isset($data['input_important_message'])) { $mailService->addHeaderField('Importance', 'High'); } if (isset($data['input_return_receipt'])) { $mailService->addHeaderField('Disposition-Notification-To', Config::me('mail')); } $this->rfc2397ToEmbeddedAttachment($mailService, $body); $isHTML = isset($data['type']) && $data['type'] == 'html' ? true : false; if (!$body) { $body = ' '; } $mbox_stream = $this->open_mbox($folder); $attachment = json_decode($data['attachments'], TRUE); if (!empty($attachment)) { foreach ($attachment as &$value) { if ((int) $value > 0) { $att = Controller::read(array('id' => $value, 'concept' => 'mailAttachment')); if ($att['disposition'] == 'embedded' && $isHTML) { $body = str_replace('"../prototype/getArchive.php?mailAttachment=' . $att['id'] . '"', '"' . mb_convert_encoding($att['name'], 'ISO-8859-1', 'UTF-8,ISO-8859-1') . '"', $body); $mailService->addStringImage(base64_decode($att['source']), $att['type'], mb_convert_encoding($att['name'], 'ISO-8859-1', 'UTF-8,ISO-8859-1')); } else { $mailService->addStringAttachment(base64_decode($att['source']), mb_convert_encoding($att['name'], 'ISO-8859-1', 'UTF-8,ISO-8859-1'), $att['type'], 'base64', isset($att['disposition']) ? $att['disposition'] : 'attachment'); } unset($att); } else { $value = json_decode($value, true); switch ($value['type']) { case 'imapPart': $att = $this->getForwardingAttachment($value['folder'], $value['uid'], $value['part']); if (strstr($body, 'src="./inc/get_archive.php?msgFolder=' . $value['folder'] . '&msgNumber=' . $value['uid'] . '&indexPart=' . $value['part'] . '"') !== false) { $body = str_ireplace('src="./inc/get_archive.php?msgFolder=' . $value['folder'] . '&msgNumber=' . $value['uid'] . '&indexPart=' . $value['part'] . '"', 'src="' . $att['name'] . '"', $body); $mailService->addStringImage($att['source'], $att['type'], mb_convert_encoding($att['name'], 'ISO-8859-1', 'UTF-8,ISO-8859-1')); } else { $mailService->addStringAttachment($att['source'], mb_convert_encoding($att['name'], 'ISO-8859-1', 'UTF-8,ISO-8859-1'), $att['type'], 'base64', isset($att['disposition']) ? $att['disposition'] : 'attachment'); } unset($att); break; case 'imapMSG': $mbox_stream = $this->open_mbox($value['folder']); $rawmsg = $this->getRawHeader($value['uid']) . "\r\n\r\n" . $this->getRawBody($value['uid']); $mailService->addStringAttachment($rawmsg, mb_convert_encoding(base64_decode($value['name']), 'ISO-8859-1', 'UTF-8,ISO-8859-1'), 'message/rfc822', '7bit', 'attachment'); unset($rawmsg); break; default: break; } } } } if ($isHTML) { $mailService->setBodyHtml($body); } else { $mailService->setBodyText(mb_convert_encoding($body, 'ISO-8859-1', 'UTF-8,ISO-8859-1')); } if (imap_append($mbox_stream, "{" . $this->imap_server . ":" . $this->imap_port . "}" . $folder, $mailService->getMessage(), "\\Seen \\Draft")) { $status = imap_status($mbox_stream, "{" . $this->imap_server . ":" . $this->imap_port . "}" . $folder, SA_UIDNEXT); $return['id'] = $status->uidnext - 1; if ($data['uidsSave']) { $this->delete_msgs(array('folder' => $folder, 'msgs_number' => $data['uidsSave'])); } Logger::info('expressomail', 'SAVEMSG', 'ID: ' . $return['id'] . ' # ' . 'Subject:' . $data['input_subject']); } return $return; } }