@@ -10,112 +10,112 @@ |
||
| 10 | 10 | class EE_Post_Meta extends EE_Base_Class |
| 11 | 11 | { |
| 12 | 12 | |
| 13 | - /** |
|
| 14 | - * @param array $props_n_values |
|
| 15 | - * @return EE_Post_Meta|mixed |
|
| 16 | - */ |
|
| 17 | - public static function new_instance($props_n_values = array()) |
|
| 18 | - { |
|
| 19 | - $has_object = parent::_check_for_object($props_n_values, __CLASS__); |
|
| 20 | - return $has_object ? $has_object : new self($props_n_values); |
|
| 21 | - } |
|
| 22 | - |
|
| 23 | - |
|
| 24 | - /** |
|
| 25 | - * @param array $props_n_values |
|
| 26 | - * @return EE_Post_Meta |
|
| 27 | - */ |
|
| 28 | - public static function new_instance_from_db($props_n_values = array()) |
|
| 29 | - { |
|
| 30 | - return new self($props_n_values, true); |
|
| 31 | - } |
|
| 32 | - |
|
| 33 | - |
|
| 34 | - /** |
|
| 35 | - * Gets meta_id |
|
| 36 | - * |
|
| 37 | - * @return int |
|
| 38 | - */ |
|
| 39 | - public function meta_id() |
|
| 40 | - { |
|
| 41 | - return $this->get('meta_id'); |
|
| 42 | - } |
|
| 43 | - |
|
| 44 | - |
|
| 45 | - /** |
|
| 46 | - * Sets meta_id |
|
| 47 | - * |
|
| 48 | - * @param int $meta_id |
|
| 49 | - * @return boolean |
|
| 50 | - */ |
|
| 51 | - public function set_meta_id($meta_id) |
|
| 52 | - { |
|
| 53 | - return $this->set('meta_id', $meta_id); |
|
| 54 | - } |
|
| 55 | - |
|
| 56 | - /** |
|
| 57 | - * Gets post_id |
|
| 58 | - * |
|
| 59 | - * @return int |
|
| 60 | - */ |
|
| 61 | - public function post_id() |
|
| 62 | - { |
|
| 63 | - return $this->get('post_id'); |
|
| 64 | - } |
|
| 65 | - |
|
| 66 | - |
|
| 67 | - /** |
|
| 68 | - * Sets post_id |
|
| 69 | - * |
|
| 70 | - * @param int $post_id |
|
| 71 | - * @return boolean |
|
| 72 | - */ |
|
| 73 | - public function set_post_id($post_id) |
|
| 74 | - { |
|
| 75 | - return $this->set('post_id', $post_id); |
|
| 76 | - } |
|
| 77 | - |
|
| 78 | - /** |
|
| 79 | - * Gets meta_key |
|
| 80 | - * |
|
| 81 | - * @return string |
|
| 82 | - */ |
|
| 83 | - public function meta_key() |
|
| 84 | - { |
|
| 85 | - return $this->get('meta_key'); |
|
| 86 | - } |
|
| 87 | - |
|
| 88 | - |
|
| 89 | - /** |
|
| 90 | - * Sets meta_key |
|
| 91 | - * |
|
| 92 | - * @param string $meta_key |
|
| 93 | - * @return boolean |
|
| 94 | - */ |
|
| 95 | - public function set_meta_key($meta_key) |
|
| 96 | - { |
|
| 97 | - return $this->set('meta_key', $meta_key); |
|
| 98 | - } |
|
| 99 | - |
|
| 100 | - /** |
|
| 101 | - * Gets meta_value |
|
| 102 | - * |
|
| 103 | - * @return mixed |
|
| 104 | - */ |
|
| 105 | - public function meta_value() |
|
| 106 | - { |
|
| 107 | - return $this->get('meta_value'); |
|
| 108 | - } |
|
| 109 | - |
|
| 110 | - |
|
| 111 | - /** |
|
| 112 | - * Sets meta_value |
|
| 113 | - * |
|
| 114 | - * @param mixed $meta_value |
|
| 115 | - * @return boolean |
|
| 116 | - */ |
|
| 117 | - public function set_meta_value($meta_value) |
|
| 118 | - { |
|
| 119 | - return $this->set('meta_value', $meta_value); |
|
| 120 | - } |
|
| 13 | + /** |
|
| 14 | + * @param array $props_n_values |
|
| 15 | + * @return EE_Post_Meta|mixed |
|
| 16 | + */ |
|
| 17 | + public static function new_instance($props_n_values = array()) |
|
| 18 | + { |
|
| 19 | + $has_object = parent::_check_for_object($props_n_values, __CLASS__); |
|
| 20 | + return $has_object ? $has_object : new self($props_n_values); |
|
| 21 | + } |
|
| 22 | + |
|
| 23 | + |
|
| 24 | + /** |
|
| 25 | + * @param array $props_n_values |
|
| 26 | + * @return EE_Post_Meta |
|
| 27 | + */ |
|
| 28 | + public static function new_instance_from_db($props_n_values = array()) |
|
| 29 | + { |
|
| 30 | + return new self($props_n_values, true); |
|
| 31 | + } |
|
| 32 | + |
|
| 33 | + |
|
| 34 | + /** |
|
| 35 | + * Gets meta_id |
|
| 36 | + * |
|
| 37 | + * @return int |
|
| 38 | + */ |
|
| 39 | + public function meta_id() |
|
| 40 | + { |
|
| 41 | + return $this->get('meta_id'); |
|
| 42 | + } |
|
| 43 | + |
|
| 44 | + |
|
| 45 | + /** |
|
| 46 | + * Sets meta_id |
|
| 47 | + * |
|
| 48 | + * @param int $meta_id |
|
| 49 | + * @return boolean |
|
| 50 | + */ |
|
| 51 | + public function set_meta_id($meta_id) |
|
| 52 | + { |
|
| 53 | + return $this->set('meta_id', $meta_id); |
|
| 54 | + } |
|
| 55 | + |
|
| 56 | + /** |
|
| 57 | + * Gets post_id |
|
| 58 | + * |
|
| 59 | + * @return int |
|
| 60 | + */ |
|
| 61 | + public function post_id() |
|
| 62 | + { |
|
| 63 | + return $this->get('post_id'); |
|
| 64 | + } |
|
| 65 | + |
|
| 66 | + |
|
| 67 | + /** |
|
| 68 | + * Sets post_id |
|
| 69 | + * |
|
| 70 | + * @param int $post_id |
|
| 71 | + * @return boolean |
|
| 72 | + */ |
|
| 73 | + public function set_post_id($post_id) |
|
| 74 | + { |
|
| 75 | + return $this->set('post_id', $post_id); |
|
| 76 | + } |
|
| 77 | + |
|
| 78 | + /** |
|
| 79 | + * Gets meta_key |
|
| 80 | + * |
|
| 81 | + * @return string |
|
| 82 | + */ |
|
| 83 | + public function meta_key() |
|
| 84 | + { |
|
| 85 | + return $this->get('meta_key'); |
|
| 86 | + } |
|
| 87 | + |
|
| 88 | + |
|
| 89 | + /** |
|
| 90 | + * Sets meta_key |
|
| 91 | + * |
|
| 92 | + * @param string $meta_key |
|
| 93 | + * @return boolean |
|
| 94 | + */ |
|
| 95 | + public function set_meta_key($meta_key) |
|
| 96 | + { |
|
| 97 | + return $this->set('meta_key', $meta_key); |
|
| 98 | + } |
|
| 99 | + |
|
| 100 | + /** |
|
| 101 | + * Gets meta_value |
|
| 102 | + * |
|
| 103 | + * @return mixed |
|
| 104 | + */ |
|
| 105 | + public function meta_value() |
|
| 106 | + { |
|
| 107 | + return $this->get('meta_value'); |
|
| 108 | + } |
|
| 109 | + |
|
| 110 | + |
|
| 111 | + /** |
|
| 112 | + * Sets meta_value |
|
| 113 | + * |
|
| 114 | + * @param mixed $meta_value |
|
| 115 | + * @return boolean |
|
| 116 | + */ |
|
| 117 | + public function set_meta_value($meta_value) |
|
| 118 | + { |
|
| 119 | + return $this->set('meta_value', $meta_value); |
|
| 120 | + } |
|
| 121 | 121 | } |
@@ -335,7 +335,7 @@ discard block |
||
| 335 | 335 | */ |
| 336 | 336 | public function options($notDeletedOptionsOnly = true, $selected_value_to_always_include = null) |
| 337 | 337 | { |
| 338 | - if (! $this->ID()) { |
|
| 338 | + if ( ! $this->ID()) { |
|
| 339 | 339 | return array(); |
| 340 | 340 | } |
| 341 | 341 | $query_params = array(); |
@@ -509,7 +509,7 @@ discard block |
||
| 509 | 509 | ), |
| 510 | 510 | $input_constructor_args |
| 511 | 511 | ); |
| 512 | - if (! $answer instanceof EE_Answer && $registration instanceof EE_Registration) { |
|
| 512 | + if ( ! $answer instanceof EE_Answer && $registration instanceof EE_Registration) { |
|
| 513 | 513 | $answer = EEM_Answer::instance()->get_registration_question_answer_object($registration, $this->ID()); |
| 514 | 514 | } |
| 515 | 515 | // has this question been answered ? |
@@ -647,7 +647,7 @@ discard block |
||
| 647 | 647 | $this, |
| 648 | 648 | $input_constructor_args |
| 649 | 649 | ); |
| 650 | - if (! $default_input) { |
|
| 650 | + if ( ! $default_input) { |
|
| 651 | 651 | $default_input = new EE_Text_Input($input_constructor_args); |
| 652 | 652 | } |
| 653 | 653 | $result = $default_input; |
@@ -14,668 +14,668 @@ |
||
| 14 | 14 | class EE_Question extends EE_Soft_Delete_Base_Class implements EEI_Duplicatable |
| 15 | 15 | { |
| 16 | 16 | |
| 17 | - /** |
|
| 18 | - * |
|
| 19 | - * @param array $props_n_values incoming values |
|
| 20 | - * @param string $timezone incoming timezone (if not set the timezone set for the website will be |
|
| 21 | - * used.) |
|
| 22 | - * @param array $date_formats incoming date_formats in an array where the first value is the |
|
| 23 | - * date_format and the second value is the time format |
|
| 24 | - * @return EE_Question |
|
| 25 | - */ |
|
| 26 | - public static function new_instance($props_n_values = array(), $timezone = null, $date_formats = array()) |
|
| 27 | - { |
|
| 28 | - $has_object = parent::_check_for_object($props_n_values, __CLASS__, $timezone, $date_formats); |
|
| 29 | - return $has_object ? $has_object : new self($props_n_values, false, $timezone, $date_formats); |
|
| 30 | - } |
|
| 31 | - |
|
| 32 | - |
|
| 33 | - /** |
|
| 34 | - * @param array $props_n_values incoming values from the database |
|
| 35 | - * @param string $timezone incoming timezone as set by the model. If not set the timezone for |
|
| 36 | - * the website will be used. |
|
| 37 | - * @return EE_Question |
|
| 38 | - */ |
|
| 39 | - public static function new_instance_from_db($props_n_values = array(), $timezone = null) |
|
| 40 | - { |
|
| 41 | - return new self($props_n_values, true, $timezone); |
|
| 42 | - } |
|
| 43 | - |
|
| 44 | - |
|
| 45 | - /** |
|
| 46 | - * Set Question display text |
|
| 47 | - * |
|
| 48 | - * @access public |
|
| 49 | - * @param string $QST_display_text |
|
| 50 | - */ |
|
| 51 | - public function set_display_text($QST_display_text = '') |
|
| 52 | - { |
|
| 53 | - $this->set('QST_display_text', $QST_display_text); |
|
| 54 | - } |
|
| 55 | - |
|
| 56 | - |
|
| 57 | - /** |
|
| 58 | - * Set Question admin text |
|
| 59 | - * |
|
| 60 | - * @access public |
|
| 61 | - * @param string $QST_admin_label |
|
| 62 | - */ |
|
| 63 | - public function set_admin_label($QST_admin_label = '') |
|
| 64 | - { |
|
| 65 | - $this->set('QST_admin_label', $QST_admin_label); |
|
| 66 | - } |
|
| 67 | - |
|
| 68 | - |
|
| 69 | - /** |
|
| 70 | - * Set system name |
|
| 71 | - * |
|
| 72 | - * @access public |
|
| 73 | - * @param mixed $QST_system |
|
| 74 | - */ |
|
| 75 | - public function set_system_ID($QST_system = '') |
|
| 76 | - { |
|
| 77 | - $this->set('QST_system', $QST_system); |
|
| 78 | - } |
|
| 79 | - |
|
| 80 | - |
|
| 81 | - /** |
|
| 82 | - * Set question's type |
|
| 83 | - * |
|
| 84 | - * @access public |
|
| 85 | - * @param string $QST_type |
|
| 86 | - */ |
|
| 87 | - public function set_question_type($QST_type = '') |
|
| 88 | - { |
|
| 89 | - $this->set('QST_type', $QST_type); |
|
| 90 | - } |
|
| 91 | - |
|
| 92 | - |
|
| 93 | - /** |
|
| 94 | - * Sets whether this question must be answered when presented in a form |
|
| 95 | - * |
|
| 96 | - * @access public |
|
| 97 | - * @param bool $QST_required |
|
| 98 | - */ |
|
| 99 | - public function set_required($QST_required = false) |
|
| 100 | - { |
|
| 101 | - $this->set('QST_required', $QST_required); |
|
| 102 | - } |
|
| 103 | - |
|
| 104 | - |
|
| 105 | - /** |
|
| 106 | - * Set Question display text |
|
| 107 | - * |
|
| 108 | - * @access public |
|
| 109 | - * @param string $QST_required_text |
|
| 110 | - */ |
|
| 111 | - public function set_required_text($QST_required_text = '') |
|
| 112 | - { |
|
| 113 | - $this->set('QST_required_text', $QST_required_text); |
|
| 114 | - } |
|
| 115 | - |
|
| 116 | - |
|
| 117 | - /** |
|
| 118 | - * Sets the order of this question when placed in a sequence of questions |
|
| 119 | - * |
|
| 120 | - * @access public |
|
| 121 | - * @param int $QST_order |
|
| 122 | - */ |
|
| 123 | - public function set_order($QST_order = 0) |
|
| 124 | - { |
|
| 125 | - $this->set('QST_order', $QST_order); |
|
| 126 | - } |
|
| 127 | - |
|
| 128 | - |
|
| 129 | - /** |
|
| 130 | - * Sets whether the question is admin-only |
|
| 131 | - * |
|
| 132 | - * @access public |
|
| 133 | - * @param bool $QST_admin_only |
|
| 134 | - */ |
|
| 135 | - public function set_admin_only($QST_admin_only = false) |
|
| 136 | - { |
|
| 137 | - $this->set('QST_admin_only', $QST_admin_only); |
|
| 138 | - } |
|
| 139 | - |
|
| 140 | - |
|
| 141 | - /** |
|
| 142 | - * Sets the wordpress user ID on the question |
|
| 143 | - * |
|
| 144 | - * @access public |
|
| 145 | - * @param int $QST_wp_user |
|
| 146 | - */ |
|
| 147 | - public function set_wp_user($QST_wp_user = 1) |
|
| 148 | - { |
|
| 149 | - $this->set('QST_wp_user', $QST_wp_user); |
|
| 150 | - } |
|
| 151 | - |
|
| 152 | - |
|
| 153 | - /** |
|
| 154 | - * Sets whether the question has been deleted |
|
| 155 | - * (we use this boolean instead of actually |
|
| 156 | - * deleting it because when users delete this question |
|
| 157 | - * they really want to remove the question from future |
|
| 158 | - * forms, BUT keep their old answers which depend |
|
| 159 | - * on this record actually existing. |
|
| 160 | - * |
|
| 161 | - * @access public |
|
| 162 | - * @param bool $QST_deleted |
|
| 163 | - */ |
|
| 164 | - public function set_deleted($QST_deleted = false) |
|
| 165 | - { |
|
| 166 | - $this->set('QST_deleted', $QST_deleted); |
|
| 167 | - } |
|
| 168 | - |
|
| 169 | - |
|
| 170 | - /** |
|
| 171 | - * returns the text for displaying the question to users |
|
| 172 | - * |
|
| 173 | - * @access public |
|
| 174 | - * @return string |
|
| 175 | - */ |
|
| 176 | - public function display_text() |
|
| 177 | - { |
|
| 178 | - return $this->get('QST_display_text'); |
|
| 179 | - } |
|
| 180 | - |
|
| 181 | - |
|
| 182 | - /** |
|
| 183 | - * returns the text for the administrative label |
|
| 184 | - * |
|
| 185 | - * @access public |
|
| 186 | - * @return string |
|
| 187 | - */ |
|
| 188 | - public function admin_label() |
|
| 189 | - { |
|
| 190 | - return $this->get('QST_admin_label'); |
|
| 191 | - } |
|
| 192 | - |
|
| 193 | - |
|
| 194 | - /** |
|
| 195 | - * returns the attendee column name for this question |
|
| 196 | - * |
|
| 197 | - * @access public |
|
| 198 | - * @return string |
|
| 199 | - */ |
|
| 200 | - public function system_ID() |
|
| 201 | - { |
|
| 202 | - return $this->get('QST_system'); |
|
| 203 | - } |
|
| 204 | - |
|
| 205 | - |
|
| 206 | - /** |
|
| 207 | - * returns either a string of 'text', 'textfield', etc. |
|
| 208 | - * |
|
| 209 | - * @access public |
|
| 210 | - * @return boolean |
|
| 211 | - */ |
|
| 212 | - public function required() |
|
| 213 | - { |
|
| 214 | - return $this->get('QST_required'); |
|
| 215 | - } |
|
| 216 | - |
|
| 217 | - |
|
| 218 | - /** |
|
| 219 | - * returns the text which should be displayed when a user |
|
| 220 | - * doesn't answer this question in a form |
|
| 221 | - * |
|
| 222 | - * @access public |
|
| 223 | - * @return string |
|
| 224 | - */ |
|
| 225 | - public function required_text() |
|
| 226 | - { |
|
| 227 | - return $this->get('QST_required_text'); |
|
| 228 | - } |
|
| 229 | - |
|
| 230 | - |
|
| 231 | - /** |
|
| 232 | - * returns the type of this question |
|
| 233 | - * |
|
| 234 | - * @access public |
|
| 235 | - * @return string |
|
| 236 | - */ |
|
| 237 | - public function type() |
|
| 238 | - { |
|
| 239 | - return $this->get('QST_type'); |
|
| 240 | - } |
|
| 241 | - |
|
| 242 | - |
|
| 243 | - /** |
|
| 244 | - * returns an integer showing where this question should |
|
| 245 | - * be placed in a sequence of questions |
|
| 246 | - * |
|
| 247 | - * @access public |
|
| 248 | - * @return int |
|
| 249 | - */ |
|
| 250 | - public function order() |
|
| 251 | - { |
|
| 252 | - return $this->get('QST_order'); |
|
| 253 | - } |
|
| 254 | - |
|
| 255 | - |
|
| 256 | - /** |
|
| 257 | - * returns whether this question should only appears to admins, |
|
| 258 | - * or to everyone |
|
| 259 | - * |
|
| 260 | - * @access public |
|
| 261 | - * @return boolean |
|
| 262 | - */ |
|
| 263 | - public function admin_only() |
|
| 264 | - { |
|
| 265 | - return $this->get('QST_admin_only'); |
|
| 266 | - } |
|
| 267 | - |
|
| 268 | - |
|
| 269 | - /** |
|
| 270 | - * returns the id the wordpress user who created this question |
|
| 271 | - * |
|
| 272 | - * @access public |
|
| 273 | - * @return int |
|
| 274 | - */ |
|
| 275 | - public function wp_user() |
|
| 276 | - { |
|
| 277 | - return $this->get('QST_wp_user'); |
|
| 278 | - } |
|
| 279 | - |
|
| 280 | - |
|
| 281 | - /** |
|
| 282 | - * returns whether this question has been marked as 'deleted' |
|
| 283 | - * |
|
| 284 | - * @access public |
|
| 285 | - * @return boolean |
|
| 286 | - */ |
|
| 287 | - public function deleted() |
|
| 288 | - { |
|
| 289 | - return $this->get('QST_deleted'); |
|
| 290 | - } |
|
| 291 | - |
|
| 292 | - |
|
| 293 | - /** |
|
| 294 | - * Gets an array of related EE_Answer to this EE_Question |
|
| 295 | - * |
|
| 296 | - * @return EE_Answer[] |
|
| 297 | - */ |
|
| 298 | - public function answers() |
|
| 299 | - { |
|
| 300 | - return $this->get_many_related('Answer'); |
|
| 301 | - } |
|
| 302 | - |
|
| 303 | - |
|
| 304 | - /** |
|
| 305 | - * Boolean check for if there are answers on this question in th db |
|
| 306 | - * |
|
| 307 | - * @return boolean true = has answers, false = no answers. |
|
| 308 | - */ |
|
| 309 | - public function has_answers() |
|
| 310 | - { |
|
| 311 | - return $this->count_related('Answer') > 0 ? true : false; |
|
| 312 | - } |
|
| 313 | - |
|
| 314 | - |
|
| 315 | - /** |
|
| 316 | - * gets an array of EE_Question_Group which relate to this question |
|
| 317 | - * |
|
| 318 | - * @return EE_Question_Group[] |
|
| 319 | - */ |
|
| 320 | - public function question_groups() |
|
| 321 | - { |
|
| 322 | - return $this->get_many_related('Question_Group'); |
|
| 323 | - } |
|
| 324 | - |
|
| 325 | - |
|
| 326 | - /** |
|
| 327 | - * Returns all the options for this question. By default, it returns only the not-yet-deleted ones. |
|
| 328 | - * |
|
| 329 | - * @param boolean $notDeletedOptionsOnly 1 |
|
| 330 | - * whether to return ALL options, or only the ones which have |
|
| 331 | - * not yet been deleleted |
|
| 332 | - * @param string|array $selected_value_to_always_include , when retrieving options to an ANSWERED question, |
|
| 333 | - * we want to usually only show non-deleted options AND the |
|
| 334 | - * value that was selected for the answer, whether it was |
|
| 335 | - * trashed or not. |
|
| 336 | - * @return EE_Question_Option[] |
|
| 337 | - */ |
|
| 338 | - public function options($notDeletedOptionsOnly = true, $selected_value_to_always_include = null) |
|
| 339 | - { |
|
| 340 | - if (! $this->ID()) { |
|
| 341 | - return array(); |
|
| 342 | - } |
|
| 343 | - $query_params = array(); |
|
| 344 | - if ($selected_value_to_always_include) { |
|
| 345 | - if (is_array($selected_value_to_always_include)) { |
|
| 346 | - $query_params[0]['OR*options-query']['QSO_value'] = array('IN', $selected_value_to_always_include); |
|
| 347 | - } else { |
|
| 348 | - $query_params[0]['OR*options-query']['QSO_value'] = $selected_value_to_always_include; |
|
| 349 | - } |
|
| 350 | - } |
|
| 351 | - if ($notDeletedOptionsOnly) { |
|
| 352 | - $query_params[0]['OR*options-query']['QSO_deleted'] = false; |
|
| 353 | - } |
|
| 354 | - // order by QSO_order |
|
| 355 | - $query_params['order_by'] = array('QSO_order' => 'ASC'); |
|
| 356 | - return $this->get_many_related('Question_Option', $query_params); |
|
| 357 | - } |
|
| 358 | - |
|
| 359 | - |
|
| 360 | - /** |
|
| 361 | - * returns an array of EE_Question_Options which relate to this question |
|
| 362 | - * |
|
| 363 | - * @return \EE_Question_Option[] |
|
| 364 | - */ |
|
| 365 | - public function temp_options() |
|
| 366 | - { |
|
| 367 | - return $this->_model_relations['Question_Option']; |
|
| 368 | - } |
|
| 369 | - |
|
| 370 | - |
|
| 371 | - /** |
|
| 372 | - * Adds an option for this question. Note: if the option were previously associated with a different |
|
| 373 | - * Question, that relationship will be overwritten. |
|
| 374 | - * |
|
| 375 | - * @param EE_Question_Option $option |
|
| 376 | - * @return boolean success |
|
| 377 | - */ |
|
| 378 | - public function add_option(EE_Question_Option $option) |
|
| 379 | - { |
|
| 380 | - return $this->_add_relation_to($option, 'Question_Option'); |
|
| 381 | - } |
|
| 382 | - |
|
| 383 | - |
|
| 384 | - /** |
|
| 385 | - * Adds an option directly to this question without saving to the db |
|
| 386 | - * |
|
| 387 | - * @param EE_Question_Option $option |
|
| 388 | - * @return boolean success |
|
| 389 | - */ |
|
| 390 | - public function add_temp_option(EE_Question_Option $option) |
|
| 391 | - { |
|
| 392 | - $this->_model_relations['Question_Option'][] = $option; |
|
| 393 | - return true; |
|
| 394 | - } |
|
| 395 | - |
|
| 396 | - |
|
| 397 | - /** |
|
| 398 | - * Marks the option as deleted. |
|
| 399 | - * |
|
| 400 | - * @param EE_Question_Option $option |
|
| 401 | - * @return boolean success |
|
| 402 | - */ |
|
| 403 | - public function remove_option(EE_Question_Option $option) |
|
| 404 | - { |
|
| 405 | - return $this->_remove_relation_to($option, 'Question_Option'); |
|
| 406 | - } |
|
| 407 | - |
|
| 408 | - |
|
| 409 | - /** |
|
| 410 | - * @return bool |
|
| 411 | - */ |
|
| 412 | - public function is_system_question() |
|
| 413 | - { |
|
| 414 | - $system_ID = $this->get('QST_system'); |
|
| 415 | - return ! empty($system_ID) ? true : false; |
|
| 416 | - } |
|
| 417 | - |
|
| 418 | - |
|
| 419 | - /** |
|
| 420 | - * The purpose of this method is set the question order this question order to be the max out of all questions |
|
| 421 | - * |
|
| 422 | - * @access public |
|
| 423 | - * @return void |
|
| 424 | - */ |
|
| 425 | - public function set_order_to_latest() |
|
| 426 | - { |
|
| 427 | - $latest_order = $this->get_model()->get_latest_question_order(); |
|
| 428 | - $latest_order++; |
|
| 429 | - $this->set('QST_order', $latest_order); |
|
| 430 | - } |
|
| 431 | - |
|
| 432 | - |
|
| 433 | - /** |
|
| 434 | - * Retrieves the list of allowed question types from the model. |
|
| 435 | - * |
|
| 436 | - * @return string[] |
|
| 437 | - */ |
|
| 438 | - private function _allowed_question_types() |
|
| 439 | - { |
|
| 440 | - $questionModel = $this->get_model(); |
|
| 441 | - /* @var $questionModel EEM_Question */ |
|
| 442 | - return $questionModel->allowed_question_types(); |
|
| 443 | - } |
|
| 444 | - |
|
| 445 | - /** |
|
| 446 | - * Duplicates this question and its question options |
|
| 447 | - * |
|
| 448 | - * @return \EE_Question |
|
| 449 | - */ |
|
| 450 | - public function duplicate($options = array()) |
|
| 451 | - { |
|
| 452 | - $new_question = clone $this; |
|
| 453 | - $new_question->set('QST_ID', null); |
|
| 454 | - $new_question->set_display_text(sprintf(esc_html__('%s **Duplicate**', 'event_espresso'), $this->display_text())); |
|
| 455 | - $new_question->set_admin_label(sprintf(esc_html__('%s **Duplicate**', 'event_espresso'), $this->admin_label())); |
|
| 456 | - $new_question->set_system_ID(null); |
|
| 457 | - $new_question->set_wp_user(get_current_user_id()); |
|
| 458 | - // if we're duplicating a trashed question, assume we don't want the new one to be trashed |
|
| 459 | - $new_question->set_deleted(false); |
|
| 460 | - $success = $new_question->save(); |
|
| 461 | - if ($success) { |
|
| 462 | - // we don't totally want to duplicate the question options, because we want them to be for the NEW question |
|
| 463 | - foreach ($this->options() as $question_option) { |
|
| 464 | - $question_option->duplicate(array('QST_ID' => $new_question->ID())); |
|
| 465 | - } |
|
| 466 | - return $new_question; |
|
| 467 | - } else { |
|
| 468 | - return null; |
|
| 469 | - } |
|
| 470 | - } |
|
| 471 | - |
|
| 472 | - /** |
|
| 473 | - * Returns the question's maximum allowed response size |
|
| 474 | - * |
|
| 475 | - * @return int|float |
|
| 476 | - */ |
|
| 477 | - public function max() |
|
| 478 | - { |
|
| 479 | - return $this->get('QST_max'); |
|
| 480 | - } |
|
| 481 | - |
|
| 482 | - /** |
|
| 483 | - * Sets the question's maximum allowed response size |
|
| 484 | - * |
|
| 485 | - * @param int|float $new_max |
|
| 486 | - * @return void |
|
| 487 | - */ |
|
| 488 | - public function set_max($new_max) |
|
| 489 | - { |
|
| 490 | - $this->set('QST_max', $new_max); |
|
| 491 | - } |
|
| 492 | - |
|
| 493 | - |
|
| 494 | - /** |
|
| 495 | - * Creates a form input from this question which can be used in HTML forms |
|
| 496 | - * |
|
| 497 | - * @param EE_Registration $registration |
|
| 498 | - * @param EE_Answer $answer |
|
| 499 | - * @param array $input_constructor_args |
|
| 500 | - * @return EE_Form_Input_Base |
|
| 501 | - */ |
|
| 502 | - public function generate_form_input($registration = null, $answer = null, $input_constructor_args = array()) |
|
| 503 | - { |
|
| 504 | - $identifier = $this->is_system_question() ? $this->system_ID() : $this->ID(); |
|
| 505 | - |
|
| 506 | - $input_constructor_args = array_merge( |
|
| 507 | - array( |
|
| 508 | - 'required' => $this->required() ? true : false, |
|
| 509 | - 'html_label_text' => $this->display_text(), |
|
| 510 | - 'required_validation_error_message' => $this->required_text(), |
|
| 511 | - ), |
|
| 512 | - $input_constructor_args |
|
| 513 | - ); |
|
| 514 | - if (! $answer instanceof EE_Answer && $registration instanceof EE_Registration) { |
|
| 515 | - $answer = EEM_Answer::instance()->get_registration_question_answer_object($registration, $this->ID()); |
|
| 516 | - } |
|
| 517 | - // has this question been answered ? |
|
| 518 | - if ( |
|
| 519 | - $answer instanceof EE_Answer |
|
| 520 | - && $answer->value() !== '' |
|
| 521 | - ) { |
|
| 522 | - // answer gets htmlspecialchars called on it, undo that please |
|
| 523 | - // because the form input's display strategy may call esc_attr too |
|
| 524 | - // which also does html special characters |
|
| 525 | - $values_with_html_special_chars = $answer->value(); |
|
| 526 | - if (is_array($values_with_html_special_chars)) { |
|
| 527 | - $default_value = array_map('htmlspecialchars_decode', $values_with_html_special_chars); |
|
| 528 | - } else { |
|
| 529 | - $default_value = htmlspecialchars_decode($values_with_html_special_chars); |
|
| 530 | - } |
|
| 531 | - $input_constructor_args['default'] = $default_value; |
|
| 532 | - } |
|
| 533 | - $max_max_for_question = EEM_Question::instance()->absolute_max_for_system_question($this->system_ID()); |
|
| 534 | - if ( |
|
| 535 | - in_array( |
|
| 536 | - $this->type(), |
|
| 537 | - EEM_Question::instance()->questionTypesWithMaxLength(), |
|
| 538 | - true |
|
| 539 | - ) |
|
| 540 | - ) { |
|
| 541 | - $input_constructor_args['validation_strategies'][] = new EE_Max_Length_Validation_Strategy( |
|
| 542 | - null, |
|
| 543 | - min($max_max_for_question, $this->max()) |
|
| 544 | - ); |
|
| 545 | - } |
|
| 546 | - $input_constructor_args = apply_filters( |
|
| 547 | - 'FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__input_constructor_args', |
|
| 548 | - $input_constructor_args, |
|
| 549 | - $registration, |
|
| 550 | - $this, |
|
| 551 | - $answer |
|
| 552 | - ); |
|
| 553 | - |
|
| 554 | - $result = null; |
|
| 555 | - switch ($this->type()) { |
|
| 556 | - // Text |
|
| 557 | - case EEM_Question::QST_type_text: |
|
| 558 | - $result = new EE_Text_Input($input_constructor_args); |
|
| 559 | - break; |
|
| 560 | - // Textarea |
|
| 561 | - case EEM_Question::QST_type_textarea: |
|
| 562 | - $result = new EE_Text_Area_Input($input_constructor_args); |
|
| 563 | - break; |
|
| 564 | - // Radio Buttons |
|
| 565 | - case EEM_Question::QST_type_radio: |
|
| 566 | - $result = new EE_Radio_Button_Input($this->options(), $input_constructor_args); |
|
| 567 | - break; |
|
| 568 | - // Dropdown |
|
| 569 | - case EEM_Question::QST_type_dropdown: |
|
| 570 | - $result = new EE_Select_Input($this->options(), $input_constructor_args); |
|
| 571 | - break; |
|
| 572 | - // State Dropdown |
|
| 573 | - case EEM_Question::QST_type_state: |
|
| 574 | - $state_options = apply_filters( |
|
| 575 | - 'FHEE__EE_Question__generate_form_input__state_options', |
|
| 576 | - null, |
|
| 577 | - $this, |
|
| 578 | - $registration, |
|
| 579 | - $answer |
|
| 580 | - ); |
|
| 581 | - $result = new EE_State_Select_Input($state_options, $input_constructor_args); |
|
| 582 | - break; |
|
| 583 | - // Country Dropdown |
|
| 584 | - case EEM_Question::QST_type_country: |
|
| 585 | - $country_options = apply_filters( |
|
| 586 | - 'FHEE__EE_Question__generate_form_input__country_options', |
|
| 587 | - null, |
|
| 588 | - $this, |
|
| 589 | - $registration, |
|
| 590 | - $answer |
|
| 591 | - ); |
|
| 592 | - $result = new EE_Country_Select_Input($country_options, $input_constructor_args); |
|
| 593 | - break; |
|
| 594 | - // Checkboxes |
|
| 595 | - case EEM_Question::QST_type_checkbox: |
|
| 596 | - $result = new EE_Checkbox_Multi_Input($this->options(), $input_constructor_args); |
|
| 597 | - break; |
|
| 598 | - // Date |
|
| 599 | - case EEM_Question::QST_type_date: |
|
| 600 | - $result = new EE_Datepicker_Input($input_constructor_args); |
|
| 601 | - break; |
|
| 602 | - case EEM_Question::QST_type_html_textarea: |
|
| 603 | - $input_constructor_args['validation_strategies'][] = new EE_Simple_HTML_Validation_Strategy(); |
|
| 604 | - $result = new EE_Text_Area_Input($input_constructor_args); |
|
| 605 | - $result->remove_validation_strategy('EE_Plaintext_Validation_Strategy'); |
|
| 606 | - break; |
|
| 607 | - case EEM_Question::QST_type_email: |
|
| 608 | - $result = new EE_Email_Input($input_constructor_args); |
|
| 609 | - break; |
|
| 610 | - // Email confirm |
|
| 611 | - case EEM_Question::QST_type_email_confirm: |
|
| 612 | - $result = new EE_Email_Confirm_Input($input_constructor_args); |
|
| 613 | - break; |
|
| 614 | - case EEM_Question::QST_type_us_phone: |
|
| 615 | - $result = new EE_Phone_Input($input_constructor_args); |
|
| 616 | - break; |
|
| 617 | - case EEM_Question::QST_type_int: |
|
| 618 | - $result = new EE_Integer_Input($input_constructor_args); |
|
| 619 | - break; |
|
| 620 | - case EEM_Question::QST_type_decimal: |
|
| 621 | - $result = new EE_Float_Input($input_constructor_args); |
|
| 622 | - break; |
|
| 623 | - case EEM_Question::QST_type_url: |
|
| 624 | - $input_constructor_args['validation_strategies'][] = LoaderFactory::getLoader()->getNew('EE_URL_Validation_Strategy'); |
|
| 625 | - $result = new EE_Text_Input($input_constructor_args); |
|
| 626 | - break; |
|
| 627 | - case EEM_Question::QST_type_year: |
|
| 628 | - $result = new EE_Year_Input( |
|
| 629 | - $input_constructor_args, |
|
| 630 | - apply_filters( |
|
| 631 | - 'FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__year_question__four_digit', |
|
| 632 | - true, |
|
| 633 | - $this |
|
| 634 | - ), |
|
| 635 | - apply_filters( |
|
| 636 | - 'FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__year_question__early_range', |
|
| 637 | - 100, |
|
| 638 | - $this |
|
| 639 | - ), |
|
| 640 | - apply_filters( |
|
| 641 | - 'FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__year_question__end_range', |
|
| 642 | - 100, |
|
| 643 | - $this |
|
| 644 | - ) |
|
| 645 | - ); |
|
| 646 | - break; |
|
| 647 | - case EEM_Question::QST_type_multi_select: |
|
| 648 | - $result = new EE_Select_Multiple_Input($this->options(), $input_constructor_args); |
|
| 649 | - break; |
|
| 650 | - // fallback |
|
| 651 | - default: |
|
| 652 | - $default_input = apply_filters( |
|
| 653 | - 'FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__default', |
|
| 654 | - null, |
|
| 655 | - $this->type(), |
|
| 656 | - $this, |
|
| 657 | - $input_constructor_args |
|
| 658 | - ); |
|
| 659 | - if (! $default_input) { |
|
| 660 | - $default_input = new EE_Text_Input($input_constructor_args); |
|
| 661 | - } |
|
| 662 | - $result = $default_input; |
|
| 663 | - } |
|
| 664 | - return apply_filters('FHEE__EE_Question__generate_form_input__return', $result, $registration, $this, $answer); |
|
| 665 | - } |
|
| 666 | - |
|
| 667 | - |
|
| 668 | - /** |
|
| 669 | - * Returns whether or not this question type should have question option entries |
|
| 670 | - * |
|
| 671 | - * @return bool |
|
| 672 | - */ |
|
| 673 | - public function should_have_question_options() |
|
| 674 | - { |
|
| 675 | - return in_array( |
|
| 676 | - $this->type(), |
|
| 677 | - $this->_model->question_types_with_options(), |
|
| 678 | - true |
|
| 679 | - ); |
|
| 680 | - } |
|
| 17 | + /** |
|
| 18 | + * |
|
| 19 | + * @param array $props_n_values incoming values |
|
| 20 | + * @param string $timezone incoming timezone (if not set the timezone set for the website will be |
|
| 21 | + * used.) |
|
| 22 | + * @param array $date_formats incoming date_formats in an array where the first value is the |
|
| 23 | + * date_format and the second value is the time format |
|
| 24 | + * @return EE_Question |
|
| 25 | + */ |
|
| 26 | + public static function new_instance($props_n_values = array(), $timezone = null, $date_formats = array()) |
|
| 27 | + { |
|
| 28 | + $has_object = parent::_check_for_object($props_n_values, __CLASS__, $timezone, $date_formats); |
|
| 29 | + return $has_object ? $has_object : new self($props_n_values, false, $timezone, $date_formats); |
|
| 30 | + } |
|
| 31 | + |
|
| 32 | + |
|
| 33 | + /** |
|
| 34 | + * @param array $props_n_values incoming values from the database |
|
| 35 | + * @param string $timezone incoming timezone as set by the model. If not set the timezone for |
|
| 36 | + * the website will be used. |
|
| 37 | + * @return EE_Question |
|
| 38 | + */ |
|
| 39 | + public static function new_instance_from_db($props_n_values = array(), $timezone = null) |
|
| 40 | + { |
|
| 41 | + return new self($props_n_values, true, $timezone); |
|
| 42 | + } |
|
| 43 | + |
|
| 44 | + |
|
| 45 | + /** |
|
| 46 | + * Set Question display text |
|
| 47 | + * |
|
| 48 | + * @access public |
|
| 49 | + * @param string $QST_display_text |
|
| 50 | + */ |
|
| 51 | + public function set_display_text($QST_display_text = '') |
|
| 52 | + { |
|
| 53 | + $this->set('QST_display_text', $QST_display_text); |
|
| 54 | + } |
|
| 55 | + |
|
| 56 | + |
|
| 57 | + /** |
|
| 58 | + * Set Question admin text |
|
| 59 | + * |
|
| 60 | + * @access public |
|
| 61 | + * @param string $QST_admin_label |
|
| 62 | + */ |
|
| 63 | + public function set_admin_label($QST_admin_label = '') |
|
| 64 | + { |
|
| 65 | + $this->set('QST_admin_label', $QST_admin_label); |
|
| 66 | + } |
|
| 67 | + |
|
| 68 | + |
|
| 69 | + /** |
|
| 70 | + * Set system name |
|
| 71 | + * |
|
| 72 | + * @access public |
|
| 73 | + * @param mixed $QST_system |
|
| 74 | + */ |
|
| 75 | + public function set_system_ID($QST_system = '') |
|
| 76 | + { |
|
| 77 | + $this->set('QST_system', $QST_system); |
|
| 78 | + } |
|
| 79 | + |
|
| 80 | + |
|
| 81 | + /** |
|
| 82 | + * Set question's type |
|
| 83 | + * |
|
| 84 | + * @access public |
|
| 85 | + * @param string $QST_type |
|
| 86 | + */ |
|
| 87 | + public function set_question_type($QST_type = '') |
|
| 88 | + { |
|
| 89 | + $this->set('QST_type', $QST_type); |
|
| 90 | + } |
|
| 91 | + |
|
| 92 | + |
|
| 93 | + /** |
|
| 94 | + * Sets whether this question must be answered when presented in a form |
|
| 95 | + * |
|
| 96 | + * @access public |
|
| 97 | + * @param bool $QST_required |
|
| 98 | + */ |
|
| 99 | + public function set_required($QST_required = false) |
|
| 100 | + { |
|
| 101 | + $this->set('QST_required', $QST_required); |
|
| 102 | + } |
|
| 103 | + |
|
| 104 | + |
|
| 105 | + /** |
|
| 106 | + * Set Question display text |
|
| 107 | + * |
|
| 108 | + * @access public |
|
| 109 | + * @param string $QST_required_text |
|
| 110 | + */ |
|
| 111 | + public function set_required_text($QST_required_text = '') |
|
| 112 | + { |
|
| 113 | + $this->set('QST_required_text', $QST_required_text); |
|
| 114 | + } |
|
| 115 | + |
|
| 116 | + |
|
| 117 | + /** |
|
| 118 | + * Sets the order of this question when placed in a sequence of questions |
|
| 119 | + * |
|
| 120 | + * @access public |
|
| 121 | + * @param int $QST_order |
|
| 122 | + */ |
|
| 123 | + public function set_order($QST_order = 0) |
|
| 124 | + { |
|
| 125 | + $this->set('QST_order', $QST_order); |
|
| 126 | + } |
|
| 127 | + |
|
| 128 | + |
|
| 129 | + /** |
|
| 130 | + * Sets whether the question is admin-only |
|
| 131 | + * |
|
| 132 | + * @access public |
|
| 133 | + * @param bool $QST_admin_only |
|
| 134 | + */ |
|
| 135 | + public function set_admin_only($QST_admin_only = false) |
|
| 136 | + { |
|
| 137 | + $this->set('QST_admin_only', $QST_admin_only); |
|
| 138 | + } |
|
| 139 | + |
|
| 140 | + |
|
| 141 | + /** |
|
| 142 | + * Sets the wordpress user ID on the question |
|
| 143 | + * |
|
| 144 | + * @access public |
|
| 145 | + * @param int $QST_wp_user |
|
| 146 | + */ |
|
| 147 | + public function set_wp_user($QST_wp_user = 1) |
|
| 148 | + { |
|
| 149 | + $this->set('QST_wp_user', $QST_wp_user); |
|
| 150 | + } |
|
| 151 | + |
|
| 152 | + |
|
| 153 | + /** |
|
| 154 | + * Sets whether the question has been deleted |
|
| 155 | + * (we use this boolean instead of actually |
|
| 156 | + * deleting it because when users delete this question |
|
| 157 | + * they really want to remove the question from future |
|
| 158 | + * forms, BUT keep their old answers which depend |
|
| 159 | + * on this record actually existing. |
|
| 160 | + * |
|
| 161 | + * @access public |
|
| 162 | + * @param bool $QST_deleted |
|
| 163 | + */ |
|
| 164 | + public function set_deleted($QST_deleted = false) |
|
| 165 | + { |
|
| 166 | + $this->set('QST_deleted', $QST_deleted); |
|
| 167 | + } |
|
| 168 | + |
|
| 169 | + |
|
| 170 | + /** |
|
| 171 | + * returns the text for displaying the question to users |
|
| 172 | + * |
|
| 173 | + * @access public |
|
| 174 | + * @return string |
|
| 175 | + */ |
|
| 176 | + public function display_text() |
|
| 177 | + { |
|
| 178 | + return $this->get('QST_display_text'); |
|
| 179 | + } |
|
| 180 | + |
|
| 181 | + |
|
| 182 | + /** |
|
| 183 | + * returns the text for the administrative label |
|
| 184 | + * |
|
| 185 | + * @access public |
|
| 186 | + * @return string |
|
| 187 | + */ |
|
| 188 | + public function admin_label() |
|
| 189 | + { |
|
| 190 | + return $this->get('QST_admin_label'); |
|
| 191 | + } |
|
| 192 | + |
|
| 193 | + |
|
| 194 | + /** |
|
| 195 | + * returns the attendee column name for this question |
|
| 196 | + * |
|
| 197 | + * @access public |
|
| 198 | + * @return string |
|
| 199 | + */ |
|
| 200 | + public function system_ID() |
|
| 201 | + { |
|
| 202 | + return $this->get('QST_system'); |
|
| 203 | + } |
|
| 204 | + |
|
| 205 | + |
|
| 206 | + /** |
|
| 207 | + * returns either a string of 'text', 'textfield', etc. |
|
| 208 | + * |
|
| 209 | + * @access public |
|
| 210 | + * @return boolean |
|
| 211 | + */ |
|
| 212 | + public function required() |
|
| 213 | + { |
|
| 214 | + return $this->get('QST_required'); |
|
| 215 | + } |
|
| 216 | + |
|
| 217 | + |
|
| 218 | + /** |
|
| 219 | + * returns the text which should be displayed when a user |
|
| 220 | + * doesn't answer this question in a form |
|
| 221 | + * |
|
| 222 | + * @access public |
|
| 223 | + * @return string |
|
| 224 | + */ |
|
| 225 | + public function required_text() |
|
| 226 | + { |
|
| 227 | + return $this->get('QST_required_text'); |
|
| 228 | + } |
|
| 229 | + |
|
| 230 | + |
|
| 231 | + /** |
|
| 232 | + * returns the type of this question |
|
| 233 | + * |
|
| 234 | + * @access public |
|
| 235 | + * @return string |
|
| 236 | + */ |
|
| 237 | + public function type() |
|
| 238 | + { |
|
| 239 | + return $this->get('QST_type'); |
|
| 240 | + } |
|
| 241 | + |
|
| 242 | + |
|
| 243 | + /** |
|
| 244 | + * returns an integer showing where this question should |
|
| 245 | + * be placed in a sequence of questions |
|
| 246 | + * |
|
| 247 | + * @access public |
|
| 248 | + * @return int |
|
| 249 | + */ |
|
| 250 | + public function order() |
|
| 251 | + { |
|
| 252 | + return $this->get('QST_order'); |
|
| 253 | + } |
|
| 254 | + |
|
| 255 | + |
|
| 256 | + /** |
|
| 257 | + * returns whether this question should only appears to admins, |
|
| 258 | + * or to everyone |
|
| 259 | + * |
|
| 260 | + * @access public |
|
| 261 | + * @return boolean |
|
| 262 | + */ |
|
| 263 | + public function admin_only() |
|
| 264 | + { |
|
| 265 | + return $this->get('QST_admin_only'); |
|
| 266 | + } |
|
| 267 | + |
|
| 268 | + |
|
| 269 | + /** |
|
| 270 | + * returns the id the wordpress user who created this question |
|
| 271 | + * |
|
| 272 | + * @access public |
|
| 273 | + * @return int |
|
| 274 | + */ |
|
| 275 | + public function wp_user() |
|
| 276 | + { |
|
| 277 | + return $this->get('QST_wp_user'); |
|
| 278 | + } |
|
| 279 | + |
|
| 280 | + |
|
| 281 | + /** |
|
| 282 | + * returns whether this question has been marked as 'deleted' |
|
| 283 | + * |
|
| 284 | + * @access public |
|
| 285 | + * @return boolean |
|
| 286 | + */ |
|
| 287 | + public function deleted() |
|
| 288 | + { |
|
| 289 | + return $this->get('QST_deleted'); |
|
| 290 | + } |
|
| 291 | + |
|
| 292 | + |
|
| 293 | + /** |
|
| 294 | + * Gets an array of related EE_Answer to this EE_Question |
|
| 295 | + * |
|
| 296 | + * @return EE_Answer[] |
|
| 297 | + */ |
|
| 298 | + public function answers() |
|
| 299 | + { |
|
| 300 | + return $this->get_many_related('Answer'); |
|
| 301 | + } |
|
| 302 | + |
|
| 303 | + |
|
| 304 | + /** |
|
| 305 | + * Boolean check for if there are answers on this question in th db |
|
| 306 | + * |
|
| 307 | + * @return boolean true = has answers, false = no answers. |
|
| 308 | + */ |
|
| 309 | + public function has_answers() |
|
| 310 | + { |
|
| 311 | + return $this->count_related('Answer') > 0 ? true : false; |
|
| 312 | + } |
|
| 313 | + |
|
| 314 | + |
|
| 315 | + /** |
|
| 316 | + * gets an array of EE_Question_Group which relate to this question |
|
| 317 | + * |
|
| 318 | + * @return EE_Question_Group[] |
|
| 319 | + */ |
|
| 320 | + public function question_groups() |
|
| 321 | + { |
|
| 322 | + return $this->get_many_related('Question_Group'); |
|
| 323 | + } |
|
| 324 | + |
|
| 325 | + |
|
| 326 | + /** |
|
| 327 | + * Returns all the options for this question. By default, it returns only the not-yet-deleted ones. |
|
| 328 | + * |
|
| 329 | + * @param boolean $notDeletedOptionsOnly 1 |
|
| 330 | + * whether to return ALL options, or only the ones which have |
|
| 331 | + * not yet been deleleted |
|
| 332 | + * @param string|array $selected_value_to_always_include , when retrieving options to an ANSWERED question, |
|
| 333 | + * we want to usually only show non-deleted options AND the |
|
| 334 | + * value that was selected for the answer, whether it was |
|
| 335 | + * trashed or not. |
|
| 336 | + * @return EE_Question_Option[] |
|
| 337 | + */ |
|
| 338 | + public function options($notDeletedOptionsOnly = true, $selected_value_to_always_include = null) |
|
| 339 | + { |
|
| 340 | + if (! $this->ID()) { |
|
| 341 | + return array(); |
|
| 342 | + } |
|
| 343 | + $query_params = array(); |
|
| 344 | + if ($selected_value_to_always_include) { |
|
| 345 | + if (is_array($selected_value_to_always_include)) { |
|
| 346 | + $query_params[0]['OR*options-query']['QSO_value'] = array('IN', $selected_value_to_always_include); |
|
| 347 | + } else { |
|
| 348 | + $query_params[0]['OR*options-query']['QSO_value'] = $selected_value_to_always_include; |
|
| 349 | + } |
|
| 350 | + } |
|
| 351 | + if ($notDeletedOptionsOnly) { |
|
| 352 | + $query_params[0]['OR*options-query']['QSO_deleted'] = false; |
|
| 353 | + } |
|
| 354 | + // order by QSO_order |
|
| 355 | + $query_params['order_by'] = array('QSO_order' => 'ASC'); |
|
| 356 | + return $this->get_many_related('Question_Option', $query_params); |
|
| 357 | + } |
|
| 358 | + |
|
| 359 | + |
|
| 360 | + /** |
|
| 361 | + * returns an array of EE_Question_Options which relate to this question |
|
| 362 | + * |
|
| 363 | + * @return \EE_Question_Option[] |
|
| 364 | + */ |
|
| 365 | + public function temp_options() |
|
| 366 | + { |
|
| 367 | + return $this->_model_relations['Question_Option']; |
|
| 368 | + } |
|
| 369 | + |
|
| 370 | + |
|
| 371 | + /** |
|
| 372 | + * Adds an option for this question. Note: if the option were previously associated with a different |
|
| 373 | + * Question, that relationship will be overwritten. |
|
| 374 | + * |
|
| 375 | + * @param EE_Question_Option $option |
|
| 376 | + * @return boolean success |
|
| 377 | + */ |
|
| 378 | + public function add_option(EE_Question_Option $option) |
|
| 379 | + { |
|
| 380 | + return $this->_add_relation_to($option, 'Question_Option'); |
|
| 381 | + } |
|
| 382 | + |
|
| 383 | + |
|
| 384 | + /** |
|
| 385 | + * Adds an option directly to this question without saving to the db |
|
| 386 | + * |
|
| 387 | + * @param EE_Question_Option $option |
|
| 388 | + * @return boolean success |
|
| 389 | + */ |
|
| 390 | + public function add_temp_option(EE_Question_Option $option) |
|
| 391 | + { |
|
| 392 | + $this->_model_relations['Question_Option'][] = $option; |
|
| 393 | + return true; |
|
| 394 | + } |
|
| 395 | + |
|
| 396 | + |
|
| 397 | + /** |
|
| 398 | + * Marks the option as deleted. |
|
| 399 | + * |
|
| 400 | + * @param EE_Question_Option $option |
|
| 401 | + * @return boolean success |
|
| 402 | + */ |
|
| 403 | + public function remove_option(EE_Question_Option $option) |
|
| 404 | + { |
|
| 405 | + return $this->_remove_relation_to($option, 'Question_Option'); |
|
| 406 | + } |
|
| 407 | + |
|
| 408 | + |
|
| 409 | + /** |
|
| 410 | + * @return bool |
|
| 411 | + */ |
|
| 412 | + public function is_system_question() |
|
| 413 | + { |
|
| 414 | + $system_ID = $this->get('QST_system'); |
|
| 415 | + return ! empty($system_ID) ? true : false; |
|
| 416 | + } |
|
| 417 | + |
|
| 418 | + |
|
| 419 | + /** |
|
| 420 | + * The purpose of this method is set the question order this question order to be the max out of all questions |
|
| 421 | + * |
|
| 422 | + * @access public |
|
| 423 | + * @return void |
|
| 424 | + */ |
|
| 425 | + public function set_order_to_latest() |
|
| 426 | + { |
|
| 427 | + $latest_order = $this->get_model()->get_latest_question_order(); |
|
| 428 | + $latest_order++; |
|
| 429 | + $this->set('QST_order', $latest_order); |
|
| 430 | + } |
|
| 431 | + |
|
| 432 | + |
|
| 433 | + /** |
|
| 434 | + * Retrieves the list of allowed question types from the model. |
|
| 435 | + * |
|
| 436 | + * @return string[] |
|
| 437 | + */ |
|
| 438 | + private function _allowed_question_types() |
|
| 439 | + { |
|
| 440 | + $questionModel = $this->get_model(); |
|
| 441 | + /* @var $questionModel EEM_Question */ |
|
| 442 | + return $questionModel->allowed_question_types(); |
|
| 443 | + } |
|
| 444 | + |
|
| 445 | + /** |
|
| 446 | + * Duplicates this question and its question options |
|
| 447 | + * |
|
| 448 | + * @return \EE_Question |
|
| 449 | + */ |
|
| 450 | + public function duplicate($options = array()) |
|
| 451 | + { |
|
| 452 | + $new_question = clone $this; |
|
| 453 | + $new_question->set('QST_ID', null); |
|
| 454 | + $new_question->set_display_text(sprintf(esc_html__('%s **Duplicate**', 'event_espresso'), $this->display_text())); |
|
| 455 | + $new_question->set_admin_label(sprintf(esc_html__('%s **Duplicate**', 'event_espresso'), $this->admin_label())); |
|
| 456 | + $new_question->set_system_ID(null); |
|
| 457 | + $new_question->set_wp_user(get_current_user_id()); |
|
| 458 | + // if we're duplicating a trashed question, assume we don't want the new one to be trashed |
|
| 459 | + $new_question->set_deleted(false); |
|
| 460 | + $success = $new_question->save(); |
|
| 461 | + if ($success) { |
|
| 462 | + // we don't totally want to duplicate the question options, because we want them to be for the NEW question |
|
| 463 | + foreach ($this->options() as $question_option) { |
|
| 464 | + $question_option->duplicate(array('QST_ID' => $new_question->ID())); |
|
| 465 | + } |
|
| 466 | + return $new_question; |
|
| 467 | + } else { |
|
| 468 | + return null; |
|
| 469 | + } |
|
| 470 | + } |
|
| 471 | + |
|
| 472 | + /** |
|
| 473 | + * Returns the question's maximum allowed response size |
|
| 474 | + * |
|
| 475 | + * @return int|float |
|
| 476 | + */ |
|
| 477 | + public function max() |
|
| 478 | + { |
|
| 479 | + return $this->get('QST_max'); |
|
| 480 | + } |
|
| 481 | + |
|
| 482 | + /** |
|
| 483 | + * Sets the question's maximum allowed response size |
|
| 484 | + * |
|
| 485 | + * @param int|float $new_max |
|
| 486 | + * @return void |
|
| 487 | + */ |
|
| 488 | + public function set_max($new_max) |
|
| 489 | + { |
|
| 490 | + $this->set('QST_max', $new_max); |
|
| 491 | + } |
|
| 492 | + |
|
| 493 | + |
|
| 494 | + /** |
|
| 495 | + * Creates a form input from this question which can be used in HTML forms |
|
| 496 | + * |
|
| 497 | + * @param EE_Registration $registration |
|
| 498 | + * @param EE_Answer $answer |
|
| 499 | + * @param array $input_constructor_args |
|
| 500 | + * @return EE_Form_Input_Base |
|
| 501 | + */ |
|
| 502 | + public function generate_form_input($registration = null, $answer = null, $input_constructor_args = array()) |
|
| 503 | + { |
|
| 504 | + $identifier = $this->is_system_question() ? $this->system_ID() : $this->ID(); |
|
| 505 | + |
|
| 506 | + $input_constructor_args = array_merge( |
|
| 507 | + array( |
|
| 508 | + 'required' => $this->required() ? true : false, |
|
| 509 | + 'html_label_text' => $this->display_text(), |
|
| 510 | + 'required_validation_error_message' => $this->required_text(), |
|
| 511 | + ), |
|
| 512 | + $input_constructor_args |
|
| 513 | + ); |
|
| 514 | + if (! $answer instanceof EE_Answer && $registration instanceof EE_Registration) { |
|
| 515 | + $answer = EEM_Answer::instance()->get_registration_question_answer_object($registration, $this->ID()); |
|
| 516 | + } |
|
| 517 | + // has this question been answered ? |
|
| 518 | + if ( |
|
| 519 | + $answer instanceof EE_Answer |
|
| 520 | + && $answer->value() !== '' |
|
| 521 | + ) { |
|
| 522 | + // answer gets htmlspecialchars called on it, undo that please |
|
| 523 | + // because the form input's display strategy may call esc_attr too |
|
| 524 | + // which also does html special characters |
|
| 525 | + $values_with_html_special_chars = $answer->value(); |
|
| 526 | + if (is_array($values_with_html_special_chars)) { |
|
| 527 | + $default_value = array_map('htmlspecialchars_decode', $values_with_html_special_chars); |
|
| 528 | + } else { |
|
| 529 | + $default_value = htmlspecialchars_decode($values_with_html_special_chars); |
|
| 530 | + } |
|
| 531 | + $input_constructor_args['default'] = $default_value; |
|
| 532 | + } |
|
| 533 | + $max_max_for_question = EEM_Question::instance()->absolute_max_for_system_question($this->system_ID()); |
|
| 534 | + if ( |
|
| 535 | + in_array( |
|
| 536 | + $this->type(), |
|
| 537 | + EEM_Question::instance()->questionTypesWithMaxLength(), |
|
| 538 | + true |
|
| 539 | + ) |
|
| 540 | + ) { |
|
| 541 | + $input_constructor_args['validation_strategies'][] = new EE_Max_Length_Validation_Strategy( |
|
| 542 | + null, |
|
| 543 | + min($max_max_for_question, $this->max()) |
|
| 544 | + ); |
|
| 545 | + } |
|
| 546 | + $input_constructor_args = apply_filters( |
|
| 547 | + 'FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__input_constructor_args', |
|
| 548 | + $input_constructor_args, |
|
| 549 | + $registration, |
|
| 550 | + $this, |
|
| 551 | + $answer |
|
| 552 | + ); |
|
| 553 | + |
|
| 554 | + $result = null; |
|
| 555 | + switch ($this->type()) { |
|
| 556 | + // Text |
|
| 557 | + case EEM_Question::QST_type_text: |
|
| 558 | + $result = new EE_Text_Input($input_constructor_args); |
|
| 559 | + break; |
|
| 560 | + // Textarea |
|
| 561 | + case EEM_Question::QST_type_textarea: |
|
| 562 | + $result = new EE_Text_Area_Input($input_constructor_args); |
|
| 563 | + break; |
|
| 564 | + // Radio Buttons |
|
| 565 | + case EEM_Question::QST_type_radio: |
|
| 566 | + $result = new EE_Radio_Button_Input($this->options(), $input_constructor_args); |
|
| 567 | + break; |
|
| 568 | + // Dropdown |
|
| 569 | + case EEM_Question::QST_type_dropdown: |
|
| 570 | + $result = new EE_Select_Input($this->options(), $input_constructor_args); |
|
| 571 | + break; |
|
| 572 | + // State Dropdown |
|
| 573 | + case EEM_Question::QST_type_state: |
|
| 574 | + $state_options = apply_filters( |
|
| 575 | + 'FHEE__EE_Question__generate_form_input__state_options', |
|
| 576 | + null, |
|
| 577 | + $this, |
|
| 578 | + $registration, |
|
| 579 | + $answer |
|
| 580 | + ); |
|
| 581 | + $result = new EE_State_Select_Input($state_options, $input_constructor_args); |
|
| 582 | + break; |
|
| 583 | + // Country Dropdown |
|
| 584 | + case EEM_Question::QST_type_country: |
|
| 585 | + $country_options = apply_filters( |
|
| 586 | + 'FHEE__EE_Question__generate_form_input__country_options', |
|
| 587 | + null, |
|
| 588 | + $this, |
|
| 589 | + $registration, |
|
| 590 | + $answer |
|
| 591 | + ); |
|
| 592 | + $result = new EE_Country_Select_Input($country_options, $input_constructor_args); |
|
| 593 | + break; |
|
| 594 | + // Checkboxes |
|
| 595 | + case EEM_Question::QST_type_checkbox: |
|
| 596 | + $result = new EE_Checkbox_Multi_Input($this->options(), $input_constructor_args); |
|
| 597 | + break; |
|
| 598 | + // Date |
|
| 599 | + case EEM_Question::QST_type_date: |
|
| 600 | + $result = new EE_Datepicker_Input($input_constructor_args); |
|
| 601 | + break; |
|
| 602 | + case EEM_Question::QST_type_html_textarea: |
|
| 603 | + $input_constructor_args['validation_strategies'][] = new EE_Simple_HTML_Validation_Strategy(); |
|
| 604 | + $result = new EE_Text_Area_Input($input_constructor_args); |
|
| 605 | + $result->remove_validation_strategy('EE_Plaintext_Validation_Strategy'); |
|
| 606 | + break; |
|
| 607 | + case EEM_Question::QST_type_email: |
|
| 608 | + $result = new EE_Email_Input($input_constructor_args); |
|
| 609 | + break; |
|
| 610 | + // Email confirm |
|
| 611 | + case EEM_Question::QST_type_email_confirm: |
|
| 612 | + $result = new EE_Email_Confirm_Input($input_constructor_args); |
|
| 613 | + break; |
|
| 614 | + case EEM_Question::QST_type_us_phone: |
|
| 615 | + $result = new EE_Phone_Input($input_constructor_args); |
|
| 616 | + break; |
|
| 617 | + case EEM_Question::QST_type_int: |
|
| 618 | + $result = new EE_Integer_Input($input_constructor_args); |
|
| 619 | + break; |
|
| 620 | + case EEM_Question::QST_type_decimal: |
|
| 621 | + $result = new EE_Float_Input($input_constructor_args); |
|
| 622 | + break; |
|
| 623 | + case EEM_Question::QST_type_url: |
|
| 624 | + $input_constructor_args['validation_strategies'][] = LoaderFactory::getLoader()->getNew('EE_URL_Validation_Strategy'); |
|
| 625 | + $result = new EE_Text_Input($input_constructor_args); |
|
| 626 | + break; |
|
| 627 | + case EEM_Question::QST_type_year: |
|
| 628 | + $result = new EE_Year_Input( |
|
| 629 | + $input_constructor_args, |
|
| 630 | + apply_filters( |
|
| 631 | + 'FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__year_question__four_digit', |
|
| 632 | + true, |
|
| 633 | + $this |
|
| 634 | + ), |
|
| 635 | + apply_filters( |
|
| 636 | + 'FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__year_question__early_range', |
|
| 637 | + 100, |
|
| 638 | + $this |
|
| 639 | + ), |
|
| 640 | + apply_filters( |
|
| 641 | + 'FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__year_question__end_range', |
|
| 642 | + 100, |
|
| 643 | + $this |
|
| 644 | + ) |
|
| 645 | + ); |
|
| 646 | + break; |
|
| 647 | + case EEM_Question::QST_type_multi_select: |
|
| 648 | + $result = new EE_Select_Multiple_Input($this->options(), $input_constructor_args); |
|
| 649 | + break; |
|
| 650 | + // fallback |
|
| 651 | + default: |
|
| 652 | + $default_input = apply_filters( |
|
| 653 | + 'FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__default', |
|
| 654 | + null, |
|
| 655 | + $this->type(), |
|
| 656 | + $this, |
|
| 657 | + $input_constructor_args |
|
| 658 | + ); |
|
| 659 | + if (! $default_input) { |
|
| 660 | + $default_input = new EE_Text_Input($input_constructor_args); |
|
| 661 | + } |
|
| 662 | + $result = $default_input; |
|
| 663 | + } |
|
| 664 | + return apply_filters('FHEE__EE_Question__generate_form_input__return', $result, $registration, $this, $answer); |
|
| 665 | + } |
|
| 666 | + |
|
| 667 | + |
|
| 668 | + /** |
|
| 669 | + * Returns whether or not this question type should have question option entries |
|
| 670 | + * |
|
| 671 | + * @return bool |
|
| 672 | + */ |
|
| 673 | + public function should_have_question_options() |
|
| 674 | + { |
|
| 675 | + return in_array( |
|
| 676 | + $this->type(), |
|
| 677 | + $this->_model->question_types_with_options(), |
|
| 678 | + true |
|
| 679 | + ); |
|
| 680 | + } |
|
| 681 | 681 | } |
@@ -285,7 +285,7 @@ |
||
| 285 | 285 | */ |
| 286 | 286 | public function pretty_price() |
| 287 | 287 | { |
| 288 | - return ! $this->is_percent() ? $this->get_pretty('PRC_amount') : $this->get('PRC_amount') . '%'; |
|
| 288 | + return ! $this->is_percent() ? $this->get_pretty('PRC_amount') : $this->get('PRC_amount').'%'; |
|
| 289 | 289 | } |
| 290 | 290 | |
| 291 | 291 | |
@@ -10,289 +10,289 @@ |
||
| 10 | 10 | class EE_Price extends EE_Soft_Delete_Base_Class |
| 11 | 11 | { |
| 12 | 12 | |
| 13 | - /** |
|
| 14 | - * @param array $props_n_values incoming values |
|
| 15 | - * @param string $timezone incoming timezone (if not set the timezone set for the website will be |
|
| 16 | - * used.) |
|
| 17 | - * @param array $date_formats incoming date_formats in an array where the first value is the |
|
| 18 | - * date_format and the second value is the time format |
|
| 19 | - * @return EE_Price |
|
| 20 | - */ |
|
| 21 | - public static function new_instance($props_n_values = array(), $timezone = null, $date_formats = array()) |
|
| 22 | - { |
|
| 23 | - $has_object = parent::_check_for_object($props_n_values, __CLASS__, $timezone, $date_formats); |
|
| 24 | - return $has_object ? $has_object : new self($props_n_values, false, $timezone, $date_formats); |
|
| 25 | - } |
|
| 26 | - |
|
| 27 | - |
|
| 28 | - /** |
|
| 29 | - * @param array $props_n_values incoming values from the database |
|
| 30 | - * @param string $timezone incoming timezone as set by the model. If not set the timezone for |
|
| 31 | - * the website will be used. |
|
| 32 | - * @return EE_Price |
|
| 33 | - */ |
|
| 34 | - public static function new_instance_from_db($props_n_values = array(), $timezone = null) |
|
| 35 | - { |
|
| 36 | - return new self($props_n_values, true, $timezone); |
|
| 37 | - } |
|
| 38 | - |
|
| 39 | - |
|
| 40 | - /** |
|
| 41 | - * Set Price type ID |
|
| 42 | - * |
|
| 43 | - * @access public |
|
| 44 | - * @param int $PRT_ID |
|
| 45 | - */ |
|
| 46 | - public function set_type($PRT_ID = 0) |
|
| 47 | - { |
|
| 48 | - $this->set('PRT_ID', $PRT_ID); |
|
| 49 | - } |
|
| 50 | - |
|
| 51 | - |
|
| 52 | - /** |
|
| 53 | - * Set Price Amount |
|
| 54 | - * |
|
| 55 | - * @access public |
|
| 56 | - * @param float $PRC_amount |
|
| 57 | - */ |
|
| 58 | - public function set_amount($PRC_amount = 0.00) |
|
| 59 | - { |
|
| 60 | - $this->set('PRC_amount', $PRC_amount); |
|
| 61 | - } |
|
| 62 | - |
|
| 63 | - |
|
| 64 | - /** |
|
| 65 | - * Set Price Name |
|
| 66 | - * |
|
| 67 | - * @access public |
|
| 68 | - * @param string $PRC_name |
|
| 69 | - */ |
|
| 70 | - public function set_name($PRC_name = '') |
|
| 71 | - { |
|
| 72 | - $this->set('PRC_name', $PRC_name); |
|
| 73 | - } |
|
| 74 | - |
|
| 75 | - |
|
| 76 | - /** |
|
| 77 | - * Set Price Description |
|
| 78 | - * |
|
| 79 | - * @access public |
|
| 80 | - * @param string $PRC_desc |
|
| 81 | - */ |
|
| 82 | - public function set_description($PRC_desc = '') |
|
| 83 | - { |
|
| 84 | - $this->Set('PRC_desc', $PRC_desc); |
|
| 85 | - } |
|
| 86 | - |
|
| 87 | - |
|
| 88 | - /** |
|
| 89 | - * set is_default |
|
| 90 | - * |
|
| 91 | - * @access public |
|
| 92 | - * @param bool $PRC_is_default |
|
| 93 | - */ |
|
| 94 | - public function set_is_default($PRC_is_default = false) |
|
| 95 | - { |
|
| 96 | - $this->set('PRC_is_default', $PRC_is_default); |
|
| 97 | - } |
|
| 98 | - |
|
| 99 | - |
|
| 100 | - /** |
|
| 101 | - * set deleted |
|
| 102 | - * |
|
| 103 | - * @access public |
|
| 104 | - * @param bool $PRC_deleted |
|
| 105 | - */ |
|
| 106 | - public function set_deleted($PRC_deleted = null) |
|
| 107 | - { |
|
| 108 | - $this->set('PRC_deleted', $PRC_deleted); |
|
| 109 | - } |
|
| 110 | - |
|
| 111 | - |
|
| 112 | - /** |
|
| 113 | - * get Price type |
|
| 114 | - * |
|
| 115 | - * @access public |
|
| 116 | - * @return int |
|
| 117 | - */ |
|
| 118 | - public function type() |
|
| 119 | - { |
|
| 120 | - return $this->get('PRT_ID'); |
|
| 121 | - } |
|
| 122 | - |
|
| 123 | - |
|
| 124 | - /** |
|
| 125 | - * get Price Amount |
|
| 126 | - * |
|
| 127 | - * @access public |
|
| 128 | - * @return float |
|
| 129 | - */ |
|
| 130 | - public function amount() |
|
| 131 | - { |
|
| 132 | - return $this->get('PRC_amount'); |
|
| 133 | - } |
|
| 134 | - |
|
| 135 | - |
|
| 136 | - /** |
|
| 137 | - * get Price Name |
|
| 138 | - * |
|
| 139 | - * @access public |
|
| 140 | - * @return string |
|
| 141 | - */ |
|
| 142 | - public function name() |
|
| 143 | - { |
|
| 144 | - return $this->get('PRC_name'); |
|
| 145 | - } |
|
| 146 | - |
|
| 147 | - |
|
| 148 | - /** |
|
| 149 | - * get Price description |
|
| 150 | - * |
|
| 151 | - * @access public |
|
| 152 | - * @return string |
|
| 153 | - */ |
|
| 154 | - public function desc() |
|
| 155 | - { |
|
| 156 | - return $this->get('PRC_desc'); |
|
| 157 | - } |
|
| 158 | - |
|
| 159 | - |
|
| 160 | - /** |
|
| 161 | - * get overrides |
|
| 162 | - * |
|
| 163 | - * @access public |
|
| 164 | - * @return int |
|
| 165 | - */ |
|
| 166 | - public function overrides() |
|
| 167 | - { |
|
| 168 | - return $this->get('PRC_overrides'); |
|
| 169 | - } |
|
| 170 | - |
|
| 171 | - |
|
| 172 | - /** |
|
| 173 | - * get order |
|
| 174 | - * |
|
| 175 | - * @access public |
|
| 176 | - * @return int |
|
| 177 | - */ |
|
| 178 | - public function order() |
|
| 179 | - { |
|
| 180 | - return $this->get('PRC_order'); |
|
| 181 | - } |
|
| 182 | - |
|
| 183 | - |
|
| 184 | - /** |
|
| 185 | - * get the author of the price |
|
| 186 | - * |
|
| 187 | - * @since 4.5.0 |
|
| 188 | - * |
|
| 189 | - * @return int |
|
| 190 | - */ |
|
| 191 | - public function wp_user() |
|
| 192 | - { |
|
| 193 | - return $this->get('PRC_wp_user'); |
|
| 194 | - } |
|
| 195 | - |
|
| 196 | - |
|
| 197 | - /** |
|
| 198 | - * get is_default |
|
| 199 | - * |
|
| 200 | - * @access public |
|
| 201 | - * @return bool |
|
| 202 | - */ |
|
| 203 | - public function is_default() |
|
| 204 | - { |
|
| 205 | - return $this->get('PRC_is_default'); |
|
| 206 | - } |
|
| 207 | - |
|
| 208 | - |
|
| 209 | - /** |
|
| 210 | - * get deleted |
|
| 211 | - * |
|
| 212 | - * @access public |
|
| 213 | - * @return bool |
|
| 214 | - */ |
|
| 215 | - public function deleted() |
|
| 216 | - { |
|
| 217 | - return $this->get('PRC_deleted'); |
|
| 218 | - } |
|
| 219 | - |
|
| 220 | - |
|
| 221 | - /** |
|
| 222 | - * @return bool |
|
| 223 | - */ |
|
| 224 | - public function parent() |
|
| 225 | - { |
|
| 226 | - return $this->get('PRC_parent'); |
|
| 227 | - } |
|
| 228 | - |
|
| 229 | - |
|
| 230 | - // some helper methods for getting info on the price_type for this price |
|
| 231 | - |
|
| 232 | - /** |
|
| 233 | - * return whether the price is a base price or not |
|
| 234 | - * |
|
| 235 | - * @return boolean |
|
| 236 | - */ |
|
| 237 | - public function is_base_price() |
|
| 238 | - { |
|
| 239 | - $price_type = $this->type_obj(); |
|
| 240 | - return $price_type->base_type() === 1; |
|
| 241 | - } |
|
| 242 | - |
|
| 243 | - |
|
| 244 | - /** |
|
| 245 | - * |
|
| 246 | - * @return EE_Price_Type |
|
| 247 | - */ |
|
| 248 | - public function type_obj() |
|
| 249 | - { |
|
| 250 | - return $this->get_first_related('Price_Type'); |
|
| 251 | - } |
|
| 252 | - |
|
| 253 | - |
|
| 254 | - /** |
|
| 255 | - * Simply indicates whether this price increases or decreases the total |
|
| 256 | - * |
|
| 257 | - * @return boolean true = discount, otherwise adds to the total |
|
| 258 | - */ |
|
| 259 | - public function is_discount() |
|
| 260 | - { |
|
| 261 | - $price_type = $this->type_obj(); |
|
| 262 | - return $price_type->is_discount(); |
|
| 263 | - } |
|
| 264 | - |
|
| 265 | - |
|
| 266 | - /** |
|
| 267 | - * whether the price is a percentage or not |
|
| 268 | - * |
|
| 269 | - * @return boolean |
|
| 270 | - */ |
|
| 271 | - public function is_percent() |
|
| 272 | - { |
|
| 273 | - $price_type = $this->type_obj(); |
|
| 274 | - return $price_type->get('PRT_is_percent'); |
|
| 275 | - } |
|
| 276 | - |
|
| 277 | - |
|
| 278 | - /** |
|
| 279 | - * return pretty price dependant on whether its a dollar or percent. |
|
| 280 | - * |
|
| 281 | - * @since 4.4.0 |
|
| 282 | - * |
|
| 283 | - * @return string |
|
| 284 | - */ |
|
| 285 | - public function pretty_price() |
|
| 286 | - { |
|
| 287 | - return ! $this->is_percent() ? $this->get_pretty('PRC_amount') : $this->get('PRC_amount') . '%'; |
|
| 288 | - } |
|
| 289 | - |
|
| 290 | - |
|
| 291 | - /** |
|
| 292 | - * @return mixed |
|
| 293 | - */ |
|
| 294 | - public function get_price_without_currency_symbol() |
|
| 295 | - { |
|
| 296 | - return str_replace(EE_Registry::instance()->CFG->currency->sign, '', $this->get_pretty('PRC_amount')); |
|
| 297 | - } |
|
| 13 | + /** |
|
| 14 | + * @param array $props_n_values incoming values |
|
| 15 | + * @param string $timezone incoming timezone (if not set the timezone set for the website will be |
|
| 16 | + * used.) |
|
| 17 | + * @param array $date_formats incoming date_formats in an array where the first value is the |
|
| 18 | + * date_format and the second value is the time format |
|
| 19 | + * @return EE_Price |
|
| 20 | + */ |
|
| 21 | + public static function new_instance($props_n_values = array(), $timezone = null, $date_formats = array()) |
|
| 22 | + { |
|
| 23 | + $has_object = parent::_check_for_object($props_n_values, __CLASS__, $timezone, $date_formats); |
|
| 24 | + return $has_object ? $has_object : new self($props_n_values, false, $timezone, $date_formats); |
|
| 25 | + } |
|
| 26 | + |
|
| 27 | + |
|
| 28 | + /** |
|
| 29 | + * @param array $props_n_values incoming values from the database |
|
| 30 | + * @param string $timezone incoming timezone as set by the model. If not set the timezone for |
|
| 31 | + * the website will be used. |
|
| 32 | + * @return EE_Price |
|
| 33 | + */ |
|
| 34 | + public static function new_instance_from_db($props_n_values = array(), $timezone = null) |
|
| 35 | + { |
|
| 36 | + return new self($props_n_values, true, $timezone); |
|
| 37 | + } |
|
| 38 | + |
|
| 39 | + |
|
| 40 | + /** |
|
| 41 | + * Set Price type ID |
|
| 42 | + * |
|
| 43 | + * @access public |
|
| 44 | + * @param int $PRT_ID |
|
| 45 | + */ |
|
| 46 | + public function set_type($PRT_ID = 0) |
|
| 47 | + { |
|
| 48 | + $this->set('PRT_ID', $PRT_ID); |
|
| 49 | + } |
|
| 50 | + |
|
| 51 | + |
|
| 52 | + /** |
|
| 53 | + * Set Price Amount |
|
| 54 | + * |
|
| 55 | + * @access public |
|
| 56 | + * @param float $PRC_amount |
|
| 57 | + */ |
|
| 58 | + public function set_amount($PRC_amount = 0.00) |
|
| 59 | + { |
|
| 60 | + $this->set('PRC_amount', $PRC_amount); |
|
| 61 | + } |
|
| 62 | + |
|
| 63 | + |
|
| 64 | + /** |
|
| 65 | + * Set Price Name |
|
| 66 | + * |
|
| 67 | + * @access public |
|
| 68 | + * @param string $PRC_name |
|
| 69 | + */ |
|
| 70 | + public function set_name($PRC_name = '') |
|
| 71 | + { |
|
| 72 | + $this->set('PRC_name', $PRC_name); |
|
| 73 | + } |
|
| 74 | + |
|
| 75 | + |
|
| 76 | + /** |
|
| 77 | + * Set Price Description |
|
| 78 | + * |
|
| 79 | + * @access public |
|
| 80 | + * @param string $PRC_desc |
|
| 81 | + */ |
|
| 82 | + public function set_description($PRC_desc = '') |
|
| 83 | + { |
|
| 84 | + $this->Set('PRC_desc', $PRC_desc); |
|
| 85 | + } |
|
| 86 | + |
|
| 87 | + |
|
| 88 | + /** |
|
| 89 | + * set is_default |
|
| 90 | + * |
|
| 91 | + * @access public |
|
| 92 | + * @param bool $PRC_is_default |
|
| 93 | + */ |
|
| 94 | + public function set_is_default($PRC_is_default = false) |
|
| 95 | + { |
|
| 96 | + $this->set('PRC_is_default', $PRC_is_default); |
|
| 97 | + } |
|
| 98 | + |
|
| 99 | + |
|
| 100 | + /** |
|
| 101 | + * set deleted |
|
| 102 | + * |
|
| 103 | + * @access public |
|
| 104 | + * @param bool $PRC_deleted |
|
| 105 | + */ |
|
| 106 | + public function set_deleted($PRC_deleted = null) |
|
| 107 | + { |
|
| 108 | + $this->set('PRC_deleted', $PRC_deleted); |
|
| 109 | + } |
|
| 110 | + |
|
| 111 | + |
|
| 112 | + /** |
|
| 113 | + * get Price type |
|
| 114 | + * |
|
| 115 | + * @access public |
|
| 116 | + * @return int |
|
| 117 | + */ |
|
| 118 | + public function type() |
|
| 119 | + { |
|
| 120 | + return $this->get('PRT_ID'); |
|
| 121 | + } |
|
| 122 | + |
|
| 123 | + |
|
| 124 | + /** |
|
| 125 | + * get Price Amount |
|
| 126 | + * |
|
| 127 | + * @access public |
|
| 128 | + * @return float |
|
| 129 | + */ |
|
| 130 | + public function amount() |
|
| 131 | + { |
|
| 132 | + return $this->get('PRC_amount'); |
|
| 133 | + } |
|
| 134 | + |
|
| 135 | + |
|
| 136 | + /** |
|
| 137 | + * get Price Name |
|
| 138 | + * |
|
| 139 | + * @access public |
|
| 140 | + * @return string |
|
| 141 | + */ |
|
| 142 | + public function name() |
|
| 143 | + { |
|
| 144 | + return $this->get('PRC_name'); |
|
| 145 | + } |
|
| 146 | + |
|
| 147 | + |
|
| 148 | + /** |
|
| 149 | + * get Price description |
|
| 150 | + * |
|
| 151 | + * @access public |
|
| 152 | + * @return string |
|
| 153 | + */ |
|
| 154 | + public function desc() |
|
| 155 | + { |
|
| 156 | + return $this->get('PRC_desc'); |
|
| 157 | + } |
|
| 158 | + |
|
| 159 | + |
|
| 160 | + /** |
|
| 161 | + * get overrides |
|
| 162 | + * |
|
| 163 | + * @access public |
|
| 164 | + * @return int |
|
| 165 | + */ |
|
| 166 | + public function overrides() |
|
| 167 | + { |
|
| 168 | + return $this->get('PRC_overrides'); |
|
| 169 | + } |
|
| 170 | + |
|
| 171 | + |
|
| 172 | + /** |
|
| 173 | + * get order |
|
| 174 | + * |
|
| 175 | + * @access public |
|
| 176 | + * @return int |
|
| 177 | + */ |
|
| 178 | + public function order() |
|
| 179 | + { |
|
| 180 | + return $this->get('PRC_order'); |
|
| 181 | + } |
|
| 182 | + |
|
| 183 | + |
|
| 184 | + /** |
|
| 185 | + * get the author of the price |
|
| 186 | + * |
|
| 187 | + * @since 4.5.0 |
|
| 188 | + * |
|
| 189 | + * @return int |
|
| 190 | + */ |
|
| 191 | + public function wp_user() |
|
| 192 | + { |
|
| 193 | + return $this->get('PRC_wp_user'); |
|
| 194 | + } |
|
| 195 | + |
|
| 196 | + |
|
| 197 | + /** |
|
| 198 | + * get is_default |
|
| 199 | + * |
|
| 200 | + * @access public |
|
| 201 | + * @return bool |
|
| 202 | + */ |
|
| 203 | + public function is_default() |
|
| 204 | + { |
|
| 205 | + return $this->get('PRC_is_default'); |
|
| 206 | + } |
|
| 207 | + |
|
| 208 | + |
|
| 209 | + /** |
|
| 210 | + * get deleted |
|
| 211 | + * |
|
| 212 | + * @access public |
|
| 213 | + * @return bool |
|
| 214 | + */ |
|
| 215 | + public function deleted() |
|
| 216 | + { |
|
| 217 | + return $this->get('PRC_deleted'); |
|
| 218 | + } |
|
| 219 | + |
|
| 220 | + |
|
| 221 | + /** |
|
| 222 | + * @return bool |
|
| 223 | + */ |
|
| 224 | + public function parent() |
|
| 225 | + { |
|
| 226 | + return $this->get('PRC_parent'); |
|
| 227 | + } |
|
| 228 | + |
|
| 229 | + |
|
| 230 | + // some helper methods for getting info on the price_type for this price |
|
| 231 | + |
|
| 232 | + /** |
|
| 233 | + * return whether the price is a base price or not |
|
| 234 | + * |
|
| 235 | + * @return boolean |
|
| 236 | + */ |
|
| 237 | + public function is_base_price() |
|
| 238 | + { |
|
| 239 | + $price_type = $this->type_obj(); |
|
| 240 | + return $price_type->base_type() === 1; |
|
| 241 | + } |
|
| 242 | + |
|
| 243 | + |
|
| 244 | + /** |
|
| 245 | + * |
|
| 246 | + * @return EE_Price_Type |
|
| 247 | + */ |
|
| 248 | + public function type_obj() |
|
| 249 | + { |
|
| 250 | + return $this->get_first_related('Price_Type'); |
|
| 251 | + } |
|
| 252 | + |
|
| 253 | + |
|
| 254 | + /** |
|
| 255 | + * Simply indicates whether this price increases or decreases the total |
|
| 256 | + * |
|
| 257 | + * @return boolean true = discount, otherwise adds to the total |
|
| 258 | + */ |
|
| 259 | + public function is_discount() |
|
| 260 | + { |
|
| 261 | + $price_type = $this->type_obj(); |
|
| 262 | + return $price_type->is_discount(); |
|
| 263 | + } |
|
| 264 | + |
|
| 265 | + |
|
| 266 | + /** |
|
| 267 | + * whether the price is a percentage or not |
|
| 268 | + * |
|
| 269 | + * @return boolean |
|
| 270 | + */ |
|
| 271 | + public function is_percent() |
|
| 272 | + { |
|
| 273 | + $price_type = $this->type_obj(); |
|
| 274 | + return $price_type->get('PRT_is_percent'); |
|
| 275 | + } |
|
| 276 | + |
|
| 277 | + |
|
| 278 | + /** |
|
| 279 | + * return pretty price dependant on whether its a dollar or percent. |
|
| 280 | + * |
|
| 281 | + * @since 4.4.0 |
|
| 282 | + * |
|
| 283 | + * @return string |
|
| 284 | + */ |
|
| 285 | + public function pretty_price() |
|
| 286 | + { |
|
| 287 | + return ! $this->is_percent() ? $this->get_pretty('PRC_amount') : $this->get('PRC_amount') . '%'; |
|
| 288 | + } |
|
| 289 | + |
|
| 290 | + |
|
| 291 | + /** |
|
| 292 | + * @return mixed |
|
| 293 | + */ |
|
| 294 | + public function get_price_without_currency_symbol() |
|
| 295 | + { |
|
| 296 | + return str_replace(EE_Registry::instance()->CFG->currency->sign, '', $this->get_pretty('PRC_amount')); |
|
| 297 | + } |
|
| 298 | 298 | } |
@@ -10,23 +10,23 @@ |
||
| 10 | 10 | class EE_Term_Relationship extends EE_Base_Class |
| 11 | 11 | { |
| 12 | 12 | |
| 13 | - /** |
|
| 14 | - * @param array $props_n_values |
|
| 15 | - * @return EE_Term_Relationship |
|
| 16 | - */ |
|
| 17 | - public static function new_instance($props_n_values = array()) |
|
| 18 | - { |
|
| 19 | - $has_object = parent::_check_for_object($props_n_values, __CLASS__); |
|
| 20 | - return $has_object ? $has_object : new self($props_n_values); |
|
| 21 | - } |
|
| 13 | + /** |
|
| 14 | + * @param array $props_n_values |
|
| 15 | + * @return EE_Term_Relationship |
|
| 16 | + */ |
|
| 17 | + public static function new_instance($props_n_values = array()) |
|
| 18 | + { |
|
| 19 | + $has_object = parent::_check_for_object($props_n_values, __CLASS__); |
|
| 20 | + return $has_object ? $has_object : new self($props_n_values); |
|
| 21 | + } |
|
| 22 | 22 | |
| 23 | 23 | |
| 24 | - /** |
|
| 25 | - * @param array $props_n_values |
|
| 26 | - * @return EE_Term_Relationship |
|
| 27 | - */ |
|
| 28 | - public static function new_instance_from_db($props_n_values = array()) |
|
| 29 | - { |
|
| 30 | - return new self($props_n_values, true); |
|
| 31 | - } |
|
| 24 | + /** |
|
| 25 | + * @param array $props_n_values |
|
| 26 | + * @return EE_Term_Relationship |
|
| 27 | + */ |
|
| 28 | + public static function new_instance_from_db($props_n_values = array()) |
|
| 29 | + { |
|
| 30 | + return new self($props_n_values, true); |
|
| 31 | + } |
|
| 32 | 32 | } |
@@ -10,144 +10,144 @@ |
||
| 10 | 10 | class EE_Answer extends EE_Base_Class |
| 11 | 11 | { |
| 12 | 12 | |
| 13 | - /** |
|
| 14 | - * |
|
| 15 | - * @param array $props_n_values |
|
| 16 | - * @return EE_Answer |
|
| 17 | - */ |
|
| 18 | - public static function new_instance($props_n_values = array()) |
|
| 19 | - { |
|
| 20 | - $has_object = parent::_check_for_object($props_n_values, __CLASS__); |
|
| 21 | - return $has_object ? $has_object : new self($props_n_values); |
|
| 22 | - } |
|
| 23 | - |
|
| 24 | - |
|
| 25 | - /** |
|
| 26 | - * |
|
| 27 | - * @param array $props_n_values |
|
| 28 | - * @return EE_Answer |
|
| 29 | - */ |
|
| 30 | - public static function new_instance_from_db($props_n_values = array()) |
|
| 31 | - { |
|
| 32 | - return new self($props_n_values, true); |
|
| 33 | - } |
|
| 34 | - |
|
| 35 | - |
|
| 36 | - /** |
|
| 37 | - * Set Question ID |
|
| 38 | - * |
|
| 39 | - * @access public |
|
| 40 | - * @param int $QST_ID |
|
| 41 | - */ |
|
| 42 | - public function set_question($QST_ID = 0) |
|
| 43 | - { |
|
| 44 | - $this->set('QST_ID', $QST_ID); |
|
| 45 | - } |
|
| 46 | - |
|
| 47 | - |
|
| 48 | - /** |
|
| 49 | - * Set Registration ID |
|
| 50 | - * |
|
| 51 | - * @access public |
|
| 52 | - * @param int $REG_ID |
|
| 53 | - */ |
|
| 54 | - public function set_registration($REG_ID = 0) |
|
| 55 | - { |
|
| 56 | - $this->set('REG_ID', $REG_ID); |
|
| 57 | - } |
|
| 58 | - |
|
| 59 | - |
|
| 60 | - /** |
|
| 61 | - * Set Answer value |
|
| 62 | - * |
|
| 63 | - * @access public |
|
| 64 | - * @param mixed $ANS_value |
|
| 65 | - */ |
|
| 66 | - public function set_value($ANS_value = '') |
|
| 67 | - { |
|
| 68 | - $this->set('ANS_value', $ANS_value); |
|
| 69 | - } |
|
| 70 | - |
|
| 71 | - |
|
| 72 | - /** |
|
| 73 | - * get Attendee First Name |
|
| 74 | - * |
|
| 75 | - * @access public |
|
| 76 | - * @return int |
|
| 77 | - */ |
|
| 78 | - public function registration_ID() |
|
| 79 | - { |
|
| 80 | - return $this->get('REG_ID'); |
|
| 81 | - } |
|
| 82 | - |
|
| 83 | - |
|
| 84 | - /** |
|
| 85 | - * get Attendee Last Name |
|
| 86 | - * |
|
| 87 | - * @access public |
|
| 88 | - * @return int |
|
| 89 | - */ |
|
| 90 | - public function question_ID() |
|
| 91 | - { |
|
| 92 | - return $this->get('QST_ID'); |
|
| 93 | - } |
|
| 94 | - |
|
| 95 | - |
|
| 96 | - /** |
|
| 97 | - * get Attendee Address |
|
| 98 | - * |
|
| 99 | - * @access public |
|
| 100 | - * @return string |
|
| 101 | - */ |
|
| 102 | - public function value() |
|
| 103 | - { |
|
| 104 | - return $this->get('ANS_value'); |
|
| 105 | - } |
|
| 106 | - |
|
| 107 | - |
|
| 108 | - /** |
|
| 109 | - * Gets a pretty form of the value (mostly applies to answers that have multiple answers) |
|
| 110 | - * |
|
| 111 | - * @param null $schema |
|
| 112 | - * @return string |
|
| 113 | - */ |
|
| 114 | - public function pretty_value($schema = null) |
|
| 115 | - { |
|
| 116 | - return $this->get_pretty('ANS_value', $schema); |
|
| 117 | - } |
|
| 118 | - |
|
| 119 | - |
|
| 120 | - /** |
|
| 121 | - * Echoes out a pretty value (even for multi-choice options) |
|
| 122 | - * |
|
| 123 | - * @param string $schema |
|
| 124 | - */ |
|
| 125 | - public function e_value($schema = null) |
|
| 126 | - { |
|
| 127 | - $this->e('ANS_value', $schema); |
|
| 128 | - } |
|
| 129 | - |
|
| 130 | - |
|
| 131 | - /** |
|
| 132 | - * Gets the related EE_Question to this EE_Answer |
|
| 133 | - * |
|
| 134 | - * @return EE_Question |
|
| 135 | - */ |
|
| 136 | - public function question() |
|
| 137 | - { |
|
| 138 | - return $this->get_first_related('Question'); |
|
| 139 | - } |
|
| 140 | - |
|
| 141 | - |
|
| 142 | - /** |
|
| 143 | - * Gets the related EE_Registration to this EE_Answer |
|
| 144 | - * |
|
| 145 | - * @return EE_Registration |
|
| 146 | - */ |
|
| 147 | - public function registration() |
|
| 148 | - { |
|
| 149 | - return $this->get_first_related('Registration'); |
|
| 150 | - } |
|
| 13 | + /** |
|
| 14 | + * |
|
| 15 | + * @param array $props_n_values |
|
| 16 | + * @return EE_Answer |
|
| 17 | + */ |
|
| 18 | + public static function new_instance($props_n_values = array()) |
|
| 19 | + { |
|
| 20 | + $has_object = parent::_check_for_object($props_n_values, __CLASS__); |
|
| 21 | + return $has_object ? $has_object : new self($props_n_values); |
|
| 22 | + } |
|
| 23 | + |
|
| 24 | + |
|
| 25 | + /** |
|
| 26 | + * |
|
| 27 | + * @param array $props_n_values |
|
| 28 | + * @return EE_Answer |
|
| 29 | + */ |
|
| 30 | + public static function new_instance_from_db($props_n_values = array()) |
|
| 31 | + { |
|
| 32 | + return new self($props_n_values, true); |
|
| 33 | + } |
|
| 34 | + |
|
| 35 | + |
|
| 36 | + /** |
|
| 37 | + * Set Question ID |
|
| 38 | + * |
|
| 39 | + * @access public |
|
| 40 | + * @param int $QST_ID |
|
| 41 | + */ |
|
| 42 | + public function set_question($QST_ID = 0) |
|
| 43 | + { |
|
| 44 | + $this->set('QST_ID', $QST_ID); |
|
| 45 | + } |
|
| 46 | + |
|
| 47 | + |
|
| 48 | + /** |
|
| 49 | + * Set Registration ID |
|
| 50 | + * |
|
| 51 | + * @access public |
|
| 52 | + * @param int $REG_ID |
|
| 53 | + */ |
|
| 54 | + public function set_registration($REG_ID = 0) |
|
| 55 | + { |
|
| 56 | + $this->set('REG_ID', $REG_ID); |
|
| 57 | + } |
|
| 58 | + |
|
| 59 | + |
|
| 60 | + /** |
|
| 61 | + * Set Answer value |
|
| 62 | + * |
|
| 63 | + * @access public |
|
| 64 | + * @param mixed $ANS_value |
|
| 65 | + */ |
|
| 66 | + public function set_value($ANS_value = '') |
|
| 67 | + { |
|
| 68 | + $this->set('ANS_value', $ANS_value); |
|
| 69 | + } |
|
| 70 | + |
|
| 71 | + |
|
| 72 | + /** |
|
| 73 | + * get Attendee First Name |
|
| 74 | + * |
|
| 75 | + * @access public |
|
| 76 | + * @return int |
|
| 77 | + */ |
|
| 78 | + public function registration_ID() |
|
| 79 | + { |
|
| 80 | + return $this->get('REG_ID'); |
|
| 81 | + } |
|
| 82 | + |
|
| 83 | + |
|
| 84 | + /** |
|
| 85 | + * get Attendee Last Name |
|
| 86 | + * |
|
| 87 | + * @access public |
|
| 88 | + * @return int |
|
| 89 | + */ |
|
| 90 | + public function question_ID() |
|
| 91 | + { |
|
| 92 | + return $this->get('QST_ID'); |
|
| 93 | + } |
|
| 94 | + |
|
| 95 | + |
|
| 96 | + /** |
|
| 97 | + * get Attendee Address |
|
| 98 | + * |
|
| 99 | + * @access public |
|
| 100 | + * @return string |
|
| 101 | + */ |
|
| 102 | + public function value() |
|
| 103 | + { |
|
| 104 | + return $this->get('ANS_value'); |
|
| 105 | + } |
|
| 106 | + |
|
| 107 | + |
|
| 108 | + /** |
|
| 109 | + * Gets a pretty form of the value (mostly applies to answers that have multiple answers) |
|
| 110 | + * |
|
| 111 | + * @param null $schema |
|
| 112 | + * @return string |
|
| 113 | + */ |
|
| 114 | + public function pretty_value($schema = null) |
|
| 115 | + { |
|
| 116 | + return $this->get_pretty('ANS_value', $schema); |
|
| 117 | + } |
|
| 118 | + |
|
| 119 | + |
|
| 120 | + /** |
|
| 121 | + * Echoes out a pretty value (even for multi-choice options) |
|
| 122 | + * |
|
| 123 | + * @param string $schema |
|
| 124 | + */ |
|
| 125 | + public function e_value($schema = null) |
|
| 126 | + { |
|
| 127 | + $this->e('ANS_value', $schema); |
|
| 128 | + } |
|
| 129 | + |
|
| 130 | + |
|
| 131 | + /** |
|
| 132 | + * Gets the related EE_Question to this EE_Answer |
|
| 133 | + * |
|
| 134 | + * @return EE_Question |
|
| 135 | + */ |
|
| 136 | + public function question() |
|
| 137 | + { |
|
| 138 | + return $this->get_first_related('Question'); |
|
| 139 | + } |
|
| 140 | + |
|
| 141 | + |
|
| 142 | + /** |
|
| 143 | + * Gets the related EE_Registration to this EE_Answer |
|
| 144 | + * |
|
| 145 | + * @return EE_Registration |
|
| 146 | + */ |
|
| 147 | + public function registration() |
|
| 148 | + { |
|
| 149 | + return $this->get_first_related('Registration'); |
|
| 150 | + } |
|
| 151 | 151 | } |
| 152 | 152 | |
| 153 | 153 | /* End of file EE_Answer.class.php */ |
@@ -10,123 +10,123 @@ |
||
| 10 | 10 | class EE_Country extends EE_Base_Class |
| 11 | 11 | { |
| 12 | 12 | |
| 13 | - /** |
|
| 14 | - * @param array $props_n_values |
|
| 15 | - * @return EE_Country|mixed |
|
| 16 | - */ |
|
| 17 | - public static function new_instance($props_n_values = array()) |
|
| 18 | - { |
|
| 19 | - $has_object = parent::_check_for_object($props_n_values, __CLASS__); |
|
| 20 | - return $has_object ? $has_object : new self($props_n_values); |
|
| 21 | - } |
|
| 22 | - |
|
| 23 | - |
|
| 24 | - /** |
|
| 25 | - * @param array $props_n_values |
|
| 26 | - * @return EE_Country |
|
| 27 | - */ |
|
| 28 | - public static function new_instance_from_db($props_n_values = array()) |
|
| 29 | - { |
|
| 30 | - return new self($props_n_values, true); |
|
| 31 | - } |
|
| 32 | - |
|
| 33 | - |
|
| 34 | - /** |
|
| 35 | - * Gets the country name |
|
| 36 | - * |
|
| 37 | - * @return string |
|
| 38 | - */ |
|
| 39 | - public function name() |
|
| 40 | - { |
|
| 41 | - return $this->get('CNT_name'); |
|
| 42 | - } |
|
| 43 | - |
|
| 44 | - |
|
| 45 | - /** |
|
| 46 | - * gets the country's currency code |
|
| 47 | - * |
|
| 48 | - * @return string |
|
| 49 | - */ |
|
| 50 | - public function currency_code() |
|
| 51 | - { |
|
| 52 | - return $this->get('CNT_cur_code'); |
|
| 53 | - } |
|
| 54 | - |
|
| 55 | - |
|
| 56 | - /** |
|
| 57 | - * gets the country's currency sign/symbol |
|
| 58 | - * |
|
| 59 | - * @return string |
|
| 60 | - */ |
|
| 61 | - public function currency_sign() |
|
| 62 | - { |
|
| 63 | - $CNT_cur_sign = $this->get('CNT_cur_sign'); |
|
| 64 | - return $CNT_cur_sign ? $CNT_cur_sign : ''; |
|
| 65 | - } |
|
| 66 | - |
|
| 67 | - |
|
| 68 | - /** |
|
| 69 | - * Currency name singular |
|
| 70 | - * |
|
| 71 | - * @return string |
|
| 72 | - */ |
|
| 73 | - public function currency_name_single() |
|
| 74 | - { |
|
| 75 | - return $this->get('CNT_cur_single'); |
|
| 76 | - } |
|
| 77 | - |
|
| 78 | - |
|
| 79 | - /** |
|
| 80 | - * Currency name plural |
|
| 81 | - * |
|
| 82 | - * @return string |
|
| 83 | - */ |
|
| 84 | - public function currency_name_plural() |
|
| 85 | - { |
|
| 86 | - return $this->get('CNT_cur_plural'); |
|
| 87 | - } |
|
| 88 | - |
|
| 89 | - |
|
| 90 | - /** |
|
| 91 | - * currency_sign_before - ie: $TRUE or FALSE$ |
|
| 92 | - * |
|
| 93 | - * @return boolean |
|
| 94 | - */ |
|
| 95 | - public function currency_sign_before() |
|
| 96 | - { |
|
| 97 | - return $this->get('CNT_cur_sign_b4'); |
|
| 98 | - } |
|
| 99 | - |
|
| 100 | - |
|
| 101 | - /** |
|
| 102 | - * currency_decimal_places : 2 = 0.00 3 = 0.000 |
|
| 103 | - * |
|
| 104 | - * @return integer |
|
| 105 | - */ |
|
| 106 | - public function currency_decimal_places() |
|
| 107 | - { |
|
| 108 | - return $this->get('CNT_cur_dec_plc'); |
|
| 109 | - } |
|
| 110 | - |
|
| 111 | - |
|
| 112 | - /** |
|
| 113 | - * currency_decimal_mark : (comma) ',' = 0,01 or (decimal) '.' = 0.01 |
|
| 114 | - * |
|
| 115 | - * @return string |
|
| 116 | - */ |
|
| 117 | - public function currency_decimal_mark() |
|
| 118 | - { |
|
| 119 | - return $this->get('CNT_cur_dec_mrk'); |
|
| 120 | - } |
|
| 121 | - |
|
| 122 | - |
|
| 123 | - /** |
|
| 124 | - * currency thousands separator: (comma) ',' = 1,000 or (decimal) '.' = 1.000 |
|
| 125 | - * |
|
| 126 | - * @return string |
|
| 127 | - */ |
|
| 128 | - public function currency_thousands_separator() |
|
| 129 | - { |
|
| 130 | - return $this->get('CNT_cur_thsnds'); |
|
| 131 | - } |
|
| 13 | + /** |
|
| 14 | + * @param array $props_n_values |
|
| 15 | + * @return EE_Country|mixed |
|
| 16 | + */ |
|
| 17 | + public static function new_instance($props_n_values = array()) |
|
| 18 | + { |
|
| 19 | + $has_object = parent::_check_for_object($props_n_values, __CLASS__); |
|
| 20 | + return $has_object ? $has_object : new self($props_n_values); |
|
| 21 | + } |
|
| 22 | + |
|
| 23 | + |
|
| 24 | + /** |
|
| 25 | + * @param array $props_n_values |
|
| 26 | + * @return EE_Country |
|
| 27 | + */ |
|
| 28 | + public static function new_instance_from_db($props_n_values = array()) |
|
| 29 | + { |
|
| 30 | + return new self($props_n_values, true); |
|
| 31 | + } |
|
| 32 | + |
|
| 33 | + |
|
| 34 | + /** |
|
| 35 | + * Gets the country name |
|
| 36 | + * |
|
| 37 | + * @return string |
|
| 38 | + */ |
|
| 39 | + public function name() |
|
| 40 | + { |
|
| 41 | + return $this->get('CNT_name'); |
|
| 42 | + } |
|
| 43 | + |
|
| 44 | + |
|
| 45 | + /** |
|
| 46 | + * gets the country's currency code |
|
| 47 | + * |
|
| 48 | + * @return string |
|
| 49 | + */ |
|
| 50 | + public function currency_code() |
|
| 51 | + { |
|
| 52 | + return $this->get('CNT_cur_code'); |
|
| 53 | + } |
|
| 54 | + |
|
| 55 | + |
|
| 56 | + /** |
|
| 57 | + * gets the country's currency sign/symbol |
|
| 58 | + * |
|
| 59 | + * @return string |
|
| 60 | + */ |
|
| 61 | + public function currency_sign() |
|
| 62 | + { |
|
| 63 | + $CNT_cur_sign = $this->get('CNT_cur_sign'); |
|
| 64 | + return $CNT_cur_sign ? $CNT_cur_sign : ''; |
|
| 65 | + } |
|
| 66 | + |
|
| 67 | + |
|
| 68 | + /** |
|
| 69 | + * Currency name singular |
|
| 70 | + * |
|
| 71 | + * @return string |
|
| 72 | + */ |
|
| 73 | + public function currency_name_single() |
|
| 74 | + { |
|
| 75 | + return $this->get('CNT_cur_single'); |
|
| 76 | + } |
|
| 77 | + |
|
| 78 | + |
|
| 79 | + /** |
|
| 80 | + * Currency name plural |
|
| 81 | + * |
|
| 82 | + * @return string |
|
| 83 | + */ |
|
| 84 | + public function currency_name_plural() |
|
| 85 | + { |
|
| 86 | + return $this->get('CNT_cur_plural'); |
|
| 87 | + } |
|
| 88 | + |
|
| 89 | + |
|
| 90 | + /** |
|
| 91 | + * currency_sign_before - ie: $TRUE or FALSE$ |
|
| 92 | + * |
|
| 93 | + * @return boolean |
|
| 94 | + */ |
|
| 95 | + public function currency_sign_before() |
|
| 96 | + { |
|
| 97 | + return $this->get('CNT_cur_sign_b4'); |
|
| 98 | + } |
|
| 99 | + |
|
| 100 | + |
|
| 101 | + /** |
|
| 102 | + * currency_decimal_places : 2 = 0.00 3 = 0.000 |
|
| 103 | + * |
|
| 104 | + * @return integer |
|
| 105 | + */ |
|
| 106 | + public function currency_decimal_places() |
|
| 107 | + { |
|
| 108 | + return $this->get('CNT_cur_dec_plc'); |
|
| 109 | + } |
|
| 110 | + |
|
| 111 | + |
|
| 112 | + /** |
|
| 113 | + * currency_decimal_mark : (comma) ',' = 0,01 or (decimal) '.' = 0.01 |
|
| 114 | + * |
|
| 115 | + * @return string |
|
| 116 | + */ |
|
| 117 | + public function currency_decimal_mark() |
|
| 118 | + { |
|
| 119 | + return $this->get('CNT_cur_dec_mrk'); |
|
| 120 | + } |
|
| 121 | + |
|
| 122 | + |
|
| 123 | + /** |
|
| 124 | + * currency thousands separator: (comma) ',' = 1,000 or (decimal) '.' = 1.000 |
|
| 125 | + * |
|
| 126 | + * @return string |
|
| 127 | + */ |
|
| 128 | + public function currency_thousands_separator() |
|
| 129 | + { |
|
| 130 | + return $this->get('CNT_cur_thsnds'); |
|
| 131 | + } |
|
| 132 | 132 | } |
@@ -12,25 +12,25 @@ |
||
| 12 | 12 | class EE_Extra_Join extends EE_Base_Class |
| 13 | 13 | { |
| 14 | 14 | |
| 15 | - /** |
|
| 16 | - * @param array $props_n_values |
|
| 17 | - * @param null $timezone |
|
| 18 | - * @return EE_Extra_Join|mixed |
|
| 19 | - */ |
|
| 20 | - public static function new_instance($props_n_values = array(), $timezone = null) |
|
| 21 | - { |
|
| 22 | - $has_object = parent::_check_for_object($props_n_values, __CLASS__, $timezone); |
|
| 23 | - return $has_object ? $has_object : new self($props_n_values, false, $timezone); |
|
| 24 | - } |
|
| 15 | + /** |
|
| 16 | + * @param array $props_n_values |
|
| 17 | + * @param null $timezone |
|
| 18 | + * @return EE_Extra_Join|mixed |
|
| 19 | + */ |
|
| 20 | + public static function new_instance($props_n_values = array(), $timezone = null) |
|
| 21 | + { |
|
| 22 | + $has_object = parent::_check_for_object($props_n_values, __CLASS__, $timezone); |
|
| 23 | + return $has_object ? $has_object : new self($props_n_values, false, $timezone); |
|
| 24 | + } |
|
| 25 | 25 | |
| 26 | 26 | |
| 27 | - /** |
|
| 28 | - * @param array $props_n_values |
|
| 29 | - * @param null $timezone |
|
| 30 | - * @return EE_Extra_Join |
|
| 31 | - */ |
|
| 32 | - public static function new_instance_from_db($props_n_values = array(), $timezone = null) |
|
| 33 | - { |
|
| 34 | - return new self($props_n_values, true, $timezone); |
|
| 35 | - } |
|
| 27 | + /** |
|
| 28 | + * @param array $props_n_values |
|
| 29 | + * @param null $timezone |
|
| 30 | + * @return EE_Extra_Join |
|
| 31 | + */ |
|
| 32 | + public static function new_instance_from_db($props_n_values = array(), $timezone = null) |
|
| 33 | + { |
|
| 34 | + return new self($props_n_values, true, $timezone); |
|
| 35 | + } |
|
| 36 | 36 | } |
@@ -10,163 +10,163 @@ |
||
| 10 | 10 | class EE_Price_Type extends EE_Soft_Delete_Base_Class |
| 11 | 11 | { |
| 12 | 12 | |
| 13 | - /** |
|
| 14 | - * @param array $props_n_values |
|
| 15 | - * @return EE_Price_Type |
|
| 16 | - */ |
|
| 17 | - public static function new_instance($props_n_values = array()) |
|
| 18 | - { |
|
| 19 | - $has_object = parent::_check_for_object($props_n_values, __CLASS__); |
|
| 20 | - return $has_object ? $has_object : new self($props_n_values); |
|
| 21 | - } |
|
| 22 | - |
|
| 23 | - |
|
| 24 | - /** |
|
| 25 | - * @param array $props_n_values |
|
| 26 | - * @return EE_Price_Type |
|
| 27 | - */ |
|
| 28 | - public static function new_instance_from_db($props_n_values = array()) |
|
| 29 | - { |
|
| 30 | - return new self($props_n_values, true); |
|
| 31 | - } |
|
| 32 | - |
|
| 33 | - |
|
| 34 | - /** |
|
| 35 | - * Set Price Type Name |
|
| 36 | - * |
|
| 37 | - * @access public |
|
| 38 | - * @param string $PRT_name |
|
| 39 | - */ |
|
| 40 | - public function set_name($PRT_name = '') |
|
| 41 | - { |
|
| 42 | - $this->set('PRT_name', $PRT_name); |
|
| 43 | - } |
|
| 44 | - |
|
| 45 | - |
|
| 46 | - /** |
|
| 47 | - * Set Price Type a percent |
|
| 48 | - * |
|
| 49 | - * @access public |
|
| 50 | - * @param bool $PRT_is_percent |
|
| 51 | - */ |
|
| 52 | - public function set_is_percent($PRT_is_percent = false) |
|
| 53 | - { |
|
| 54 | - $this->set('PRT_is_percent', $PRT_is_percent); |
|
| 55 | - } |
|
| 56 | - |
|
| 57 | - |
|
| 58 | - /** |
|
| 59 | - * Set Price Type order |
|
| 60 | - * |
|
| 61 | - * @access public |
|
| 62 | - * @param int $PRT_order |
|
| 63 | - */ |
|
| 64 | - public function set_order($PRT_order = 0) |
|
| 65 | - { |
|
| 66 | - $this->set('PRT_order', $PRT_order); |
|
| 67 | - } |
|
| 68 | - |
|
| 69 | - |
|
| 70 | - /** |
|
| 71 | - * |
|
| 72 | - */ |
|
| 73 | - public function move_to_trash() |
|
| 74 | - { |
|
| 75 | - $this->set('PRT_deleted', true); |
|
| 76 | - } |
|
| 77 | - |
|
| 78 | - |
|
| 79 | - /** |
|
| 80 | - * |
|
| 81 | - */ |
|
| 82 | - public function restore_from_trash() |
|
| 83 | - { |
|
| 84 | - $this->set('PRT_deleted', false); |
|
| 85 | - } |
|
| 86 | - |
|
| 87 | - |
|
| 88 | - /** |
|
| 89 | - * get Price Type Name |
|
| 90 | - * |
|
| 91 | - * @access public |
|
| 92 | - */ |
|
| 93 | - public function name() |
|
| 94 | - { |
|
| 95 | - return $this->get('PRT_name'); |
|
| 96 | - } |
|
| 97 | - |
|
| 98 | - |
|
| 99 | - /** |
|
| 100 | - * get is Price Type a discount? |
|
| 101 | - * |
|
| 102 | - * @access public |
|
| 103 | - */ |
|
| 104 | - public function base_type() |
|
| 105 | - { |
|
| 106 | - return $this->get('PBT_ID'); |
|
| 107 | - } |
|
| 108 | - |
|
| 109 | - |
|
| 110 | - /** |
|
| 111 | - * @return mixed |
|
| 112 | - */ |
|
| 113 | - public function base_type_name() |
|
| 114 | - { |
|
| 115 | - return $this->get_pretty('PBT_ID'); |
|
| 116 | - } |
|
| 117 | - |
|
| 118 | - |
|
| 119 | - /** |
|
| 120 | - * get is Price Type a percent? |
|
| 121 | - * |
|
| 122 | - * @access public |
|
| 123 | - */ |
|
| 124 | - public function is_percent() |
|
| 125 | - { |
|
| 126 | - return $this->get('PRT_is_percent'); |
|
| 127 | - } |
|
| 128 | - |
|
| 129 | - |
|
| 130 | - /** |
|
| 131 | - * @return bool |
|
| 132 | - */ |
|
| 133 | - public function is_discount() |
|
| 134 | - { |
|
| 135 | - return $this->get('PBT_ID') == 2 ? true : false; |
|
| 136 | - } |
|
| 137 | - |
|
| 138 | - |
|
| 139 | - /** |
|
| 140 | - * get the author of the price type. |
|
| 141 | - * |
|
| 142 | - * @since 4.5.0 |
|
| 143 | - * |
|
| 144 | - * @return int |
|
| 145 | - */ |
|
| 146 | - public function wp_user() |
|
| 147 | - { |
|
| 148 | - return $this->get('PRT_wp_user'); |
|
| 149 | - } |
|
| 150 | - |
|
| 151 | - |
|
| 152 | - /** |
|
| 153 | - * get Price Type order |
|
| 154 | - * |
|
| 155 | - * @access public |
|
| 156 | - */ |
|
| 157 | - public function order() |
|
| 158 | - { |
|
| 159 | - return $this->get('PRT_order'); |
|
| 160 | - } |
|
| 161 | - |
|
| 162 | - |
|
| 163 | - /** |
|
| 164 | - * get is Price Type deleted ? |
|
| 165 | - * |
|
| 166 | - * @access public |
|
| 167 | - */ |
|
| 168 | - public function deleted() |
|
| 169 | - { |
|
| 170 | - return $this->get('PRT_deleted'); |
|
| 171 | - } |
|
| 13 | + /** |
|
| 14 | + * @param array $props_n_values |
|
| 15 | + * @return EE_Price_Type |
|
| 16 | + */ |
|
| 17 | + public static function new_instance($props_n_values = array()) |
|
| 18 | + { |
|
| 19 | + $has_object = parent::_check_for_object($props_n_values, __CLASS__); |
|
| 20 | + return $has_object ? $has_object : new self($props_n_values); |
|
| 21 | + } |
|
| 22 | + |
|
| 23 | + |
|
| 24 | + /** |
|
| 25 | + * @param array $props_n_values |
|
| 26 | + * @return EE_Price_Type |
|
| 27 | + */ |
|
| 28 | + public static function new_instance_from_db($props_n_values = array()) |
|
| 29 | + { |
|
| 30 | + return new self($props_n_values, true); |
|
| 31 | + } |
|
| 32 | + |
|
| 33 | + |
|
| 34 | + /** |
|
| 35 | + * Set Price Type Name |
|
| 36 | + * |
|
| 37 | + * @access public |
|
| 38 | + * @param string $PRT_name |
|
| 39 | + */ |
|
| 40 | + public function set_name($PRT_name = '') |
|
| 41 | + { |
|
| 42 | + $this->set('PRT_name', $PRT_name); |
|
| 43 | + } |
|
| 44 | + |
|
| 45 | + |
|
| 46 | + /** |
|
| 47 | + * Set Price Type a percent |
|
| 48 | + * |
|
| 49 | + * @access public |
|
| 50 | + * @param bool $PRT_is_percent |
|
| 51 | + */ |
|
| 52 | + public function set_is_percent($PRT_is_percent = false) |
|
| 53 | + { |
|
| 54 | + $this->set('PRT_is_percent', $PRT_is_percent); |
|
| 55 | + } |
|
| 56 | + |
|
| 57 | + |
|
| 58 | + /** |
|
| 59 | + * Set Price Type order |
|
| 60 | + * |
|
| 61 | + * @access public |
|
| 62 | + * @param int $PRT_order |
|
| 63 | + */ |
|
| 64 | + public function set_order($PRT_order = 0) |
|
| 65 | + { |
|
| 66 | + $this->set('PRT_order', $PRT_order); |
|
| 67 | + } |
|
| 68 | + |
|
| 69 | + |
|
| 70 | + /** |
|
| 71 | + * |
|
| 72 | + */ |
|
| 73 | + public function move_to_trash() |
|
| 74 | + { |
|
| 75 | + $this->set('PRT_deleted', true); |
|
| 76 | + } |
|
| 77 | + |
|
| 78 | + |
|
| 79 | + /** |
|
| 80 | + * |
|
| 81 | + */ |
|
| 82 | + public function restore_from_trash() |
|
| 83 | + { |
|
| 84 | + $this->set('PRT_deleted', false); |
|
| 85 | + } |
|
| 86 | + |
|
| 87 | + |
|
| 88 | + /** |
|
| 89 | + * get Price Type Name |
|
| 90 | + * |
|
| 91 | + * @access public |
|
| 92 | + */ |
|
| 93 | + public function name() |
|
| 94 | + { |
|
| 95 | + return $this->get('PRT_name'); |
|
| 96 | + } |
|
| 97 | + |
|
| 98 | + |
|
| 99 | + /** |
|
| 100 | + * get is Price Type a discount? |
|
| 101 | + * |
|
| 102 | + * @access public |
|
| 103 | + */ |
|
| 104 | + public function base_type() |
|
| 105 | + { |
|
| 106 | + return $this->get('PBT_ID'); |
|
| 107 | + } |
|
| 108 | + |
|
| 109 | + |
|
| 110 | + /** |
|
| 111 | + * @return mixed |
|
| 112 | + */ |
|
| 113 | + public function base_type_name() |
|
| 114 | + { |
|
| 115 | + return $this->get_pretty('PBT_ID'); |
|
| 116 | + } |
|
| 117 | + |
|
| 118 | + |
|
| 119 | + /** |
|
| 120 | + * get is Price Type a percent? |
|
| 121 | + * |
|
| 122 | + * @access public |
|
| 123 | + */ |
|
| 124 | + public function is_percent() |
|
| 125 | + { |
|
| 126 | + return $this->get('PRT_is_percent'); |
|
| 127 | + } |
|
| 128 | + |
|
| 129 | + |
|
| 130 | + /** |
|
| 131 | + * @return bool |
|
| 132 | + */ |
|
| 133 | + public function is_discount() |
|
| 134 | + { |
|
| 135 | + return $this->get('PBT_ID') == 2 ? true : false; |
|
| 136 | + } |
|
| 137 | + |
|
| 138 | + |
|
| 139 | + /** |
|
| 140 | + * get the author of the price type. |
|
| 141 | + * |
|
| 142 | + * @since 4.5.0 |
|
| 143 | + * |
|
| 144 | + * @return int |
|
| 145 | + */ |
|
| 146 | + public function wp_user() |
|
| 147 | + { |
|
| 148 | + return $this->get('PRT_wp_user'); |
|
| 149 | + } |
|
| 150 | + |
|
| 151 | + |
|
| 152 | + /** |
|
| 153 | + * get Price Type order |
|
| 154 | + * |
|
| 155 | + * @access public |
|
| 156 | + */ |
|
| 157 | + public function order() |
|
| 158 | + { |
|
| 159 | + return $this->get('PRT_order'); |
|
| 160 | + } |
|
| 161 | + |
|
| 162 | + |
|
| 163 | + /** |
|
| 164 | + * get is Price Type deleted ? |
|
| 165 | + * |
|
| 166 | + * @access public |
|
| 167 | + */ |
|
| 168 | + public function deleted() |
|
| 169 | + { |
|
| 170 | + return $this->get('PRT_deleted'); |
|
| 171 | + } |
|
| 172 | 172 | } |
@@ -14,40 +14,40 @@ |
||
| 14 | 14 | class EE_Currency_Payment_Method extends EE_Base_Class |
| 15 | 15 | { |
| 16 | 16 | |
| 17 | - /** Currency to Payment Method Link ID @var CPM_ID */ |
|
| 18 | - protected $_CPM_ID = null; |
|
| 19 | - /** Currency Code @var CUR_code */ |
|
| 20 | - protected $_CUR_code = null; |
|
| 21 | - /** Payment Method ID @var PMD_ID */ |
|
| 22 | - protected $_PMD_ID = null; |
|
| 23 | - protected $_Payment_Method; |
|
| 24 | - protected $_Currency; |
|
| 17 | + /** Currency to Payment Method Link ID @var CPM_ID */ |
|
| 18 | + protected $_CPM_ID = null; |
|
| 19 | + /** Currency Code @var CUR_code */ |
|
| 20 | + protected $_CUR_code = null; |
|
| 21 | + /** Payment Method ID @var PMD_ID */ |
|
| 22 | + protected $_PMD_ID = null; |
|
| 23 | + protected $_Payment_Method; |
|
| 24 | + protected $_Currency; |
|
| 25 | 25 | |
| 26 | 26 | |
| 27 | - /** |
|
| 28 | - * |
|
| 29 | - * @param array $props_n_values incoming values |
|
| 30 | - * @param string $timezone incoming timezone (if not set the timezone set for the website will be |
|
| 31 | - * used.) |
|
| 32 | - * @param array $date_formats incoming date_formats in an array where the first value is the |
|
| 33 | - * date_format and the second value is the time format |
|
| 34 | - * @return EE_Attendee |
|
| 35 | - */ |
|
| 36 | - public static function new_instance($props_n_values = array(), $timezone = null, $date_formats = array()) |
|
| 37 | - { |
|
| 38 | - $has_object = parent::_check_for_object($props_n_values, __CLASS__, $timezone, $date_formats); |
|
| 39 | - return $has_object ? $has_object : new self($props_n_values, false, $timezone, $date_formats); |
|
| 40 | - } |
|
| 27 | + /** |
|
| 28 | + * |
|
| 29 | + * @param array $props_n_values incoming values |
|
| 30 | + * @param string $timezone incoming timezone (if not set the timezone set for the website will be |
|
| 31 | + * used.) |
|
| 32 | + * @param array $date_formats incoming date_formats in an array where the first value is the |
|
| 33 | + * date_format and the second value is the time format |
|
| 34 | + * @return EE_Attendee |
|
| 35 | + */ |
|
| 36 | + public static function new_instance($props_n_values = array(), $timezone = null, $date_formats = array()) |
|
| 37 | + { |
|
| 38 | + $has_object = parent::_check_for_object($props_n_values, __CLASS__, $timezone, $date_formats); |
|
| 39 | + return $has_object ? $has_object : new self($props_n_values, false, $timezone, $date_formats); |
|
| 40 | + } |
|
| 41 | 41 | |
| 42 | 42 | |
| 43 | - /** |
|
| 44 | - * @param array $props_n_values incoming values from the database |
|
| 45 | - * @param string $timezone incoming timezone as set by the model. If not set the timezone for |
|
| 46 | - * the website will be used. |
|
| 47 | - * @return EE_Attendee |
|
| 48 | - */ |
|
| 49 | - public static function new_instance_from_db($props_n_values = array(), $timezone = null) |
|
| 50 | - { |
|
| 51 | - return new self($props_n_values, true, $timezone); |
|
| 52 | - } |
|
| 43 | + /** |
|
| 44 | + * @param array $props_n_values incoming values from the database |
|
| 45 | + * @param string $timezone incoming timezone as set by the model. If not set the timezone for |
|
| 46 | + * the website will be used. |
|
| 47 | + * @return EE_Attendee |
|
| 48 | + */ |
|
| 49 | + public static function new_instance_from_db($props_n_values = array(), $timezone = null) |
|
| 50 | + { |
|
| 51 | + return new self($props_n_values, true, $timezone); |
|
| 52 | + } |
|
| 53 | 53 | } |