@@ -37,7 +37,7 @@ |
||
37 | 37 | if (get_option(RewriteRules::OPTION_KEY_FLUSH_REWRITE_RULES, true)) { |
38 | 38 | add_action( |
39 | 39 | 'shutdown', |
40 | - static function () { |
|
40 | + static function() { |
|
41 | 41 | flush_rewrite_rules(); |
42 | 42 | update_option(RewriteRules::OPTION_KEY_FLUSH_REWRITE_RULES, false); |
43 | 43 | } |
@@ -12,35 +12,35 @@ |
||
12 | 12 | */ |
13 | 13 | class RewriteRules |
14 | 14 | { |
15 | - const OPTION_KEY_FLUSH_REWRITE_RULES = 'ee_flush_rewrite_rules'; |
|
15 | + const OPTION_KEY_FLUSH_REWRITE_RULES = 'ee_flush_rewrite_rules'; |
|
16 | 16 | |
17 | 17 | |
18 | - /** |
|
19 | - * This will flush rewrite rules on demand. This actually gets called around wp init priority level 100. |
|
20 | - * |
|
21 | - * @return void |
|
22 | - */ |
|
23 | - public function flush() |
|
24 | - { |
|
25 | - update_option(RewriteRules::OPTION_KEY_FLUSH_REWRITE_RULES, true); |
|
26 | - } |
|
18 | + /** |
|
19 | + * This will flush rewrite rules on demand. This actually gets called around wp init priority level 100. |
|
20 | + * |
|
21 | + * @return void |
|
22 | + */ |
|
23 | + public function flush() |
|
24 | + { |
|
25 | + update_option(RewriteRules::OPTION_KEY_FLUSH_REWRITE_RULES, true); |
|
26 | + } |
|
27 | 27 | |
28 | 28 | |
29 | - /** |
|
30 | - * This will flush rewrite rules on demand. This actually gets called around wp init priority level 100. |
|
31 | - * |
|
32 | - * @return void |
|
33 | - */ |
|
34 | - public function flushRewriteRules() |
|
35 | - { |
|
36 | - if (get_option(RewriteRules::OPTION_KEY_FLUSH_REWRITE_RULES, true)) { |
|
37 | - add_action( |
|
38 | - 'shutdown', |
|
39 | - static function () { |
|
40 | - flush_rewrite_rules(); |
|
41 | - update_option(RewriteRules::OPTION_KEY_FLUSH_REWRITE_RULES, false); |
|
42 | - } |
|
43 | - ); |
|
44 | - } |
|
45 | - } |
|
29 | + /** |
|
30 | + * This will flush rewrite rules on demand. This actually gets called around wp init priority level 100. |
|
31 | + * |
|
32 | + * @return void |
|
33 | + */ |
|
34 | + public function flushRewriteRules() |
|
35 | + { |
|
36 | + if (get_option(RewriteRules::OPTION_KEY_FLUSH_REWRITE_RULES, true)) { |
|
37 | + add_action( |
|
38 | + 'shutdown', |
|
39 | + static function () { |
|
40 | + flush_rewrite_rules(); |
|
41 | + update_option(RewriteRules::OPTION_KEY_FLUSH_REWRITE_RULES, false); |
|
42 | + } |
|
43 | + ); |
|
44 | + } |
|
45 | + } |
|
46 | 46 | } |
@@ -68,7 +68,7 @@ |
||
68 | 68 | */ |
69 | 69 | public function visit($model_objects_to_identify) |
70 | 70 | { |
71 | - if (! $this->isDiscovered()) { |
|
71 | + if ( ! $this->isDiscovered()) { |
|
72 | 72 | $this->discover(); |
73 | 73 | } |
74 | 74 | if ($this->isComplete()) { |
@@ -31,105 +31,105 @@ |
||
31 | 31 | */ |
32 | 32 | abstract class BaseNode |
33 | 33 | { |
34 | - /** |
|
35 | - * @var boolean |
|
36 | - */ |
|
37 | - protected $complete; |
|
34 | + /** |
|
35 | + * @var boolean |
|
36 | + */ |
|
37 | + protected $complete; |
|
38 | 38 | |
39 | 39 | |
40 | - /** |
|
41 | - * @var array of model names we don't want to traverse |
|
42 | - */ |
|
43 | - protected $dont_traverse_models; |
|
40 | + /** |
|
41 | + * @var array of model names we don't want to traverse |
|
42 | + */ |
|
43 | + protected $dont_traverse_models; |
|
44 | 44 | |
45 | - /** |
|
46 | - * Whether this item has already been initialized |
|
47 | - */ |
|
48 | - abstract protected function isDiscovered(); |
|
45 | + /** |
|
46 | + * Whether this item has already been initialized |
|
47 | + */ |
|
48 | + abstract protected function isDiscovered(); |
|
49 | 49 | |
50 | - /** |
|
51 | - * Determines if the work is done yet or not. Requires you to have first discovered what work exists by calling |
|
52 | - * discover(). |
|
53 | - * @since 4.10.12.p |
|
54 | - * @return boolean |
|
55 | - */ |
|
56 | - abstract public function isComplete(); |
|
50 | + /** |
|
51 | + * Determines if the work is done yet or not. Requires you to have first discovered what work exists by calling |
|
52 | + * discover(). |
|
53 | + * @since 4.10.12.p |
|
54 | + * @return boolean |
|
55 | + */ |
|
56 | + abstract public function isComplete(); |
|
57 | 57 | |
58 | - /** |
|
59 | - * Discovers what work needs to be done to complete traversing this node and its children. |
|
60 | - * Note that this is separate from the constructor, so we can create child nodes without |
|
61 | - * discovering them immediately. |
|
62 | - * @since 4.10.12.p |
|
63 | - * @return mixed |
|
64 | - */ |
|
65 | - abstract protected function discover(); |
|
58 | + /** |
|
59 | + * Discovers what work needs to be done to complete traversing this node and its children. |
|
60 | + * Note that this is separate from the constructor, so we can create child nodes without |
|
61 | + * discovering them immediately. |
|
62 | + * @since 4.10.12.p |
|
63 | + * @return mixed |
|
64 | + */ |
|
65 | + abstract protected function discover(); |
|
66 | 66 | |
67 | - /** |
|
68 | - * Identifies model objects, up to the limit $model_objects_to_identify. |
|
69 | - * @since 4.10.12.p |
|
70 | - * @param int $model_objects_to_identify |
|
71 | - * @return int units of work done |
|
72 | - */ |
|
73 | - abstract protected function work($model_objects_to_identify); |
|
67 | + /** |
|
68 | + * Identifies model objects, up to the limit $model_objects_to_identify. |
|
69 | + * @since 4.10.12.p |
|
70 | + * @param int $model_objects_to_identify |
|
71 | + * @return int units of work done |
|
72 | + */ |
|
73 | + abstract protected function work($model_objects_to_identify); |
|
74 | 74 | |
75 | - /** |
|
76 | - * Shows the entity/relation node as an array. |
|
77 | - * @since 4.10.12.p |
|
78 | - * @return array |
|
79 | - */ |
|
80 | - abstract public function toArray(); |
|
75 | + /** |
|
76 | + * Shows the entity/relation node as an array. |
|
77 | + * @since 4.10.12.p |
|
78 | + * @return array |
|
79 | + */ |
|
80 | + abstract public function toArray(); |
|
81 | 81 | |
82 | - /** |
|
83 | - * Discovers how much work there is to do, double-checks the work isn't already finished, and then does the work. |
|
84 | - * Note: do not call when site is in maintenance mode level 2. |
|
85 | - * |
|
86 | - * @since 4.10.12.p |
|
87 | - * @param $model_objects_to_identify |
|
88 | - * @return int number of model objects we want to identify during this call. On subsequent calls we'll continue |
|
89 | - * where we left off. |
|
90 | - */ |
|
91 | - public function visit($model_objects_to_identify) |
|
92 | - { |
|
93 | - if (! $this->isDiscovered()) { |
|
94 | - $this->discover(); |
|
95 | - } |
|
96 | - if ($this->isComplete()) { |
|
97 | - return 0; |
|
98 | - } |
|
99 | - return $this->work($model_objects_to_identify); |
|
100 | - } |
|
82 | + /** |
|
83 | + * Discovers how much work there is to do, double-checks the work isn't already finished, and then does the work. |
|
84 | + * Note: do not call when site is in maintenance mode level 2. |
|
85 | + * |
|
86 | + * @since 4.10.12.p |
|
87 | + * @param $model_objects_to_identify |
|
88 | + * @return int number of model objects we want to identify during this call. On subsequent calls we'll continue |
|
89 | + * where we left off. |
|
90 | + */ |
|
91 | + public function visit($model_objects_to_identify) |
|
92 | + { |
|
93 | + if (! $this->isDiscovered()) { |
|
94 | + $this->discover(); |
|
95 | + } |
|
96 | + if ($this->isComplete()) { |
|
97 | + return 0; |
|
98 | + } |
|
99 | + return $this->work($model_objects_to_identify); |
|
100 | + } |
|
101 | 101 | |
102 | - /** |
|
103 | - * Gets the IDs of completely identified model objects that can be deleted. |
|
104 | - * @since 4.10.12.p |
|
105 | - * @return mixed |
|
106 | - */ |
|
107 | - abstract public function getIds(); |
|
102 | + /** |
|
103 | + * Gets the IDs of completely identified model objects that can be deleted. |
|
104 | + * @since 4.10.12.p |
|
105 | + * @return mixed |
|
106 | + */ |
|
107 | + abstract public function getIds(); |
|
108 | 108 | |
109 | - /** |
|
110 | - * Make sure we encode whether its complete or not, but don't use such a long name. |
|
111 | - * @since 4.10.12.p |
|
112 | - * @return array |
|
113 | - */ |
|
114 | - public function __sleep() |
|
115 | - { |
|
116 | - $this->c = $this->complete; |
|
117 | - $this->dtm = $this->dont_traverse_models; |
|
118 | - return [ |
|
119 | - 'c', |
|
120 | - 'dtm' |
|
121 | - ]; |
|
122 | - } |
|
109 | + /** |
|
110 | + * Make sure we encode whether its complete or not, but don't use such a long name. |
|
111 | + * @since 4.10.12.p |
|
112 | + * @return array |
|
113 | + */ |
|
114 | + public function __sleep() |
|
115 | + { |
|
116 | + $this->c = $this->complete; |
|
117 | + $this->dtm = $this->dont_traverse_models; |
|
118 | + return [ |
|
119 | + 'c', |
|
120 | + 'dtm' |
|
121 | + ]; |
|
122 | + } |
|
123 | 123 | |
124 | - /** |
|
125 | - * Use the dynamic property to set the "complete" property. |
|
126 | - * @since 4.10.12.p |
|
127 | - */ |
|
128 | - public function __wakeup() |
|
129 | - { |
|
130 | - $this->complete = $this->c; |
|
131 | - $this->dont_traverse_models = $this->dtm; |
|
132 | - } |
|
124 | + /** |
|
125 | + * Use the dynamic property to set the "complete" property. |
|
126 | + * @since 4.10.12.p |
|
127 | + */ |
|
128 | + public function __wakeup() |
|
129 | + { |
|
130 | + $this->complete = $this->c; |
|
131 | + $this->dont_traverse_models = $this->dtm; |
|
132 | + } |
|
133 | 133 | } |
134 | 134 | // End of file BaseNode.php |
135 | 135 | // Location: EventEspresso\core\services\orm\tree_traversal/BaseNode.php |
@@ -49,12 +49,12 @@ discard block |
||
49 | 49 | */ |
50 | 50 | public function getModelObjNodesInGroup($code) |
51 | 51 | { |
52 | - if (! $code) { |
|
52 | + if ( ! $code) { |
|
53 | 53 | throw new Exception(esc_html__('We aren’t sure which job you are performing. Please press back in your browser and try again.', 'event_espresso')); |
54 | 54 | } |
55 | - $deletion_data = get_option($this->getOptionPrefix() . $code, []); |
|
55 | + $deletion_data = get_option($this->getOptionPrefix().$code, []); |
|
56 | 56 | foreach ($deletion_data as $root) { |
57 | - if (! $root instanceof ModelObjNode) { |
|
57 | + if ( ! $root instanceof ModelObjNode) { |
|
58 | 58 | throw new UnexpectedEntityException($root, 'ModelObjNode'); |
59 | 59 | } |
60 | 60 | } |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | public function persistModelObjNodesGroup($model_obj_nodes, $code) |
112 | 112 | { |
113 | 113 | return add_option( |
114 | - $this->getOptionPrefix() . $code, |
|
114 | + $this->getOptionPrefix().$code, |
|
115 | 115 | $model_obj_nodes, |
116 | 116 | null, |
117 | 117 | 'no' |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | */ |
127 | 127 | public function deleteModelObjNodesInGroup($code) |
128 | 128 | { |
129 | - return delete_option($this->getOptionPrefix() . $code); |
|
129 | + return delete_option($this->getOptionPrefix().$code); |
|
130 | 130 | } |
131 | 131 | } |
132 | 132 | // End of file NodeGroupDao.php |
@@ -22,112 +22,112 @@ |
||
22 | 22 | */ |
23 | 23 | class NodeGroupDao |
24 | 24 | { |
25 | - /** |
|
26 | - * @since 4.10.12.p |
|
27 | - * @return mixed|void |
|
28 | - */ |
|
29 | - public function generateGroupCode() |
|
30 | - { |
|
31 | - return wp_generate_password(6, false); |
|
32 | - } |
|
25 | + /** |
|
26 | + * @since 4.10.12.p |
|
27 | + * @return mixed|void |
|
28 | + */ |
|
29 | + public function generateGroupCode() |
|
30 | + { |
|
31 | + return wp_generate_password(6, false); |
|
32 | + } |
|
33 | 33 | |
34 | - /** |
|
35 | - * Gets the string we put in front of the WP Option name used to store the jobs. |
|
36 | - * @since 4.10.12.p |
|
37 | - * @return string |
|
38 | - */ |
|
39 | - private function getOptionPrefix() |
|
40 | - { |
|
41 | - return 'ee_deletion_'; |
|
42 | - } |
|
34 | + /** |
|
35 | + * Gets the string we put in front of the WP Option name used to store the jobs. |
|
36 | + * @since 4.10.12.p |
|
37 | + * @return string |
|
38 | + */ |
|
39 | + private function getOptionPrefix() |
|
40 | + { |
|
41 | + return 'ee_deletion_'; |
|
42 | + } |
|
43 | 43 | |
44 | - /** |
|
45 | - * @since 4.10.12.p |
|
46 | - * @param $code |
|
47 | - * @return ModelObjNode[] |
|
48 | - * @throws UnexpectedEntityException |
|
49 | - */ |
|
50 | - public function getModelObjNodesInGroup($code) |
|
51 | - { |
|
52 | - if (! $code) { |
|
53 | - throw new Exception(esc_html__('We aren’t sure which job you are performing. Please press back in your browser and try again.', 'event_espresso')); |
|
54 | - } |
|
55 | - $deletion_data = get_option($this->getOptionPrefix() . $code, []); |
|
56 | - foreach ($deletion_data as $root) { |
|
57 | - if (! $root instanceof ModelObjNode) { |
|
58 | - throw new UnexpectedEntityException($root, 'ModelObjNode'); |
|
59 | - } |
|
60 | - } |
|
61 | - return $deletion_data; |
|
62 | - } |
|
44 | + /** |
|
45 | + * @since 4.10.12.p |
|
46 | + * @param $code |
|
47 | + * @return ModelObjNode[] |
|
48 | + * @throws UnexpectedEntityException |
|
49 | + */ |
|
50 | + public function getModelObjNodesInGroup($code) |
|
51 | + { |
|
52 | + if (! $code) { |
|
53 | + throw new Exception(esc_html__('We aren’t sure which job you are performing. Please press back in your browser and try again.', 'event_espresso')); |
|
54 | + } |
|
55 | + $deletion_data = get_option($this->getOptionPrefix() . $code, []); |
|
56 | + foreach ($deletion_data as $root) { |
|
57 | + if (! $root instanceof ModelObjNode) { |
|
58 | + throw new UnexpectedEntityException($root, 'ModelObjNode'); |
|
59 | + } |
|
60 | + } |
|
61 | + return $deletion_data; |
|
62 | + } |
|
63 | 63 | |
64 | - /** |
|
65 | - * Gets an array indicating what database rows are contained in the job. |
|
66 | - * Each top-level key is a model name, and its value is an array of IDs. |
|
67 | - * @since 4.10.12.p |
|
68 | - * @param ModelObjNode[] $model_obj_nodes |
|
69 | - * @return array |
|
70 | - * @throws EE_Error |
|
71 | - * @throws InvalidDataTypeException |
|
72 | - * @throws InvalidInterfaceException |
|
73 | - * @throws InvalidArgumentException |
|
74 | - * @throws ReflectionException |
|
75 | - */ |
|
76 | - public function getModelsAndIdsContainedIn($model_obj_nodes) |
|
77 | - { |
|
78 | - $models_and_ids_to_delete = []; |
|
79 | - foreach ($model_obj_nodes as $root) { |
|
80 | - $models_and_ids_to_delete = array_replace_recursive($models_and_ids_to_delete, $root->getIds()); |
|
81 | - } |
|
82 | - return $models_and_ids_to_delete; |
|
83 | - } |
|
64 | + /** |
|
65 | + * Gets an array indicating what database rows are contained in the job. |
|
66 | + * Each top-level key is a model name, and its value is an array of IDs. |
|
67 | + * @since 4.10.12.p |
|
68 | + * @param ModelObjNode[] $model_obj_nodes |
|
69 | + * @return array |
|
70 | + * @throws EE_Error |
|
71 | + * @throws InvalidDataTypeException |
|
72 | + * @throws InvalidInterfaceException |
|
73 | + * @throws InvalidArgumentException |
|
74 | + * @throws ReflectionException |
|
75 | + */ |
|
76 | + public function getModelsAndIdsContainedIn($model_obj_nodes) |
|
77 | + { |
|
78 | + $models_and_ids_to_delete = []; |
|
79 | + foreach ($model_obj_nodes as $root) { |
|
80 | + $models_and_ids_to_delete = array_replace_recursive($models_and_ids_to_delete, $root->getIds()); |
|
81 | + } |
|
82 | + return $models_and_ids_to_delete; |
|
83 | + } |
|
84 | 84 | |
85 | - /** |
|
86 | - * Gets an array indicating what database rows are contained in the job. |
|
87 | - * Each top-level key is a model name, and its value is an array of IDs. |
|
88 | - * @since 4.10.12.p |
|
89 | - * @param string $code |
|
90 | - * @return array |
|
91 | - * @throws EE_Error |
|
92 | - * @throws InvalidArgumentException |
|
93 | - * @throws InvalidDataTypeException |
|
94 | - * @throws InvalidInterfaceException |
|
95 | - * @throws ReflectionException |
|
96 | - * @throws UnexpectedEntityException |
|
97 | - */ |
|
98 | - public function getModelsAndIdsFromGroup($code) |
|
99 | - { |
|
100 | - $model_obj_nodes = $this->getModelObjNodesInGroup($code); |
|
101 | - return $this->getModelsAndIdsContainedIn($model_obj_nodes); |
|
102 | - } |
|
85 | + /** |
|
86 | + * Gets an array indicating what database rows are contained in the job. |
|
87 | + * Each top-level key is a model name, and its value is an array of IDs. |
|
88 | + * @since 4.10.12.p |
|
89 | + * @param string $code |
|
90 | + * @return array |
|
91 | + * @throws EE_Error |
|
92 | + * @throws InvalidArgumentException |
|
93 | + * @throws InvalidDataTypeException |
|
94 | + * @throws InvalidInterfaceException |
|
95 | + * @throws ReflectionException |
|
96 | + * @throws UnexpectedEntityException |
|
97 | + */ |
|
98 | + public function getModelsAndIdsFromGroup($code) |
|
99 | + { |
|
100 | + $model_obj_nodes = $this->getModelObjNodesInGroup($code); |
|
101 | + return $this->getModelsAndIdsContainedIn($model_obj_nodes); |
|
102 | + } |
|
103 | 103 | |
104 | - /** |
|
105 | - * Persists the ModelObjNodes for future requests, using the code for reference. |
|
106 | - * @since 4.10.12.p |
|
107 | - * @param ModelObjNode[] $model_obj_nodes |
|
108 | - * @param string $code |
|
109 | - * @return bool |
|
110 | - */ |
|
111 | - public function persistModelObjNodesGroup($model_obj_nodes, $code) |
|
112 | - { |
|
113 | - return add_option( |
|
114 | - $this->getOptionPrefix() . $code, |
|
115 | - $model_obj_nodes, |
|
116 | - null, |
|
117 | - 'no' |
|
118 | - ); |
|
119 | - } |
|
104 | + /** |
|
105 | + * Persists the ModelObjNodes for future requests, using the code for reference. |
|
106 | + * @since 4.10.12.p |
|
107 | + * @param ModelObjNode[] $model_obj_nodes |
|
108 | + * @param string $code |
|
109 | + * @return bool |
|
110 | + */ |
|
111 | + public function persistModelObjNodesGroup($model_obj_nodes, $code) |
|
112 | + { |
|
113 | + return add_option( |
|
114 | + $this->getOptionPrefix() . $code, |
|
115 | + $model_obj_nodes, |
|
116 | + null, |
|
117 | + 'no' |
|
118 | + ); |
|
119 | + } |
|
120 | 120 | |
121 | - /** |
|
122 | - * Forgets about the group of ModelObjNodes. Doesn't delete the rows in the database they reference though. |
|
123 | - * @since 4.10.12.p |
|
124 | - * @param $code |
|
125 | - * @return bool |
|
126 | - */ |
|
127 | - public function deleteModelObjNodesInGroup($code) |
|
128 | - { |
|
129 | - return delete_option($this->getOptionPrefix() . $code); |
|
130 | - } |
|
121 | + /** |
|
122 | + * Forgets about the group of ModelObjNodes. Doesn't delete the rows in the database they reference though. |
|
123 | + * @since 4.10.12.p |
|
124 | + * @param $code |
|
125 | + * @return bool |
|
126 | + */ |
|
127 | + public function deleteModelObjNodesInGroup($code) |
|
128 | + { |
|
129 | + return delete_option($this->getOptionPrefix() . $code); |
|
130 | + } |
|
131 | 131 | } |
132 | 132 | // End of file NodeGroupDao.php |
133 | 133 | // Location: EventEspresso\core\services\orm\tree_traversal/NodeGroupDao.php |
@@ -89,17 +89,17 @@ discard block |
||
89 | 89 | $deletion_job_code = isset($request_data['deletion_job_code']) ? sanitize_key($request_data['deletion_job_code']) : ''; |
90 | 90 | $models_and_ids_to_delete = $this->dao->getModelsAndIdsFromGroup($deletion_job_code); |
91 | 91 | $event_ids = isset($models_and_ids_to_delete['Event']) ? $models_and_ids_to_delete['Event'] : array(); |
92 | - if (empty($event_ids) || !is_array($event_ids)) { |
|
92 | + if (empty($event_ids) || ! is_array($event_ids)) { |
|
93 | 93 | throw new EE_Error( |
94 | 94 | esc_html__('No Events were found to delete.', 'event_espresso') |
95 | 95 | ); |
96 | 96 | } |
97 | 97 | $datetime_ids = isset($models_and_ids_to_delete['Datetime']) ? $models_and_ids_to_delete['Datetime'] : array(); |
98 | - if (!is_array($datetime_ids)) { |
|
98 | + if ( ! is_array($datetime_ids)) { |
|
99 | 99 | throw new UnexpectedEntityException($datetime_ids, 'array'); |
100 | 100 | } |
101 | 101 | $registration_ids = isset($models_and_ids_to_delete['Registration']) ? $models_and_ids_to_delete['Registration'] : array(); |
102 | - if (!is_array($registration_ids)) { |
|
102 | + if ( ! is_array($registration_ids)) { |
|
103 | 103 | throw new UnexpectedEntityException($registration_ids, 'array'); |
104 | 104 | } |
105 | 105 | $num_registrations_to_show = 10; |
@@ -135,7 +135,7 @@ discard block |
||
135 | 135 | ]; |
136 | 136 | return [ |
137 | 137 | 'admin_page_content' => EEH_Template::display_template( |
138 | - EVENTS_TEMPLATE_PATH . 'event_preview_deletion.template.php', |
|
138 | + EVENTS_TEMPLATE_PATH.'event_preview_deletion.template.php', |
|
139 | 139 | [ |
140 | 140 | 'form_url' => EE_Admin_Page::add_query_args_and_nonce( |
141 | 141 | $confirm_deletion_args, |
@@ -31,127 +31,127 @@ |
||
31 | 31 | */ |
32 | 32 | class PreviewDeletion |
33 | 33 | { |
34 | - /** |
|
35 | - * @var NodeGroupDao |
|
36 | - */ |
|
37 | - protected $dao; |
|
34 | + /** |
|
35 | + * @var NodeGroupDao |
|
36 | + */ |
|
37 | + protected $dao; |
|
38 | 38 | |
39 | - /** |
|
40 | - * @var EEM_Event |
|
41 | - */ |
|
42 | - protected $event_model; |
|
39 | + /** |
|
40 | + * @var EEM_Event |
|
41 | + */ |
|
42 | + protected $event_model; |
|
43 | 43 | |
44 | - /** |
|
45 | - * @var EEM_Datetime |
|
46 | - */ |
|
47 | - protected $datetime_model; |
|
44 | + /** |
|
45 | + * @var EEM_Datetime |
|
46 | + */ |
|
47 | + protected $datetime_model; |
|
48 | 48 | |
49 | - /** |
|
50 | - * @var EEM_Registration |
|
51 | - */ |
|
52 | - protected $registration_model; |
|
49 | + /** |
|
50 | + * @var EEM_Registration |
|
51 | + */ |
|
52 | + protected $registration_model; |
|
53 | 53 | |
54 | - /** |
|
55 | - * PreviewDeletion constructor. |
|
56 | - * @param NodeGroupDao $dao |
|
57 | - * @param EEM_Event $event_model |
|
58 | - * @param EEM_Datetime $datetime_model |
|
59 | - * @param EEM_Registration $registration_model |
|
60 | - */ |
|
61 | - public function __construct( |
|
62 | - NodeGroupDao $dao, |
|
63 | - EEM_Event $event_model, |
|
64 | - EEM_Datetime $datetime_model, |
|
65 | - EEM_Registration $registration_model |
|
66 | - ) { |
|
67 | - $this->dao = $dao; |
|
68 | - $this->event_model = $event_model; |
|
69 | - $this->datetime_model = $datetime_model; |
|
70 | - $this->registration_model = $registration_model; |
|
71 | - } |
|
54 | + /** |
|
55 | + * PreviewDeletion constructor. |
|
56 | + * @param NodeGroupDao $dao |
|
57 | + * @param EEM_Event $event_model |
|
58 | + * @param EEM_Datetime $datetime_model |
|
59 | + * @param EEM_Registration $registration_model |
|
60 | + */ |
|
61 | + public function __construct( |
|
62 | + NodeGroupDao $dao, |
|
63 | + EEM_Event $event_model, |
|
64 | + EEM_Datetime $datetime_model, |
|
65 | + EEM_Registration $registration_model |
|
66 | + ) { |
|
67 | + $this->dao = $dao; |
|
68 | + $this->event_model = $event_model; |
|
69 | + $this->datetime_model = $datetime_model; |
|
70 | + $this->registration_model = $registration_model; |
|
71 | + } |
|
72 | 72 | |
73 | - /** |
|
74 | - * Renders the preview deletion page. |
|
75 | - * @since 4.10.12.p |
|
76 | - * @param $request_data |
|
77 | - * @param $admin_base_url |
|
78 | - * @return array |
|
79 | - * @throws UnexpectedEntityException |
|
80 | - * @throws DomainException |
|
81 | - * @throws EE_Error |
|
82 | - * @throws InvalidDataTypeException |
|
83 | - * @throws InvalidInterfaceException |
|
84 | - * @throws InvalidArgumentException |
|
85 | - * @throws ReflectionException |
|
86 | - */ |
|
87 | - public function handle($request_data, $admin_base_url) |
|
88 | - { |
|
89 | - $deletion_job_code = isset($request_data['deletion_job_code']) ? sanitize_key($request_data['deletion_job_code']) : ''; |
|
90 | - $models_and_ids_to_delete = $this->dao->getModelsAndIdsFromGroup($deletion_job_code); |
|
91 | - $event_ids = isset($models_and_ids_to_delete['Event']) ? $models_and_ids_to_delete['Event'] : array(); |
|
92 | - if (empty($event_ids) || !is_array($event_ids)) { |
|
93 | - throw new EE_Error( |
|
94 | - esc_html__('No Events were found to delete.', 'event_espresso') |
|
95 | - ); |
|
96 | - } |
|
97 | - $datetime_ids = isset($models_and_ids_to_delete['Datetime']) ? $models_and_ids_to_delete['Datetime'] : array(); |
|
98 | - if (!is_array($datetime_ids)) { |
|
99 | - throw new UnexpectedEntityException($datetime_ids, 'array'); |
|
100 | - } |
|
101 | - $registration_ids = isset($models_and_ids_to_delete['Registration']) ? $models_and_ids_to_delete['Registration'] : array(); |
|
102 | - if (!is_array($registration_ids)) { |
|
103 | - throw new UnexpectedEntityException($registration_ids, 'array'); |
|
104 | - } |
|
105 | - $num_registrations_to_show = 10; |
|
106 | - $reg_count = count($registration_ids); |
|
107 | - if ($reg_count > $num_registrations_to_show) { |
|
108 | - $registration_ids = array_slice($registration_ids, 0, $num_registrations_to_show); |
|
109 | - } |
|
110 | - $form = new ConfirmEventDeletionForm($event_ids); |
|
111 | - $events = $this->event_model->get_all_deleted_and_undeleted( |
|
112 | - [ |
|
113 | - [ |
|
114 | - 'EVT_ID' => ['IN', $event_ids] |
|
115 | - ] |
|
116 | - ] |
|
117 | - ); |
|
118 | - $datetimes = $this->datetime_model->get_all_deleted_and_undeleted( |
|
119 | - [ |
|
120 | - [ |
|
121 | - 'DTT_ID' => ['IN', $datetime_ids] |
|
122 | - ] |
|
123 | - ] |
|
124 | - ); |
|
125 | - $registrations = $this->registration_model->get_all_deleted_and_undeleted( |
|
126 | - [ |
|
127 | - [ |
|
128 | - 'REG_ID' => ['IN', $registration_ids] |
|
129 | - ] |
|
130 | - ] |
|
131 | - ); |
|
132 | - $confirm_deletion_args = [ |
|
133 | - 'action' => 'confirm_deletion', |
|
134 | - 'deletion_job_code' => $deletion_job_code |
|
135 | - ]; |
|
136 | - return [ |
|
137 | - 'admin_page_content' => EEH_Template::display_template( |
|
138 | - EVENTS_TEMPLATE_PATH . 'event_preview_deletion.template.php', |
|
139 | - [ |
|
140 | - 'form_url' => EE_Admin_Page::add_query_args_and_nonce( |
|
141 | - $confirm_deletion_args, |
|
142 | - $admin_base_url |
|
143 | - ), |
|
144 | - 'form' => $form, |
|
145 | - 'events' => $events, |
|
146 | - 'datetimes' => $datetimes, |
|
147 | - 'registrations' => $registrations, |
|
148 | - 'reg_count' => $reg_count, |
|
149 | - 'num_registrations_to_show' => $num_registrations_to_show |
|
150 | - ], |
|
151 | - true |
|
152 | - ) |
|
153 | - ]; |
|
154 | - } |
|
73 | + /** |
|
74 | + * Renders the preview deletion page. |
|
75 | + * @since 4.10.12.p |
|
76 | + * @param $request_data |
|
77 | + * @param $admin_base_url |
|
78 | + * @return array |
|
79 | + * @throws UnexpectedEntityException |
|
80 | + * @throws DomainException |
|
81 | + * @throws EE_Error |
|
82 | + * @throws InvalidDataTypeException |
|
83 | + * @throws InvalidInterfaceException |
|
84 | + * @throws InvalidArgumentException |
|
85 | + * @throws ReflectionException |
|
86 | + */ |
|
87 | + public function handle($request_data, $admin_base_url) |
|
88 | + { |
|
89 | + $deletion_job_code = isset($request_data['deletion_job_code']) ? sanitize_key($request_data['deletion_job_code']) : ''; |
|
90 | + $models_and_ids_to_delete = $this->dao->getModelsAndIdsFromGroup($deletion_job_code); |
|
91 | + $event_ids = isset($models_and_ids_to_delete['Event']) ? $models_and_ids_to_delete['Event'] : array(); |
|
92 | + if (empty($event_ids) || !is_array($event_ids)) { |
|
93 | + throw new EE_Error( |
|
94 | + esc_html__('No Events were found to delete.', 'event_espresso') |
|
95 | + ); |
|
96 | + } |
|
97 | + $datetime_ids = isset($models_and_ids_to_delete['Datetime']) ? $models_and_ids_to_delete['Datetime'] : array(); |
|
98 | + if (!is_array($datetime_ids)) { |
|
99 | + throw new UnexpectedEntityException($datetime_ids, 'array'); |
|
100 | + } |
|
101 | + $registration_ids = isset($models_and_ids_to_delete['Registration']) ? $models_and_ids_to_delete['Registration'] : array(); |
|
102 | + if (!is_array($registration_ids)) { |
|
103 | + throw new UnexpectedEntityException($registration_ids, 'array'); |
|
104 | + } |
|
105 | + $num_registrations_to_show = 10; |
|
106 | + $reg_count = count($registration_ids); |
|
107 | + if ($reg_count > $num_registrations_to_show) { |
|
108 | + $registration_ids = array_slice($registration_ids, 0, $num_registrations_to_show); |
|
109 | + } |
|
110 | + $form = new ConfirmEventDeletionForm($event_ids); |
|
111 | + $events = $this->event_model->get_all_deleted_and_undeleted( |
|
112 | + [ |
|
113 | + [ |
|
114 | + 'EVT_ID' => ['IN', $event_ids] |
|
115 | + ] |
|
116 | + ] |
|
117 | + ); |
|
118 | + $datetimes = $this->datetime_model->get_all_deleted_and_undeleted( |
|
119 | + [ |
|
120 | + [ |
|
121 | + 'DTT_ID' => ['IN', $datetime_ids] |
|
122 | + ] |
|
123 | + ] |
|
124 | + ); |
|
125 | + $registrations = $this->registration_model->get_all_deleted_and_undeleted( |
|
126 | + [ |
|
127 | + [ |
|
128 | + 'REG_ID' => ['IN', $registration_ids] |
|
129 | + ] |
|
130 | + ] |
|
131 | + ); |
|
132 | + $confirm_deletion_args = [ |
|
133 | + 'action' => 'confirm_deletion', |
|
134 | + 'deletion_job_code' => $deletion_job_code |
|
135 | + ]; |
|
136 | + return [ |
|
137 | + 'admin_page_content' => EEH_Template::display_template( |
|
138 | + EVENTS_TEMPLATE_PATH . 'event_preview_deletion.template.php', |
|
139 | + [ |
|
140 | + 'form_url' => EE_Admin_Page::add_query_args_and_nonce( |
|
141 | + $confirm_deletion_args, |
|
142 | + $admin_base_url |
|
143 | + ), |
|
144 | + 'form' => $form, |
|
145 | + 'events' => $events, |
|
146 | + 'datetimes' => $datetimes, |
|
147 | + 'registrations' => $registrations, |
|
148 | + 'reg_count' => $reg_count, |
|
149 | + 'num_registrations_to_show' => $num_registrations_to_show |
|
150 | + ], |
|
151 | + true |
|
152 | + ) |
|
153 | + ]; |
|
154 | + } |
|
155 | 155 | } |
156 | 156 | // End of file PreviewDeletion.php |
157 | 157 | // Location: EventEspresso\core\domain\services\admin\events\data/PreviewDeletion.php |
@@ -93,8 +93,8 @@ discard block |
||
93 | 93 | // Add entity nodes for each of the model objects we fetched. |
94 | 94 | foreach ($related_model_objs as $related_model_obj) { |
95 | 95 | $entity_node = new ModelObjNode($related_model_obj->ID(), $related_model_obj->get_model(), $this->dont_traverse_models); |
96 | - $this->nodes[ $related_model_obj->ID() ] = $entity_node; |
|
97 | - $new_item_nodes[ $related_model_obj->ID() ] = $entity_node; |
|
96 | + $this->nodes[$related_model_obj->ID()] = $entity_node; |
|
97 | + $new_item_nodes[$related_model_obj->ID()] = $entity_node; |
|
98 | 98 | } |
99 | 99 | $num_identified += count($new_item_nodes); |
100 | 100 | if ($num_identified < $model_objects_to_identify) { |
@@ -120,7 +120,7 @@ discard block |
||
120 | 120 | protected function allChildrenComplete() |
121 | 121 | { |
122 | 122 | foreach ($this->nodes as $model_obj_node) { |
123 | - if (! $model_obj_node->isComplete()) { |
|
123 | + if ( ! $model_obj_node->isComplete()) { |
|
124 | 124 | return false; |
125 | 125 | } |
126 | 126 | } |
@@ -137,7 +137,7 @@ discard block |
||
137 | 137 | protected function visitAlreadyDiscoveredNodes($model_obj_nodes, $work_budget) |
138 | 138 | { |
139 | 139 | $work_done = 0; |
140 | - if (! $model_obj_nodes) { |
|
140 | + if ( ! $model_obj_nodes) { |
|
141 | 141 | return 0; |
142 | 142 | } |
143 | 143 | foreach ($model_obj_nodes as $model_obj_node) { |
@@ -199,7 +199,7 @@ discard block |
||
199 | 199 | */ |
200 | 200 | protected function whereQueryParams() |
201 | 201 | { |
202 | - $where_params = [ |
|
202 | + $where_params = [ |
|
203 | 203 | $this->related_model->get_foreign_key_to( |
204 | 204 | $this->main_model->get_this_model_name() |
205 | 205 | )->get_name() => $this->id |
@@ -212,7 +212,7 @@ discard block |
||
212 | 212 | $relation_settings = null; |
213 | 213 | } |
214 | 214 | if ($relation_settings instanceof EE_Has_Many_Any_Relation) { |
215 | - $where_params[ $this->related_model->get_field_containing_related_model_name()->get_name() ] = $this->main_model->get_this_model_name(); |
|
215 | + $where_params[$this->related_model->get_field_containing_related_model_name()->get_name()] = $this->main_model->get_this_model_name(); |
|
216 | 216 | } |
217 | 217 | return $where_params; |
218 | 218 | } |
@@ -228,7 +228,7 @@ discard block |
||
228 | 228 | 'objs' => [] |
229 | 229 | ]; |
230 | 230 | foreach ($this->nodes as $id => $model_obj_node) { |
231 | - $tree['objs'][ $id ] = $model_obj_node->toArray(); |
|
231 | + $tree['objs'][$id] = $model_obj_node->toArray(); |
|
232 | 232 | } |
233 | 233 | return $tree; |
234 | 234 | } |
@@ -27,289 +27,289 @@ |
||
27 | 27 | */ |
28 | 28 | class RelationNode extends BaseNode |
29 | 29 | { |
30 | - /** |
|
31 | - * @var string|int |
|
32 | - */ |
|
33 | - protected $id; |
|
30 | + /** |
|
31 | + * @var string|int |
|
32 | + */ |
|
33 | + protected $id; |
|
34 | 34 | |
35 | - /** |
|
36 | - * @var EEM_Base |
|
37 | - */ |
|
38 | - protected $main_model; |
|
35 | + /** |
|
36 | + * @var EEM_Base |
|
37 | + */ |
|
38 | + protected $main_model; |
|
39 | 39 | |
40 | - /** |
|
41 | - * @var int |
|
42 | - */ |
|
43 | - protected $count; |
|
40 | + /** |
|
41 | + * @var int |
|
42 | + */ |
|
43 | + protected $count; |
|
44 | 44 | |
45 | - /** |
|
46 | - * @var EEM_Base |
|
47 | - */ |
|
48 | - protected $related_model; |
|
45 | + /** |
|
46 | + * @var EEM_Base |
|
47 | + */ |
|
48 | + protected $related_model; |
|
49 | 49 | |
50 | - /** |
|
51 | - * @var ModelObjNode[] |
|
52 | - */ |
|
53 | - protected $nodes; |
|
50 | + /** |
|
51 | + * @var ModelObjNode[] |
|
52 | + */ |
|
53 | + protected $nodes; |
|
54 | 54 | |
55 | - /** |
|
56 | - * RelationNode constructor. |
|
57 | - * @param $main_model_obj_id |
|
58 | - * @param EEM_Base $main_model |
|
59 | - * @param EEM_Base $related_model |
|
60 | - * @param array $dont_traverse_models array of model names we DON'T want to traverse |
|
61 | - */ |
|
62 | - public function __construct( |
|
63 | - $main_model_obj_id, |
|
64 | - EEM_Base $main_model, |
|
65 | - EEM_Base $related_model, |
|
66 | - array $dont_traverse_models = [] |
|
67 | - ) { |
|
68 | - $this->id = $main_model_obj_id; |
|
69 | - $this->main_model = $main_model; |
|
70 | - $this->related_model = $related_model; |
|
71 | - $this->nodes = []; |
|
72 | - $this->dont_traverse_models = $dont_traverse_models; |
|
73 | - } |
|
55 | + /** |
|
56 | + * RelationNode constructor. |
|
57 | + * @param $main_model_obj_id |
|
58 | + * @param EEM_Base $main_model |
|
59 | + * @param EEM_Base $related_model |
|
60 | + * @param array $dont_traverse_models array of model names we DON'T want to traverse |
|
61 | + */ |
|
62 | + public function __construct( |
|
63 | + $main_model_obj_id, |
|
64 | + EEM_Base $main_model, |
|
65 | + EEM_Base $related_model, |
|
66 | + array $dont_traverse_models = [] |
|
67 | + ) { |
|
68 | + $this->id = $main_model_obj_id; |
|
69 | + $this->main_model = $main_model; |
|
70 | + $this->related_model = $related_model; |
|
71 | + $this->nodes = []; |
|
72 | + $this->dont_traverse_models = $dont_traverse_models; |
|
73 | + } |
|
74 | 74 | |
75 | 75 | |
76 | - /** |
|
77 | - * Here is where most of the work happens. We've counted how many related model objects exist, here we identify |
|
78 | - * them (ie, learn their IDs). But its recursive, so we'll also find their related dependent model objects etc. |
|
79 | - * @since 4.10.12.p |
|
80 | - * @param int $model_objects_to_identify |
|
81 | - * @return int |
|
82 | - * @throws EE_Error |
|
83 | - * @throws InvalidArgumentException |
|
84 | - * @throws InvalidDataTypeException |
|
85 | - * @throws InvalidInterfaceException |
|
86 | - * @throws ReflectionException |
|
87 | - */ |
|
88 | - protected function work($model_objects_to_identify) |
|
89 | - { |
|
90 | - $num_identified = $this->visitAlreadyDiscoveredNodes($this->nodes, $model_objects_to_identify); |
|
91 | - if ($num_identified < $model_objects_to_identify) { |
|
92 | - $related_model_objs = $this->related_model->get_all( |
|
93 | - [ |
|
94 | - $this->whereQueryParams(), |
|
95 | - 'limit' => [ |
|
96 | - count($this->nodes), |
|
97 | - $model_objects_to_identify - $num_identified |
|
98 | - ] |
|
99 | - ] |
|
100 | - ); |
|
101 | - $new_item_nodes = []; |
|
76 | + /** |
|
77 | + * Here is where most of the work happens. We've counted how many related model objects exist, here we identify |
|
78 | + * them (ie, learn their IDs). But its recursive, so we'll also find their related dependent model objects etc. |
|
79 | + * @since 4.10.12.p |
|
80 | + * @param int $model_objects_to_identify |
|
81 | + * @return int |
|
82 | + * @throws EE_Error |
|
83 | + * @throws InvalidArgumentException |
|
84 | + * @throws InvalidDataTypeException |
|
85 | + * @throws InvalidInterfaceException |
|
86 | + * @throws ReflectionException |
|
87 | + */ |
|
88 | + protected function work($model_objects_to_identify) |
|
89 | + { |
|
90 | + $num_identified = $this->visitAlreadyDiscoveredNodes($this->nodes, $model_objects_to_identify); |
|
91 | + if ($num_identified < $model_objects_to_identify) { |
|
92 | + $related_model_objs = $this->related_model->get_all( |
|
93 | + [ |
|
94 | + $this->whereQueryParams(), |
|
95 | + 'limit' => [ |
|
96 | + count($this->nodes), |
|
97 | + $model_objects_to_identify - $num_identified |
|
98 | + ] |
|
99 | + ] |
|
100 | + ); |
|
101 | + $new_item_nodes = []; |
|
102 | 102 | |
103 | - // Add entity nodes for each of the model objects we fetched. |
|
104 | - foreach ($related_model_objs as $related_model_obj) { |
|
105 | - $entity_node = new ModelObjNode($related_model_obj->ID(), $related_model_obj->get_model(), $this->dont_traverse_models); |
|
106 | - $this->nodes[ $related_model_obj->ID() ] = $entity_node; |
|
107 | - $new_item_nodes[ $related_model_obj->ID() ] = $entity_node; |
|
108 | - } |
|
109 | - $num_identified += count($new_item_nodes); |
|
110 | - if ($num_identified < $model_objects_to_identify) { |
|
111 | - // And lastly do the work. |
|
112 | - $num_identified += $this->visitAlreadyDiscoveredNodes( |
|
113 | - $new_item_nodes, |
|
114 | - $model_objects_to_identify - $num_identified |
|
115 | - ); |
|
116 | - } |
|
117 | - } |
|
103 | + // Add entity nodes for each of the model objects we fetched. |
|
104 | + foreach ($related_model_objs as $related_model_obj) { |
|
105 | + $entity_node = new ModelObjNode($related_model_obj->ID(), $related_model_obj->get_model(), $this->dont_traverse_models); |
|
106 | + $this->nodes[ $related_model_obj->ID() ] = $entity_node; |
|
107 | + $new_item_nodes[ $related_model_obj->ID() ] = $entity_node; |
|
108 | + } |
|
109 | + $num_identified += count($new_item_nodes); |
|
110 | + if ($num_identified < $model_objects_to_identify) { |
|
111 | + // And lastly do the work. |
|
112 | + $num_identified += $this->visitAlreadyDiscoveredNodes( |
|
113 | + $new_item_nodes, |
|
114 | + $model_objects_to_identify - $num_identified |
|
115 | + ); |
|
116 | + } |
|
117 | + } |
|
118 | 118 | |
119 | - if (count($this->nodes) >= $this->count && $this->allChildrenComplete()) { |
|
120 | - $this->complete = true; |
|
121 | - } |
|
122 | - return $num_identified; |
|
123 | - } |
|
119 | + if (count($this->nodes) >= $this->count && $this->allChildrenComplete()) { |
|
120 | + $this->complete = true; |
|
121 | + } |
|
122 | + return $num_identified; |
|
123 | + } |
|
124 | 124 | |
125 | - /** |
|
126 | - * Checks if all the identified child nodes are complete or not. |
|
127 | - * @since 4.10.12.p |
|
128 | - * @return bool |
|
129 | - */ |
|
130 | - protected function allChildrenComplete() |
|
131 | - { |
|
132 | - foreach ($this->nodes as $model_obj_node) { |
|
133 | - if (! $model_obj_node->isComplete()) { |
|
134 | - return false; |
|
135 | - } |
|
136 | - } |
|
137 | - return true; |
|
138 | - } |
|
125 | + /** |
|
126 | + * Checks if all the identified child nodes are complete or not. |
|
127 | + * @since 4.10.12.p |
|
128 | + * @return bool |
|
129 | + */ |
|
130 | + protected function allChildrenComplete() |
|
131 | + { |
|
132 | + foreach ($this->nodes as $model_obj_node) { |
|
133 | + if (! $model_obj_node->isComplete()) { |
|
134 | + return false; |
|
135 | + } |
|
136 | + } |
|
137 | + return true; |
|
138 | + } |
|
139 | 139 | |
140 | - /** |
|
141 | - * Visits the provided nodes and keeps track of how much work was done, making sure to not go over budget. |
|
142 | - * @since 4.10.12.p |
|
143 | - * @param ModelObjNode[] $model_obj_nodes |
|
144 | - * @param $work_budget |
|
145 | - * @return int |
|
146 | - */ |
|
147 | - protected function visitAlreadyDiscoveredNodes($model_obj_nodes, $work_budget) |
|
148 | - { |
|
149 | - $work_done = 0; |
|
150 | - if (! $model_obj_nodes) { |
|
151 | - return 0; |
|
152 | - } |
|
153 | - foreach ($model_obj_nodes as $model_obj_node) { |
|
154 | - if ($work_done >= $work_budget) { |
|
155 | - break; |
|
156 | - } |
|
157 | - $work_done += $model_obj_node->visit($work_budget - $work_done); |
|
158 | - } |
|
159 | - return $work_done; |
|
160 | - } |
|
140 | + /** |
|
141 | + * Visits the provided nodes and keeps track of how much work was done, making sure to not go over budget. |
|
142 | + * @since 4.10.12.p |
|
143 | + * @param ModelObjNode[] $model_obj_nodes |
|
144 | + * @param $work_budget |
|
145 | + * @return int |
|
146 | + */ |
|
147 | + protected function visitAlreadyDiscoveredNodes($model_obj_nodes, $work_budget) |
|
148 | + { |
|
149 | + $work_done = 0; |
|
150 | + if (! $model_obj_nodes) { |
|
151 | + return 0; |
|
152 | + } |
|
153 | + foreach ($model_obj_nodes as $model_obj_node) { |
|
154 | + if ($work_done >= $work_budget) { |
|
155 | + break; |
|
156 | + } |
|
157 | + $work_done += $model_obj_node->visit($work_budget - $work_done); |
|
158 | + } |
|
159 | + return $work_done; |
|
160 | + } |
|
161 | 161 | |
162 | - /** |
|
163 | - * Whether this item has already been initialized |
|
164 | - */ |
|
165 | - protected function isDiscovered() |
|
166 | - { |
|
167 | - return $this->count !== null; |
|
168 | - } |
|
162 | + /** |
|
163 | + * Whether this item has already been initialized |
|
164 | + */ |
|
165 | + protected function isDiscovered() |
|
166 | + { |
|
167 | + return $this->count !== null; |
|
168 | + } |
|
169 | 169 | |
170 | - /** |
|
171 | - * @since 4.10.12.p |
|
172 | - * @return boolean |
|
173 | - */ |
|
174 | - public function isComplete() |
|
175 | - { |
|
176 | - if ($this->complete === null) { |
|
177 | - if (count($this->nodes) === $this->count) { |
|
178 | - $this->complete = true; |
|
179 | - } else { |
|
180 | - $this->complete = false; |
|
181 | - } |
|
182 | - } |
|
183 | - return $this->complete; |
|
184 | - } |
|
170 | + /** |
|
171 | + * @since 4.10.12.p |
|
172 | + * @return boolean |
|
173 | + */ |
|
174 | + public function isComplete() |
|
175 | + { |
|
176 | + if ($this->complete === null) { |
|
177 | + if (count($this->nodes) === $this->count) { |
|
178 | + $this->complete = true; |
|
179 | + } else { |
|
180 | + $this->complete = false; |
|
181 | + } |
|
182 | + } |
|
183 | + return $this->complete; |
|
184 | + } |
|
185 | 185 | |
186 | - /** |
|
187 | - * Discovers how many related model objects exist. |
|
188 | - * @since 4.10.12.p |
|
189 | - * @return mixed|void |
|
190 | - * @throws EE_Error |
|
191 | - * @throws InvalidArgumentException |
|
192 | - * @throws InvalidDataTypeException |
|
193 | - * @throws InvalidInterfaceException |
|
194 | - * @throws ReflectionException |
|
195 | - */ |
|
196 | - protected function discover() |
|
197 | - { |
|
198 | - $this->count = $this->related_model->count([$this->whereQueryParams()]); |
|
199 | - } |
|
186 | + /** |
|
187 | + * Discovers how many related model objects exist. |
|
188 | + * @since 4.10.12.p |
|
189 | + * @return mixed|void |
|
190 | + * @throws EE_Error |
|
191 | + * @throws InvalidArgumentException |
|
192 | + * @throws InvalidDataTypeException |
|
193 | + * @throws InvalidInterfaceException |
|
194 | + * @throws ReflectionException |
|
195 | + */ |
|
196 | + protected function discover() |
|
197 | + { |
|
198 | + $this->count = $this->related_model->count([$this->whereQueryParams()]); |
|
199 | + } |
|
200 | 200 | |
201 | - /** |
|
202 | - * @since 4.10.12.p |
|
203 | - * @return array |
|
204 | - * @throws EE_Error |
|
205 | - * @throws InvalidDataTypeException |
|
206 | - * @throws InvalidInterfaceException |
|
207 | - * @throws InvalidArgumentException |
|
208 | - * @throws ReflectionException |
|
209 | - */ |
|
210 | - protected function whereQueryParams() |
|
211 | - { |
|
212 | - $where_params = [ |
|
213 | - $this->related_model->get_foreign_key_to( |
|
214 | - $this->main_model->get_this_model_name() |
|
215 | - )->get_name() => $this->id |
|
216 | - ]; |
|
217 | - try { |
|
218 | - $relation_settings = $this->main_model->related_settings_for($this->related_model->get_this_model_name()); |
|
219 | - } catch (EE_Error $e) { |
|
220 | - // This will happen for has-and-belongs-to-many relations, when this node's related model is that join table |
|
221 | - // which hasn't been explicitly declared in the main model object's model's relations. |
|
222 | - $relation_settings = null; |
|
223 | - } |
|
224 | - if ($relation_settings instanceof EE_Has_Many_Any_Relation) { |
|
225 | - $where_params[ $this->related_model->get_field_containing_related_model_name()->get_name() ] = $this->main_model->get_this_model_name(); |
|
226 | - } |
|
227 | - return $where_params; |
|
228 | - } |
|
229 | - /** |
|
230 | - * @since 4.10.12.p |
|
231 | - * @return array |
|
232 | - */ |
|
233 | - public function toArray() |
|
234 | - { |
|
235 | - $tree = [ |
|
236 | - 'count' => $this->count, |
|
237 | - 'complete' => $this->isComplete(), |
|
238 | - 'objs' => [] |
|
239 | - ]; |
|
240 | - foreach ($this->nodes as $id => $model_obj_node) { |
|
241 | - $tree['objs'][ $id ] = $model_obj_node->toArray(); |
|
242 | - } |
|
243 | - return $tree; |
|
244 | - } |
|
201 | + /** |
|
202 | + * @since 4.10.12.p |
|
203 | + * @return array |
|
204 | + * @throws EE_Error |
|
205 | + * @throws InvalidDataTypeException |
|
206 | + * @throws InvalidInterfaceException |
|
207 | + * @throws InvalidArgumentException |
|
208 | + * @throws ReflectionException |
|
209 | + */ |
|
210 | + protected function whereQueryParams() |
|
211 | + { |
|
212 | + $where_params = [ |
|
213 | + $this->related_model->get_foreign_key_to( |
|
214 | + $this->main_model->get_this_model_name() |
|
215 | + )->get_name() => $this->id |
|
216 | + ]; |
|
217 | + try { |
|
218 | + $relation_settings = $this->main_model->related_settings_for($this->related_model->get_this_model_name()); |
|
219 | + } catch (EE_Error $e) { |
|
220 | + // This will happen for has-and-belongs-to-many relations, when this node's related model is that join table |
|
221 | + // which hasn't been explicitly declared in the main model object's model's relations. |
|
222 | + $relation_settings = null; |
|
223 | + } |
|
224 | + if ($relation_settings instanceof EE_Has_Many_Any_Relation) { |
|
225 | + $where_params[ $this->related_model->get_field_containing_related_model_name()->get_name() ] = $this->main_model->get_this_model_name(); |
|
226 | + } |
|
227 | + return $where_params; |
|
228 | + } |
|
229 | + /** |
|
230 | + * @since 4.10.12.p |
|
231 | + * @return array |
|
232 | + */ |
|
233 | + public function toArray() |
|
234 | + { |
|
235 | + $tree = [ |
|
236 | + 'count' => $this->count, |
|
237 | + 'complete' => $this->isComplete(), |
|
238 | + 'objs' => [] |
|
239 | + ]; |
|
240 | + foreach ($this->nodes as $id => $model_obj_node) { |
|
241 | + $tree['objs'][ $id ] = $model_obj_node->toArray(); |
|
242 | + } |
|
243 | + return $tree; |
|
244 | + } |
|
245 | 245 | |
246 | - /** |
|
247 | - * Gets the IDs of all the model objects to delete; indexed first by model object name. |
|
248 | - * @since 4.10.12.p |
|
249 | - * @return array |
|
250 | - */ |
|
251 | - public function getIds() |
|
252 | - { |
|
253 | - if (empty($this->nodes)) { |
|
254 | - return []; |
|
255 | - } |
|
256 | - $ids = [ |
|
257 | - $this->related_model->get_this_model_name() => array_combine( |
|
258 | - array_keys($this->nodes), |
|
259 | - array_keys($this->nodes) |
|
260 | - ) |
|
261 | - ]; |
|
262 | - foreach ($this->nodes as $model_obj_node) { |
|
263 | - $ids = array_replace_recursive($ids, $model_obj_node->getIds()); |
|
264 | - } |
|
265 | - return $ids; |
|
266 | - } |
|
246 | + /** |
|
247 | + * Gets the IDs of all the model objects to delete; indexed first by model object name. |
|
248 | + * @since 4.10.12.p |
|
249 | + * @return array |
|
250 | + */ |
|
251 | + public function getIds() |
|
252 | + { |
|
253 | + if (empty($this->nodes)) { |
|
254 | + return []; |
|
255 | + } |
|
256 | + $ids = [ |
|
257 | + $this->related_model->get_this_model_name() => array_combine( |
|
258 | + array_keys($this->nodes), |
|
259 | + array_keys($this->nodes) |
|
260 | + ) |
|
261 | + ]; |
|
262 | + foreach ($this->nodes as $model_obj_node) { |
|
263 | + $ids = array_replace_recursive($ids, $model_obj_node->getIds()); |
|
264 | + } |
|
265 | + return $ids; |
|
266 | + } |
|
267 | 267 | |
268 | - /** |
|
269 | - * Returns the number of sub-nodes found (ie, related model objects across this relation.) |
|
270 | - * @since 4.10.12.p |
|
271 | - * @return int |
|
272 | - */ |
|
273 | - public function countSubNodes() |
|
274 | - { |
|
275 | - return count($this->nodes); |
|
276 | - } |
|
268 | + /** |
|
269 | + * Returns the number of sub-nodes found (ie, related model objects across this relation.) |
|
270 | + * @since 4.10.12.p |
|
271 | + * @return int |
|
272 | + */ |
|
273 | + public function countSubNodes() |
|
274 | + { |
|
275 | + return count($this->nodes); |
|
276 | + } |
|
277 | 277 | |
278 | - /** |
|
279 | - * Don't serialize the models. Just record their names on some dynamic properties. |
|
280 | - * @since 4.10.12.p |
|
281 | - */ |
|
282 | - public function __sleep() |
|
283 | - { |
|
284 | - $this->m = $this->main_model->get_this_model_name(); |
|
285 | - $this->rm = $this->related_model->get_this_model_name(); |
|
286 | - return array_merge( |
|
287 | - [ |
|
288 | - 'm', |
|
289 | - 'rm', |
|
290 | - 'id', |
|
291 | - 'count', |
|
292 | - 'nodes', |
|
293 | - ], |
|
294 | - parent::__sleep() |
|
295 | - ); |
|
296 | - } |
|
278 | + /** |
|
279 | + * Don't serialize the models. Just record their names on some dynamic properties. |
|
280 | + * @since 4.10.12.p |
|
281 | + */ |
|
282 | + public function __sleep() |
|
283 | + { |
|
284 | + $this->m = $this->main_model->get_this_model_name(); |
|
285 | + $this->rm = $this->related_model->get_this_model_name(); |
|
286 | + return array_merge( |
|
287 | + [ |
|
288 | + 'm', |
|
289 | + 'rm', |
|
290 | + 'id', |
|
291 | + 'count', |
|
292 | + 'nodes', |
|
293 | + ], |
|
294 | + parent::__sleep() |
|
295 | + ); |
|
296 | + } |
|
297 | 297 | |
298 | - /** |
|
299 | - * Use the dynamic properties to instantiate the models we use. |
|
300 | - * @since 4.10.12.p |
|
301 | - * @throws EE_Error |
|
302 | - * @throws InvalidArgumentException |
|
303 | - * @throws InvalidDataTypeException |
|
304 | - * @throws InvalidInterfaceException |
|
305 | - * @throws ReflectionException |
|
306 | - */ |
|
307 | - public function __wakeup() |
|
308 | - { |
|
309 | - $this->main_model = EE_Registry::instance()->load_model($this->m); |
|
310 | - $this->related_model = EE_Registry::instance()->load_model($this->rm); |
|
311 | - parent::__wakeup(); |
|
312 | - } |
|
298 | + /** |
|
299 | + * Use the dynamic properties to instantiate the models we use. |
|
300 | + * @since 4.10.12.p |
|
301 | + * @throws EE_Error |
|
302 | + * @throws InvalidArgumentException |
|
303 | + * @throws InvalidDataTypeException |
|
304 | + * @throws InvalidInterfaceException |
|
305 | + * @throws ReflectionException |
|
306 | + */ |
|
307 | + public function __wakeup() |
|
308 | + { |
|
309 | + $this->main_model = EE_Registry::instance()->load_model($this->m); |
|
310 | + $this->related_model = EE_Registry::instance()->load_model($this->rm); |
|
311 | + parent::__wakeup(); |
|
312 | + } |
|
313 | 313 | } |
314 | 314 | // End of file RelationNode.php |
315 | 315 | // Location: EventEspresso\core\services\orm\tree_traversal/RelationNode.php |
@@ -22,55 +22,55 @@ |
||
22 | 22 | */ |
23 | 23 | class ConfirmEventDeletionForm extends \EE_Form_Section_Proper |
24 | 24 | { |
25 | - /** |
|
26 | - * @var EE_Event[] |
|
27 | - */ |
|
28 | - protected $events; |
|
29 | - public function __construct($event_ids, $options_array = array()) |
|
30 | - { |
|
31 | - if (! isset($options_array['subsections'])) { |
|
32 | - $options_array['subsections'] = []; |
|
33 | - } |
|
34 | - if (! isset($options_array['subsections']['events'])) { |
|
35 | - $events_subsection = new \EE_Form_Section_Proper(); |
|
36 | - $options_array['subsections']['events'] = $events_subsection; |
|
37 | - } |
|
38 | - $events = EEM_Event::instance()->get_all_deleted_and_undeleted( |
|
39 | - [ |
|
40 | - [ |
|
41 | - 'EVT_ID' => ['IN',$event_ids] |
|
42 | - ] |
|
43 | - ] |
|
44 | - ); |
|
45 | - if (! is_array($events)) { |
|
46 | - throw new UnexpectedEntityException($event_ids, 'array'); |
|
47 | - } |
|
48 | - $this->events = $events; |
|
49 | - $events_inputs = [ |
|
50 | - ]; |
|
51 | - foreach ($events as $event) { |
|
52 | - $events_inputs[ $event->ID() ] = new EE_Checkbox_Multi_Input( |
|
53 | - [ |
|
54 | - 'yes' => $event->name(), |
|
55 | - ], |
|
56 | - [ |
|
57 | - 'html_label_text' => esc_html__('Please confirm you wish to delete:', 'event_espresso'), |
|
58 | - 'required' => true |
|
59 | - ] |
|
60 | - ); |
|
61 | - } |
|
62 | - $events_subsection->add_subsections($events_inputs); |
|
63 | - $options_array['subsections']['backup'] = new EE_Checkbox_Multi_Input( |
|
64 | - [ |
|
65 | - 'yes' => esc_html__('I have backed up my database.', 'event_espresso') |
|
66 | - ], |
|
67 | - [ |
|
68 | - 'html_label_text' => esc_html__('Deleting this data cannot be undone. Please confirm you have a usable database backup.', 'event_espresso'), |
|
69 | - 'required' => true |
|
70 | - ] |
|
71 | - ); |
|
72 | - parent::__construct($options_array); |
|
73 | - } |
|
25 | + /** |
|
26 | + * @var EE_Event[] |
|
27 | + */ |
|
28 | + protected $events; |
|
29 | + public function __construct($event_ids, $options_array = array()) |
|
30 | + { |
|
31 | + if (! isset($options_array['subsections'])) { |
|
32 | + $options_array['subsections'] = []; |
|
33 | + } |
|
34 | + if (! isset($options_array['subsections']['events'])) { |
|
35 | + $events_subsection = new \EE_Form_Section_Proper(); |
|
36 | + $options_array['subsections']['events'] = $events_subsection; |
|
37 | + } |
|
38 | + $events = EEM_Event::instance()->get_all_deleted_and_undeleted( |
|
39 | + [ |
|
40 | + [ |
|
41 | + 'EVT_ID' => ['IN',$event_ids] |
|
42 | + ] |
|
43 | + ] |
|
44 | + ); |
|
45 | + if (! is_array($events)) { |
|
46 | + throw new UnexpectedEntityException($event_ids, 'array'); |
|
47 | + } |
|
48 | + $this->events = $events; |
|
49 | + $events_inputs = [ |
|
50 | + ]; |
|
51 | + foreach ($events as $event) { |
|
52 | + $events_inputs[ $event->ID() ] = new EE_Checkbox_Multi_Input( |
|
53 | + [ |
|
54 | + 'yes' => $event->name(), |
|
55 | + ], |
|
56 | + [ |
|
57 | + 'html_label_text' => esc_html__('Please confirm you wish to delete:', 'event_espresso'), |
|
58 | + 'required' => true |
|
59 | + ] |
|
60 | + ); |
|
61 | + } |
|
62 | + $events_subsection->add_subsections($events_inputs); |
|
63 | + $options_array['subsections']['backup'] = new EE_Checkbox_Multi_Input( |
|
64 | + [ |
|
65 | + 'yes' => esc_html__('I have backed up my database.', 'event_espresso') |
|
66 | + ], |
|
67 | + [ |
|
68 | + 'html_label_text' => esc_html__('Deleting this data cannot be undone. Please confirm you have a usable database backup.', 'event_espresso'), |
|
69 | + 'required' => true |
|
70 | + ] |
|
71 | + ); |
|
72 | + parent::__construct($options_array); |
|
73 | + } |
|
74 | 74 | } |
75 | 75 | // End of file ConfirmEventDeletionForm.php |
76 | 76 | // Location: EventEspresso\admin_pages\events\form_sections/ConfirmEventDeletionForm.php |
@@ -28,28 +28,28 @@ |
||
28 | 28 | protected $events; |
29 | 29 | public function __construct($event_ids, $options_array = array()) |
30 | 30 | { |
31 | - if (! isset($options_array['subsections'])) { |
|
31 | + if ( ! isset($options_array['subsections'])) { |
|
32 | 32 | $options_array['subsections'] = []; |
33 | 33 | } |
34 | - if (! isset($options_array['subsections']['events'])) { |
|
34 | + if ( ! isset($options_array['subsections']['events'])) { |
|
35 | 35 | $events_subsection = new \EE_Form_Section_Proper(); |
36 | 36 | $options_array['subsections']['events'] = $events_subsection; |
37 | 37 | } |
38 | 38 | $events = EEM_Event::instance()->get_all_deleted_and_undeleted( |
39 | 39 | [ |
40 | 40 | [ |
41 | - 'EVT_ID' => ['IN',$event_ids] |
|
41 | + 'EVT_ID' => ['IN', $event_ids] |
|
42 | 42 | ] |
43 | 43 | ] |
44 | 44 | ); |
45 | - if (! is_array($events)) { |
|
45 | + if ( ! is_array($events)) { |
|
46 | 46 | throw new UnexpectedEntityException($event_ids, 'array'); |
47 | 47 | } |
48 | 48 | $this->events = $events; |
49 | 49 | $events_inputs = [ |
50 | 50 | ]; |
51 | 51 | foreach ($events as $event) { |
52 | - $events_inputs[ $event->ID() ] = new EE_Checkbox_Multi_Input( |
|
52 | + $events_inputs[$event->ID()] = new EE_Checkbox_Multi_Input( |
|
53 | 53 | [ |
54 | 54 | 'yes' => $event->name(), |
55 | 55 | ], |
@@ -29,10 +29,10 @@ |
||
29 | 29 | isset($input_settings['validation_error_message']) |
30 | 30 | ? $input_settings['validation_error_message'] |
31 | 31 | : null, |
32 | - '#' . str_replace('email_confirm', 'email', $input_settings['html_id']) |
|
32 | + '#'.str_replace('email_confirm', 'email', $input_settings['html_id']) |
|
33 | 33 | ) |
34 | 34 | ); |
35 | 35 | parent::__construct($input_settings); |
36 | - $this->set_html_class($this->html_class() . ' email'); |
|
36 | + $this->set_html_class($this->html_class().' email'); |
|
37 | 37 | } |
38 | 38 | } |
@@ -10,29 +10,29 @@ |
||
10 | 10 | */ |
11 | 11 | class EE_Email_Confirm_Input extends EE_Form_Input_Base |
12 | 12 | { |
13 | - /** |
|
14 | - * @param array $input_settings |
|
15 | - */ |
|
16 | - public function __construct($input_settings = array()) |
|
17 | - { |
|
18 | - $this->_set_display_strategy(new EE_Text_Input_Display_Strategy('email')); |
|
19 | - $this->_set_normalization_strategy(new EE_Text_Normalization()); |
|
20 | - $this->_add_validation_strategy( |
|
21 | - new EE_Email_Validation_Strategy( |
|
22 | - isset($input_settings['validation_error_message']) |
|
23 | - ? $input_settings['validation_error_message'] |
|
24 | - : null |
|
25 | - ) |
|
26 | - ); |
|
27 | - $this->_add_validation_strategy( |
|
28 | - new EE_Equal_To_Validation_Strategy( |
|
29 | - isset($input_settings['validation_error_message']) |
|
30 | - ? $input_settings['validation_error_message'] |
|
31 | - : null, |
|
32 | - '#' . str_replace('email_confirm', 'email', $input_settings['html_id']) |
|
33 | - ) |
|
34 | - ); |
|
35 | - parent::__construct($input_settings); |
|
36 | - $this->set_html_class($this->html_class() . ' email'); |
|
37 | - } |
|
13 | + /** |
|
14 | + * @param array $input_settings |
|
15 | + */ |
|
16 | + public function __construct($input_settings = array()) |
|
17 | + { |
|
18 | + $this->_set_display_strategy(new EE_Text_Input_Display_Strategy('email')); |
|
19 | + $this->_set_normalization_strategy(new EE_Text_Normalization()); |
|
20 | + $this->_add_validation_strategy( |
|
21 | + new EE_Email_Validation_Strategy( |
|
22 | + isset($input_settings['validation_error_message']) |
|
23 | + ? $input_settings['validation_error_message'] |
|
24 | + : null |
|
25 | + ) |
|
26 | + ); |
|
27 | + $this->_add_validation_strategy( |
|
28 | + new EE_Equal_To_Validation_Strategy( |
|
29 | + isset($input_settings['validation_error_message']) |
|
30 | + ? $input_settings['validation_error_message'] |
|
31 | + : null, |
|
32 | + '#' . str_replace('email_confirm', 'email', $input_settings['html_id']) |
|
33 | + ) |
|
34 | + ); |
|
35 | + parent::__construct($input_settings); |
|
36 | + $this->set_html_class($this->html_class() . ' email'); |
|
37 | + } |
|
38 | 38 | } |
@@ -23,7 +23,7 @@ |
||
23 | 23 | */ |
24 | 24 | public function __construct($validation_error_message = '', $compare_to) |
25 | 25 | { |
26 | - if (! $validation_error_message) { |
|
26 | + if ( ! $validation_error_message) { |
|
27 | 27 | $validation_error_message = apply_filters( |
28 | 28 | 'FHEE__EE_Equal_To_Validation_Strategy____construct__validation_error_message', |
29 | 29 | esc_html__('Fields do not match.', 'event_espresso') |
@@ -15,49 +15,49 @@ |
||
15 | 15 | */ |
16 | 16 | class EE_Equal_To_Validation_Strategy extends EE_Text_Validation_Strategy |
17 | 17 | { |
18 | - protected $_compare_to = null; |
|
19 | - |
|
20 | - |
|
21 | - /** |
|
22 | - * @param string $validation_error_message |
|
23 | - */ |
|
24 | - public function __construct($validation_error_message = '', $compare_to) |
|
25 | - { |
|
26 | - if (! $validation_error_message) { |
|
27 | - $validation_error_message = apply_filters( |
|
28 | - 'FHEE__EE_Equal_To_Validation_Strategy____construct__validation_error_message', |
|
29 | - esc_html__('Fields do not match.', 'event_espresso') |
|
30 | - ); |
|
31 | - } |
|
32 | - parent::__construct($validation_error_message); |
|
33 | - $this->_compare_to = $compare_to; |
|
34 | - } |
|
35 | - |
|
36 | - |
|
37 | - |
|
38 | - /** |
|
39 | - * just checks the field isn't blank |
|
40 | - * |
|
41 | - * @param $normalized_value |
|
42 | - * @return bool |
|
43 | - * @throws InvalidArgumentException |
|
44 | - * @throws InvalidInterfaceException |
|
45 | - * @throws InvalidDataTypeException |
|
46 | - * @throws EE_Validation_Error |
|
47 | - */ |
|
48 | - public function validate($normalized_value) |
|
49 | - { |
|
50 | - // No need to be validated |
|
51 | - return true; |
|
52 | - } |
|
53 | - |
|
54 | - |
|
55 | - |
|
56 | - /** |
|
57 | - * @return array |
|
58 | - */ |
|
59 | - public function get_jquery_validation_rule_array() |
|
60 | - { |
|
61 | - return array('equalTo' => $this->_compare_to, 'messages' => array('equalTo' => $this->get_validation_error_message())); |
|
62 | - } |
|
18 | + protected $_compare_to = null; |
|
19 | + |
|
20 | + |
|
21 | + /** |
|
22 | + * @param string $validation_error_message |
|
23 | + */ |
|
24 | + public function __construct($validation_error_message = '', $compare_to) |
|
25 | + { |
|
26 | + if (! $validation_error_message) { |
|
27 | + $validation_error_message = apply_filters( |
|
28 | + 'FHEE__EE_Equal_To_Validation_Strategy____construct__validation_error_message', |
|
29 | + esc_html__('Fields do not match.', 'event_espresso') |
|
30 | + ); |
|
31 | + } |
|
32 | + parent::__construct($validation_error_message); |
|
33 | + $this->_compare_to = $compare_to; |
|
34 | + } |
|
35 | + |
|
36 | + |
|
37 | + |
|
38 | + /** |
|
39 | + * just checks the field isn't blank |
|
40 | + * |
|
41 | + * @param $normalized_value |
|
42 | + * @return bool |
|
43 | + * @throws InvalidArgumentException |
|
44 | + * @throws InvalidInterfaceException |
|
45 | + * @throws InvalidDataTypeException |
|
46 | + * @throws EE_Validation_Error |
|
47 | + */ |
|
48 | + public function validate($normalized_value) |
|
49 | + { |
|
50 | + // No need to be validated |
|
51 | + return true; |
|
52 | + } |
|
53 | + |
|
54 | + |
|
55 | + |
|
56 | + /** |
|
57 | + * @return array |
|
58 | + */ |
|
59 | + public function get_jquery_validation_rule_array() |
|
60 | + { |
|
61 | + return array('equalTo' => $this->_compare_to, 'messages' => array('equalTo' => $this->get_validation_error_message())); |
|
62 | + } |
|
63 | 63 | } |
@@ -112,10 +112,10 @@ |
||
112 | 112 | ]; |
113 | 113 | $this->_wp_core_model = true; |
114 | 114 | $this->_caps_slug = 'users'; |
115 | - $this->_cap_contexts_to_cap_action_map[ EEM_Base::caps_read ] = 'list'; |
|
116 | - $this->_cap_contexts_to_cap_action_map[ EEM_Base::caps_read_admin ] = 'list'; |
|
115 | + $this->_cap_contexts_to_cap_action_map[EEM_Base::caps_read] = 'list'; |
|
116 | + $this->_cap_contexts_to_cap_action_map[EEM_Base::caps_read_admin] = 'list'; |
|
117 | 117 | foreach ($this->_cap_contexts_to_cap_action_map as $context => $action) { |
118 | - $this->_cap_restriction_generators[ $context ] = new EE_Restriction_Generator_WP_User(); |
|
118 | + $this->_cap_restriction_generators[$context] = new EE_Restriction_Generator_WP_User(); |
|
119 | 119 | } |
120 | 120 | // @todo: account for create_users controls whether they can create users at all |
121 | 121 | parent::__construct($timezone); |
@@ -12,133 +12,133 @@ |
||
12 | 12 | */ |
13 | 13 | class EEM_WP_User extends EEM_Base |
14 | 14 | { |
15 | - /** |
|
16 | - * private instance of the EEM_WP_User object |
|
17 | - * |
|
18 | - * @type EEM_WP_User |
|
19 | - */ |
|
20 | - protected static $_instance; |
|
15 | + /** |
|
16 | + * private instance of the EEM_WP_User object |
|
17 | + * |
|
18 | + * @type EEM_WP_User |
|
19 | + */ |
|
20 | + protected static $_instance; |
|
21 | 21 | |
22 | 22 | |
23 | - /** |
|
24 | - * constructor |
|
25 | - * |
|
26 | - * @param null $timezone |
|
27 | - * @param ModelFieldFactory $model_field_factory |
|
28 | - * @throws EE_Error |
|
29 | - * @throws InvalidArgumentException |
|
30 | - */ |
|
31 | - protected function __construct($timezone, ModelFieldFactory $model_field_factory) |
|
32 | - { |
|
33 | - $this->singular_item = esc_html__('WP_User', 'event_espresso'); |
|
34 | - $this->plural_item = esc_html__('WP_Users', 'event_espresso'); |
|
35 | - global $wpdb; |
|
36 | - $this->_tables = array( |
|
37 | - 'WP_User' => new EE_Primary_Table($wpdb->users, 'ID', true), |
|
38 | - ); |
|
39 | - $this->_fields = array( |
|
40 | - 'WP_User' => array( |
|
41 | - 'ID' => $model_field_factory->createPrimaryKeyIntField( |
|
42 | - 'ID', |
|
43 | - esc_html__('WP_User ID', 'event_espresso') |
|
44 | - ), |
|
45 | - 'user_login' => $model_field_factory->createPlainTextField( |
|
46 | - 'user_login', |
|
47 | - esc_html__('User Login', 'event_espresso'), |
|
48 | - false |
|
49 | - ), |
|
50 | - 'user_pass' => $model_field_factory->createPlainTextField( |
|
51 | - 'user_pass', |
|
52 | - esc_html__('User Password', 'event_espresso'), |
|
53 | - false |
|
54 | - ), |
|
55 | - 'user_nicename' => $model_field_factory->createPlainTextField( |
|
56 | - 'user_nicename', |
|
57 | - esc_html__(' User Nice Name', 'event_espresso'), |
|
58 | - false |
|
59 | - ), |
|
60 | - 'user_email' => $model_field_factory->createEmailField( |
|
61 | - 'user_email', |
|
62 | - esc_html__('User Email', 'event_espresso'), |
|
63 | - false, |
|
64 | - null |
|
65 | - ), |
|
66 | - 'user_registered' => $model_field_factory->createDatetimeField( |
|
67 | - 'user_registered', |
|
68 | - esc_html__('Date User Registered', 'event_espresso'), |
|
69 | - $timezone |
|
70 | - ), |
|
71 | - 'user_activation_key' => $model_field_factory->createPlainTextField( |
|
72 | - 'user_activation_key', |
|
73 | - esc_html__('User Activation Key', 'event_espresso'), |
|
74 | - false |
|
75 | - ), |
|
76 | - 'user_status' => $model_field_factory->createIntegerField( |
|
77 | - 'user_status', |
|
78 | - esc_html__('User Status', 'event_espresso') |
|
79 | - ), |
|
80 | - 'display_name' => $model_field_factory->createPlainTextField( |
|
81 | - 'display_name', |
|
82 | - esc_html__('Display Name', 'event_espresso'), |
|
83 | - false |
|
84 | - ), |
|
85 | - ), |
|
86 | - ); |
|
87 | - $this->_model_relations = array( |
|
88 | - 'Attendee' => new EE_Has_Many_Relation(), |
|
89 | - // all models are related to the change log |
|
90 | - // 'Change_Log' => new EE_Has_Many_Relation(), |
|
91 | - 'Event' => new EE_Has_Many_Relation(), |
|
92 | - 'Message' => new EE_Has_Many_Relation(), |
|
93 | - 'Payment_Method' => new EE_Has_Many_Relation(), |
|
94 | - 'Price' => new EE_Has_Many_Relation(), |
|
95 | - 'Price_Type' => new EE_Has_Many_Relation(), |
|
96 | - 'Question' => new EE_Has_Many_Relation(), |
|
97 | - 'Question_Group' => new EE_Has_Many_Relation(), |
|
98 | - 'Ticket' => new EE_Has_Many_Relation(), |
|
99 | - 'Venue' => new EE_Has_Many_Relation(), |
|
100 | - ); |
|
101 | - $this->foreign_key_aliases = [ |
|
102 | - 'Event.EVT_wp_user' => 'WP_User.ID', |
|
103 | - 'Payment_Method.PMD_wp_user' => 'WP_User.ID', |
|
104 | - 'Price.PRC_wp_user' => 'WP_User.ID', |
|
105 | - 'Price_Type.PRT_wp_user' => 'WP_User.ID', |
|
106 | - 'Question.QST_wp_user' => 'WP_User.ID', |
|
107 | - 'Question_Group.QSG_wp_user' => 'WP_User.ID', |
|
108 | - 'Ticket.VNU_wp_user' => 'WP_User.ID', |
|
109 | - 'Venue.TKT_wp_user' => 'WP_User.ID', |
|
110 | - ]; |
|
111 | - $this->_wp_core_model = true; |
|
112 | - $this->_caps_slug = 'users'; |
|
113 | - $this->_cap_contexts_to_cap_action_map[ EEM_Base::caps_read ] = 'list'; |
|
114 | - $this->_cap_contexts_to_cap_action_map[ EEM_Base::caps_read_admin ] = 'list'; |
|
115 | - foreach ($this->_cap_contexts_to_cap_action_map as $context => $action) { |
|
116 | - $this->_cap_restriction_generators[ $context ] = new EE_Restriction_Generator_WP_User(); |
|
117 | - } |
|
118 | - // @todo: account for create_users controls whether they can create users at all |
|
119 | - parent::__construct($timezone); |
|
120 | - } |
|
23 | + /** |
|
24 | + * constructor |
|
25 | + * |
|
26 | + * @param null $timezone |
|
27 | + * @param ModelFieldFactory $model_field_factory |
|
28 | + * @throws EE_Error |
|
29 | + * @throws InvalidArgumentException |
|
30 | + */ |
|
31 | + protected function __construct($timezone, ModelFieldFactory $model_field_factory) |
|
32 | + { |
|
33 | + $this->singular_item = esc_html__('WP_User', 'event_espresso'); |
|
34 | + $this->plural_item = esc_html__('WP_Users', 'event_espresso'); |
|
35 | + global $wpdb; |
|
36 | + $this->_tables = array( |
|
37 | + 'WP_User' => new EE_Primary_Table($wpdb->users, 'ID', true), |
|
38 | + ); |
|
39 | + $this->_fields = array( |
|
40 | + 'WP_User' => array( |
|
41 | + 'ID' => $model_field_factory->createPrimaryKeyIntField( |
|
42 | + 'ID', |
|
43 | + esc_html__('WP_User ID', 'event_espresso') |
|
44 | + ), |
|
45 | + 'user_login' => $model_field_factory->createPlainTextField( |
|
46 | + 'user_login', |
|
47 | + esc_html__('User Login', 'event_espresso'), |
|
48 | + false |
|
49 | + ), |
|
50 | + 'user_pass' => $model_field_factory->createPlainTextField( |
|
51 | + 'user_pass', |
|
52 | + esc_html__('User Password', 'event_espresso'), |
|
53 | + false |
|
54 | + ), |
|
55 | + 'user_nicename' => $model_field_factory->createPlainTextField( |
|
56 | + 'user_nicename', |
|
57 | + esc_html__(' User Nice Name', 'event_espresso'), |
|
58 | + false |
|
59 | + ), |
|
60 | + 'user_email' => $model_field_factory->createEmailField( |
|
61 | + 'user_email', |
|
62 | + esc_html__('User Email', 'event_espresso'), |
|
63 | + false, |
|
64 | + null |
|
65 | + ), |
|
66 | + 'user_registered' => $model_field_factory->createDatetimeField( |
|
67 | + 'user_registered', |
|
68 | + esc_html__('Date User Registered', 'event_espresso'), |
|
69 | + $timezone |
|
70 | + ), |
|
71 | + 'user_activation_key' => $model_field_factory->createPlainTextField( |
|
72 | + 'user_activation_key', |
|
73 | + esc_html__('User Activation Key', 'event_espresso'), |
|
74 | + false |
|
75 | + ), |
|
76 | + 'user_status' => $model_field_factory->createIntegerField( |
|
77 | + 'user_status', |
|
78 | + esc_html__('User Status', 'event_espresso') |
|
79 | + ), |
|
80 | + 'display_name' => $model_field_factory->createPlainTextField( |
|
81 | + 'display_name', |
|
82 | + esc_html__('Display Name', 'event_espresso'), |
|
83 | + false |
|
84 | + ), |
|
85 | + ), |
|
86 | + ); |
|
87 | + $this->_model_relations = array( |
|
88 | + 'Attendee' => new EE_Has_Many_Relation(), |
|
89 | + // all models are related to the change log |
|
90 | + // 'Change_Log' => new EE_Has_Many_Relation(), |
|
91 | + 'Event' => new EE_Has_Many_Relation(), |
|
92 | + 'Message' => new EE_Has_Many_Relation(), |
|
93 | + 'Payment_Method' => new EE_Has_Many_Relation(), |
|
94 | + 'Price' => new EE_Has_Many_Relation(), |
|
95 | + 'Price_Type' => new EE_Has_Many_Relation(), |
|
96 | + 'Question' => new EE_Has_Many_Relation(), |
|
97 | + 'Question_Group' => new EE_Has_Many_Relation(), |
|
98 | + 'Ticket' => new EE_Has_Many_Relation(), |
|
99 | + 'Venue' => new EE_Has_Many_Relation(), |
|
100 | + ); |
|
101 | + $this->foreign_key_aliases = [ |
|
102 | + 'Event.EVT_wp_user' => 'WP_User.ID', |
|
103 | + 'Payment_Method.PMD_wp_user' => 'WP_User.ID', |
|
104 | + 'Price.PRC_wp_user' => 'WP_User.ID', |
|
105 | + 'Price_Type.PRT_wp_user' => 'WP_User.ID', |
|
106 | + 'Question.QST_wp_user' => 'WP_User.ID', |
|
107 | + 'Question_Group.QSG_wp_user' => 'WP_User.ID', |
|
108 | + 'Ticket.VNU_wp_user' => 'WP_User.ID', |
|
109 | + 'Venue.TKT_wp_user' => 'WP_User.ID', |
|
110 | + ]; |
|
111 | + $this->_wp_core_model = true; |
|
112 | + $this->_caps_slug = 'users'; |
|
113 | + $this->_cap_contexts_to_cap_action_map[ EEM_Base::caps_read ] = 'list'; |
|
114 | + $this->_cap_contexts_to_cap_action_map[ EEM_Base::caps_read_admin ] = 'list'; |
|
115 | + foreach ($this->_cap_contexts_to_cap_action_map as $context => $action) { |
|
116 | + $this->_cap_restriction_generators[ $context ] = new EE_Restriction_Generator_WP_User(); |
|
117 | + } |
|
118 | + // @todo: account for create_users controls whether they can create users at all |
|
119 | + parent::__construct($timezone); |
|
120 | + } |
|
121 | 121 | |
122 | 122 | |
123 | - /** |
|
124 | - * We don't need a foreign key to the WP_User model, we just need its primary key |
|
125 | - * |
|
126 | - * @return string |
|
127 | - * @throws EE_Error |
|
128 | - */ |
|
129 | - public function wp_user_field_name() |
|
130 | - { |
|
131 | - return $this->primary_key_name(); |
|
132 | - } |
|
123 | + /** |
|
124 | + * We don't need a foreign key to the WP_User model, we just need its primary key |
|
125 | + * |
|
126 | + * @return string |
|
127 | + * @throws EE_Error |
|
128 | + */ |
|
129 | + public function wp_user_field_name() |
|
130 | + { |
|
131 | + return $this->primary_key_name(); |
|
132 | + } |
|
133 | 133 | |
134 | 134 | |
135 | - /** |
|
136 | - * This WP_User model IS owned, even though it doesn't have a foreign key to itself |
|
137 | - * |
|
138 | - * @return boolean |
|
139 | - */ |
|
140 | - public function is_owned() |
|
141 | - { |
|
142 | - return true; |
|
143 | - } |
|
135 | + /** |
|
136 | + * This WP_User model IS owned, even though it doesn't have a foreign key to itself |
|
137 | + * |
|
138 | + * @return boolean |
|
139 | + */ |
|
140 | + public function is_owned() |
|
141 | + { |
|
142 | + return true; |
|
143 | + } |
|
144 | 144 | } |