[ Index ]

MailPress 7.2

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

title

Body

[close]

/mp-includes/class/options/privacy/exporters/ -> tracking.php (source)

   1  <?php /* tracking */
   2  if ( class_exists( 'MailPress' ) && class_exists( 'MailPress_tracking' ) )
   3  {
   4  class MP_WP_Privacy_exporter_tracking extends MP_WP_privacy_exporter_
   5  {
   6      const per_page = 100;
   7  
   8      var $priority = 44;
   9  
  10  	function exporter( $email, $page = 1 )
  11      {
  12          global $wpdb;
  13  
  14          $mp_user = $this->get_user( $email );
  15          if ( !$mp_user ) return $this->export;
  16  
  17          /*  */
  18  
  19          $start = ( $page - 1 ) * self::per_page;
  20  
  21          $tracks = $wpdb->get_results( $wpdb->prepare( "SELECT SQL_CALC_FOUND_ROWS * FROM $wpdb->mp_tracks WHERE user_id = %d ORDER BY tmstp ASC LIMIT $start, " . self::per_page . ";", $mp_user->id ) );
  22  
  23          if ( !$tracks ) return $this->export;
  24  
  25          $total = $wpdb->get_var( "SELECT FOUND_ROWS()" );
  26          $current = $start + count( $tracks );
  27  
  28          /*  */
  29  
  30          $x = new MP_Mail();
  31  
  32          foreach ( (array) $tracks as $k => $track )
  33          {
  34              if ( MailPress::is_bot( $track->agent ) )
  35              {
  36                  unset( $tracks[$k] );
  37                  continue;
  38              }
  39  
  40              $subject = $wpdb->get_var( $wpdb->prepare( "SELECT subject FROM $wpdb->mp_mails WHERE id = %d ;", $track->mail_id ) );
  41              $tracks[$k]->subject = $x->viewsubject( $subject, $track->mail_id, $track->mail_id, $mp_user->id );
  42  
  43              switch ( $track->track )
  44              {
  45                  case '{{viewhtml}}' :
  46                      $tracks[$k]->track = sprintf( '<a href="%1$s" title="%2$s" target="_blank">%3$s</a>',
  47                                              MP_User::get_view_url( $mp_user->confkey, $track->mail_id ),
  48                                              esc_attr( $track->track ),
  49                                              MailPress_tracking::translate_track( $track->track, $track->mail_id )
  50                      );
  51                  break;
  52                  case '{{subscribe}}' :
  53                      //$url = MP_User::get_subscribe_url( $get_['us'] );    break;
  54                  case '{{unsubscribe}}' :
  55                      //$url = MP_User::get_unsubscribe_url( $get_['us'] ); break;
  56                  default :
  57                      $tracks[$k]->track = MailPress_tracking::translate_track( $track->track, $track->mail_id );
  58                  break;
  59              }
  60          }
  61  
  62          /*  */
  63  
  64          $properties = array(
  65              'tmstp'     => __( 'Collect Time', 'MailPress' ),
  66              'id'         => __( 'Collect Id', 'MailPress' ),
  67              'mail_id'     => __( 'Mail Id', 'MailPress' ),
  68              'subject'    => __( 'Mail Subject', 'MailPress' ),
  69              'track'     => __( 'Collected Url', 'MailPress' ),
  70              'context'     => __( 'Collected Context', 'MailPress' ),
  71              'ip'         => __( 'Collected Ip', 'MailPress' ),
  72              'agent'     => __( 'Collected UserAgent', 'MailPress' ),
  73              'referrer'    => __( 'Collected Referrer', 'MailPress' ),
  74          );
  75  
  76          foreach ( (array) $tracks as $track )
  77          {
  78              $data = array();
  79  
  80              foreach ( $properties as $key => $name )
  81              {
  82                  $value = '';
  83  
  84                  switch ( $key )
  85                  {
  86                      case 'id':
  87                          $value = $track->{$key};
  88                      break;
  89                      case 'mail_id':
  90                      case 'subject':
  91                      case 'tmstp':
  92                      case 'context':
  93                      case 'ip':
  94                      case 'agent':
  95                      case 'track':
  96                      case 'referrer':
  97                          $value = $track->{$key};
  98                      break;
  99                  };
 100  
 101                  if ( empty( $value ) ) continue;
 102  
 103                  $data[] = array( 'name' => $name, 'value' => $value, );
 104              }
 105  
 106              $this->export['data'][] = array(
 107                  'group_id'    => 'mp_tracks',
 108                  'group_label' => __( 'Subscriber > Collected Data', 'MailPress' ),
 109                  'group_description' => __( 'Subscriber&#8217;s mail activity.', 'MailPress' ),
 110                  'item_id'     => "mp_user-{$mp_user->id}-{$track->id}",
 111                  'data'        => $data,
 112              );
 113          }
 114  
 115          $this->export['done'] = ( $total == $current );
 116  
 117          return $this->export;
 118      }
 119  }
 120  new MP_WP_Privacy_exporter_tracking( __( 'MailPress tracks', 'MailPress' ) );
 121  }


Generated: Tue May 19 15:55:14 2020 Cross-referenced by PHPXref 0.7.1