/** * 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(); }
/* * this file is called by the admin menu item, also a link in the admin record list * * submission processing happens in Participants_Db::process_page_request on the * admin_init action * */ if (!isset($participant_id)) { // if there is no id in the request, use the default record $participant_id = isset($_REQUEST['id']) ? $_REQUEST['id'] : false; } if (false === $participant_id) { $action = 'insert'; $page_title = __('Add New Participant Record', 'participants-database'); $participant_values = Participants_Db::get_default_record(); } else { $action = 'update'; $page_title = __('Edit Existing Participant Record', 'participants-database'); $participant_values = Participants_Db::get_participant($participant_id); } /* * if we have a valid ID or are creating a new record, show the form */ if ($participant_values) { //error_log( basename( __FILE__).' default record:'.print_r( $participant_values,1)); //get the groups info $groups = Participants_Db::get_groups(); // get the current user's info get_currentuserinfo(); $options = get_option(self::$participants_db_options);
/** * 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(); }