Overview

Packages

  • CONTENIDO
  • Core
    • Authentication
    • Backend
    • Cache
    • CEC
    • Chain
    • ContentType
    • Database
    • Debug
    • Exception
    • Frontend
      • Search
      • URI
      • Util
    • GenericDB
      • Model
    • GUI
      • HTML
    • I18N
    • LayoutHandler
    • Log
    • Security
    • Session
    • Util
    • Validation
    • Versioning
    • XML
  • Module
    • ContentRssCreator
    • ContentSitemapHtml
    • ContentSitemapXml
    • ContentUserForum
    • NavigationTop
    • ScriptCookieDirective
  • mpAutoloaderClassMap
  • None
  • Plugin
    • ContentAllocation
    • CronjobOverview
    • FormAssistant
    • FrontendLogic
    • FrontendUsers
    • Linkchecker
    • ModRewrite
    • Newsletter
    • Repository
      • FrontendNavigation
      • KeywordDensity
    • SearchSolr
    • SmartyWrapper
    • UrlShortener
    • UserForum
    • Workflow
  • PluginManager
  • Setup
    • Form
    • GUI
    • Helper
      • Environment
      • Filesystem
      • MySQL
      • PHP
    • UpgradeJob
  • Smarty
    • Cacher
    • Compiler
    • Config
    • Debug
    • PluginsBlock
    • PluginsFilter
    • PluginsFunction
    • PluginsInternal
    • PluginsModifier
    • PluginsModifierCompiler
    • PluginsShared
    • Security
    • Template
    • TemplateResources
  • Swift
    • ByteStream
    • CharacterStream
    • Encoder
    • Events
    • KeyCache
    • Mailer
    • Mime
    • Plugins
    • Transport

Classes

  • Swift_FailoverTransport
  • Swift_LoadBalancedTransport
  • Swift_MailTransport
  • Swift_Plugins_Loggers_ArrayLogger
  • Swift_Plugins_Loggers_EchoLogger
  • Swift_SendmailTransport
  • Swift_SmtpTransport
  • Swift_Transport_AbstractSmtpTransport
  • Swift_Transport_Esmtp_Auth_CramMd5Authenticator
  • Swift_Transport_Esmtp_Auth_LoginAuthenticator
  • Swift_Transport_Esmtp_Auth_PlainAuthenticator
  • Swift_Transport_Esmtp_AuthHandler
  • Swift_Transport_EsmtpTransport
  • Swift_Transport_FailoverTransport
  • Swift_Transport_LoadBalancedTransport
  • Swift_Transport_MailTransport
  • Swift_Transport_SendmailTransport
  • Swift_Transport_SimpleMailInvoker
  • Swift_Transport_StreamBuffer

