[ Index ]

MailPress 544

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

title

Body

[close]

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

   1  <?php
   2  class MP_AdminPage extends MP_adminpage_
   3  {
   4      const screen         = 'mailpress_revision';
   5      const capability     = 'MailPress_edit_mails';
   6      const help_url        = false;
   7      const file            = __FILE__;
   8  
   9  ////  Redirect  ////
  10  
  11  	public static function redirect() 
  12      {
  13          $action    = (isset($_GET['action']))     ? $_GET['action'] : false;
  14  
  15          $revision_id= (isset($_GET['revision']))     ? absint($_GET['revision']) : false;
  16          $id        = absint($_GET['id']);
  17  
  18          $left        = (isset($_GET['left']))     ? absint($_GET['left']) : false;
  19          $right    = (isset($_GET['right']))     ? absint($_GET['right']) : false;
  20  
  21          $redirect_to = MailPress_edit;
  22  
  23          switch ( $action )
  24          {
  25              case 'delete' :
  26              break;
  27              case 'edit' :
  28              break;
  29              case 'restore' :
  30                  if (!$revision = MP_Mail::get($revision_id)) break;
  31                  if (!$mail     = MP_Mail::get($id))          break;
  32  
  33                  $_POST = get_object_vars($mail);
  34                  foreach(array('toname', 'subject', 'html', 'plaintext') as $k) if ($_POST[$k]) $_POST[$k] = addcslashes($_POST[$k], "'");
  35                  MP_Mail_draft::update($revision_id, '');
  36  
  37                  $_POST = get_object_vars($revision);
  38                  unset($_POST['created']);
  39                  foreach(array('toname', 'subject', 'html', 'plaintext') as $k) if ($_POST[$k]) $_POST[$k] = addcslashes($_POST[$k], "'");
  40                  MP_Mail_draft::update($id);
  41  
  42                  $redirect_to .= "&id=$id&revision=$revision_id&message=5&time=" . urlencode($revision->created);
  43              break;
  44              case 'diff' :
  45                  $redirect_to .= "&id=$id";
  46  
  47                  if ( $left == $right ) 
  48                  {
  49                      $redirect = $redirect_to;
  50                      include(ABSPATH . 'wp-admin/js/revisions-js.php' );
  51                      break;
  52                  }
  53  
  54                  if ( !$left_revision  = MP_Mail::get( $left ) )
  55                      break;
  56                  if ( !$right_revision = MP_Mail::get( $right ) )
  57                      break;
  58  
  59                  if ( strtotime($right_revision->created) < strtotime($left_revision->created) ) 
  60                  {
  61                      $redirect_to = MailPress_revision;
  62                      $redirect_to .= "&action=diff&id=$id&left=$right_revision->id&right=$left_revision->id";
  63                      break;
  64                  }
  65  
  66                  if ($left_revision->id  == $id) $left_ok = true;
  67                  if ($right_revision->id == $id) $right_ok = true;
  68                  $rev_ids = MP_Mail_meta::get($id, '_MailPress_mail_revisions');
  69                  foreach ($rev_ids as $v) if ($left_revision->id  == $v) $left_ok = true;
  70                  foreach ($rev_ids as $v) if ($right_revision->id == $v) $right_ok = true;
  71                  if (!($left_ok && $right_ok)) break;
  72                  $redirect_to = false;
  73              break;
  74              case 'view' :
  75              default :
  76                   if ( !$revision = MP_Mail::get( $revision_id ) )
  77                      break;
  78                  if ( !$mail = MP_Mail::get( $id ) )
  79                      break;
  80  
  81                  $redirect_to = false;
  82              break;
  83          }
  84          if ($redirect_to) self::mp_redirect( $redirect_to );
  85      }
  86  
  87  ////  Title  ////
  88  
  89  	public static function title() { global $title; $title = __('Mail Revisions', MP_TXTDOM); }
  90  
  91  ////  Styles  ////
  92  
  93  	public static function print_styles($styles = array()) 
  94      {
  95          wp_register_style ( self::screen, '/' . MP_PATH . 'mp-admin/css/write.css', array('thickbox') );
  96  
  97          $styles[] = self::screen;
  98          parent::print_styles($styles);
  99      }
 100  }


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