예제 #1
0
 /**
  * initializes the record edit object
  */
 public function __construct($shortcode_atts)
 {
     // define shortcode-specific attributes to use
     $add_atts = array('module' => 'single', 'class' => $this->wrap_class, 'term' => 'id');
     // run the parent class initialization to set up the parent methods
     parent::__construct($shortcode_atts, $add_atts);
     /*
      * determine the ID of the record to show
      *
      * 'pdb' is a generic $_GET variable that indexes the record according to
      * the 'term' value, which defaults to 'id'
      *
      */
     if ($this->shortcode_atts['record_id'] !== false) {
         $id = $this->shortcode_atts['record_id'];
     } else {
         $id = 0;
     }
     // override the shortcode att if the value is in the URI
     if (isset($_GET['pdb'])) {
         $id = $_GET['pdb'];
     }
     $record_id = Participants_Db::get_record_id_by_term($this->shortcode_atts['term'], $id);
     if (false === $record_id) {
         $this->_not_found();
     } else {
         $this->participant_values = Participants_Db::get_participant($record_id);
         $this->participant_id = $record_id;
         $this->_setup_iteration();
         $this->_print_from_template();
     }
 }
 /**
  * initializes the record edit object
  */
 public function __construct($shortcode_atts)
 {
     // define shortcode-specific attributes to use
     $add_atts = array('module' => 'record', 'class' => 'edit-participant ' . $this->wrap_class, 'submit_button' => Participants_Db::plugin_setting('save_changes_button'));
     // run the parent class initialization to set up the parent methods
     parent::__construct($shortcode_atts, $add_atts);
     $this->_setup_multipage();
     // set the action URI for the form
     $this->_set_submission_page();
     if (false === $this->shortcode_atts['record_id']) {
         $this->_not_found();
     } else {
         $this->participant_id = $this->shortcode_atts['record_id'];
         $this->participant_values = Participants_Db::get_participant($this->participant_id);
         if ($this->participant_values === false) {
             $this->_not_found();
         } else {
             // update the access timestamp
             Participants_Db::set_record_access($this->participant_id);
             $this->_get_validation_errors();
             $this->_setup_iteration();
             $this->_print_from_template();
         }
     }
 }
예제 #3
0
 /**
  * instantiates the signup form object
  *
  * this class is called by a WP shortcode
  *
  * @param array $shortcode_atts   this array supplies the display parameters for the instance
  *                 'title'   string displays a title for the form (default none)
  *
  */
 public function __construct($shortcode_atts)
 {
     // define shortcode-specific attributes to use
     $shortcode_defaults = array('module' => 'signup');
     $sent = true;
     // start by assuming the notification email has been sent
     /*
      * this is set true if the form is a multi-page form. This is so a multi-page form 
      * can't be completed by skipping back to the signup form, they must go to a page 
      * with a thanks shortcode
      */
     $redirected = false;
     if ($shortcode_atts['module'] != 'thanks' && (isset($shortcode_atts['action']) && $shortcode_atts['action'] !== '')) {
         // this is set true if the signup form is supposed to be redirected after the submission
         $redirected = true;
     }
     if (isset($_GET['m']) && $_GET['m'] == 'r' || $shortcode_atts['module'] == 'retrieve') {
         /*
          * we're proceesing a link retrieve request
          */
         $shortcode_atts['module'] = 'retrieve';
     } elseif ($this->participant_id = Participants_Db::$session->get('pdbid')) {
         /*
          * the submission is successful, clear the session
          */
         Participants_Db::$session->clear('pdbid');
         Participants_Db::$session->clear('captcha_vars');
         Participants_Db::$session->clear('captcha_result');
         $this->participant_values = Participants_Db::get_participant($this->participant_id);
         if ($this->participant_values && !$redirected) {
             // check the notification sent status of the record
             $sent = $this->check_sent_status($this->participant_id);
             $this->submitted = true;
             $shortcode_atts['module'] = 'thanks';
         }
         $shortcode_atts['id'] = $this->participant_id;
     } elseif ($shortcode_atts['module'] == 'signup') {
         /*
          * we're showing the signup form
          */
         $this->participant_values = Participants_Db::get_default_record();
     } else {
         /*
          * there was no type set
          */
         return;
     }
     // run the parent class initialization to set up the $shortcode_atts property
     parent::__construct($shortcode_atts, $shortcode_defaults);
     $this->registration_page = Participants_Db::get_record_link($this->participant_values['private_id']);
     // set up the signup form email preferences
     $this->_set_email_prefs();
     // set the action URI for the form
     $this->_set_submission_page();
     // set up the template iteration object
     $this->_setup_iteration();
     if ($this->submitted) {
         /*
          * filter provides access to the freshly-stored record and the email and thanks message properties so user feedback can be altered.
          */
         if (has_filter(Participants_Db::$prefix . 'before_signup_thanks')) {
             $signup_feedback_props = array('recipient', 'receipt_subject', 'receipt_body', 'notify_recipients', 'notify_subject', 'notify_body', 'thanks_message', 'participant_values');
             $signup_feedback = new stdClass();
             foreach ($signup_feedback_props as $prop) {
                 $signup_feedback->{$prop} =& $this->{$prop};
             }
             apply_filters(Participants_Db::$prefix . 'before_signup_thanks', $signup_feedback);
         }
         /*
          * check to see if the thanks email has been sent and send it if it has not
          */
         if ($sent === false) {
             $this->_send_email();
             // mark the record as sent
             $this->update_sent_status($this->participant_id, true);
         } else {
             return false;
         }
         // the thanks message and email have already been sent for this ID
     }
     // print the shortcode output
     $this->_print_from_template();
 }
 /**
  * sets up the array of display columns
  *
  * @global object $wpdb
  */
 protected function _set_shortcode_display_columns()
 {
     if (empty($this->shortcode_atts['groups'])) {
         $this->display_columns = $this->get_list_display_columns('display_column');
     } else {
         parent::_set_shortcode_display_columns();
     }
 }
