[ Index ]

MailPress 7.1

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

title

Body

[close]

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

   1  <?php
   2  class MP_Mail_links
   3  {
   4  	public static function process() 
   5      {
   6          $get_ = filter_input_array( INPUT_GET );
   7  
   8          foreach( $get_ as $method => $mp_confkey ) if ( method_exists( __CLASS__, $method ) ) $results = self::$method( $mp_confkey );
   9  
  10          if ( !isset( $results ) ) return false;
  11  
  12          if ( is_numeric( $results ) )
  13          {
  14              $errs[1] = __( 'unknown user', 'MailPress' );
  15              $errs[2] = __( 'unknown user', 'MailPress' );
  16              $errs[3] = __( 'cannot activate user', 'MailPress' );
  17              $errs[4] = __( 'user already active', 'MailPress' );
  18              $errs[5] = __( 'unknown user', 'MailPress' );
  19              $errs[6] = __( 'user not a recipient', 'MailPress' );
  20              $errs[7] = __( 'user not a recipient', 'MailPress' );
  21              $errs[8] = __( 'unknown mail', 'MailPress' );
  22              $errs[9] = __( 'unknown user', 'MailPress' );
  23  
  24              $content  = '<p>' . sprintf( __( '<p> ERROR # %1$s (%2$s) !</p>', 'MailPress' ), $results, $errs[$results] ) . "</p>\n";
  25              $content .= '<p>' . __( 'Check you are using the appropriate link.', 'MailPress' ) . "</p>\n";
  26              $content .= "<br />\n";
  27  
  28              return array( 'title' => '', 'content' => $content );
  29          }
  30          
  31          return $results;
  32      }
  33  
  34  	public static function add( $mp_confkey )
  35      {
  36          $mp_user_id = MP_User::get_id( $mp_confkey );
  37          if ( !$mp_user_id )                         return 5;
  38          if ( 'active' == MP_User::get_status( $mp_user_id ) )     return 4;
  39          if ( !MP_User::set_status( $mp_user_id, 'active' ) )     return 3;
  40  
  41          $email     = MP_User::get_email( $mp_user_id );
  42          $url         = MP_User::get_unsubscribe_url( $mp_confkey );
  43  
  44          $title     = __( 'Subscription confirmed', 'MailPress' );
  45          $content     = '';
  46  
  47          $content .= sprintf( __( '<p><b>%1$s</b> has successfully subscribed.</p>', 'MailPress' ), $email );
  48          $content .= "<br />\n";
  49          $content .= "<h3>" . sprintf( __( '<a href="%1$s">Manage Subscription</a>', 'MailPress' ), $url ) . "</h3>\n";
  50          $content .= "<br />\n";
  51  
  52          return array( 'title' => $title, 'content' => $content );
  53      }
  54  
  55  	public static function del( $mp_confkey )
  56      {
  57          $mp_user_id = MP_User::get_id( $mp_confkey );
  58          if ( !$mp_user_id ) return 1;
  59  
  60          $mp_user = MP_User::get( $mp_user_id );
  61          $active = ( 'active' == $mp_user->status ) ? true : false;
  62          $comment = ( $active || ( 'waiting' == $mp_user->status ) );
  63  
  64          $title    =  sprintf( __( 'Manage Subscription (%1$s)', 'MailPress' ), $mp_user->email );
  65          $content = '';
  66  
  67          $post_ = filter_input_array( INPUT_POST );
  68  
  69          if ( isset( $post_['cancel'] ) )
  70          {
  71              $content .= '<p>' . __( 'Cancelled action', 'MailPress' ) ."</p>\n";
  72              $content .= "<br />\n";
  73              return array( 'title' => $title, 'content' => $content );
  74          }
  75  
  76          if ( isset( $post_['delconf'] ) )
  77          {
  78              if ( $mp_user->name != $post_['mp_user_name'] )
  79              {
  80                  MP_User::update_name( $mp_user->id, $post_['mp_user_name'] );
  81                  $mp_user->name = $post_['mp_user_name'];
  82              }
  83  
  84              if ( class_exists( 'MailPress_comment' ) )     if ( $comment )    MailPress_comment::update_checklist( $mp_user_id );
  85              if ( class_exists( 'MailPress_newsletter' ) )  if ( $active )     MailPress_newsletter::update_checklist( $mp_user_id );
  86              if ( class_exists( 'MailPress_mailinglist' ) ) if ( $active )     MailPress_mailinglist::update_checklist( $mp_user_id );
  87  
  88              $content .= '<div id="moderated" class="updated fade"><p>' . __( 'Subscriptions saved', 'MailPress' ) . '</p></div>' . "\n";
  89          }
  90  
  91          $content .= '<form method="post">' . "\n";
  92  
  93          $content .= '<div id="mp_mail_links_name">';
  94          $content .= '<h3>' . __( 'Name', 'MailPress' ) . "</h3>\n";
  95          $content .= '<input type="text" name="mp_user_name" size="30" value="' . esc_attr( $mp_user->name ) . '" />' . "\n";
  96          $content .= '</div>'; 
  97  
  98          $args = array( 'htmlstart' => '<li><label for="{{id}}">', 'htmlmiddle'=> '&#160;', 'htmlend' => "</label></li>\n" );
  99          $ok = false;
 100          $checklist_comments     = ( class_exists( 'MailPress_comment' )     && $comment )    ? MailPress_comment::get_checklist( $mp_user_id, $args )     : false;
 101          if ( $checklist_comments ) 
 102          {
 103              $ok = true;
 104              $content .= '<div id="mp_mail_links_comments">';
 105              $content .= "<h3>" . __( 'Comments' ) . "</h3>\n";
 106              $content .= "<ul>$checklist_comments</ul>" ; 
 107              $content .= '</div>'; 
 108          }
 109  
 110          $checklist_newsletters  = ( class_exists( 'MailPress_newsletter' )  && $active )     ? MailPress_newsletter::get_checklist( $mp_user_id, $args )    : false;
 111          if ( $checklist_newsletters ) 
 112          {    
 113              $ok = true;    
 114              $content .= '<div id="mp_mail_links_newsletters">';
 115              $content .= "<h3>" . __( 'Newsletters', 'MailPress' ) . "</h3>\n";
 116              $content .= "<ul>$checklist_newsletters</ul>" ; 
 117              $content .= '</div>'; 
 118          }
 119  
 120          $checklist_mailinglists = ( class_exists( 'MailPress_mailinglist' ) && $active )    ? MailPress_mailinglist::get_checklist( $mp_user_id, $args )    : false;
 121          if ( $checklist_mailinglists )
 122          {    
 123              $ok = true;    
 124              $content .= '<div id="mp_mail_links_mailinglists">';
 125              $content .= "<h3>" . __( 'Mailing lists', 'MailPress' ) . "</h3>\n";
 126              $content .= "<ul>$checklist_mailinglists</ul>" ; 
 127              $content .= '</div>'; 
 128          }
 129  
 130          if ( $ok )
 131          {
 132              $content .= '    <input type="hidden" name="status" value="' . esc_attr( MP_User::get_status( $mp_user_id ) ) . '" />' . "\n<br /><p>";
 133              $content .= '    <input type="submit" name="delconf" class="button" value="' . esc_attr( __( 'OK', 'MailPress' ) )     . '" />' . "\n";
 134              $content .= '    <input type="submit" name="cancel"  class="button" value="' . esc_attr( __( 'Cancel', 'MailPress' ) ) . '" /></p>' . "\n";
 135          }
 136          else
 137          {
 138              $content .= '<br /><br />';
 139              if ( $active || $comment )     $content .= __( 'Nothing to subscribe for ...', 'MailPress' );
 140              else                    $content .= __( 'Your email has been deactivated, ask the administrator ...', 'MailPress' );
 141              $content .= '<br /><br />';
 142          }
 143          $content .= "</form>\n";
 144          $content .= "<br />\n";
 145          $content .= '<h3><a href="' . MP_User::get_delall_url( $mp_confkey ) . '">' . __( 'Delete Subscription', 'MailPress' ) . '</a></h3>' . "\n";
 146          $content .= "<br />\n";
 147          return array( 'title' => $title, 'content' => $content );
 148      }
 149  
 150  	public static function delall( $mp_confkey )
 151      {
 152          $mp_user_id = MP_User::get_id( $mp_confkey );
 153          if ( !$mp_user_id )                         return 2;
 154  
 155          $email     = MP_User::get_email( $mp_user_id );
 156  
 157          $title = __( 'Unsubscribe', 'MailPress' );
 158          $content = '';
 159  
 160          $post_ = filter_input_array( INPUT_POST );
 161  
 162          if ( isset( $post_['delconf'] ) ) 
 163          {
 164              if ( MP_User::set_status( $mp_user_id, 'unsubscribed' ) )
 165              {
 166                  $content .= sprintf( __( '<p>We confirm that the email address <b>%1$s</b> has been unsubscribed.</p>', 'MailPress' ), $email );
 167                  $content .= "<br />\n";
 168                  return array( 'title' => $title, 'content' => $content );
 169              }
 170          }
 171          elseif ( isset( $post_['cancel'] ) )
 172          {
 173              $content .= '<p>' . __( 'Cancelled action', 'MailPress' ) ."</p>\n";
 174              $content .= "<br />\n";
 175              return array( 'title' => $title, 'content' => $content );
 176          }
 177          else
 178          {
 179              $content .= '<p>' .sprintf( __( '<p>Are you sure you want to unsubscribe <b>%1$s</b> from <b>%2$s</b>.</p>', 'MailPress' ), $email, get_bloginfo( 'name' ) ) ."</p>\n";
 180              $content .= "<br /><br />\n";
 181              $content .= '<form method="post">' . "\n";
 182              $content .= '    <input type="submit" name="delconf" class="button" value="' . __( 'OK', 'MailPress' ) . '" />' . "\n";
 183              $content .= '    <input type="submit" name="cancel"  class="button" value="' . __( 'Cancel', 'MailPress' ) . '" />' . "\n";
 184              $content .= "</form>\n";
 185              $content .= "<br />\n";
 186              return array( 'title' => $title, 'content' => $content );
 187          }
 188      }
 189  
 190  	public static function view( $mp_confkey )
 191      {
 192          global $mp_general;
 193  
 194          $mp_user_id = MP_User::get_id( $mp_confkey );
 195          if ( !$mp_user_id )                             return 9;
 196  
 197          $email     = MP_User::get_email( $mp_user_id );
 198  
 199          $mail_id = (int) filter_input( INPUT_GET, 'id' );
 200          $mail = MP_Mail::get( $mail_id );
 201          if ( !$mail )                                return 8;
 202  
 203          $title    = $mail->subject;
 204          $content = '';
 205  
 206          $is_email = ( MailPress::is_email( $mail->toemail ) );
 207  
 208          if ( $is_email && ( $email != $mail->toemail ) )    return 6;
 209                  
 210          if ( !$is_email )
 211          {
 212              $recipients = unserialize( $mail->toemail );
 213              if ( !( is_array( $recipients ) && ( isset( $recipients[$email] ) ) ) )     return 7;
 214  
 215              $m = MP_Mail_meta::get( $mail_id, '_MailPress_replacements' );
 216              if ( !is_array( $m ) ) $m = array();
 217  
 218              $replacements = array_merge( $m, $recipients[$email] );
 219  
 220              foreach ( $replacements as $k => $v ) $title = str_replace( $k, $v, $title );
 221  
 222              foreach( array( 'html', 'plaintext' ) as $type ) if ( !empty( $mail->{$type} ) ) {foreach( $replacements as $k => $v ) $mail->{$type} = str_replace( $k, $v, $mail->{$type}, $ch );};
 223          }
 224  
 225          if ( !empty( $mail->html ) )
 226          {
 227              $x = new MP_Mail();
 228              $content = $x->process_img( $mail->html, $mail->themedir, 'draft' );
 229          }
 230          elseif ( !empty( $mail->plaintext ) )
 231              $content = '<!DOCTYPE html><html ' . get_language_attributes() . '><head><meta charset="' . get_bloginfo( 'charset' ) . '/><meta name="viewport" content="width=device-width" /><title>' . get_bloginfo( 'name' ) . ' &gt; ' . $title  . '</title></head><body>' . '<pre>' . htmlspecialchars( $mail->plaintext, ENT_NOQUOTES ) . '</pre>' . '</body></html>';
 232  /*
 233          $metas = MP_Mail_meta::has( $mail_id, '_MailPress_attached_file' );
 234          if ( $metas )
 235          {
 236              $content .= '<div id="attachments"><table><tr><td style="vertical-align:top;">' . __( 'Attachments', 'MailPress' ) . '</td><td><table>';
 237                          foreach( $metas as $meta ) { $content .= '<tr><td>&#160;' . MP_Mail::get_attachment_link( $meta, $mail->status ) . '</td></tr>'; }
 238              $content .= '</table></td></tr></table></div>' . "\n";
 239          }
 240  */
 241  
 242          if ( !isset( $mp_general['fullscreen'] ) )         return array( 'title' => $title, 'content' => $content );
 243          
 244          die( $content );
 245      }
 246  
 247  	public static function arch( $mp_confkey )
 248      {
 249          global $mp_general;
 250  
 251          if ( $mp_confkey )                             return 9;
 252  
 253          $mail_id = (int) filter_input( INPUT_GET, 'id' );
 254          $mail = MP_Mail::get( $mail_id );
 255          if ( !$mail )                                return 8;
 256          if ( 'archived' != $mail->status )                  return 8;
 257  
 258          $title    = $mail->subject;
 259          $content = '';
 260  
 261          if ( !empty( $mail->html ) )
 262          {
 263              $x = new MP_Mail();
 264              $content = $x->process_img( $mail->html, $mail->themedir, 'draft' );
 265          }
 266          elseif ( !empty( $mail->plaintext ) )
 267              $content = '<!DOCTYPE html><html ' . get_language_attributes() . '><head><meta charset="' . get_bloginfo( 'charset' ) . '/><meta name="viewport" content="width=device-width" /><title>' . get_bloginfo( 'name' ) . ' &gt; ' . $title  . '</title></head><body>' . '<pre>' . htmlspecialchars( $mail->plaintext, ENT_NOQUOTES ) . '</pre>' . '</body></html>';
 268  
 269          if ( !isset( $mp_general['fullscreen'] ) )         return array( 'title' => $title, 'content' => $content );
 270          
 271          die( $content );
 272      }
 273  }


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