Exemplo n.º 1
0
 function event_espresso_add_question_groups($question_groups, $answer = '', $event_id = null, $multi_reg = 0, $meta = array())
 {
     global $wpdb;
     $event_id = empty($_REQUEST['event_id']) ? $event_id : $_REQUEST['event_id'];
     if (count($question_groups) > 0) {
         $questions_in = '';
         $FILTER = '';
         if (isset($_REQUEST['regevent_action'])) {
             $FILTER = " AND q.admin_only = 'N' ";
         }
         //echo 'additional_attendee_reg_info = '.$meta['additional_attendee_reg_info'].'<br />';
         //Only personal inforamation for the additional attendees in each group
         if (isset($meta['additional_attendee_reg_info']) && $meta['additional_attendee_reg_info'] == '2' && isset($meta['attendee_number']) && $meta['attendee_number'] > 1) {
             $FILTER .= " AND qg.system_group = 1 ";
         }
         if (!is_array($question_groups) && !empty($question_groups)) {
             $question_groups = unserialize($question_groups);
         }
         foreach ($question_groups as $g_id) {
             $questions_in .= $g_id . ',';
         }
         $questions_in = substr($questions_in, 0, -1);
         $group_name = '';
         $counter = 0;
         $sql = "SELECT q.*, qg.group_name, qg.group_description, qg.show_group_name, qg.show_group_description, qg.group_identifier\n\t\t\t\t\tFROM " . EVENTS_QUESTION_TABLE . " q\n\t\t\t\t\tJOIN " . EVENTS_QST_GROUP_REL_TABLE . " qgr ON q.id = qgr.question_id\n\t\t\t\t\tJOIN " . EVENTS_QST_GROUP_TABLE . " qg ON qg.id = qgr.group_id\n\t\t\t\t\tWHERE qgr.group_id in ( " . $questions_in . ")\n\t\t\t\t\t" . $FILTER . "\n\t\t\t\t\tORDER BY qg.group_order ASC, qg.id, q.sequence, q.id ASC";
         //echo $sql;
         $questions = $wpdb->get_results($sql);
         $num_rows = $wpdb->num_rows;
         $html = '';
         if ($num_rows > 0) {
             $questions_displayed = array();
             foreach ($questions as $question) {
                 $counter++;
                 if (!in_array($question->id, $questions_displayed)) {
                     $questions_displayed[] = $question->id;
                     //if new group, close fieldset
                     $html .= $group_name != '' && $group_name != $question->group_name ? '</div>' : '';
                     if ($group_name != $question->group_name) {
                         $html .= '<div class="event_questions" id="' . $question->group_identifier . '">';
                         $html .= $question->show_group_name != 0 ? "<h4 class=\"reg-quest-title section-title\">{$question->group_name}</h4>" : '';
                         $html .= $question->show_group_description != 0 && $question->group_description == true ? "<p class='quest-group-descript'>{$question->group_description}</p>" : '';
                         $group_name = $question->group_name;
                     }
                     $html .= event_form_build($question, $answer, $event_id, $multi_reg, $meta);
                 }
                 $html .= $counter == $num_rows ? '</div>' : '';
             }
         }
         //end questions display
     } else {
         $html = '';
     }
     return $html;
 }
Exemplo n.º 2
0
 function event_espresso_add_question_groups($question_groups, $answer = '', $event_id = null, $multi_reg = 0, $meta = array(), $class = 'my_class')
 {
     global $wpdb;
     //If memebers addon is installed, check to see if we want to disable the form fields for members
     $disabled = '';
     if (function_exists('espresso_members_installed') && espresso_members_installed() == true) {
         $member_options = get_option('events_member_settings');
         if (is_user_logged_in() && !empty($member_options['autofilled_editable']) && $member_options['autofilled_editable'] == 'N') {
             $disabled = 'disabled="disabled"';
         }
     }
     $event_id = empty($_REQUEST['event_id']) ? $event_id : $_REQUEST['event_id'];
     if (count($question_groups) > 0) {
         $questions_in = '';
         $FILTER = '';
         if (isset($_REQUEST['regevent_action'])) {
             $FILTER = " AND q.admin_only != 'Y' ";
         }
         //echo 'additional_attendee_reg_info = '.$meta['additional_attendee_reg_info'].'<br />';
         //Only personal information for the additional attendees in each group
         if (isset($meta['additional_attendee_reg_info']) && $meta['additional_attendee_reg_info'] == '2' && isset($meta['attendee_number']) && $meta['attendee_number'] > 1) {
             $FILTER .= " AND qg.system_group = 1 ";
         }
         if (!is_array($question_groups) && !empty($question_groups)) {
             $question_groups = unserialize($question_groups);
         }
         //Debug
         //echo "<pre>".print_r($question_groups,true)."</pre>";
         foreach ($question_groups as $g_id) {
             $questions_in .= $g_id . ',';
         }
         $questions_in = substr($questions_in, 0, -1);
         $group_name = '';
         $counter = 0;
         $sql = "SELECT q.*, qg.group_name, qg.group_description, qg.show_group_name, qg.show_group_description, qg.group_identifier\n\t\t\t\t\tFROM " . EVENTS_QUESTION_TABLE . " q\n\t\t\t\t\tJOIN " . EVENTS_QST_GROUP_REL_TABLE . " qgr ON q.id = qgr.question_id\n\t\t\t\t\tJOIN " . EVENTS_QST_GROUP_TABLE . " qg ON qg.id = qgr.group_id\n\t\t\t\t\tWHERE qgr.group_id in ( {$questions_in} ) {$FILTER}\n\t\t\t\t\tORDER BY qg.group_order ASC, qg.id, q.sequence, q.id ASC";
         //echo $sql;
         $questions = $wpdb->get_results($sql);
         $num_rows = $wpdb->num_rows;
         $html = '';
         if ($num_rows > 0) {
             $questions_displayed = array();
             foreach ($questions as $question) {
                 $counter++;
                 if (!in_array($question->id, $questions_displayed)) {
                     $questions_displayed[] = $question->id;
                     //if new group, close fieldset
                     $html .= $group_name != '' && $group_name != $question->group_name ? '</fieldset>' : '';
                     if ($group_name != $question->group_name) {
                         $html .= '<fieldset class="event_questions" id="' . $question->group_identifier . '">';
                         $html .= $question->show_group_name != 0 ? "<h4 class=\"reg-quest-title section-title\">" . stripslashes_deep($question->group_name) . "</h4>" : '';
                         $html .= $question->show_group_description != 0 && $question->group_description == true ? '<p class="quest-group-descript">' . stripslashes_deep($question->group_description) . '</p>' : '';
                         $group_name = stripslashes_deep($question->group_name);
                     }
                     $html .= event_form_build($question, $answer, $event_id, $multi_reg, $meta, $class, $disabled);
                 }
                 $html .= $counter == $num_rows ? '</fieldset>' : '';
             }
         }
         //end questions display
     } else {
         $html = '';
     }
     return $html;
 }