[ Index ]

MailPress 7.1

[ 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                  'item_id'     => "mp_user-{$mp_user->id}-{$i}",
  62                  'data'        => $data,
  63              );
  64          }
  65  
  66          $this->export['done'] = ( $total == $current );
  67  
  68          return $this->export;
  69      }
  70  
  71  	function get_items()
  72      {
  73          global $mp_subscriptions, $mp_registered_newsletters;
  74          $n = array();
  75  
  76          $s = MailPress_newsletter::get_subscriptions( $this->mp_user_id );
  77  
  78          foreach( $mp_subscriptions['newsletters'] as $k => $v )
  79          {
  80              if ( !isset( $s[$k] ) ) continue;
  81              $n[$k] = $mp_registered_newsletters[$k]['descriptions']['blog'];
  82          }
  83  
  84          return $n; 
  85      }
  86  }
  87  new MP_WP_Privacy_exporter_newsletter( __( 'MailPress newsletters', 'MailPress' ) );
  88  }


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