PageRenderTime 68ms CodeModel.GetById 20ms RepoModel.GetById 0ms app.codeStats 0ms

/wp-content/plugins/event-espresso.3.1.23.P/includes/form-builder/questions/edit_question.php

https://bitbucket.org/anneivycat/ebcookhouse
PHP | 174 lines | 167 code | 4 blank | 3 comment | 18 complexity | c9698e82f50c7c81fbd919a1477d86e8 MD5 | raw file
  1. <?php
  2. //Function for editing existing questions
  3. function event_espresso_form_builder_edit(){
  4. global $wpdb;
  5. $question_id = $_REQUEST['question_id'];
  6. $sql = "SELECT * FROM " . EVENTS_QUESTION_TABLE . " WHERE id = '" . $question_id . "'";
  7. $questions = $wpdb->get_results($sql);
  8. if ($wpdb->num_rows > 0) {
  9. foreach ($questions as $question) {
  10. $question_id = $question->id;
  11. $question_name = stripslashes($question->question);
  12. $question_values = stripslashes($question->response);
  13. $question_type = stripslashes($question->question_type);
  14. $required = stripslashes($question->required);
  15. $sequence = $question->sequence;
  16. $required_text = $question->required_text;
  17. $admin_only = $question->admin_only;
  18. $system_name = $question->system_name;
  19. if ($question->system_name !=''){
  20. $system_question = true;
  21. } else {
  22. $system_question = false;
  23. }
  24. $wp_user = $question->wp_user;
  25. if ( function_exists( 'espresso_member_data' ) ) {
  26. if (function_exists( 'espresso_is_admin' ) ) {
  27. // If the user doesn't have admin access get only user's own question groups
  28. if ( !espresso_is_admin() ) {
  29. if ( espresso_member_data('id') != $wp_user ) {
  30. echo '<h2>' . __('Sorry, you do not have permission to edit this question group.', 'event_espresso') . '</h2>';
  31. return;
  32. }
  33. }
  34. }
  35. }
  36. ?>
  37. <div class="metabox-holder">
  38. <div class="postbox">
  39. <div class="handlediv" title="Click to toggle"><br>
  40. </div>
  41. <h3 class="hndle">
  42. <?php _e('Edit Question','event_espresso'); ?>
  43. </h3>
  44. <div class="inside">
  45. <form id="edit-new-question-form" name="newquestion" method="post" action="<?php echo $_SERVER["REQUEST_URI"]?>">
  46. <p class="intro"> <?php _e('Edit the question using the form below. By default all participants will be asked for their first name, last name, and email address.','event_espresso'); ?></p>
  47. <?php
  48. if ($system_question == true){
  49. echo '<p class="inform">'.__('Attention: This is a "System Question", some settings may be disabled.','event_espresso').'</p>';
  50. }
  51. ?>
  52. <table class="form-table">
  53. <tbody>
  54. <tr>
  55. <th>
  56. <label for="question"><?php _e('Question','event_espresso'); ?></label>
  57. </th>
  58. <td>
  59. <input name="question" id="question" size="50" value="<?php echo $question_name; ?>" type="text">
  60. </td>
  61. </tr>
  62. <tr>
  63. <th id="question-type-select">
  64. <label for="question_type"><?php _e('Type','event_espresso'); ?></label>
  65. </th>
  66. <td>
  67. <?php
  68. $q_values = array(
  69. array('id'=>'TEXT','text'=> __('Text','event_espresso')),
  70. array('id'=>'TEXTAREA','text'=> __('Text Area','event_espresso')),
  71. array('id'=>'SINGLE','text'=> __('Radio Button','event_espresso')),
  72. array('id'=>'DROPDOWN','text'=> __('Drop Down','event_espresso')),
  73. array('id'=>'MULTIPLE','text'=> __('Checkbox','event_espresso')),
  74. //array('id'=>'DATE','text'=> __('Date Picker','event_espresso'))
  75. );
  76. if ($system_question == true){
  77. $q_values=array(array('id'=>'TEXT','text'=> __('Text','event_espresso')));
  78. }
  79. echo select_input( 'question_type', $q_values, $question_type, 'id="question_type"');
  80. ?>
  81. </td>
  82. </tr>
  83. <tr id="add-question-values">
  84. <th>
  85. <label for="values"><?php _e('Values','event_espresso'); ?></label>
  86. </th>
  87. <td>
  88. <input name="values" id="values" size="50" value="<?php echo $question_values; ?>" type="text" />
  89. <br />
  90. <span class="description"><?php _e('A comma seperated list of values. Eg. black, blue, red', 'event_espresso'); ?></span>
  91. </td>
  92. </tr>
  93. <tr>
  94. <th>
  95. <label for="required"><?php _e('Required','event_espresso'); ?></label>
  96. </th>
  97. <td>
  98. <?php
  99. $values=array(
  100. array('id'=>'Y','text'=> __('Yes','event_espresso')),
  101. array('id'=>'N','text'=> __('No','event_espresso'))
  102. );
  103. if ($system_question == true && ($system_name =='fname'||$system_name =='lname'||$system_name =='email')){
  104. $values=array(array('id'=>'Y','text'=> __('Yes','event_espresso')));
  105. }
  106. echo select_input('required', $values, $required);
  107. ?><br />
  108. <span class="description"><?php _e('Mark this question as required.', 'event_espresso'); ?></span>
  109. </td>
  110. </tr>
  111. <tr>
  112. <th>
  113. <label for="admin_only">
  114. <?php _e('Admin View Only','event_espresso'); ?>
  115. </label>
  116. </th>
  117. <td>
  118. <?php
  119. $values=array(
  120. array('id'=>'Y','text'=> __('Yes','event_espresso')),
  121. array('id'=>'N','text'=> __('No','event_espresso'))
  122. );
  123. if ($system_question == true && ($system_name =='fname'||$system_name =='lname'||$system_name =='email')){
  124. $values=array(array('id'=>'N','text'=> __('No','event_espresso')));
  125. }
  126. echo select_input('admin_only', $values, $admin_only);
  127. ?><br />
  128. <span class="description"><?php _e('Only the administrator can see this field.', 'event_espresso'); ?></span>
  129. </td>
  130. </tr>
  131. <tr>
  132. <th>
  133. <label for="required_text">
  134. <?php _e('Required Text','event_espresso'); ?>
  135. </label>
  136. </th>
  137. <td>
  138. <input name="required_text" id="required_text" size="50" value="<?php echo $required_text; ?>" type="text" /><br />
  139. <span class="description"><?php _e('Text displayed if not completed.', 'event_espresso'); ?></span>
  140. </td>
  141. </tr>
  142. <tr>
  143. <th>
  144. <label for="sequence">
  145. <?php _e('Order/Sequence','event_espresso'); ?>
  146. </label>
  147. </th>
  148. <td>
  149. <input name="sequence" id="sequence" size="50" value="<?php echo $sequence; ?>" type="text" />
  150. </td>
  151. </tr>
  152. </tbody>
  153. </table>
  154. <p class="submit-footer">
  155. <input name="edit_action" value="update" type="hidden">
  156. <input type="hidden" name="action" value="edit_question">
  157. <input name="question_id" value="<?php echo $question_id; ?>" type="hidden">
  158. <input class="button-primary" name="Submit" value="Update Question" type="submit">
  159. <?php wp_nonce_field( 'espresso_form_check', 'edit_question' ) ?>
  160. </p>
  161. </form>
  162. </div>
  163. </div>
  164. </div>
  165. <?php
  166. }
  167. }else{
  168. _e('Nothing found!','event_espresso');
  169. }
  170. }