[ Index ]

MailPress 7.1

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

title

Body

[close]

/mp-includes/class/ -> MP_WP_List.class.php (source)

   1  <?php
   2  abstract class MP_WP_List
   3  {
   4  	public static function _get_object_class( $object_type )
   5      {
   6          return self::_get_that( $object_type, 'class' );
   7      }
   8  
   9  	public static function _get_object_file( $object_type )
  10      {
  11          return self::_get_that( $object_type, 'file' );
  12      }
  13  
  14  	public static function _get_object_dims( $object_type )
  15      {
  16          return self::_get_that( $object_type, 'dims' );
  17      }
  18  
  19  	public static function _get_that( $object_type, $id )
  20      {
  21          $those = array(     'user' => array( 'class' => 'MP_User', 'file' => 'users', 'dims' => array( 'unsubscribed' => 'waiting', 'waiting' => 'active', 'active' => 'waiting', 'bounced' => 'waiting' )),
  22                          'mail' => array( 'class' => 'MP_Mail', 'file' => 'mails', 'dims' => array( 'sent' => 'archived', 'archived' => 'sent' ), ),
  23          );
  24  
  25          return ( isset( $those[$object_type][$id] ) ) ? $those[$object_type][$id] : false;
  26      }
  27  
  28  	public static function add_object( $object_type )
  29      {
  30          $_object_class = self::_get_object_class( $object_type );
  31  
  32          require_once( MP_ABSPATH . 'mp-admin/' . self::_get_object_file( $object_type ) . '.php' );
  33  
  34          $url_parms = MP_AdminPage::get_url_parms();
  35          $url_parms['paged'] = isset( $url_parms['paged'] ) ? $url_parms['paged'] : 1;
  36          $_per_page = MP_AdminPage::get_per_page();
  37          $start = ( $url_parms['paged'] - 1 ) * $_per_page;
  38  
  39          list( $objects, $total ) = MP_AdminPage::get_list( array( 'start' => $start, '_per_page' => 1, 'url_parms' => $url_parms ) );
  40  
  41          if ( !$objects ) MP_::mp_die( 1 );
  42  
  43          $x = new WP_Ajax_Response();
  44          foreach ( ( array ) $objects as $object ) 
  45          {
  46              $_object_class::get( $object );
  47              $html = MP_AdminPage::get_row( $object->id, $url_parms, false );
  48  
  49              $x->add( array( 
  50                  'what'     => $object_type, 
  51                  'id'         => $object->id, 
  52                  'data'     => $html
  53               ) );
  54          }
  55          $x->send();
  56      }
  57  
  58  	public static function dim_object( $object_type ) 
  59      {
  60          $_object_class = self::_get_object_class( $object_type );
  61          $_object_dims  = self::_get_object_dims( $object_type );
  62  
  63          require_once( MP_ABSPATH . 'mp-admin/' . self::_get_object_file( $object_type ) . '.php' );
  64  
  65          $url_parms     = MP_AdminPage::get_url_parms();
  66  
  67             $id = isset( MP_WP_Ajax::$pst_['id'] )? ( int ) MP_WP_Ajax::$pst_['id'] : 0;
  68             $status = $_object_class::get_status( $id );
  69  
  70          if ( !isset( $_object_dims[$status] ) ) MP_::mp_die();
  71          if ( !$_object_class::set_status( $id, $_object_dims[$status] ) ) MP_::mp_die( -1 );
  72          
  73          $html = MP_AdminPage::get_row( $id, $url_parms );
  74  
  75          $xml = "<rc><![CDATA[0]]></rc><id><![CDATA[$id]]></id><item><![CDATA[$html]]></item><old_status><![CDATA[$status]]></old_status><new_status><![CDATA[" . $_object_dims[$status] . "]]></new_status>"; 
  76  
  77          ob_end_clean();
  78          header( 'Content-Type: text/xml' );
  79          MP_::mp_die( "<?xml version='1.0' standalone='yes'?><mp_action>$xml</mp_action>" );
  80      }
  81  
  82  	public static function delete_object( $object_type ) 
  83      {
  84          $_object_class = self::_get_object_class( $object_type );
  85  
  86          $id = isset( MP_WP_Ajax::$pst_['id'] )? ( int ) MP_WP_Ajax::$pst_['id'] : 0;
  87          MP_::mp_die( $_object_class::set_status( $id, 'delete' ) ? 1 : 0 );
  88      }
  89  }


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