b2evolution PHP Cross Reference Blogging Systems

Source: /inc/newsletter/newsletter.ctrl.php - 128 lines - 4313 bytes - Text - Print

Description: This file is part of b2evolution - {@link http://b2evolution.net/} See also {@link http://sourceforge.net/projects/evocms/}.

   1  <?php
   2  /**

   3   * This file is part of b2evolution - {@link http://b2evolution.net/}

   4   * See also {@link http://sourceforge.net/projects/evocms/}.

   5   *

   6   * @copyright (c)2009-2014 by Francois PLANQUE - {@link http://fplanque.net/}

   7   * Parts of this file are copyright (c)2009 by The Evo Factory - {@link http://www.evofactory.com/}.

   8   *

   9   * Released under GNU GPL License - {@link http://b2evolution.net/about/license.html}

  10   *

  11   * {@internal Open Source relicensing agreement:

  12   * The Evo Factory grants Francois PLANQUE the right to license

  13   * The Evo Factory's contributions to this file and the b2evolution project

  14   * under any OSI approved OSS license (http://www.opensource.org/licenses/).

  15   * }}

  16   *

  17   * @package messaging

  18   *

  19   * {@internal Below is a list of authors who have contributed to design/coding of this file: }}

  20   * @author fplanque: Francois Planque.

  21   *

  22   * @version $Id: newsletter.ctrl.php 657 2012-01-04 11:53:26Z yura $

  23   */
  24  
  25  if( !defined('EVO_MAIN_INIT') ) die( 'Please, do not access this page directly.' );
  26  
  27  global $users_all, $users_active, $users_newsletter;
  28  
  29  load_funcs( 'newsletter/model/_newsletter.funcs.php' );
  30  
  31  $current_User->check_perm( 'users', 'edit', true );
  32  
  33  // Get users info for newsletter

  34  $users_numbers = get_newsletter_users_numbers();
  35  
  36  if( $users_numbers['all'] == 0 )
  37  {    // No users in the filterset, Redirect to users list
  38      $Messages->add( T_('No found accounts in filterset. Please try to change the filter of users list.'), 'error' );
  39      header_redirect( $admin_url.'?ctrl=users' );
  40  }
  41  
  42  if( $users_numbers['newsletter'] == 0 )
  43  {    // No users for newsletter
  44      $Messages->add( T_('No found active accounts which accept newsletter email. Please try to change the filter of users list.'), 'note' );
  45  }
  46  
  47  param_action();
  48  
  49  /*

  50   * Perform actions:

  51   */
  52  switch( $action )
  53  {
  54      case 'preview':
  55          // Check that this action request is not a CSRF hacked request:

  56          $Session->assert_received_crumb( 'newsletter' );
  57  
  58          param( 'title', 'string' );
  59          param_check_not_empty( 'title', T_('Please enter a title.') );
  60  
  61          param( 'message', 'text' );
  62          param_check_not_empty( 'message', T_('Please enter a message.') );
  63          
  64          $Session->set( 'newsletter_title', $title );
  65          $Session->set( 'newsletter_message', $message );
  66          $Session->dbsave();
  67  
  68          if( $Messages->has_errors() )
  69          {    // Errors
  70              header_redirect( $admin_url.'?ctrl=newsletter' );
  71          }
  72          break;
  73  
  74      case 'send':
  75          // Check that this action request is not a CSRF hacked request:

  76          $Session->assert_received_crumb( 'newsletter' );
  77  
  78          $Messages->add( T_('Newsletter is sending now, please see a report below...'), 'success' );
  79          break;
  80  }
  81  
  82  $AdminUI->breadcrumbpath_init( false );  // fp> I'm playing with the idea of keeping the current blog in the path here...

  83  $AdminUI->breadcrumbpath_add( T_('Users'), '?ctrl=users' );
  84  $AdminUI->breadcrumbpath_add( T_('List'), '?ctrl=users' );
  85  $AdminUI->breadcrumbpath_add( T_('Newsletter'), '?ctrl=newsletter' );
  86  $AdminUI->set_path( 'users', 'users' );
  87  
  88  
  89  // Display <html><head>...</head> section! (Note: should be done early if actions do not redirect)

  90  $AdminUI->disp_html_head();
  91  
  92  // Display title, menu, messages, etc. (Note: messages MUST be displayed AFTER the actions)

  93  $AdminUI->disp_body_top();
  94  
  95  $AdminUI->disp_payload_begin();
  96  
  97  /*

  98   * Display appropriate payload:

  99   */
 100  switch( $action )
 101  {
 102      case 'preview':
 103          $email_newsletter_params = array(
 104                  'message' => $Session->get( 'newsletter_message' )
 105              );
 106          $newsletter = array(
 107                  'title' => mail_autoinsert_user_data( $Session->get( 'newsletter_title' ), $current_User ),
 108                  'html'  => mail_autoinsert_user_data( mail_template( 'newsletter', 'html', $email_newsletter_params, $current_User ), $current_User ),
 109                  'text'  => mail_autoinsert_user_data( mail_template( 'newsletter', 'text', $email_newsletter_params, $current_User ), $current_User )
 110              );
 111          $AdminUI->disp_view( 'newsletter/views/_newsletter_preview.view.php' );
 112          break;
 113  
 114      case 'send':
 115          $AdminUI->disp_view( 'newsletter/views/_newsletter_report.view.php' );
 116          break;
 117  
 118      default:
 119          $AdminUI->disp_view( 'newsletter/views/_newsletter.form.php' );
 120          break;
 121  }
 122  
 123  $AdminUI->disp_payload_end();
 124  
 125  // Display body bottom, debug info and close </html>:

 126  $AdminUI->disp_global_footer();
 127  
 128  ?>

title

Description

title

Description

title

Description

title

title

Body