@@ -1,7 +1,6 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | namespace EventEspresso\Codeception\helpers; |
| 3 | 3 | |
| 4 | -use Page\CoreAdmin; |
|
| 5 | 4 | use Page\CountrySettingsAdmin as CountrySettings; |
| 6 | 5 | |
| 7 | 6 | trait CountrySettingsAdmin |
@@ -6,59 +6,59 @@ |
||
| 6 | 6 | |
| 7 | 7 | trait CountrySettingsAdmin |
| 8 | 8 | { |
| 9 | - /** |
|
| 10 | - * Instructs the actor to browse to the country settings page. |
|
| 11 | - * Assumes the actor is already logged in. |
|
| 12 | - * @param string $additional_params |
|
| 13 | - */ |
|
| 14 | - public function amOnCountrySettingsAdminPage($additional_params = '') |
|
| 15 | - { |
|
| 16 | - $this->actor()->amOnAdminPage(CountrySettings::url($additional_params)); |
|
| 17 | - } |
|
| 9 | + /** |
|
| 10 | + * Instructs the actor to browse to the country settings page. |
|
| 11 | + * Assumes the actor is already logged in. |
|
| 12 | + * @param string $additional_params |
|
| 13 | + */ |
|
| 14 | + public function amOnCountrySettingsAdminPage($additional_params = '') |
|
| 15 | + { |
|
| 16 | + $this->actor()->amOnAdminPage(CountrySettings::url($additional_params)); |
|
| 17 | + } |
|
| 18 | 18 | |
| 19 | 19 | |
| 20 | - /** |
|
| 21 | - * Instructs the actor to select the given decimal places radio option. |
|
| 22 | - * Assumes the actor is already on the country settings page. |
|
| 23 | - * @param string $decimal_places |
|
| 24 | - * @param string $country_code |
|
| 25 | - */ |
|
| 26 | - public function setCurrencyDecimalPlacesTo($decimal_places = '2', $country_code = 'US') |
|
| 27 | - { |
|
| 28 | - $this->actor()->click(CountrySettings::currencyDecimalPlacesRadioField($decimal_places, $country_code)); |
|
| 29 | - } |
|
| 20 | + /** |
|
| 21 | + * Instructs the actor to select the given decimal places radio option. |
|
| 22 | + * Assumes the actor is already on the country settings page. |
|
| 23 | + * @param string $decimal_places |
|
| 24 | + * @param string $country_code |
|
| 25 | + */ |
|
| 26 | + public function setCurrencyDecimalPlacesTo($decimal_places = '2', $country_code = 'US') |
|
| 27 | + { |
|
| 28 | + $this->actor()->click(CountrySettings::currencyDecimalPlacesRadioField($decimal_places, $country_code)); |
|
| 29 | + } |
|
| 30 | 30 | |
| 31 | 31 | |
| 32 | - /** |
|
| 33 | - * Instructs the actor to select the given decimal mark radio option. |
|
| 34 | - * Assumes the actor is already on the country settings page. |
|
| 35 | - * @param string $decimal_mark |
|
| 36 | - */ |
|
| 37 | - public function setCurrencyDecimalMarkTo($decimal_mark = '.') |
|
| 38 | - { |
|
| 39 | - $this->actor()->click(CountrySettings::currencyDecimalMarkRadioField($decimal_mark)); |
|
| 40 | - } |
|
| 32 | + /** |
|
| 33 | + * Instructs the actor to select the given decimal mark radio option. |
|
| 34 | + * Assumes the actor is already on the country settings page. |
|
| 35 | + * @param string $decimal_mark |
|
| 36 | + */ |
|
| 37 | + public function setCurrencyDecimalMarkTo($decimal_mark = '.') |
|
| 38 | + { |
|
| 39 | + $this->actor()->click(CountrySettings::currencyDecimalMarkRadioField($decimal_mark)); |
|
| 40 | + } |
|
| 41 | 41 | |
| 42 | 42 | |
| 43 | - /** |
|
| 44 | - * Instructs the actor to select the given thousands separator radio option. |
|
| 45 | - * Assumes the actor is already on the country settings page. |
|
| 46 | - * @param string $thousands_seperator |
|
| 47 | - */ |
|
| 48 | - public function setCurrencyThousandsSeparatorTo($thousands_seperator = ',') |
|
| 49 | - { |
|
| 50 | - $this->actor()->click(CountrySettings::currencyThousandsSeparatorField($thousands_seperator)); |
|
| 51 | - } |
|
| 43 | + /** |
|
| 44 | + * Instructs the actor to select the given thousands separator radio option. |
|
| 45 | + * Assumes the actor is already on the country settings page. |
|
| 46 | + * @param string $thousands_seperator |
|
| 47 | + */ |
|
| 48 | + public function setCurrencyThousandsSeparatorTo($thousands_seperator = ',') |
|
| 49 | + { |
|
| 50 | + $this->actor()->click(CountrySettings::currencyThousandsSeparatorField($thousands_seperator)); |
|
| 51 | + } |
|
| 52 | 52 | |
| 53 | 53 | |
| 54 | - /** |
|
| 55 | - * Clicks the country settings submit button. |
|
| 56 | - * Assumes the actor is on the country settings admin page. |
|
| 57 | - */ |
|
| 58 | - public function saveCountrySettings() |
|
| 59 | - { |
|
| 60 | - $this->actor()->click(CountrySettings::COUNTRY_SETTINGS_SAVE_BUTTON); |
|
| 61 | - //no indicator on the page when stuff has been updated so just give a bit of time for it to finish. |
|
| 62 | - $this->actor()->wait(10); |
|
| 63 | - } |
|
| 54 | + /** |
|
| 55 | + * Clicks the country settings submit button. |
|
| 56 | + * Assumes the actor is on the country settings admin page. |
|
| 57 | + */ |
|
| 58 | + public function saveCountrySettings() |
|
| 59 | + { |
|
| 60 | + $this->actor()->click(CountrySettings::COUNTRY_SETTINGS_SAVE_BUTTON); |
|
| 61 | + //no indicator on the page when stuff has been updated so just give a bit of time for it to finish. |
|
| 62 | + $this->actor()->wait(10); |
|
| 63 | + } |
|
| 64 | 64 | } |
| 65 | 65 | \ No newline at end of file |
@@ -14,51 +14,51 @@ |
||
| 14 | 14 | { |
| 15 | 15 | |
| 16 | 16 | |
| 17 | - const COUNTRY_SETTINGS_SAVE_BUTTON = '#country_settings_save_2'; |
|
| 17 | + const COUNTRY_SETTINGS_SAVE_BUTTON = '#country_settings_save_2'; |
|
| 18 | 18 | |
| 19 | 19 | |
| 20 | 20 | |
| 21 | - /** |
|
| 22 | - * Return the url for the country settings admin page. |
|
| 23 | - * @param string $additional_params |
|
| 24 | - * @return string |
|
| 25 | - */ |
|
| 26 | - public static function url($additional_params = '') |
|
| 27 | - { |
|
| 28 | - return self::adminUrl('espresso_general_settings', 'country_settings', $additional_params); |
|
| 29 | - } |
|
| 21 | + /** |
|
| 22 | + * Return the url for the country settings admin page. |
|
| 23 | + * @param string $additional_params |
|
| 24 | + * @return string |
|
| 25 | + */ |
|
| 26 | + public static function url($additional_params = '') |
|
| 27 | + { |
|
| 28 | + return self::adminUrl('espresso_general_settings', 'country_settings', $additional_params); |
|
| 29 | + } |
|
| 30 | 30 | |
| 31 | 31 | |
| 32 | - /** |
|
| 33 | - * Return the decimal places (precision) radio field locator for selection. |
|
| 34 | - * @param int $decimal_place_value |
|
| 35 | - * @param string $country_code |
|
| 36 | - * @return string |
|
| 37 | - */ |
|
| 38 | - public static function currencyDecimalPlacesRadioField($decimal_place_value = 2, $country_code = 'US') |
|
| 39 | - { |
|
| 40 | - return "//input[@id='CNT_cur_dec_plc-$country_code-$decimal_place_value']"; |
|
| 41 | - } |
|
| 32 | + /** |
|
| 33 | + * Return the decimal places (precision) radio field locator for selection. |
|
| 34 | + * @param int $decimal_place_value |
|
| 35 | + * @param string $country_code |
|
| 36 | + * @return string |
|
| 37 | + */ |
|
| 38 | + public static function currencyDecimalPlacesRadioField($decimal_place_value = 2, $country_code = 'US') |
|
| 39 | + { |
|
| 40 | + return "//input[@id='CNT_cur_dec_plc-$country_code-$decimal_place_value']"; |
|
| 41 | + } |
|
| 42 | 42 | |
| 43 | 43 | |
| 44 | - /** |
|
| 45 | - * Return the currency decimal mark field locator for selection. |
|
| 46 | - * @param string $decimal_mark |
|
| 47 | - * @return string |
|
| 48 | - */ |
|
| 49 | - public static function currencyDecimalMarkRadioField($decimal_mark = '.') |
|
| 50 | - { |
|
| 51 | - return "//input[@class='CNT_cur_dec_mrk' and @value='$decimal_mark']"; |
|
| 52 | - } |
|
| 44 | + /** |
|
| 45 | + * Return the currency decimal mark field locator for selection. |
|
| 46 | + * @param string $decimal_mark |
|
| 47 | + * @return string |
|
| 48 | + */ |
|
| 49 | + public static function currencyDecimalMarkRadioField($decimal_mark = '.') |
|
| 50 | + { |
|
| 51 | + return "//input[@class='CNT_cur_dec_mrk' and @value='$decimal_mark']"; |
|
| 52 | + } |
|
| 53 | 53 | |
| 54 | 54 | |
| 55 | - /** |
|
| 56 | - * Return the currency thousands separator field locator for selection. |
|
| 57 | - * @param string $thousands_separator |
|
| 58 | - * @return string |
|
| 59 | - */ |
|
| 60 | - public static function currencyThousandsSeparatorField($thousands_separator = ',') |
|
| 61 | - { |
|
| 62 | - return "//input[@class='CNT_cur_thsnds' and @value='$thousands_separator']"; |
|
| 63 | - } |
|
| 55 | + /** |
|
| 56 | + * Return the currency thousands separator field locator for selection. |
|
| 57 | + * @param string $thousands_separator |
|
| 58 | + * @return string |
|
| 59 | + */ |
|
| 60 | + public static function currencyThousandsSeparatorField($thousands_separator = ',') |
|
| 61 | + { |
|
| 62 | + return "//input[@class='CNT_cur_thsnds' and @value='$thousands_separator']"; |
|
| 63 | + } |
|
| 64 | 64 | } |
| 65 | 65 | \ No newline at end of file |
@@ -16,38 +16,38 @@ |
||
| 16 | 16 | { |
| 17 | 17 | |
| 18 | 18 | |
| 19 | - /** |
|
| 20 | - * @param string $table_column |
|
| 21 | - * @param string $nice_name |
|
| 22 | - * @param bool $nullable |
|
| 23 | - * @param null $default_value |
|
| 24 | - * @throws InvalidArgumentException |
|
| 25 | - */ |
|
| 26 | - public function __construct($table_column, $nice_name, $nullable, $default_value = null) |
|
| 27 | - { |
|
| 28 | - parent::__construct($table_column, $nice_name, $nullable, $default_value); |
|
| 29 | - $this->setSchemaFormat('email'); |
|
| 30 | - } |
|
| 19 | + /** |
|
| 20 | + * @param string $table_column |
|
| 21 | + * @param string $nice_name |
|
| 22 | + * @param bool $nullable |
|
| 23 | + * @param null $default_value |
|
| 24 | + * @throws InvalidArgumentException |
|
| 25 | + */ |
|
| 26 | + public function __construct($table_column, $nice_name, $nullable, $default_value = null) |
|
| 27 | + { |
|
| 28 | + parent::__construct($table_column, $nice_name, $nullable, $default_value); |
|
| 29 | + $this->setSchemaFormat('email'); |
|
| 30 | + } |
|
| 31 | 31 | |
| 32 | 32 | |
| 33 | 33 | |
| 34 | - /** |
|
| 35 | - * In form inputs, we should have called htmlentities and addslashes() on form inputs, |
|
| 36 | - * so we need to undo that on setting of these fields |
|
| 37 | - * |
|
| 38 | - * @param string $email_address |
|
| 39 | - * @return string |
|
| 40 | - * @throws InvalidArgumentException |
|
| 41 | - * @throws InvalidInterfaceException |
|
| 42 | - * @throws InvalidDataTypeException |
|
| 43 | - */ |
|
| 44 | - public function prepare_for_set($email_address) |
|
| 45 | - { |
|
| 46 | - try { |
|
| 47 | - $email_address = EmailAddressFactory::create($email_address); |
|
| 48 | - return $email_address->get(); |
|
| 49 | - } catch (EmailValidationException $e) { |
|
| 50 | - return ''; |
|
| 51 | - } |
|
| 52 | - } |
|
| 34 | + /** |
|
| 35 | + * In form inputs, we should have called htmlentities and addslashes() on form inputs, |
|
| 36 | + * so we need to undo that on setting of these fields |
|
| 37 | + * |
|
| 38 | + * @param string $email_address |
|
| 39 | + * @return string |
|
| 40 | + * @throws InvalidArgumentException |
|
| 41 | + * @throws InvalidInterfaceException |
|
| 42 | + * @throws InvalidDataTypeException |
|
| 43 | + */ |
|
| 44 | + public function prepare_for_set($email_address) |
|
| 45 | + { |
|
| 46 | + try { |
|
| 47 | + $email_address = EmailAddressFactory::create($email_address); |
|
| 48 | + return $email_address->get(); |
|
| 49 | + } catch (EmailValidationException $e) { |
|
| 50 | + return ''; |
|
| 51 | + } |
|
| 52 | + } |
|
| 53 | 53 | } |
@@ -15,11 +15,11 @@ |
||
| 15 | 15 | interface FactoryInterface |
| 16 | 16 | { |
| 17 | 17 | |
| 18 | - /** |
|
| 19 | - * @param mixed $arguments |
|
| 20 | - * @return mixed |
|
| 21 | - */ |
|
| 22 | - public static function create($arguments); |
|
| 18 | + /** |
|
| 19 | + * @param mixed $arguments |
|
| 20 | + * @return mixed |
|
| 21 | + */ |
|
| 22 | + public static function create($arguments); |
|
| 23 | 23 | |
| 24 | 24 | |
| 25 | 25 | } |
@@ -34,7 +34,7 @@ discard block |
||
| 34 | 34 | $email_address, |
| 35 | 35 | $this->getAtIndex($email_address) |
| 36 | 36 | ); |
| 37 | - if (! checkdnsrr($domain, 'MX')) { |
|
| 37 | + if ( ! checkdnsrr($domain, 'MX')) { |
|
| 38 | 38 | // domain not found in MX records |
| 39 | 39 | throw new EmailValidationException( |
| 40 | 40 | __( |
@@ -45,7 +45,7 @@ discard block |
||
| 45 | 45 | ) |
| 46 | 46 | ); |
| 47 | 47 | } |
| 48 | - if (! checkdnsrr($domain, 'A')) { |
|
| 48 | + if ( ! checkdnsrr($domain, 'A')) { |
|
| 49 | 49 | // domain not found in A records |
| 50 | 50 | throw new EmailValidationException( |
| 51 | 51 | __( |
@@ -15,43 +15,43 @@ |
||
| 15 | 15 | class InternationalDNS extends International |
| 16 | 16 | { |
| 17 | 17 | |
| 18 | - /** |
|
| 19 | - * Validates the email in teh same way as the parent, but also |
|
| 20 | - * verifies the domain exists. |
|
| 21 | - * |
|
| 22 | - * @param string $email_address |
|
| 23 | - * @return bool |
|
| 24 | - * @throws EmailValidationException |
|
| 25 | - */ |
|
| 26 | - public function validate($email_address) |
|
| 27 | - { |
|
| 28 | - parent::validate($email_address); |
|
| 29 | - $domain = $this->getDomainPartOfEmail( |
|
| 30 | - $email_address, |
|
| 31 | - $this->getAtIndex($email_address) |
|
| 32 | - ); |
|
| 33 | - if (! checkdnsrr($domain, 'MX')) { |
|
| 34 | - // domain not found in MX records |
|
| 35 | - throw new EmailValidationException( |
|
| 36 | - __( |
|
| 37 | - // @codingStandardsIgnoreStart |
|
| 38 | - 'Although the email address provided is formatted correctly, a valid "MX record" could not be located for that address and domain. Please enter a valid email address.', |
|
| 39 | - // @codingStandardsIgnoreEnd |
|
| 40 | - 'event_espresso' |
|
| 41 | - ) |
|
| 42 | - ); |
|
| 43 | - } |
|
| 44 | - if (! checkdnsrr($domain, 'A')) { |
|
| 45 | - // domain not found in A records |
|
| 46 | - throw new EmailValidationException( |
|
| 47 | - __( |
|
| 48 | - // @codingStandardsIgnoreStart |
|
| 49 | - 'Although the email address provided is formatted correctly, a valid "A record" could not be located for that address and domain. Please enter a valid email address.', |
|
| 50 | - // @codingStandardsIgnoreEnd |
|
| 51 | - 'event_espresso' |
|
| 52 | - ) |
|
| 53 | - ); |
|
| 54 | - } |
|
| 55 | - return true; |
|
| 56 | - } |
|
| 18 | + /** |
|
| 19 | + * Validates the email in teh same way as the parent, but also |
|
| 20 | + * verifies the domain exists. |
|
| 21 | + * |
|
| 22 | + * @param string $email_address |
|
| 23 | + * @return bool |
|
| 24 | + * @throws EmailValidationException |
|
| 25 | + */ |
|
| 26 | + public function validate($email_address) |
|
| 27 | + { |
|
| 28 | + parent::validate($email_address); |
|
| 29 | + $domain = $this->getDomainPartOfEmail( |
|
| 30 | + $email_address, |
|
| 31 | + $this->getAtIndex($email_address) |
|
| 32 | + ); |
|
| 33 | + if (! checkdnsrr($domain, 'MX')) { |
|
| 34 | + // domain not found in MX records |
|
| 35 | + throw new EmailValidationException( |
|
| 36 | + __( |
|
| 37 | + // @codingStandardsIgnoreStart |
|
| 38 | + 'Although the email address provided is formatted correctly, a valid "MX record" could not be located for that address and domain. Please enter a valid email address.', |
|
| 39 | + // @codingStandardsIgnoreEnd |
|
| 40 | + 'event_espresso' |
|
| 41 | + ) |
|
| 42 | + ); |
|
| 43 | + } |
|
| 44 | + if (! checkdnsrr($domain, 'A')) { |
|
| 45 | + // domain not found in A records |
|
| 46 | + throw new EmailValidationException( |
|
| 47 | + __( |
|
| 48 | + // @codingStandardsIgnoreStart |
|
| 49 | + 'Although the email address provided is formatted correctly, a valid "A record" could not be located for that address and domain. Please enter a valid email address.', |
|
| 50 | + // @codingStandardsIgnoreEnd |
|
| 51 | + 'event_espresso' |
|
| 52 | + ) |
|
| 53 | + ); |
|
| 54 | + } |
|
| 55 | + return true; |
|
| 56 | + } |
|
| 57 | 57 | } |
@@ -18,14 +18,14 @@ |
||
| 18 | 18 | interface EmailValidatorInterface |
| 19 | 19 | { |
| 20 | 20 | |
| 21 | - /** |
|
| 22 | - * Validates the supplied email address. If it is invalid, throws EmailValidationException |
|
| 23 | - * |
|
| 24 | - * @param string $email_address |
|
| 25 | - * @return boolean |
|
| 26 | - * @throws EmailValidationException |
|
| 27 | - */ |
|
| 28 | - public function validate($email_address); |
|
| 21 | + /** |
|
| 22 | + * Validates the supplied email address. If it is invalid, throws EmailValidationException |
|
| 23 | + * |
|
| 24 | + * @param string $email_address |
|
| 25 | + * @return boolean |
|
| 26 | + * @throws EmailValidationException |
|
| 27 | + */ |
|
| 28 | + public function validate($email_address); |
|
| 29 | 29 | |
| 30 | 30 | |
| 31 | 31 | } |
@@ -18,72 +18,72 @@ |
||
| 18 | 18 | { |
| 19 | 19 | |
| 20 | 20 | |
| 21 | - /** |
|
| 22 | - * @param string $validation_error_message |
|
| 23 | - */ |
|
| 24 | - public function __construct($validation_error_message = '') |
|
| 25 | - { |
|
| 26 | - if (! $validation_error_message) { |
|
| 27 | - $validation_error_message = esc_html__('Please enter a valid email address.', 'event_espresso'); |
|
| 28 | - } |
|
| 29 | - parent::__construct($validation_error_message); |
|
| 30 | - } |
|
| 21 | + /** |
|
| 22 | + * @param string $validation_error_message |
|
| 23 | + */ |
|
| 24 | + public function __construct($validation_error_message = '') |
|
| 25 | + { |
|
| 26 | + if (! $validation_error_message) { |
|
| 27 | + $validation_error_message = esc_html__('Please enter a valid email address.', 'event_espresso'); |
|
| 28 | + } |
|
| 29 | + parent::__construct($validation_error_message); |
|
| 30 | + } |
|
| 31 | 31 | |
| 32 | 32 | |
| 33 | 33 | |
| 34 | - /** |
|
| 35 | - * just checks the field isn't blank |
|
| 36 | - * |
|
| 37 | - * @param $normalized_value |
|
| 38 | - * @return bool |
|
| 39 | - * @throws InvalidArgumentException |
|
| 40 | - * @throws InvalidInterfaceException |
|
| 41 | - * @throws InvalidDataTypeException |
|
| 42 | - * @throws EE_Validation_Error |
|
| 43 | - */ |
|
| 44 | - public function validate($normalized_value) |
|
| 45 | - { |
|
| 46 | - if ($normalized_value && ! $this->_validate_email($normalized_value)) { |
|
| 47 | - throw new EE_Validation_Error($this->get_validation_error_message(), 'required'); |
|
| 48 | - } |
|
| 49 | - return true; |
|
| 50 | - } |
|
| 34 | + /** |
|
| 35 | + * just checks the field isn't blank |
|
| 36 | + * |
|
| 37 | + * @param $normalized_value |
|
| 38 | + * @return bool |
|
| 39 | + * @throws InvalidArgumentException |
|
| 40 | + * @throws InvalidInterfaceException |
|
| 41 | + * @throws InvalidDataTypeException |
|
| 42 | + * @throws EE_Validation_Error |
|
| 43 | + */ |
|
| 44 | + public function validate($normalized_value) |
|
| 45 | + { |
|
| 46 | + if ($normalized_value && ! $this->_validate_email($normalized_value)) { |
|
| 47 | + throw new EE_Validation_Error($this->get_validation_error_message(), 'required'); |
|
| 48 | + } |
|
| 49 | + return true; |
|
| 50 | + } |
|
| 51 | 51 | |
| 52 | 52 | |
| 53 | 53 | |
| 54 | - /** |
|
| 55 | - * @return array |
|
| 56 | - */ |
|
| 57 | - public function get_jquery_validation_rule_array() |
|
| 58 | - { |
|
| 59 | - return array('email' => true, 'messages' => array('email' => $this->get_validation_error_message())); |
|
| 60 | - } |
|
| 54 | + /** |
|
| 55 | + * @return array |
|
| 56 | + */ |
|
| 57 | + public function get_jquery_validation_rule_array() |
|
| 58 | + { |
|
| 59 | + return array('email' => true, 'messages' => array('email' => $this->get_validation_error_message())); |
|
| 60 | + } |
|
| 61 | 61 | |
| 62 | 62 | |
| 63 | 63 | |
| 64 | - /** |
|
| 65 | - * Validate an email address. |
|
| 66 | - * Provide email address (raw input) |
|
| 67 | - * |
|
| 68 | - * @param $email |
|
| 69 | - * @return bool of whether the email is valid or not |
|
| 70 | - * @throws InvalidArgumentException |
|
| 71 | - * @throws InvalidInterfaceException |
|
| 72 | - * @throws InvalidDataTypeException |
|
| 73 | - * @throws EE_Validation_Error |
|
| 74 | - */ |
|
| 75 | - private function _validate_email($email) |
|
| 76 | - { |
|
| 77 | - try { |
|
| 78 | - EmailAddressFactory::create($email); |
|
| 79 | - } catch (EmailValidationException $e) { |
|
| 80 | - throw new EE_Validation_Error( |
|
| 81 | - $e->getMessage(), |
|
| 82 | - 'invalid_email', |
|
| 83 | - $this->_input, |
|
| 84 | - $e |
|
| 85 | - ); |
|
| 86 | - } |
|
| 87 | - return true; |
|
| 88 | - } |
|
| 64 | + /** |
|
| 65 | + * Validate an email address. |
|
| 66 | + * Provide email address (raw input) |
|
| 67 | + * |
|
| 68 | + * @param $email |
|
| 69 | + * @return bool of whether the email is valid or not |
|
| 70 | + * @throws InvalidArgumentException |
|
| 71 | + * @throws InvalidInterfaceException |
|
| 72 | + * @throws InvalidDataTypeException |
|
| 73 | + * @throws EE_Validation_Error |
|
| 74 | + */ |
|
| 75 | + private function _validate_email($email) |
|
| 76 | + { |
|
| 77 | + try { |
|
| 78 | + EmailAddressFactory::create($email); |
|
| 79 | + } catch (EmailValidationException $e) { |
|
| 80 | + throw new EE_Validation_Error( |
|
| 81 | + $e->getMessage(), |
|
| 82 | + 'invalid_email', |
|
| 83 | + $this->_input, |
|
| 84 | + $e |
|
| 85 | + ); |
|
| 86 | + } |
|
| 87 | + return true; |
|
| 88 | + } |
|
| 89 | 89 | } |
@@ -23,7 +23,7 @@ |
||
| 23 | 23 | */ |
| 24 | 24 | public function __construct($validation_error_message = '') |
| 25 | 25 | { |
| 26 | - if (! $validation_error_message) { |
|
| 26 | + if ( ! $validation_error_message) { |
|
| 27 | 27 | $validation_error_message = esc_html__('Please enter a valid email address.', 'event_espresso'); |
| 28 | 28 | } |
| 29 | 29 | parent::__construct($validation_error_message); |
@@ -351,7 +351,7 @@ |
||
| 351 | 351 | * retrieve a single attendee from db via their ID |
| 352 | 352 | * |
| 353 | 353 | * @param $ATT_ID |
| 354 | - * @return mixed array on success, FALSE on fail |
|
| 354 | + * @return EE_Base_Class|null array on success, FALSE on fail |
|
| 355 | 355 | * @deprecated |
| 356 | 356 | */ |
| 357 | 357 | public function get_attendee_by_ID($ATT_ID = false) |
@@ -1,5 +1,4 @@ |
||
| 1 | 1 | <?php |
| 2 | -use EventEspresso\core\services\loaders\Loader; |
|
| 3 | 2 | use EventEspresso\core\services\orm\ModelFieldFactory; |
| 4 | 3 | |
| 5 | 4 | /** |
@@ -12,411 +12,411 @@ |
||
| 12 | 12 | class EEM_Attendee extends EEM_CPT_Base |
| 13 | 13 | { |
| 14 | 14 | |
| 15 | - // private instance of the Attendee object |
|
| 16 | - protected static $_instance = null; |
|
| 15 | + // private instance of the Attendee object |
|
| 16 | + protected static $_instance = null; |
|
| 17 | 17 | |
| 18 | - /** |
|
| 19 | - * QST_system for questions are strings not integers now, |
|
| 20 | - * so these constants are deprecated. |
|
| 21 | - * Please instead use the EEM_Attendee::system_question_* constants |
|
| 22 | - * |
|
| 23 | - * @deprecated |
|
| 24 | - */ |
|
| 25 | - const fname_question_id = 1; |
|
| 18 | + /** |
|
| 19 | + * QST_system for questions are strings not integers now, |
|
| 20 | + * so these constants are deprecated. |
|
| 21 | + * Please instead use the EEM_Attendee::system_question_* constants |
|
| 22 | + * |
|
| 23 | + * @deprecated |
|
| 24 | + */ |
|
| 25 | + const fname_question_id = 1; |
|
| 26 | 26 | |
| 27 | - /** |
|
| 28 | - * @deprecated |
|
| 29 | - */ |
|
| 30 | - const lname_question_id = 2; |
|
| 27 | + /** |
|
| 28 | + * @deprecated |
|
| 29 | + */ |
|
| 30 | + const lname_question_id = 2; |
|
| 31 | 31 | |
| 32 | 32 | |
| 33 | - /** |
|
| 34 | - * @deprecated |
|
| 35 | - */ |
|
| 36 | - const email_question_id = 3; |
|
| 33 | + /** |
|
| 34 | + * @deprecated |
|
| 35 | + */ |
|
| 36 | + const email_question_id = 3; |
|
| 37 | 37 | |
| 38 | 38 | |
| 39 | - /** |
|
| 40 | - * @deprecated |
|
| 41 | - */ |
|
| 42 | - const address_question_id = 4; |
|
| 39 | + /** |
|
| 40 | + * @deprecated |
|
| 41 | + */ |
|
| 42 | + const address_question_id = 4; |
|
| 43 | 43 | |
| 44 | 44 | |
| 45 | - /** |
|
| 46 | - * @deprecated |
|
| 47 | - */ |
|
| 48 | - const address2_question_id = 5; |
|
| 49 | - |
|
| 50 | - |
|
| 51 | - /** |
|
| 52 | - * @deprecated |
|
| 53 | - */ |
|
| 54 | - const city_question_id = 6; |
|
| 55 | - |
|
| 56 | - |
|
| 57 | - /** |
|
| 58 | - * @deprecated |
|
| 59 | - */ |
|
| 60 | - const state_question_id = 7; |
|
| 61 | - |
|
| 62 | - |
|
| 63 | - /** |
|
| 64 | - * @deprecated |
|
| 65 | - */ |
|
| 66 | - const country_question_id = 8; |
|
| 67 | - |
|
| 68 | - |
|
| 69 | - /** |
|
| 70 | - * @deprecated |
|
| 71 | - */ |
|
| 72 | - const zip_question_id = 9; |
|
| 73 | - |
|
| 74 | - |
|
| 75 | - /** |
|
| 76 | - * @deprecated |
|
| 77 | - */ |
|
| 78 | - const phone_question_id = 10; |
|
| 79 | - |
|
| 80 | - /** |
|
| 81 | - * When looking for questions that correspond to attendee fields, |
|
| 82 | - * look for the question with this QST_system value. |
|
| 83 | - * These replace the old constants like EEM_Attendee::*_question_id |
|
| 84 | - */ |
|
| 85 | - const system_question_fname = 'fname'; |
|
| 86 | - |
|
| 87 | - const system_question_lname = 'lname'; |
|
| 88 | - |
|
| 89 | - const system_question_email = 'email'; |
|
| 90 | - |
|
| 91 | - const system_question_address = 'address'; |
|
| 92 | - |
|
| 93 | - const system_question_address2 = 'address2'; |
|
| 94 | - |
|
| 95 | - const system_question_city = 'city'; |
|
| 96 | - |
|
| 97 | - const system_question_state = 'state'; |
|
| 98 | - |
|
| 99 | - const system_question_country = 'country'; |
|
| 100 | - |
|
| 101 | - const system_question_zip = 'zip'; |
|
| 102 | - |
|
| 103 | - const system_question_phone = 'phone'; |
|
| 104 | - |
|
| 105 | - /** |
|
| 106 | - * Keys are all the EEM_Attendee::system_question_* constants, which are |
|
| 107 | - * also all the values of QST_system in the questions table, and values |
|
| 108 | - * are their corresponding Attendee field names |
|
| 109 | - * |
|
| 110 | - * @var array |
|
| 111 | - */ |
|
| 112 | - protected $_system_question_to_attendee_field_name = array( |
|
| 113 | - EEM_Attendee::system_question_fname => 'ATT_fname', |
|
| 114 | - EEM_Attendee::system_question_lname => 'ATT_lname', |
|
| 115 | - EEM_Attendee::system_question_email => 'ATT_email', |
|
| 116 | - EEM_Attendee::system_question_address => 'ATT_address', |
|
| 117 | - EEM_Attendee::system_question_address2 => 'ATT_address2', |
|
| 118 | - EEM_Attendee::system_question_city => 'ATT_city', |
|
| 119 | - EEM_Attendee::system_question_state => 'STA_ID', |
|
| 120 | - EEM_Attendee::system_question_country => 'CNT_ISO', |
|
| 121 | - EEM_Attendee::system_question_zip => 'ATT_zip', |
|
| 122 | - EEM_Attendee::system_question_phone => 'ATT_phone', |
|
| 123 | - ); |
|
| 124 | - |
|
| 125 | - |
|
| 126 | - |
|
| 127 | - /** |
|
| 128 | - * EEM_Attendee constructor. |
|
| 129 | - * |
|
| 130 | - * @param null $timezone |
|
| 131 | - * @param ModelFieldFactory $model_field_factory |
|
| 132 | - * @throws EE_Error |
|
| 133 | - * @throws InvalidArgumentException |
|
| 134 | - */ |
|
| 135 | - protected function __construct($timezone = null, ModelFieldFactory $model_field_factory) |
|
| 136 | - { |
|
| 137 | - $this->singular_item = esc_html__('Attendee', 'event_espresso'); |
|
| 138 | - $this->plural_item = esc_html__('Attendees', 'event_espresso'); |
|
| 139 | - $this->_tables = array( |
|
| 140 | - 'Attendee_CPT' => new EE_Primary_Table('posts', 'ID'), |
|
| 141 | - 'Attendee_Meta' => new EE_Secondary_Table( |
|
| 142 | - 'esp_attendee_meta', |
|
| 143 | - 'ATTM_ID', |
|
| 144 | - 'ATT_ID' |
|
| 145 | - ), |
|
| 146 | - ); |
|
| 147 | - $this->_fields = array( |
|
| 148 | - 'Attendee_CPT' => array( |
|
| 149 | - 'ATT_ID' => $model_field_factory->createPrimaryKeyIntField( |
|
| 150 | - 'ID', |
|
| 151 | - esc_html__('Attendee ID', 'event_espresso') |
|
| 152 | - ), |
|
| 153 | - 'ATT_full_name' => $model_field_factory->createPlainTextField( |
|
| 154 | - 'post_title', |
|
| 155 | - esc_html__('Attendee Full Name', 'event_espresso'), |
|
| 156 | - false, |
|
| 157 | - esc_html__('Unknown', 'event_espresso') |
|
| 158 | - ), |
|
| 159 | - 'ATT_bio' => $model_field_factory->createPostContentField( |
|
| 160 | - 'post_content', |
|
| 161 | - esc_html__('Attendee Biography', 'event_espresso'), |
|
| 162 | - false, |
|
| 163 | - esc_html__('No Biography Provided', 'event_espresso') |
|
| 164 | - ), |
|
| 165 | - 'ATT_slug' => $model_field_factory->createSlugField( |
|
| 166 | - 'post_name', |
|
| 167 | - esc_html__('Attendee URL Slug', 'event_espresso') |
|
| 168 | - ), |
|
| 169 | - 'ATT_created' => $model_field_factory->createDatetimeField( |
|
| 170 | - 'post_date', |
|
| 171 | - esc_html__('Time Attendee Created', 'event_espresso') |
|
| 172 | - ), |
|
| 173 | - 'ATT_short_bio' => $model_field_factory->createSimpleHtmlField( |
|
| 174 | - 'post_excerpt', |
|
| 175 | - esc_html__('Attendee Short Biography', 'event_espresso'), |
|
| 176 | - true, |
|
| 177 | - esc_html__('No Biography Provided', 'event_espresso') |
|
| 178 | - ), |
|
| 179 | - 'ATT_modified' => $model_field_factory->createDatetimeField( |
|
| 180 | - 'post_modified', |
|
| 181 | - esc_html__('Time Attendee Last Modified', 'event_espresso') |
|
| 182 | - ), |
|
| 183 | - 'ATT_author' => $model_field_factory->createWpUserField( |
|
| 184 | - 'post_author', |
|
| 185 | - esc_html__('Creator ID of the first Event attended', 'event_espresso'), |
|
| 186 | - false |
|
| 187 | - ), |
|
| 188 | - 'ATT_parent' => $model_field_factory->createDbOnlyIntField( |
|
| 189 | - 'post_parent', |
|
| 190 | - esc_html__('Parent Attendee (unused)', 'event_espresso'), |
|
| 191 | - false, |
|
| 192 | - 0 |
|
| 193 | - ), |
|
| 194 | - 'post_type' => $model_field_factory->createWpPostTypeField('espresso_attendees'), |
|
| 195 | - 'status' => $model_field_factory->createWpPostStatusField( |
|
| 196 | - 'post_status', |
|
| 197 | - esc_html__('Attendee Status', 'event_espresso'), |
|
| 198 | - false, |
|
| 199 | - 'publish' |
|
| 200 | - ), |
|
| 201 | - ), |
|
| 202 | - 'Attendee_Meta' => array( |
|
| 203 | - 'ATTM_ID' => $model_field_factory->createDbOnlyIntField( |
|
| 204 | - 'ATTM_ID', |
|
| 205 | - esc_html__('Attendee Meta Row ID', 'event_espresso'), |
|
| 206 | - false |
|
| 207 | - ), |
|
| 208 | - 'ATT_ID_fk' => $model_field_factory->createDbOnlyIntField( |
|
| 209 | - 'ATT_ID', |
|
| 210 | - esc_html__('Foreign Key to Attendee in Post Table', 'event_espresso'), |
|
| 211 | - false |
|
| 212 | - ), |
|
| 213 | - 'ATT_fname' => $model_field_factory->createPlainTextField( |
|
| 214 | - 'ATT_fname', |
|
| 215 | - esc_html__('First Name', 'event_espresso') |
|
| 216 | - ), |
|
| 217 | - 'ATT_lname' => $model_field_factory->createPlainTextField( |
|
| 218 | - 'ATT_lname', |
|
| 219 | - esc_html__('Last Name', 'event_espresso') |
|
| 220 | - ), |
|
| 221 | - 'ATT_address' => $model_field_factory->createPlainTextField( |
|
| 222 | - 'ATT_address', |
|
| 223 | - esc_html__('Address Part 1', 'event_espresso') |
|
| 224 | - ), |
|
| 225 | - 'ATT_address2' => $model_field_factory->createPlainTextField( |
|
| 226 | - 'ATT_address2', |
|
| 227 | - esc_html__('Address Part 2', 'event_espresso') |
|
| 228 | - ), |
|
| 229 | - 'ATT_city' => $model_field_factory->createPlainTextField( |
|
| 230 | - 'ATT_city', |
|
| 231 | - esc_html__('City', 'event_espresso') |
|
| 232 | - ), |
|
| 233 | - 'STA_ID' => $model_field_factory->createForeignKeyIntField( |
|
| 234 | - 'STA_ID', |
|
| 235 | - esc_html__('State', 'event_espresso'), |
|
| 236 | - true, |
|
| 237 | - 0, |
|
| 238 | - 'State' |
|
| 239 | - ), |
|
| 240 | - 'CNT_ISO' => $model_field_factory->createForeignKeyStringField( |
|
| 241 | - 'CNT_ISO', |
|
| 242 | - esc_html__('Country', 'event_espresso'), |
|
| 243 | - true, |
|
| 244 | - '', |
|
| 245 | - 'Country' |
|
| 246 | - ), |
|
| 247 | - 'ATT_zip' => $model_field_factory->createPlainTextField( |
|
| 248 | - 'ATT_zip', |
|
| 249 | - esc_html__('ZIP/Postal Code', 'event_espresso') |
|
| 250 | - ), |
|
| 251 | - 'ATT_email' => $model_field_factory->createEmailField( |
|
| 252 | - 'ATT_email', |
|
| 253 | - esc_html__('Email Address', 'event_espresso') |
|
| 254 | - ), |
|
| 255 | - 'ATT_phone' => $model_field_factory->createPlainTextField( |
|
| 256 | - 'ATT_phone', |
|
| 257 | - esc_html__('Phone', 'event_espresso') |
|
| 258 | - ), |
|
| 259 | - ), |
|
| 260 | - ); |
|
| 261 | - $this->_model_relations = array( |
|
| 262 | - 'Registration' => new EE_Has_Many_Relation(), |
|
| 263 | - 'State' => new EE_Belongs_To_Relation(), |
|
| 264 | - 'Country' => new EE_Belongs_To_Relation(), |
|
| 265 | - 'Event' => new EE_HABTM_Relation('Registration', false), |
|
| 266 | - 'WP_User' => new EE_Belongs_To_Relation(), |
|
| 267 | - 'Message' => new EE_Has_Many_Any_Relation(false), |
|
| 268 | - // allow deletion of attendees even if they have messages in the queue for them. |
|
| 269 | - 'Term_Relationship' => new EE_Has_Many_Relation(), |
|
| 270 | - 'Term_Taxonomy' => new EE_HABTM_Relation('Term_Relationship'), |
|
| 271 | - ); |
|
| 272 | - $this->_caps_slug = 'contacts'; |
|
| 273 | - parent::__construct($timezone); |
|
| 274 | - } |
|
| 275 | - |
|
| 276 | - |
|
| 277 | - |
|
| 278 | - /** |
|
| 279 | - * Gets the name of the field on the attendee model corresponding to the system question string |
|
| 280 | - * which should be one of the keys from EEM_Attendee::_system_question_to_attendee_field_name |
|
| 281 | - * |
|
| 282 | - * @param string $system_question_string |
|
| 283 | - * @return string|null if not found |
|
| 284 | - */ |
|
| 285 | - public function get_attendee_field_for_system_question($system_question_string) |
|
| 286 | - { |
|
| 287 | - return isset($this->_system_question_to_attendee_field_name[ $system_question_string ]) |
|
| 288 | - ? $this->_system_question_to_attendee_field_name[ $system_question_string ] |
|
| 289 | - : null; |
|
| 290 | - } |
|
| 291 | - |
|
| 292 | - |
|
| 293 | - |
|
| 294 | - /** |
|
| 295 | - * Gets mapping from esp_question.QST_system values to their corresponding attendee field names |
|
| 296 | - * |
|
| 297 | - * @return array |
|
| 298 | - */ |
|
| 299 | - public function system_question_to_attendee_field_mapping() |
|
| 300 | - { |
|
| 301 | - return $this->_system_question_to_attendee_field_name; |
|
| 302 | - } |
|
| 303 | - |
|
| 304 | - |
|
| 305 | - |
|
| 306 | - /** |
|
| 307 | - * Gets all the attendees for a transaction (by using the esp_registration as a join table) |
|
| 308 | - * |
|
| 309 | - * @param EE_Transaction /int $transaction_id_or_obj EE_Transaction or its ID |
|
| 310 | - * @return EE_Attendee[]|EE_Base_Class[] |
|
| 311 | - * @throws EE_Error |
|
| 312 | - */ |
|
| 313 | - public function get_attendees_for_transaction($transaction_id_or_obj) |
|
| 314 | - { |
|
| 315 | - return $this->get_all( |
|
| 316 | - array( |
|
| 317 | - array( |
|
| 318 | - 'Registration.Transaction.TXN_ID' => $transaction_id_or_obj instanceof EE_Transaction |
|
| 319 | - ? $transaction_id_or_obj->ID() |
|
| 320 | - : $transaction_id_or_obj, |
|
| 321 | - ), |
|
| 322 | - ) |
|
| 323 | - ); |
|
| 324 | - } |
|
| 325 | - |
|
| 326 | - |
|
| 327 | - |
|
| 328 | - /** |
|
| 329 | - * retrieve a single attendee from db via their ID |
|
| 330 | - * |
|
| 331 | - * @param $ATT_ID |
|
| 332 | - * @return mixed array on success, FALSE on fail |
|
| 333 | - * @deprecated |
|
| 334 | - */ |
|
| 335 | - public function get_attendee_by_ID($ATT_ID = false) |
|
| 336 | - { |
|
| 337 | - // retrieve a particular EE_Attendee |
|
| 338 | - return $this->get_one_by_ID($ATT_ID); |
|
| 339 | - } |
|
| 340 | - |
|
| 341 | - |
|
| 342 | - |
|
| 343 | - /** |
|
| 344 | - * retrieve a single attendee from db via their ID |
|
| 345 | - * |
|
| 346 | - * @param array $where_cols_n_values |
|
| 347 | - * @return mixed array on success, FALSE on fail |
|
| 348 | - * @throws EE_Error |
|
| 349 | - */ |
|
| 350 | - public function get_attendee($where_cols_n_values = array()) |
|
| 351 | - { |
|
| 352 | - if (empty($where_cols_n_values)) { |
|
| 353 | - return false; |
|
| 354 | - } |
|
| 355 | - $attendee = $this->get_all(array($where_cols_n_values)); |
|
| 356 | - if (! empty($attendee)) { |
|
| 357 | - return array_shift($attendee); |
|
| 358 | - } |
|
| 359 | - return false; |
|
| 360 | - } |
|
| 361 | - |
|
| 362 | - |
|
| 363 | - |
|
| 364 | - /** |
|
| 365 | - * Search for an existing Attendee record in the DB |
|
| 366 | - * |
|
| 367 | - * @param array $where_cols_n_values |
|
| 368 | - * @return bool|mixed |
|
| 369 | - * @throws EE_Error |
|
| 370 | - */ |
|
| 371 | - public function find_existing_attendee($where_cols_n_values = null) |
|
| 372 | - { |
|
| 373 | - // search by combo of first and last names plus the email address |
|
| 374 | - $attendee_data_keys = array( |
|
| 375 | - 'ATT_fname' => $this->_ATT_fname, |
|
| 376 | - 'ATT_lname' => $this->_ATT_lname, |
|
| 377 | - 'ATT_email' => $this->_ATT_email, |
|
| 378 | - ); |
|
| 379 | - // no search params means attendee object already exists. |
|
| 380 | - $where_cols_n_values = is_array($where_cols_n_values) && ! empty($where_cols_n_values) |
|
| 381 | - ? $where_cols_n_values |
|
| 382 | - : $attendee_data_keys; |
|
| 383 | - $valid_data = true; |
|
| 384 | - // check for required values |
|
| 385 | - $valid_data = isset($where_cols_n_values['ATT_fname']) && ! empty($where_cols_n_values['ATT_fname']) |
|
| 386 | - ? $valid_data |
|
| 387 | - : false; |
|
| 388 | - $valid_data = isset($where_cols_n_values['ATT_lname']) && ! empty($where_cols_n_values['ATT_lname']) |
|
| 389 | - ? $valid_data |
|
| 390 | - : false; |
|
| 391 | - $valid_data = isset($where_cols_n_values['ATT_email']) && ! empty($where_cols_n_values['ATT_email']) |
|
| 392 | - ? $valid_data |
|
| 393 | - : false; |
|
| 394 | - if ($valid_data) { |
|
| 395 | - $attendee = $this->get_attendee($where_cols_n_values); |
|
| 396 | - if ($attendee instanceof EE_Attendee) { |
|
| 397 | - return $attendee; |
|
| 398 | - } |
|
| 399 | - } |
|
| 400 | - return false; |
|
| 401 | - } |
|
| 402 | - |
|
| 403 | - |
|
| 404 | - |
|
| 405 | - /** |
|
| 406 | - * Takes an incoming array of EE_Registration ids |
|
| 407 | - * and sends back a list of corresponding non duplicate EE_Attendee objects. |
|
| 408 | - * |
|
| 409 | - * @since 4.3.0 |
|
| 410 | - * @param array $ids array of EE_Registration ids |
|
| 411 | - * @return EE_Attendee[]|EE_Base_Class[] |
|
| 412 | - * @throws EE_Error |
|
| 413 | - */ |
|
| 414 | - public function get_array_of_contacts_from_reg_ids($ids) |
|
| 415 | - { |
|
| 416 | - $ids = (array) $ids; |
|
| 417 | - $_where = array( |
|
| 418 | - 'Registration.REG_ID' => array('in', $ids), |
|
| 419 | - ); |
|
| 420 | - return $this->get_all(array($_where)); |
|
| 421 | - } |
|
| 45 | + /** |
|
| 46 | + * @deprecated |
|
| 47 | + */ |
|
| 48 | + const address2_question_id = 5; |
|
| 49 | + |
|
| 50 | + |
|
| 51 | + /** |
|
| 52 | + * @deprecated |
|
| 53 | + */ |
|
| 54 | + const city_question_id = 6; |
|
| 55 | + |
|
| 56 | + |
|
| 57 | + /** |
|
| 58 | + * @deprecated |
|
| 59 | + */ |
|
| 60 | + const state_question_id = 7; |
|
| 61 | + |
|
| 62 | + |
|
| 63 | + /** |
|
| 64 | + * @deprecated |
|
| 65 | + */ |
|
| 66 | + const country_question_id = 8; |
|
| 67 | + |
|
| 68 | + |
|
| 69 | + /** |
|
| 70 | + * @deprecated |
|
| 71 | + */ |
|
| 72 | + const zip_question_id = 9; |
|
| 73 | + |
|
| 74 | + |
|
| 75 | + /** |
|
| 76 | + * @deprecated |
|
| 77 | + */ |
|
| 78 | + const phone_question_id = 10; |
|
| 79 | + |
|
| 80 | + /** |
|
| 81 | + * When looking for questions that correspond to attendee fields, |
|
| 82 | + * look for the question with this QST_system value. |
|
| 83 | + * These replace the old constants like EEM_Attendee::*_question_id |
|
| 84 | + */ |
|
| 85 | + const system_question_fname = 'fname'; |
|
| 86 | + |
|
| 87 | + const system_question_lname = 'lname'; |
|
| 88 | + |
|
| 89 | + const system_question_email = 'email'; |
|
| 90 | + |
|
| 91 | + const system_question_address = 'address'; |
|
| 92 | + |
|
| 93 | + const system_question_address2 = 'address2'; |
|
| 94 | + |
|
| 95 | + const system_question_city = 'city'; |
|
| 96 | + |
|
| 97 | + const system_question_state = 'state'; |
|
| 98 | + |
|
| 99 | + const system_question_country = 'country'; |
|
| 100 | + |
|
| 101 | + const system_question_zip = 'zip'; |
|
| 102 | + |
|
| 103 | + const system_question_phone = 'phone'; |
|
| 104 | + |
|
| 105 | + /** |
|
| 106 | + * Keys are all the EEM_Attendee::system_question_* constants, which are |
|
| 107 | + * also all the values of QST_system in the questions table, and values |
|
| 108 | + * are their corresponding Attendee field names |
|
| 109 | + * |
|
| 110 | + * @var array |
|
| 111 | + */ |
|
| 112 | + protected $_system_question_to_attendee_field_name = array( |
|
| 113 | + EEM_Attendee::system_question_fname => 'ATT_fname', |
|
| 114 | + EEM_Attendee::system_question_lname => 'ATT_lname', |
|
| 115 | + EEM_Attendee::system_question_email => 'ATT_email', |
|
| 116 | + EEM_Attendee::system_question_address => 'ATT_address', |
|
| 117 | + EEM_Attendee::system_question_address2 => 'ATT_address2', |
|
| 118 | + EEM_Attendee::system_question_city => 'ATT_city', |
|
| 119 | + EEM_Attendee::system_question_state => 'STA_ID', |
|
| 120 | + EEM_Attendee::system_question_country => 'CNT_ISO', |
|
| 121 | + EEM_Attendee::system_question_zip => 'ATT_zip', |
|
| 122 | + EEM_Attendee::system_question_phone => 'ATT_phone', |
|
| 123 | + ); |
|
| 124 | + |
|
| 125 | + |
|
| 126 | + |
|
| 127 | + /** |
|
| 128 | + * EEM_Attendee constructor. |
|
| 129 | + * |
|
| 130 | + * @param null $timezone |
|
| 131 | + * @param ModelFieldFactory $model_field_factory |
|
| 132 | + * @throws EE_Error |
|
| 133 | + * @throws InvalidArgumentException |
|
| 134 | + */ |
|
| 135 | + protected function __construct($timezone = null, ModelFieldFactory $model_field_factory) |
|
| 136 | + { |
|
| 137 | + $this->singular_item = esc_html__('Attendee', 'event_espresso'); |
|
| 138 | + $this->plural_item = esc_html__('Attendees', 'event_espresso'); |
|
| 139 | + $this->_tables = array( |
|
| 140 | + 'Attendee_CPT' => new EE_Primary_Table('posts', 'ID'), |
|
| 141 | + 'Attendee_Meta' => new EE_Secondary_Table( |
|
| 142 | + 'esp_attendee_meta', |
|
| 143 | + 'ATTM_ID', |
|
| 144 | + 'ATT_ID' |
|
| 145 | + ), |
|
| 146 | + ); |
|
| 147 | + $this->_fields = array( |
|
| 148 | + 'Attendee_CPT' => array( |
|
| 149 | + 'ATT_ID' => $model_field_factory->createPrimaryKeyIntField( |
|
| 150 | + 'ID', |
|
| 151 | + esc_html__('Attendee ID', 'event_espresso') |
|
| 152 | + ), |
|
| 153 | + 'ATT_full_name' => $model_field_factory->createPlainTextField( |
|
| 154 | + 'post_title', |
|
| 155 | + esc_html__('Attendee Full Name', 'event_espresso'), |
|
| 156 | + false, |
|
| 157 | + esc_html__('Unknown', 'event_espresso') |
|
| 158 | + ), |
|
| 159 | + 'ATT_bio' => $model_field_factory->createPostContentField( |
|
| 160 | + 'post_content', |
|
| 161 | + esc_html__('Attendee Biography', 'event_espresso'), |
|
| 162 | + false, |
|
| 163 | + esc_html__('No Biography Provided', 'event_espresso') |
|
| 164 | + ), |
|
| 165 | + 'ATT_slug' => $model_field_factory->createSlugField( |
|
| 166 | + 'post_name', |
|
| 167 | + esc_html__('Attendee URL Slug', 'event_espresso') |
|
| 168 | + ), |
|
| 169 | + 'ATT_created' => $model_field_factory->createDatetimeField( |
|
| 170 | + 'post_date', |
|
| 171 | + esc_html__('Time Attendee Created', 'event_espresso') |
|
| 172 | + ), |
|
| 173 | + 'ATT_short_bio' => $model_field_factory->createSimpleHtmlField( |
|
| 174 | + 'post_excerpt', |
|
| 175 | + esc_html__('Attendee Short Biography', 'event_espresso'), |
|
| 176 | + true, |
|
| 177 | + esc_html__('No Biography Provided', 'event_espresso') |
|
| 178 | + ), |
|
| 179 | + 'ATT_modified' => $model_field_factory->createDatetimeField( |
|
| 180 | + 'post_modified', |
|
| 181 | + esc_html__('Time Attendee Last Modified', 'event_espresso') |
|
| 182 | + ), |
|
| 183 | + 'ATT_author' => $model_field_factory->createWpUserField( |
|
| 184 | + 'post_author', |
|
| 185 | + esc_html__('Creator ID of the first Event attended', 'event_espresso'), |
|
| 186 | + false |
|
| 187 | + ), |
|
| 188 | + 'ATT_parent' => $model_field_factory->createDbOnlyIntField( |
|
| 189 | + 'post_parent', |
|
| 190 | + esc_html__('Parent Attendee (unused)', 'event_espresso'), |
|
| 191 | + false, |
|
| 192 | + 0 |
|
| 193 | + ), |
|
| 194 | + 'post_type' => $model_field_factory->createWpPostTypeField('espresso_attendees'), |
|
| 195 | + 'status' => $model_field_factory->createWpPostStatusField( |
|
| 196 | + 'post_status', |
|
| 197 | + esc_html__('Attendee Status', 'event_espresso'), |
|
| 198 | + false, |
|
| 199 | + 'publish' |
|
| 200 | + ), |
|
| 201 | + ), |
|
| 202 | + 'Attendee_Meta' => array( |
|
| 203 | + 'ATTM_ID' => $model_field_factory->createDbOnlyIntField( |
|
| 204 | + 'ATTM_ID', |
|
| 205 | + esc_html__('Attendee Meta Row ID', 'event_espresso'), |
|
| 206 | + false |
|
| 207 | + ), |
|
| 208 | + 'ATT_ID_fk' => $model_field_factory->createDbOnlyIntField( |
|
| 209 | + 'ATT_ID', |
|
| 210 | + esc_html__('Foreign Key to Attendee in Post Table', 'event_espresso'), |
|
| 211 | + false |
|
| 212 | + ), |
|
| 213 | + 'ATT_fname' => $model_field_factory->createPlainTextField( |
|
| 214 | + 'ATT_fname', |
|
| 215 | + esc_html__('First Name', 'event_espresso') |
|
| 216 | + ), |
|
| 217 | + 'ATT_lname' => $model_field_factory->createPlainTextField( |
|
| 218 | + 'ATT_lname', |
|
| 219 | + esc_html__('Last Name', 'event_espresso') |
|
| 220 | + ), |
|
| 221 | + 'ATT_address' => $model_field_factory->createPlainTextField( |
|
| 222 | + 'ATT_address', |
|
| 223 | + esc_html__('Address Part 1', 'event_espresso') |
|
| 224 | + ), |
|
| 225 | + 'ATT_address2' => $model_field_factory->createPlainTextField( |
|
| 226 | + 'ATT_address2', |
|
| 227 | + esc_html__('Address Part 2', 'event_espresso') |
|
| 228 | + ), |
|
| 229 | + 'ATT_city' => $model_field_factory->createPlainTextField( |
|
| 230 | + 'ATT_city', |
|
| 231 | + esc_html__('City', 'event_espresso') |
|
| 232 | + ), |
|
| 233 | + 'STA_ID' => $model_field_factory->createForeignKeyIntField( |
|
| 234 | + 'STA_ID', |
|
| 235 | + esc_html__('State', 'event_espresso'), |
|
| 236 | + true, |
|
| 237 | + 0, |
|
| 238 | + 'State' |
|
| 239 | + ), |
|
| 240 | + 'CNT_ISO' => $model_field_factory->createForeignKeyStringField( |
|
| 241 | + 'CNT_ISO', |
|
| 242 | + esc_html__('Country', 'event_espresso'), |
|
| 243 | + true, |
|
| 244 | + '', |
|
| 245 | + 'Country' |
|
| 246 | + ), |
|
| 247 | + 'ATT_zip' => $model_field_factory->createPlainTextField( |
|
| 248 | + 'ATT_zip', |
|
| 249 | + esc_html__('ZIP/Postal Code', 'event_espresso') |
|
| 250 | + ), |
|
| 251 | + 'ATT_email' => $model_field_factory->createEmailField( |
|
| 252 | + 'ATT_email', |
|
| 253 | + esc_html__('Email Address', 'event_espresso') |
|
| 254 | + ), |
|
| 255 | + 'ATT_phone' => $model_field_factory->createPlainTextField( |
|
| 256 | + 'ATT_phone', |
|
| 257 | + esc_html__('Phone', 'event_espresso') |
|
| 258 | + ), |
|
| 259 | + ), |
|
| 260 | + ); |
|
| 261 | + $this->_model_relations = array( |
|
| 262 | + 'Registration' => new EE_Has_Many_Relation(), |
|
| 263 | + 'State' => new EE_Belongs_To_Relation(), |
|
| 264 | + 'Country' => new EE_Belongs_To_Relation(), |
|
| 265 | + 'Event' => new EE_HABTM_Relation('Registration', false), |
|
| 266 | + 'WP_User' => new EE_Belongs_To_Relation(), |
|
| 267 | + 'Message' => new EE_Has_Many_Any_Relation(false), |
|
| 268 | + // allow deletion of attendees even if they have messages in the queue for them. |
|
| 269 | + 'Term_Relationship' => new EE_Has_Many_Relation(), |
|
| 270 | + 'Term_Taxonomy' => new EE_HABTM_Relation('Term_Relationship'), |
|
| 271 | + ); |
|
| 272 | + $this->_caps_slug = 'contacts'; |
|
| 273 | + parent::__construct($timezone); |
|
| 274 | + } |
|
| 275 | + |
|
| 276 | + |
|
| 277 | + |
|
| 278 | + /** |
|
| 279 | + * Gets the name of the field on the attendee model corresponding to the system question string |
|
| 280 | + * which should be one of the keys from EEM_Attendee::_system_question_to_attendee_field_name |
|
| 281 | + * |
|
| 282 | + * @param string $system_question_string |
|
| 283 | + * @return string|null if not found |
|
| 284 | + */ |
|
| 285 | + public function get_attendee_field_for_system_question($system_question_string) |
|
| 286 | + { |
|
| 287 | + return isset($this->_system_question_to_attendee_field_name[ $system_question_string ]) |
|
| 288 | + ? $this->_system_question_to_attendee_field_name[ $system_question_string ] |
|
| 289 | + : null; |
|
| 290 | + } |
|
| 291 | + |
|
| 292 | + |
|
| 293 | + |
|
| 294 | + /** |
|
| 295 | + * Gets mapping from esp_question.QST_system values to their corresponding attendee field names |
|
| 296 | + * |
|
| 297 | + * @return array |
|
| 298 | + */ |
|
| 299 | + public function system_question_to_attendee_field_mapping() |
|
| 300 | + { |
|
| 301 | + return $this->_system_question_to_attendee_field_name; |
|
| 302 | + } |
|
| 303 | + |
|
| 304 | + |
|
| 305 | + |
|
| 306 | + /** |
|
| 307 | + * Gets all the attendees for a transaction (by using the esp_registration as a join table) |
|
| 308 | + * |
|
| 309 | + * @param EE_Transaction /int $transaction_id_or_obj EE_Transaction or its ID |
|
| 310 | + * @return EE_Attendee[]|EE_Base_Class[] |
|
| 311 | + * @throws EE_Error |
|
| 312 | + */ |
|
| 313 | + public function get_attendees_for_transaction($transaction_id_or_obj) |
|
| 314 | + { |
|
| 315 | + return $this->get_all( |
|
| 316 | + array( |
|
| 317 | + array( |
|
| 318 | + 'Registration.Transaction.TXN_ID' => $transaction_id_or_obj instanceof EE_Transaction |
|
| 319 | + ? $transaction_id_or_obj->ID() |
|
| 320 | + : $transaction_id_or_obj, |
|
| 321 | + ), |
|
| 322 | + ) |
|
| 323 | + ); |
|
| 324 | + } |
|
| 325 | + |
|
| 326 | + |
|
| 327 | + |
|
| 328 | + /** |
|
| 329 | + * retrieve a single attendee from db via their ID |
|
| 330 | + * |
|
| 331 | + * @param $ATT_ID |
|
| 332 | + * @return mixed array on success, FALSE on fail |
|
| 333 | + * @deprecated |
|
| 334 | + */ |
|
| 335 | + public function get_attendee_by_ID($ATT_ID = false) |
|
| 336 | + { |
|
| 337 | + // retrieve a particular EE_Attendee |
|
| 338 | + return $this->get_one_by_ID($ATT_ID); |
|
| 339 | + } |
|
| 340 | + |
|
| 341 | + |
|
| 342 | + |
|
| 343 | + /** |
|
| 344 | + * retrieve a single attendee from db via their ID |
|
| 345 | + * |
|
| 346 | + * @param array $where_cols_n_values |
|
| 347 | + * @return mixed array on success, FALSE on fail |
|
| 348 | + * @throws EE_Error |
|
| 349 | + */ |
|
| 350 | + public function get_attendee($where_cols_n_values = array()) |
|
| 351 | + { |
|
| 352 | + if (empty($where_cols_n_values)) { |
|
| 353 | + return false; |
|
| 354 | + } |
|
| 355 | + $attendee = $this->get_all(array($where_cols_n_values)); |
|
| 356 | + if (! empty($attendee)) { |
|
| 357 | + return array_shift($attendee); |
|
| 358 | + } |
|
| 359 | + return false; |
|
| 360 | + } |
|
| 361 | + |
|
| 362 | + |
|
| 363 | + |
|
| 364 | + /** |
|
| 365 | + * Search for an existing Attendee record in the DB |
|
| 366 | + * |
|
| 367 | + * @param array $where_cols_n_values |
|
| 368 | + * @return bool|mixed |
|
| 369 | + * @throws EE_Error |
|
| 370 | + */ |
|
| 371 | + public function find_existing_attendee($where_cols_n_values = null) |
|
| 372 | + { |
|
| 373 | + // search by combo of first and last names plus the email address |
|
| 374 | + $attendee_data_keys = array( |
|
| 375 | + 'ATT_fname' => $this->_ATT_fname, |
|
| 376 | + 'ATT_lname' => $this->_ATT_lname, |
|
| 377 | + 'ATT_email' => $this->_ATT_email, |
|
| 378 | + ); |
|
| 379 | + // no search params means attendee object already exists. |
|
| 380 | + $where_cols_n_values = is_array($where_cols_n_values) && ! empty($where_cols_n_values) |
|
| 381 | + ? $where_cols_n_values |
|
| 382 | + : $attendee_data_keys; |
|
| 383 | + $valid_data = true; |
|
| 384 | + // check for required values |
|
| 385 | + $valid_data = isset($where_cols_n_values['ATT_fname']) && ! empty($where_cols_n_values['ATT_fname']) |
|
| 386 | + ? $valid_data |
|
| 387 | + : false; |
|
| 388 | + $valid_data = isset($where_cols_n_values['ATT_lname']) && ! empty($where_cols_n_values['ATT_lname']) |
|
| 389 | + ? $valid_data |
|
| 390 | + : false; |
|
| 391 | + $valid_data = isset($where_cols_n_values['ATT_email']) && ! empty($where_cols_n_values['ATT_email']) |
|
| 392 | + ? $valid_data |
|
| 393 | + : false; |
|
| 394 | + if ($valid_data) { |
|
| 395 | + $attendee = $this->get_attendee($where_cols_n_values); |
|
| 396 | + if ($attendee instanceof EE_Attendee) { |
|
| 397 | + return $attendee; |
|
| 398 | + } |
|
| 399 | + } |
|
| 400 | + return false; |
|
| 401 | + } |
|
| 402 | + |
|
| 403 | + |
|
| 404 | + |
|
| 405 | + /** |
|
| 406 | + * Takes an incoming array of EE_Registration ids |
|
| 407 | + * and sends back a list of corresponding non duplicate EE_Attendee objects. |
|
| 408 | + * |
|
| 409 | + * @since 4.3.0 |
|
| 410 | + * @param array $ids array of EE_Registration ids |
|
| 411 | + * @return EE_Attendee[]|EE_Base_Class[] |
|
| 412 | + * @throws EE_Error |
|
| 413 | + */ |
|
| 414 | + public function get_array_of_contacts_from_reg_ids($ids) |
|
| 415 | + { |
|
| 416 | + $ids = (array) $ids; |
|
| 417 | + $_where = array( |
|
| 418 | + 'Registration.REG_ID' => array('in', $ids), |
|
| 419 | + ); |
|
| 420 | + return $this->get_all(array($_where)); |
|
| 421 | + } |
|
| 422 | 422 | } |
@@ -284,8 +284,8 @@ discard block |
||
| 284 | 284 | */ |
| 285 | 285 | public function get_attendee_field_for_system_question($system_question_string) |
| 286 | 286 | { |
| 287 | - return isset($this->_system_question_to_attendee_field_name[ $system_question_string ]) |
|
| 288 | - ? $this->_system_question_to_attendee_field_name[ $system_question_string ] |
|
| 287 | + return isset($this->_system_question_to_attendee_field_name[$system_question_string]) |
|
| 288 | + ? $this->_system_question_to_attendee_field_name[$system_question_string] |
|
| 289 | 289 | : null; |
| 290 | 290 | } |
| 291 | 291 | |
@@ -353,7 +353,7 @@ discard block |
||
| 353 | 353 | return false; |
| 354 | 354 | } |
| 355 | 355 | $attendee = $this->get_all(array($where_cols_n_values)); |
| 356 | - if (! empty($attendee)) { |
|
| 356 | + if ( ! empty($attendee)) { |
|
| 357 | 357 | return array_shift($attendee); |
| 358 | 358 | } |
| 359 | 359 | return false; |
@@ -98,7 +98,7 @@ |
||
| 98 | 98 | * |
| 99 | 99 | * @param EE_Event $event EE event object |
| 100 | 100 | * @param array $data The request data from the form |
| 101 | - * @return bool success or fail |
|
| 101 | + * @return integer success or fail |
|
| 102 | 102 | * @throws EE_Error |
| 103 | 103 | */ |
| 104 | 104 | public function attach_evt_message_templates($event, $data) |
@@ -12,276 +12,276 @@ |
||
| 12 | 12 | */ |
| 13 | 13 | class espresso_events_Messages_Hooks_Extend extends espresso_events_Messages_Hooks |
| 14 | 14 | { |
| 15 | - /** |
|
| 16 | - * espresso_events_Messages_Hooks_Extend constructor. |
|
| 17 | - * |
|
| 18 | - * @param \EE_Admin_Page $admin_page |
|
| 19 | - */ |
|
| 20 | - public function __construct(EE_Admin_Page $admin_page) |
|
| 21 | - { |
|
| 22 | - /** |
|
| 23 | - * Add cap restriction ... metaboxes should not show if user does not have the ability to edit_custom_messages |
|
| 24 | - */ |
|
| 25 | - if (! EE_Registry::instance()->CAP->current_user_can( |
|
| 26 | - 'ee_edit_messages', |
|
| 27 | - 'messages_events_editor_metabox' |
|
| 28 | - )) { |
|
| 29 | - return; |
|
| 30 | - } |
|
| 31 | - add_filter( |
|
| 32 | - 'FHEE__Events_Admin_Page___insert_update_cpt_item__event_update_callbacks', |
|
| 33 | - array($this, 'caf_updates'), |
|
| 34 | - 10 |
|
| 35 | - ); |
|
| 36 | - add_action( |
|
| 37 | - 'AHEE__Extend_Events_Admin_Page___duplicate_event__after', |
|
| 38 | - array($this, 'duplicate_custom_message_settings'), |
|
| 39 | - 10, |
|
| 40 | - 2 |
|
| 41 | - ); |
|
| 42 | - parent::__construct($admin_page); |
|
| 43 | - } |
|
| 44 | - |
|
| 45 | - |
|
| 46 | - /** |
|
| 47 | - * extending the properties set in espresso_events_Messages_Hooks |
|
| 48 | - * |
|
| 49 | - * @access protected |
|
| 50 | - * @return void |
|
| 51 | - */ |
|
| 52 | - protected function _extend_properties() |
|
| 53 | - { |
|
| 54 | - define('EE_MSGS_EXTEND_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'messages/assets/'); |
|
| 55 | - $this->_ajax_func = array( |
|
| 56 | - 'ee_msgs_create_new_custom' => 'create_new_custom', |
|
| 57 | - ); |
|
| 58 | - $this->_metaboxes = array( |
|
| 59 | - 0 => array( |
|
| 60 | - 'page_route' => array('edit', 'create_new'), |
|
| 61 | - 'func' => 'messages_metabox', |
|
| 62 | - 'label' => esc_html__('Notifications', 'event_espresso'), |
|
| 63 | - 'priority' => 'high', |
|
| 64 | - ), |
|
| 65 | - ); |
|
| 66 | - |
|
| 67 | - // see explanation for layout in EE_Admin_Hooks |
|
| 68 | - $this->_scripts_styles = array( |
|
| 69 | - 'registers' => array( |
|
| 70 | - 'events_msg_admin' => array( |
|
| 71 | - 'url' => EE_MSGS_EXTEND_ASSETS_URL . 'events_messages_admin.js', |
|
| 72 | - 'depends' => array('ee-dialog', 'ee-parse-uri', 'ee-serialize-full-array'), |
|
| 73 | - ), |
|
| 74 | - 'events_msg_admin_css' => array( |
|
| 75 | - 'url' => EE_MSGS_EXTEND_ASSETS_URL . 'ee_msg_events_admin.css', |
|
| 76 | - 'type' => 'css', |
|
| 77 | - ), |
|
| 78 | - ), |
|
| 79 | - 'enqueues' => array( |
|
| 80 | - 'events_msg_admin' => array('edit', 'create_new'), |
|
| 81 | - 'events_msg_admin_css' => array('edit', 'create_new'), |
|
| 82 | - ), |
|
| 83 | - ); |
|
| 84 | - } |
|
| 85 | - |
|
| 86 | - |
|
| 87 | - public function caf_updates($update_callbacks) |
|
| 88 | - { |
|
| 89 | - $update_callbacks[] = array($this, 'attach_evt_message_templates'); |
|
| 90 | - return $update_callbacks; |
|
| 91 | - } |
|
| 92 | - |
|
| 93 | - |
|
| 94 | - /** |
|
| 95 | - * Handles attaching Message Templates to the Event on save. |
|
| 96 | - * |
|
| 97 | - * @param EE_Event $event EE event object |
|
| 98 | - * @param array $data The request data from the form |
|
| 99 | - * @return bool success or fail |
|
| 100 | - * @throws EE_Error |
|
| 101 | - */ |
|
| 102 | - public function attach_evt_message_templates($event, $data) |
|
| 103 | - { |
|
| 104 | - // first we remove all existing relations on the Event for message types. |
|
| 105 | - $event->_remove_relations('Message_Template_Group'); |
|
| 106 | - // now let's just loop through the selected templates and add relations! |
|
| 107 | - if (isset($data['event_message_templates_relation'])) { |
|
| 108 | - foreach ($data['event_message_templates_relation'] as $grp_ID) { |
|
| 109 | - $event->_add_relation_to($grp_ID, 'Message_Template_Group'); |
|
| 110 | - } |
|
| 111 | - } |
|
| 112 | - // now save |
|
| 113 | - return $event->save(); |
|
| 114 | - } |
|
| 115 | - |
|
| 116 | - |
|
| 117 | - /** |
|
| 118 | - * @param $event |
|
| 119 | - * @param $callback_args |
|
| 120 | - * @return string |
|
| 121 | - * @throws \EE_Error |
|
| 122 | - */ |
|
| 123 | - public function messages_metabox($event, $callback_args) |
|
| 124 | - { |
|
| 125 | - // let's get the active messengers (b/c messenger objects have the active message templates) |
|
| 126 | - // convert 'evt_id' to 'EVT_ID' |
|
| 127 | - $this->_req_data['EVT_ID'] = isset($this->_req_data['EVT_ID']) ? $this->_req_data['EVT_ID'] : null; |
|
| 128 | - $this->_req_data['EVT_ID'] = isset($this->_req_data['post']) && empty($this->_req_data['EVT_ID']) |
|
| 129 | - ? $this->_req_data['post'] |
|
| 130 | - : $this->_req_data['EVT_ID']; |
|
| 131 | - |
|
| 132 | - $this->_req_data['EVT_ID'] = empty($this->_req_data['EVT_ID']) && isset($this->_req_data['evt_id']) |
|
| 133 | - ? $this->_req_data['evt_id'] |
|
| 134 | - : $this->_req_data['EVT_ID']; |
|
| 135 | - /** @type EE_Message_Resource_Manager $message_resource_manager */ |
|
| 136 | - $message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager'); |
|
| 137 | - $active_messengers = $message_resource_manager->active_messengers(); |
|
| 138 | - $tabs = array(); |
|
| 139 | - |
|
| 140 | - // empty messengers? |
|
| 141 | - // Note message types will always have at least one available because every messenger has a default message type |
|
| 142 | - // associated with it (payment) if no other message types are selected. |
|
| 143 | - if (empty($active_messengers)) { |
|
| 144 | - $msg_activate_url = EE_Admin_Page::add_query_args_and_nonce( |
|
| 145 | - array('action' => 'settings'), |
|
| 146 | - EE_MSG_ADMIN_URL |
|
| 147 | - ); |
|
| 148 | - $error_msg = sprintf( |
|
| 149 | - esc_html__( |
|
| 150 | - 'There are no active messengers. So no notifications will go out for %1$sany%2$s events. You will want to %3$sActivate a Messenger%4$s.', |
|
| 151 | - 'event_espresso' |
|
| 152 | - ), |
|
| 153 | - '<strong>', |
|
| 154 | - '</strong>', |
|
| 155 | - '<a href="' . $msg_activate_url . '">', |
|
| 156 | - '</a>' |
|
| 157 | - ); |
|
| 158 | - $error_content = '<div class="error"><p>' . $error_msg . '</p></div>'; |
|
| 159 | - $internal_content = '<div id="messages-error"><p>' . $error_msg . '</p></div>'; |
|
| 160 | - |
|
| 161 | - echo $error_content; |
|
| 162 | - echo $internal_content; |
|
| 163 | - return ''; |
|
| 164 | - } |
|
| 165 | - |
|
| 166 | - $event_id = isset($this->_req_data['EVT_ID']) ? $this->_req_data['EVT_ID'] : null; |
|
| 167 | - // get content for active messengers |
|
| 168 | - foreach ($active_messengers as $name => $messenger) { |
|
| 169 | - // first check if there are any active message types for this messenger. |
|
| 170 | - $active_mts = $message_resource_manager->get_active_message_types_for_messenger($name); |
|
| 171 | - if (empty($active_mts)) { |
|
| 172 | - continue; |
|
| 173 | - } |
|
| 174 | - |
|
| 175 | - $tab_content = $messenger->get_messenger_admin_page_content( |
|
| 176 | - 'events', |
|
| 177 | - 'edit', |
|
| 178 | - array('event' => $event_id) |
|
| 179 | - ); |
|
| 180 | - |
|
| 181 | - if (! empty($tab_content)) { |
|
| 182 | - $tabs[ $name ] = $tab_content; |
|
| 183 | - } |
|
| 184 | - } |
|
| 185 | - |
|
| 186 | - |
|
| 187 | - // we want this to be tabbed content so let's use the EEH_Tabbed_Content::display helper. |
|
| 188 | - $tabbed_content = EEH_Tabbed_Content::display($tabs); |
|
| 189 | - if ($tabbed_content instanceof WP_Error) { |
|
| 190 | - $tabbed_content = $tabbed_content->get_error_message(); |
|
| 191 | - } |
|
| 192 | - |
|
| 193 | - $notices = ' |
|
| 15 | + /** |
|
| 16 | + * espresso_events_Messages_Hooks_Extend constructor. |
|
| 17 | + * |
|
| 18 | + * @param \EE_Admin_Page $admin_page |
|
| 19 | + */ |
|
| 20 | + public function __construct(EE_Admin_Page $admin_page) |
|
| 21 | + { |
|
| 22 | + /** |
|
| 23 | + * Add cap restriction ... metaboxes should not show if user does not have the ability to edit_custom_messages |
|
| 24 | + */ |
|
| 25 | + if (! EE_Registry::instance()->CAP->current_user_can( |
|
| 26 | + 'ee_edit_messages', |
|
| 27 | + 'messages_events_editor_metabox' |
|
| 28 | + )) { |
|
| 29 | + return; |
|
| 30 | + } |
|
| 31 | + add_filter( |
|
| 32 | + 'FHEE__Events_Admin_Page___insert_update_cpt_item__event_update_callbacks', |
|
| 33 | + array($this, 'caf_updates'), |
|
| 34 | + 10 |
|
| 35 | + ); |
|
| 36 | + add_action( |
|
| 37 | + 'AHEE__Extend_Events_Admin_Page___duplicate_event__after', |
|
| 38 | + array($this, 'duplicate_custom_message_settings'), |
|
| 39 | + 10, |
|
| 40 | + 2 |
|
| 41 | + ); |
|
| 42 | + parent::__construct($admin_page); |
|
| 43 | + } |
|
| 44 | + |
|
| 45 | + |
|
| 46 | + /** |
|
| 47 | + * extending the properties set in espresso_events_Messages_Hooks |
|
| 48 | + * |
|
| 49 | + * @access protected |
|
| 50 | + * @return void |
|
| 51 | + */ |
|
| 52 | + protected function _extend_properties() |
|
| 53 | + { |
|
| 54 | + define('EE_MSGS_EXTEND_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'messages/assets/'); |
|
| 55 | + $this->_ajax_func = array( |
|
| 56 | + 'ee_msgs_create_new_custom' => 'create_new_custom', |
|
| 57 | + ); |
|
| 58 | + $this->_metaboxes = array( |
|
| 59 | + 0 => array( |
|
| 60 | + 'page_route' => array('edit', 'create_new'), |
|
| 61 | + 'func' => 'messages_metabox', |
|
| 62 | + 'label' => esc_html__('Notifications', 'event_espresso'), |
|
| 63 | + 'priority' => 'high', |
|
| 64 | + ), |
|
| 65 | + ); |
|
| 66 | + |
|
| 67 | + // see explanation for layout in EE_Admin_Hooks |
|
| 68 | + $this->_scripts_styles = array( |
|
| 69 | + 'registers' => array( |
|
| 70 | + 'events_msg_admin' => array( |
|
| 71 | + 'url' => EE_MSGS_EXTEND_ASSETS_URL . 'events_messages_admin.js', |
|
| 72 | + 'depends' => array('ee-dialog', 'ee-parse-uri', 'ee-serialize-full-array'), |
|
| 73 | + ), |
|
| 74 | + 'events_msg_admin_css' => array( |
|
| 75 | + 'url' => EE_MSGS_EXTEND_ASSETS_URL . 'ee_msg_events_admin.css', |
|
| 76 | + 'type' => 'css', |
|
| 77 | + ), |
|
| 78 | + ), |
|
| 79 | + 'enqueues' => array( |
|
| 80 | + 'events_msg_admin' => array('edit', 'create_new'), |
|
| 81 | + 'events_msg_admin_css' => array('edit', 'create_new'), |
|
| 82 | + ), |
|
| 83 | + ); |
|
| 84 | + } |
|
| 85 | + |
|
| 86 | + |
|
| 87 | + public function caf_updates($update_callbacks) |
|
| 88 | + { |
|
| 89 | + $update_callbacks[] = array($this, 'attach_evt_message_templates'); |
|
| 90 | + return $update_callbacks; |
|
| 91 | + } |
|
| 92 | + |
|
| 93 | + |
|
| 94 | + /** |
|
| 95 | + * Handles attaching Message Templates to the Event on save. |
|
| 96 | + * |
|
| 97 | + * @param EE_Event $event EE event object |
|
| 98 | + * @param array $data The request data from the form |
|
| 99 | + * @return bool success or fail |
|
| 100 | + * @throws EE_Error |
|
| 101 | + */ |
|
| 102 | + public function attach_evt_message_templates($event, $data) |
|
| 103 | + { |
|
| 104 | + // first we remove all existing relations on the Event for message types. |
|
| 105 | + $event->_remove_relations('Message_Template_Group'); |
|
| 106 | + // now let's just loop through the selected templates and add relations! |
|
| 107 | + if (isset($data['event_message_templates_relation'])) { |
|
| 108 | + foreach ($data['event_message_templates_relation'] as $grp_ID) { |
|
| 109 | + $event->_add_relation_to($grp_ID, 'Message_Template_Group'); |
|
| 110 | + } |
|
| 111 | + } |
|
| 112 | + // now save |
|
| 113 | + return $event->save(); |
|
| 114 | + } |
|
| 115 | + |
|
| 116 | + |
|
| 117 | + /** |
|
| 118 | + * @param $event |
|
| 119 | + * @param $callback_args |
|
| 120 | + * @return string |
|
| 121 | + * @throws \EE_Error |
|
| 122 | + */ |
|
| 123 | + public function messages_metabox($event, $callback_args) |
|
| 124 | + { |
|
| 125 | + // let's get the active messengers (b/c messenger objects have the active message templates) |
|
| 126 | + // convert 'evt_id' to 'EVT_ID' |
|
| 127 | + $this->_req_data['EVT_ID'] = isset($this->_req_data['EVT_ID']) ? $this->_req_data['EVT_ID'] : null; |
|
| 128 | + $this->_req_data['EVT_ID'] = isset($this->_req_data['post']) && empty($this->_req_data['EVT_ID']) |
|
| 129 | + ? $this->_req_data['post'] |
|
| 130 | + : $this->_req_data['EVT_ID']; |
|
| 131 | + |
|
| 132 | + $this->_req_data['EVT_ID'] = empty($this->_req_data['EVT_ID']) && isset($this->_req_data['evt_id']) |
|
| 133 | + ? $this->_req_data['evt_id'] |
|
| 134 | + : $this->_req_data['EVT_ID']; |
|
| 135 | + /** @type EE_Message_Resource_Manager $message_resource_manager */ |
|
| 136 | + $message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager'); |
|
| 137 | + $active_messengers = $message_resource_manager->active_messengers(); |
|
| 138 | + $tabs = array(); |
|
| 139 | + |
|
| 140 | + // empty messengers? |
|
| 141 | + // Note message types will always have at least one available because every messenger has a default message type |
|
| 142 | + // associated with it (payment) if no other message types are selected. |
|
| 143 | + if (empty($active_messengers)) { |
|
| 144 | + $msg_activate_url = EE_Admin_Page::add_query_args_and_nonce( |
|
| 145 | + array('action' => 'settings'), |
|
| 146 | + EE_MSG_ADMIN_URL |
|
| 147 | + ); |
|
| 148 | + $error_msg = sprintf( |
|
| 149 | + esc_html__( |
|
| 150 | + 'There are no active messengers. So no notifications will go out for %1$sany%2$s events. You will want to %3$sActivate a Messenger%4$s.', |
|
| 151 | + 'event_espresso' |
|
| 152 | + ), |
|
| 153 | + '<strong>', |
|
| 154 | + '</strong>', |
|
| 155 | + '<a href="' . $msg_activate_url . '">', |
|
| 156 | + '</a>' |
|
| 157 | + ); |
|
| 158 | + $error_content = '<div class="error"><p>' . $error_msg . '</p></div>'; |
|
| 159 | + $internal_content = '<div id="messages-error"><p>' . $error_msg . '</p></div>'; |
|
| 160 | + |
|
| 161 | + echo $error_content; |
|
| 162 | + echo $internal_content; |
|
| 163 | + return ''; |
|
| 164 | + } |
|
| 165 | + |
|
| 166 | + $event_id = isset($this->_req_data['EVT_ID']) ? $this->_req_data['EVT_ID'] : null; |
|
| 167 | + // get content for active messengers |
|
| 168 | + foreach ($active_messengers as $name => $messenger) { |
|
| 169 | + // first check if there are any active message types for this messenger. |
|
| 170 | + $active_mts = $message_resource_manager->get_active_message_types_for_messenger($name); |
|
| 171 | + if (empty($active_mts)) { |
|
| 172 | + continue; |
|
| 173 | + } |
|
| 174 | + |
|
| 175 | + $tab_content = $messenger->get_messenger_admin_page_content( |
|
| 176 | + 'events', |
|
| 177 | + 'edit', |
|
| 178 | + array('event' => $event_id) |
|
| 179 | + ); |
|
| 180 | + |
|
| 181 | + if (! empty($tab_content)) { |
|
| 182 | + $tabs[ $name ] = $tab_content; |
|
| 183 | + } |
|
| 184 | + } |
|
| 185 | + |
|
| 186 | + |
|
| 187 | + // we want this to be tabbed content so let's use the EEH_Tabbed_Content::display helper. |
|
| 188 | + $tabbed_content = EEH_Tabbed_Content::display($tabs); |
|
| 189 | + if ($tabbed_content instanceof WP_Error) { |
|
| 190 | + $tabbed_content = $tabbed_content->get_error_message(); |
|
| 191 | + } |
|
| 192 | + |
|
| 193 | + $notices = ' |
|
| 194 | 194 | <div id="espresso-ajax-loading" class="ajax-loader-grey"> |
| 195 | 195 | <span class="ee-spinner ee-spin"></span><span class="hidden">' |
| 196 | - . esc_html__('loading...', 'event_espresso') |
|
| 197 | - . '</span> |
|
| 196 | + . esc_html__('loading...', 'event_espresso') |
|
| 197 | + . '</span> |
|
| 198 | 198 | </div> |
| 199 | 199 | <div class="ee-notices"></div>'; |
| 200 | 200 | |
| 201 | - if (defined('DOING_AJAX')) { |
|
| 202 | - return $tabbed_content; |
|
| 203 | - } |
|
| 204 | - |
|
| 205 | - do_action('AHEE__espresso_events_Messages_Hooks_Extend__messages_metabox__before_content'); |
|
| 206 | - echo $notices . '<div class="messages-tabs-content">' . $tabbed_content . '</div>'; |
|
| 207 | - do_action('AHEE__espresso_events_Messages_Hooks_Extend__messages_metabox__after_content'); |
|
| 208 | - } |
|
| 209 | - |
|
| 210 | - |
|
| 211 | - /** |
|
| 212 | - * Ajax callback for ee_msgs_create_new_custom ajax request. |
|
| 213 | - * Takes incoming GRP_ID and name and description values from ajax request |
|
| 214 | - * to create a new custom template based off of the incoming GRP_ID. |
|
| 215 | - * |
|
| 216 | - * @access public |
|
| 217 | - * @return string either an html string will be returned or a success message |
|
| 218 | - * @throws EE_Error |
|
| 219 | - */ |
|
| 220 | - public function create_new_custom() |
|
| 221 | - { |
|
| 222 | - if (! EE_Registry::instance()->CAP->current_user_can('ee_edit_messages', 'create_new_custom_ajax')) { |
|
| 223 | - wp_die(__('You don\'t have privileges to do this action', 'event_espresso')); |
|
| 224 | - } |
|
| 225 | - |
|
| 226 | - // let's clean up the _POST global a bit for downstream usage of name and description. |
|
| 227 | - $_POST['templateName'] = ! empty($this->_req_data['custom_template_args']['MTP_name']) |
|
| 228 | - ? $this->_req_data['custom_template_args']['MTP_name'] |
|
| 229 | - : ''; |
|
| 230 | - $_POST['templateDescription'] = ! empty($this->_req_data['custom_template_args']['MTP_description']) |
|
| 231 | - ? $this->_req_data['custom_template_args']['MTP_description'] |
|
| 232 | - : ''; |
|
| 233 | - |
|
| 234 | - |
|
| 235 | - // set EE_Admin_Page object (see method details in EE_Admin_Hooks parent |
|
| 236 | - $this->_set_page_object(); |
|
| 237 | - |
|
| 238 | - // is this a template switch if so EE_Admin_Page child needs this object |
|
| 239 | - $this->_page_object->set_hook_object($this); |
|
| 240 | - |
|
| 241 | - $this->_page_object->add_message_template( |
|
| 242 | - $this->_req_data['messageType'], |
|
| 243 | - $this->_req_data['messenger'], |
|
| 244 | - $this->_req_data['group_ID'] |
|
| 245 | - ); |
|
| 246 | - } |
|
| 247 | - |
|
| 248 | - |
|
| 249 | - public function create_new_admin_footer() |
|
| 250 | - { |
|
| 251 | - $this->edit_admin_footer(); |
|
| 252 | - } |
|
| 253 | - |
|
| 254 | - |
|
| 255 | - /** |
|
| 256 | - * This is the dynamic method for this class |
|
| 257 | - * that will end up hooking into the 'admin_footer' hook on the 'edit_event' route in the events page. |
|
| 258 | - * |
|
| 259 | - * @return string |
|
| 260 | - * @throws DomainException |
|
| 261 | - */ |
|
| 262 | - public function edit_admin_footer() |
|
| 263 | - { |
|
| 264 | - EEH_Template::display_template( |
|
| 265 | - EE_CORE_CAF_ADMIN_EXTEND . 'messages/templates/create_custom_template_form.template.php' |
|
| 266 | - ); |
|
| 267 | - } |
|
| 268 | - |
|
| 269 | - |
|
| 270 | - /** |
|
| 271 | - * Callback for AHEE__Extend_Events_Admin_Page___duplicate_event__after hook used to ensure new events duplicate |
|
| 272 | - * the assigned custom message templates. |
|
| 273 | - * |
|
| 274 | - * @param EE_Event $new_event |
|
| 275 | - * @param EE_Event $original_event |
|
| 276 | - * @throws EE_Error |
|
| 277 | - */ |
|
| 278 | - public function duplicate_custom_message_settings(EE_Event $new_event, EE_Event $original_event) |
|
| 279 | - { |
|
| 280 | - $message_template_groups = $original_event->get_many_related('Message_Template_Group'); |
|
| 281 | - foreach ($message_template_groups as $message_template_group) { |
|
| 282 | - $new_event->_add_relation_to($message_template_group, 'Message_Template_Group'); |
|
| 283 | - } |
|
| 284 | - // save new event |
|
| 285 | - $new_event->save(); |
|
| 286 | - } |
|
| 201 | + if (defined('DOING_AJAX')) { |
|
| 202 | + return $tabbed_content; |
|
| 203 | + } |
|
| 204 | + |
|
| 205 | + do_action('AHEE__espresso_events_Messages_Hooks_Extend__messages_metabox__before_content'); |
|
| 206 | + echo $notices . '<div class="messages-tabs-content">' . $tabbed_content . '</div>'; |
|
| 207 | + do_action('AHEE__espresso_events_Messages_Hooks_Extend__messages_metabox__after_content'); |
|
| 208 | + } |
|
| 209 | + |
|
| 210 | + |
|
| 211 | + /** |
|
| 212 | + * Ajax callback for ee_msgs_create_new_custom ajax request. |
|
| 213 | + * Takes incoming GRP_ID and name and description values from ajax request |
|
| 214 | + * to create a new custom template based off of the incoming GRP_ID. |
|
| 215 | + * |
|
| 216 | + * @access public |
|
| 217 | + * @return string either an html string will be returned or a success message |
|
| 218 | + * @throws EE_Error |
|
| 219 | + */ |
|
| 220 | + public function create_new_custom() |
|
| 221 | + { |
|
| 222 | + if (! EE_Registry::instance()->CAP->current_user_can('ee_edit_messages', 'create_new_custom_ajax')) { |
|
| 223 | + wp_die(__('You don\'t have privileges to do this action', 'event_espresso')); |
|
| 224 | + } |
|
| 225 | + |
|
| 226 | + // let's clean up the _POST global a bit for downstream usage of name and description. |
|
| 227 | + $_POST['templateName'] = ! empty($this->_req_data['custom_template_args']['MTP_name']) |
|
| 228 | + ? $this->_req_data['custom_template_args']['MTP_name'] |
|
| 229 | + : ''; |
|
| 230 | + $_POST['templateDescription'] = ! empty($this->_req_data['custom_template_args']['MTP_description']) |
|
| 231 | + ? $this->_req_data['custom_template_args']['MTP_description'] |
|
| 232 | + : ''; |
|
| 233 | + |
|
| 234 | + |
|
| 235 | + // set EE_Admin_Page object (see method details in EE_Admin_Hooks parent |
|
| 236 | + $this->_set_page_object(); |
|
| 237 | + |
|
| 238 | + // is this a template switch if so EE_Admin_Page child needs this object |
|
| 239 | + $this->_page_object->set_hook_object($this); |
|
| 240 | + |
|
| 241 | + $this->_page_object->add_message_template( |
|
| 242 | + $this->_req_data['messageType'], |
|
| 243 | + $this->_req_data['messenger'], |
|
| 244 | + $this->_req_data['group_ID'] |
|
| 245 | + ); |
|
| 246 | + } |
|
| 247 | + |
|
| 248 | + |
|
| 249 | + public function create_new_admin_footer() |
|
| 250 | + { |
|
| 251 | + $this->edit_admin_footer(); |
|
| 252 | + } |
|
| 253 | + |
|
| 254 | + |
|
| 255 | + /** |
|
| 256 | + * This is the dynamic method for this class |
|
| 257 | + * that will end up hooking into the 'admin_footer' hook on the 'edit_event' route in the events page. |
|
| 258 | + * |
|
| 259 | + * @return string |
|
| 260 | + * @throws DomainException |
|
| 261 | + */ |
|
| 262 | + public function edit_admin_footer() |
|
| 263 | + { |
|
| 264 | + EEH_Template::display_template( |
|
| 265 | + EE_CORE_CAF_ADMIN_EXTEND . 'messages/templates/create_custom_template_form.template.php' |
|
| 266 | + ); |
|
| 267 | + } |
|
| 268 | + |
|
| 269 | + |
|
| 270 | + /** |
|
| 271 | + * Callback for AHEE__Extend_Events_Admin_Page___duplicate_event__after hook used to ensure new events duplicate |
|
| 272 | + * the assigned custom message templates. |
|
| 273 | + * |
|
| 274 | + * @param EE_Event $new_event |
|
| 275 | + * @param EE_Event $original_event |
|
| 276 | + * @throws EE_Error |
|
| 277 | + */ |
|
| 278 | + public function duplicate_custom_message_settings(EE_Event $new_event, EE_Event $original_event) |
|
| 279 | + { |
|
| 280 | + $message_template_groups = $original_event->get_many_related('Message_Template_Group'); |
|
| 281 | + foreach ($message_template_groups as $message_template_group) { |
|
| 282 | + $new_event->_add_relation_to($message_template_group, 'Message_Template_Group'); |
|
| 283 | + } |
|
| 284 | + // save new event |
|
| 285 | + $new_event->save(); |
|
| 286 | + } |
|
| 287 | 287 | } |
@@ -22,7 +22,7 @@ discard block |
||
| 22 | 22 | /** |
| 23 | 23 | * Add cap restriction ... metaboxes should not show if user does not have the ability to edit_custom_messages |
| 24 | 24 | */ |
| 25 | - if (! EE_Registry::instance()->CAP->current_user_can( |
|
| 25 | + if ( ! EE_Registry::instance()->CAP->current_user_can( |
|
| 26 | 26 | 'ee_edit_messages', |
| 27 | 27 | 'messages_events_editor_metabox' |
| 28 | 28 | )) { |
@@ -51,7 +51,7 @@ discard block |
||
| 51 | 51 | */ |
| 52 | 52 | protected function _extend_properties() |
| 53 | 53 | { |
| 54 | - define('EE_MSGS_EXTEND_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'messages/assets/'); |
|
| 54 | + define('EE_MSGS_EXTEND_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL.'messages/assets/'); |
|
| 55 | 55 | $this->_ajax_func = array( |
| 56 | 56 | 'ee_msgs_create_new_custom' => 'create_new_custom', |
| 57 | 57 | ); |
@@ -68,11 +68,11 @@ discard block |
||
| 68 | 68 | $this->_scripts_styles = array( |
| 69 | 69 | 'registers' => array( |
| 70 | 70 | 'events_msg_admin' => array( |
| 71 | - 'url' => EE_MSGS_EXTEND_ASSETS_URL . 'events_messages_admin.js', |
|
| 71 | + 'url' => EE_MSGS_EXTEND_ASSETS_URL.'events_messages_admin.js', |
|
| 72 | 72 | 'depends' => array('ee-dialog', 'ee-parse-uri', 'ee-serialize-full-array'), |
| 73 | 73 | ), |
| 74 | 74 | 'events_msg_admin_css' => array( |
| 75 | - 'url' => EE_MSGS_EXTEND_ASSETS_URL . 'ee_msg_events_admin.css', |
|
| 75 | + 'url' => EE_MSGS_EXTEND_ASSETS_URL.'ee_msg_events_admin.css', |
|
| 76 | 76 | 'type' => 'css', |
| 77 | 77 | ), |
| 78 | 78 | ), |
@@ -152,11 +152,11 @@ discard block |
||
| 152 | 152 | ), |
| 153 | 153 | '<strong>', |
| 154 | 154 | '</strong>', |
| 155 | - '<a href="' . $msg_activate_url . '">', |
|
| 155 | + '<a href="'.$msg_activate_url.'">', |
|
| 156 | 156 | '</a>' |
| 157 | 157 | ); |
| 158 | - $error_content = '<div class="error"><p>' . $error_msg . '</p></div>'; |
|
| 159 | - $internal_content = '<div id="messages-error"><p>' . $error_msg . '</p></div>'; |
|
| 158 | + $error_content = '<div class="error"><p>'.$error_msg.'</p></div>'; |
|
| 159 | + $internal_content = '<div id="messages-error"><p>'.$error_msg.'</p></div>'; |
|
| 160 | 160 | |
| 161 | 161 | echo $error_content; |
| 162 | 162 | echo $internal_content; |
@@ -178,8 +178,8 @@ discard block |
||
| 178 | 178 | array('event' => $event_id) |
| 179 | 179 | ); |
| 180 | 180 | |
| 181 | - if (! empty($tab_content)) { |
|
| 182 | - $tabs[ $name ] = $tab_content; |
|
| 181 | + if ( ! empty($tab_content)) { |
|
| 182 | + $tabs[$name] = $tab_content; |
|
| 183 | 183 | } |
| 184 | 184 | } |
| 185 | 185 | |
@@ -203,7 +203,7 @@ discard block |
||
| 203 | 203 | } |
| 204 | 204 | |
| 205 | 205 | do_action('AHEE__espresso_events_Messages_Hooks_Extend__messages_metabox__before_content'); |
| 206 | - echo $notices . '<div class="messages-tabs-content">' . $tabbed_content . '</div>'; |
|
| 206 | + echo $notices.'<div class="messages-tabs-content">'.$tabbed_content.'</div>'; |
|
| 207 | 207 | do_action('AHEE__espresso_events_Messages_Hooks_Extend__messages_metabox__after_content'); |
| 208 | 208 | } |
| 209 | 209 | |
@@ -219,7 +219,7 @@ discard block |
||
| 219 | 219 | */ |
| 220 | 220 | public function create_new_custom() |
| 221 | 221 | { |
| 222 | - if (! EE_Registry::instance()->CAP->current_user_can('ee_edit_messages', 'create_new_custom_ajax')) { |
|
| 222 | + if ( ! EE_Registry::instance()->CAP->current_user_can('ee_edit_messages', 'create_new_custom_ajax')) { |
|
| 223 | 223 | wp_die(__('You don\'t have privileges to do this action', 'event_espresso')); |
| 224 | 224 | } |
| 225 | 225 | |
@@ -262,7 +262,7 @@ discard block |
||
| 262 | 262 | public function edit_admin_footer() |
| 263 | 263 | { |
| 264 | 264 | EEH_Template::display_template( |
| 265 | - EE_CORE_CAF_ADMIN_EXTEND . 'messages/templates/create_custom_template_form.template.php' |
|
| 265 | + EE_CORE_CAF_ADMIN_EXTEND.'messages/templates/create_custom_template_form.template.php' |
|
| 266 | 266 | ); |
| 267 | 267 | } |
| 268 | 268 | |