@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
3 | - exit( 'No direct script access allowed' ); |
|
2 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
3 | + exit('No direct script access allowed'); |
|
4 | 4 | } |
5 | 5 | /** |
6 | 6 | * |
@@ -15,7 +15,7 @@ discard block |
||
15 | 15 | * @since 4.6.0 |
16 | 16 | * |
17 | 17 | */ |
18 | -class EE_Default_Where_Conditions{ |
|
18 | +class EE_Default_Where_Conditions { |
|
19 | 19 | |
20 | 20 | /** |
21 | 21 | * This const can be used in EE_Default_Where_Conditions values, and at the time of querying it will be |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | * onto any field names |
49 | 49 | * @param array $custom_where_conditions |
50 | 50 | */ |
51 | - public function __construct( $custom_where_conditions = array() ) { |
|
51 | + public function __construct($custom_where_conditions = array()) { |
|
52 | 52 | $this->_where_conditions_provided = $custom_where_conditions; |
53 | 53 | } |
54 | 54 | |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | * for querying of the model. |
60 | 60 | * @param EEM_Base $model |
61 | 61 | */ |
62 | - function _finalize_construct(EEM_Base $model){ |
|
62 | + function _finalize_construct(EEM_Base $model) { |
|
63 | 63 | $this->_model = $model; |
64 | 64 | } |
65 | 65 | |
@@ -80,8 +80,8 @@ discard block |
||
80 | 80 | * @param string $model_relation_chain |
81 | 81 | * @return array like what's expected in EEM_Base::get_all()'s $query_params[0] |
82 | 82 | */ |
83 | - function get_default_where_conditions( $model_relation_chain = '' ){ |
|
84 | - return $this->prepare_where_conditions_for_querying( array_merge( $this->_get_default_where_conditions(), $this->get_where_conditions_provided() ), $model_relation_chain ); |
|
83 | + function get_default_where_conditions($model_relation_chain = '') { |
|
84 | + return $this->prepare_where_conditions_for_querying(array_merge($this->_get_default_where_conditions(), $this->get_where_conditions_provided()), $model_relation_chain); |
|
85 | 85 | } |
86 | 86 | |
87 | 87 | |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | * Adding model relation chains is handled by the public method get_default_where_conditions |
92 | 92 | * @return array |
93 | 93 | */ |
94 | - protected function _get_default_where_conditions(){ |
|
94 | + protected function _get_default_where_conditions() { |
|
95 | 95 | return array(); |
96 | 96 | } |
97 | 97 | |
@@ -105,36 +105,36 @@ discard block |
||
105 | 105 | * @return array |
106 | 106 | * @throws \EE_Error |
107 | 107 | */ |
108 | - public function prepare_where_conditions_for_querying( $where_conditions, $model_relation_chain ) { |
|
108 | + public function prepare_where_conditions_for_querying($where_conditions, $model_relation_chain) { |
|
109 | 109 | $where_conditions_with_model_relation_chain_prefixes = array(); |
110 | - if ( ! is_array( $where_conditions ) ) { |
|
110 | + if ( ! is_array($where_conditions)) { |
|
111 | 111 | $where_conditions = array(); |
112 | 112 | } |
113 | - foreach ( $where_conditions as $key => $value ) { |
|
113 | + foreach ($where_conditions as $key => $value) { |
|
114 | 114 | if ( |
115 | - in_array( $key, array( 'OR', 'AND', 'NOT' ) ) |
|
116 | - || strpos( $key, 'OR*' ) !== false |
|
117 | - || strpos( $key, 'AND*' ) !== false |
|
118 | - || strpos( $key, 'NOT*' ) !== false |
|
115 | + in_array($key, array('OR', 'AND', 'NOT')) |
|
116 | + || strpos($key, 'OR*') !== false |
|
117 | + || strpos($key, 'AND*') !== false |
|
118 | + || strpos($key, 'NOT*') !== false |
|
119 | 119 | ) { |
120 | - $where_conditions_with_model_relation_chain_prefixes[ $key ] = $this->prepare_where_conditions_for_querying( |
|
120 | + $where_conditions_with_model_relation_chain_prefixes[$key] = $this->prepare_where_conditions_for_querying( |
|
121 | 121 | $value, |
122 | 122 | $model_relation_chain |
123 | 123 | ); |
124 | 124 | } else { |
125 | 125 | if ( |
126 | 126 | $model_relation_chain != '' |
127 | - && $model_relation_chain[ strlen( $model_relation_chain ) - 1 ] != '.' |
|
127 | + && $model_relation_chain[strlen($model_relation_chain) - 1] != '.' |
|
128 | 128 | ) { |
129 | - $model_relation_chain = $model_relation_chain . "."; |
|
129 | + $model_relation_chain = $model_relation_chain."."; |
|
130 | 130 | } |
131 | 131 | //check for the current user id place holder, and if present change it |
132 | - if ( $value === self::current_user_placeholder ) { |
|
132 | + if ($value === self::current_user_placeholder) { |
|
133 | 133 | $value = get_current_user_id(); |
134 | 134 | } |
135 | 135 | //check for user field placeholder |
136 | - if ( $key == self::user_field_name_placeholder ) { |
|
137 | - if ( ! $this->_model->wp_user_field_name() ) { |
|
136 | + if ($key == self::user_field_name_placeholder) { |
|
137 | + if ( ! $this->_model->wp_user_field_name()) { |
|
138 | 138 | throw new EE_Error( |
139 | 139 | sprintf( |
140 | 140 | __( |
@@ -147,7 +147,7 @@ discard block |
||
147 | 147 | } |
148 | 148 | $key = $this->_model->wp_user_field_name(); |
149 | 149 | } |
150 | - $where_conditions_with_model_relation_chain_prefixes[ $model_relation_chain . $key ] = $value; |
|
150 | + $where_conditions_with_model_relation_chain_prefixes[$model_relation_chain.$key] = $value; |
|
151 | 151 | } |
152 | 152 | } |
153 | 153 | return $where_conditions_with_model_relation_chain_prefixes; |
@@ -5,7 +5,7 @@ |
||
5 | 5 | /** |
6 | 6 | * |
7 | 7 | * Class EE_Default_Where_Conditions |
8 | - * |
|
8 | + * |
|
9 | 9 | * Strategy to be used for getting default where conditions for EEM_Base children. |
10 | 10 | * Should be initialized and set on construction of model |
11 | 11 | * |
@@ -1,7 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
4 | - exit( 'No direct script access allowed' ); |
|
3 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
4 | + exit('No direct script access allowed'); |
|
5 | 5 | } |
6 | 6 | |
7 | 7 | |
@@ -53,10 +53,10 @@ discard block |
||
53 | 53 | * @param \EE_Message_Resource_Manager $Message_Resource_Manager |
54 | 54 | * @return \EE_Message_Factory instance |
55 | 55 | */ |
56 | - public static function instance( EE_Message_Resource_Manager $Message_Resource_Manager ) { |
|
56 | + public static function instance(EE_Message_Resource_Manager $Message_Resource_Manager) { |
|
57 | 57 | // check if class object is instantiated, and instantiated properly |
58 | - if ( ! self::$_instance instanceof EE_Message_Factory ) { |
|
59 | - self::$_instance = new EE_Message_Factory( $Message_Resource_Manager ); |
|
58 | + if ( ! self::$_instance instanceof EE_Message_Factory) { |
|
59 | + self::$_instance = new EE_Message_Factory($Message_Resource_Manager); |
|
60 | 60 | } |
61 | 61 | return self::$_instance; |
62 | 62 | } |
@@ -68,10 +68,10 @@ discard block |
||
68 | 68 | * @param array $props_n_values |
69 | 69 | * @return mixed |
70 | 70 | */ |
71 | - public static function create( $props_n_values = array() ) { |
|
71 | + public static function create($props_n_values = array()) { |
|
72 | 72 | /** @type EE_Message_Factory $Message_Factory */ |
73 | - $Message_Factory = EE_Registry::instance()->load_lib( 'Message_Factory' ); |
|
74 | - return $Message_Factory->_create( $props_n_values ); |
|
73 | + $Message_Factory = EE_Registry::instance()->load_lib('Message_Factory'); |
|
74 | + return $Message_Factory->_create($props_n_values); |
|
75 | 75 | } |
76 | 76 | |
77 | 77 | |
@@ -82,10 +82,10 @@ discard block |
||
82 | 82 | * @return \EE_Message |
83 | 83 | * @throws \EE_Error |
84 | 84 | */ |
85 | - public static function set_messenger_and_message_type( EE_Message $message ) { |
|
85 | + public static function set_messenger_and_message_type(EE_Message $message) { |
|
86 | 86 | /** @type EE_Message_Factory $Message_Factory */ |
87 | - $Message_Factory = EE_Registry::instance()->load_lib( 'Message_Factory' ); |
|
88 | - return $Message_Factory->_set_messenger_and_message_type( $message ); |
|
87 | + $Message_Factory = EE_Registry::instance()->load_lib('Message_Factory'); |
|
88 | + return $Message_Factory->_set_messenger_and_message_type($message); |
|
89 | 89 | } |
90 | 90 | |
91 | 91 | |
@@ -96,10 +96,10 @@ discard block |
||
96 | 96 | * @return \EE_Message |
97 | 97 | * @throws \EE_Error |
98 | 98 | */ |
99 | - public static function set_messenger( EE_Message $message ) { |
|
99 | + public static function set_messenger(EE_Message $message) { |
|
100 | 100 | /** @type EE_Message_Factory $Message_Factory */ |
101 | - $Message_Factory = EE_Registry::instance()->load_lib( 'Message_Factory' ); |
|
102 | - return $Message_Factory->_set_messenger( $message ); |
|
101 | + $Message_Factory = EE_Registry::instance()->load_lib('Message_Factory'); |
|
102 | + return $Message_Factory->_set_messenger($message); |
|
103 | 103 | } |
104 | 104 | |
105 | 105 | |
@@ -110,10 +110,10 @@ discard block |
||
110 | 110 | * @return \EE_Message |
111 | 111 | * @throws \EE_Error |
112 | 112 | */ |
113 | - public static function set_message_type( EE_Message $message ) { |
|
113 | + public static function set_message_type(EE_Message $message) { |
|
114 | 114 | /** @type EE_Message_Factory $Message_Factory */ |
115 | - $Message_Factory = EE_Registry::instance()->load_lib( 'Message_Factory' ); |
|
116 | - return $Message_Factory->_set_message_type( $message ); |
|
115 | + $Message_Factory = EE_Registry::instance()->load_lib('Message_Factory'); |
|
116 | + return $Message_Factory->_set_message_type($message); |
|
117 | 117 | } |
118 | 118 | |
119 | 119 | |
@@ -124,15 +124,15 @@ discard block |
||
124 | 124 | * @return \EE_Message |
125 | 125 | * @throws \EE_Error |
126 | 126 | */ |
127 | - protected function _create( $props_n_values = array() ) { |
|
127 | + protected function _create($props_n_values = array()) { |
|
128 | 128 | $new_instance = false; |
129 | - if ( ! empty( $props_n_values['MSG_ID'] ) ) { |
|
130 | - $message = EE_Message::new_instance_from_db( $props_n_values ); |
|
129 | + if ( ! empty($props_n_values['MSG_ID'])) { |
|
130 | + $message = EE_Message::new_instance_from_db($props_n_values); |
|
131 | 131 | } else { |
132 | - $message = EE_Message::new_instance( $props_n_values ); |
|
132 | + $message = EE_Message::new_instance($props_n_values); |
|
133 | 133 | $new_instance = true; |
134 | 134 | } |
135 | - return $this->_set_messenger_and_message_type( $message, $new_instance ); |
|
135 | + return $this->_set_messenger_and_message_type($message, $new_instance); |
|
136 | 136 | } |
137 | 137 | |
138 | 138 | |
@@ -144,9 +144,9 @@ discard block |
||
144 | 144 | * @return \EE_Message |
145 | 145 | * @throws \EE_Error |
146 | 146 | */ |
147 | - protected function _set_messenger_and_message_type( EE_Message $message, $new_instance = false ) { |
|
148 | - $message = $this->_set_messenger( $message ); |
|
149 | - $message = $this->_set_message_type( $message, $new_instance ); |
|
147 | + protected function _set_messenger_and_message_type(EE_Message $message, $new_instance = false) { |
|
148 | + $message = $this->_set_messenger($message); |
|
149 | + $message = $this->_set_message_type($message, $new_instance); |
|
150 | 150 | return $message; |
151 | 151 | } |
152 | 152 | |
@@ -158,10 +158,10 @@ discard block |
||
158 | 158 | * @return \EE_Message |
159 | 159 | * @throws \EE_Error |
160 | 160 | */ |
161 | - protected function _set_messenger( EE_Message $message ) { |
|
162 | - $messenger = $this->_message_resource_manager->get_messenger( $message->messenger() ); |
|
163 | - if ( $messenger instanceof EE_messenger ) { |
|
164 | - $message->set_messenger_object( $messenger ); |
|
161 | + protected function _set_messenger(EE_Message $message) { |
|
162 | + $messenger = $this->_message_resource_manager->get_messenger($message->messenger()); |
|
163 | + if ($messenger instanceof EE_messenger) { |
|
164 | + $message->set_messenger_object($messenger); |
|
165 | 165 | } |
166 | 166 | return $message; |
167 | 167 | } |
@@ -175,10 +175,10 @@ discard block |
||
175 | 175 | * @return \EE_Message |
176 | 176 | * @throws \EE_Error |
177 | 177 | */ |
178 | - protected function _set_message_type( EE_Message $message, $new_instance = false ) { |
|
179 | - $message_type = $this->_message_resource_manager->get_message_type( $message->message_type() ); |
|
180 | - if ( $message_type instanceof EE_message_type ) { |
|
181 | - $message->set_message_type_object( $message_type, $new_instance ); |
|
178 | + protected function _set_message_type(EE_Message $message, $new_instance = false) { |
|
179 | + $message_type = $this->_message_resource_manager->get_message_type($message->message_type()); |
|
180 | + if ($message_type instanceof EE_message_type) { |
|
181 | + $message->set_message_type_object($message_type, $new_instance); |
|
182 | 182 | } |
183 | 183 | return $message; |
184 | 184 | } |
@@ -36,9 +36,9 @@ discard block |
||
36 | 36 | * This is then used to populate the properties in here. |
37 | 37 | * @param EE_Message_Resource_Manager $message_resource_manager |
38 | 38 | */ |
39 | - public function __construct( $token, $sending_messenger_slug = 'html', EE_Message_Resource_Manager $message_resource_manager ) { |
|
39 | + public function __construct($token, $sending_messenger_slug = 'html', EE_Message_Resource_Manager $message_resource_manager) { |
|
40 | 40 | $this->token = $token; |
41 | - $this->_sending_messenger = $this->_set_sending_messenger( $sending_messenger_slug, $message_resource_manager ); |
|
41 | + $this->_sending_messenger = $this->_set_sending_messenger($sending_messenger_slug, $message_resource_manager); |
|
42 | 42 | $this->_message = $this->_generate_message(); |
43 | 43 | //set params for parent from the message object |
44 | 44 | parent::__construct( |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | $sending_messenger_slug, |
62 | 62 | EE_Message_Resource_Manager $message_resource_manager |
63 | 63 | ) { |
64 | - $sending_messenger = $message_resource_manager->get_active_messenger( $sending_messenger_slug ); |
|
64 | + $sending_messenger = $message_resource_manager->get_active_messenger($sending_messenger_slug); |
|
65 | 65 | return $sending_messenger instanceof EE_messenger ? $sending_messenger : $sending_messenger_slug; |
66 | 66 | } |
67 | 67 | |
@@ -83,27 +83,27 @@ discard block |
||
83 | 83 | * @return EE_Message |
84 | 84 | * @throws \EE_Error |
85 | 85 | */ |
86 | - protected function _generate_message( $properties = array() ) { |
|
86 | + protected function _generate_message($properties = array()) { |
|
87 | 87 | // a message was generated immediately but the parent class will call this again |
88 | - if ( $this->_message instanceof EE_Message ) { |
|
88 | + if ($this->_message instanceof EE_Message) { |
|
89 | 89 | return $this->_message; |
90 | 90 | } |
91 | - $message = EEM_Message::instance()->get_one_by_token( $this->token ); |
|
92 | - if ( ! $message instanceof EE_Message ) { |
|
91 | + $message = EEM_Message::instance()->get_one_by_token($this->token); |
|
92 | + if ( ! $message instanceof EE_Message) { |
|
93 | 93 | throw new EE_Error( |
94 | 94 | sprintf( |
95 | - __( 'Unable to retrieve generated message from DB using given token: "%1$s"', 'event_espresso' ), |
|
95 | + __('Unable to retrieve generated message from DB using given token: "%1$s"', 'event_espresso'), |
|
96 | 96 | $this->token |
97 | 97 | ) |
98 | 98 | ); |
99 | 99 | } |
100 | - $message->set_STS_ID( EEM_Message::status_idle ); |
|
100 | + $message->set_STS_ID(EEM_Message::status_idle); |
|
101 | 101 | |
102 | - if ( ! $this->_sending_messenger instanceof EE_messenger ) { |
|
103 | - $message->set_STS_ID( EEM_Message::status_failed ); |
|
102 | + if ( ! $this->_sending_messenger instanceof EE_messenger) { |
|
103 | + $message->set_STS_ID(EEM_Message::status_failed); |
|
104 | 104 | $message->set_error_message( |
105 | 105 | sprintf( |
106 | - __( 'Unable to send message because the "%1$s" messenger is not active or not installed', 'event_espresso' ), |
|
106 | + __('Unable to send message because the "%1$s" messenger is not active or not installed', 'event_espresso'), |
|
107 | 107 | $this->_sending_messenger |
108 | 108 | ) |
109 | 109 | ); |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if (!defined('EVENT_ESPRESSO_VERSION')) |
|
2 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) |
|
3 | 3 | exit('No direct script access allowed'); |
4 | 4 | |
5 | 5 | |
@@ -32,13 +32,13 @@ discard block |
||
32 | 32 | * |
33 | 33 | * @return bool |
34 | 34 | */ |
35 | - public function add( $message, $info = null ) { |
|
36 | - $attached = parent::add( $message ); |
|
35 | + public function add($message, $info = null) { |
|
36 | + $attached = parent::add($message); |
|
37 | 37 | //ensure $info is an array if not already |
38 | 38 | $info = $info === null ? $info = array() : (array) $info; |
39 | - $data = $this->_init_data( $info, $attached, $message ); |
|
40 | - if ( $attached ) { |
|
41 | - $this->set_info( $message, $data ); |
|
39 | + $data = $this->_init_data($info, $attached, $message); |
|
40 | + if ($attached) { |
|
41 | + $this->set_info($message, $data); |
|
42 | 42 | } |
43 | 43 | return $attached; |
44 | 44 | } |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | * @param EE_Message $message |
52 | 52 | * @return array |
53 | 53 | */ |
54 | - protected function _init_data( $info, $attached, $message ) { |
|
54 | + protected function _init_data($info, $attached, $message) { |
|
55 | 55 | $data = array( |
56 | 56 | 'test_send' => false, |
57 | 57 | 'preview' => false, |
@@ -60,20 +60,20 @@ discard block |
||
60 | 60 | 'MSG_generation_data' => array() |
61 | 61 | ) |
62 | 62 | ); |
63 | - if ( isset( $info['preview'] ) ) { |
|
63 | + if (isset($info['preview'])) { |
|
64 | 64 | $data['preview'] = $info['preview']; |
65 | - unset( $info['preview'] ); |
|
65 | + unset($info['preview']); |
|
66 | 66 | } |
67 | - if ( isset( $info['test_send'] ) ) { |
|
67 | + if (isset($info['test_send'])) { |
|
68 | 68 | $data['test_send'] = $info['test_send']; |
69 | - unset( $info['test_send'] ); |
|
69 | + unset($info['test_send']); |
|
70 | 70 | } |
71 | - if ( isset( $info['data_handler_class_name'] ) ) { |
|
71 | + if (isset($info['data_handler_class_name'])) { |
|
72 | 72 | $data['data_handler_class_name'] = $info['data_handler_class_name']; |
73 | - unset( $info['data_handler_class_name'] ); |
|
73 | + unset($info['data_handler_class_name']); |
|
74 | 74 | } |
75 | - if ( $attached && $message->STS_ID() === EEM_Message::status_incomplete ) { |
|
76 | - $generation_data = isset( $info['MSG_generation_data'] ) ? $info['MSG_generation_data'] : array(); |
|
75 | + if ($attached && $message->STS_ID() === EEM_Message::status_incomplete) { |
|
76 | + $generation_data = isset($info['MSG_generation_data']) ? $info['MSG_generation_data'] : array(); |
|
77 | 77 | //if data isn't in $info...let's see if its available via the message object |
78 | 78 | $generation_data = ! $generation_data ? $message->get_generation_data() : $generation_data; |
79 | 79 | //still empty then let's just use info |
@@ -96,19 +96,19 @@ discard block |
||
96 | 96 | */ |
97 | 97 | public function saveAll() { |
98 | 98 | $this->rewind(); |
99 | - $save_tracking = array( 'updated' => 0, 'notupdated' => 0, 'errors' => array() ); |
|
99 | + $save_tracking = array('updated' => 0, 'notupdated' => 0, 'errors' => array()); |
|
100 | 100 | |
101 | 101 | //exit early if there is nothing to save. |
102 | - if ( ! $this->count() > 0 ) { |
|
102 | + if ( ! $this->count() > 0) { |
|
103 | 103 | return $save_tracking; |
104 | 104 | } |
105 | 105 | |
106 | - while( $this->valid() ) { |
|
106 | + while ($this->valid()) { |
|
107 | 107 | |
108 | 108 | $saved = $this->current()->save(); |
109 | - if ( $saved === false ) { |
|
109 | + if ($saved === false) { |
|
110 | 110 | $save_tracking['errors'][] = $this->current()->MSG_token(); |
111 | - } elseif ( $saved ) { |
|
111 | + } elseif ($saved) { |
|
112 | 112 | $save_tracking['updated']++; |
113 | 113 | } else { |
114 | 114 | $save_tracking['notupdated']++; |
@@ -132,10 +132,10 @@ discard block |
||
132 | 132 | * @param string $token Token. |
133 | 133 | * @return EE_Message | null |
134 | 134 | */ |
135 | - public function getMessageByToken( $token ) { |
|
135 | + public function getMessageByToken($token) { |
|
136 | 136 | $this->rewind(); |
137 | - while( $this->valid() ) { |
|
138 | - if ( $this->current()->MSG_token() === $token ) { |
|
137 | + while ($this->valid()) { |
|
138 | + if ($this->current()->MSG_token() === $token) { |
|
139 | 139 | $message = $this->current(); |
140 | 140 | $this->rewind(); |
141 | 141 | return $message; |
@@ -156,11 +156,11 @@ discard block |
||
156 | 156 | */ |
157 | 157 | public function get_generation_data() { |
158 | 158 | //first verify we're at a valid iterator point. |
159 | - if ( ! $this->valid() ) { |
|
159 | + if ( ! $this->valid()) { |
|
160 | 160 | return array(); |
161 | 161 | } |
162 | 162 | $info = $this->getInfo(); |
163 | - return isset( $info['data'] ) && isset( $info['data']['MSG_generation_data'] ) ? $info['data']['MSG_generation_data'] : array(); |
|
163 | + return isset($info['data']) && isset($info['data']['MSG_generation_data']) ? $info['data']['MSG_generation_data'] : array(); |
|
164 | 164 | } |
165 | 165 | |
166 | 166 | |
@@ -171,11 +171,11 @@ discard block |
||
171 | 171 | * @return string |
172 | 172 | */ |
173 | 173 | public function get_data_handler() { |
174 | - if ( ! $this->valid() ) { |
|
174 | + if ( ! $this->valid()) { |
|
175 | 175 | return ''; |
176 | 176 | } |
177 | 177 | $info = $this->getInfo(); |
178 | - return isset( $info['data_handler_class_name'] ) ? $info['data_handler_class_name'] : ''; |
|
178 | + return isset($info['data_handler_class_name']) ? $info['data_handler_class_name'] : ''; |
|
179 | 179 | } |
180 | 180 | |
181 | 181 | |
@@ -185,7 +185,7 @@ discard block |
||
185 | 185 | * @return bool |
186 | 186 | */ |
187 | 187 | public function is_preview() { |
188 | - if ( ! $this->valid() ) { |
|
188 | + if ( ! $this->valid()) { |
|
189 | 189 | return false; |
190 | 190 | } |
191 | 191 | $info = $this->getInfo(); |
@@ -198,7 +198,7 @@ discard block |
||
198 | 198 | * @return bool |
199 | 199 | */ |
200 | 200 | public function is_test_send() { |
201 | - if ( ! $this->valid() ) { |
|
201 | + if ( ! $this->valid()) { |
|
202 | 202 | return false; |
203 | 203 | } |
204 | 204 | $info = $this->getInfo(); |
@@ -213,16 +213,16 @@ discard block |
||
213 | 213 | * data is attached for later retrieval (batch generation). |
214 | 214 | */ |
215 | 215 | protected function _maybe_persist_attached_data() { |
216 | - if ( ! $this->valid() ) { |
|
216 | + if ( ! $this->valid()) { |
|
217 | 217 | return; |
218 | 218 | } |
219 | 219 | |
220 | 220 | $info = $this->getInfo(); |
221 | - $data_handler_class_name = isset( $info['data_handler_class_name'] ) ? $info['data_handler_class_name'] : ''; |
|
222 | - $data = isset( $info['data'] ) && isset( $info['data']['MSG_generation_data'] ) ? $info['data']['MSG_generation_data'] : array(); |
|
223 | - if ( $data && $this->current()->STS_ID() === EEM_Message::status_incomplete ) { |
|
224 | - $this->current()->set_generation_data( $data ); |
|
225 | - $this->current()->set_field_or_extra_meta( 'data_handler_class_name', $data_handler_class_name ); |
|
221 | + $data_handler_class_name = isset($info['data_handler_class_name']) ? $info['data_handler_class_name'] : ''; |
|
222 | + $data = isset($info['data']) && isset($info['data']['MSG_generation_data']) ? $info['data']['MSG_generation_data'] : array(); |
|
223 | + if ($data && $this->current()->STS_ID() === EEM_Message::status_incomplete) { |
|
224 | + $this->current()->set_generation_data($data); |
|
225 | + $this->current()->set_field_or_extra_meta('data_handler_class_name', $data_handler_class_name); |
|
226 | 226 | } |
227 | 227 | } |
228 | 228 | |
@@ -235,15 +235,15 @@ discard block |
||
235 | 235 | * @param array $status the optional status(es) that will also be filtered by when priority matches. |
236 | 236 | * @return int count of messages in the queue matching the conditions. |
237 | 237 | */ |
238 | - public function count_by_priority_and_status( $priority, $status = array() ) { |
|
239 | - if ( ! empty( $status ) ) { |
|
240 | - $status = is_array( $status ) ? $status : array( $status ); |
|
238 | + public function count_by_priority_and_status($priority, $status = array()) { |
|
239 | + if ( ! empty($status)) { |
|
240 | + $status = is_array($status) ? $status : array($status); |
|
241 | 241 | } |
242 | 242 | |
243 | 243 | $count = 0; |
244 | 244 | $this->rewind(); |
245 | - while ( $this->valid() ) { |
|
246 | - if ( $this->current()->priority() === $priority && ( ( $status && in_array( $this->current()->STS_ID(), $status ) ) || ! $status ) ) { |
|
245 | + while ($this->valid()) { |
|
246 | + if ($this->current()->priority() === $priority && (($status && in_array($this->current()->STS_ID(), $status)) || ! $status)) { |
|
247 | 247 | $count++; |
248 | 248 | } |
249 | 249 | $this->next(); |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
3 | - exit( 'No direct script access allowed' ); |
|
2 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
3 | + exit('No direct script access allowed'); |
|
4 | 4 | } |
5 | 5 | |
6 | 6 | |
@@ -28,14 +28,14 @@ discard block |
||
28 | 28 | * indexing the template by key. |
29 | 29 | * @return bool |
30 | 30 | */ |
31 | - public function add( $message_template_group, $EVT_ID = null ) { |
|
32 | - if ( $message_template_group instanceof $this->interface ) { |
|
33 | - $data[ 'key' ] = $this->get_key( |
|
31 | + public function add($message_template_group, $EVT_ID = null) { |
|
32 | + if ($message_template_group instanceof $this->interface) { |
|
33 | + $data['key'] = $this->get_key( |
|
34 | 34 | $message_template_group->messenger(), |
35 | 35 | $message_template_group->message_type(), |
36 | 36 | $EVT_ID |
37 | 37 | ); |
38 | - return parent::add( $message_template_group, $data ); |
|
38 | + return parent::add($message_template_group, $data); |
|
39 | 39 | } |
40 | 40 | return false; |
41 | 41 | } |
@@ -48,10 +48,10 @@ discard block |
||
48 | 48 | * @param $GRP_ID |
49 | 49 | * @return EE_Message_Template_Group | null |
50 | 50 | */ |
51 | - public function get_by_ID( $GRP_ID ) { |
|
51 | + public function get_by_ID($GRP_ID) { |
|
52 | 52 | $this->rewind(); |
53 | - while ( $this->valid() ) { |
|
54 | - if ( $this->current()->ID() === $GRP_ID ) { |
|
53 | + while ($this->valid()) { |
|
54 | + if ($this->current()->ID() === $GRP_ID) { |
|
55 | 55 | $grp = $this->current(); |
56 | 56 | $this->rewind(); |
57 | 57 | return $grp; |
@@ -73,8 +73,8 @@ discard block |
||
73 | 73 | * |
74 | 74 | * @return string |
75 | 75 | */ |
76 | - public function get_key( $messenger, $message_type, $EVT_ID = 0 ) { |
|
77 | - return md5( $messenger.$message_type.$EVT_ID ); |
|
76 | + public function get_key($messenger, $message_type, $EVT_ID = 0) { |
|
77 | + return md5($messenger.$message_type.$EVT_ID); |
|
78 | 78 | } |
79 | 79 | |
80 | 80 | |
@@ -86,11 +86,11 @@ discard block |
||
86 | 86 | * |
87 | 87 | * @return null|EE_Message_Template_Group |
88 | 88 | */ |
89 | - public function get_by_key( $key ) { |
|
89 | + public function get_by_key($key) { |
|
90 | 90 | $this->rewind(); |
91 | - while ( $this->valid() ) { |
|
91 | + while ($this->valid()) { |
|
92 | 92 | $data = $this->getInfo(); |
93 | - if ( isset( $data['key'] ) && $data['key'] === $key ) { |
|
93 | + if (isset($data['key']) && $data['key'] === $key) { |
|
94 | 94 | $handler = $this->current(); |
95 | 95 | $this->rewind(); |
96 | 96 | return $handler; |
@@ -45,7 +45,7 @@ |
||
45 | 45 | |
46 | 46 | /** |
47 | 47 | * This retrieves any EE_Message_Template_Group in the repo by its ID. |
48 | - * @param $GRP_ID |
|
48 | + * @param integer $GRP_ID |
|
49 | 49 | * @return EE_Message_Template_Group | null |
50 | 50 | */ |
51 | 51 | public function get_by_ID( $GRP_ID ) { |
@@ -25,12 +25,12 @@ discard block |
||
25 | 25 | * @param EE_Messages_Queue $queue |
26 | 26 | * @param string $custom_subject Used if a custom subject is desired for the generated aggregate EE_Message object |
27 | 27 | */ |
28 | - public function __construct( $messenger_name, $message_type_name, EE_Messages_Queue $queue, $custom_subject = '' ) { |
|
28 | + public function __construct($messenger_name, $message_type_name, EE_Messages_Queue $queue, $custom_subject = '') { |
|
29 | 29 | $this->queue = $queue; |
30 | - parent::__construct( $messenger_name, $message_type_name, array(), '', false, EEM_Message::status_idle ); |
|
31 | - if ( $this->valid() ) { |
|
32 | - $this->_message->set_content( $this->_get_content() ); |
|
33 | - $this->_message->set_subject( $this->_get_subject( $custom_subject ) ); |
|
30 | + parent::__construct($messenger_name, $message_type_name, array(), '', false, EEM_Message::status_idle); |
|
31 | + if ($this->valid()) { |
|
32 | + $this->_message->set_content($this->_get_content()); |
|
33 | + $this->_message->set_subject($this->_get_subject($custom_subject)); |
|
34 | 34 | } |
35 | 35 | } |
36 | 36 | |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | protected function _get_content() { |
45 | 45 | $content = ''; |
46 | 46 | $this->queue->get_queue()->rewind(); |
47 | - while ( $this->queue->get_queue()->valid() ) { |
|
47 | + while ($this->queue->get_queue()->valid()) { |
|
48 | 48 | $content .= $this->queue->get_queue()->current()->content(); |
49 | 49 | $this->queue->get_queue()->next(); |
50 | 50 | } |
@@ -58,15 +58,15 @@ discard block |
||
58 | 58 | * |
59 | 59 | * @return string |
60 | 60 | */ |
61 | - protected function _get_subject( $custom_subject = '' ) { |
|
62 | - if ( ! empty( $custom_subject ) ) { |
|
61 | + protected function _get_subject($custom_subject = '') { |
|
62 | + if ( ! empty($custom_subject)) { |
|
63 | 63 | return $custom_subject; |
64 | 64 | } |
65 | 65 | $this->queue->get_queue()->rewind(); |
66 | 66 | $count_of_items = $this->queue->get_queue()->count(); |
67 | 67 | |
68 | 68 | //if $count of items in queue == 1, then let's just return the subject for that item. |
69 | - if ( $count_of_items === 1 ) { |
|
69 | + if ($count_of_items === 1) { |
|
70 | 70 | return $this->queue->get_queue()->current()->subject(); |
71 | 71 | } |
72 | 72 |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
3 | - exit( 'No direct script access allowed' ); |
|
2 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
3 | + exit('No direct script access allowed'); |
|
4 | 4 | } |
5 | 5 | |
6 | 6 | |
@@ -31,8 +31,8 @@ discard block |
||
31 | 31 | * |
32 | 32 | * @param EE_Message_Type_Collection $message_types |
33 | 33 | */ |
34 | - public function __construct( EE_Message_Type_Collection $message_types ) { |
|
35 | - $this->set_message_type_collection( $message_types ); |
|
34 | + public function __construct(EE_Message_Type_Collection $message_types) { |
|
35 | + $this->set_message_type_collection($message_types); |
|
36 | 36 | } |
37 | 37 | |
38 | 38 | |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | /** |
50 | 50 | * @param mixed $message_types |
51 | 51 | */ |
52 | - public function set_message_type_collection( EE_Message_Type_Collection $message_types ) { |
|
52 | + public function set_message_type_collection(EE_Message_Type_Collection $message_types) { |
|
53 | 53 | $this->_message_type_collection = $message_types; |
54 | 54 | } |
55 | 55 | |
@@ -62,41 +62,41 @@ discard block |
||
62 | 62 | * @param string $folder |
63 | 63 | * @throws \EE_Error |
64 | 64 | */ |
65 | - public function load_message_types_from_folder( $folder = '' ) { |
|
65 | + public function load_message_types_from_folder($folder = '') { |
|
66 | 66 | //make sure autoloaders are set (fail-safe) |
67 | 67 | EED_Messages::set_autoloaders(); |
68 | - $folder = ! empty( $folder ) ? $folder : EE_LIBRARIES . 'messages' . DS . 'message_type'; |
|
69 | - $folder .= $folder[ strlen( $folder ) - 1 ] != DS ? DS : ''; |
|
68 | + $folder = ! empty($folder) ? $folder : EE_LIBRARIES.'messages'.DS.'message_type'; |
|
69 | + $folder .= $folder[strlen($folder) - 1] != DS ? DS : ''; |
|
70 | 70 | // get all the files in that folder that end in ".class.php |
71 | 71 | $filepaths = apply_filters( |
72 | 72 | 'FHEE__EE_messages__get_installed__messagetype_files', |
73 | - glob( $folder . '*.class.php' ) |
|
73 | + glob($folder.'*.class.php') |
|
74 | 74 | ); |
75 | - if ( empty( $filepaths ) ) { |
|
75 | + if (empty($filepaths)) { |
|
76 | 76 | return; |
77 | 77 | } |
78 | - foreach ( (array) $filepaths as $file_path ) { |
|
78 | + foreach ((array) $filepaths as $file_path) { |
|
79 | 79 | // extract filename from path |
80 | - $file_path = basename( $file_path ); |
|
80 | + $file_path = basename($file_path); |
|
81 | 81 | // now remove any file extensions |
82 | - $message_type_class_name = substr( $file_path, 0, strpos( $file_path, '.' ) ); |
|
82 | + $message_type_class_name = substr($file_path, 0, strpos($file_path, '.')); |
|
83 | 83 | |
84 | 84 | //if this class name doesn't represent a message type class, then we just skip. |
85 | - if ( strpos( strtolower( $message_type_class_name ), 'message_type' ) === false ) { |
|
85 | + if (strpos(strtolower($message_type_class_name), 'message_type') === false) { |
|
86 | 86 | continue; |
87 | 87 | } |
88 | 88 | |
89 | - if ( ! class_exists( $message_type_class_name ) ) { |
|
89 | + if ( ! class_exists($message_type_class_name)) { |
|
90 | 90 | throw new EE_Error( |
91 | 91 | sprintf( |
92 | - __( 'The "%1$s" message type class can\'t be loaded from %2$s. Likely there is a typo in the class name or the file name.', 'event_espresso' ), |
|
92 | + __('The "%1$s" message type class can\'t be loaded from %2$s. Likely there is a typo in the class name or the file name.', 'event_espresso'), |
|
93 | 93 | $message_type_class_name, |
94 | 94 | $file_path |
95 | 95 | ) |
96 | 96 | ); |
97 | 97 | } |
98 | 98 | |
99 | - $this->_load_message_type( new $message_type_class_name ); |
|
99 | + $this->_load_message_type(new $message_type_class_name); |
|
100 | 100 | } |
101 | 101 | } |
102 | 102 | |
@@ -106,8 +106,8 @@ discard block |
||
106 | 106 | * @param EE_message_type $message_type |
107 | 107 | * @return bool |
108 | 108 | */ |
109 | - protected function _load_message_type( EE_message_type $message_type ) { |
|
110 | - if ( $this->message_type_collection()->has_by_name( $message_type->name ) ) { |
|
109 | + protected function _load_message_type(EE_message_type $message_type) { |
|
110 | + if ($this->message_type_collection()->has_by_name($message_type->name)) { |
|
111 | 111 | return true; |
112 | 112 | } |
113 | 113 | return $this->message_type_collection()->add( |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if (!defined('EVENT_ESPRESSO_VERSION') ) |
|
2 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) |
|
3 | 3 | exit('NO direct script access allowed'); |
4 | 4 | |
5 | 5 | /** |
@@ -184,9 +184,9 @@ discard block |
||
184 | 184 | * @access protected |
185 | 185 | * @param string $messenger |
186 | 186 | */ |
187 | - protected function _set_existing_admin_settings( $messenger = '' ) { |
|
187 | + protected function _set_existing_admin_settings($messenger = '') { |
|
188 | 188 | /** @var EE_Message_Resource_Manager $Message_Resource_Manager */ |
189 | - $Message_Resource_Manager = EE_Registry::instance()->load_lib( 'Message_Resource_Manager' ); |
|
189 | + $Message_Resource_Manager = EE_Registry::instance()->load_lib('Message_Resource_Manager'); |
|
190 | 190 | $active_messengers = $Message_Resource_Manager->get_active_messengers_option(); |
191 | 191 | $settings_to_use = $active_messengers; |
192 | 192 | |
@@ -194,14 +194,14 @@ discard block |
||
194 | 194 | * This determines what will be used for the getting the settings. |
195 | 195 | */ |
196 | 196 | if ( |
197 | - ! empty( $messenger ) |
|
198 | - && $Message_Resource_Manager->is_message_type_active_for_messenger( $messenger, $this->name ) |
|
197 | + ! empty($messenger) |
|
198 | + && $Message_Resource_Manager->is_message_type_active_for_messenger($messenger, $this->name) |
|
199 | 199 | ) { |
200 | - $settings_to_use = $active_messengers[ $messenger ]['settings'][ $messenger . '-message_types' ]; |
|
200 | + $settings_to_use = $active_messengers[$messenger]['settings'][$messenger.'-message_types']; |
|
201 | 201 | } |
202 | 202 | |
203 | - $this->_existing_admin_settings = isset( $settings_to_use[ $this->name ]['settings'] ) |
|
204 | - ? $settings_to_use[ $this->name ]['settings'] |
|
203 | + $this->_existing_admin_settings = isset($settings_to_use[$this->name]['settings']) |
|
204 | + ? $settings_to_use[$this->name]['settings'] |
|
205 | 205 | : null; |
206 | 206 | } |
207 | 207 | |
@@ -218,12 +218,12 @@ discard block |
||
218 | 218 | * @param string $messenger |
219 | 219 | * @return array settings |
220 | 220 | */ |
221 | - public function get_existing_admin_settings( $messenger = '' ) { |
|
221 | + public function get_existing_admin_settings($messenger = '') { |
|
222 | 222 | // if admin_settings property empty lets try setting it. |
223 | - if ( method_exists($this, '_set_existing_admin_settings') && empty( $this->_existing_admin_settings ) ) { |
|
224 | - $this->_set_existing_admin_settings( $messenger ); |
|
223 | + if (method_exists($this, '_set_existing_admin_settings') && empty($this->_existing_admin_settings)) { |
|
224 | + $this->_set_existing_admin_settings($messenger); |
|
225 | 225 | } |
226 | - return property_exists( $this, '_existing_admin_settings' ) |
|
226 | + return property_exists($this, '_existing_admin_settings') |
|
227 | 227 | ? $this->_existing_admin_settings |
228 | 228 | : null; |
229 | 229 | } |
@@ -239,12 +239,12 @@ discard block |
||
239 | 239 | */ |
240 | 240 | public function get_valid_shortcodes() { |
241 | 241 | $valid_shortcodes = apply_filters( |
242 | - 'FHEE__' . get_class( $this ) . '__get_valid_shortcodes', |
|
242 | + 'FHEE__'.get_class($this).'__get_valid_shortcodes', |
|
243 | 243 | $this->_valid_shortcodes, |
244 | 244 | $this |
245 | 245 | ); |
246 | 246 | //The below filter applies to ALL messengers and message types so use with care! |
247 | - $valid_shortcodes = apply_filters( 'FHEE__EE_Messages_Base__get_valid_shortcodes', $valid_shortcodes, $this ); |
|
247 | + $valid_shortcodes = apply_filters('FHEE__EE_Messages_Base__get_valid_shortcodes', $valid_shortcodes, $this); |
|
248 | 248 | return $valid_shortcodes; |
249 | 249 | } |
250 | 250 | |
@@ -278,23 +278,23 @@ discard block |
||
278 | 278 | * @access protected |
279 | 279 | * @return string $content for page. |
280 | 280 | */ |
281 | - protected function _get_admin_page_content( $page, $action, $extra, $actives ) { |
|
281 | + protected function _get_admin_page_content($page, $action, $extra, $actives) { |
|
282 | 282 | //we can also further refine the context by action (if present). |
283 | - if ( !empty($action) ) { |
|
284 | - $page = $page . '_' . $action; |
|
283 | + if ( ! empty($action)) { |
|
284 | + $page = $page.'_'.$action; |
|
285 | 285 | } |
286 | 286 | |
287 | - if ( !isset( $this->admin_registered_pages[$page]) ){ |
|
287 | + if ( ! isset($this->admin_registered_pages[$page])) { |
|
288 | 288 | // todo: a place to throw an exception? |
289 | 289 | // We need to indicate there is no registered page so this function is not being called correctly. |
290 | 290 | return false; |
291 | 291 | } |
292 | 292 | //k made it here so let's call the method |
293 | 293 | $content = call_user_func_array( |
294 | - array( $this, '_get_admin_content_' . $page ), |
|
295 | - array( $actives, $extra ) |
|
294 | + array($this, '_get_admin_content_'.$page), |
|
295 | + array($actives, $extra) |
|
296 | 296 | ); |
297 | - if ( $content === false ) { |
|
297 | + if ($content === false) { |
|
298 | 298 | // todo this needs to be an exception once we've got exceptions in place. |
299 | 299 | return false; |
300 | 300 | } |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if (!defined('EVENT_ESPRESSO_VERSION')) |
|
2 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) |
|
3 | 3 | exit('No direct script access allowed'); |
4 | 4 | |
5 | 5 | |
@@ -26,10 +26,10 @@ discard block |
||
26 | 26 | * classname to create an alternative index for retrieving data_handlers. |
27 | 27 | * @return bool |
28 | 28 | */ |
29 | - public function add( $data_handler, $data = null) { |
|
29 | + public function add($data_handler, $data = null) { |
|
30 | 30 | $data = $data === null ? array() : (array) $data; |
31 | - $info['key'] = $this->get_key( get_class( $data_handler ), $data ); |
|
32 | - return parent::add( $data_handler, $info ); |
|
31 | + $info['key'] = $this->get_key(get_class($data_handler), $data); |
|
32 | + return parent::add($data_handler, $info); |
|
33 | 33 | } |
34 | 34 | |
35 | 35 | |
@@ -44,8 +44,8 @@ discard block |
||
44 | 44 | * |
45 | 45 | * @return string md5 hash using provided info. |
46 | 46 | */ |
47 | - public function get_key( $classname, $data ) { |
|
48 | - return md5( $classname . print_r( $data, true ) ); |
|
47 | + public function get_key($classname, $data) { |
|
48 | + return md5($classname.print_r($data, true)); |
|
49 | 49 | } |
50 | 50 | |
51 | 51 | |
@@ -61,11 +61,11 @@ discard block |
||
61 | 61 | * |
62 | 62 | * @return null|EE_Messages_incoming_data |
63 | 63 | */ |
64 | - public function get_by_key( $key ) { |
|
64 | + public function get_by_key($key) { |
|
65 | 65 | $this->rewind(); |
66 | - while( $this->valid() ) { |
|
66 | + while ($this->valid()) { |
|
67 | 67 | $data = $this->getInfo(); |
68 | - if ( isset( $data['key'] ) && $data['key'] === $key ) { |
|
68 | + if (isset($data['key']) && $data['key'] === $key) { |
|
69 | 69 | $handler = $this->current(); |
70 | 70 | $this->rewind(); |
71 | 71 | return $handler; |