@@ -21,471 +21,471 @@ |
||
21 | 21 | class Collection extends SplObjectStorage implements CollectionInterface |
22 | 22 | { |
23 | 23 | |
24 | - /** |
|
25 | - * a unique string for identifying this collection |
|
26 | - * |
|
27 | - * @type string $collection_identifier |
|
28 | - */ |
|
29 | - protected $collection_identifier; |
|
30 | - |
|
31 | - /** |
|
32 | - * an interface (or class) name to be used for restricting the type of objects added to the storage |
|
33 | - * this should be set from within the child class constructor |
|
34 | - * |
|
35 | - * @type string $interface |
|
36 | - */ |
|
37 | - protected $collection_interface; |
|
38 | - |
|
39 | - |
|
40 | - /** |
|
41 | - * Collection constructor |
|
42 | - * |
|
43 | - * @param string $collection_interface |
|
44 | - * @throws InvalidInterfaceException |
|
45 | - */ |
|
46 | - public function __construct($collection_interface) |
|
47 | - { |
|
48 | - $this->setCollectionInterface($collection_interface); |
|
49 | - $this->setCollectionIdentifier(); |
|
50 | - } |
|
51 | - |
|
52 | - |
|
53 | - /** |
|
54 | - * @return string |
|
55 | - */ |
|
56 | - public function collectionIdentifier() |
|
57 | - { |
|
58 | - return $this->collection_identifier; |
|
59 | - } |
|
60 | - |
|
61 | - |
|
62 | - /** |
|
63 | - * creates a very readable unique 9 character identifier like: CF2-532-DAC |
|
64 | - * and appends it to the non-qualified class name, ex: ThingCollection-CF2-532-DAC |
|
65 | - * |
|
66 | - * @return void |
|
67 | - */ |
|
68 | - protected function setCollectionIdentifier() |
|
69 | - { |
|
70 | - // hash a few collection details |
|
71 | - $identifier = md5(spl_object_hash($this) . $this->collection_interface . time()); |
|
72 | - // grab a few characters from the start, middle, and end of the hash |
|
73 | - $id = array(); |
|
74 | - for ($x = 0; $x < 19; $x += 9) { |
|
75 | - $id[] = substr($identifier, $x, 3); |
|
76 | - } |
|
77 | - $identifier = basename(str_replace('\\', '/', get_class($this))); |
|
78 | - $identifier .= '-' . strtoupper(implode('-', $id)); |
|
79 | - $this->collection_identifier = $identifier; |
|
80 | - } |
|
81 | - |
|
82 | - |
|
83 | - /** |
|
84 | - * setCollectionInterface |
|
85 | - * |
|
86 | - * @access protected |
|
87 | - * @param string $collection_interface |
|
88 | - * @throws \EventEspresso\core\exceptions\InvalidInterfaceException |
|
89 | - */ |
|
90 | - protected function setCollectionInterface($collection_interface) |
|
91 | - { |
|
92 | - if (! (interface_exists($collection_interface) || class_exists($collection_interface))) { |
|
93 | - throw new InvalidInterfaceException($collection_interface); |
|
94 | - } |
|
95 | - $this->collection_interface = $collection_interface; |
|
96 | - } |
|
97 | - |
|
98 | - |
|
99 | - /** |
|
100 | - * add |
|
101 | - * attaches an object to the Collection |
|
102 | - * and sets any supplied data associated with the current iterator entry |
|
103 | - * by calling EE_Object_Collection::set_identifier() |
|
104 | - * |
|
105 | - * @access public |
|
106 | - * @param $object |
|
107 | - * @param mixed $identifier |
|
108 | - * @return bool |
|
109 | - * @throws InvalidEntityException |
|
110 | - * @throws DuplicateCollectionIdentifierException |
|
111 | - */ |
|
112 | - public function add($object, $identifier = null) |
|
113 | - { |
|
114 | - if (! $object instanceof $this->collection_interface) { |
|
115 | - throw new InvalidEntityException($object, $this->collection_interface); |
|
116 | - } |
|
117 | - if ($this->contains($object)) { |
|
118 | - throw new DuplicateCollectionIdentifierException($identifier); |
|
119 | - } |
|
120 | - $this->attach($object); |
|
121 | - $this->setIdentifier($object, $identifier); |
|
122 | - return $this->contains($object); |
|
123 | - } |
|
124 | - |
|
125 | - |
|
126 | - /** |
|
127 | - * setIdentifier |
|
128 | - * Sets the data associated with an object in the Collection |
|
129 | - * if no $identifier is supplied, then the spl_object_hash() is used |
|
130 | - * |
|
131 | - * @access public |
|
132 | - * @param $object |
|
133 | - * @param mixed $identifier |
|
134 | - * @return bool |
|
135 | - */ |
|
136 | - public function setIdentifier($object, $identifier = null) |
|
137 | - { |
|
138 | - $identifier = ! empty($identifier) |
|
139 | - ? $identifier |
|
140 | - : spl_object_hash($object); |
|
141 | - $this->rewind(); |
|
142 | - while ($this->valid()) { |
|
143 | - if ($object === $this->current()) { |
|
144 | - $this->setInfo($identifier); |
|
145 | - $this->rewind(); |
|
146 | - return true; |
|
147 | - } |
|
148 | - $this->next(); |
|
149 | - } |
|
150 | - return false; |
|
151 | - } |
|
152 | - |
|
153 | - |
|
154 | - /** |
|
155 | - * get |
|
156 | - * finds and returns an object in the Collection based on the identifier that was set using addObject() |
|
157 | - * PLZ NOTE: the pointer is reset to the beginning of the collection before returning |
|
158 | - * |
|
159 | - * @access public |
|
160 | - * @param mixed $identifier |
|
161 | - * @return mixed |
|
162 | - */ |
|
163 | - public function get($identifier) |
|
164 | - { |
|
165 | - $this->rewind(); |
|
166 | - while ($this->valid()) { |
|
167 | - if ($identifier === $this->getInfo()) { |
|
168 | - $object = $this->current(); |
|
169 | - $this->rewind(); |
|
170 | - return $object; |
|
171 | - } |
|
172 | - $this->next(); |
|
173 | - } |
|
174 | - return null; |
|
175 | - } |
|
176 | - |
|
177 | - |
|
178 | - /** |
|
179 | - * has |
|
180 | - * returns TRUE or FALSE |
|
181 | - * depending on whether the object is within the Collection |
|
182 | - * based on the supplied $identifier |
|
183 | - * |
|
184 | - * @access public |
|
185 | - * @param mixed $identifier |
|
186 | - * @return bool |
|
187 | - */ |
|
188 | - public function has($identifier) |
|
189 | - { |
|
190 | - $this->rewind(); |
|
191 | - while ($this->valid()) { |
|
192 | - if ($identifier === $this->getInfo()) { |
|
193 | - $this->rewind(); |
|
194 | - return true; |
|
195 | - } |
|
196 | - $this->next(); |
|
197 | - } |
|
198 | - return false; |
|
199 | - } |
|
200 | - |
|
201 | - |
|
202 | - /** |
|
203 | - * hasObject |
|
204 | - * returns TRUE or FALSE depending on whether the supplied object is within the Collection |
|
205 | - * |
|
206 | - * @access public |
|
207 | - * @param $object |
|
208 | - * @return bool |
|
209 | - */ |
|
210 | - public function hasObject($object) |
|
211 | - { |
|
212 | - return $this->contains($object); |
|
213 | - } |
|
214 | - |
|
215 | - |
|
216 | - /** |
|
217 | - * hasObjects |
|
218 | - * returns true if there are objects within the Collection, and false if it is empty |
|
219 | - * |
|
220 | - * @access public |
|
221 | - * @return bool |
|
222 | - */ |
|
223 | - public function hasObjects() |
|
224 | - { |
|
225 | - return $this->count() !== 0; |
|
226 | - } |
|
227 | - |
|
228 | - |
|
229 | - /** |
|
230 | - * isEmpty |
|
231 | - * returns true if there are no objects within the Collection, and false if there are |
|
232 | - * |
|
233 | - * @access public |
|
234 | - * @return bool |
|
235 | - */ |
|
236 | - public function isEmpty() |
|
237 | - { |
|
238 | - return $this->count() === 0; |
|
239 | - } |
|
240 | - |
|
241 | - |
|
242 | - /** |
|
243 | - * remove |
|
244 | - * detaches an object from the Collection |
|
245 | - * |
|
246 | - * @access public |
|
247 | - * @param $object |
|
248 | - * @return bool |
|
249 | - */ |
|
250 | - public function remove($object) |
|
251 | - { |
|
252 | - $this->detach($object); |
|
253 | - return true; |
|
254 | - } |
|
255 | - |
|
256 | - |
|
257 | - /** |
|
258 | - * setCurrent |
|
259 | - * advances pointer to the object whose identifier matches that which was provided |
|
260 | - * |
|
261 | - * @access public |
|
262 | - * @param mixed $identifier |
|
263 | - * @return boolean |
|
264 | - */ |
|
265 | - public function setCurrent($identifier) |
|
266 | - { |
|
267 | - $this->rewind(); |
|
268 | - while ($this->valid()) { |
|
269 | - if ($identifier === $this->getInfo()) { |
|
270 | - return true; |
|
271 | - } |
|
272 | - $this->next(); |
|
273 | - } |
|
274 | - return false; |
|
275 | - } |
|
276 | - |
|
277 | - |
|
278 | - /** |
|
279 | - * setCurrentUsingObject |
|
280 | - * advances pointer to the provided object |
|
281 | - * |
|
282 | - * @access public |
|
283 | - * @param $object |
|
284 | - * @return boolean |
|
285 | - */ |
|
286 | - public function setCurrentUsingObject($object) |
|
287 | - { |
|
288 | - $this->rewind(); |
|
289 | - while ($this->valid()) { |
|
290 | - if ($this->current() === $object) { |
|
291 | - return true; |
|
292 | - } |
|
293 | - $this->next(); |
|
294 | - } |
|
295 | - return false; |
|
296 | - } |
|
297 | - |
|
298 | - |
|
299 | - /** |
|
300 | - * Returns the object occupying the index before the current object, |
|
301 | - * unless this is already the first object, in which case it just returns the first object |
|
302 | - * |
|
303 | - * @return mixed |
|
304 | - */ |
|
305 | - public function previous() |
|
306 | - { |
|
307 | - $index = $this->indexOf($this->current()); |
|
308 | - if ($index === 0) { |
|
309 | - return $this->current(); |
|
310 | - } |
|
311 | - $index--; |
|
312 | - return $this->objectAtIndex($index); |
|
313 | - } |
|
314 | - |
|
315 | - |
|
316 | - /** |
|
317 | - * Returns the index of a given object, or false if not found |
|
318 | - * |
|
319 | - * @see http://stackoverflow.com/a/8736013 |
|
320 | - * @param $object |
|
321 | - * @return boolean|int|string |
|
322 | - */ |
|
323 | - public function indexOf($object) |
|
324 | - { |
|
325 | - if (! $this->contains($object)) { |
|
326 | - return false; |
|
327 | - } |
|
328 | - foreach ($this as $index => $obj) { |
|
329 | - if ($obj === $object) { |
|
330 | - return $index; |
|
331 | - } |
|
332 | - } |
|
333 | - return false; |
|
334 | - } |
|
335 | - |
|
336 | - |
|
337 | - /** |
|
338 | - * Returns the object at the given index |
|
339 | - * |
|
340 | - * @see http://stackoverflow.com/a/8736013 |
|
341 | - * @param int $index |
|
342 | - * @return mixed |
|
343 | - */ |
|
344 | - public function objectAtIndex($index) |
|
345 | - { |
|
346 | - $iterator = new LimitIterator($this, $index, 1); |
|
347 | - $iterator->rewind(); |
|
348 | - return $iterator->current(); |
|
349 | - } |
|
350 | - |
|
351 | - |
|
352 | - /** |
|
353 | - * Returns the sequence of objects as specified by the offset and length |
|
354 | - * |
|
355 | - * @see http://stackoverflow.com/a/8736013 |
|
356 | - * @param int $offset |
|
357 | - * @param int $length |
|
358 | - * @return array |
|
359 | - */ |
|
360 | - public function slice($offset, $length) |
|
361 | - { |
|
362 | - $slice = array(); |
|
363 | - $iterator = new LimitIterator($this, $offset, $length); |
|
364 | - foreach ($iterator as $object) { |
|
365 | - $slice[] = $object; |
|
366 | - } |
|
367 | - return $slice; |
|
368 | - } |
|
369 | - |
|
370 | - |
|
371 | - /** |
|
372 | - * Inserts an object at a certain point |
|
373 | - * |
|
374 | - * @see http://stackoverflow.com/a/8736013 |
|
375 | - * @param mixed $object A single object |
|
376 | - * @param int $index |
|
377 | - * @param mixed $identifier |
|
378 | - * @return bool |
|
379 | - * @throws DuplicateCollectionIdentifierException |
|
380 | - * @throws InvalidEntityException |
|
381 | - */ |
|
382 | - public function insertObjectAt($object, $index, $identifier = null) |
|
383 | - { |
|
384 | - // check to ensure that objects don't already exist in the collection |
|
385 | - if ($this->has($identifier)) { |
|
386 | - throw new DuplicateCollectionIdentifierException($identifier); |
|
387 | - } |
|
388 | - // detach any objects at or past this index |
|
389 | - $remaining_objects = array(); |
|
390 | - if ($index < $this->count()) { |
|
391 | - $remaining_objects = $this->slice($index, $this->count() - $index); |
|
392 | - foreach ($remaining_objects as $key => $remaining_object) { |
|
393 | - // we need to grab the identifiers for each object and use them as keys |
|
394 | - $remaining_objects[ $remaining_object->getInfo() ] = $remaining_object; |
|
395 | - // and then remove the object from the current tracking array |
|
396 | - unset($remaining_objects[ $key ]); |
|
397 | - // and then remove it from the Collection |
|
398 | - $this->detach($remaining_object); |
|
399 | - } |
|
400 | - } |
|
401 | - // add the new object we're splicing in |
|
402 | - $this->add($object, $identifier); |
|
403 | - // attach the objects we previously detached |
|
404 | - foreach ($remaining_objects as $key => $remaining_object) { |
|
405 | - $this->add($remaining_object, $key); |
|
406 | - } |
|
407 | - return $this->contains($object); |
|
408 | - } |
|
409 | - |
|
410 | - |
|
411 | - /** |
|
412 | - * Inserts an object (or an array of objects) at a certain point |
|
413 | - * |
|
414 | - * @see http://stackoverflow.com/a/8736013 |
|
415 | - * @param mixed $objects A single object or an array of objects |
|
416 | - * @param int $index |
|
417 | - */ |
|
418 | - public function insertAt($objects, $index) |
|
419 | - { |
|
420 | - if (! is_array($objects)) { |
|
421 | - $objects = array($objects); |
|
422 | - } |
|
423 | - // check to ensure that objects don't already exist in the collection |
|
424 | - foreach ($objects as $key => $object) { |
|
425 | - if ($this->contains($object)) { |
|
426 | - unset($objects[ $key ]); |
|
427 | - } |
|
428 | - } |
|
429 | - // do we have any objects left? |
|
430 | - if (! $objects) { |
|
431 | - return; |
|
432 | - } |
|
433 | - // detach any objects at or past this index |
|
434 | - $remaining = array(); |
|
435 | - if ($index < $this->count()) { |
|
436 | - $remaining = $this->slice($index, $this->count() - $index); |
|
437 | - foreach ($remaining as $object) { |
|
438 | - $this->detach($object); |
|
439 | - } |
|
440 | - } |
|
441 | - // add the new objects we're splicing in |
|
442 | - foreach ($objects as $object) { |
|
443 | - $this->attach($object); |
|
444 | - } |
|
445 | - // attach the objects we previously detached |
|
446 | - foreach ($remaining as $object) { |
|
447 | - $this->attach($object); |
|
448 | - } |
|
449 | - } |
|
450 | - |
|
451 | - |
|
452 | - /** |
|
453 | - * Removes the object at the given index |
|
454 | - * |
|
455 | - * @see http://stackoverflow.com/a/8736013 |
|
456 | - * @param int $index |
|
457 | - */ |
|
458 | - public function removeAt($index) |
|
459 | - { |
|
460 | - $this->detach($this->objectAtIndex($index)); |
|
461 | - } |
|
462 | - |
|
463 | - |
|
464 | - /** |
|
465 | - * detaches ALL objects from the Collection |
|
466 | - */ |
|
467 | - public function detachAll() |
|
468 | - { |
|
469 | - $this->rewind(); |
|
470 | - while ($this->valid()) { |
|
471 | - $object = $this->current(); |
|
472 | - $this->next(); |
|
473 | - $this->detach($object); |
|
474 | - } |
|
475 | - } |
|
476 | - |
|
477 | - |
|
478 | - /** |
|
479 | - * unsets and detaches ALL objects from the Collection |
|
480 | - */ |
|
481 | - public function trashAndDetachAll() |
|
482 | - { |
|
483 | - $this->rewind(); |
|
484 | - while ($this->valid()) { |
|
485 | - $object = $this->current(); |
|
486 | - $this->next(); |
|
487 | - $this->detach($object); |
|
488 | - unset($object); |
|
489 | - } |
|
490 | - } |
|
24 | + /** |
|
25 | + * a unique string for identifying this collection |
|
26 | + * |
|
27 | + * @type string $collection_identifier |
|
28 | + */ |
|
29 | + protected $collection_identifier; |
|
30 | + |
|
31 | + /** |
|
32 | + * an interface (or class) name to be used for restricting the type of objects added to the storage |
|
33 | + * this should be set from within the child class constructor |
|
34 | + * |
|
35 | + * @type string $interface |
|
36 | + */ |
|
37 | + protected $collection_interface; |
|
38 | + |
|
39 | + |
|
40 | + /** |
|
41 | + * Collection constructor |
|
42 | + * |
|
43 | + * @param string $collection_interface |
|
44 | + * @throws InvalidInterfaceException |
|
45 | + */ |
|
46 | + public function __construct($collection_interface) |
|
47 | + { |
|
48 | + $this->setCollectionInterface($collection_interface); |
|
49 | + $this->setCollectionIdentifier(); |
|
50 | + } |
|
51 | + |
|
52 | + |
|
53 | + /** |
|
54 | + * @return string |
|
55 | + */ |
|
56 | + public function collectionIdentifier() |
|
57 | + { |
|
58 | + return $this->collection_identifier; |
|
59 | + } |
|
60 | + |
|
61 | + |
|
62 | + /** |
|
63 | + * creates a very readable unique 9 character identifier like: CF2-532-DAC |
|
64 | + * and appends it to the non-qualified class name, ex: ThingCollection-CF2-532-DAC |
|
65 | + * |
|
66 | + * @return void |
|
67 | + */ |
|
68 | + protected function setCollectionIdentifier() |
|
69 | + { |
|
70 | + // hash a few collection details |
|
71 | + $identifier = md5(spl_object_hash($this) . $this->collection_interface . time()); |
|
72 | + // grab a few characters from the start, middle, and end of the hash |
|
73 | + $id = array(); |
|
74 | + for ($x = 0; $x < 19; $x += 9) { |
|
75 | + $id[] = substr($identifier, $x, 3); |
|
76 | + } |
|
77 | + $identifier = basename(str_replace('\\', '/', get_class($this))); |
|
78 | + $identifier .= '-' . strtoupper(implode('-', $id)); |
|
79 | + $this->collection_identifier = $identifier; |
|
80 | + } |
|
81 | + |
|
82 | + |
|
83 | + /** |
|
84 | + * setCollectionInterface |
|
85 | + * |
|
86 | + * @access protected |
|
87 | + * @param string $collection_interface |
|
88 | + * @throws \EventEspresso\core\exceptions\InvalidInterfaceException |
|
89 | + */ |
|
90 | + protected function setCollectionInterface($collection_interface) |
|
91 | + { |
|
92 | + if (! (interface_exists($collection_interface) || class_exists($collection_interface))) { |
|
93 | + throw new InvalidInterfaceException($collection_interface); |
|
94 | + } |
|
95 | + $this->collection_interface = $collection_interface; |
|
96 | + } |
|
97 | + |
|
98 | + |
|
99 | + /** |
|
100 | + * add |
|
101 | + * attaches an object to the Collection |
|
102 | + * and sets any supplied data associated with the current iterator entry |
|
103 | + * by calling EE_Object_Collection::set_identifier() |
|
104 | + * |
|
105 | + * @access public |
|
106 | + * @param $object |
|
107 | + * @param mixed $identifier |
|
108 | + * @return bool |
|
109 | + * @throws InvalidEntityException |
|
110 | + * @throws DuplicateCollectionIdentifierException |
|
111 | + */ |
|
112 | + public function add($object, $identifier = null) |
|
113 | + { |
|
114 | + if (! $object instanceof $this->collection_interface) { |
|
115 | + throw new InvalidEntityException($object, $this->collection_interface); |
|
116 | + } |
|
117 | + if ($this->contains($object)) { |
|
118 | + throw new DuplicateCollectionIdentifierException($identifier); |
|
119 | + } |
|
120 | + $this->attach($object); |
|
121 | + $this->setIdentifier($object, $identifier); |
|
122 | + return $this->contains($object); |
|
123 | + } |
|
124 | + |
|
125 | + |
|
126 | + /** |
|
127 | + * setIdentifier |
|
128 | + * Sets the data associated with an object in the Collection |
|
129 | + * if no $identifier is supplied, then the spl_object_hash() is used |
|
130 | + * |
|
131 | + * @access public |
|
132 | + * @param $object |
|
133 | + * @param mixed $identifier |
|
134 | + * @return bool |
|
135 | + */ |
|
136 | + public function setIdentifier($object, $identifier = null) |
|
137 | + { |
|
138 | + $identifier = ! empty($identifier) |
|
139 | + ? $identifier |
|
140 | + : spl_object_hash($object); |
|
141 | + $this->rewind(); |
|
142 | + while ($this->valid()) { |
|
143 | + if ($object === $this->current()) { |
|
144 | + $this->setInfo($identifier); |
|
145 | + $this->rewind(); |
|
146 | + return true; |
|
147 | + } |
|
148 | + $this->next(); |
|
149 | + } |
|
150 | + return false; |
|
151 | + } |
|
152 | + |
|
153 | + |
|
154 | + /** |
|
155 | + * get |
|
156 | + * finds and returns an object in the Collection based on the identifier that was set using addObject() |
|
157 | + * PLZ NOTE: the pointer is reset to the beginning of the collection before returning |
|
158 | + * |
|
159 | + * @access public |
|
160 | + * @param mixed $identifier |
|
161 | + * @return mixed |
|
162 | + */ |
|
163 | + public function get($identifier) |
|
164 | + { |
|
165 | + $this->rewind(); |
|
166 | + while ($this->valid()) { |
|
167 | + if ($identifier === $this->getInfo()) { |
|
168 | + $object = $this->current(); |
|
169 | + $this->rewind(); |
|
170 | + return $object; |
|
171 | + } |
|
172 | + $this->next(); |
|
173 | + } |
|
174 | + return null; |
|
175 | + } |
|
176 | + |
|
177 | + |
|
178 | + /** |
|
179 | + * has |
|
180 | + * returns TRUE or FALSE |
|
181 | + * depending on whether the object is within the Collection |
|
182 | + * based on the supplied $identifier |
|
183 | + * |
|
184 | + * @access public |
|
185 | + * @param mixed $identifier |
|
186 | + * @return bool |
|
187 | + */ |
|
188 | + public function has($identifier) |
|
189 | + { |
|
190 | + $this->rewind(); |
|
191 | + while ($this->valid()) { |
|
192 | + if ($identifier === $this->getInfo()) { |
|
193 | + $this->rewind(); |
|
194 | + return true; |
|
195 | + } |
|
196 | + $this->next(); |
|
197 | + } |
|
198 | + return false; |
|
199 | + } |
|
200 | + |
|
201 | + |
|
202 | + /** |
|
203 | + * hasObject |
|
204 | + * returns TRUE or FALSE depending on whether the supplied object is within the Collection |
|
205 | + * |
|
206 | + * @access public |
|
207 | + * @param $object |
|
208 | + * @return bool |
|
209 | + */ |
|
210 | + public function hasObject($object) |
|
211 | + { |
|
212 | + return $this->contains($object); |
|
213 | + } |
|
214 | + |
|
215 | + |
|
216 | + /** |
|
217 | + * hasObjects |
|
218 | + * returns true if there are objects within the Collection, and false if it is empty |
|
219 | + * |
|
220 | + * @access public |
|
221 | + * @return bool |
|
222 | + */ |
|
223 | + public function hasObjects() |
|
224 | + { |
|
225 | + return $this->count() !== 0; |
|
226 | + } |
|
227 | + |
|
228 | + |
|
229 | + /** |
|
230 | + * isEmpty |
|
231 | + * returns true if there are no objects within the Collection, and false if there are |
|
232 | + * |
|
233 | + * @access public |
|
234 | + * @return bool |
|
235 | + */ |
|
236 | + public function isEmpty() |
|
237 | + { |
|
238 | + return $this->count() === 0; |
|
239 | + } |
|
240 | + |
|
241 | + |
|
242 | + /** |
|
243 | + * remove |
|
244 | + * detaches an object from the Collection |
|
245 | + * |
|
246 | + * @access public |
|
247 | + * @param $object |
|
248 | + * @return bool |
|
249 | + */ |
|
250 | + public function remove($object) |
|
251 | + { |
|
252 | + $this->detach($object); |
|
253 | + return true; |
|
254 | + } |
|
255 | + |
|
256 | + |
|
257 | + /** |
|
258 | + * setCurrent |
|
259 | + * advances pointer to the object whose identifier matches that which was provided |
|
260 | + * |
|
261 | + * @access public |
|
262 | + * @param mixed $identifier |
|
263 | + * @return boolean |
|
264 | + */ |
|
265 | + public function setCurrent($identifier) |
|
266 | + { |
|
267 | + $this->rewind(); |
|
268 | + while ($this->valid()) { |
|
269 | + if ($identifier === $this->getInfo()) { |
|
270 | + return true; |
|
271 | + } |
|
272 | + $this->next(); |
|
273 | + } |
|
274 | + return false; |
|
275 | + } |
|
276 | + |
|
277 | + |
|
278 | + /** |
|
279 | + * setCurrentUsingObject |
|
280 | + * advances pointer to the provided object |
|
281 | + * |
|
282 | + * @access public |
|
283 | + * @param $object |
|
284 | + * @return boolean |
|
285 | + */ |
|
286 | + public function setCurrentUsingObject($object) |
|
287 | + { |
|
288 | + $this->rewind(); |
|
289 | + while ($this->valid()) { |
|
290 | + if ($this->current() === $object) { |
|
291 | + return true; |
|
292 | + } |
|
293 | + $this->next(); |
|
294 | + } |
|
295 | + return false; |
|
296 | + } |
|
297 | + |
|
298 | + |
|
299 | + /** |
|
300 | + * Returns the object occupying the index before the current object, |
|
301 | + * unless this is already the first object, in which case it just returns the first object |
|
302 | + * |
|
303 | + * @return mixed |
|
304 | + */ |
|
305 | + public function previous() |
|
306 | + { |
|
307 | + $index = $this->indexOf($this->current()); |
|
308 | + if ($index === 0) { |
|
309 | + return $this->current(); |
|
310 | + } |
|
311 | + $index--; |
|
312 | + return $this->objectAtIndex($index); |
|
313 | + } |
|
314 | + |
|
315 | + |
|
316 | + /** |
|
317 | + * Returns the index of a given object, or false if not found |
|
318 | + * |
|
319 | + * @see http://stackoverflow.com/a/8736013 |
|
320 | + * @param $object |
|
321 | + * @return boolean|int|string |
|
322 | + */ |
|
323 | + public function indexOf($object) |
|
324 | + { |
|
325 | + if (! $this->contains($object)) { |
|
326 | + return false; |
|
327 | + } |
|
328 | + foreach ($this as $index => $obj) { |
|
329 | + if ($obj === $object) { |
|
330 | + return $index; |
|
331 | + } |
|
332 | + } |
|
333 | + return false; |
|
334 | + } |
|
335 | + |
|
336 | + |
|
337 | + /** |
|
338 | + * Returns the object at the given index |
|
339 | + * |
|
340 | + * @see http://stackoverflow.com/a/8736013 |
|
341 | + * @param int $index |
|
342 | + * @return mixed |
|
343 | + */ |
|
344 | + public function objectAtIndex($index) |
|
345 | + { |
|
346 | + $iterator = new LimitIterator($this, $index, 1); |
|
347 | + $iterator->rewind(); |
|
348 | + return $iterator->current(); |
|
349 | + } |
|
350 | + |
|
351 | + |
|
352 | + /** |
|
353 | + * Returns the sequence of objects as specified by the offset and length |
|
354 | + * |
|
355 | + * @see http://stackoverflow.com/a/8736013 |
|
356 | + * @param int $offset |
|
357 | + * @param int $length |
|
358 | + * @return array |
|
359 | + */ |
|
360 | + public function slice($offset, $length) |
|
361 | + { |
|
362 | + $slice = array(); |
|
363 | + $iterator = new LimitIterator($this, $offset, $length); |
|
364 | + foreach ($iterator as $object) { |
|
365 | + $slice[] = $object; |
|
366 | + } |
|
367 | + return $slice; |
|
368 | + } |
|
369 | + |
|
370 | + |
|
371 | + /** |
|
372 | + * Inserts an object at a certain point |
|
373 | + * |
|
374 | + * @see http://stackoverflow.com/a/8736013 |
|
375 | + * @param mixed $object A single object |
|
376 | + * @param int $index |
|
377 | + * @param mixed $identifier |
|
378 | + * @return bool |
|
379 | + * @throws DuplicateCollectionIdentifierException |
|
380 | + * @throws InvalidEntityException |
|
381 | + */ |
|
382 | + public function insertObjectAt($object, $index, $identifier = null) |
|
383 | + { |
|
384 | + // check to ensure that objects don't already exist in the collection |
|
385 | + if ($this->has($identifier)) { |
|
386 | + throw new DuplicateCollectionIdentifierException($identifier); |
|
387 | + } |
|
388 | + // detach any objects at or past this index |
|
389 | + $remaining_objects = array(); |
|
390 | + if ($index < $this->count()) { |
|
391 | + $remaining_objects = $this->slice($index, $this->count() - $index); |
|
392 | + foreach ($remaining_objects as $key => $remaining_object) { |
|
393 | + // we need to grab the identifiers for each object and use them as keys |
|
394 | + $remaining_objects[ $remaining_object->getInfo() ] = $remaining_object; |
|
395 | + // and then remove the object from the current tracking array |
|
396 | + unset($remaining_objects[ $key ]); |
|
397 | + // and then remove it from the Collection |
|
398 | + $this->detach($remaining_object); |
|
399 | + } |
|
400 | + } |
|
401 | + // add the new object we're splicing in |
|
402 | + $this->add($object, $identifier); |
|
403 | + // attach the objects we previously detached |
|
404 | + foreach ($remaining_objects as $key => $remaining_object) { |
|
405 | + $this->add($remaining_object, $key); |
|
406 | + } |
|
407 | + return $this->contains($object); |
|
408 | + } |
|
409 | + |
|
410 | + |
|
411 | + /** |
|
412 | + * Inserts an object (or an array of objects) at a certain point |
|
413 | + * |
|
414 | + * @see http://stackoverflow.com/a/8736013 |
|
415 | + * @param mixed $objects A single object or an array of objects |
|
416 | + * @param int $index |
|
417 | + */ |
|
418 | + public function insertAt($objects, $index) |
|
419 | + { |
|
420 | + if (! is_array($objects)) { |
|
421 | + $objects = array($objects); |
|
422 | + } |
|
423 | + // check to ensure that objects don't already exist in the collection |
|
424 | + foreach ($objects as $key => $object) { |
|
425 | + if ($this->contains($object)) { |
|
426 | + unset($objects[ $key ]); |
|
427 | + } |
|
428 | + } |
|
429 | + // do we have any objects left? |
|
430 | + if (! $objects) { |
|
431 | + return; |
|
432 | + } |
|
433 | + // detach any objects at or past this index |
|
434 | + $remaining = array(); |
|
435 | + if ($index < $this->count()) { |
|
436 | + $remaining = $this->slice($index, $this->count() - $index); |
|
437 | + foreach ($remaining as $object) { |
|
438 | + $this->detach($object); |
|
439 | + } |
|
440 | + } |
|
441 | + // add the new objects we're splicing in |
|
442 | + foreach ($objects as $object) { |
|
443 | + $this->attach($object); |
|
444 | + } |
|
445 | + // attach the objects we previously detached |
|
446 | + foreach ($remaining as $object) { |
|
447 | + $this->attach($object); |
|
448 | + } |
|
449 | + } |
|
450 | + |
|
451 | + |
|
452 | + /** |
|
453 | + * Removes the object at the given index |
|
454 | + * |
|
455 | + * @see http://stackoverflow.com/a/8736013 |
|
456 | + * @param int $index |
|
457 | + */ |
|
458 | + public function removeAt($index) |
|
459 | + { |
|
460 | + $this->detach($this->objectAtIndex($index)); |
|
461 | + } |
|
462 | + |
|
463 | + |
|
464 | + /** |
|
465 | + * detaches ALL objects from the Collection |
|
466 | + */ |
|
467 | + public function detachAll() |
|
468 | + { |
|
469 | + $this->rewind(); |
|
470 | + while ($this->valid()) { |
|
471 | + $object = $this->current(); |
|
472 | + $this->next(); |
|
473 | + $this->detach($object); |
|
474 | + } |
|
475 | + } |
|
476 | + |
|
477 | + |
|
478 | + /** |
|
479 | + * unsets and detaches ALL objects from the Collection |
|
480 | + */ |
|
481 | + public function trashAndDetachAll() |
|
482 | + { |
|
483 | + $this->rewind(); |
|
484 | + while ($this->valid()) { |
|
485 | + $object = $this->current(); |
|
486 | + $this->next(); |
|
487 | + $this->detach($object); |
|
488 | + unset($object); |
|
489 | + } |
|
490 | + } |
|
491 | 491 | } |
@@ -68,14 +68,14 @@ discard block |
||
68 | 68 | protected function setCollectionIdentifier() |
69 | 69 | { |
70 | 70 | // hash a few collection details |
71 | - $identifier = md5(spl_object_hash($this) . $this->collection_interface . time()); |
|
71 | + $identifier = md5(spl_object_hash($this).$this->collection_interface.time()); |
|
72 | 72 | // grab a few characters from the start, middle, and end of the hash |
73 | 73 | $id = array(); |
74 | 74 | for ($x = 0; $x < 19; $x += 9) { |
75 | 75 | $id[] = substr($identifier, $x, 3); |
76 | 76 | } |
77 | 77 | $identifier = basename(str_replace('\\', '/', get_class($this))); |
78 | - $identifier .= '-' . strtoupper(implode('-', $id)); |
|
78 | + $identifier .= '-'.strtoupper(implode('-', $id)); |
|
79 | 79 | $this->collection_identifier = $identifier; |
80 | 80 | } |
81 | 81 | |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | */ |
90 | 90 | protected function setCollectionInterface($collection_interface) |
91 | 91 | { |
92 | - if (! (interface_exists($collection_interface) || class_exists($collection_interface))) { |
|
92 | + if ( ! (interface_exists($collection_interface) || class_exists($collection_interface))) { |
|
93 | 93 | throw new InvalidInterfaceException($collection_interface); |
94 | 94 | } |
95 | 95 | $this->collection_interface = $collection_interface; |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | */ |
112 | 112 | public function add($object, $identifier = null) |
113 | 113 | { |
114 | - if (! $object instanceof $this->collection_interface) { |
|
114 | + if ( ! $object instanceof $this->collection_interface) { |
|
115 | 115 | throw new InvalidEntityException($object, $this->collection_interface); |
116 | 116 | } |
117 | 117 | if ($this->contains($object)) { |
@@ -322,7 +322,7 @@ discard block |
||
322 | 322 | */ |
323 | 323 | public function indexOf($object) |
324 | 324 | { |
325 | - if (! $this->contains($object)) { |
|
325 | + if ( ! $this->contains($object)) { |
|
326 | 326 | return false; |
327 | 327 | } |
328 | 328 | foreach ($this as $index => $obj) { |
@@ -391,9 +391,9 @@ discard block |
||
391 | 391 | $remaining_objects = $this->slice($index, $this->count() - $index); |
392 | 392 | foreach ($remaining_objects as $key => $remaining_object) { |
393 | 393 | // we need to grab the identifiers for each object and use them as keys |
394 | - $remaining_objects[ $remaining_object->getInfo() ] = $remaining_object; |
|
394 | + $remaining_objects[$remaining_object->getInfo()] = $remaining_object; |
|
395 | 395 | // and then remove the object from the current tracking array |
396 | - unset($remaining_objects[ $key ]); |
|
396 | + unset($remaining_objects[$key]); |
|
397 | 397 | // and then remove it from the Collection |
398 | 398 | $this->detach($remaining_object); |
399 | 399 | } |
@@ -417,17 +417,17 @@ discard block |
||
417 | 417 | */ |
418 | 418 | public function insertAt($objects, $index) |
419 | 419 | { |
420 | - if (! is_array($objects)) { |
|
420 | + if ( ! is_array($objects)) { |
|
421 | 421 | $objects = array($objects); |
422 | 422 | } |
423 | 423 | // check to ensure that objects don't already exist in the collection |
424 | 424 | foreach ($objects as $key => $object) { |
425 | 425 | if ($this->contains($object)) { |
426 | - unset($objects[ $key ]); |
|
426 | + unset($objects[$key]); |
|
427 | 427 | } |
428 | 428 | } |
429 | 429 | // do we have any objects left? |
430 | - if (! $objects) { |
|
430 | + if ( ! $objects) { |
|
431 | 431 | return; |
432 | 432 | } |
433 | 433 | // detach any objects at or past this index |
@@ -10,294 +10,294 @@ |
||
10 | 10 | */ |
11 | 11 | trait MessagesAdmin |
12 | 12 | { |
13 | - /** |
|
14 | - * @param string $additional_params Any additional request parameters for the generated url should be included as |
|
15 | - * a string. |
|
16 | - */ |
|
17 | - public function amOnMessagesActivityListTablePage($additional_params = '') |
|
18 | - { |
|
19 | - $this->actor()->amOnAdminPage(MessagesPage::messageActivityListTableUrl($additional_params)); |
|
20 | - } |
|
21 | - |
|
22 | - /** |
|
23 | - * @param string $additional_params Any additional request parameters for the generated url should be included as |
|
24 | - * a string. |
|
25 | - */ |
|
26 | - public function amOnDefaultMessageTemplateListTablePage($additional_params = '') |
|
27 | - { |
|
28 | - $this->actor()->amOnAdminPage(MessagesPage::defaultMessageTemplateListTableUrl($additional_params)); |
|
29 | - } |
|
30 | - |
|
31 | - |
|
32 | - /** |
|
33 | - * @param string $additional_params Any additional request parameters for the generated url should be included as |
|
34 | - * a string. |
|
35 | - */ |
|
36 | - public function amOnCustomMessageTemplateListTablePage($additional_params = '') |
|
37 | - { |
|
38 | - $this->actor()->amOnAdminPage(MessagesPage::customMessageTemplateListTableUrl($additional_params)); |
|
39 | - } |
|
40 | - |
|
41 | - |
|
42 | - /** |
|
43 | - * Directs to message settings page |
|
44 | - */ |
|
45 | - public function amOnMessageSettingsPage() |
|
46 | - { |
|
47 | - $this->actor()->amOnAdminPage(MessagesPage::messageSettingsUrl()); |
|
48 | - } |
|
49 | - |
|
50 | - |
|
51 | - public function activateMessageTypeForMessenger($message_type_slug, $messenger_slug = 'email') |
|
52 | - { |
|
53 | - $this->actor()->dragAndDrop( |
|
54 | - MessagesPage::draggableSettingsBoxSelectorForMessageTypeAndMessenger($message_type_slug, $messenger_slug), |
|
55 | - MessagesPage::MESSAGES_SETTINGS_ACTIVE_MESSAGE_TYPES_CONTAINER_SELECTOR |
|
56 | - ); |
|
57 | - } |
|
58 | - |
|
59 | - |
|
60 | - /** |
|
61 | - * Assumes you are already on the list table page that has the ui for editing the template. |
|
62 | - * @param string $message_type_slug |
|
63 | - * @param string $context [optional] if you want to click directly to the given context in the editor |
|
64 | - */ |
|
65 | - public function clickToEditMessageTemplateByMessageType($message_type_slug, $context = '') |
|
66 | - { |
|
67 | - $this->actor()->click(MessagesPage::editMessageTemplateClassByMessageType($message_type_slug, $context)); |
|
68 | - } |
|
69 | - |
|
70 | - |
|
71 | - /** |
|
72 | - * Use this action to verify that the count for the given text in the specified field is as expected. For example |
|
73 | - * filling the condition of, "There should only be 1 instance of `[email protected]` in all the 'to' column. |
|
74 | - * |
|
75 | - * @param int $expected_occurence_count |
|
76 | - * @param string $text_to_check_for |
|
77 | - * @param string $field |
|
78 | - * @param string $message_type_label |
|
79 | - * @param string $message_status |
|
80 | - * @param string $messenger |
|
81 | - * @param string $context |
|
82 | - */ |
|
83 | - public function verifyMatchingCountofTextInMessageActivityListTableFor( |
|
84 | - $expected_occurence_count, |
|
85 | - $text_to_check_for, |
|
86 | - $field, |
|
87 | - $message_type_label, |
|
88 | - $message_status = MessagesPage::MESSAGE_STATUS_SENT, |
|
89 | - $messenger = 'Email', |
|
90 | - $context = 'Event Admin' |
|
91 | - ) { |
|
92 | - $elements = $this->actor()->grabMultiple(MessagesPage::messagesActivityListTableCellSelectorFor( |
|
93 | - $field, |
|
94 | - $message_type_label, |
|
95 | - $message_status, |
|
96 | - $messenger, |
|
97 | - $context, |
|
98 | - $text_to_check_for, |
|
99 | - 0 |
|
100 | - )); |
|
101 | - $actual_count = count($elements); |
|
102 | - $this->actor()->assertEquals( |
|
103 | - $expected_occurence_count, |
|
104 | - $actual_count, |
|
105 | - sprintf( |
|
106 | - 'Expected %s of the %s text for the %s field but there were actually %s counted.', |
|
107 | - $expected_occurence_count, |
|
108 | - $text_to_check_for, |
|
109 | - $field, |
|
110 | - $actual_count |
|
111 | - ) |
|
112 | - ); |
|
113 | - } |
|
114 | - |
|
115 | - |
|
116 | - /** |
|
117 | - * This will create a custom message template for the given messenger and message type from the context of the |
|
118 | - * default (global) message template list table. |
|
119 | - * Also takes care of verifying the template was created. |
|
120 | - * @param string $message_type_label |
|
121 | - * @param string $messenger_label |
|
122 | - */ |
|
123 | - public function createCustomMessageTemplateFromDefaultFor($message_type_label, $messenger_label) |
|
124 | - { |
|
125 | - $this->amOnDefaultMessageTemplateListTablePage(); |
|
126 | - $this->actor()->click( |
|
127 | - MessagesPage::createCustomButtonForMessageTypeAndMessenger( |
|
128 | - $message_type_label, |
|
129 | - $messenger_label |
|
130 | - ) |
|
131 | - ); |
|
132 | - $this->actor()->seeInField('#title', 'New Custom Template'); |
|
133 | - } |
|
134 | - |
|
135 | - |
|
136 | - /** |
|
137 | - * This switches the context of the current messages template to the given reference. |
|
138 | - * @param string $context_reference This should be the visible label for the option. |
|
139 | - */ |
|
140 | - public function switchContextTo($context_reference) |
|
141 | - { |
|
142 | - $this->actor()->selectOption(MessagesPage::MESSAGES_CONTEXT_SWITCHER_SELECTOR, $context_reference); |
|
143 | - $this->actor()->click(MessagesPage::MESSAGES_CONTEXT_SWITCHER_BUTTON_SELECTOR); |
|
144 | - $this->actor()->waitForText($context_reference, 10, 'h1'); |
|
145 | - } |
|
146 | - |
|
147 | - |
|
148 | - /** |
|
149 | - * Toggles Context so its turned off or on (depending on where it started) and verifies the expected state after |
|
150 | - * toggling. |
|
151 | - * |
|
152 | - * @param string $context_string What context is being switched (used for the expected state text) |
|
153 | - * @param bool $expected_state_is_active Used to indicate whether the expected state is active (true) or inactive |
|
154 | - * (false) |
|
155 | - */ |
|
156 | - public function toggleContextState($context_string, $expected_state_is_active = true) |
|
157 | - { |
|
158 | - $this->actor()->scrollTo(MessagesPage::MESSAGES_CONTEXT_SWITCHER_SELECTOR); |
|
159 | - $this->actor()->click(MessagesPage::MESSAGES_CONTEXT_ACTIVE_STATE_TOGGLE); |
|
160 | - if ($expected_state_is_active) { |
|
161 | - $this->actor()->waitForText("The template for $context_string is currently active."); |
|
162 | - } else { |
|
163 | - $this->actor()->waitForText("The template for $context_string is currently inactive"); |
|
164 | - } |
|
165 | - } |
|
166 | - |
|
167 | - |
|
168 | - /** |
|
169 | - * Triggers saving the message template. |
|
170 | - * @param bool $and_close Use to indicate to click the Save and Close button. |
|
171 | - */ |
|
172 | - public function saveMessageTemplate($and_close = false) |
|
173 | - { |
|
174 | - $this->actor()->scrollTo(MessagesPage::MESSAGES_CONTEXT_SWITCHER_SELECTOR); |
|
175 | - if ($and_close) { |
|
176 | - $this->actor()->click('Save and Close'); |
|
177 | - } else { |
|
178 | - $this->actor()->click('Save'); |
|
179 | - } |
|
180 | - $this->actor()->waitForText('successfully updated'); |
|
181 | - } |
|
182 | - |
|
183 | - |
|
184 | - /** |
|
185 | - * This takes care of clicking the View Message icon for the given parameters. |
|
186 | - * Assumes you are already viewing the messages activity list table. |
|
187 | - * @param $message_type_label |
|
188 | - * @param $message_status |
|
189 | - * @param string $messenger |
|
190 | - * @param string $context |
|
191 | - * @param int $number_in_set |
|
192 | - */ |
|
193 | - public function viewMessageInMessagesListTableFor( |
|
194 | - $message_type_label, |
|
195 | - $message_status = MessagesPage::MESSAGE_STATUS_SENT, |
|
196 | - $messenger = 'Email', |
|
197 | - $context = 'Event Admin', |
|
198 | - $number_in_set = 1 |
|
199 | - ) { |
|
200 | - $this->actor()->click(MessagesPage::messagesActivityListTableViewButtonSelectorFor( |
|
201 | - $message_type_label, |
|
202 | - $message_status, |
|
203 | - $messenger, |
|
204 | - $context, |
|
205 | - $number_in_set |
|
206 | - )); |
|
207 | - } |
|
208 | - |
|
209 | - |
|
210 | - /** |
|
211 | - * Takes care of deleting a message matching the given parameters via the message activity list table. |
|
212 | - * Assumes you are already viewing the messages activity list table. |
|
213 | - * @param $message_type_label |
|
214 | - * @param $message_status |
|
215 | - * @param string $messenger |
|
216 | - * @param string $context |
|
217 | - * @param int $number_in_set |
|
218 | - */ |
|
219 | - public function deleteMessageInMessagesListTableFor( |
|
220 | - $message_type_label, |
|
221 | - $message_status = MessagesPage::MESSAGE_STATUS_SENT, |
|
222 | - $messenger = 'Email', |
|
223 | - $context = 'Event Admin', |
|
224 | - $number_in_set = 1 |
|
225 | - ) { |
|
226 | - $delete_action_selector = MessagesPage::messagesActivityListTableDeleteActionSelectorFor( |
|
227 | - $message_type_label, |
|
228 | - $message_status, |
|
229 | - $messenger, |
|
230 | - $context, |
|
231 | - $number_in_set |
|
232 | - ); |
|
233 | - $cell_selector = MessagesPage::messagesActivityListTableCellSelectorFor( |
|
234 | - 'to', |
|
235 | - $message_type_label, |
|
236 | - $message_status, |
|
237 | - $messenger, |
|
238 | - $context, |
|
239 | - '', |
|
240 | - $number_in_set |
|
241 | - ); |
|
242 | - $this->actor()->scrollTo($cell_selector, 0, -30); |
|
243 | - $this->actor()->moveMouseOver( |
|
244 | - $cell_selector, |
|
245 | - 5, |
|
246 | - 5 |
|
247 | - ); |
|
248 | - $this->actor()->waitForElementVisible( |
|
249 | - $delete_action_selector |
|
250 | - ); |
|
251 | - $this->actor()->click( |
|
252 | - $delete_action_selector |
|
253 | - ); |
|
254 | - $this->actor()->waitForText('successfully deleted', 20); |
|
255 | - } |
|
256 | - |
|
257 | - |
|
258 | - /** |
|
259 | - * Assuming you have already triggered the view modal for a single message from the context of the message activity |
|
260 | - * list table, this will take care of validating the given text is in that window. |
|
261 | - * @param string $text_to_view |
|
262 | - */ |
|
263 | - public function seeTextInViewMessageModal($text_to_view, $should_not_see = false) |
|
264 | - { |
|
265 | - $this->actor()->wait(2); |
|
266 | - $this->actor()->waitForElementVisible('.ee-admin-dialog-container-inner-content'); |
|
267 | - $this->actor()->switchToIframe('message-view-window'); |
|
268 | - $should_not_see ? $this->actor()->dontSee($text_to_view) : $this->actor()->see($text_to_view); |
|
269 | - $this->actor()->switchToIframe(); |
|
270 | - } |
|
271 | - |
|
272 | - |
|
273 | - /** |
|
274 | - * This returns the value for the link at the given selector in the message modal. |
|
275 | - * @param string $selector (any selector string accepted by WebDriver) |
|
276 | - */ |
|
277 | - public function observeLinkAtSelectorInMessageModal($selector) |
|
278 | - { |
|
279 | - $this->actor()->wait(2); |
|
280 | - $this->actor()->waitForElementVisible('.ee-admin-dialog-container-inner-content'); |
|
281 | - $this->actor()->switchToIframe('message-view-window'); |
|
282 | - $link = $this->actor()->observeLinkUrlAt($selector); |
|
283 | - $this->actor()->switchToIframe(); |
|
284 | - return $link; |
|
285 | - } |
|
286 | - |
|
287 | - |
|
288 | - /** |
|
289 | - * Assuming you have already triggered the view modal for a single message from the context of the message activity |
|
290 | - * list table, this will take care of validating the given text is NOT that window. |
|
291 | - * @param string $text_to_view |
|
292 | - */ |
|
293 | - public function dontSeeTextInViewMessageModal($text_to_view) |
|
294 | - { |
|
295 | - $this->seeTextInViewMessageModal($text_to_view, true); |
|
296 | - } |
|
297 | - |
|
298 | - |
|
299 | - public function dismissMessageModal() |
|
300 | - { |
|
301 | - $this->actor()->executeJs('window.dialogHelper.closeModal()'); |
|
302 | - } |
|
13 | + /** |
|
14 | + * @param string $additional_params Any additional request parameters for the generated url should be included as |
|
15 | + * a string. |
|
16 | + */ |
|
17 | + public function amOnMessagesActivityListTablePage($additional_params = '') |
|
18 | + { |
|
19 | + $this->actor()->amOnAdminPage(MessagesPage::messageActivityListTableUrl($additional_params)); |
|
20 | + } |
|
21 | + |
|
22 | + /** |
|
23 | + * @param string $additional_params Any additional request parameters for the generated url should be included as |
|
24 | + * a string. |
|
25 | + */ |
|
26 | + public function amOnDefaultMessageTemplateListTablePage($additional_params = '') |
|
27 | + { |
|
28 | + $this->actor()->amOnAdminPage(MessagesPage::defaultMessageTemplateListTableUrl($additional_params)); |
|
29 | + } |
|
30 | + |
|
31 | + |
|
32 | + /** |
|
33 | + * @param string $additional_params Any additional request parameters for the generated url should be included as |
|
34 | + * a string. |
|
35 | + */ |
|
36 | + public function amOnCustomMessageTemplateListTablePage($additional_params = '') |
|
37 | + { |
|
38 | + $this->actor()->amOnAdminPage(MessagesPage::customMessageTemplateListTableUrl($additional_params)); |
|
39 | + } |
|
40 | + |
|
41 | + |
|
42 | + /** |
|
43 | + * Directs to message settings page |
|
44 | + */ |
|
45 | + public function amOnMessageSettingsPage() |
|
46 | + { |
|
47 | + $this->actor()->amOnAdminPage(MessagesPage::messageSettingsUrl()); |
|
48 | + } |
|
49 | + |
|
50 | + |
|
51 | + public function activateMessageTypeForMessenger($message_type_slug, $messenger_slug = 'email') |
|
52 | + { |
|
53 | + $this->actor()->dragAndDrop( |
|
54 | + MessagesPage::draggableSettingsBoxSelectorForMessageTypeAndMessenger($message_type_slug, $messenger_slug), |
|
55 | + MessagesPage::MESSAGES_SETTINGS_ACTIVE_MESSAGE_TYPES_CONTAINER_SELECTOR |
|
56 | + ); |
|
57 | + } |
|
58 | + |
|
59 | + |
|
60 | + /** |
|
61 | + * Assumes you are already on the list table page that has the ui for editing the template. |
|
62 | + * @param string $message_type_slug |
|
63 | + * @param string $context [optional] if you want to click directly to the given context in the editor |
|
64 | + */ |
|
65 | + public function clickToEditMessageTemplateByMessageType($message_type_slug, $context = '') |
|
66 | + { |
|
67 | + $this->actor()->click(MessagesPage::editMessageTemplateClassByMessageType($message_type_slug, $context)); |
|
68 | + } |
|
69 | + |
|
70 | + |
|
71 | + /** |
|
72 | + * Use this action to verify that the count for the given text in the specified field is as expected. For example |
|
73 | + * filling the condition of, "There should only be 1 instance of `[email protected]` in all the 'to' column. |
|
74 | + * |
|
75 | + * @param int $expected_occurence_count |
|
76 | + * @param string $text_to_check_for |
|
77 | + * @param string $field |
|
78 | + * @param string $message_type_label |
|
79 | + * @param string $message_status |
|
80 | + * @param string $messenger |
|
81 | + * @param string $context |
|
82 | + */ |
|
83 | + public function verifyMatchingCountofTextInMessageActivityListTableFor( |
|
84 | + $expected_occurence_count, |
|
85 | + $text_to_check_for, |
|
86 | + $field, |
|
87 | + $message_type_label, |
|
88 | + $message_status = MessagesPage::MESSAGE_STATUS_SENT, |
|
89 | + $messenger = 'Email', |
|
90 | + $context = 'Event Admin' |
|
91 | + ) { |
|
92 | + $elements = $this->actor()->grabMultiple(MessagesPage::messagesActivityListTableCellSelectorFor( |
|
93 | + $field, |
|
94 | + $message_type_label, |
|
95 | + $message_status, |
|
96 | + $messenger, |
|
97 | + $context, |
|
98 | + $text_to_check_for, |
|
99 | + 0 |
|
100 | + )); |
|
101 | + $actual_count = count($elements); |
|
102 | + $this->actor()->assertEquals( |
|
103 | + $expected_occurence_count, |
|
104 | + $actual_count, |
|
105 | + sprintf( |
|
106 | + 'Expected %s of the %s text for the %s field but there were actually %s counted.', |
|
107 | + $expected_occurence_count, |
|
108 | + $text_to_check_for, |
|
109 | + $field, |
|
110 | + $actual_count |
|
111 | + ) |
|
112 | + ); |
|
113 | + } |
|
114 | + |
|
115 | + |
|
116 | + /** |
|
117 | + * This will create a custom message template for the given messenger and message type from the context of the |
|
118 | + * default (global) message template list table. |
|
119 | + * Also takes care of verifying the template was created. |
|
120 | + * @param string $message_type_label |
|
121 | + * @param string $messenger_label |
|
122 | + */ |
|
123 | + public function createCustomMessageTemplateFromDefaultFor($message_type_label, $messenger_label) |
|
124 | + { |
|
125 | + $this->amOnDefaultMessageTemplateListTablePage(); |
|
126 | + $this->actor()->click( |
|
127 | + MessagesPage::createCustomButtonForMessageTypeAndMessenger( |
|
128 | + $message_type_label, |
|
129 | + $messenger_label |
|
130 | + ) |
|
131 | + ); |
|
132 | + $this->actor()->seeInField('#title', 'New Custom Template'); |
|
133 | + } |
|
134 | + |
|
135 | + |
|
136 | + /** |
|
137 | + * This switches the context of the current messages template to the given reference. |
|
138 | + * @param string $context_reference This should be the visible label for the option. |
|
139 | + */ |
|
140 | + public function switchContextTo($context_reference) |
|
141 | + { |
|
142 | + $this->actor()->selectOption(MessagesPage::MESSAGES_CONTEXT_SWITCHER_SELECTOR, $context_reference); |
|
143 | + $this->actor()->click(MessagesPage::MESSAGES_CONTEXT_SWITCHER_BUTTON_SELECTOR); |
|
144 | + $this->actor()->waitForText($context_reference, 10, 'h1'); |
|
145 | + } |
|
146 | + |
|
147 | + |
|
148 | + /** |
|
149 | + * Toggles Context so its turned off or on (depending on where it started) and verifies the expected state after |
|
150 | + * toggling. |
|
151 | + * |
|
152 | + * @param string $context_string What context is being switched (used for the expected state text) |
|
153 | + * @param bool $expected_state_is_active Used to indicate whether the expected state is active (true) or inactive |
|
154 | + * (false) |
|
155 | + */ |
|
156 | + public function toggleContextState($context_string, $expected_state_is_active = true) |
|
157 | + { |
|
158 | + $this->actor()->scrollTo(MessagesPage::MESSAGES_CONTEXT_SWITCHER_SELECTOR); |
|
159 | + $this->actor()->click(MessagesPage::MESSAGES_CONTEXT_ACTIVE_STATE_TOGGLE); |
|
160 | + if ($expected_state_is_active) { |
|
161 | + $this->actor()->waitForText("The template for $context_string is currently active."); |
|
162 | + } else { |
|
163 | + $this->actor()->waitForText("The template for $context_string is currently inactive"); |
|
164 | + } |
|
165 | + } |
|
166 | + |
|
167 | + |
|
168 | + /** |
|
169 | + * Triggers saving the message template. |
|
170 | + * @param bool $and_close Use to indicate to click the Save and Close button. |
|
171 | + */ |
|
172 | + public function saveMessageTemplate($and_close = false) |
|
173 | + { |
|
174 | + $this->actor()->scrollTo(MessagesPage::MESSAGES_CONTEXT_SWITCHER_SELECTOR); |
|
175 | + if ($and_close) { |
|
176 | + $this->actor()->click('Save and Close'); |
|
177 | + } else { |
|
178 | + $this->actor()->click('Save'); |
|
179 | + } |
|
180 | + $this->actor()->waitForText('successfully updated'); |
|
181 | + } |
|
182 | + |
|
183 | + |
|
184 | + /** |
|
185 | + * This takes care of clicking the View Message icon for the given parameters. |
|
186 | + * Assumes you are already viewing the messages activity list table. |
|
187 | + * @param $message_type_label |
|
188 | + * @param $message_status |
|
189 | + * @param string $messenger |
|
190 | + * @param string $context |
|
191 | + * @param int $number_in_set |
|
192 | + */ |
|
193 | + public function viewMessageInMessagesListTableFor( |
|
194 | + $message_type_label, |
|
195 | + $message_status = MessagesPage::MESSAGE_STATUS_SENT, |
|
196 | + $messenger = 'Email', |
|
197 | + $context = 'Event Admin', |
|
198 | + $number_in_set = 1 |
|
199 | + ) { |
|
200 | + $this->actor()->click(MessagesPage::messagesActivityListTableViewButtonSelectorFor( |
|
201 | + $message_type_label, |
|
202 | + $message_status, |
|
203 | + $messenger, |
|
204 | + $context, |
|
205 | + $number_in_set |
|
206 | + )); |
|
207 | + } |
|
208 | + |
|
209 | + |
|
210 | + /** |
|
211 | + * Takes care of deleting a message matching the given parameters via the message activity list table. |
|
212 | + * Assumes you are already viewing the messages activity list table. |
|
213 | + * @param $message_type_label |
|
214 | + * @param $message_status |
|
215 | + * @param string $messenger |
|
216 | + * @param string $context |
|
217 | + * @param int $number_in_set |
|
218 | + */ |
|
219 | + public function deleteMessageInMessagesListTableFor( |
|
220 | + $message_type_label, |
|
221 | + $message_status = MessagesPage::MESSAGE_STATUS_SENT, |
|
222 | + $messenger = 'Email', |
|
223 | + $context = 'Event Admin', |
|
224 | + $number_in_set = 1 |
|
225 | + ) { |
|
226 | + $delete_action_selector = MessagesPage::messagesActivityListTableDeleteActionSelectorFor( |
|
227 | + $message_type_label, |
|
228 | + $message_status, |
|
229 | + $messenger, |
|
230 | + $context, |
|
231 | + $number_in_set |
|
232 | + ); |
|
233 | + $cell_selector = MessagesPage::messagesActivityListTableCellSelectorFor( |
|
234 | + 'to', |
|
235 | + $message_type_label, |
|
236 | + $message_status, |
|
237 | + $messenger, |
|
238 | + $context, |
|
239 | + '', |
|
240 | + $number_in_set |
|
241 | + ); |
|
242 | + $this->actor()->scrollTo($cell_selector, 0, -30); |
|
243 | + $this->actor()->moveMouseOver( |
|
244 | + $cell_selector, |
|
245 | + 5, |
|
246 | + 5 |
|
247 | + ); |
|
248 | + $this->actor()->waitForElementVisible( |
|
249 | + $delete_action_selector |
|
250 | + ); |
|
251 | + $this->actor()->click( |
|
252 | + $delete_action_selector |
|
253 | + ); |
|
254 | + $this->actor()->waitForText('successfully deleted', 20); |
|
255 | + } |
|
256 | + |
|
257 | + |
|
258 | + /** |
|
259 | + * Assuming you have already triggered the view modal for a single message from the context of the message activity |
|
260 | + * list table, this will take care of validating the given text is in that window. |
|
261 | + * @param string $text_to_view |
|
262 | + */ |
|
263 | + public function seeTextInViewMessageModal($text_to_view, $should_not_see = false) |
|
264 | + { |
|
265 | + $this->actor()->wait(2); |
|
266 | + $this->actor()->waitForElementVisible('.ee-admin-dialog-container-inner-content'); |
|
267 | + $this->actor()->switchToIframe('message-view-window'); |
|
268 | + $should_not_see ? $this->actor()->dontSee($text_to_view) : $this->actor()->see($text_to_view); |
|
269 | + $this->actor()->switchToIframe(); |
|
270 | + } |
|
271 | + |
|
272 | + |
|
273 | + /** |
|
274 | + * This returns the value for the link at the given selector in the message modal. |
|
275 | + * @param string $selector (any selector string accepted by WebDriver) |
|
276 | + */ |
|
277 | + public function observeLinkAtSelectorInMessageModal($selector) |
|
278 | + { |
|
279 | + $this->actor()->wait(2); |
|
280 | + $this->actor()->waitForElementVisible('.ee-admin-dialog-container-inner-content'); |
|
281 | + $this->actor()->switchToIframe('message-view-window'); |
|
282 | + $link = $this->actor()->observeLinkUrlAt($selector); |
|
283 | + $this->actor()->switchToIframe(); |
|
284 | + return $link; |
|
285 | + } |
|
286 | + |
|
287 | + |
|
288 | + /** |
|
289 | + * Assuming you have already triggered the view modal for a single message from the context of the message activity |
|
290 | + * list table, this will take care of validating the given text is NOT that window. |
|
291 | + * @param string $text_to_view |
|
292 | + */ |
|
293 | + public function dontSeeTextInViewMessageModal($text_to_view) |
|
294 | + { |
|
295 | + $this->seeTextInViewMessageModal($text_to_view, true); |
|
296 | + } |
|
297 | + |
|
298 | + |
|
299 | + public function dismissMessageModal() |
|
300 | + { |
|
301 | + $this->actor()->executeJs('window.dialogHelper.closeModal()'); |
|
302 | + } |
|
303 | 303 | } |
@@ -16,24 +16,24 @@ |
||
16 | 16 | */ |
17 | 17 | class AssetRegistrationException extends RuntimeException |
18 | 18 | { |
19 | - /** |
|
20 | - * @param $script_handle |
|
21 | - * @param string $message |
|
22 | - * @param int $code |
|
23 | - * @param Exception|null $previous |
|
24 | - */ |
|
25 | - public function __construct($script_handle, $message = '', $code = 0, Exception $previous = null) |
|
26 | - { |
|
27 | - if (empty($message)) { |
|
28 | - $message = sprintf( |
|
29 | - esc_html_x( |
|
30 | - 'The "%1$s" script could not be registered with WordPress core.', |
|
31 | - 'The "script-handle" script could not be registered with WordPress core.', |
|
32 | - 'event_espresso' |
|
33 | - ), |
|
34 | - $script_handle |
|
35 | - ); |
|
36 | - } |
|
37 | - parent::__construct($message, $code, $previous); |
|
38 | - } |
|
19 | + /** |
|
20 | + * @param $script_handle |
|
21 | + * @param string $message |
|
22 | + * @param int $code |
|
23 | + * @param Exception|null $previous |
|
24 | + */ |
|
25 | + public function __construct($script_handle, $message = '', $code = 0, Exception $previous = null) |
|
26 | + { |
|
27 | + if (empty($message)) { |
|
28 | + $message = sprintf( |
|
29 | + esc_html_x( |
|
30 | + 'The "%1$s" script could not be registered with WordPress core.', |
|
31 | + 'The "script-handle" script could not be registered with WordPress core.', |
|
32 | + 'event_espresso' |
|
33 | + ), |
|
34 | + $script_handle |
|
35 | + ); |
|
36 | + } |
|
37 | + parent::__construct($message, $code, $previous); |
|
38 | + } |
|
39 | 39 | } |
40 | 40 | \ No newline at end of file |
@@ -16,20 +16,20 @@ |
||
16 | 16 | interface PrivacyPolicyInterface |
17 | 17 | { |
18 | 18 | |
19 | - /** |
|
20 | - * Returns the translated name to display in this privacy policy's section's title |
|
21 | - * |
|
22 | - * @return string |
|
23 | - */ |
|
24 | - public function getName(); |
|
19 | + /** |
|
20 | + * Returns the translated name to display in this privacy policy's section's title |
|
21 | + * |
|
22 | + * @return string |
|
23 | + */ |
|
24 | + public function getName(); |
|
25 | 25 | |
26 | 26 | |
27 | - /** |
|
28 | - * Returns the suggested privacy policy content for this plugin. May contain HTML |
|
29 | - * |
|
30 | - * @return string |
|
31 | - */ |
|
32 | - public function getContent(); |
|
27 | + /** |
|
28 | + * Returns the suggested privacy policy content for this plugin. May contain HTML |
|
29 | + * |
|
30 | + * @return string |
|
31 | + */ |
|
32 | + public function getContent(); |
|
33 | 33 | } |
34 | 34 | // End of file PrivacyPolicyInterface.php |
35 | 35 | // Location: EventEspresso\core\domain\services\admin/PrivacyPolicyInterface.php |
@@ -15,106 +15,106 @@ |
||
15 | 15 | */ |
16 | 16 | class ExportTransaction implements PersonalDataExporterInterface |
17 | 17 | { |
18 | - /** |
|
19 | - * @var EEM_Transaction $transaction_model |
|
20 | - */ |
|
21 | - protected $transaction_model; |
|
18 | + /** |
|
19 | + * @var EEM_Transaction $transaction_model |
|
20 | + */ |
|
21 | + protected $transaction_model; |
|
22 | 22 | |
23 | - /** |
|
24 | - * ExportTransaction constructor. |
|
25 | - * |
|
26 | - * @param $transaction_model |
|
27 | - */ |
|
28 | - public function __construct(EEM_Transaction $transaction_model) |
|
29 | - { |
|
30 | - $this->transaction_model = $transaction_model; |
|
31 | - } |
|
23 | + /** |
|
24 | + * ExportTransaction constructor. |
|
25 | + * |
|
26 | + * @param $transaction_model |
|
27 | + */ |
|
28 | + public function __construct(EEM_Transaction $transaction_model) |
|
29 | + { |
|
30 | + $this->transaction_model = $transaction_model; |
|
31 | + } |
|
32 | 32 | |
33 | 33 | |
34 | - /** |
|
35 | - * Returns data for export. |
|
36 | - * |
|
37 | - * @param string $email_address , |
|
38 | - * @param int $page starts at 1, not 0 |
|
39 | - * @return array { |
|
40 | - * @type array $data { |
|
41 | - * @type array { |
|
42 | - * @type string $group_id (not translated, same for all exports) |
|
43 | - * @type string $group_label (translated string) |
|
44 | - * @type string|int $item_id |
|
45 | - * @type array $data { |
|
46 | - * @type array { |
|
47 | - * @type string $name what's shown in the left-column of the export row |
|
48 | - * @type string $value what's showin the right-column of the export row |
|
49 | - * } |
|
50 | - * } |
|
51 | - * } |
|
52 | - * } |
|
53 | - * } |
|
54 | - */ |
|
55 | - public function export($email_address, $page = 1) |
|
56 | - { |
|
57 | - $page_size = 10; |
|
58 | - $transactions = $this->transaction_model->get_all( |
|
59 | - array( |
|
60 | - array( |
|
61 | - 'Registration.Attendee.ATT_email' => $email_address, |
|
62 | - ), |
|
63 | - 'limit' => array( |
|
64 | - ($page - 1) * $page_size, |
|
65 | - $page_size, |
|
66 | - ), |
|
67 | - ) |
|
68 | - ); |
|
69 | - $export_fields = array_intersect_key( |
|
70 | - EEM_Transaction::instance()->field_settings(), |
|
71 | - array_flip( |
|
72 | - array( |
|
73 | - 'TXN_timestamp', |
|
74 | - 'TXN_total', |
|
75 | - 'TXN_paid', |
|
76 | - 'TXN_session_data', |
|
77 | - ) |
|
78 | - ) |
|
79 | - ); |
|
80 | - $export_items = array(); |
|
81 | - $found_something = false; |
|
82 | - foreach ($transactions as $transaction) { |
|
83 | - $found_something = true; |
|
84 | - $data = array(); |
|
85 | - foreach ($export_fields as $field_name => $field_obj) { |
|
86 | - if ($field_name === 'TXN_session_data') { |
|
87 | - $value = $transaction->get_pretty($field_name, 'print_r'); |
|
88 | - } else { |
|
89 | - $value = $transaction->get_pretty($field_name); |
|
90 | - } |
|
91 | - $data[] = array( |
|
92 | - 'name' => $field_obj->get_nicename(), |
|
93 | - 'value' => $value, |
|
94 | - ); |
|
95 | - } |
|
96 | - $export_items[] = array( |
|
97 | - 'group_id' => 'transactions', |
|
98 | - 'group_label' => esc_html__('Transactions', 'event_espresso'), |
|
99 | - 'item_id' => $transaction->ID(), |
|
100 | - 'data' => $data, |
|
101 | - ); |
|
102 | - } |
|
103 | - return array( |
|
104 | - 'data' => $export_items, |
|
105 | - 'done' => ! $found_something, |
|
106 | - ); |
|
107 | - } |
|
34 | + /** |
|
35 | + * Returns data for export. |
|
36 | + * |
|
37 | + * @param string $email_address , |
|
38 | + * @param int $page starts at 1, not 0 |
|
39 | + * @return array { |
|
40 | + * @type array $data { |
|
41 | + * @type array { |
|
42 | + * @type string $group_id (not translated, same for all exports) |
|
43 | + * @type string $group_label (translated string) |
|
44 | + * @type string|int $item_id |
|
45 | + * @type array $data { |
|
46 | + * @type array { |
|
47 | + * @type string $name what's shown in the left-column of the export row |
|
48 | + * @type string $value what's showin the right-column of the export row |
|
49 | + * } |
|
50 | + * } |
|
51 | + * } |
|
52 | + * } |
|
53 | + * } |
|
54 | + */ |
|
55 | + public function export($email_address, $page = 1) |
|
56 | + { |
|
57 | + $page_size = 10; |
|
58 | + $transactions = $this->transaction_model->get_all( |
|
59 | + array( |
|
60 | + array( |
|
61 | + 'Registration.Attendee.ATT_email' => $email_address, |
|
62 | + ), |
|
63 | + 'limit' => array( |
|
64 | + ($page - 1) * $page_size, |
|
65 | + $page_size, |
|
66 | + ), |
|
67 | + ) |
|
68 | + ); |
|
69 | + $export_fields = array_intersect_key( |
|
70 | + EEM_Transaction::instance()->field_settings(), |
|
71 | + array_flip( |
|
72 | + array( |
|
73 | + 'TXN_timestamp', |
|
74 | + 'TXN_total', |
|
75 | + 'TXN_paid', |
|
76 | + 'TXN_session_data', |
|
77 | + ) |
|
78 | + ) |
|
79 | + ); |
|
80 | + $export_items = array(); |
|
81 | + $found_something = false; |
|
82 | + foreach ($transactions as $transaction) { |
|
83 | + $found_something = true; |
|
84 | + $data = array(); |
|
85 | + foreach ($export_fields as $field_name => $field_obj) { |
|
86 | + if ($field_name === 'TXN_session_data') { |
|
87 | + $value = $transaction->get_pretty($field_name, 'print_r'); |
|
88 | + } else { |
|
89 | + $value = $transaction->get_pretty($field_name); |
|
90 | + } |
|
91 | + $data[] = array( |
|
92 | + 'name' => $field_obj->get_nicename(), |
|
93 | + 'value' => $value, |
|
94 | + ); |
|
95 | + } |
|
96 | + $export_items[] = array( |
|
97 | + 'group_id' => 'transactions', |
|
98 | + 'group_label' => esc_html__('Transactions', 'event_espresso'), |
|
99 | + 'item_id' => $transaction->ID(), |
|
100 | + 'data' => $data, |
|
101 | + ); |
|
102 | + } |
|
103 | + return array( |
|
104 | + 'data' => $export_items, |
|
105 | + 'done' => ! $found_something, |
|
106 | + ); |
|
107 | + } |
|
108 | 108 | |
109 | - /** |
|
110 | - * Gets the Translated name of this exporter |
|
111 | - * |
|
112 | - * @return string |
|
113 | - */ |
|
114 | - public function name() |
|
115 | - { |
|
116 | - return esc_html__('Event Espresso Transaction Exporter', 'event_espresso'); |
|
117 | - } |
|
109 | + /** |
|
110 | + * Gets the Translated name of this exporter |
|
111 | + * |
|
112 | + * @return string |
|
113 | + */ |
|
114 | + public function name() |
|
115 | + { |
|
116 | + return esc_html__('Event Espresso Transaction Exporter', 'event_espresso'); |
|
117 | + } |
|
118 | 118 | } |
119 | 119 | // End of file ExportTransaction.php |
120 | 120 | // Location: EventEspresso\core\domain\services\admin\privacy\export/ExportTransaction.php |
@@ -16,112 +16,112 @@ |
||
16 | 16 | */ |
17 | 17 | class ExportCheckins implements PersonalDataExporterInterface |
18 | 18 | { |
19 | - /** |
|
20 | - * @var EEM_Checkin |
|
21 | - */ |
|
22 | - protected $checkin_model; |
|
19 | + /** |
|
20 | + * @var EEM_Checkin |
|
21 | + */ |
|
22 | + protected $checkin_model; |
|
23 | 23 | |
24 | - /** |
|
25 | - * ExportCheckins constructor. |
|
26 | - * |
|
27 | - * @param EEM_Checkin $checkin_model |
|
28 | - */ |
|
29 | - public function __construct(EEM_Checkin $checkin_model) |
|
30 | - { |
|
31 | - $this->checkin_model = $checkin_model; |
|
32 | - } |
|
24 | + /** |
|
25 | + * ExportCheckins constructor. |
|
26 | + * |
|
27 | + * @param EEM_Checkin $checkin_model |
|
28 | + */ |
|
29 | + public function __construct(EEM_Checkin $checkin_model) |
|
30 | + { |
|
31 | + $this->checkin_model = $checkin_model; |
|
32 | + } |
|
33 | 33 | |
34 | 34 | |
35 | - /** |
|
36 | - * Returns data for export. |
|
37 | - * |
|
38 | - * @param string $email_address , |
|
39 | - * @param int $page starts at 1, not 0 |
|
40 | - * @return array { |
|
41 | - * @type array $data { |
|
42 | - * @type array { |
|
43 | - * @type string $group_id (not translated, same for all exports) |
|
44 | - * @type string $group_label (translated string) |
|
45 | - * @type string|int $item_id |
|
46 | - * @type array $data { |
|
47 | - * @type array { |
|
48 | - * @type string $name what's shown in the left-column of the export row |
|
49 | - * @type string $value what's showin the right-column of the export row |
|
50 | - * } |
|
51 | - * } |
|
52 | - * } |
|
53 | - * } |
|
54 | - * } |
|
55 | - */ |
|
56 | - public function export($email_address, $page = 1) |
|
57 | - { |
|
58 | - $page_size = 10; |
|
59 | - $checkins = $this->checkin_model->get_all( |
|
60 | - array( |
|
61 | - array( |
|
62 | - 'Registration.Attendee.ATT_email' => $email_address, |
|
63 | - ), |
|
64 | - 'limit' => array( |
|
65 | - ($page - 1) * $page_size, |
|
66 | - $page_size, |
|
67 | - ), |
|
68 | - 'force_join' => array('Registration.Event'), |
|
69 | - ) |
|
70 | - ); |
|
35 | + /** |
|
36 | + * Returns data for export. |
|
37 | + * |
|
38 | + * @param string $email_address , |
|
39 | + * @param int $page starts at 1, not 0 |
|
40 | + * @return array { |
|
41 | + * @type array $data { |
|
42 | + * @type array { |
|
43 | + * @type string $group_id (not translated, same for all exports) |
|
44 | + * @type string $group_label (translated string) |
|
45 | + * @type string|int $item_id |
|
46 | + * @type array $data { |
|
47 | + * @type array { |
|
48 | + * @type string $name what's shown in the left-column of the export row |
|
49 | + * @type string $value what's showin the right-column of the export row |
|
50 | + * } |
|
51 | + * } |
|
52 | + * } |
|
53 | + * } |
|
54 | + * } |
|
55 | + */ |
|
56 | + public function export($email_address, $page = 1) |
|
57 | + { |
|
58 | + $page_size = 10; |
|
59 | + $checkins = $this->checkin_model->get_all( |
|
60 | + array( |
|
61 | + array( |
|
62 | + 'Registration.Attendee.ATT_email' => $email_address, |
|
63 | + ), |
|
64 | + 'limit' => array( |
|
65 | + ($page - 1) * $page_size, |
|
66 | + $page_size, |
|
67 | + ), |
|
68 | + 'force_join' => array('Registration.Event'), |
|
69 | + ) |
|
70 | + ); |
|
71 | 71 | |
72 | - if (empty($checkins)) { |
|
73 | - return array( |
|
74 | - 'data' => array(), |
|
75 | - 'done' => true, |
|
76 | - ); |
|
77 | - } |
|
72 | + if (empty($checkins)) { |
|
73 | + return array( |
|
74 | + 'data' => array(), |
|
75 | + 'done' => true, |
|
76 | + ); |
|
77 | + } |
|
78 | 78 | |
79 | - $export_items = array(); |
|
80 | - foreach ($checkins as $checkin) { |
|
81 | - $reg = $checkin->get_first_related('Registration'); |
|
82 | - if ($reg instanceof EE_Registration) { |
|
83 | - $event_name = $reg->event_name(); |
|
84 | - } else { |
|
85 | - $event_name = esc_html__('Unknown', 'event_espresso'); |
|
86 | - } |
|
87 | - $export_items[] = |
|
88 | - array( |
|
89 | - 'group_id' => 'check-ins', |
|
90 | - 'group_label' => esc_html__('Event Check-Ins', 'event_espresso'), |
|
91 | - 'item_id' => $checkin->ID(), |
|
92 | - 'data' => array( |
|
93 | - array( |
|
94 | - 'name' => esc_html__('Time', 'event_espresso'), |
|
95 | - 'value' => $checkin->get_pretty('CHK_timestamp'), |
|
96 | - ), |
|
97 | - array( |
|
98 | - 'name' => esc_html__('Check in/out', 'event_espresso'), |
|
99 | - 'value' => $checkin->get('CHK_in') |
|
100 | - ? esc_html__('In', 'event_espresso') |
|
101 | - : esc_html__('Out', 'event_espresso'), |
|
102 | - ), |
|
103 | - array( |
|
104 | - 'name' => esc_html__('Event', 'event_espresso'), |
|
105 | - 'value' => $event_name, |
|
106 | - ), |
|
107 | - ), |
|
108 | - ); |
|
109 | - } |
|
110 | - return array( |
|
111 | - 'data' => $export_items, |
|
112 | - 'done' => true, |
|
113 | - ); |
|
114 | - } |
|
79 | + $export_items = array(); |
|
80 | + foreach ($checkins as $checkin) { |
|
81 | + $reg = $checkin->get_first_related('Registration'); |
|
82 | + if ($reg instanceof EE_Registration) { |
|
83 | + $event_name = $reg->event_name(); |
|
84 | + } else { |
|
85 | + $event_name = esc_html__('Unknown', 'event_espresso'); |
|
86 | + } |
|
87 | + $export_items[] = |
|
88 | + array( |
|
89 | + 'group_id' => 'check-ins', |
|
90 | + 'group_label' => esc_html__('Event Check-Ins', 'event_espresso'), |
|
91 | + 'item_id' => $checkin->ID(), |
|
92 | + 'data' => array( |
|
93 | + array( |
|
94 | + 'name' => esc_html__('Time', 'event_espresso'), |
|
95 | + 'value' => $checkin->get_pretty('CHK_timestamp'), |
|
96 | + ), |
|
97 | + array( |
|
98 | + 'name' => esc_html__('Check in/out', 'event_espresso'), |
|
99 | + 'value' => $checkin->get('CHK_in') |
|
100 | + ? esc_html__('In', 'event_espresso') |
|
101 | + : esc_html__('Out', 'event_espresso'), |
|
102 | + ), |
|
103 | + array( |
|
104 | + 'name' => esc_html__('Event', 'event_espresso'), |
|
105 | + 'value' => $event_name, |
|
106 | + ), |
|
107 | + ), |
|
108 | + ); |
|
109 | + } |
|
110 | + return array( |
|
111 | + 'data' => $export_items, |
|
112 | + 'done' => true, |
|
113 | + ); |
|
114 | + } |
|
115 | 115 | |
116 | - /** |
|
117 | - * Gets the Translated name of this exporter |
|
118 | - * |
|
119 | - * @return string |
|
120 | - */ |
|
121 | - public function name() |
|
122 | - { |
|
123 | - return esc_html__('Event Espresso Checkins Exporter', 'event_espresso'); |
|
124 | - } |
|
116 | + /** |
|
117 | + * Gets the Translated name of this exporter |
|
118 | + * |
|
119 | + * @return string |
|
120 | + */ |
|
121 | + public function name() |
|
122 | + { |
|
123 | + return esc_html__('Event Espresso Checkins Exporter', 'event_espresso'); |
|
124 | + } |
|
125 | 125 | } |
126 | 126 | // End of file ExportCheckins.php |
127 | 127 | // Location: EventEspresso\core\domain\services\admin\privacy\export/ExportCheckins.php |
@@ -15,116 +15,116 @@ |
||
15 | 15 | */ |
16 | 16 | class ExportAttendee implements PersonalDataExporterInterface |
17 | 17 | { |
18 | - /** |
|
19 | - * @var EEM_Attendee |
|
20 | - */ |
|
21 | - protected $attendee_model; |
|
18 | + /** |
|
19 | + * @var EEM_Attendee |
|
20 | + */ |
|
21 | + protected $attendee_model; |
|
22 | 22 | |
23 | - /** |
|
24 | - * ExportAttendee constructor. |
|
25 | - * |
|
26 | - * @param EEM_Attendee $attendee_model |
|
27 | - */ |
|
28 | - public function __construct(EEM_Attendee $attendee_model) |
|
29 | - { |
|
30 | - $this->attendee_model = $attendee_model; |
|
31 | - } |
|
23 | + /** |
|
24 | + * ExportAttendee constructor. |
|
25 | + * |
|
26 | + * @param EEM_Attendee $attendee_model |
|
27 | + */ |
|
28 | + public function __construct(EEM_Attendee $attendee_model) |
|
29 | + { |
|
30 | + $this->attendee_model = $attendee_model; |
|
31 | + } |
|
32 | 32 | |
33 | 33 | |
34 | - /** |
|
35 | - * Returns data for export. |
|
36 | - * |
|
37 | - * @param string $email_address , |
|
38 | - * @param int $page starts at 1, not 0 |
|
39 | - * @return array { |
|
40 | - * @type array $data { |
|
41 | - * @type array { |
|
42 | - * @type string $group_id (not translated, same for all exports) |
|
43 | - * @type string $group_label (translated string) |
|
44 | - * @type string|int $item_id |
|
45 | - * @type array $data { |
|
46 | - * @type array { |
|
47 | - * @type string $name what's shown in the left-column of the export row |
|
48 | - * @type string $value what's showin the right-column of the export row |
|
49 | - * } |
|
50 | - * } |
|
51 | - * } |
|
52 | - * } |
|
53 | - * } |
|
54 | - */ |
|
55 | - public function export($email_address, $page = 1) |
|
56 | - { |
|
57 | - $attendees = $this->attendee_model->get_all( |
|
58 | - array( |
|
59 | - array( |
|
60 | - 'ATT_email' => $email_address, |
|
61 | - ), |
|
62 | - ) |
|
63 | - ); |
|
34 | + /** |
|
35 | + * Returns data for export. |
|
36 | + * |
|
37 | + * @param string $email_address , |
|
38 | + * @param int $page starts at 1, not 0 |
|
39 | + * @return array { |
|
40 | + * @type array $data { |
|
41 | + * @type array { |
|
42 | + * @type string $group_id (not translated, same for all exports) |
|
43 | + * @type string $group_label (translated string) |
|
44 | + * @type string|int $item_id |
|
45 | + * @type array $data { |
|
46 | + * @type array { |
|
47 | + * @type string $name what's shown in the left-column of the export row |
|
48 | + * @type string $value what's showin the right-column of the export row |
|
49 | + * } |
|
50 | + * } |
|
51 | + * } |
|
52 | + * } |
|
53 | + * } |
|
54 | + */ |
|
55 | + public function export($email_address, $page = 1) |
|
56 | + { |
|
57 | + $attendees = $this->attendee_model->get_all( |
|
58 | + array( |
|
59 | + array( |
|
60 | + 'ATT_email' => $email_address, |
|
61 | + ), |
|
62 | + ) |
|
63 | + ); |
|
64 | 64 | |
65 | - if (empty($attendees)) { |
|
66 | - return array( |
|
67 | - 'data' => array(), |
|
68 | - 'done' => true, |
|
69 | - ); |
|
70 | - } |
|
65 | + if (empty($attendees)) { |
|
66 | + return array( |
|
67 | + 'data' => array(), |
|
68 | + 'done' => true, |
|
69 | + ); |
|
70 | + } |
|
71 | 71 | |
72 | - $export_items = array(); |
|
73 | - foreach ($attendees as $attendee) { |
|
74 | - $export_fields = array_intersect_key( |
|
75 | - $this->attendee_model->field_settings(), |
|
76 | - array_flip( |
|
77 | - array( |
|
78 | - 'ATT_fname', |
|
79 | - 'ATT_lname', |
|
80 | - 'ATT_email', |
|
81 | - 'ATT_address1', |
|
82 | - 'ATT_address2', |
|
83 | - 'ATT_city', |
|
84 | - 'STA_ID', |
|
85 | - 'CNT_ISO', |
|
86 | - 'ATT_zip', |
|
87 | - 'ATT_phone', |
|
88 | - ) |
|
89 | - ) |
|
90 | - ); |
|
91 | - $data = array(); |
|
92 | - foreach ($export_fields as $field_name => $field_obj) { |
|
93 | - if ($field_name === 'STA_ID') { |
|
94 | - $value = $attendee->state_name(); |
|
95 | - } elseif ($field_name == 'CNT_ISO') { |
|
96 | - $value = $attendee->country_name(); |
|
97 | - } else { |
|
98 | - $value = $attendee->get_pretty($field_name); |
|
99 | - } |
|
100 | - $data[] = array( |
|
101 | - 'name' => $field_obj->get_nicename(), |
|
102 | - 'value' => $value, |
|
103 | - ); |
|
104 | - } |
|
105 | - $export_items[] = |
|
106 | - array( |
|
107 | - 'group_id' => 'att-' . $attendee->ID(), |
|
108 | - 'group_label' => esc_html__('Contact Profiles', 'event_espresso'), |
|
109 | - 'item_id' => $attendee->ID(), |
|
110 | - 'data' => $data, |
|
111 | - ); |
|
112 | - } |
|
113 | - return array( |
|
114 | - 'data' => $export_items, |
|
115 | - 'done' => true, |
|
116 | - ); |
|
117 | - } |
|
72 | + $export_items = array(); |
|
73 | + foreach ($attendees as $attendee) { |
|
74 | + $export_fields = array_intersect_key( |
|
75 | + $this->attendee_model->field_settings(), |
|
76 | + array_flip( |
|
77 | + array( |
|
78 | + 'ATT_fname', |
|
79 | + 'ATT_lname', |
|
80 | + 'ATT_email', |
|
81 | + 'ATT_address1', |
|
82 | + 'ATT_address2', |
|
83 | + 'ATT_city', |
|
84 | + 'STA_ID', |
|
85 | + 'CNT_ISO', |
|
86 | + 'ATT_zip', |
|
87 | + 'ATT_phone', |
|
88 | + ) |
|
89 | + ) |
|
90 | + ); |
|
91 | + $data = array(); |
|
92 | + foreach ($export_fields as $field_name => $field_obj) { |
|
93 | + if ($field_name === 'STA_ID') { |
|
94 | + $value = $attendee->state_name(); |
|
95 | + } elseif ($field_name == 'CNT_ISO') { |
|
96 | + $value = $attendee->country_name(); |
|
97 | + } else { |
|
98 | + $value = $attendee->get_pretty($field_name); |
|
99 | + } |
|
100 | + $data[] = array( |
|
101 | + 'name' => $field_obj->get_nicename(), |
|
102 | + 'value' => $value, |
|
103 | + ); |
|
104 | + } |
|
105 | + $export_items[] = |
|
106 | + array( |
|
107 | + 'group_id' => 'att-' . $attendee->ID(), |
|
108 | + 'group_label' => esc_html__('Contact Profiles', 'event_espresso'), |
|
109 | + 'item_id' => $attendee->ID(), |
|
110 | + 'data' => $data, |
|
111 | + ); |
|
112 | + } |
|
113 | + return array( |
|
114 | + 'data' => $export_items, |
|
115 | + 'done' => true, |
|
116 | + ); |
|
117 | + } |
|
118 | 118 | |
119 | - /** |
|
120 | - * Gets the Translated name of this exporter |
|
121 | - * |
|
122 | - * @return string |
|
123 | - */ |
|
124 | - public function name() |
|
125 | - { |
|
126 | - return esc_html__('Event Espresso Attendee Data Exporter', 'event_espresso'); |
|
127 | - } |
|
119 | + /** |
|
120 | + * Gets the Translated name of this exporter |
|
121 | + * |
|
122 | + * @return string |
|
123 | + */ |
|
124 | + public function name() |
|
125 | + { |
|
126 | + return esc_html__('Event Espresso Attendee Data Exporter', 'event_espresso'); |
|
127 | + } |
|
128 | 128 | } |
129 | 129 | // End of file ExportAttendee.php |
130 | 130 | // Location: EventEspresso\core\domain\services\admin\privacy\export/ExportAttendee.php |
@@ -104,7 +104,7 @@ |
||
104 | 104 | } |
105 | 105 | $export_items[] = |
106 | 106 | array( |
107 | - 'group_id' => 'att-' . $attendee->ID(), |
|
107 | + 'group_id' => 'att-'.$attendee->ID(), |
|
108 | 108 | 'group_label' => esc_html__('Contact Profiles', 'event_espresso'), |
109 | 109 | 'item_id' => $attendee->ID(), |
110 | 110 | 'data' => $data, |
@@ -18,133 +18,133 @@ |
||
18 | 18 | */ |
19 | 19 | class ExportRegistration implements PersonalDataExporterInterface |
20 | 20 | { |
21 | - /** |
|
22 | - * @var EEM_Registration |
|
23 | - */ |
|
24 | - protected $registration_model; |
|
21 | + /** |
|
22 | + * @var EEM_Registration |
|
23 | + */ |
|
24 | + protected $registration_model; |
|
25 | 25 | |
26 | - /** |
|
27 | - * ExportRegistration constructor. |
|
28 | - * |
|
29 | - * @param EEM_Registration $registration_model |
|
30 | - */ |
|
31 | - public function __construct(EEM_Registration $registration_model) |
|
32 | - { |
|
33 | - $this->registration_model = $registration_model; |
|
34 | - } |
|
26 | + /** |
|
27 | + * ExportRegistration constructor. |
|
28 | + * |
|
29 | + * @param EEM_Registration $registration_model |
|
30 | + */ |
|
31 | + public function __construct(EEM_Registration $registration_model) |
|
32 | + { |
|
33 | + $this->registration_model = $registration_model; |
|
34 | + } |
|
35 | 35 | |
36 | 36 | |
37 | - /** |
|
38 | - * Returns data for export. |
|
39 | - * |
|
40 | - * @param string $email_address , |
|
41 | - * @param int $page starts at 1, not 0 |
|
42 | - * @return array { |
|
43 | - * @type array $data { |
|
44 | - * @type array { |
|
45 | - * @type string $group_id (not translated, same for all exports) |
|
46 | - * @type string $group_label (translated string) |
|
47 | - * @type string|int $item_id |
|
48 | - * @type array $data { |
|
49 | - * @type array { |
|
50 | - * @type string $name what's shown in the left-column of the export row |
|
51 | - * @type string $value what's showin the right-column of the export row |
|
52 | - * } |
|
53 | - * } |
|
54 | - * } |
|
55 | - * } |
|
56 | - * } |
|
57 | - */ |
|
58 | - public function export($email_address, $page = 1) |
|
59 | - { |
|
60 | - $page_size = 10; |
|
61 | - $registrations = $this->registration_model->get_all( |
|
62 | - array( |
|
63 | - array( |
|
64 | - 'Attendee.ATT_email' => $email_address, |
|
65 | - ), |
|
66 | - 'limit' => array( |
|
67 | - ($page - 1) * $page_size, |
|
68 | - $page_size, |
|
69 | - ), |
|
70 | - ) |
|
71 | - ); |
|
72 | - $export_fields = array_intersect_key( |
|
73 | - $this->registration_model->field_settings(), |
|
74 | - array_flip( |
|
75 | - array( |
|
76 | - 'REG_code', |
|
77 | - 'REG_date', |
|
78 | - 'REG_final_price', |
|
79 | - 'REG_paid', |
|
80 | - 'REG_url_link', |
|
81 | - 'REG_count', |
|
82 | - 'REG_group_size', |
|
83 | - 'REG_att_is_going', |
|
84 | - ) |
|
85 | - ) |
|
86 | - ); |
|
87 | - $export_items = array(); |
|
88 | - $found_something = false; |
|
89 | - foreach ($registrations as $registration) { |
|
90 | - /** |
|
91 | - * @var $registration EE_Registration |
|
92 | - */ |
|
93 | - $found_something = true; |
|
94 | - $data = array(); |
|
95 | - foreach ($export_fields as $field_name => $field_obj) { |
|
96 | - $data[] = array( |
|
97 | - 'name' => $field_obj->get_nicename(), |
|
98 | - 'value' => $registration->get_pretty($field_name), |
|
99 | - ); |
|
100 | - } |
|
101 | - $answers = $registration->answers( |
|
102 | - array( |
|
103 | - 'force_join' => array( |
|
104 | - 'Question', |
|
105 | - ), |
|
106 | - ) |
|
107 | - ); |
|
108 | - foreach ($answers as $answer) { |
|
109 | - $data[] = array( |
|
110 | - 'name' => $answer->question()->display_text(), |
|
111 | - 'value' => $answer->pretty_value(), |
|
112 | - ); |
|
113 | - } |
|
114 | - $ticket = $registration->ticket(); |
|
115 | - if ($ticket instanceof EE_Ticket) { |
|
116 | - $data[] = array( |
|
117 | - 'name' => esc_html__('Ticket', 'event_espresso'), |
|
118 | - 'value' => $ticket->name_and_info(), |
|
119 | - ); |
|
120 | - $data[] = array( |
|
121 | - 'name' => esc_html__('Event', 'event_espresso'), |
|
122 | - 'value' => $ticket->get_event_name(), |
|
123 | - ); |
|
124 | - } |
|
37 | + /** |
|
38 | + * Returns data for export. |
|
39 | + * |
|
40 | + * @param string $email_address , |
|
41 | + * @param int $page starts at 1, not 0 |
|
42 | + * @return array { |
|
43 | + * @type array $data { |
|
44 | + * @type array { |
|
45 | + * @type string $group_id (not translated, same for all exports) |
|
46 | + * @type string $group_label (translated string) |
|
47 | + * @type string|int $item_id |
|
48 | + * @type array $data { |
|
49 | + * @type array { |
|
50 | + * @type string $name what's shown in the left-column of the export row |
|
51 | + * @type string $value what's showin the right-column of the export row |
|
52 | + * } |
|
53 | + * } |
|
54 | + * } |
|
55 | + * } |
|
56 | + * } |
|
57 | + */ |
|
58 | + public function export($email_address, $page = 1) |
|
59 | + { |
|
60 | + $page_size = 10; |
|
61 | + $registrations = $this->registration_model->get_all( |
|
62 | + array( |
|
63 | + array( |
|
64 | + 'Attendee.ATT_email' => $email_address, |
|
65 | + ), |
|
66 | + 'limit' => array( |
|
67 | + ($page - 1) * $page_size, |
|
68 | + $page_size, |
|
69 | + ), |
|
70 | + ) |
|
71 | + ); |
|
72 | + $export_fields = array_intersect_key( |
|
73 | + $this->registration_model->field_settings(), |
|
74 | + array_flip( |
|
75 | + array( |
|
76 | + 'REG_code', |
|
77 | + 'REG_date', |
|
78 | + 'REG_final_price', |
|
79 | + 'REG_paid', |
|
80 | + 'REG_url_link', |
|
81 | + 'REG_count', |
|
82 | + 'REG_group_size', |
|
83 | + 'REG_att_is_going', |
|
84 | + ) |
|
85 | + ) |
|
86 | + ); |
|
87 | + $export_items = array(); |
|
88 | + $found_something = false; |
|
89 | + foreach ($registrations as $registration) { |
|
90 | + /** |
|
91 | + * @var $registration EE_Registration |
|
92 | + */ |
|
93 | + $found_something = true; |
|
94 | + $data = array(); |
|
95 | + foreach ($export_fields as $field_name => $field_obj) { |
|
96 | + $data[] = array( |
|
97 | + 'name' => $field_obj->get_nicename(), |
|
98 | + 'value' => $registration->get_pretty($field_name), |
|
99 | + ); |
|
100 | + } |
|
101 | + $answers = $registration->answers( |
|
102 | + array( |
|
103 | + 'force_join' => array( |
|
104 | + 'Question', |
|
105 | + ), |
|
106 | + ) |
|
107 | + ); |
|
108 | + foreach ($answers as $answer) { |
|
109 | + $data[] = array( |
|
110 | + 'name' => $answer->question()->display_text(), |
|
111 | + 'value' => $answer->pretty_value(), |
|
112 | + ); |
|
113 | + } |
|
114 | + $ticket = $registration->ticket(); |
|
115 | + if ($ticket instanceof EE_Ticket) { |
|
116 | + $data[] = array( |
|
117 | + 'name' => esc_html__('Ticket', 'event_espresso'), |
|
118 | + 'value' => $ticket->name_and_info(), |
|
119 | + ); |
|
120 | + $data[] = array( |
|
121 | + 'name' => esc_html__('Event', 'event_espresso'), |
|
122 | + 'value' => $ticket->get_event_name(), |
|
123 | + ); |
|
124 | + } |
|
125 | 125 | |
126 | - $export_items[] = array( |
|
127 | - 'group_id' => 'registration', |
|
128 | - 'group_label' => esc_html__('Event Registrations', 'event_espresso'), |
|
129 | - 'item_id' => $registration->ID(), |
|
130 | - 'data' => $data, |
|
131 | - ); |
|
132 | - } |
|
133 | - return array( |
|
134 | - 'data' => $export_items, |
|
135 | - 'done' => ! $found_something, |
|
136 | - ); |
|
137 | - } |
|
126 | + $export_items[] = array( |
|
127 | + 'group_id' => 'registration', |
|
128 | + 'group_label' => esc_html__('Event Registrations', 'event_espresso'), |
|
129 | + 'item_id' => $registration->ID(), |
|
130 | + 'data' => $data, |
|
131 | + ); |
|
132 | + } |
|
133 | + return array( |
|
134 | + 'data' => $export_items, |
|
135 | + 'done' => ! $found_something, |
|
136 | + ); |
|
137 | + } |
|
138 | 138 | |
139 | - /** |
|
140 | - * Gets the Translated name of this exporter |
|
141 | - * |
|
142 | - * @return string |
|
143 | - */ |
|
144 | - public function name() |
|
145 | - { |
|
146 | - return esc_html__('Event Espresso Registration Data Exporter', 'event_espresso'); |
|
147 | - } |
|
139 | + /** |
|
140 | + * Gets the Translated name of this exporter |
|
141 | + * |
|
142 | + * @return string |
|
143 | + */ |
|
144 | + public function name() |
|
145 | + { |
|
146 | + return esc_html__('Event Espresso Registration Data Exporter', 'event_espresso'); |
|
147 | + } |
|
148 | 148 | } |
149 | 149 | // End of file ExportRegistration.php |
150 | 150 | // Location: EventEspresso\core\domain\services\admin\privacy\export/ExportRegistration.php |
@@ -7,16 +7,16 @@ discard block |
||
7 | 7 | define('EE_SUPPORT_EMAIL', '[email protected]'); |
8 | 8 | // used to be DIRECTORY_SEPARATOR, but that caused issues on windows |
9 | 9 | if (! defined('DS')) { |
10 | - define('DS', '/'); |
|
10 | + define('DS', '/'); |
|
11 | 11 | } |
12 | 12 | if (! defined('PS')) { |
13 | - define('PS', PATH_SEPARATOR); |
|
13 | + define('PS', PATH_SEPARATOR); |
|
14 | 14 | } |
15 | 15 | if (! defined('SP')) { |
16 | - define('SP', ' '); |
|
16 | + define('SP', ' '); |
|
17 | 17 | } |
18 | 18 | if (! defined('EENL')) { |
19 | - define('EENL', "\n"); |
|
19 | + define('EENL', "\n"); |
|
20 | 20 | } |
21 | 21 | // define the plugin directory and URL |
22 | 22 | define('EE_PLUGIN_BASENAME', plugin_basename(EVENT_ESPRESSO_MAIN_FILE)); |
@@ -70,16 +70,16 @@ discard block |
||
70 | 70 | define('EE_LANGUAGES_SAFE_DIR', EVENT_ESPRESSO_UPLOAD_DIR . 'languages' . DS); |
71 | 71 | // check for DOMPDF fonts in uploads |
72 | 72 | if (file_exists(EVENT_ESPRESSO_UPLOAD_DIR . 'fonts' . DS)) { |
73 | - define('DOMPDF_FONT_DIR', EVENT_ESPRESSO_UPLOAD_DIR . 'fonts' . DS); |
|
73 | + define('DOMPDF_FONT_DIR', EVENT_ESPRESSO_UPLOAD_DIR . 'fonts' . DS); |
|
74 | 74 | } |
75 | 75 | // ajax constants |
76 | 76 | define( |
77 | - 'EE_FRONT_AJAX', |
|
78 | - isset($_REQUEST['ee_front_ajax']) || isset($_REQUEST['data']['ee_front_ajax']) |
|
77 | + 'EE_FRONT_AJAX', |
|
78 | + isset($_REQUEST['ee_front_ajax']) || isset($_REQUEST['data']['ee_front_ajax']) |
|
79 | 79 | ); |
80 | 80 | define( |
81 | - 'EE_ADMIN_AJAX', |
|
82 | - isset($_REQUEST['ee_admin_ajax']) || isset($_REQUEST['data']['ee_admin_ajax']) |
|
81 | + 'EE_ADMIN_AJAX', |
|
82 | + isset($_REQUEST['ee_admin_ajax']) || isset($_REQUEST['data']['ee_admin_ajax']) |
|
83 | 83 | ); |
84 | 84 | // just a handy constant occasionally needed for finding values representing infinity in the DB |
85 | 85 | // you're better to use this than its straight value (currently -1) in case you ever |
@@ -89,5 +89,5 @@ discard block |
||
89 | 89 | define('EE_DEBUG', false); |
90 | 90 | // for older WP versions |
91 | 91 | if (! defined('MONTH_IN_SECONDS')) { |
92 | - define('MONTH_IN_SECONDS', DAY_IN_SECONDS * 30); |
|
92 | + define('MONTH_IN_SECONDS', DAY_IN_SECONDS * 30); |
|
93 | 93 | } |
@@ -6,71 +6,71 @@ discard block |
||
6 | 6 | define('EE_MIN_PHP_VER_RECOMMENDED', '5.6.32'); |
7 | 7 | define('EE_SUPPORT_EMAIL', '[email protected]'); |
8 | 8 | // used to be DIRECTORY_SEPARATOR, but that caused issues on windows |
9 | -if (! defined('DS')) { |
|
9 | +if ( ! defined('DS')) { |
|
10 | 10 | define('DS', '/'); |
11 | 11 | } |
12 | -if (! defined('PS')) { |
|
12 | +if ( ! defined('PS')) { |
|
13 | 13 | define('PS', PATH_SEPARATOR); |
14 | 14 | } |
15 | -if (! defined('SP')) { |
|
15 | +if ( ! defined('SP')) { |
|
16 | 16 | define('SP', ' '); |
17 | 17 | } |
18 | -if (! defined('EENL')) { |
|
18 | +if ( ! defined('EENL')) { |
|
19 | 19 | define('EENL', "\n"); |
20 | 20 | } |
21 | 21 | // define the plugin directory and URL |
22 | 22 | define('EE_PLUGIN_BASENAME', plugin_basename(EVENT_ESPRESSO_MAIN_FILE)); |
23 | -define('EE_PLUGIN_DIR_PATH', dirname(EVENT_ESPRESSO_MAIN_FILE) . DS); |
|
23 | +define('EE_PLUGIN_DIR_PATH', dirname(EVENT_ESPRESSO_MAIN_FILE).DS); |
|
24 | 24 | define('EE_PLUGIN_DIR_URL', plugin_dir_url(EVENT_ESPRESSO_MAIN_FILE)); |
25 | 25 | // main root folder paths |
26 | -define('EE_ADMIN_PAGES', EE_PLUGIN_DIR_PATH . 'admin_pages' . DS); |
|
27 | -define('EE_CORE', EE_PLUGIN_DIR_PATH . 'core' . DS); |
|
28 | -define('EE_MODULES', EE_PLUGIN_DIR_PATH . 'modules' . DS); |
|
29 | -define('EE_PUBLIC', EE_PLUGIN_DIR_PATH . 'public' . DS); |
|
30 | -define('EE_SHORTCODES', EE_PLUGIN_DIR_PATH . 'shortcodes' . DS); |
|
31 | -define('EE_WIDGETS', EE_PLUGIN_DIR_PATH . 'widgets' . DS); |
|
32 | -define('EE_PAYMENT_METHODS', EE_PLUGIN_DIR_PATH . 'payment_methods' . DS); |
|
33 | -define('EE_CAFF_PATH', EE_PLUGIN_DIR_PATH . 'caffeinated' . DS); |
|
26 | +define('EE_ADMIN_PAGES', EE_PLUGIN_DIR_PATH.'admin_pages'.DS); |
|
27 | +define('EE_CORE', EE_PLUGIN_DIR_PATH.'core'.DS); |
|
28 | +define('EE_MODULES', EE_PLUGIN_DIR_PATH.'modules'.DS); |
|
29 | +define('EE_PUBLIC', EE_PLUGIN_DIR_PATH.'public'.DS); |
|
30 | +define('EE_SHORTCODES', EE_PLUGIN_DIR_PATH.'shortcodes'.DS); |
|
31 | +define('EE_WIDGETS', EE_PLUGIN_DIR_PATH.'widgets'.DS); |
|
32 | +define('EE_PAYMENT_METHODS', EE_PLUGIN_DIR_PATH.'payment_methods'.DS); |
|
33 | +define('EE_CAFF_PATH', EE_PLUGIN_DIR_PATH.'caffeinated'.DS); |
|
34 | 34 | // core system paths |
35 | -define('EE_ADMIN', EE_CORE . 'admin' . DS); |
|
36 | -define('EE_CPTS', EE_CORE . 'CPTs' . DS); |
|
37 | -define('EE_CLASSES', EE_CORE . 'db_classes' . DS); |
|
38 | -define('EE_INTERFACES', EE_CORE . 'interfaces' . DS); |
|
39 | -define('EE_BUSINESS', EE_CORE . 'business' . DS); |
|
40 | -define('EE_MODELS', EE_CORE . 'db_models' . DS); |
|
41 | -define('EE_HELPERS', EE_CORE . 'helpers' . DS); |
|
42 | -define('EE_LIBRARIES', EE_CORE . 'libraries' . DS); |
|
43 | -define('EE_TEMPLATES', EE_CORE . 'templates' . DS); |
|
44 | -define('EE_THIRD_PARTY', EE_CORE . 'third_party_libs' . DS); |
|
45 | -define('EE_GLOBAL_ASSETS', EE_TEMPLATES . 'global_assets' . DS); |
|
46 | -define('EE_FORM_SECTIONS', EE_LIBRARIES . 'form_sections' . DS); |
|
35 | +define('EE_ADMIN', EE_CORE.'admin'.DS); |
|
36 | +define('EE_CPTS', EE_CORE.'CPTs'.DS); |
|
37 | +define('EE_CLASSES', EE_CORE.'db_classes'.DS); |
|
38 | +define('EE_INTERFACES', EE_CORE.'interfaces'.DS); |
|
39 | +define('EE_BUSINESS', EE_CORE.'business'.DS); |
|
40 | +define('EE_MODELS', EE_CORE.'db_models'.DS); |
|
41 | +define('EE_HELPERS', EE_CORE.'helpers'.DS); |
|
42 | +define('EE_LIBRARIES', EE_CORE.'libraries'.DS); |
|
43 | +define('EE_TEMPLATES', EE_CORE.'templates'.DS); |
|
44 | +define('EE_THIRD_PARTY', EE_CORE.'third_party_libs'.DS); |
|
45 | +define('EE_GLOBAL_ASSETS', EE_TEMPLATES.'global_assets'.DS); |
|
46 | +define('EE_FORM_SECTIONS', EE_LIBRARIES.'form_sections'.DS); |
|
47 | 47 | // gateways |
48 | -define('EE_GATEWAYS', EE_MODULES . 'gateways' . DS); |
|
49 | -define('EE_GATEWAYS_URL', EE_PLUGIN_DIR_URL . 'modules' . DS . 'gateways' . DS); |
|
48 | +define('EE_GATEWAYS', EE_MODULES.'gateways'.DS); |
|
49 | +define('EE_GATEWAYS_URL', EE_PLUGIN_DIR_URL.'modules'.DS.'gateways'.DS); |
|
50 | 50 | // asset URL paths |
51 | -define('EE_TEMPLATES_URL', EE_PLUGIN_DIR_URL . 'core' . DS . 'templates' . DS); |
|
52 | -define('EE_GLOBAL_ASSETS_URL', EE_TEMPLATES_URL . 'global_assets' . DS); |
|
53 | -define('EE_IMAGES_URL', EE_GLOBAL_ASSETS_URL . 'images' . DS); |
|
54 | -define('EE_THIRD_PARTY_URL', EE_PLUGIN_DIR_URL . 'core' . DS . 'third_party_libs' . DS); |
|
55 | -define('EE_HELPERS_ASSETS', EE_PLUGIN_DIR_URL . 'core/helpers/assets/'); |
|
56 | -define('EE_LIBRARIES_URL', EE_PLUGIN_DIR_URL . 'core/libraries/'); |
|
51 | +define('EE_TEMPLATES_URL', EE_PLUGIN_DIR_URL.'core'.DS.'templates'.DS); |
|
52 | +define('EE_GLOBAL_ASSETS_URL', EE_TEMPLATES_URL.'global_assets'.DS); |
|
53 | +define('EE_IMAGES_URL', EE_GLOBAL_ASSETS_URL.'images'.DS); |
|
54 | +define('EE_THIRD_PARTY_URL', EE_PLUGIN_DIR_URL.'core'.DS.'third_party_libs'.DS); |
|
55 | +define('EE_HELPERS_ASSETS', EE_PLUGIN_DIR_URL.'core/helpers/assets/'); |
|
56 | +define('EE_LIBRARIES_URL', EE_PLUGIN_DIR_URL.'core/libraries/'); |
|
57 | 57 | // define upload paths |
58 | 58 | $uploads = wp_upload_dir(); |
59 | 59 | // define the uploads directory and URL |
60 | -define('EVENT_ESPRESSO_UPLOAD_DIR', $uploads['basedir'] . DS . 'espresso' . DS); |
|
61 | -define('EVENT_ESPRESSO_UPLOAD_URL', $uploads['baseurl'] . DS . 'espresso' . DS); |
|
60 | +define('EVENT_ESPRESSO_UPLOAD_DIR', $uploads['basedir'].DS.'espresso'.DS); |
|
61 | +define('EVENT_ESPRESSO_UPLOAD_URL', $uploads['baseurl'].DS.'espresso'.DS); |
|
62 | 62 | // define the templates directory and URL |
63 | -define('EVENT_ESPRESSO_TEMPLATE_DIR', $uploads['basedir'] . DS . 'espresso' . DS . 'templates' . DS); |
|
64 | -define('EVENT_ESPRESSO_TEMPLATE_URL', $uploads['baseurl'] . DS . 'espresso' . DS . 'templates' . DS); |
|
63 | +define('EVENT_ESPRESSO_TEMPLATE_DIR', $uploads['basedir'].DS.'espresso'.DS.'templates'.DS); |
|
64 | +define('EVENT_ESPRESSO_TEMPLATE_URL', $uploads['baseurl'].DS.'espresso'.DS.'templates'.DS); |
|
65 | 65 | // define the gateway directory and URL |
66 | -define('EVENT_ESPRESSO_GATEWAY_DIR', $uploads['basedir'] . DS . 'espresso' . DS . 'gateways' . DS); |
|
67 | -define('EVENT_ESPRESSO_GATEWAY_URL', $uploads['baseurl'] . DS . 'espresso' . DS . 'gateways' . DS); |
|
66 | +define('EVENT_ESPRESSO_GATEWAY_DIR', $uploads['basedir'].DS.'espresso'.DS.'gateways'.DS); |
|
67 | +define('EVENT_ESPRESSO_GATEWAY_URL', $uploads['baseurl'].DS.'espresso'.DS.'gateways'.DS); |
|
68 | 68 | // languages folder/path |
69 | -define('EE_LANGUAGES_SAFE_LOC', '..' . DS . 'uploads' . DS . 'espresso' . DS . 'languages' . DS); |
|
70 | -define('EE_LANGUAGES_SAFE_DIR', EVENT_ESPRESSO_UPLOAD_DIR . 'languages' . DS); |
|
69 | +define('EE_LANGUAGES_SAFE_LOC', '..'.DS.'uploads'.DS.'espresso'.DS.'languages'.DS); |
|
70 | +define('EE_LANGUAGES_SAFE_DIR', EVENT_ESPRESSO_UPLOAD_DIR.'languages'.DS); |
|
71 | 71 | // check for DOMPDF fonts in uploads |
72 | -if (file_exists(EVENT_ESPRESSO_UPLOAD_DIR . 'fonts' . DS)) { |
|
73 | - define('DOMPDF_FONT_DIR', EVENT_ESPRESSO_UPLOAD_DIR . 'fonts' . DS); |
|
72 | +if (file_exists(EVENT_ESPRESSO_UPLOAD_DIR.'fonts'.DS)) { |
|
73 | + define('DOMPDF_FONT_DIR', EVENT_ESPRESSO_UPLOAD_DIR.'fonts'.DS); |
|
74 | 74 | } |
75 | 75 | // ajax constants |
76 | 76 | define( |
@@ -88,6 +88,6 @@ discard block |
||
88 | 88 | define('EE_INF', INF > (float) PHP_INT_MAX ? INF : PHP_INT_MAX); |
89 | 89 | define('EE_DEBUG', false); |
90 | 90 | // for older WP versions |
91 | -if (! defined('MONTH_IN_SECONDS')) { |
|
91 | +if ( ! defined('MONTH_IN_SECONDS')) { |
|
92 | 92 | define('MONTH_IN_SECONDS', DAY_IN_SECONDS * 30); |
93 | 93 | } |