[ Index ]

MailPress 544

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

title

Body

[close]

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

   1  <?php
   2  class MP_AdminPage extends MP_adminpage_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  ////  Title  ////
  10  
  11  	public static function title() 
  12      {
  13          new MP_Tracking_metaboxes('user');
  14  
  15          global $title; 
  16          $title = __('Tracking', MP_TXTDOM); 
  17      }
  18  
  19  ////  Styles  ////
  20  
  21  	public static function print_styles($styles = array()) 
  22      {
  23          $styles[] = 'dashboard';
  24  
  25          wp_register_style ('mp_user',     '/' . MP_PATH . 'mp-admin/css/users.css' );
  26          $styles[] = 'mp_user';
  27  
  28          wp_register_style ( self::screen,     '/' . MP_PATH . 'mp-admin/css/tracking_u.css' );
  29  
  30          $styles[] = self::screen;
  31          parent::print_styles($styles);
  32      }
  33  
  34  ////  Scripts  ////
  35  
  36  	public static function print_scripts($scripts = array())  
  37      {
  38          $scripts = apply_filters('MailPress_autorefresh_js', $scripts);
  39  
  40          wp_register_script( self::screen,         '/' . MP_PATH . 'mp-admin/js/tracking_t.js', array('postbox'), false, 1);
  41          wp_localize_script( self::screen,         'MP_AdminPageL10n',  array(
  42              'screen' => self::screen
  43          ));
  44  
  45          $scripts[] = self::screen;
  46  
  47          parent::print_scripts($scripts);
  48      }
  49  
  50  ////  Metaboxes  ////
  51  
  52  	public static function screen_meta() 
  53      {
  54          do_action('MailPress_tracking_add_meta_box', self::screen);
  55          parent::screen_meta();
  56      }
  57  
  58  //// Columns ////
  59  
  60  	public static function get_columns() 
  61      {
  62          $columns = array(    'title'     => __('E-mail', MP_TXTDOM), 
  63                      'user_name'    => __('Name', MP_TXTDOM), 
  64                      'author'     => __('Author'), 
  65                      'date'    => __('Date'));
  66          $columns = apply_filters('MailPress_users_columns', $columns);
  67          return $columns;
  68      }
  69  
  70  	public static function columns_list($id = true)
  71      {
  72          $columns = self::get_columns();
  73          $hidden  = array();
  74          foreach ( $columns as $key => $display_name ) 
  75          {
  76              $thid  = ( $id ) ? " id='$key'" : '';
  77              $class = ( 'cb' === $key ) ? " class='check-column'" : " class='manage-column column-$key'";
  78              $style = ( in_array($key, $hidden) ) ? " style='display:none;'" : '';
  79  
  80              echo "<th$thid$class$style>$display_name</th>";
  81          } 
  82      }
  83  
  84  ////  Row  ////
  85  
  86  	public static function get_row( $id, $url_parms, $xtra = false)
  87      {
  88          add_action('MailPress_get_icon_users',     array(__CLASS__, 'get_icon_users'), 8, 1);
  89  
  90          global $mp_user;
  91  
  92          $mp_user = $user = MP_User::get( $id );
  93          $the_user_status = $user->status;
  94  
  95          static $to_do_add_action = true;
  96          if ($to_do_add_action) add_action('MailPress_get_icon_users',     array(__CLASS__, 'get_icon_users'), 8, 1);
  97          $to_do_add_action = false;
  98  
  99  // url's
 100          $args = array();
 101          $args['id']     = $id;
 102  
 103          $edit_url        = esc_url(self::url( MailPress_user, array_merge($args, $url_parms) ));
 104  
 105          $author = ( 0 == $user->laststatus_user_id) ? $user->created_user_id : $user->laststatus_user_id;
 106          if ($author != 0 && is_numeric($author)) {
 107              unset($url_parms['author']);
 108              $wp_user = get_userdata($author);
 109              $author_url = esc_url(self::url( MailPress_users, array_merge( array('author'=>$author), $url_parms) ));
 110          }
 111  
 112  // actions
 113          $actions = array();
 114          $actions['edit']      = "<a href='$edit_url'  title='" . sprintf( __('Edit "%1$s"', MP_TXTDOM), $mp_user->email ) . "'>" . __('Edit') . '</a>';
 115  
 116  // table row 
 117  //    class
 118          $row_class = '';
 119          if ('waiting' == $the_user_status) $row_class = 'unapproved';
 120          if ('bounced' == $the_user_status) $row_class = 'bounced';
 121          if ('unsubscribed' == $the_user_status) $row_class = 'unsubscribed';
 122  ?>
 123      <tr id="user-<?php echo $id; ?>" class='<?php echo $row_class; ?>'>
 124  <?php
 125          $columns = self::get_columns();
 126  
 127          foreach ( $columns as $column_name => $column_display_name ) 
 128          {
 129              $class = "class='$column_name column-$column_name'";
 130  
 131              $style = '';
 132              if ('bounced' == $mp_user->status)         $style .= 'font-style:italic;';
 133              if ('unsubscribed' == $mp_user->status)     $style .= 'font-style:italic;';
 134              $style = ' style="' . $style . '"';
 135  
 136              $attributes = "$class$style";
 137  
 138              switch ($column_name) 
 139              {
 140                  case 'title' :
 141                      $attributes = 'class="username column-username"' . $style;
 142  ?>
 143          <td  <?php echo $attributes ?>>
 144  <?php self::flag_IP(); ?>
 145  <?php    do_action('MailPress_get_icon_users', $mp_user); ?>
 146  <?php if (get_option('show_avatars')) echo get_avatar( $user->email, 32 ); ?>
 147              <strong>
 148                  <a class='row-title' href='<?php echo $edit_url; ?>' title='<?php printf( __('Edit "%1$s"', MP_TXTDOM) ,$mp_user->email ); ?>'>
 149                      <?php echo $mp_user->email; ?>
 150                  </a>
 151              </strong>
 152  <?php echo self::get_actions($actions); ?>
 153          </td>
 154  <?php
 155                  break;
 156                  case 'user_name' :
 157  ?>
 158          <td  <?php echo $attributes ?>>
 159              <abbr title="<?php echo esc_attr($user->name); ?>"><?php echo esc_attr($user->name); ?></abbr>
 160          </td>
 161  <?php
 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          <td  <?php echo $attributes ?>>
 169              <abbr title="<?php echo $t_time; ?>"><?php echo $h_time; ?></abbr>
 170          </td>
 171  <?php
 172                  break;
 173                  case 'author' :
 174  ?>
 175          <td  <?php echo $attributes ?>>    
 176  <?php                 if ($author != 0 && is_numeric($author)) { ?>
 177                  <a href='<?php echo $author_url; ?>' title='<?php printf( __('Users by "%1$s"', MP_TXTDOM), $wp_user->display_name); ?>'><?php echo $wp_user->display_name; ?></a>
 178  <?php                 } else      _e("(unknown)", MP_TXTDOM); ?>
 179          </td>
 180  <?php
 181                  break;
 182                  default:
 183  ?>
 184          <td  <?php echo $attributes ?>>
 185              <?php    do_action('MailPress_users_get_row', $column_name, $user, $url_parms); ?>
 186          </td>
 187  <?php
 188                  break;
 189              }
 190          }
 191  ?>
 192        </tr>
 193  <?php
 194  
 195      }
 196  
 197  	public static function user_date( $d = '' ) {
 198          echo self::get_user_date( $d );
 199      }
 200  
 201  	public static function get_user_date( $d = '' ) {
 202          $x = self::get_user_date_raw();
 203          return ( '' == $d ) ? mysql2date( get_option('date_format'), $x) : mysql2date($d, $x);
 204      }
 205  
 206  	public static function get_user_date_raw() {
 207          global $mp_user;
 208          return ( $mp_user->created >= $mp_user->laststatus) ? $mp_user->created : $mp_user->laststatus;
 209      }
 210  
 211  	public static function user_author_IP() {
 212          echo self::get_user_author_IP();
 213      }
 214  
 215  	public static function get_user_author_IP() {
 216          global $mp_user;
 217          $ip = ( '' == $mp_user->laststatus_IP) ? $mp_user->created_IP : $mp_user->laststatus_IP;
 218          return $ip;
 219      }
 220  
 221  	public static function flag_IP() {
 222          echo self::get_flag_IP();
 223      }
 224  
 225  	public static function get_flag_IP() {
 226          global $mp_user;
 227          return (('ZZ' == $mp_user->created_country) || empty($mp_user->created_country)) ? '' : "<img class='flag' alt='" . strtolower($mp_user->created_country) . "' title='" . strtolower($mp_user->created_country) . "' src='" . site_url() . '/' . MP_PATH . 'mp-admin/images/flag/' . strtolower($mp_user->created_country) . ".gif' />\n";
 228      }
 229  
 230  	public static function get_icon_users($mp_user)
 231      {
 232          if ('unsubscribed' != $mp_user->status) return;
 233  ?>
 234              <span class='icon unsubscribed' title="<?php _e('Unsubscribed', MP_TXTDOM); ?>"></span>
 235  <?php
 236      }
 237  }


Generated: Thu Apr 28 18:38:52 2016 Cross-referenced by PHPXref 0.7.1