b2evolution PHP Cross Reference Blogging Systems

Source: /inc/tools/views/_email_blocked.view.php - 282 lines - 10058 bytes - Summary - Text - Print

Description: This file implements the UI view for Tools > Email > Addresses This file is part of the evoCore framework - {@link http://evocore.net/} See also {@link http://sourceforge.net/projects/evocms/}.

   1  <?php
   2  /**

   3   * This file implements the UI view for Tools > Email > Addresses

   4   *

   5   * This file is part of the evoCore framework - {@link http://evocore.net/}

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

   7   *

   8   * @copyright (c)2003-2014 by Francois Planque - {@link http://fplanque.com/}

   9   *

  10   * {@internal License choice

  11   * - If you have received this file as part of a package, please find the license.txt file in

  12   *   the same folder or the closest folder above for complete license terms.

  13   * - If you have received this file individually (e-g: from http://evocms.cvs.sourceforge.net/)

  14   *   then you must choose one of the following licenses before using the file:

  15   *   - GNU General Public License 2 (GPL) - http://www.opensource.org/licenses/gpl-license.php

  16   *   - Mozilla Public License 1.1 (MPL) - http://www.opensource.org/licenses/mozilla1.1.php

  17   * }}

  18   *

  19   * {@internal Open Source relicensing agreement:

  20   * }}

  21   *

  22   * @package admin

  23   *

  24   * @version $Id: _email_blocked.view.php 349 2011-11-18 11:18:14Z yura $

  25   */
  26  if( !defined('EVO_MAIN_INIT') ) die( 'Please, do not access this page directly.' );
  27  
  28  global $blog, $admin_url, $UserSettings, $email, $statuses;
  29  
  30  param( 'email', 'string', '', true );
  31  param( 'statuses', 'array/string', array( 'warning', 'suspicious3' ), true );
  32  
  33  // Create result set:

  34  
  35  $SQL = new SQL();
  36  $SQL->SELECT( 'SQL_NO_CACHE emblk_ID, emblk_address, emblk_status, emblk_last_sent_ts, emblk_sent_count, emblk_sent_last_returnerror, emblk_last_error_ts, 
  37  ( emblk_prmerror_count + emblk_tmperror_count + emblk_spamerror_count + emblk_othererror_count ) AS emblk_all_count,
  38  emblk_prmerror_count, emblk_tmperror_count, emblk_spamerror_count, emblk_othererror_count, 
  39  COUNT( user_ID ) AS users_count' );
  40  $SQL->FROM( 'T_email__blocked' );
  41  $SQL->FROM_add( 'LEFT JOIN T_users ON user_email = emblk_address' );
  42  $SQL->GROUP_BY( 'emblk_ID' );
  43  
  44  $CountSQL = new SQL();
  45  $CountSQL->SELECT( 'SQL_NO_CACHE COUNT(emblk_ID)' );
  46  $CountSQL->FROM( 'T_email__blocked' );
  47  
  48  if( !empty( $email ) )
  49  {    // Filter by email
  50      $SQL->WHERE_and( 'emblk_address LIKE '.$DB->quote( $email ) );
  51      $CountSQL->WHERE_and( 'emblk_address LIKE '.$DB->quote( $email ) );
  52  }
  53  if( !empty( $statuses ) )
  54  {    // Filter by statuses
  55      $SQL->WHERE_and( 'emblk_status IN ('.$DB->quote( $statuses ).')' );
  56      $CountSQL->WHERE_and( 'emblk_status IN ('.$DB->quote( $statuses ).')' );
  57  }
  58  
  59  $Results = new Results( $SQL->get(), 'emblk_', '---D', $UserSettings->get( 'results_per_page' ), $CountSQL->get() );
  60  
  61  $Results->title = T_('Email addresses');
  62  
  63  $Results->global_icon( T_('Create a new email address...'), 'new', $admin_url.'?ctrl=email&amp;tab=blocked&amp;action=blocked_new', T_('Add an email address').' &raquo;', 3, 4 );
  64  
  65  /**

  66   * Callback to add filters on top of the result set

  67   *

  68   * @param Form

  69   */
  70  function filter_email_blocked( & $Form )
  71  {
  72      $Form->text_input( 'email', get_param( 'email' ), 40, T_('Email') );
  73  
  74      $statuses = emblk_get_status_titles();
  75      foreach( $statuses as $status_value => $status_title )
  76      {    // Display the checkboxes to filter by status
  77          $Form->checkbox( 'statuses[]', in_array( $status_value, get_param( 'statuses' ) ), $status_title, '', '', $status_value );
  78      }
  79  }
  80  $Results->filter_area = array(
  81      'callback' => 'filter_email_blocked',
  82      'presets' => array(
  83          'all'       => array( T_('All'), $admin_url.'?ctrl=email&amp;tab=blocked&amp;statuses[]=unknown&amp;statuses[]=warning&amp;statuses[]=suspicious1&amp;statuses[]=suspicious2&amp;statuses[]=suspicious3&amp;statuses[]=prmerror&amp;statuses[]=spammer'),
  84          'errors'    => array( T_('Errors'), $admin_url.'?ctrl=email&amp;tab=blocked&amp;statuses[]=warning&amp;statuses[]=suspicious1&amp;statuses[]=suspicious2&amp;statuses[]=suspicious3&amp;statuses[]=prmerror&amp;statuses[]=spammer'),
  85          'attention' => array( T_('Need Attention'), $admin_url.'?ctrl=email&amp;tab=blocked&amp;statuses[]=warning&amp;statuses[]=suspicious3'),
  86          )
  87      );
  88  
  89  /**

  90   * Decode the special symbols

  91   * It used to avoid an error, because a symbol '%' is special symbol of class Result to parse the functions

  92   *

  93   * @param string Url

  94   * @param string Url

  95   */
  96  function url_decode_special_symbols( $url )
  97  {
  98      return str_replace(
  99              array( '%5B', '%5D' ),
 100              array( '[',   ']' ),
 101              $url
 102          );
 103  }
 104  $Results->cols[] = array(
 105          'th' => T_('ID'),
 106          'order' => 'emblk_ID',
 107          'th_class' => 'shrinkwrap',
 108          'td_class' => 'right',
 109          'td' => '$emblk_ID$',
 110      );
 111  
 112  $Results->cols[] = array(
 113          'th' => T_('Address'),
 114          'order' => 'emblk_address',
 115          'td' => '<a href="'.url_decode_special_symbols( regenerate_url( 'email,action,emblk_ID', 'email=$emblk_address$' ) ).'">$emblk_address$</a>',
 116          'th_class' => 'shrinkwrap',
 117      );
 118  
 119  $Results->cols[] = array(
 120          'th' => T_('Status'),
 121          'order' => 'emblk_status',
 122          'td' => '$emblk_status$',
 123          'td' => /* Check permission: */$current_User->check_perm( 'emails', 'edit' ) ?
 124              /* Current user can edit emails */'<a href="#" rel="$emblk_status$">%emblk_get_status_title( #emblk_status# )%</a>' :
 125              /* No edit, only view the status */'%emblk_get_status_title( #emblk_status# )%',
 126          'th_class' => 'shrinkwrap',
 127          'td_class' => 'shrinkwrap emblk_status_edit',
 128          'extra' => array ( 'style' => 'background-color: %emblk_get_status_color( "#emblk_status#" )%;', 'format_to_output' => false )
 129      );
 130  
 131  $Results->cols[] = array(
 132          'th_group' => T_('Send messages'),
 133          'th' => T_('Last sent date'),
 134          'order' => 'emblk_last_sent_ts',
 135          'default_dir' => 'D',
 136          'td_class' => 'timestamp',
 137          'td' => '%mysql2localedatetime_spans( #emblk_last_sent_ts#, "M-d" )%',
 138      );
 139  
 140  $Results->cols[] = array(
 141          'th_group' => T_('Send messages'),
 142          'th' => T_('Sent count'),
 143          'order' => 'emblk_sent_count',
 144          'default_dir' => 'D',
 145          'td' => '<a href="'.$admin_url.'?ctrl=email&amp;tab=sent&amp;filter=new&amp;email=$emblk_address$">$emblk_sent_count$</a>',
 146          'td_class' => 'right'
 147      );
 148  
 149  $Results->cols[] = array(
 150          'th_group' => T_('Send messages'),
 151          'th' => T_('Since last error'),
 152          'order' => 'emblk_sent_last_returnerror',
 153          'default_dir' => 'D',
 154          'td' => '$emblk_sent_last_returnerror$',
 155          'td_class' => 'right'
 156      );
 157  
 158  $Results->cols[] = array(
 159          'th_group' => T_('Returned error messages'),
 160          'th' => T_('Last error date'),
 161          'order' => 'emblk_last_error_ts',
 162          'default_dir' => 'D',
 163          'td_class' => 'timestamp',
 164          'td' => '%mysql2localedatetime_spans( #emblk_last_error_ts#, "M-d" )%',
 165      );
 166  
 167  $Results->cols[] = array(
 168          'th_group' => T_('Returned error messages'),
 169          'th' => T_('Count'),
 170          'order' => 'emblk_all_count',
 171          'default_dir' => 'D',
 172          'td' => '$emblk_all_count$',
 173          'td_class' => 'right'
 174      );
 175  
 176  $Results->cols[] = array(
 177          'th_group' => T_('Returned error messages'),
 178          'th' => T_('Permanent errors'),
 179          'order' => 'emblk_prmerror_count',
 180          'default_dir' => 'D',
 181          'td' => '$emblk_prmerror_count$',
 182          'td_class' => 'right'
 183      );
 184  
 185  $Results->cols[] = array(
 186          'th_group' => T_('Returned error messages'),
 187          'th' => T_('Temporary errors'),
 188          'order' => 'emblk_tmperror_count',
 189          'default_dir' => 'D',
 190          'td' => '$emblk_tmperror_count$',
 191          'td_class' => 'right'
 192      );
 193  
 194  $Results->cols[] = array(
 195          'th_group' => T_('Returned error messages'),
 196          'th' => T_('Spam errors'),
 197          'order' => 'emblk_spamerror_count',
 198          'default_dir' => 'D',
 199          'td' => '$emblk_spamerror_count$',
 200          'td_class' => 'right'
 201      );
 202  
 203  $Results->cols[] = array(
 204          'th_group' => T_('Returned error messages'),
 205          'th' => T_('Other errors'),
 206          'order' => 'emblk_othererror_count',
 207          'default_dir' => 'D',
 208          'td' => '$emblk_othererror_count$',
 209          'td_class' => 'right'
 210      );
 211  
 212  $Results->cols[] = array(
 213          'th' => T_('Users'),
 214          'order' => 'users_count',
 215          'default_dir' => 'D',
 216          'td' => '<a href="'.$admin_url.'?ctrl=users&amp;filter=new&amp;keywords=$emblk_address$" title="'.format_to_output( T_('Go to users list with this email address'), 'htmlattr' ).'">$users_count$</a>',
 217          'td_class' => 'right'
 218      );
 219  
 220  $Results->cols[] = array(
 221          'th' => T_('Actions'),
 222          'th_class' => 'shrinkwrap',
 223          'td_class' => 'shrinkwrap',
 224          'td' => action_icon( T_('Filter the returned emails by this email address...'), 'magnifier', $admin_url.'?ctrl=email&amp;tab=return&amp;email=$emblk_address$' )
 225              .action_icon( T_('Edit this email address...'), 'properties', $admin_url.'?ctrl=email&amp;tab=blocked&amp;emblk_ID=$emblk_ID$' )
 226              .action_icon( T_('Delete this email address!'), 'delete', url_decode_special_symbols( regenerate_url( 'emblk_ID,action', 'emblk_ID=$emblk_ID$&amp;action=blocked_delete&amp;'.url_crumb('email_blocked') ) ) )
 227      );
 228  
 229  // Display results:

 230  $Results->display();
 231  
 232  if( $current_User->check_perm( 'emails', 'edit' ) )
 233  {    // Check permission to edit emails:
 234  ?>
 235  <script type="text/javascript">
 236  jQuery( document ).ready( function()
 237  {
 238      jQuery( '.emblk_status_edit' ).editable( htsrv_url + 'async.php?action=emblk_status_edit&<?php echo url_crumb( 'emblkstatus' )?>',
 239      {
 240      data : function( value, settings )
 241          {
 242              value = ajax_debug_clear( value );
 243              var re =  /rel="(.*)"/;
 244              var result = value.match(re);
 245              return {<?php
 246  $status_titles = emblk_get_status_titles();
 247  foreach( $status_titles as $status_value => $status_title )
 248  {
 249      echo '    \''.$status_value.'\': \''.$status_title.'\',';
 250  }
 251  ?>
 252                  'selected' : result[1]
 253              }
 254          },
 255      type     : 'select',
 256      name     : 'new_status',
 257      tooltip  : 'Click to edit',
 258      event    : 'click',
 259      callback : function( settings, original )
 260          {
 261              //evoFadeSuccess( this );

 262              jQuery( this ).html( ajax_debug_clear( settings ) );
 263              var link = jQuery( this ).find( 'a' );
 264              jQuery( this ).css( 'background-color', link.attr( 'color' ) );
 265              link.removeAttr( 'color' );
 266          },
 267      onsubmit: function( settings, original ) {
 268      },
 269      submitdata: function( value, settings ) {
 270              var id = jQuery( ':first', jQuery( this ).parent() ).text();
 271              return { emblk_ID: id }
 272          },
 273      onerror : function( settings, original, xhr ) {
 274              evoFadeFailure( original );
 275          }
 276      } );
 277  } );
 278  </script>
 279  <?php
 280  }
 281  
 282  ?>

title

Description

title

Description

title

Description

title

title

Body