[ Index ]

MailPress 7.1

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

title

Body

[close]

/mp-admin/includes/ -> autoresponders.php (source)

   1  <?php
   2  
   3  if ( !( function_exists( 'current_user_can' ) && current_user_can( MP_AdminPage::capability ) ) ) die( 'Access denied' );
   4  
   5  $url_parms = MP_AdminPage::get_url_parms();
   6  
   7  //
   8  // MANAGING H1
   9  //
  10  
  11  $h1 = __( 'Autoresponders', 'MailPress' );
  12  
  13  //
  14  // MANAGING MESSAGE
  15  //
  16  
  17  $messages[1] = __( 'Autoresponder added.', 'MailPress' );
  18  $messages[2] = __( 'Autoresponder updated.', 'MailPress' );
  19  $messages[3] = __( 'Autoresponder deleted.', 'MailPress' );
  20  $messages[4] = __( 'Autoresponders deleted.', 'MailPress' );
  21  $messages[91] = __( 'Autoresponder not added.', 'MailPress' );
  22  $messages[92] = __( 'Autoresponder not updated.', 'MailPress' );
  23  
  24  if ( isset( MP_AdminPage::$get_['message'] ) )
  25  {
  26      $message = $messages[MP_AdminPage::$get_['message']];
  27      $_SERVER['REQUEST_URI'] = remove_query_arg( array( 'message' ), $_SERVER['REQUEST_URI'] );
  28  }
  29  
  30  //
  31  // MANAGING BULK ACTIONS
  32  //
  33  
  34  $bulk_actions['']         = __( 'Bulk Actions' );
  35  $bulk_actions['delete']    = __( 'Delete', 'MailPress' );
  36  
  37  //
  38  // MANAGING CONTENT
  39  //
  40  
  41  $mp_autoresponder_registered_events = MP_Autoresponder_events::get_all();
  42  
  43  global $action;
  44  wp_reset_vars( array( 'action' ) );
  45  if ( 'edit' == $action ) 
  46  {
  47      $action = 'edited';
  48      $cancel = '<input type="submit" name="cancel" class="button" value="' . esc_attr( __( 'Cancel', 'MailPress' ) ) . '" />';
  49  
  50      $id = ( int ) MP_AdminPage::$get_['id'];
  51      $autoresponder = MP_Autoresponder::get( $id );
  52  
  53      $h3 = __( 'Edit Autoresponder', 'MailPress' );
  54      $hb3= __( 'Update' );
  55      $hbclass = '-primary';
  56  
  57      $disabled = '';
  58          
  59      $hidden =  '<input type="hidden" name="id"   value="' . $id . '" />';
  60      $hidden .= '<input type="hidden" name="name" value="' . esc_attr( $autoresponder->name ) . '"/>';
  61      
  62      $_mails = MP_Autoresponder::get_term_objects( $id );
  63  }
  64  else 
  65  {
  66      $action = MP_AdminPage::add_form_id;
  67      $cancel = '';
  68  
  69      $autoresponder = new stdClass();
  70  
  71      $h3 = $hb3 = __( 'Add Autoresponder', 'MailPress' );
  72      $hbclass = '';
  73  
  74      $disabled = '';
  75      $hidden = '';
  76  
  77      $_mails = false;
  78  }
  79  
  80  //
  81  // MANAGING LIST
  82  //
  83  
  84  $url_parms['paged'] = isset( $url_parms['paged'] ) ? $url_parms['paged'] : 1;
  85  $_per_page = MP_AdminPage::get_per_page();
  86  
  87  $total = ( isset( $url_parms['s'] ) ) ? count( MP_Autoresponder::get_all( array( 'hide_empty' => 0, 'search' => $url_parms['s'] ) ) ) : wp_count_terms( MP_AdminPage::taxonomy );
  88  
  89  ?>
  90  <div class="wrap nosubsub">
  91      <h1>
  92          <?php echo esc_html( $h1 ); ?> 
  93  <?php if ( isset( $url_parms['s'] ) ) printf( '<span class="subtitle">' . __( 'Search results for &#8220;%s&#8221;' ) . '</span>', esc_attr( $url_parms['s'] ) ); ?>
  94      </h1>
  95  <?php if ( isset( $message ) ) MP_AdminPage::message( $message, ( MP_AdminPage::$get_['message'] < 90 ) ); ?>
  96      <form class="search-form topmargin" method="get">
  97  
  98          <input type="hidden" name="page" value="<?php echo MP_AdminPage::screen; ?>" />
  99  
 100          <p class="search-box">
 101              <input type="text" name="s" class="search-input" value="<?php if ( isset( $url_parms['s'] ) ) echo esc_attr( $url_parms['s'] ); ?>" />
 102              <input type="submit" class="button" value="<?php _e( 'Search', 'MailPress' ); ?>" />
 103          </p>
 104  
 105      </form>
 106      <br class="clear" />
 107      <div id="col-container">
 108          <div id="col-right">
 109              <div class="col-wrap">
 110                  <form id="posts-filter" method="get">
 111  
 112                      <input type="hidden" name="page" value="<?php echo MP_AdminPage::screen; ?>" />
 113  
 114                      <div class="tablenav top">
 115  <?php MP_AdminPage::pagination( $total ); ?>
 116                          <div class="alignleft actions bulkactions">
 117  <?php    MP_AdminPage::get_bulk_actions( $bulk_actions ); ?>
 118                          </div>
 119                          <br class="clear" />
 120                      </div>
 121                      <div class="clear"></div>
 122                      <table class="wp-list-table widefat fixed striped <?php echo MP_AdminPage::tr_prefix_id; ?>">
 123                          <thead>
 124                              <tr>
 125  <?php MP_AdminPage::columns_list(); ?>
 126                              </tr>
 127                          </thead>
 128                          <tbody id="<?php echo MP_AdminPage::list_id; ?>" class="list:<?php echo MP_AdminPage::tr_prefix_id; ?> autoresponders">
 129  <?php MP_AdminPage::get_list( array( 'start' => $url_parms['paged'], '_per_page' => $_per_page ) ); ?>
 130                          </tbody>
 131                          <tfoot>
 132                              <tr>
 133  <?php MP_AdminPage::columns_list( false ); ?>
 134                              </tr>
 135                          </tfoot>
 136                      </table>
 137                      <div class="tablenav bottom">
 138  <?php MP_AdminPage::pagination( $total, 'bottom' ); ?>
 139                          <div class="alignleft actions bulkactions">
 140  <?php    MP_AdminPage::get_bulk_actions( $bulk_actions, 'action2' ); ?>
 141                          </div>
 142                          <br class="clear" />
 143                      </div>
 144                      <br class="clear" />
 145                  </form>
 146              </div>
 147          </div><!-- /col-right -->
 148          <div id="col-left">
 149              <div class="col-wrap">
 150                  <div class="form-wrap">
 151                      <h3><?php echo esc_html( $h3 ); ?></h3>
 152                      <div id="ajax-response"></div>
 153                      <form name="<?php echo $action; ?>"  id="<?php echo $action; ?>"  method="post" class="<?php echo $action; ?>:<?php echo MP_AdminPage::list_id; ?>: validate">
 154  
 155                          <input type="hidden" name="action"   value="<?php echo $action; ?>" />
 156                          <input type="hidden" name="formname" value="autoresponder_form" />
 157                          <?php echo $hidden; ?>
 158                          <?php wp_nonce_field( 'update-' . MP_AdminPage::tr_prefix_id ); ?>
 159  
 160                          <div class="form-field form-required nopm">
 161                              <label for="autoresponder_name"><?php _e( 'Name', 'MailPress' ); ?></label>
 162                              <input type="text" name="name" id="autoresponder_name" size="40" aria-required="true"<?php echo $disabled; ?> value="<?php if ( isset( $autoresponder->name ) ) echo esc_attr( $autoresponder->name ); ?>" />
 163                              <p><?php _e( 'The name is used to identify the autoresponder almost everywhere.', 'MailPress' ); ?></p>
 164                          </div>
 165                          <div class="form-field nopm">
 166                              <label for="autoresponder_slug"><?php _e( 'Slug', 'MailPress' ) ?></label>
 167                              <input type="text" name="slug" id="autoresponder_slug" size="40" value="<?php if ( isset( $autoresponder->slug ) ) echo esc_attr( $autoresponder->slug ); ?>" />
 168                              <p><?php _e( 'The &#8220;slug&#8221; is a unique id for the autoresponder (not so friendly !).', 'MailPress' ); ?></p>
 169                          </div>
 170                          <div class="form-field nopm">
 171                              <label for="autoresponder_description"><?php _e( 'Description', 'MailPress' ) ?></label>
 172                              <input type="text" name="description[desc]" id="autoresponder_description" size="40" value="<?php if ( isset( $autoresponder->description ) ) echo htmlentities( stripslashes( $autoresponder->description['desc'] ),ENT_QUOTES ); ?>" />
 173                              <p><?php _e( 'The description is not prominent by default.', 'MailPress' ); ?></p>
 174                          </div>
 175                          <div class="form-field nopm">
 176                              <label for="autoresponder_active"><?php _e( 'Active', 'MailPress' ) ?></label>
 177                              <input type="checkbox" name="description[active]" class="wa" id="autoresponder_active"<?php checked( isset( $autoresponder->description['active'] ) ); ?> />
 178                              <p><?php _e( "If unchecked during a certain period of time, All mails that should have been sent on time will be cancelled. Following mails (if any) will be lost as well.", 'MailPress' ); ?></p>
 179                          </div>
 180                          <div class="form-field nopm">
 181                              <label for="autoresponder_event"><?php _e( 'Event', 'MailPress' ) ?></label>
 182                              <select name="description[event]" id="autoresponder_event">
 183  <?php MP_AdminPage::select_option( $mp_autoresponder_registered_events, ( isset( $autoresponder->description['event'] ) ) ? $autoresponder->description['event'] : '' ); ?>
 184                              </select>
 185                          </div>
 186                          <div id="autoresponder_events_specs">
 187  <?php foreach ( $mp_autoresponder_registered_events as $key => $event ) : ?>
 188                              <div id="autoresponder_<?php echo $key; ?>_settings" class="autoresponder_settings <?php if ( !isset( $autoresponder->description['event'] ) || $key != $autoresponder->description['event'] ) echo " hidden"; ?>">
 189  <?php do_action( "MailPress_autoresponder_{$key}_settings_form", ( isset( $autoresponder->description['settings'] ) ) ? $autoresponder->description['settings'] : 0 ); ?>
 190                              </div>
 191  <?php endforeach; ?>
 192                          </div>
 193  <?php if ( $_mails ) : ?>
 194                          <div class="form-field nopm">
 195                              <label><?php _e( 'Mails', 'MailPress' ) ?></label>
 196                              <table class="wp-list-table widefat fixed striped autoresponder" id="autoresponder_mails">
 197                                  <thead>
 198                                      <tr>
 199                                          <th><?php _e( 'mail', 'MailPress' ); ?></th>
 200                                          <th><?php _e( 'subject', 'MailPress' ); ?></th>
 201                                          <th><?php _e( 'y/m/w/d/h', 'MailPress' ); ?></th>
 202                                      </tr>
 203                                  </thead>
 204                                  <tbody>
 205  <?php     foreach( $_mails as $_mail ) 
 206          { 
 207              $id   = $_mail['mail_id'];
 208              $mail = MP_Mail::get( $id );
 209              $subject_display = htmlspecialchars( $mail->subject,ENT_QUOTES );
 210              if ( strlen( $subject_display ) > 40 )    $subject_display = mb_substr( $subject_display, 0, 39, get_option( 'blog_charset' ) ) . '...';
 211              if ( '' == $mail->subject )              $subject_display = $mail->subject = htmlspecialchars( __( '(no subject)', 'MailPress' ),ENT_QUOTES );
 212  
 213              $edit_url        = esc_url( MailPress_edit . "&id=$id" );
 214              $actions['edit']    = '<a href="' . $edit_url . '" title="' . esc_attr( sprintf( __( 'Edit &#8220;%1$s&#8221;', 'MailPress' ) , $subject_display ) ) . '">' . $_mail['mail_id'] . '</a>';
 215  
 216              $args = array( 'id' => $id, 'action' => 'mp_ajax', 'mp_action' => 'iview', 'TB_iframe' => 'true' );
 217              $view_url = esc_url( add_query_arg( $args, admin_url( 'admin-ajax.php' ) ) );
 218              $actions['view'] = '<a href="' . $view_url . '" class="thickbox thickbox-preview" title="' . esc_attr( sprintf( __( 'View &#8220;%1$s&#8221;', 'MailPress' ) , $subject_display ) ) . '">' . $subject_display . '</a>';
 219  ?>
 220                                      <tr>
 221                                          <td>
 222                                              <?php echo $actions['edit']; ?>
 223                                          </td>
 224                                          <td>
 225                                              <?php echo $actions['view']; ?>
 226                                          </td>
 227                                          <td>
 228                                              <?php unset( $_mail['schedule']['date'] ); echo implode( '/', $_mail['schedule'] ); ?>
 229                                          </td>
 230                                      </tr>
 231  <?php     } ?>
 232                                  </tbody>
 233                              </table>
 234                              <p></p>
 235                          </div>
 236  <?php endif; ?>
 237                          <p class="submit">
 238                              <input type="submit" name="submit" id="autoresponder_submit" class="button<?php echo $hbclass; ?>" value="<?php echo $hb3; ?>" />
 239                              <?php echo $cancel; ?>
 240                          </p>
 241                      </form>
 242                  </div>
 243              </div>
 244          </div><!-- /col-left -->
 245      </div><!-- /col-container -->
 246  </div><!-- /wrap -->


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