[ Index ]

MailPress 7.1

[ Index ]     [ Classes ]     [ Functions ]     [ Variables ]     [ Constants ]     [ Statistics ]    

title

Body

[close]

/mp-admin/ -> tracking_m.php (source)

   1  <?php
   2  class MP_AdminPage extends MP_WP_Admin_page_list_
   3  {
   4      const screen        = 'mailpress_tracking_m';
   5      const capability    = 'MailPress_tracking_mails';
   6      const help_url        = 'http://blog.mailpress.org/tutorials/add-ons/tracking/';
   7      const file            = __FILE__;
   8  
   9      const map_of        = 'mp_mail';
  10  
  11  ////  Title  ////
  12  
  13  	public static function title() 
  14      { 
  15          new MP_Tracking_metaboxes( 'mail' );
  16  
  17          global $title; 
  18          $title = __( 'Tracking', 'MailPress' ); 
  19      }
  20  
  21  //// Help ////
  22  
  23  	public static function add_help_tab() 
  24      {
  25          global $current_screen;
  26  
  27          $content = '';
  28          $content .= '<p><strong>' . __( 'Tracking Mail :', 'MailPress' ) . '</strong></p>';
  29          $content .= '<p>' . sprintf( __( 'Depending of your choice in %s settings, several boxes are displayed and are reporting the activity tracked for that mail.', 'MailPress' ), sprintf( '<a href="%1$s" target="_blank">%2$s</a>', MailPress_settings . '&tab=tracking', __( 'Tracking', 'MailPress' ) ) ) . '</p>';
  30  
  31          $current_screen->add_help_tab( array(     'id'        => 'overview',
  32                                          'title'        => __( 'Overview' ),
  33                                          'content'    => $content )
  34          );
  35      }
  36  
  37  ////  Styles  ////
  38  
  39  	public static function print_styles( $s ) 
  40      {
  41          $styles = ( is_array( $s ) ) ? $s : array();
  42  
  43          $styles[] = MP_Map::print_styles();
  44  
  45          $styles[] = 'dashboard';
  46  
  47          wp_register_style( 'mp_mail',     '/' . MP_PATH . 'mp-admin/css/mails.css', array( 'thickbox' ) );
  48          $styles[] = 'mp_mail';
  49  
  50          wp_register_style( self::screen,     '/' . MP_PATH . 'mp-admin/css/tracking_m.css' );
  51          $styles[] = self::screen;
  52  
  53          parent::print_styles( $styles );
  54      }
  55  
  56  	public static function print_styles_icons( $i = array( 'browser', 'device', 'domain', 'flag', 'icon', 'os', ) ) 
  57      {
  58          return parent::print_styles_icons( $i );
  59      }
  60  
  61  ////  Scripts  ////
  62  
  63  	public static function print_scripts( $scripts = array() )
  64      {
  65          $scripts = apply_filters( 'MailPress_autorefresh_js', $scripts );
  66  
  67          wp_register_script( 'mp-thickbox',         '/' . MP_PATH . 'mp-includes/js/mp_thickbox.js', array( 'thickbox' ), false, 1 );
  68  
  69          wp_register_script( self::screen,         '/' . MP_PATH . 'mp-admin/js/tracking_t.js', array( 'mp-thickbox', 'postbox' ), false, 1 );
  70          wp_localize_script( self::screen,         'MP_AdminPageL10n',  array( 
  71              'screen' => self::screen
  72           ) );
  73  
  74          $scripts[] = self::screen;
  75          parent::print_scripts( $scripts );
  76      }
  77  
  78  ////  Metaboxes  ////
  79  
  80  	public static function admin_head() 
  81      {
  82          do_action( 'MailPress_tracking_add_meta_box', self::screen );
  83          parent::admin_head();
  84      }
  85  
  86  //// Columns ////
  87  
  88  	public static function get_columns() 
  89      {
  90          $columns = array(    'title'    => __( 'Subject', 'MailPress' ), 
  91                          'author'    => __( 'Author' ), 
  92                          'theme'    => __( 'Theme', 'MailPress' ), 
  93                          'to'        => __( 'To', 'MailPress' ), 
  94                          'date'    => __( 'Date' )
  95          );
  96          $columns = apply_filters( 'MailPress_mails_columns', $columns );
  97          return $columns;
  98      }
  99  
 100  ////  Row  ////
 101  
 102  	public static function get_row( $id, $url_parms, $xtra = false ) 
 103      {
 104          global $mp_mail;
 105  
 106          $mp_mail = $mail = MP_Mail::get( $id );
 107          $the_mail_status = $mail->status;
 108  
 109  // url's
 110          $args = array(    'id'            => $id,
 111                      'action'        => 'mp_ajax',
 112                      'mp_action'    => 'iview',
 113                      'TB_iframe'    => 'true'
 114          );
 115          $view_url = esc_url( add_query_arg( $args, admin_url( 'admin-ajax.php' ) ) );
 116  
 117  // table row 
 118  //    to
 119          $draft_dest = MP_User::get_mailinglists();
 120  
 121          switch ( true )
 122          {
 123              case ( $xtra ) :
 124                  $email_display = '<span class="onerror blinkme">' . $xtra . '</span>';
 125              break;
 126              case ( MailPress::is_email( $mail->toemail ) ) :
 127                  $mail_url = self::url( MailPress_mails, $url_parms );
 128                  $mail_url = remove_query_arg( 's', $mail_url );
 129                  $mail_url = esc_url( add_query_arg( 's', $mail->toemail, $mail_url ) );
 130  
 131                  $email_display = '';
 132  
 133                  if ( get_option( 'show_avatars' ) ) 
 134                  {
 135                      $email_display .= '<div class="tkg_avatar">';
 136                      $email_display .= get_avatar( $mail->toemail, 32 );
 137                      $email_display .= '</div>';
 138                  }
 139                  $email_display .= '<div>';
 140                  $email_display .= '<strong>';
 141                  $email_display .= ( strlen( $mail->toemail ) > 40 ) ? substr( $mail->toemail, 0, 39 ) . '...' : $mail->toemail;
 142                  $email_display .= '</strong>';
 143                  if ( !empty( $mail->toname ) )
 144                  {
 145                      $email_display .= '<br />' . $mail->toname;
 146                  }
 147                  $email_display .= '</div>';
 148              break;
 149              case ( isset( $draft_dest[$mail->toemail] ) ) :
 150                  $email_display = '<strong>' . $draft_dest[$mail->toemail] . '</strong>';
 151              break;
 152              case ( is_serialized( $mail->toemail ) ) :
 153                  $email_display = '<div class="num post-com-count-wrapper"><a class="post-com-count"><span class="comment-count">' . count( unserialize( $mail->toemail ) ) . '</span></a></div>';
 154              break;
 155              default  :
 156                  $email_display = '<span class="onerror">' . __( '(unknown)', 'MailPress' ) . '</span>';
 157                  unset( $actions['send'] );
 158              break;
 159          }
 160          $email_display = apply_filters( 'MailPress_to_mails_column', $email_display, $mail );
 161          if ( $mailinglist_desc = MP_Mail_meta::get( $mail->id, '_mailinglist_desc' ) )
 162          {
 163              $email_display = '<div>' . $email_display . '</div>' . $mailinglist_desc;
 164          }
 165  //    author
 166          $author = ( 0 == $mail->sent_user_id ) ? $mail->created_user_id : $mail->sent_user_id;
 167          if ( $author != 0 && is_numeric( $author ) ) 
 168          {
 169              unset( $url_parms['author'] );
 170              $wp_user         = get_userdata( $author );
 171          }
 172  //    subject
 173          $metas = MP_Mail_meta::get( $id, '_MailPress_replacements' );
 174          $subject_display = $mail->subject;
 175          if ( $metas )
 176          {
 177              foreach( $metas as $k => $v )
 178              {
 179                  $subject_display = str_replace( $k, $v, $subject_display );
 180              }
 181          }
 182  
 183          $title_title    = esc_attr( sprintf( ( 'draft' == $mail->status ) ?  __( 'Edit &#8220;%1$s&#8221;', 'MailPress' ) : __( 'View &#8220;%1$s&#8221;', 'MailPress' ) , ( '' == $subject_display ) ? __( '(no subject)', 'MailPress' ) : htmlspecialchars( $subject_display, ENT_QUOTES ) ) );
 184  
 185  //    attachments
 186          $attach = false;
 187          $metas = MP_Mail_meta::has( $id, '_MailPress_attached_file' );
 188          if ( $metas )
 189          {
 190              foreach( $metas as $meta )
 191              {
 192                  $meta_value = unserialize( $meta['meta_value'] );
 193                  if ( is_file( $meta_value['file_fullpath'] ) )
 194                  {
 195                      $attach = true;
 196                      break;
 197                  }
 198              }
 199          }
 200  
 201          $out = '';
 202          $out .= '<tr id="mail-' . $id . '">';
 203  
 204          $columns = self::get_columns();
 205          $hidden  = self::get_hidden_columns();
 206  
 207          foreach ( $columns as $column_name => $column_display_name ) 
 208          {
 209              $attributes = sprintf( 'class="%1$s column-%1$s%2$s%3$s"', $column_name, ( in_array( $column_name, $hidden ) ) ? ' hidden' : '', ( 'unsent' == $mail->status ) ? ' fi' : '' );
 210  
 211              switch ( $column_name ) 
 212              {
 213                  case 'title':
 214                      $attributes = sprintf( 'class="post-title column-title%2$s%3$s"', $column_name, ( in_array( $column_name, $hidden ) ) ? ' hidden' : '', ( 'unsent' == $mail->status ) ? ' fi' : '' );
 215  
 216                      $out .= '<td ' . $attributes . '>';
 217                      if ( 'paused' == $mail->status )
 218                      {
 219                          $out .= '<span class="mp_icon mp_icon_paused" title="' . esc_attr( __( 'Paused', 'MailPress' ) ) . '"></span>';
 220                      }
 221                      if ( $attach )
 222                      {
 223                          $out .= '<span class="mp_icon mp_icon_attachment" title="' . esc_attr( __( 'Attachments', 'MailPress' ) ) . '"></span>';
 224                      }
 225                      $out .= apply_filters( 'MailPress_get_icon_mails', '', $id );
 226  
 227                      $out .= '<strong>';
 228                      $out .= '<a class="row-title thickbox thickbox-preview" href="' . $view_url . '" title="' . esc_attr( $title_title ) . '">';
 229                      $out .= ( '' == $subject_display ) ? __( '(no subject)', 'MailPress' ) : ( ( strlen( $subject_display ) > 40 ) ? $subject_display = mb_substr( $subject_display, 0, 39, get_option( 'blog_charset' ) ) . '...' : $subject_display );
 230                      $out .= '</a>';
 231  
 232                      switch ( $mail->status ) 
 233                      {
 234                          case 'paused' :
 235                              $out .= ' - ' . __( 'Paused', 'MailPress' );
 236                          break;
 237                          case 'archived' :
 238                              $out .= ' - ' . __( 'Archive', 'MailPress' );
 239                          break;
 240                      }
 241                      $out .= '</strong>';
 242                      $out .= '</td>';
 243                  break;
 244                  case 'author':
 245                      $out .= '<td ' . $attributes . '>';
 246                      if ( $author != 0 && is_numeric( $author ) )
 247                      {
 248                          $out .= $wp_user->display_name;
 249                      }
 250                      else
 251                      {
 252                          $out .= __( '(unknown)', 'MailPress' );
 253                      }
 254                      $out .= '</td>';
 255                  break;
 256                  case 'theme':
 257                      $out .= '<td ' . $attributes . '>';
 258                      $out .= $mail->theme;
 259                      if ( '' != $mail->template )
 260                      {
 261                          $out .=  '<br />(' . $mail->template . ')';
 262                      }
 263                      $out .= '</td>';
 264                  break;
 265                  case 'to':
 266                      $out .= '<td ' . $attributes . '>';
 267                      $out .= $email_display;
 268                      $out .= '</td>';
 269                  break;
 270                  case 'date':
 271                      $t_time = self::get_mail_date( __( 'Y/m/d H:i:s' ) );
 272                      $h_time = self::human_time_diff( self::get_mail_date_raw() );
 273  
 274                      $out .= '<td ' . $attributes . '>';
 275                      $out .= '<abbr title="' . $t_time . '">' . $h_time . '</abbr>';
 276                      $out .= '</td>';
 277                  break;
 278                  default:
 279                      $out .= '<td ' . $attributes . '>';
 280                      $out .= apply_filters( 'MailPress_mails_get_row', '', $column_name, $mail, $url_parms );
 281                      $out .= '</td>';
 282                  break;
 283              }
 284          }
 285          $out .= '</tr>';
 286  
 287          return $out;
 288      }
 289  
 290  	public static function get_mail_date( $d = '' ) {
 291          $x = self::get_mail_date_raw();
 292          return ( '' == $d ) ? mysql2date( get_option( 'date_format' ), $x ) : mysql2date( $d, $x );
 293      }
 294  
 295  	public static function get_mail_date_raw() {
 296          global $mp_mail;
 297          $x = ( $mp_mail->sent >= $mp_mail->created ) ? $mp_mail->sent : $mp_mail->created;
 298          return $x;
 299      }
 300  }


Generated: Mon Mar 11 18:33:33 2019 Cross-referenced by PHPXref 0.7.1