Interfaces

  • Swift_Plugins_Logger
  • Swift_Plugins_Pop_Pop3Exception
  • Swift_Transport
  • Swift_Transport_Esmtp_Authenticator
  • Swift_Transport_EsmtpHandler
  • Swift_Transport_IoBuffer
  • Swift_Transport_MailInvoker
  • Swift_Transport_SmtpAgent
  • Swift_TransportException
  • Overview
  • Package
  • Function
  • Todo
  • Download
  1: <?php
  2: /**
  3:  * This file renders the main mail log view.
  4:  *
  5:  * @package Core
  6:  * @subpackage Backend
  7:  * @version SVN Revision $Rev:$
  8:  *
  9:  * @author Simon Sprankel
 10:  * @copyright four for business AG <www.4fb.de>
 11:  * @license http://www.contenido.org/license/LIZENZ.txt
 12:  * @link http://www.4fb.de
 13:  * @link http://www.contenido.org
 14:  */
 15: defined('CON_FRAMEWORK') || die('Illegal call: Missing framework initialization - request aborted.');
 16: 
 17: global $area, $action, $perm;
 18: 
 19: $page = new cGuiPage('mail_log_overview');
 20: 
 21: if (!$perm->have_perm_area_action($area)) {
 22:     $page->displayError(i18n('Permission denied'));
 23:     $page->abortRendering();
 24:     $page->render();
 25:     exit();
 26: }
 27: 
 28: // show notification if mail logging is disabled
 29: if (getSystemProperty('system', 'mail_log') === 'false') {
 30:     $page->displayWarning(i18n('Mail logging is disabled!'));
 31: }
 32: 
 33: $mailLogCollection = new cApiMailLogCollection();
 34: 
 35: // execute the actions
 36: if ($action == 'mail_log_delete') {
 37:     // delete all mails and the corresponding success entries with the given
 38:     // idmails
 39:     if (!empty($_REQUEST['idmails'])) {
 40:         $mailLogSuccessCollection = new cApiMailLogSuccessCollection();
 41:         $idmails = json_decode($_REQUEST['idmails'], true);
 42:         foreach ($idmails as $idmail) {
 43:             $mailLogCollection->delete($idmail);
 44:             // also delete the entries in mail_log_success
 45:             $mailLogSuccessCollection->deleteBy('idmail', $idmail);
 46:         }
 47:     }
 48: } else if ($action == 'mail_log_resend') {
 49:     $mailer = new cMailer();
 50:     $mailer->resendMail($_REQUEST['idmailsuccess']);
 51: }
 52: 
 53: $mailLogCollection->query();
 54: // show notification if there no mails have been logged yet
 55: if ($mailLogCollection->count() === 0) {
 56:     $page->displayInfo(i18n('No mails have been logged yet.'));
 57:     $page->abortRendering();
 58:     $page->render();
 59:     exit();
 60: }
 61: 
 62: if ($area === 'mail_log' || $area === 'mail_log_overview') {
 63:     // construct the hidden form
 64:     $form = new cHTMLForm('bulk_editing', '', 'post', 'action-form');
 65:     $form->setVar('area', '');
 66:     $form->setVar('frame', '4');
 67:     $form->setVar('action', '');
 68:     $form->setVar('contenido', cRegistry::getSession()->id);
 69:     $form->setVar('idmail', '');
 70:     $form->setVar('idmails', '');
 71:     $page->appendContent($form);
 72: 
 73:     // add the top bulk editing functions
 74:     $page->appendContent(mailLogBulkEditingFunctions());
 75: 
 76:     // construct the overview table
 77:     $table = new cHTMLTable();
 78:     $table->setClass('generic');
 79:     $table->setWidth('100%');
 80: 
 81:     // construct the header
 82:     $headers = array(
 83:         'checkbox' => i18n('Mark'),
 84:         'subject' => i18n('Subject'),
 85:         'to' => i18n('To'),
 86:         'created' => i18n('Date'),
 87:         'client' => i18n('Client'),
 88:         'action' => i18n('Action')
 89:     );
 90:     $thead = new cHTMLTableHeader();
 91:     $tr = new cHTMLTableRow();
 92:     foreach ($headers as $header) {
 93:         $th = new cHTMLTableHead();
 94:         $th->setContent($header);
 95:         $tr->appendContent($th);
 96:     }
 97:     $thead->setContent($tr);
 98:     $table->appendContent($thead);
 99: 
100:     // construct the content rows containing the mails
101:     $tbody = new cHTMLTableBody();
102:     // iterate over all logged mails
103:     while (($item = $mailLogCollection->next()) !== false) {
104:         $tr = new cHTMLTableRow();
105:         foreach ($headers as $key => $value) {
106:             $td = new cHTMLTableData();
107:             switch ($key) {
108:                 case 'checkbox':
109:                     $checkbox = new cHTMLCheckbox('', $item->get('idmail'), '', false, '', '', '', 'mark_emails');
110:                     $td->setContent($checkbox->toHtml(false));
111:                     break;
112:                 case 'client':
113:                     $idclient = $item->get('idclient');
114:                     $clientItem = new cApiClient($idclient);
115:                     $td->setContent($clientItem->get('name') . '&nbsp;');
116:                     break;
117:                 case 'from':
118:                 case 'to':
119:                     $addresses = $item->get($key);
120:                     $addresses = mailLogDecodeAddresses($addresses);
121:                     $td->setContent($addresses . '&nbsp;');
122:                     break;
123:                 case 'action':
124:                     // construct the info link
125:                     $img = new cHTMLImage('images/info.gif');
126:                     $link = new cHTMLLink('javascript:void(0)');
127:                     $link->setEvent('click', 'showInfo(' . $item->get('idmail') . ');');
128:                     $link->setContent($img);
129:                     $link->appendStyleDefinition('margin-right', '5px');
130:                     $td->appendContent($link);
131:                     // construct the delete link
132:                     $img = new cHTMLImage('images/delete.gif');
133:                     $link = new cHTMLLink('javascript:void(0)');
134:                     $link->setEvent('click', 'Con.showConfirmation("' . i18n('Do you really want to delete this email?') . '", function() { deleteEmails(' . $item->get('idmail') . '); });return false;');
135:                     $link->setContent($img);
136:                     $td->appendContent($link);
137:                     break;
138:                 default:
139:                     $td->setContent($item->get($key) . '&nbsp;');
140:             }
141:             $tr->appendContent($td);
142:         }
143:         $tbody->appendContent($tr);
144:     }
145:     $table->appendContent($tbody);
146:     $page->appendContent($table);
147: 
148:     // add the bottom bulk editing functions
149:     $page->appendContent(mailLogBulkEditingFunctions());
150: } else if ($area === 'mail_log_detail') {
151:     if (isset($_REQUEST['idmail']) && is_numeric($_REQUEST['idmail'])) {
152:         // construct the back button
153:         $link = new cHTMLLink(cRegistry::getBackendUrl() . 'main.php?area=mail_log&frame=4&contenido=' . cRegistry::getSession()->id);
154:         $image = new cHTMLImage('images/but_back.gif');
155:         $image->appendStyleDefinition('cursor', 'pointer');
156:         $image->appendStyleDefinition('margin-bottom', '10px');
157:         $link->setContent($image);
158:         $page->appendContent($link);
159: 
160:         $idmail = $_REQUEST['idmail'];
161:         // construct the hidden form
162:         $form = new cHTMLForm('', '', 'post', 'action-form');
163:         $form->setVar('area', '');
164:         $form->setVar('frame', '4');
165:         $form->setVar('action', 'mail_log_overview');
166:         $form->setVar('contenido', cRegistry::getSession()->id);
167:         $form->setVar('idmail', $idmail);
168:         $form->setVar('idmails', '[' . $idmail . ']');
169:         $form->setVar('idmailsuccess', '');
170:         $page->appendContent($form);
171: 
172:         // construct the email details table
173:         $tableHeaderDetail = array(
174:             'from' => i18n('From'),
175:             'to' => i18n('To'),
176:             'reply_to' => i18n('Reply to'),
177:             'cc' => i18n('CC'),
178:             'bcc' => i18n('BCC'),
179:             'subject' => i18n('Subject'),
180:             'body' => i18n('Body'),
181:             'created' => i18n('Date')
182:         );
183:         $table = new cHTMLTable();
184:         $table->setClass('generic');
185:         $table->appendStyleDefinition('border-top', '1px solid #B3B3B3');
186:         $mailItem = new cApiMailLog($idmail);
187:         foreach ($tableHeaderDetail as $key => $value) {
188:             $tr = new cHTMLTableRow();
189:             $td = new cHTMLTableData();
190:             $td->setContent($value . '&nbsp;');
191:             $tr->appendContent($td);
192:             switch ($key) {
193:                 // addresses are saved JSON-encoded, so decode them accordingly
194:                 case 'from':
195:                 case 'to':
196:                 case 'reply_to':
197:                 case 'cc':
198:                 case 'bcc':
199:                     $td = new cHTMLTableData();
200:                     $addresses = mailLogDecodeAddresses($mailItem->get($key));
201:                     $td->setContent($addresses . '&nbsp;');
202:                     $tr->appendContent($td);
203:                     break;
204:                 default:
205:                     $td = new cHTMLTableData();
206:                     $data = $mailItem->get($key);
207:                     if ($mailItem->get('content_type') === 'text/plain') {
208:                         $data = nl2br($data);
209:                     }
210:                     $td->setContent($data . '&nbsp;');
211:                     $tr->appendContent($td);
212:             }
213:             $table->appendContent($tr);
214:         }
215:         // construct the action row
216:         $tr = new cHTMLTableRow();
217:         $td = new cHTMLTableData();
218:         $td->setContent(i18n('Action'));
219:         $tr->appendContent($td);
220:         $td = new cHTMLTableData();
221:         $link = new cHTMLLink('javascript:void(0)');
222:         $link->setClass('con_deletemails');
223:         $link->setEvent('click', 'Con.showConfirmation("' . i18n('Do you really want to delete this email?') . '", function() { deleteEmails(' . $idmail . '); });return false;');
224:         $image = new cHTMLImage('images/delete.gif');
225:         $image->setAlt(i18n('Delete emails'));
226:         $link->setContent($image);
227:         $td->setContent($link);
228:         $tr->appendContent($td);
229:         $table->appendContent($tr);
230:         $page->appendContent($table);
231: 
232:         // generate the success table
233:         $successTable = new cHTMLTable();
234:         $successTable->setClass('generic');
235:         $successTable->appendStyleDefinition('margin-top', '20px');
236:         // get all status entries for the given idmail
237:         $mailLogSuccessCollection = new cApiMailLogSuccessCollection();
238:         $mailLogSuccessCollection->select('`idmail`=' . $idmail);
239:         $tr = new cHTMLTableRow();
240:         $th = new cHTMLTableHead();
241:         $th->setContent(i18n('Recipient'));
242:         $tr->appendContent($th);
243:         $th = new cHTMLTableHead();
244:         $th->setContent(i18n('Status'));
245:         $tr->appendContent($th);
246:         $successTable->appendContent($tr);
247: 
248:         // construct a table row for each recipient
249:         while (($mailSuccessItem = $mailLogSuccessCollection->next()) !== false) {
250:             $tr = new cHTMLTableRow();
251:             $td = new cHTMLTableData();
252:             $td->setContent(mailLogDecodeAddresses($mailSuccessItem->get('recipient')));
253:             $tr->appendContent($td);
254:             $td = new cHTMLTableData();
255:             if ($mailSuccessItem->get('success')) {
256:                 // mail has been sent successfully, show OK image
257:                 $image = new cHTMLImage('images/but_ok.gif');
258:                 $image->appendStyleDefinition('display', 'block');
259:                 $image->appendStyleDefinition('margin', '0 auto');
260:                 $image->appendStyleDefinition('padding', '3px');
261:                 $image->setAlt(i18n('Mail sent successfully!'));
262:                 $td->setContent($image);
263:             } else {
264:                 // mail could not be sent yet, show resend button
265:                 $link = new cHTMLLink('javascript:void(0)');
266:                 $link->setEvent('click', 'resendEmail(' . $mailSuccessItem->get('idmailsuccess') . ')');
267:                 $link->setAlt(i18n('Resend email'));
268:                 $image = new cHTMLImage('images/but_refresh.gif');
269:                 $image->appendStyleDefinition('display', 'block');
270:                 $image->appendStyleDefinition('margin', '0 auto');
271:                 $image->appendStyleDefinition('padding', '3px');
272:                 $link->setContent($image);
273:                 $td->setContent($link);
274:             }
275:             $tr->appendContent($td);
276:             $successTable->appendContent($tr);
277:         }
278:         $page->appendContent($successTable);
279:     } else {
280:         // no mail has been selected, show error
281:         $contenidoNotification = new cGuiNotification();
282:         $contenidoNotification->displayNotification('error', i18n('No item selected!'));
283:     }
284: }
285: 
286: $page->render();
287: 
288: /**
289:  * Takes an associative array where the keys represent the mail addresses
290:  * and the values optionally represent the mailer name and returns an HTML
291:  * representation in the following form:
292:  * Vorname Nachname <vorname.nachname@domain.tld>
293:  * Vorname2 Nachname2 <vorname2.nachname2@domain2.tld>
294:  *
295:  * @param array $addresses associative array containing the mail addresses
296:  *        as keys and the mailer names as values
297:  *
298:  * @return string HTML code showing the given mail addresses and names
299:  */
300: function mailLogDecodeAddresses($addresses) {
301:     $result = '';
302:     $addresses = json_decode($addresses, true);
303:     if(!is_array($addresses)) {
304:         return "";
305:     }
306:     foreach ($addresses as $mail => $name) {
307:         $result .= $name . ' &lt;' . $mail . '&gt;<br>';
308:     }
309:     $result = substr($result, 0, strlen($result) - 4);
310: 
311:     return $result;
312: }
313: 
314: function mailLogBulkEditingFunctions() {
315:     $table = new cHTMLTable();
316:     $table->setClass('generic');
317:     $table->setWidth('100%');
318:     $table->appendStyleDefinition('margin', '10px 0');
319:     $tr = new cHTMLTableRow();
320:     $th = new cHTMLTableHead();
321:     $th->appendStyleDefinition('border-bottom', '1px solid #B3B3B3');
322:     // construct the invert selection function
323:     $link = new cHTMLLink();
324:     $link->setClass('flip_mark');
325:     $image = new cHTMLImage('images/but_invert_selection.gif');
326:     $image->setAlt(i18n('Flip Selection'));
327:     $link->appendContent($image);
328:     $link->appendContent(' ' . i18n('Flip Selection'));
329:     $th->appendContent($link);
330: 
331:     // construct the bulk editing functions
332:     $link = new cHTMLLink('javascript:void(0)');
333:     $link->setClass('con_deletemails');
334:     $link->setEvent('click', 'Con.showConfirmation("' . i18n('Do you really want to delete the selected emails?') . '", deleteEmails);return false;');
335:     $image = new cHTMLImage('images/delete.gif');
336:     $image->setAlt(i18n('Delete emails'));
337:     $link->setContent($image);
338:     $div = new cHTMLDiv(i18n('Apply to all selected emails:'), 'bulk_editing_functions');
339:     $div->appendContent($link);
340:     $th->appendContent($div);
341: 
342:     $tr->setContent($th);
343:     $table->setContent($tr);
344: 
345:     return $table;
346: }
347: 
CMS CONTENIDO 4.9.7 API documentation generated by ApiGen