예제 #5
0
 /**
  * sets up the main list columns
  */
 private static function setup_display_columns()
 {
     global $wpdb;
     $sql = '
       SELECT f.name, f.form_element, f.default, f.group, f.title
       FROM ' . Participants_Db::$fields_table . ' f 
       WHERE f.name IN ("' . implode('","', PDb_Shortcode::get_list_display_columns('admin_column')) . '") 
       ORDER BY f.admin_column ASC';
     self::$display_columns = $wpdb->get_results($sql);
 }
예제 #6
0
 /**
  * initializes and outputs the list on the frontend as called by the shortcode
  *
  * @param array $shortcode_atts display customization parameters
  *                              from the shortcode
  */
 public function __construct($shortcode_atts)
 {
     // set the list limit value; this can be overridden by the shortcode atts later
     $this->page_list_limit = intval((!isset($_POST['list_limit']) or !is_numeric($_POST['list_limit']) or $_POST['list_limit'] < 1) ? Participants_Db::$plugin_options['list_limit'] : $_POST['list_limit']);
     // define the default settings for the shortcode
     $shortcode_defaults = array('sort' => 'false', 'search' => 'false', 'list_limit' => $this->page_list_limit, 'class' => 'participants-database', 'filter' => '', 'orderby' => Participants_Db::$plugin_options['list_default_sort'], 'order' => Participants_Db::$plugin_options['list_default_sort_order'], 'fields' => '', 'single_record_link' => '', 'display_count' => Participants_Db::$plugin_options['show_count'], 'template' => 'default', 'module' => 'list', 'action' => '', 'suppress' => '');
     // run the parent class initialization to set up the parent methods
     parent::__construct($shortcode_atts, $shortcode_defaults);
     //    error_log( __METHOD__.' $this->shortcode_atts:'.print_r( $this->shortcode_atts,1 ));
     $this->registration_page_url = get_bloginfo('url') . '/' . (isset(Participants_Db::$plugin_options['registration_page']) ? Participants_Db::$plugin_options['registration_page'] : '');
     /*
      * set the initial sortable field list; this is the set of all fields that are 
      * both marked "sortable" and currently displayed in the list
      */
     $this->sortables = Participants_Db::get_sortables();
     //    $this->sortables = Participants_Db::get_sortables(Participants_Db::get_sortables() + $this->display_columns);
     $this->_setup_i18n();
     $this->_set_single_record_url();
     /*
      * if the 'suppress' shortcode attribute is set
      */
     if (!empty($this->shortcode_atts['suppress'])) {
         $this->suppress = true;
     }
     // enqueue the filter/sort AJAX script
     if ($this->_sort_filter_mode() !== 'none' and Participants_Db::$plugin_options['ajax_search'] == 1) {
         global $wp_query;
         $ajax_params = array('ajaxurl' => admin_url('admin-ajax.php'), 'filterNonce' => wp_create_nonce(Participants_Db::$prefix . 'list-filter-nonce'), 'postID' => isset($wp_query->post) ? $wp_query->post->ID : '', 'prefix' => Participants_Db::$prefix, 'loading_indicator' => Participants_Db::get_loading_spinner(), 'i18n' => $this->i18n);
         wp_localize_script(Participants_Db::$prefix . 'list-filter', 'PDb_ajax', $ajax_params);
         wp_enqueue_script(Participants_Db::$prefix . 'list-filter');
     }
     // set up the iteration data
     $this->_setup_iteration();
     $this->_print_from_template();
 }
 /**
  * instantiates the signup form object
  *
  * @param array $shortcode_atts   this array supplies the display parameters for the instance
  *
  */
 public function __construct($shortcode_atts)
 {
     // define shortcode-specific attributes to use
     $shortcode_defaults = array('module' => 'signup', 'submit_button' => Participants_Db::plugin_setting('signup_button_text'), 'edit_record_page' => Participants_Db::plugin_setting('registration_page'));
     /*
      * status values: normal (signup form submission) or multipage
      */
     $form_status = $this->get_form_status();
     /*
      * get the record ID from the last submission or current multiform
      */
     $this->participant_id = Participants_Db::$session->get('pdbid');
     /*
      * if we've opened a regular signup form while in a multipage session, treat it 
      * as a normal signup form and terminate the multipage session
      */
     if ($shortcode_atts['module'] === 'signup' && $this->participant_id !== false && !isset($shortcode_atts['action']) && $form_status === 'multipage') {
         $this->participant_id = false;
         $this->_clear_multipage_session();
     }
     /*
      * if no ID is set, no submission has been received
      */
     if ($this->participant_id === false) {
         if (filter_input(INPUT_GET, 'm') === 'r' || $shortcode_atts['module'] == 'retrieve') {
             /*
              * we're proceesing a link retrieve request
              */
             $shortcode_atts['module'] = 'retrieve';
             add_filter('pdb-before_field_added_to_iterator', array($this, 'allow_readonly_fields_in_form'));
         }
         if ($shortcode_atts['module'] == 'signup') {
             /*
              * we're showing the signup form
              */
             $this->participant_values = Participants_Db::get_default_record();
         }
     } else {
         /*
          * if we arrive here, the form has been submitted and is complete or is a multipage 
          * form and we've come back to the signup shortcode before the form was completed: 
          * in which case we show the saved values from the record
          */
         $this->participant_values = Participants_Db::get_participant($this->participant_id);
         if ($this->participant_values && ($form_status === 'normal' || $shortcode_atts['module'] == 'thanks' && $form_status === 'multipage')) {
             /*
              * the submission is successful, clear the session and set the submitted flag
              */
             $this->_clear_multipage_session();
             $this->submitted = true;
             $shortcode_atts['module'] = 'thanks';
         }
         $shortcode_atts['id'] = $this->participant_id;
     }
     // run the parent class initialization to set up the $shortcode_atts property
     parent::__construct($shortcode_atts, $shortcode_defaults);
     // set up the signup form email preferences
     $this->_set_email_prefs();
     // set the action URI for the form
     $this->_set_submission_page();
     // set up the template iteration object
     $this->_setup_iteration();
     if ($this->submitted) {
         /*
          * filter provides access to the freshly-stored record and the email and 
          * thanks message properties so user feedback can be altered.
          * 
          * filter: pdb-before_signup_thanks
          */
         if (has_filter(Participants_Db::$prefix . 'before_signup_thanks')) {
             $signup_feedback_props = array('recipient', 'receipt_subject', 'receipt_body', 'notify_recipients', 'notify_subject', 'notify_body', 'thanks_message', 'participant_values');
             $signup_feedback = new stdClass();
             foreach ($signup_feedback_props as $prop) {
                 $signup_feedback->{$prop} =& $this->{$prop};
             }
             apply_filters(Participants_Db::$prefix . 'before_signup_thanks', $signup_feedback);
         }
         $this->_send_email();
         // form has been submitted, close it
         Participants_Db::$session->clear('form_status');
     }
     // print the shortcode output
     $this->_print_from_template();
 }