[ Index ]

MailPress 7.1

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

title

Body

[close]

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

   1  <?php
   2  class MP_AdminPage extends MP_WP_Admin_page_list_
   3  {
   4      const screen        = 'mailpress_tracking_u';
   5      const capability    = 'MailPress_tracking_users';
   6      const help_url        = 'http://blog.mailpress.org/tutorials/add-ons/tracking/';
   7      const file            = __FILE__;
   8  
   9      const map_of        = 'mp_user';
  10  
  11  ////  Title  ////
  12  
  13  	public static function title() 
  14      {
  15          new MP_Tracking_metaboxes( 'user' );
  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 User :', '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 mp user.', '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_users',         '/' . MP_PATH . 'mp-admin/css/users.css' );
  48          $styles[] = 'mp_users';
  49  
  50          wp_register_style( self::screen,     '/' . MP_PATH . 'mp-admin/css/tracking_u.css' );
  51          $styles[] = self::screen;
  52  
  53          parent::print_styles( $styles );
  54      }
  55  
  56  	public static function print_styles_icons( $i = array( 'browser', 'device', '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( self::screen,         '/' . MP_PATH . 'mp-admin/js/tracking_t.js', array( 'postbox' ), false, 1 );
  68          wp_localize_script( self::screen,         'MP_AdminPageL10n',  array( 'screen' => self::screen ) );
  69  
  70          $scripts[] = self::screen;
  71          parent::print_scripts( $scripts );
  72      }
  73  
  74  ////  Metaboxes  ////
  75  
  76  	public static function admin_head() 
  77      {
  78          do_action( 'MailPress_tracking_add_meta_box', self::screen );
  79          parent::admin_head();
  80      }
  81  
  82  //// Columns ////
  83  
  84  	public static function get_columns() 
  85      {
  86          $columns = array(    'title'        => __( 'E-mail', 'MailPress' ),
  87                          'user_name'    => __( 'Name', 'MailPress' ),
  88                          'author'        => __( 'Author' ),
  89                          'date'        => __( 'Date' )
  90          );
  91          $columns = apply_filters( 'MailPress_users_columns', $columns );
  92          return $columns;
  93      }
  94  
  95  ////  Row  ////
  96  
  97  	public static function get_row( $id, $url_parms, $xtra = false )
  98      {
  99          add_filter( 'MailPress_get_icon_users',     array( __CLASS__, 'get_icon_users' ), 8, 2 ); // just one row !
 100  
 101          global $mp_user;
 102  
 103          $mp_user = $user = MP_User::get( $id );
 104          $the_user_status = $user->status;
 105  
 106  // url's
 107          $args = array();
 108          $args['id'] = $id;
 109  
 110          $edit_url = esc_url( self::url( MailPress_user, array_merge( $args, $url_parms ) ) );
 111  
 112          $author = ( 0 == $user->laststatus_user_id ) ? $user->created_user_id : $user->laststatus_user_id;
 113          if ( $author != 0 && is_numeric( $author ) )
 114          {
 115              unset( $url_parms['author'] );
 116              $wp_user = get_userdata( $author );
 117              $author_url = esc_url( self::url( MailPress_users, array_merge( array( 'author'=>$author ), $url_parms ) ) );
 118          }
 119  
 120  // actions
 121          $actions = array();
 122          $actions['edit'] = '<a href="' . $edit_url . '"  title="' . esc_attr( sprintf( __( 'Edit &#8220;%1$s&#8221;', 'MailPress' ), $mp_user->email ) ) . '">' . __( 'Edit' ) . '</a>';
 123  
 124  // table row 
 125  //    class
 126          $row_class = '';
 127          if ( 'waiting' == $the_user_status ) $row_class = 'unapproved';
 128          if ( 'bounced' == $the_user_status ) $row_class = 'bounced';
 129          if ( 'unsubscribed' == $the_user_status ) $row_class = 'unsubscribed';
 130  
 131          $out = '';
 132          $out .= '<tr id="user-' . $id . '" class="' . $row_class . '">';
 133  
 134          $columns = self::get_columns();
 135          $hidden  = self::get_hidden_columns();
 136  
 137          foreach ( $columns as $column_name => $column_display_name ) 
 138          {
 139              $attributes = sprintf( 'class="%1$s column-%1$s%2$s%3$s"', $column_name, ( in_array( $column_name, $hidden ) ) ? ' hidden' : '', ( in_array( $user->status, array('bounced', 'unsubscribed') ) ) ? ' fi' : '' );
 140  
 141              switch ( $column_name ) 
 142              {
 143                  case 'title' :
 144                      $attributes = sprintf( 'class="username column-username%2$s%3$s"', $column_name, ( in_array( $column_name, $hidden ) ) ? ' hidden' : '', ( in_array( $user->status, array('bounced', 'unsubscribed') ) ) ? ' fi' : '' );
 145  
 146                      $out .= '<td ' . $attributes . '>';
 147                      $out .= self::get_flag_IP();
 148                      $out .= apply_filters( 'MailPress_get_icon_users', '', $mp_user ); 
 149                      $out .= ( get_option( 'show_avatars' ) ) ? get_avatar( $user->email, 32 ) : '';
 150                      $out .= '<strong>';
 151                      $out .= '<a class="row-title" href="' . $edit_url . '" title="' . esc_attr( sprintf( __( 'Edit &#8220;%1$s&#8221;', 'MailPress' ) ,$user->email ) ) . '">';
 152                      $out .= $mp_user->email;
 153                      $out .= '</a>';
 154                      $out .= '</strong>';
 155                      $out .= self::get_actions( $actions );
 156                      $out .= '</td>';
 157                  break;
 158                  case 'user_name' :
 159                      $out .= '<td ' . $attributes . '>';
 160                      $out .= '<abbr title="' . esc_attr( $user->name ) . '">' . esc_attr( $user->name ) . '</abbr>';
 161                      $out .= '</td>';
 162                  break;
 163                  case 'date' :
 164  
 165                      $t_time = self::get_user_date( __( 'Y/m/d H:i:s' ) );
 166                      $h_time = self::human_time_diff( self::get_user_date_raw() );
 167  
 168                      $out .= '<td ' . $attributes . '>';
 169                      $out .= '<abbr title="' . $t_time . '">' . $h_time . '</abbr>';
 170                      $out .= '</td>';
 171                  break;
 172                  case 'author' :
 173                      $out .= '<td ' . $attributes . '>';
 174                      if ( $author != 0 && is_numeric( $author ) )
 175                      {
 176                          $out .= '<a href="' . $author_url . '" title="' . esc_attr( sprintf( __( 'Users by &#8220;%1$s&#8221;', 'MailPress' ), $wp_user->display_name ) ) . '">' . $wp_user->display_name . '</a>';
 177                      }
 178                      else
 179                      {
 180                          $out .= __( '(unknown)', 'MailPress' );
 181                      }
 182                      $out .= '</td>';
 183                  break;
 184                  default:
 185                      $out .= '<td ' . $attributes . '>';
 186                      $out .= apply_filters( 'MailPress_users_get_row', '', $column_name, $user, $url_parms );
 187                      $out .= '</td>';
 188                  break;
 189              }
 190          }
 191          $out .= '</tr>';
 192  
 193          return $out;
 194      }
 195  
 196  	public static function get_user_date( $d = '' ) {
 197          $x = self::get_user_date_raw();
 198          return ( '' == $d ) ? mysql2date( get_option( 'date_format' ), $x ) : mysql2date( $d, $x );
 199      }
 200  
 201  	public static function get_user_date_raw() {
 202          global $mp_user;
 203          return ( $mp_user->created >= $mp_user->laststatus ) ? $mp_user->created : $mp_user->laststatus;
 204      }
 205  
 206  	public static function get_user_author_IP() {
 207          global $mp_user;
 208          $ip = ( '' == $mp_user->laststatus_IP ) ? $mp_user->created_IP : $mp_user->laststatus_IP;
 209          return $ip;
 210      }
 211  
 212  	public static function get_flag_IP()     {
 213          global $mp_user;
 214          return ( ( 'ZZ' == $mp_user->created_country ) || empty( $mp_user->created_country ) ) ? '' : '<div class="mp_flag mp_flag_' . strtolower( $mp_user->created_country ) . '" title="' . esc_attr( strtolower( $mp_user->created_country ) ) . '"></div>';
 215      }
 216  
 217  	public static function get_icon_users( $out, $mp_user )
 218      {
 219          if ( 'unsubscribed' == $mp_user->status )
 220          {
 221              $out .= '<span class="mp_icon mp_icon_unsubscribed" title="' . esc_attr( __( 'Unsubscribed', 'MailPress' ) ) . '"></span>';
 222          }
 223          return $out;
 224      }
 225  }


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