[ Index ]

MailPress 7.2

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

title

Body

[close]

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

   1  <?php /* newsletter */
   2  if ( class_exists( 'MailPress' ) && class_exists( 'MailPress_newsletter' ) )
   3  {
   4  class MP_WP_Privacy_exporter_newsletter extends MP_WP_privacy_exporter_
   5  {
   6      const per_page = 100;
   7  
   8      var $priority = 43;
   9  
  10  	function exporter( $email, $page = 1 )
  11      {
  12          $mp_user = $this->get_user( $email );
  13          if ( !$mp_user ) return $this->export;
  14  
  15          /*  */
  16  
  17          $start = ( $page - 1 ) * self::per_page;
  18  
  19          $items = $this->get_items();
  20  
  21          if ( !$items ) return $this->export;
  22  
  23          $newsletters = array_slice( $items, $start, self::per_page, true );
  24  
  25          $total = count( $items );
  26          $current = $start + count( $newsletters );
  27  
  28          /*  */
  29  
  30          $properties = array(
  31              'id' => __( 'Newsletter Id', 'MailPress' ),
  32              'name' => __( 'Newsletter Name', 'MailPress' ),
  33          );
  34  
  35          foreach ( (array) $newsletters as $i => $n )
  36          {
  37              $data = array();
  38  
  39              foreach ( $properties as $key => $name )
  40              {
  41                  $value = '';
  42  
  43                  switch ( $key )
  44                  {
  45                      case 'id':
  46                          $value = $i;
  47                      break;
  48                      case 'name':
  49                          $value = $n;
  50                      break;
  51                  };
  52  
  53  //                if ( empty( $value ) ) continue;
  54  
  55                  $data[] = array( 'name' => $name, 'value' => $value, );
  56              }
  57  
  58              $this->export['data'][] = array(
  59                  'group_id'    => 'mp_newsletters',
  60                  'group_label' => _n( 'Subscriber > Newsletter', 'Subscriber > Newsletters', $total, 'MailPress' ),
  61                  'group_description' => _n( 'Subscriber&#8217;s newsletter subscription.', 'Subscriber&#8217;s newsletter subscriptions.', $total, 'MailPress' ),
  62                  'item_id'     => "mp_user-{$mp_user->id}-{$i}",
  63                  'data'        => $data,
  64              );
  65          }
  66  
  67          $this->export['done'] = ( $total == $current );
  68  
  69          return $this->export;
  70      }
  71  
  72  	function get_items()
  73      {
  74          global $mp_subscriptions, $mp_registered_newsletters;
  75          $n = array();
  76  
  77          $s = MailPress_newsletter::get_subscriptions( $this->mp_user_id );
  78  
  79          foreach( $mp_subscriptions['newsletters'] as $k => $v )
  80          {
  81              if ( !isset( $s[$k] ) ) continue;
  82              $n[$k] = $mp_registered_newsletters[$k]['descriptions']['blog'];
  83          }
  84  
  85          return $n; 
  86      }
  87  }
  88  new MP_WP_Privacy_exporter_newsletter( __( 'MailPress newsletters', 'MailPress' ) );
  89  }


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