[ Index ]

MailPress 7.2

[ 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     = ( class_exists( 'MailPress_comment' )     && $comment )    ? MailPress_comment::get_checklist( $mp_user_id, $args )     : false;
 101          if ( empty( $checklist ) ) $checklist = false;
 102          if ( $checklist ) 
 103          {
 104              $ok = true;
 105              $content .= '<div id="mp_mail_links_comments">';
 106              $content .= "<h3>" . __( 'Comments' ) . "</h3>\n";
 107              $content .= "<ul>$checklist</ul>" ; 
 108              $content .= '</div>'; 
 109          }
 110  
 111          $checklist  = ( class_exists( 'MailPress_newsletter' )  && $active )     ? MailPress_newsletter::get_checklist( $mp_user_id, $args )    : false;
 112          if ( empty( $checklist ) ) $checklist = false;
 113          if ( $checklist ) 
 114          {    
 115              $ok = true;    
 116              $content .= '<div id="mp_mail_links_newsletters">';
 117              $content .= "<h3>" . __( 'Newsletters', 'MailPress' ) . "</h3>\n";
 118              $content .= "<ul>$checklist</ul>" ; 
 119              $content .= '</div>'; 
 120          }
 121  
 122          $checklist = ( class_exists( 'MailPress_mailinglist' ) && $active )    ? MailPress_mailinglist::get_checklist( $mp_user_id, $args )    : false;
 123          if ( empty( $checklist ) ) $checklist = false;
 124          if ( $checklist )
 125          {    
 126              $ok = true;    
 127              $content .= '<div id="mp_mail_links_mailinglists">';
 128              $content .= "<h3>" . __( 'Mailing lists', 'MailPress' ) . "</h3>\n";
 129              $content .= "<ul>$checklist</ul>" ; 
 130              $content .= '</div>'; 
 131          }
 132  
 133          if ( $ok )
 134          {
 135              $content .= '    <input type="hidden" name="status" value="' . esc_attr( MP_User::get_status( $mp_user_id ) ) . '" />' . "\n<br /><p>";
 136              $content .= '    <input type="submit" name="delconf" class="button" value="' . esc_attr( __( 'OK', 'MailPress' ) )     . '" />' . "\n";
 137              $content .= '    <input type="submit" name="cancel"  class="button" value="' . esc_attr( __( 'Cancel', 'MailPress' ) ) . '" /></p>' . "\n";
 138          }
 139          else
 140          {
 141              $content .= '<br /><br />';
 142              if ( $active || $comment )     $content .= __( 'Nothing to subscribe for ...', 'MailPress' );
 143              else                    $content .= __( 'Your email has been deactivated, ask the administrator ...', 'MailPress' );
 144              $content .= '<br /><br />';
 145          }
 146          $content .= "</form>\n";
 147          $content .= "<br />\n";
 148          $content .= '<h3><a href="' . MP_User::get_delall_url( $mp_confkey ) . '">' . __( 'Delete Subscription', 'MailPress' ) . '</a></h3>' . "\n";
 149          $content .= "<br />\n";
 150          return array( 'title' => $title, 'content' => $content );
 151      }
 152  
 153  	public static function delall( $mp_confkey )
 154      {
 155          $mp_user_id = MP_User::get_id( $mp_confkey );
 156          if ( !$mp_user_id )                         return 2;
 157  
 158          $email     = MP_User::get_email( $mp_user_id );
 159  
 160          $title = __( 'Unsubscribe', 'MailPress' );
 161          $content = '';
 162  
 163          $post_ = filter_input_array( INPUT_POST );
 164  
 165          if ( isset( $post_['delconf'] ) ) 
 166          {
 167              if ( MP_User::set_status( $mp_user_id, 'unsubscribed' ) )
 168              {
 169                  $content .= sprintf( __( '<p>We confirm that the email address <b>%1$s</b> has been unsubscribed.</p>', 'MailPress' ), $email );
 170                  $content .= "<br />\n";
 171                  return array( 'title' => $title, 'content' => $content );
 172              }
 173          }
 174          elseif ( isset( $post_['cancel'] ) )
 175          {
 176              $content .= '<p>' . __( 'Cancelled action', 'MailPress' ) ."</p>\n";
 177              $content .= "<br />\n";
 178              return array( 'title' => $title, 'content' => $content );
 179          }
 180          else
 181          {
 182              $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";
 183              $content .= "<br /><br />\n";
 184              $content .= '<form method="post">' . "\n";
 185              $content .= '    <input type="submit" name="delconf" class="button" value="' . __( 'OK', 'MailPress' ) . '" />' . "\n";
 186              $content .= '    <input type="submit" name="cancel"  class="button" value="' . __( 'Cancel', 'MailPress' ) . '" />' . "\n";
 187              $content .= "</form>\n";
 188              $content .= "<br />\n";
 189              return array( 'title' => $title, 'content' => $content );
 190          }
 191      }
 192  
 193  	public static function view( $mp_confkey )
 194      {
 195          global $mp_general;
 196  
 197          $mp_user_id = MP_User::get_id( $mp_confkey );
 198          if ( !$mp_user_id )                             return 9;
 199  
 200          $email     = MP_User::get_email( $mp_user_id );
 201  
 202          $mail_id = (int) filter_input( INPUT_GET, 'id' );
 203          $mail = MP_Mail::get( $mail_id );
 204          if ( !$mail )                                return 8;
 205  
 206          $title    = $mail->subject;
 207          $content = '';
 208  
 209          $is_email = ( MailPress::is_email( $mail->toemail ) );
 210  
 211          if ( $is_email && ( $email != $mail->toemail ) )    return 6;
 212                  
 213          if ( !$is_email )
 214          {
 215              $recipients = unserialize( $mail->toemail );
 216              if ( !( is_array( $recipients ) && ( isset( $recipients[$email] ) ) ) )     return 7;
 217  
 218              $m = MP_Mail_meta::get( $mail_id, '_MailPress_replacements' );
 219              if ( !is_array( $m ) ) $m = array();
 220  
 221              $replacements = array_merge( $m, $recipients[$email] );
 222  
 223              foreach ( $replacements as $k => $v ) $title = str_replace( $k, $v, $title );
 224  
 225              foreach( array( 'html', 'plaintext' ) as $type ) if ( !empty( $mail->{$type} ) ) {foreach( $replacements as $k => $v ) $mail->{$type} = str_replace( $k, $v, $mail->{$type}, $ch );};
 226          }
 227  
 228          if ( !empty( $mail->html ) )
 229          {
 230              $x = new MP_Mail();
 231              $content = $x->process_img( $mail->html, $mail->themedir, 'draft' );
 232          }
 233          elseif ( !empty( $mail->plaintext ) )
 234              $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>';
 235  /*
 236          $metas = MP_Mail_meta::has( $mail_id, '_MailPress_attached_file' );
 237          if ( $metas )
 238          {
 239              $content .= '<div id="attachments"><table><tr><td style="vertical-align:top;">' . __( 'Attachments', 'MailPress' ) . '</td><td><table>';
 240                          foreach( $metas as $meta ) { $content .= '<tr><td>&#160;' . MP_Mail::get_attachment_link( $meta, $mail->status ) . '</td></tr>'; }
 241              $content .= '</table></td></tr></table></div>' . "\n";
 242          }
 243  */
 244  
 245          if ( !isset( $mp_general['fullscreen'] ) )         return array( 'title' => $title, 'content' => $content );
 246          
 247          die( $content );
 248      }
 249  
 250  	public static function arch( $mp_confkey )
 251      {
 252          global $mp_general;
 253  
 254          if ( $mp_confkey )                             return 9;
 255  
 256          $mail_id = (int) filter_input( INPUT_GET, 'id' );
 257          $mail = MP_Mail::get( $mail_id );
 258          if ( !$mail )                                return 8;
 259          if ( 'archived' != $mail->status )                  return 8;
 260  
 261          $title    = $mail->subject;
 262          $content = '';
 263  
 264          if ( !empty( $mail->html ) )
 265          {
 266              $x = new MP_Mail();
 267              $content = $x->process_img( $mail->html, $mail->themedir, 'draft' );
 268          }
 269          elseif ( !empty( $mail->plaintext ) )
 270              $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>';
 271  
 272          if ( !isset( $mp_general['fullscreen'] ) )         return array( 'title' => $title, 'content' => $content );
 273          
 274          die( $content );
 275      }
 276  
 277  	public static function liun( $mp_confkey )
 278      {
 279          self::del( $mp_confkey );
 280      }
 281  }


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