@@ -13,15 +13,15 @@ discard block |
||
13 | 13 | class Venues extends GraphQLData |
14 | 14 | { |
15 | 15 | |
16 | - /** |
|
17 | - * @param array $where_params |
|
18 | - * @return array|null |
|
19 | - * @since $VID:$ |
|
20 | - */ |
|
21 | - public function getData(array $where_params = []) |
|
22 | - { |
|
23 | - $field_key = lcfirst($this->namespace) . 'Venues'; |
|
24 | - $query = <<<QUERY |
|
16 | + /** |
|
17 | + * @param array $where_params |
|
18 | + * @return array|null |
|
19 | + * @since $VID:$ |
|
20 | + */ |
|
21 | + public function getData(array $where_params = []) |
|
22 | + { |
|
23 | + $field_key = lcfirst($this->namespace) . 'Venues'; |
|
24 | + $query = <<<QUERY |
|
25 | 25 | query GET_VENUES(\$where: RootQueryTo{$this->namespace}VenueConnectionWhereArgs, \$first: Int, \$last: Int ) { |
26 | 26 | {$field_key}(where: \$where, first: \$first, last: \$last) { |
27 | 27 | nodes { |
@@ -41,14 +41,14 @@ discard block |
||
41 | 41 | } |
42 | 42 | } |
43 | 43 | QUERY; |
44 | - $this->setParams([ |
|
45 | - 'operation_name' => 'GET_VENUES', |
|
46 | - 'variables' => [ |
|
47 | - 'first' => 100, |
|
48 | - ], |
|
49 | - 'query' => $query, |
|
50 | - ]); |
|
44 | + $this->setParams([ |
|
45 | + 'operation_name' => 'GET_VENUES', |
|
46 | + 'variables' => [ |
|
47 | + 'first' => 100, |
|
48 | + ], |
|
49 | + 'query' => $query, |
|
50 | + ]); |
|
51 | 51 | |
52 | - return $this->getQueryResponse($field_key, $where_params); |
|
53 | - } |
|
52 | + return $this->getQueryResponse($field_key, $where_params); |
|
53 | + } |
|
54 | 54 | } |
@@ -20,7 +20,7 @@ |
||
20 | 20 | */ |
21 | 21 | public function getData(array $where_params = []) |
22 | 22 | { |
23 | - $field_key = lcfirst($this->namespace) . 'Venues'; |
|
23 | + $field_key = lcfirst($this->namespace).'Venues'; |
|
24 | 24 | $query = <<<QUERY |
25 | 25 | query GET_VENUES(\$where: RootQueryTo{$this->namespace}VenueConnectionWhereArgs, \$first: Int, \$last: Int ) { |
26 | 26 | {$field_key}(where: \$where, first: \$first, last: \$last) { |
@@ -18,128 +18,128 @@ |
||
18 | 18 | class EspressoEventEditor extends EspressoEventsAdmin |
19 | 19 | { |
20 | 20 | |
21 | - /** |
|
22 | - * returns true if the current request matches this route |
|
23 | - * |
|
24 | - * @return bool |
|
25 | - * @since $VID:$ |
|
26 | - */ |
|
27 | - public function matchesCurrentRequest(): bool |
|
28 | - { |
|
29 | - return parent::matchesCurrentRequest() |
|
30 | - && $this->admin_config->useAdvancedEditor() |
|
31 | - && ( |
|
32 | - $this->request->getRequestParam('action') === 'create_new' |
|
33 | - || $this->request->getRequestParam('action') === 'edit' |
|
34 | - ); |
|
35 | - } |
|
21 | + /** |
|
22 | + * returns true if the current request matches this route |
|
23 | + * |
|
24 | + * @return bool |
|
25 | + * @since $VID:$ |
|
26 | + */ |
|
27 | + public function matchesCurrentRequest(): bool |
|
28 | + { |
|
29 | + return parent::matchesCurrentRequest() |
|
30 | + && $this->admin_config->useAdvancedEditor() |
|
31 | + && ( |
|
32 | + $this->request->getRequestParam('action') === 'create_new' |
|
33 | + || $this->request->getRequestParam('action') === 'edit' |
|
34 | + ); |
|
35 | + } |
|
36 | 36 | |
37 | 37 | |
38 | - /** |
|
39 | - * @since $VID:$ |
|
40 | - */ |
|
41 | - protected function registerDependencies() |
|
42 | - { |
|
43 | - $editor_dependencies = [ |
|
44 | - 'EventEspresso\core\domain\services\admin\events\editor\EventEditorGraphQLData' => [ |
|
45 | - 'EventEspresso\core\domain\entities\admin\GraphQLData\Datetimes' => EE_Dependency_Map::load_from_cache, |
|
46 | - 'EventEspresso\core\domain\entities\admin\GraphQLData\Event' => EE_Dependency_Map::load_from_cache, |
|
47 | - 'EventEspresso\core\domain\entities\admin\GraphQLData\Prices' => EE_Dependency_Map::load_from_cache, |
|
48 | - 'EventEspresso\core\domain\entities\admin\GraphQLData\PriceTypes' => EE_Dependency_Map::load_from_cache, |
|
49 | - 'EventEspresso\core\domain\entities\admin\GraphQLData\Tickets' => EE_Dependency_Map::load_from_cache, |
|
50 | - 'EventEspresso\core\domain\services\admin\events\editor\NewEventDefaultEntities' => EE_Dependency_Map::load_from_cache, |
|
51 | - '\EventEspresso\core\domain\services\admin\events\editor\EventManagerData' => EE_Dependency_Map::load_from_cache, |
|
52 | - 'EventEspresso\core\domain\services\admin\events\editor\EventEntityRelations' => EE_Dependency_Map::load_from_cache, |
|
53 | - 'EventEspresso\core\domain\services\admin\events\editor\TicketMeta' => EE_Dependency_Map::load_from_cache, |
|
54 | - 'EventEspresso\core\domain\services\admin\events\editor\FormBuilder' => EE_Dependency_Map::load_from_cache, |
|
55 | - 'EventEspresso\core\domain\entities\admin\GraphQLData\Venues' => EE_Dependency_Map::load_from_cache, |
|
56 | - ], |
|
57 | - 'EventEspresso\core\domain\services\admin\events\editor\EventEntityRelations' => [ |
|
58 | - 'EEM_Datetime' => EE_Dependency_Map::load_from_cache, |
|
59 | - 'EEM_Event' => EE_Dependency_Map::load_from_cache, |
|
60 | - 'EEM_Price' => EE_Dependency_Map::load_from_cache, |
|
61 | - 'EEM_Price_Type' => EE_Dependency_Map::load_from_cache, |
|
62 | - 'EEM_Ticket' => EE_Dependency_Map::load_from_cache, |
|
63 | - 'EventEspresso\core\domain\services\graphql\Utilities' => EE_Dependency_Map::load_from_cache, |
|
64 | - ], |
|
65 | - 'EventEspresso\core\domain\services\admin\events\editor\NewEventDefaultEntities' => [ |
|
66 | - 'EventEspresso\core\domain\services\admin\entities\DefaultDatetimes' => EE_Dependency_Map::load_from_cache, |
|
67 | - 'EventEspresso\core\domain\services\admin\entities\DefaultFormSections' => EE_Dependency_Map::load_from_cache, |
|
68 | - 'EEM_Datetime' => EE_Dependency_Map::load_from_cache, |
|
69 | - 'EEM_Event' => EE_Dependency_Map::load_from_cache, |
|
70 | - 'EEM_Price' => EE_Dependency_Map::load_from_cache, |
|
71 | - 'EEM_Price_Type' => EE_Dependency_Map::load_from_cache, |
|
72 | - 'EEM_Ticket' => EE_Dependency_Map::load_from_cache, |
|
73 | - 'EventEspresso\core\domain\services\graphql\Utilities' => EE_Dependency_Map::load_from_cache, |
|
74 | - ], |
|
75 | - 'EventEspresso\core\domain\services\admin\events\editor\TicketMeta' => [ |
|
76 | - 'EEM_Ticket' => EE_Dependency_Map::load_from_cache, |
|
77 | - ], |
|
78 | - 'EventEspresso\core\domain\services\admin\entities\DefaultDatetimes' => [ |
|
79 | - 'EventEspresso\core\domain\services\admin\entities\DefaultTickets' => EE_Dependency_Map::load_from_cache, |
|
80 | - 'EEM_Datetime' => EE_Dependency_Map::load_from_cache, |
|
81 | - ], |
|
82 | - 'EventEspresso\core\domain\services\admin\entities\DefaultTickets' => [ |
|
83 | - 'EventEspresso\core\domain\services\admin\entities\DefaultPrices' => EE_Dependency_Map::load_from_cache, |
|
84 | - 'EEM_Ticket' => EE_Dependency_Map::load_from_cache, |
|
85 | - ], |
|
86 | - 'EventEspresso\core\domain\services\admin\entities\DefaultPrices' => [ |
|
87 | - 'EEM_Price' => EE_Dependency_Map::load_from_cache, |
|
88 | - 'EEM_Price_Type' => EE_Dependency_Map::load_from_cache, |
|
89 | - ], |
|
90 | - 'EventEspresso\core\domain\services\admin\entities\DefaultFormSections' => [ |
|
91 | - 'EEM_Form_Element' => EE_Dependency_Map::load_from_cache, |
|
92 | - 'EEM_Form_Section' => EE_Dependency_Map::load_from_cache, |
|
93 | - ], |
|
94 | - 'EventEspresso\core\domain\entities\routing\data_nodes\domains\EventEditor' => [ |
|
95 | - 'EventEspresso\core\domain\services\admin\events\editor\EventEditorGraphQLData' => EE_Dependency_Map::load_from_cache, |
|
96 | - 'EventEspresso\core\services\json\JsonDataNodeValidator' => EE_Dependency_Map::load_from_cache, |
|
97 | - ], |
|
98 | - 'EventEspresso\core\domain\services\assets\EventEditorAssetManager' => [ |
|
99 | - 'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache, |
|
100 | - 'EventEspresso\core\services\assets\AssetCollection' => EE_Dependency_Map::load_from_cache, |
|
101 | - 'EventEspresso\core\services\assets\Registry' => EE_Dependency_Map::load_from_cache, |
|
102 | - ], |
|
103 | - 'EventEspresso\core\domain\services\admin\events\editor\EventManagerData' => [ |
|
104 | - 'EventEspresso\core\domain\entities\users\EventManagers' => EE_Dependency_Map::load_from_cache, |
|
105 | - 'EventEspresso\core\domain\services\graphql\Utilities' => EE_Dependency_Map::load_from_cache, |
|
106 | - ], |
|
107 | - ]; |
|
108 | - foreach ($editor_dependencies as $dependency => $dependencies) { |
|
109 | - $this->dependency_map->registerDependencies($dependency, $dependencies); |
|
110 | - } |
|
111 | - } |
|
38 | + /** |
|
39 | + * @since $VID:$ |
|
40 | + */ |
|
41 | + protected function registerDependencies() |
|
42 | + { |
|
43 | + $editor_dependencies = [ |
|
44 | + 'EventEspresso\core\domain\services\admin\events\editor\EventEditorGraphQLData' => [ |
|
45 | + 'EventEspresso\core\domain\entities\admin\GraphQLData\Datetimes' => EE_Dependency_Map::load_from_cache, |
|
46 | + 'EventEspresso\core\domain\entities\admin\GraphQLData\Event' => EE_Dependency_Map::load_from_cache, |
|
47 | + 'EventEspresso\core\domain\entities\admin\GraphQLData\Prices' => EE_Dependency_Map::load_from_cache, |
|
48 | + 'EventEspresso\core\domain\entities\admin\GraphQLData\PriceTypes' => EE_Dependency_Map::load_from_cache, |
|
49 | + 'EventEspresso\core\domain\entities\admin\GraphQLData\Tickets' => EE_Dependency_Map::load_from_cache, |
|
50 | + 'EventEspresso\core\domain\services\admin\events\editor\NewEventDefaultEntities' => EE_Dependency_Map::load_from_cache, |
|
51 | + '\EventEspresso\core\domain\services\admin\events\editor\EventManagerData' => EE_Dependency_Map::load_from_cache, |
|
52 | + 'EventEspresso\core\domain\services\admin\events\editor\EventEntityRelations' => EE_Dependency_Map::load_from_cache, |
|
53 | + 'EventEspresso\core\domain\services\admin\events\editor\TicketMeta' => EE_Dependency_Map::load_from_cache, |
|
54 | + 'EventEspresso\core\domain\services\admin\events\editor\FormBuilder' => EE_Dependency_Map::load_from_cache, |
|
55 | + 'EventEspresso\core\domain\entities\admin\GraphQLData\Venues' => EE_Dependency_Map::load_from_cache, |
|
56 | + ], |
|
57 | + 'EventEspresso\core\domain\services\admin\events\editor\EventEntityRelations' => [ |
|
58 | + 'EEM_Datetime' => EE_Dependency_Map::load_from_cache, |
|
59 | + 'EEM_Event' => EE_Dependency_Map::load_from_cache, |
|
60 | + 'EEM_Price' => EE_Dependency_Map::load_from_cache, |
|
61 | + 'EEM_Price_Type' => EE_Dependency_Map::load_from_cache, |
|
62 | + 'EEM_Ticket' => EE_Dependency_Map::load_from_cache, |
|
63 | + 'EventEspresso\core\domain\services\graphql\Utilities' => EE_Dependency_Map::load_from_cache, |
|
64 | + ], |
|
65 | + 'EventEspresso\core\domain\services\admin\events\editor\NewEventDefaultEntities' => [ |
|
66 | + 'EventEspresso\core\domain\services\admin\entities\DefaultDatetimes' => EE_Dependency_Map::load_from_cache, |
|
67 | + 'EventEspresso\core\domain\services\admin\entities\DefaultFormSections' => EE_Dependency_Map::load_from_cache, |
|
68 | + 'EEM_Datetime' => EE_Dependency_Map::load_from_cache, |
|
69 | + 'EEM_Event' => EE_Dependency_Map::load_from_cache, |
|
70 | + 'EEM_Price' => EE_Dependency_Map::load_from_cache, |
|
71 | + 'EEM_Price_Type' => EE_Dependency_Map::load_from_cache, |
|
72 | + 'EEM_Ticket' => EE_Dependency_Map::load_from_cache, |
|
73 | + 'EventEspresso\core\domain\services\graphql\Utilities' => EE_Dependency_Map::load_from_cache, |
|
74 | + ], |
|
75 | + 'EventEspresso\core\domain\services\admin\events\editor\TicketMeta' => [ |
|
76 | + 'EEM_Ticket' => EE_Dependency_Map::load_from_cache, |
|
77 | + ], |
|
78 | + 'EventEspresso\core\domain\services\admin\entities\DefaultDatetimes' => [ |
|
79 | + 'EventEspresso\core\domain\services\admin\entities\DefaultTickets' => EE_Dependency_Map::load_from_cache, |
|
80 | + 'EEM_Datetime' => EE_Dependency_Map::load_from_cache, |
|
81 | + ], |
|
82 | + 'EventEspresso\core\domain\services\admin\entities\DefaultTickets' => [ |
|
83 | + 'EventEspresso\core\domain\services\admin\entities\DefaultPrices' => EE_Dependency_Map::load_from_cache, |
|
84 | + 'EEM_Ticket' => EE_Dependency_Map::load_from_cache, |
|
85 | + ], |
|
86 | + 'EventEspresso\core\domain\services\admin\entities\DefaultPrices' => [ |
|
87 | + 'EEM_Price' => EE_Dependency_Map::load_from_cache, |
|
88 | + 'EEM_Price_Type' => EE_Dependency_Map::load_from_cache, |
|
89 | + ], |
|
90 | + 'EventEspresso\core\domain\services\admin\entities\DefaultFormSections' => [ |
|
91 | + 'EEM_Form_Element' => EE_Dependency_Map::load_from_cache, |
|
92 | + 'EEM_Form_Section' => EE_Dependency_Map::load_from_cache, |
|
93 | + ], |
|
94 | + 'EventEspresso\core\domain\entities\routing\data_nodes\domains\EventEditor' => [ |
|
95 | + 'EventEspresso\core\domain\services\admin\events\editor\EventEditorGraphQLData' => EE_Dependency_Map::load_from_cache, |
|
96 | + 'EventEspresso\core\services\json\JsonDataNodeValidator' => EE_Dependency_Map::load_from_cache, |
|
97 | + ], |
|
98 | + 'EventEspresso\core\domain\services\assets\EventEditorAssetManager' => [ |
|
99 | + 'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache, |
|
100 | + 'EventEspresso\core\services\assets\AssetCollection' => EE_Dependency_Map::load_from_cache, |
|
101 | + 'EventEspresso\core\services\assets\Registry' => EE_Dependency_Map::load_from_cache, |
|
102 | + ], |
|
103 | + 'EventEspresso\core\domain\services\admin\events\editor\EventManagerData' => [ |
|
104 | + 'EventEspresso\core\domain\entities\users\EventManagers' => EE_Dependency_Map::load_from_cache, |
|
105 | + 'EventEspresso\core\domain\services\graphql\Utilities' => EE_Dependency_Map::load_from_cache, |
|
106 | + ], |
|
107 | + ]; |
|
108 | + foreach ($editor_dependencies as $dependency => $dependencies) { |
|
109 | + $this->dependency_map->registerDependencies($dependency, $dependencies); |
|
110 | + } |
|
111 | + } |
|
112 | 112 | |
113 | 113 | |
114 | - /** |
|
115 | - * @return string |
|
116 | - */ |
|
117 | - protected function dataNodeClass(): string |
|
118 | - { |
|
119 | - return EventEditor::class; |
|
120 | - } |
|
114 | + /** |
|
115 | + * @return string |
|
116 | + */ |
|
117 | + protected function dataNodeClass(): string |
|
118 | + { |
|
119 | + return EventEditor::class; |
|
120 | + } |
|
121 | 121 | |
122 | 122 | |
123 | - /** |
|
124 | - * implements logic required to run during request |
|
125 | - * |
|
126 | - * @return bool |
|
127 | - * @since $VID:$ |
|
128 | - */ |
|
129 | - protected function requestHandler(): bool |
|
130 | - { |
|
131 | - if (! class_exists('WPGraphQL')) { |
|
132 | - require_once EE_THIRD_PARTY . 'wp-graphql/wp-graphql.php'; |
|
133 | - } |
|
134 | - /** @var GraphQLManager $graphQL_manager */ |
|
135 | - $graphQL_manager = $this->loader->getShared('EventEspresso\core\services\graphql\GraphQLManager'); |
|
136 | - $graphQL_manager->init(); |
|
123 | + /** |
|
124 | + * implements logic required to run during request |
|
125 | + * |
|
126 | + * @return bool |
|
127 | + * @since $VID:$ |
|
128 | + */ |
|
129 | + protected function requestHandler(): bool |
|
130 | + { |
|
131 | + if (! class_exists('WPGraphQL')) { |
|
132 | + require_once EE_THIRD_PARTY . 'wp-graphql/wp-graphql.php'; |
|
133 | + } |
|
134 | + /** @var GraphQLManager $graphQL_manager */ |
|
135 | + $graphQL_manager = $this->loader->getShared('EventEspresso\core\services\graphql\GraphQLManager'); |
|
136 | + $graphQL_manager->init(); |
|
137 | 137 | |
138 | - /** @var EventEditorAssetManager $asset_manager */ |
|
139 | - $asset_manager = $this->loader->getShared( |
|
140 | - 'EventEspresso\core\domain\services\assets\EventEditorAssetManager' |
|
141 | - ); |
|
142 | - add_action('admin_enqueue_scripts', [$asset_manager, 'enqueueEventEditor']); |
|
143 | - return true; |
|
144 | - } |
|
138 | + /** @var EventEditorAssetManager $asset_manager */ |
|
139 | + $asset_manager = $this->loader->getShared( |
|
140 | + 'EventEspresso\core\domain\services\assets\EventEditorAssetManager' |
|
141 | + ); |
|
142 | + add_action('admin_enqueue_scripts', [$asset_manager, 'enqueueEventEditor']); |
|
143 | + return true; |
|
144 | + } |
|
145 | 145 | } |
@@ -22,150 +22,150 @@ |
||
22 | 22 | class EventEditorGraphQLData |
23 | 23 | { |
24 | 24 | |
25 | - /** |
|
26 | - * @var Event |
|
27 | - */ |
|
28 | - protected $event; |
|
29 | - |
|
30 | - /** |
|
31 | - * @var Datetimes |
|
32 | - */ |
|
33 | - protected $datetimes; |
|
34 | - |
|
35 | - /** |
|
36 | - * @var Prices |
|
37 | - */ |
|
38 | - protected $prices; |
|
39 | - |
|
40 | - /** |
|
41 | - * @var PriceTypes |
|
42 | - */ |
|
43 | - protected $price_types; |
|
44 | - |
|
45 | - /** |
|
46 | - * @var Tickets |
|
47 | - */ |
|
48 | - protected $tickets; |
|
49 | - |
|
50 | - /** |
|
51 | - * @var EventEntityRelations |
|
52 | - */ |
|
53 | - protected $relations; |
|
54 | - |
|
55 | - /** |
|
56 | - * @var EventManagerData |
|
57 | - */ |
|
58 | - protected $managers; |
|
59 | - |
|
60 | - /** |
|
61 | - * @var NewEventDefaultEntities |
|
62 | - */ |
|
63 | - protected $default_entities; |
|
64 | - |
|
65 | - /** |
|
66 | - * @var TicketMeta |
|
67 | - */ |
|
68 | - protected $ticket_meta; |
|
69 | - |
|
70 | - /** |
|
71 | - * @var FormBuilder |
|
72 | - */ |
|
73 | - protected $form_builder; |
|
74 | - |
|
75 | - /** |
|
76 | - * @var Venues |
|
77 | - */ |
|
78 | - protected $venues; |
|
79 | - |
|
80 | - |
|
81 | - /** |
|
82 | - * EventEditorGraphQLData constructor. |
|
83 | - * |
|
84 | - * @param Datetimes $datetimes |
|
85 | - * @param Event $event |
|
86 | - * @param Prices $prices |
|
87 | - * @param PriceTypes $price_types |
|
88 | - * @param Tickets $tickets |
|
89 | - * @param EventEntityRelations $relations |
|
90 | - * @param EventManagerData $managers |
|
91 | - * @param NewEventDefaultEntities $default_entities |
|
92 | - * @param TicketMeta $ticket_meta |
|
93 | - * @param FormBuilder $form_builder |
|
94 | - * @param Venues $venues |
|
95 | - */ |
|
96 | - public function __construct( |
|
97 | - Datetimes $datetimes, |
|
98 | - Event $event, |
|
99 | - Prices $prices, |
|
100 | - PriceTypes $price_types, |
|
101 | - Tickets $tickets, |
|
102 | - EventEntityRelations $relations, |
|
103 | - EventManagerData $managers, |
|
104 | - NewEventDefaultEntities $default_entities, |
|
105 | - TicketMeta $ticket_meta, |
|
106 | - FormBuilder $form_builder, |
|
107 | - Venues $venues |
|
108 | - ) { |
|
109 | - $this->datetimes = $datetimes; |
|
110 | - $this->event = $event; |
|
111 | - $this->default_entities = $default_entities; |
|
112 | - $this->prices = $prices; |
|
113 | - $this->price_types = $price_types; |
|
114 | - $this->managers = $managers; |
|
115 | - $this->relations = $relations; |
|
116 | - $this->tickets = $tickets; |
|
117 | - $this->ticket_meta = $ticket_meta; |
|
118 | - $this->form_builder = $form_builder; |
|
119 | - $this->venues = $venues; |
|
120 | - } |
|
121 | - |
|
122 | - |
|
123 | - /** |
|
124 | - * @param int $eventId |
|
125 | - * @return array |
|
126 | - * @throws EE_Error |
|
127 | - * @throws ReflectionException |
|
128 | - * @since $VID:$ |
|
129 | - */ |
|
130 | - public function getData(int $eventId) |
|
131 | - { |
|
132 | - $this->default_entities->getData($eventId); |
|
133 | - $event = $this->event->getData(['id' => $eventId]); |
|
134 | - $datetimes = $this->datetimes->getData(['eventId' => $eventId]); |
|
135 | - $eventManagers = $this->managers ->getData($eventId); |
|
136 | - |
|
137 | - $tickets = $this->tickets->getData([ |
|
138 | - 'eventId' => $eventId, |
|
139 | - 'includeDefaultTickets' => true, |
|
140 | - ]); |
|
141 | - |
|
142 | - $prices = $this->prices->getData([ |
|
143 | - 'eventId' => $eventId, |
|
144 | - 'includeDefaultTicketsPrices' => true, |
|
145 | - 'includeDefaultPrices' => true, |
|
146 | - ]); |
|
147 | - |
|
148 | - $priceTypes = $this->price_types->getData(); |
|
149 | - |
|
150 | - $relations = $this->relations->getData($eventId); |
|
151 | - |
|
152 | - $ticketMeta = $this->ticket_meta->getData($eventId); |
|
153 | - |
|
154 | - $formBuilder = $this->form_builder->getData($eventId); |
|
155 | - |
|
156 | - $venues = $this->venues->getData(); |
|
157 | - |
|
158 | - return compact( |
|
159 | - 'datetimes', |
|
160 | - 'event', |
|
161 | - 'eventManagers', |
|
162 | - 'formBuilder', |
|
163 | - 'prices', |
|
164 | - 'priceTypes', |
|
165 | - 'relations', |
|
166 | - 'tickets', |
|
167 | - 'ticketMeta', |
|
168 | - 'venues' |
|
169 | - ); |
|
170 | - } |
|
25 | + /** |
|
26 | + * @var Event |
|
27 | + */ |
|
28 | + protected $event; |
|
29 | + |
|
30 | + /** |
|
31 | + * @var Datetimes |
|
32 | + */ |
|
33 | + protected $datetimes; |
|
34 | + |
|
35 | + /** |
|
36 | + * @var Prices |
|
37 | + */ |
|
38 | + protected $prices; |
|
39 | + |
|
40 | + /** |
|
41 | + * @var PriceTypes |
|
42 | + */ |
|
43 | + protected $price_types; |
|
44 | + |
|
45 | + /** |
|
46 | + * @var Tickets |
|
47 | + */ |
|
48 | + protected $tickets; |
|
49 | + |
|
50 | + /** |
|
51 | + * @var EventEntityRelations |
|
52 | + */ |
|
53 | + protected $relations; |
|
54 | + |
|
55 | + /** |
|
56 | + * @var EventManagerData |
|
57 | + */ |
|
58 | + protected $managers; |
|
59 | + |
|
60 | + /** |
|
61 | + * @var NewEventDefaultEntities |
|
62 | + */ |
|
63 | + protected $default_entities; |
|
64 | + |
|
65 | + /** |
|
66 | + * @var TicketMeta |
|
67 | + */ |
|
68 | + protected $ticket_meta; |
|
69 | + |
|
70 | + /** |
|
71 | + * @var FormBuilder |
|
72 | + */ |
|
73 | + protected $form_builder; |
|
74 | + |
|
75 | + /** |
|
76 | + * @var Venues |
|
77 | + */ |
|
78 | + protected $venues; |
|
79 | + |
|
80 | + |
|
81 | + /** |
|
82 | + * EventEditorGraphQLData constructor. |
|
83 | + * |
|
84 | + * @param Datetimes $datetimes |
|
85 | + * @param Event $event |
|
86 | + * @param Prices $prices |
|
87 | + * @param PriceTypes $price_types |
|
88 | + * @param Tickets $tickets |
|
89 | + * @param EventEntityRelations $relations |
|
90 | + * @param EventManagerData $managers |
|
91 | + * @param NewEventDefaultEntities $default_entities |
|
92 | + * @param TicketMeta $ticket_meta |
|
93 | + * @param FormBuilder $form_builder |
|
94 | + * @param Venues $venues |
|
95 | + */ |
|
96 | + public function __construct( |
|
97 | + Datetimes $datetimes, |
|
98 | + Event $event, |
|
99 | + Prices $prices, |
|
100 | + PriceTypes $price_types, |
|
101 | + Tickets $tickets, |
|
102 | + EventEntityRelations $relations, |
|
103 | + EventManagerData $managers, |
|
104 | + NewEventDefaultEntities $default_entities, |
|
105 | + TicketMeta $ticket_meta, |
|
106 | + FormBuilder $form_builder, |
|
107 | + Venues $venues |
|
108 | + ) { |
|
109 | + $this->datetimes = $datetimes; |
|
110 | + $this->event = $event; |
|
111 | + $this->default_entities = $default_entities; |
|
112 | + $this->prices = $prices; |
|
113 | + $this->price_types = $price_types; |
|
114 | + $this->managers = $managers; |
|
115 | + $this->relations = $relations; |
|
116 | + $this->tickets = $tickets; |
|
117 | + $this->ticket_meta = $ticket_meta; |
|
118 | + $this->form_builder = $form_builder; |
|
119 | + $this->venues = $venues; |
|
120 | + } |
|
121 | + |
|
122 | + |
|
123 | + /** |
|
124 | + * @param int $eventId |
|
125 | + * @return array |
|
126 | + * @throws EE_Error |
|
127 | + * @throws ReflectionException |
|
128 | + * @since $VID:$ |
|
129 | + */ |
|
130 | + public function getData(int $eventId) |
|
131 | + { |
|
132 | + $this->default_entities->getData($eventId); |
|
133 | + $event = $this->event->getData(['id' => $eventId]); |
|
134 | + $datetimes = $this->datetimes->getData(['eventId' => $eventId]); |
|
135 | + $eventManagers = $this->managers ->getData($eventId); |
|
136 | + |
|
137 | + $tickets = $this->tickets->getData([ |
|
138 | + 'eventId' => $eventId, |
|
139 | + 'includeDefaultTickets' => true, |
|
140 | + ]); |
|
141 | + |
|
142 | + $prices = $this->prices->getData([ |
|
143 | + 'eventId' => $eventId, |
|
144 | + 'includeDefaultTicketsPrices' => true, |
|
145 | + 'includeDefaultPrices' => true, |
|
146 | + ]); |
|
147 | + |
|
148 | + $priceTypes = $this->price_types->getData(); |
|
149 | + |
|
150 | + $relations = $this->relations->getData($eventId); |
|
151 | + |
|
152 | + $ticketMeta = $this->ticket_meta->getData($eventId); |
|
153 | + |
|
154 | + $formBuilder = $this->form_builder->getData($eventId); |
|
155 | + |
|
156 | + $venues = $this->venues->getData(); |
|
157 | + |
|
158 | + return compact( |
|
159 | + 'datetimes', |
|
160 | + 'event', |
|
161 | + 'eventManagers', |
|
162 | + 'formBuilder', |
|
163 | + 'prices', |
|
164 | + 'priceTypes', |
|
165 | + 'relations', |
|
166 | + 'tickets', |
|
167 | + 'ticketMeta', |
|
168 | + 'venues' |
|
169 | + ); |
|
170 | + } |
|
171 | 171 | } |
@@ -44,11 +44,11 @@ discard block |
||
44 | 44 | $args['EVT_external_URL'] = sanitize_text_field($input['altRegPage']); |
45 | 45 | } |
46 | 46 | |
47 | - if (! empty($input['defaultRegStatus'])) { |
|
47 | + if ( ! empty($input['defaultRegStatus'])) { |
|
48 | 48 | $args['EVT_default_registration_status'] = sanitize_text_field($input['defaultRegStatus']); |
49 | 49 | } |
50 | 50 | |
51 | - if (! empty($input['description'])) { |
|
51 | + if ( ! empty($input['description'])) { |
|
52 | 52 | $args['EVT_desc'] = sanitize_post_field('post_content', $input['description'], null, 'db'); |
53 | 53 | } |
54 | 54 | |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | $args['EVT_display_ticket_selector'] = filter_var($input['displayTicketSelector'], FILTER_VALIDATE_BOOLEAN); |
61 | 61 | } |
62 | 62 | |
63 | - if (! empty($input['maxRegistrations'])) { |
|
63 | + if ( ! empty($input['maxRegistrations'])) { |
|
64 | 64 | $args['EVT_additional_limit'] = absint($input['maxRegistrations']); |
65 | 65 | } |
66 | 66 | |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | $args['EVT_member_only'] = filter_var($input['memberOnly'], FILTER_VALIDATE_BOOLEAN); |
69 | 69 | } |
70 | 70 | |
71 | - if (! empty($input['name'])) { |
|
71 | + if ( ! empty($input['name'])) { |
|
72 | 72 | $args['EVT_name'] = sanitize_text_field($input['name']); |
73 | 73 | } |
74 | 74 | |
@@ -88,11 +88,11 @@ discard block |
||
88 | 88 | $args['EVT_timezone_string'] = sanitize_text_field($input['timezoneString']); |
89 | 89 | } |
90 | 90 | |
91 | - if (! empty($input['visibleOn'])) { |
|
91 | + if ( ! empty($input['visibleOn'])) { |
|
92 | 92 | $args['EVT_visible_on'] = new DateTime(sanitize_text_field($input['visibleOn'])); |
93 | 93 | } |
94 | 94 | |
95 | - if (! empty($input['manager'])) { |
|
95 | + if ( ! empty($input['manager'])) { |
|
96 | 96 | $parts = Relay::fromGlobalId(sanitize_text_field($input['manager'])); |
97 | 97 | $args['EVT_wp_user'] = ! empty($parts['id']) ? $parts['id'] : null; |
98 | 98 | } |
@@ -21,113 +21,113 @@ |
||
21 | 21 | class EventMutation |
22 | 22 | { |
23 | 23 | |
24 | - /** |
|
25 | - * Maps the GraphQL input to a format that the model functions can use |
|
26 | - * |
|
27 | - * @param array $input Data coming from the GraphQL mutation query input |
|
28 | - * @return array |
|
29 | - * @throws Exception |
|
30 | - */ |
|
31 | - public static function prepareFields(array $input): array |
|
32 | - { |
|
33 | - $args = []; |
|
34 | - |
|
35 | - if (array_key_exists('allowDonations', $input)) { |
|
36 | - $args['EVT_donations'] = filter_var($input['allowDonations'], FILTER_VALIDATE_BOOLEAN); |
|
37 | - } |
|
38 | - |
|
39 | - if (array_key_exists('allowOverflow', $input)) { |
|
40 | - $args['EVT_allow_overflow'] = filter_var($input['allowOverflow'], FILTER_VALIDATE_BOOLEAN); |
|
41 | - } |
|
42 | - |
|
43 | - if (array_key_exists('altRegPage', $input)) { |
|
44 | - $args['EVT_external_URL'] = sanitize_text_field($input['altRegPage']); |
|
45 | - } |
|
46 | - |
|
47 | - if (! empty($input['defaultRegStatus'])) { |
|
48 | - $args['EVT_default_registration_status'] = sanitize_text_field($input['defaultRegStatus']); |
|
49 | - } |
|
50 | - |
|
51 | - if (! empty($input['description'])) { |
|
52 | - $args['EVT_desc'] = sanitize_post_field('post_content', $input['description'], null, 'db'); |
|
53 | - } |
|
54 | - |
|
55 | - if (array_key_exists('displayDescription', $input)) { |
|
56 | - $args['EVT_display_desc'] = filter_var($input['displayDescription'], FILTER_VALIDATE_BOOLEAN); |
|
57 | - } |
|
58 | - |
|
59 | - if (array_key_exists('displayTicketSelector', $input)) { |
|
60 | - $args['EVT_display_ticket_selector'] = filter_var($input['displayTicketSelector'], FILTER_VALIDATE_BOOLEAN); |
|
61 | - } |
|
62 | - |
|
63 | - if (! empty($input['maxRegistrations'])) { |
|
64 | - $args['EVT_additional_limit'] = absint($input['maxRegistrations']); |
|
65 | - } |
|
66 | - |
|
67 | - if (array_key_exists('memberOnly', $input)) { |
|
68 | - $args['EVT_member_only'] = filter_var($input['memberOnly'], FILTER_VALIDATE_BOOLEAN); |
|
69 | - } |
|
70 | - |
|
71 | - if (! empty($input['name'])) { |
|
72 | - $args['EVT_name'] = sanitize_text_field($input['name']); |
|
73 | - } |
|
74 | - |
|
75 | - if (array_key_exists('order', $input)) { |
|
76 | - $args['EVT_order'] = absint($input['order']); |
|
77 | - } |
|
78 | - |
|
79 | - if (array_key_exists('phoneNumber', $input)) { |
|
80 | - $args['EVT_phone'] = sanitize_text_field($input['phoneNumber']); |
|
81 | - } |
|
82 | - |
|
83 | - if (array_key_exists('shortDescription', $input)) { |
|
84 | - $args['EVT_short_desc'] = sanitize_post_field('post_excerpt', $input['shortDescription'], null, 'db'); |
|
85 | - } |
|
86 | - |
|
87 | - if (array_key_exists('timezoneString', $input)) { |
|
88 | - $args['EVT_timezone_string'] = sanitize_text_field($input['timezoneString']); |
|
89 | - } |
|
90 | - |
|
91 | - if (! empty($input['visibleOn'])) { |
|
92 | - $args['EVT_visible_on'] = new DateTime(sanitize_text_field($input['visibleOn'])); |
|
93 | - } |
|
94 | - |
|
95 | - if (! empty($input['manager'])) { |
|
96 | - $parts = Relay::fromGlobalId(sanitize_text_field($input['manager'])); |
|
97 | - $args['EVT_wp_user'] = ! empty($parts['id']) ? $parts['id'] : null; |
|
98 | - } |
|
99 | - |
|
100 | - if (array_key_exists('venue', $input)) { |
|
101 | - $venue_id = sanitize_text_field($input['venue']); |
|
102 | - $parts = Relay::fromGlobalId($venue_id); |
|
103 | - $args['venue'] = ! empty($parts['id']) ? $parts['id'] : $venue_id; |
|
104 | - } |
|
105 | - |
|
106 | - return apply_filters( |
|
107 | - 'FHEE__EventEspresso_core_domain_services_graphql_data_mutations__event_args', |
|
108 | - $args, |
|
109 | - $input |
|
110 | - ); |
|
111 | - } |
|
112 | - |
|
113 | - |
|
114 | - /** |
|
115 | - * Sets the venue for the event. |
|
116 | - * |
|
117 | - * @param EE_Event $entity The event instance. |
|
118 | - * @param int $venue The venue ID |
|
119 | - * @throws EE_Error |
|
120 | - * @throws InvalidDataTypeException |
|
121 | - * @throws InvalidInterfaceException |
|
122 | - * @throws InvalidArgumentException |
|
123 | - * @throws ReflectionException |
|
124 | - */ |
|
125 | - public static function setEventVenue(EE_Event $entity, int $venue) |
|
126 | - { |
|
127 | - if (empty($venue)) { |
|
128 | - $entity->remove_venue($venue); |
|
129 | - } else { |
|
130 | - $entity->add_venue($venue); |
|
131 | - } |
|
132 | - } |
|
24 | + /** |
|
25 | + * Maps the GraphQL input to a format that the model functions can use |
|
26 | + * |
|
27 | + * @param array $input Data coming from the GraphQL mutation query input |
|
28 | + * @return array |
|
29 | + * @throws Exception |
|
30 | + */ |
|
31 | + public static function prepareFields(array $input): array |
|
32 | + { |
|
33 | + $args = []; |
|
34 | + |
|
35 | + if (array_key_exists('allowDonations', $input)) { |
|
36 | + $args['EVT_donations'] = filter_var($input['allowDonations'], FILTER_VALIDATE_BOOLEAN); |
|
37 | + } |
|
38 | + |
|
39 | + if (array_key_exists('allowOverflow', $input)) { |
|
40 | + $args['EVT_allow_overflow'] = filter_var($input['allowOverflow'], FILTER_VALIDATE_BOOLEAN); |
|
41 | + } |
|
42 | + |
|
43 | + if (array_key_exists('altRegPage', $input)) { |
|
44 | + $args['EVT_external_URL'] = sanitize_text_field($input['altRegPage']); |
|
45 | + } |
|
46 | + |
|
47 | + if (! empty($input['defaultRegStatus'])) { |
|
48 | + $args['EVT_default_registration_status'] = sanitize_text_field($input['defaultRegStatus']); |
|
49 | + } |
|
50 | + |
|
51 | + if (! empty($input['description'])) { |
|
52 | + $args['EVT_desc'] = sanitize_post_field('post_content', $input['description'], null, 'db'); |
|
53 | + } |
|
54 | + |
|
55 | + if (array_key_exists('displayDescription', $input)) { |
|
56 | + $args['EVT_display_desc'] = filter_var($input['displayDescription'], FILTER_VALIDATE_BOOLEAN); |
|
57 | + } |
|
58 | + |
|
59 | + if (array_key_exists('displayTicketSelector', $input)) { |
|
60 | + $args['EVT_display_ticket_selector'] = filter_var($input['displayTicketSelector'], FILTER_VALIDATE_BOOLEAN); |
|
61 | + } |
|
62 | + |
|
63 | + if (! empty($input['maxRegistrations'])) { |
|
64 | + $args['EVT_additional_limit'] = absint($input['maxRegistrations']); |
|
65 | + } |
|
66 | + |
|
67 | + if (array_key_exists('memberOnly', $input)) { |
|
68 | + $args['EVT_member_only'] = filter_var($input['memberOnly'], FILTER_VALIDATE_BOOLEAN); |
|
69 | + } |
|
70 | + |
|
71 | + if (! empty($input['name'])) { |
|
72 | + $args['EVT_name'] = sanitize_text_field($input['name']); |
|
73 | + } |
|
74 | + |
|
75 | + if (array_key_exists('order', $input)) { |
|
76 | + $args['EVT_order'] = absint($input['order']); |
|
77 | + } |
|
78 | + |
|
79 | + if (array_key_exists('phoneNumber', $input)) { |
|
80 | + $args['EVT_phone'] = sanitize_text_field($input['phoneNumber']); |
|
81 | + } |
|
82 | + |
|
83 | + if (array_key_exists('shortDescription', $input)) { |
|
84 | + $args['EVT_short_desc'] = sanitize_post_field('post_excerpt', $input['shortDescription'], null, 'db'); |
|
85 | + } |
|
86 | + |
|
87 | + if (array_key_exists('timezoneString', $input)) { |
|
88 | + $args['EVT_timezone_string'] = sanitize_text_field($input['timezoneString']); |
|
89 | + } |
|
90 | + |
|
91 | + if (! empty($input['visibleOn'])) { |
|
92 | + $args['EVT_visible_on'] = new DateTime(sanitize_text_field($input['visibleOn'])); |
|
93 | + } |
|
94 | + |
|
95 | + if (! empty($input['manager'])) { |
|
96 | + $parts = Relay::fromGlobalId(sanitize_text_field($input['manager'])); |
|
97 | + $args['EVT_wp_user'] = ! empty($parts['id']) ? $parts['id'] : null; |
|
98 | + } |
|
99 | + |
|
100 | + if (array_key_exists('venue', $input)) { |
|
101 | + $venue_id = sanitize_text_field($input['venue']); |
|
102 | + $parts = Relay::fromGlobalId($venue_id); |
|
103 | + $args['venue'] = ! empty($parts['id']) ? $parts['id'] : $venue_id; |
|
104 | + } |
|
105 | + |
|
106 | + return apply_filters( |
|
107 | + 'FHEE__EventEspresso_core_domain_services_graphql_data_mutations__event_args', |
|
108 | + $args, |
|
109 | + $input |
|
110 | + ); |
|
111 | + } |
|
112 | + |
|
113 | + |
|
114 | + /** |
|
115 | + * Sets the venue for the event. |
|
116 | + * |
|
117 | + * @param EE_Event $entity The event instance. |
|
118 | + * @param int $venue The venue ID |
|
119 | + * @throws EE_Error |
|
120 | + * @throws InvalidDataTypeException |
|
121 | + * @throws InvalidInterfaceException |
|
122 | + * @throws InvalidArgumentException |
|
123 | + * @throws ReflectionException |
|
124 | + */ |
|
125 | + public static function setEventVenue(EE_Event $entity, int $venue) |
|
126 | + { |
|
127 | + if (empty($venue)) { |
|
128 | + $entity->remove_venue($venue); |
|
129 | + } else { |
|
130 | + $entity->add_venue($venue); |
|
131 | + } |
|
132 | + } |
|
133 | 133 | } |
@@ -15,243 +15,243 @@ |
||
15 | 15 | class Event_Edit_Help_Tour extends EE_Help_Tour |
16 | 16 | { |
17 | 17 | |
18 | - protected function _set_tour_properties() |
|
19 | - { |
|
20 | - $this->_label = __('Event Editor Tour', 'event_espresso'); |
|
21 | - $this->_slug = $this->_is_caf ? 'event-edit-caf-joyride' : 'event-edit-joyride'; |
|
22 | - } |
|
18 | + protected function _set_tour_properties() |
|
19 | + { |
|
20 | + $this->_label = __('Event Editor Tour', 'event_espresso'); |
|
21 | + $this->_slug = $this->_is_caf ? 'event-edit-caf-joyride' : 'event-edit-joyride'; |
|
22 | + } |
|
23 | 23 | |
24 | - protected function _set_tour_stops() |
|
25 | - { |
|
26 | - $this->_stops = array( |
|
27 | - 10 => array( |
|
28 | - 'content' => $this->_start(), |
|
29 | - ), |
|
30 | - 20 => array( |
|
31 | - 'id' => 'titlewrap', |
|
32 | - 'content' => $this->_event_title_stop(), |
|
33 | - 'options' => array( |
|
34 | - 'tipLocation' => 'bottom', |
|
35 | - 'tipAdjustmentY' => -40, |
|
36 | - ), |
|
37 | - ), |
|
38 | - 30 => array( |
|
39 | - 'id' => 'wp-content-editor-tools', |
|
40 | - 'content' => $this->_event_description_stop(), |
|
41 | - 'options' => array( |
|
42 | - 'tipLocation' => 'right', |
|
43 | - ), |
|
44 | - ), |
|
45 | - 35 => array( |
|
46 | - 'id' => 'espresso_event_editor_tickets', |
|
47 | - 'content' => $this->_event_pricing_stop(), |
|
48 | - 'options' => array( |
|
49 | - 'tipLocation' => 'top', |
|
50 | - 'tipAdjustmentY' => -30, |
|
51 | - ), |
|
52 | - ), |
|
53 | - 40 => array( |
|
54 | - 'id' => 'espresso_events_Venues_Hooks_venue_metabox_metabox', |
|
55 | - 'content' => $this->_event_venues_caf(), |
|
56 | - 'options' => array( |
|
57 | - 'tipLocation' => 'top', |
|
58 | - 'tipAdjustmentY' => -30, |
|
59 | - ), |
|
60 | - ), |
|
61 | - 45 => array( |
|
62 | - 'id' => 'espresso_event_editor_venue', |
|
63 | - 'content' => $this->_event_venues_stop(), |
|
64 | - 'options' => array( |
|
65 | - 'tipLocation' => 'top', |
|
66 | - 'tipAdjustmentY' => -30, |
|
67 | - ), |
|
68 | - ), |
|
69 | - 50 => array( |
|
70 | - 'id' => 'espresso_events_Pricing_Hooks_pricing_metabox_metabox', |
|
71 | - 'content' => $this->_event_pricing_caf(), |
|
72 | - 'options' => array( |
|
73 | - 'tipLocation' => 'top', |
|
74 | - 'tipAdjustmentY' => -30, |
|
75 | - ), |
|
76 | - ), |
|
77 | - 60 => array( |
|
78 | - 'id' => 'tagsdiv-post_tag', |
|
79 | - 'content' => $this->_event_post_tag_stop(), |
|
80 | - 'options' => array( |
|
81 | - 'tipLocation' => 'left', |
|
82 | - ), |
|
83 | - ), |
|
84 | - 70 => array( |
|
85 | - 'id' => 'espresso_event_categoriesdiv', |
|
86 | - 'content' => $this->_event_categories_stop(), |
|
87 | - 'options' => array( |
|
88 | - 'tipLocation' => 'left', |
|
89 | - ), |
|
90 | - ), |
|
24 | + protected function _set_tour_stops() |
|
25 | + { |
|
26 | + $this->_stops = array( |
|
27 | + 10 => array( |
|
28 | + 'content' => $this->_start(), |
|
29 | + ), |
|
30 | + 20 => array( |
|
31 | + 'id' => 'titlewrap', |
|
32 | + 'content' => $this->_event_title_stop(), |
|
33 | + 'options' => array( |
|
34 | + 'tipLocation' => 'bottom', |
|
35 | + 'tipAdjustmentY' => -40, |
|
36 | + ), |
|
37 | + ), |
|
38 | + 30 => array( |
|
39 | + 'id' => 'wp-content-editor-tools', |
|
40 | + 'content' => $this->_event_description_stop(), |
|
41 | + 'options' => array( |
|
42 | + 'tipLocation' => 'right', |
|
43 | + ), |
|
44 | + ), |
|
45 | + 35 => array( |
|
46 | + 'id' => 'espresso_event_editor_tickets', |
|
47 | + 'content' => $this->_event_pricing_stop(), |
|
48 | + 'options' => array( |
|
49 | + 'tipLocation' => 'top', |
|
50 | + 'tipAdjustmentY' => -30, |
|
51 | + ), |
|
52 | + ), |
|
53 | + 40 => array( |
|
54 | + 'id' => 'espresso_events_Venues_Hooks_venue_metabox_metabox', |
|
55 | + 'content' => $this->_event_venues_caf(), |
|
56 | + 'options' => array( |
|
57 | + 'tipLocation' => 'top', |
|
58 | + 'tipAdjustmentY' => -30, |
|
59 | + ), |
|
60 | + ), |
|
61 | + 45 => array( |
|
62 | + 'id' => 'espresso_event_editor_venue', |
|
63 | + 'content' => $this->_event_venues_stop(), |
|
64 | + 'options' => array( |
|
65 | + 'tipLocation' => 'top', |
|
66 | + 'tipAdjustmentY' => -30, |
|
67 | + ), |
|
68 | + ), |
|
69 | + 50 => array( |
|
70 | + 'id' => 'espresso_events_Pricing_Hooks_pricing_metabox_metabox', |
|
71 | + 'content' => $this->_event_pricing_caf(), |
|
72 | + 'options' => array( |
|
73 | + 'tipLocation' => 'top', |
|
74 | + 'tipAdjustmentY' => -30, |
|
75 | + ), |
|
76 | + ), |
|
77 | + 60 => array( |
|
78 | + 'id' => 'tagsdiv-post_tag', |
|
79 | + 'content' => $this->_event_post_tag_stop(), |
|
80 | + 'options' => array( |
|
81 | + 'tipLocation' => 'left', |
|
82 | + ), |
|
83 | + ), |
|
84 | + 70 => array( |
|
85 | + 'id' => 'espresso_event_categoriesdiv', |
|
86 | + 'content' => $this->_event_categories_stop(), |
|
87 | + 'options' => array( |
|
88 | + 'tipLocation' => 'left', |
|
89 | + ), |
|
90 | + ), |
|
91 | 91 | |
92 | - 80 => array( |
|
93 | - 'id' => $this->_is_caf ? 'espresso_events_Registration_Form_Hooks_Extend_primary_questions_metabox' |
|
94 | - : 'espresso_events_Registration_Form_Hooks_primary_questions_metabox', |
|
95 | - 'content' => $this->_primary_question_stop_caf(), |
|
96 | - 'options' => array( |
|
97 | - 'tipLocation' => 'left', |
|
98 | - ), |
|
99 | - ), |
|
100 | - 90 => array( |
|
101 | - 'id' => 'espresso_events_Registration_Form_Hooks_Extend_additional_questions_metabox', |
|
102 | - 'content' => $this->_additional_questions_stop_caf(), |
|
103 | - 'options' => array( |
|
104 | - 'tipLocation' => 'left', |
|
105 | - ), |
|
106 | - ), |
|
107 | - 100 => array( |
|
108 | - 'id' => 'postimagediv', |
|
109 | - 'content' => $this->_featured_image_stop(), |
|
110 | - 'options' => array( |
|
111 | - 'tipLocation' => 'left', |
|
112 | - ), |
|
113 | - ), |
|
114 | - 110 => array( |
|
115 | - 'id' => 'espresso_event_editor_event_options', |
|
116 | - 'content' => $this->_event_registration_options_stop(), |
|
117 | - 'options' => array( |
|
118 | - 'tipLocation' => 'left', |
|
119 | - ), |
|
120 | - ), |
|
121 | - 120 => array( |
|
122 | - 'id' => 'submitpost', |
|
123 | - 'content' => $this->_publish_event_stop(), |
|
124 | - 'options' => array( |
|
125 | - 'tipLocation' => 'left', |
|
126 | - ), |
|
127 | - ), |
|
128 | - ); |
|
92 | + 80 => array( |
|
93 | + 'id' => $this->_is_caf ? 'espresso_events_Registration_Form_Hooks_Extend_primary_questions_metabox' |
|
94 | + : 'espresso_events_Registration_Form_Hooks_primary_questions_metabox', |
|
95 | + 'content' => $this->_primary_question_stop_caf(), |
|
96 | + 'options' => array( |
|
97 | + 'tipLocation' => 'left', |
|
98 | + ), |
|
99 | + ), |
|
100 | + 90 => array( |
|
101 | + 'id' => 'espresso_events_Registration_Form_Hooks_Extend_additional_questions_metabox', |
|
102 | + 'content' => $this->_additional_questions_stop_caf(), |
|
103 | + 'options' => array( |
|
104 | + 'tipLocation' => 'left', |
|
105 | + ), |
|
106 | + ), |
|
107 | + 100 => array( |
|
108 | + 'id' => 'postimagediv', |
|
109 | + 'content' => $this->_featured_image_stop(), |
|
110 | + 'options' => array( |
|
111 | + 'tipLocation' => 'left', |
|
112 | + ), |
|
113 | + ), |
|
114 | + 110 => array( |
|
115 | + 'id' => 'espresso_event_editor_event_options', |
|
116 | + 'content' => $this->_event_registration_options_stop(), |
|
117 | + 'options' => array( |
|
118 | + 'tipLocation' => 'left', |
|
119 | + ), |
|
120 | + ), |
|
121 | + 120 => array( |
|
122 | + 'id' => 'submitpost', |
|
123 | + 'content' => $this->_publish_event_stop(), |
|
124 | + 'options' => array( |
|
125 | + 'tipLocation' => 'left', |
|
126 | + ), |
|
127 | + ), |
|
128 | + ); |
|
129 | 129 | |
130 | - if (EE_Config::instance()->admin->useAdvancedEditor()) { |
|
131 | - unset( |
|
132 | - // description |
|
133 | - $this->_stops[30], |
|
134 | - // tickets |
|
135 | - $this->_stops[35], |
|
136 | - // venues |
|
137 | - $this->_stops[40], |
|
138 | - $this->_stops[45], |
|
139 | - // pricing |
|
140 | - $this->_stops[50], |
|
141 | - // questions |
|
142 | - $this->_stops[90], |
|
143 | - // reg options |
|
144 | - $this->_stops[110] |
|
145 | - ); |
|
146 | - } |
|
147 | - } |
|
130 | + if (EE_Config::instance()->admin->useAdvancedEditor()) { |
|
131 | + unset( |
|
132 | + // description |
|
133 | + $this->_stops[30], |
|
134 | + // tickets |
|
135 | + $this->_stops[35], |
|
136 | + // venues |
|
137 | + $this->_stops[40], |
|
138 | + $this->_stops[45], |
|
139 | + // pricing |
|
140 | + $this->_stops[50], |
|
141 | + // questions |
|
142 | + $this->_stops[90], |
|
143 | + // reg options |
|
144 | + $this->_stops[110] |
|
145 | + ); |
|
146 | + } |
|
147 | + } |
|
148 | 148 | |
149 | 149 | |
150 | - protected function _start() |
|
151 | - { |
|
152 | - $content = '<h3>' . __('Event Editor', 'event_espresso') . '</h3>'; |
|
153 | - $content .= '<p>' |
|
154 | - . __( |
|
155 | - 'This tour of the Event Editor will provide an overview of the different areas of the screen to help you understand what they are used for. Let\'s get started on setting up your first event with Event Espresso!', |
|
156 | - 'event_espresso' |
|
157 | - ) . '</p>'; |
|
158 | - return $content; |
|
159 | - } |
|
150 | + protected function _start() |
|
151 | + { |
|
152 | + $content = '<h3>' . __('Event Editor', 'event_espresso') . '</h3>'; |
|
153 | + $content .= '<p>' |
|
154 | + . __( |
|
155 | + 'This tour of the Event Editor will provide an overview of the different areas of the screen to help you understand what they are used for. Let\'s get started on setting up your first event with Event Espresso!', |
|
156 | + 'event_espresso' |
|
157 | + ) . '</p>'; |
|
158 | + return $content; |
|
159 | + } |
|
160 | 160 | |
161 | - protected function _event_title_stop() |
|
162 | - { |
|
163 | - return '<p>Enter the title for your event in this field.</p>'; |
|
164 | - } |
|
161 | + protected function _event_title_stop() |
|
162 | + { |
|
163 | + return '<p>Enter the title for your event in this field.</p>'; |
|
164 | + } |
|
165 | 165 | |
166 | - protected function _event_description_stop() |
|
167 | - { |
|
168 | - return '<p>' |
|
169 | - . __( |
|
170 | - 'The rich text editor can be used to add information about your event. Images and links can also be added along with your text.', |
|
171 | - 'event_espresso' |
|
172 | - ) . '</p>'; |
|
173 | - } |
|
166 | + protected function _event_description_stop() |
|
167 | + { |
|
168 | + return '<p>' |
|
169 | + . __( |
|
170 | + 'The rich text editor can be used to add information about your event. Images and links can also be added along with your text.', |
|
171 | + 'event_espresso' |
|
172 | + ) . '</p>'; |
|
173 | + } |
|
174 | 174 | |
175 | - protected function _event_venues_caf() |
|
176 | - { |
|
177 | - return '<p>' |
|
178 | - . __( |
|
179 | - 'In this section, you can select the venue that is hosting your event.', |
|
180 | - 'event_espresso' |
|
181 | - ) . '</p>'; |
|
182 | - } |
|
175 | + protected function _event_venues_caf() |
|
176 | + { |
|
177 | + return '<p>' |
|
178 | + . __( |
|
179 | + 'In this section, you can select the venue that is hosting your event.', |
|
180 | + 'event_espresso' |
|
181 | + ) . '</p>'; |
|
182 | + } |
|
183 | 183 | |
184 | - protected function _event_venues_stop() |
|
185 | - { |
|
186 | - return '<p>' |
|
187 | - . __( |
|
188 | - 'In this section, you can enter information about the venue that is hosting your event.', |
|
189 | - 'event_espresso' |
|
190 | - ) . '</p>'; |
|
191 | - } |
|
184 | + protected function _event_venues_stop() |
|
185 | + { |
|
186 | + return '<p>' |
|
187 | + . __( |
|
188 | + 'In this section, you can enter information about the venue that is hosting your event.', |
|
189 | + 'event_espresso' |
|
190 | + ) . '</p>'; |
|
191 | + } |
|
192 | 192 | |
193 | - protected function _event_pricing_stop() |
|
194 | - { |
|
195 | - return '<p>' |
|
196 | - . __( |
|
197 | - 'Use the Event Datetime & Ticket section to enter details about when the event is happening and what tickets you want to offer for access to the event.', |
|
198 | - 'event_espresso' |
|
199 | - ) . '</p>'; |
|
200 | - } |
|
193 | + protected function _event_pricing_stop() |
|
194 | + { |
|
195 | + return '<p>' |
|
196 | + . __( |
|
197 | + 'Use the Event Datetime & Ticket section to enter details about when the event is happening and what tickets you want to offer for access to the event.', |
|
198 | + 'event_espresso' |
|
199 | + ) . '</p>'; |
|
200 | + } |
|
201 | 201 | |
202 | - protected function _event_pricing_caf() |
|
203 | - { |
|
204 | - return '<p>' |
|
205 | - . __( |
|
206 | - 'Use the Event Datetimes & Ticket section to enter details about when the event is happening and what tickets you want to offer for access to the event.', |
|
207 | - 'event_espresso' |
|
208 | - ) . '</p>'; |
|
209 | - } |
|
202 | + protected function _event_pricing_caf() |
|
203 | + { |
|
204 | + return '<p>' |
|
205 | + . __( |
|
206 | + 'Use the Event Datetimes & Ticket section to enter details about when the event is happening and what tickets you want to offer for access to the event.', |
|
207 | + 'event_espresso' |
|
208 | + ) . '</p>'; |
|
209 | + } |
|
210 | 210 | |
211 | - protected function _event_registration_options_stop() |
|
212 | - { |
|
213 | - return '<p>' . __('Setup custom options for your event registration.', 'event_espresso') . '</p>'; |
|
214 | - } |
|
211 | + protected function _event_registration_options_stop() |
|
212 | + { |
|
213 | + return '<p>' . __('Setup custom options for your event registration.', 'event_espresso') . '</p>'; |
|
214 | + } |
|
215 | 215 | |
216 | - protected function _event_post_tag_stop() |
|
217 | - { |
|
218 | - return '<p>' . __('Quickly add tags to your event.', 'event_espresso') . '</p>'; |
|
219 | - } |
|
216 | + protected function _event_post_tag_stop() |
|
217 | + { |
|
218 | + return '<p>' . __('Quickly add tags to your event.', 'event_espresso') . '</p>'; |
|
219 | + } |
|
220 | 220 | |
221 | - protected function _event_categories_stop() |
|
222 | - { |
|
223 | - return '<p>' . __('Events can also be categorized if you wish.', 'event_espresso') . '</p>'; |
|
224 | - } |
|
221 | + protected function _event_categories_stop() |
|
222 | + { |
|
223 | + return '<p>' . __('Events can also be categorized if you wish.', 'event_espresso') . '</p>'; |
|
224 | + } |
|
225 | 225 | |
226 | - protected function _primary_question_stop_caf() |
|
227 | - { |
|
228 | - return '<p>' |
|
229 | - . __( |
|
230 | - 'Use the questions group to request information from your primary registrant.', |
|
231 | - 'event_espresso' |
|
232 | - ) . '</p>'; |
|
233 | - } |
|
226 | + protected function _primary_question_stop_caf() |
|
227 | + { |
|
228 | + return '<p>' |
|
229 | + . __( |
|
230 | + 'Use the questions group to request information from your primary registrant.', |
|
231 | + 'event_espresso' |
|
232 | + ) . '</p>'; |
|
233 | + } |
|
234 | 234 | |
235 | - protected function _additional_questions_stop_caf() |
|
236 | - { |
|
237 | - return '<p>' |
|
238 | - . __( |
|
239 | - 'Use the questions group to request information from your additional registrant.', |
|
240 | - 'event_espresso' |
|
241 | - ) . '</p>'; |
|
242 | - } |
|
235 | + protected function _additional_questions_stop_caf() |
|
236 | + { |
|
237 | + return '<p>' |
|
238 | + . __( |
|
239 | + 'Use the questions group to request information from your additional registrant.', |
|
240 | + 'event_espresso' |
|
241 | + ) . '</p>'; |
|
242 | + } |
|
243 | 243 | |
244 | - protected function _featured_image_stop() |
|
245 | - { |
|
246 | - return '<p>' . __('Set a feature image for your event here.', 'event_espresso') . '</p>'; |
|
247 | - } |
|
244 | + protected function _featured_image_stop() |
|
245 | + { |
|
246 | + return '<p>' . __('Set a feature image for your event here.', 'event_espresso') . '</p>'; |
|
247 | + } |
|
248 | 248 | |
249 | - protected function _publish_event_stop() |
|
250 | - { |
|
251 | - return '<p>' |
|
252 | - . __( |
|
253 | - 'Easily control the state of your event. The main states are Published, Pending Review, and Draft. Additional states are Cancelled, Postponed, and Sold Out.', |
|
254 | - 'event_espresso' |
|
255 | - ) . '</p>'; |
|
256 | - } |
|
249 | + protected function _publish_event_stop() |
|
250 | + { |
|
251 | + return '<p>' |
|
252 | + . __( |
|
253 | + 'Easily control the state of your event. The main states are Published, Pending Review, and Draft. Additional states are Cancelled, Postponed, and Sold Out.', |
|
254 | + 'event_espresso' |
|
255 | + ) . '</p>'; |
|
256 | + } |
|
257 | 257 | } |
@@ -15,216 +15,216 @@ |
||
15 | 15 | class espresso_events_Venues_Hooks extends EE_Admin_Hooks |
16 | 16 | { |
17 | 17 | |
18 | - /** |
|
19 | - * @var EE_Event |
|
20 | - */ |
|
21 | - protected $_event; |
|
22 | - |
|
23 | - |
|
24 | - public function __construct(EE_Admin_Page $admin_page) |
|
25 | - { |
|
26 | - parent::__construct($admin_page); |
|
27 | - } |
|
28 | - |
|
29 | - |
|
30 | - protected function _set_hooks_properties() |
|
31 | - { |
|
32 | - |
|
33 | - $this->_name = 'venues'; |
|
34 | - |
|
35 | - if (EE_Config::instance()->admin->useAdvancedEditor()) { |
|
36 | - $this->_metaboxes = []; |
|
37 | - $this->_scripts_styles = []; |
|
38 | - return; |
|
39 | - } |
|
40 | - $this->_metaboxes = array( |
|
41 | - 0 => array( |
|
42 | - 'page_route' => array('edit', 'create_new'), |
|
43 | - 'func' => 'venue_metabox', |
|
44 | - 'label' => __('Venue Details', 'event_espresso'), |
|
45 | - 'priority' => 'high', |
|
46 | - 'context' => 'normal', |
|
47 | - ), |
|
48 | - ); |
|
49 | - |
|
50 | - $this->_scripts_styles = array( |
|
51 | - 'registers' => array( |
|
52 | - 'ee_event_venues' => array( |
|
53 | - 'type' => 'js', |
|
54 | - 'url' => EE_VENUES_ASSETS_URL . 'ee-event-venues-admin.js', |
|
55 | - 'depends' => array('jquery'), |
|
56 | - ), |
|
57 | - 'ee_event_venues_css' => array( |
|
58 | - 'type' => 'css', |
|
59 | - 'url' => EE_VENUES_ASSETS_URL . 'ee-event-venues-admin.css', |
|
60 | - ), |
|
61 | - ), |
|
62 | - 'enqueues' => array( |
|
63 | - 'ee_event_venues' => array('edit', 'create_new'), |
|
64 | - 'ee_event_venues_css' => array('edit', 'create_new'), |
|
65 | - ), |
|
66 | - ); |
|
67 | - |
|
68 | - // hook into the handler for saving venue |
|
69 | - add_filter( |
|
70 | - 'FHEE__Events_Admin_Page___insert_update_cpt_item__event_update_callbacks', |
|
71 | - array($this, 'modify_callbacks'), |
|
72 | - 10 |
|
73 | - ); |
|
74 | - |
|
75 | - // remove default ee_autosave returns for DECAF venues (not needed for CAF venues cause we have a dropdown selector) |
|
76 | - add_filter('FHEE__Events_Admin_Page__ee_autosave_edit_do_decaf_venue_save', '__return_false'); |
|
77 | - } |
|
78 | - |
|
79 | - |
|
80 | - public function modify_callbacks($callbacks) |
|
81 | - { |
|
82 | - // first remove default venue callback |
|
83 | - foreach ($callbacks as $key => $callback) { |
|
84 | - if ($callback[1] == '_default_venue_update') { |
|
85 | - unset($callbacks[ $key ]); |
|
86 | - } |
|
87 | - } |
|
88 | - |
|
89 | - // now let's add the caf version |
|
90 | - $callbacks[] = array($this, 'caf_venue_update'); |
|
91 | - return $callbacks; |
|
92 | - } |
|
93 | - |
|
94 | - |
|
95 | - public function venue_metabox() |
|
96 | - { |
|
97 | - $evt_obj = $this->_adminpage_obj->get_event_object(); |
|
98 | - $evt_id = $evt_obj->ID(); |
|
99 | - |
|
100 | - // first let's see if we have a venue already |
|
101 | - $evt_venues = ! empty($evt_id) ? $evt_obj->venues() : array(); |
|
102 | - $evt_venue = $evt_venues && is_array($evt_venues) ? reset($evt_venues) : null; |
|
103 | - $evt_venue_id = $evt_venue instanceof EE_Venue ? $evt_venue->ID() : null; |
|
104 | - |
|
105 | - // possibly private venues. |
|
106 | - if (EE_Registry::instance()->CAP->current_user_can('ee_read_private_venues', 'get_venues')) { |
|
107 | - $vnu_where['status'] = array('IN', array('publish', 'private')); |
|
108 | - } else { |
|
109 | - $vnu_where['status'] = 'publish'; |
|
110 | - } |
|
111 | - |
|
112 | - // cap checks |
|
113 | - if (! EE_Registry::instance()->CAP->current_user_can('ee_read_others_venues', 'get_venues')) { |
|
114 | - $vnu_where['VNU_wp_user'] = get_current_user_id(); |
|
115 | - } |
|
116 | - |
|
117 | - $vnumdl = EE_Registry::instance()->load_model('Venue'); |
|
118 | - $venues = $vnumdl->get_all(array($vnu_where, 'order_by' => array('VNU_name' => 'ASC'))); |
|
119 | - |
|
120 | - $ven_select = array(); |
|
121 | - $ven_select[0] = __('Select a Venue', 'event_espresso'); |
|
122 | - // setup venues for selector |
|
123 | - foreach ($venues as $venue) { |
|
124 | - $ven_select[ $venue->ID() ] = $venue->name(); |
|
125 | - } |
|
126 | - |
|
127 | - // if $ven_select does not have the existing venue attached to event then let's add that because we'll always |
|
128 | - // show existing attached venues even if it's trashed (or some other restricted status). |
|
129 | - |
|
130 | - if ($evt_venue_id && ! isset($ven_select[ $evt_venue_id ])) { |
|
131 | - $ven_select[ $evt_venue_id ] = $evt_venue->name(); |
|
132 | - $venues = array_merge($venues, array($evt_venue)); |
|
133 | - } |
|
134 | - |
|
135 | - $template_args['venues'] = $venues; |
|
136 | - $template_args['evt_venue_id'] = $evt_venue_id; |
|
137 | - $venue_selector = new EE_Select_Input( |
|
138 | - $ven_select, |
|
139 | - array( |
|
140 | - 'html_name' => 'venue_id', |
|
141 | - 'html_id' => 'venue_id', |
|
142 | - 'html_class' => 'wide', |
|
143 | - 'default' => $evt_venue_id ? $evt_venue_id : '0' |
|
144 | - ) |
|
145 | - ); |
|
146 | - $template_args['venue_selector'] = $venue_selector->get_html_for_input(); |
|
147 | - $enable_for_gmap = new EE_Yes_No_Input( |
|
148 | - array( |
|
149 | - 'html_name' => 'enable_for_gmap', |
|
150 | - 'html_id' => 'enable_for_gmap', |
|
151 | - 'default' => $evt_venue instanceof EE_Venue ? $evt_venue->enable_for_gmap() : false |
|
152 | - ) |
|
153 | - ); |
|
154 | - $template_args['enable_for_gmap'] = $enable_for_gmap->get_html_for_input(); |
|
155 | - $template_args['new_venue_link'] = EEH_HTML::link( |
|
156 | - EE_Admin_Page::add_query_args_and_nonce( |
|
157 | - array('action' => 'create_new'), |
|
158 | - EE_VENUES_ADMIN_URL |
|
159 | - ), |
|
160 | - esc_html_x('Add new Venue', 'a link to add a new venue', 'event_espresso'), |
|
161 | - esc_html_x('Add new Venue', 'a link to add a new venue', 'event_espresso'), |
|
162 | - 'ev_new_venue_link', |
|
163 | - 'button', |
|
164 | - 'margin-left:10px;', |
|
165 | - 'target="_blank"' |
|
166 | - ); |
|
167 | - |
|
168 | - // Decide on an info text when there are no venues to display. |
|
169 | - $no_venues_info_txt = esc_html_x( |
|
170 | - 'You have not created any venues yet.', |
|
171 | - 'Information text displayed in the venues metabox when there are no venues to display', |
|
172 | - 'event_espresso' |
|
173 | - ); |
|
174 | - if (empty($venues)) { |
|
175 | - $unpublished_where = $vnu_where; |
|
176 | - $unpublished_where['status'] = 'draft'; |
|
177 | - $unpublished_venues = $vnumdl->get_all(array($unpublished_where, 'order_by' => array('VNU_name' => 'ASC'))); |
|
178 | - if (count($unpublished_venues) > 0) { |
|
179 | - $no_venues_info_txt = esc_html_x( |
|
180 | - // @codingStandardsIgnoreStart |
|
181 | - 'Use the link below to publish your venue through the venue editor so it appears here for selection.', |
|
182 | - // @codingStandardsIgnoreEnd |
|
183 | - 'Information text displayed in the venues metabox when there are no venues to display', |
|
184 | - 'event_espresso' |
|
185 | - ); |
|
186 | - } |
|
187 | - } |
|
188 | - $template_args['no_venues_info'] = EEH_HTML::p( |
|
189 | - EEH_HTML::strong($no_venues_info_txt), |
|
190 | - 'no_venues_info', |
|
191 | - 'info' |
|
192 | - ); |
|
193 | - |
|
194 | - $template_path = empty($venues) ? EE_VENUES_TEMPLATE_PATH . 'event_venues_metabox_content.template.php' |
|
195 | - : EE_VENUES_TEMPLATE_PATH . 'event_venues_metabox_content_from_manager.template.php'; |
|
196 | - |
|
197 | - // Allow events venue metabox template args filtering. |
|
198 | - $template_args = apply_filters( |
|
199 | - 'FHEE__espresso_events_Venues_Hooks___venue_metabox__template_args', |
|
200 | - $template_args, |
|
201 | - $template_path |
|
202 | - ); |
|
203 | - |
|
204 | - EEH_Template::display_template($template_path, $template_args); |
|
205 | - } |
|
206 | - |
|
207 | - |
|
208 | - public function caf_venue_update($evtobj, $data) |
|
209 | - { |
|
210 | - EE_Registry::instance()->load_model('Venue'); |
|
211 | - $venue_id = ! empty($data['venue_id']) ? $data['venue_id'] : null; |
|
212 | - |
|
213 | - |
|
214 | - // first let's check if the selected venue matches any existing venue attached to the event |
|
215 | - $evt_venue = $evtobj->venues(); |
|
216 | - $evt_venue = ! empty($evt_venue) ? array_shift($evt_venue) : null; |
|
217 | - |
|
218 | - if (! empty($evt_venue) && $evt_venue->ID() != $venue_id) { |
|
219 | - $evtobj->_remove_relation_to($evt_venue->ID(), 'Venue'); |
|
220 | - } |
|
221 | - |
|
222 | - if (empty($venue_id)) { |
|
223 | - return true; |
|
224 | - } //no venue to attach |
|
225 | - |
|
226 | - // this should take care of adding to revisions as well as main post object |
|
227 | - $success = $evtobj->_add_relation_to($venue_id, 'Venue'); |
|
228 | - return ! empty($success) ? true : false; |
|
229 | - } |
|
18 | + /** |
|
19 | + * @var EE_Event |
|
20 | + */ |
|
21 | + protected $_event; |
|
22 | + |
|
23 | + |
|
24 | + public function __construct(EE_Admin_Page $admin_page) |
|
25 | + { |
|
26 | + parent::__construct($admin_page); |
|
27 | + } |
|
28 | + |
|
29 | + |
|
30 | + protected function _set_hooks_properties() |
|
31 | + { |
|
32 | + |
|
33 | + $this->_name = 'venues'; |
|
34 | + |
|
35 | + if (EE_Config::instance()->admin->useAdvancedEditor()) { |
|
36 | + $this->_metaboxes = []; |
|
37 | + $this->_scripts_styles = []; |
|
38 | + return; |
|
39 | + } |
|
40 | + $this->_metaboxes = array( |
|
41 | + 0 => array( |
|
42 | + 'page_route' => array('edit', 'create_new'), |
|
43 | + 'func' => 'venue_metabox', |
|
44 | + 'label' => __('Venue Details', 'event_espresso'), |
|
45 | + 'priority' => 'high', |
|
46 | + 'context' => 'normal', |
|
47 | + ), |
|
48 | + ); |
|
49 | + |
|
50 | + $this->_scripts_styles = array( |
|
51 | + 'registers' => array( |
|
52 | + 'ee_event_venues' => array( |
|
53 | + 'type' => 'js', |
|
54 | + 'url' => EE_VENUES_ASSETS_URL . 'ee-event-venues-admin.js', |
|
55 | + 'depends' => array('jquery'), |
|
56 | + ), |
|
57 | + 'ee_event_venues_css' => array( |
|
58 | + 'type' => 'css', |
|
59 | + 'url' => EE_VENUES_ASSETS_URL . 'ee-event-venues-admin.css', |
|
60 | + ), |
|
61 | + ), |
|
62 | + 'enqueues' => array( |
|
63 | + 'ee_event_venues' => array('edit', 'create_new'), |
|
64 | + 'ee_event_venues_css' => array('edit', 'create_new'), |
|
65 | + ), |
|
66 | + ); |
|
67 | + |
|
68 | + // hook into the handler for saving venue |
|
69 | + add_filter( |
|
70 | + 'FHEE__Events_Admin_Page___insert_update_cpt_item__event_update_callbacks', |
|
71 | + array($this, 'modify_callbacks'), |
|
72 | + 10 |
|
73 | + ); |
|
74 | + |
|
75 | + // remove default ee_autosave returns for DECAF venues (not needed for CAF venues cause we have a dropdown selector) |
|
76 | + add_filter('FHEE__Events_Admin_Page__ee_autosave_edit_do_decaf_venue_save', '__return_false'); |
|
77 | + } |
|
78 | + |
|
79 | + |
|
80 | + public function modify_callbacks($callbacks) |
|
81 | + { |
|
82 | + // first remove default venue callback |
|
83 | + foreach ($callbacks as $key => $callback) { |
|
84 | + if ($callback[1] == '_default_venue_update') { |
|
85 | + unset($callbacks[ $key ]); |
|
86 | + } |
|
87 | + } |
|
88 | + |
|
89 | + // now let's add the caf version |
|
90 | + $callbacks[] = array($this, 'caf_venue_update'); |
|
91 | + return $callbacks; |
|
92 | + } |
|
93 | + |
|
94 | + |
|
95 | + public function venue_metabox() |
|
96 | + { |
|
97 | + $evt_obj = $this->_adminpage_obj->get_event_object(); |
|
98 | + $evt_id = $evt_obj->ID(); |
|
99 | + |
|
100 | + // first let's see if we have a venue already |
|
101 | + $evt_venues = ! empty($evt_id) ? $evt_obj->venues() : array(); |
|
102 | + $evt_venue = $evt_venues && is_array($evt_venues) ? reset($evt_venues) : null; |
|
103 | + $evt_venue_id = $evt_venue instanceof EE_Venue ? $evt_venue->ID() : null; |
|
104 | + |
|
105 | + // possibly private venues. |
|
106 | + if (EE_Registry::instance()->CAP->current_user_can('ee_read_private_venues', 'get_venues')) { |
|
107 | + $vnu_where['status'] = array('IN', array('publish', 'private')); |
|
108 | + } else { |
|
109 | + $vnu_where['status'] = 'publish'; |
|
110 | + } |
|
111 | + |
|
112 | + // cap checks |
|
113 | + if (! EE_Registry::instance()->CAP->current_user_can('ee_read_others_venues', 'get_venues')) { |
|
114 | + $vnu_where['VNU_wp_user'] = get_current_user_id(); |
|
115 | + } |
|
116 | + |
|
117 | + $vnumdl = EE_Registry::instance()->load_model('Venue'); |
|
118 | + $venues = $vnumdl->get_all(array($vnu_where, 'order_by' => array('VNU_name' => 'ASC'))); |
|
119 | + |
|
120 | + $ven_select = array(); |
|
121 | + $ven_select[0] = __('Select a Venue', 'event_espresso'); |
|
122 | + // setup venues for selector |
|
123 | + foreach ($venues as $venue) { |
|
124 | + $ven_select[ $venue->ID() ] = $venue->name(); |
|
125 | + } |
|
126 | + |
|
127 | + // if $ven_select does not have the existing venue attached to event then let's add that because we'll always |
|
128 | + // show existing attached venues even if it's trashed (or some other restricted status). |
|
129 | + |
|
130 | + if ($evt_venue_id && ! isset($ven_select[ $evt_venue_id ])) { |
|
131 | + $ven_select[ $evt_venue_id ] = $evt_venue->name(); |
|
132 | + $venues = array_merge($venues, array($evt_venue)); |
|
133 | + } |
|
134 | + |
|
135 | + $template_args['venues'] = $venues; |
|
136 | + $template_args['evt_venue_id'] = $evt_venue_id; |
|
137 | + $venue_selector = new EE_Select_Input( |
|
138 | + $ven_select, |
|
139 | + array( |
|
140 | + 'html_name' => 'venue_id', |
|
141 | + 'html_id' => 'venue_id', |
|
142 | + 'html_class' => 'wide', |
|
143 | + 'default' => $evt_venue_id ? $evt_venue_id : '0' |
|
144 | + ) |
|
145 | + ); |
|
146 | + $template_args['venue_selector'] = $venue_selector->get_html_for_input(); |
|
147 | + $enable_for_gmap = new EE_Yes_No_Input( |
|
148 | + array( |
|
149 | + 'html_name' => 'enable_for_gmap', |
|
150 | + 'html_id' => 'enable_for_gmap', |
|
151 | + 'default' => $evt_venue instanceof EE_Venue ? $evt_venue->enable_for_gmap() : false |
|
152 | + ) |
|
153 | + ); |
|
154 | + $template_args['enable_for_gmap'] = $enable_for_gmap->get_html_for_input(); |
|
155 | + $template_args['new_venue_link'] = EEH_HTML::link( |
|
156 | + EE_Admin_Page::add_query_args_and_nonce( |
|
157 | + array('action' => 'create_new'), |
|
158 | + EE_VENUES_ADMIN_URL |
|
159 | + ), |
|
160 | + esc_html_x('Add new Venue', 'a link to add a new venue', 'event_espresso'), |
|
161 | + esc_html_x('Add new Venue', 'a link to add a new venue', 'event_espresso'), |
|
162 | + 'ev_new_venue_link', |
|
163 | + 'button', |
|
164 | + 'margin-left:10px;', |
|
165 | + 'target="_blank"' |
|
166 | + ); |
|
167 | + |
|
168 | + // Decide on an info text when there are no venues to display. |
|
169 | + $no_venues_info_txt = esc_html_x( |
|
170 | + 'You have not created any venues yet.', |
|
171 | + 'Information text displayed in the venues metabox when there are no venues to display', |
|
172 | + 'event_espresso' |
|
173 | + ); |
|
174 | + if (empty($venues)) { |
|
175 | + $unpublished_where = $vnu_where; |
|
176 | + $unpublished_where['status'] = 'draft'; |
|
177 | + $unpublished_venues = $vnumdl->get_all(array($unpublished_where, 'order_by' => array('VNU_name' => 'ASC'))); |
|
178 | + if (count($unpublished_venues) > 0) { |
|
179 | + $no_venues_info_txt = esc_html_x( |
|
180 | + // @codingStandardsIgnoreStart |
|
181 | + 'Use the link below to publish your venue through the venue editor so it appears here for selection.', |
|
182 | + // @codingStandardsIgnoreEnd |
|
183 | + 'Information text displayed in the venues metabox when there are no venues to display', |
|
184 | + 'event_espresso' |
|
185 | + ); |
|
186 | + } |
|
187 | + } |
|
188 | + $template_args['no_venues_info'] = EEH_HTML::p( |
|
189 | + EEH_HTML::strong($no_venues_info_txt), |
|
190 | + 'no_venues_info', |
|
191 | + 'info' |
|
192 | + ); |
|
193 | + |
|
194 | + $template_path = empty($venues) ? EE_VENUES_TEMPLATE_PATH . 'event_venues_metabox_content.template.php' |
|
195 | + : EE_VENUES_TEMPLATE_PATH . 'event_venues_metabox_content_from_manager.template.php'; |
|
196 | + |
|
197 | + // Allow events venue metabox template args filtering. |
|
198 | + $template_args = apply_filters( |
|
199 | + 'FHEE__espresso_events_Venues_Hooks___venue_metabox__template_args', |
|
200 | + $template_args, |
|
201 | + $template_path |
|
202 | + ); |
|
203 | + |
|
204 | + EEH_Template::display_template($template_path, $template_args); |
|
205 | + } |
|
206 | + |
|
207 | + |
|
208 | + public function caf_venue_update($evtobj, $data) |
|
209 | + { |
|
210 | + EE_Registry::instance()->load_model('Venue'); |
|
211 | + $venue_id = ! empty($data['venue_id']) ? $data['venue_id'] : null; |
|
212 | + |
|
213 | + |
|
214 | + // first let's check if the selected venue matches any existing venue attached to the event |
|
215 | + $evt_venue = $evtobj->venues(); |
|
216 | + $evt_venue = ! empty($evt_venue) ? array_shift($evt_venue) : null; |
|
217 | + |
|
218 | + if (! empty($evt_venue) && $evt_venue->ID() != $venue_id) { |
|
219 | + $evtobj->_remove_relation_to($evt_venue->ID(), 'Venue'); |
|
220 | + } |
|
221 | + |
|
222 | + if (empty($venue_id)) { |
|
223 | + return true; |
|
224 | + } //no venue to attach |
|
225 | + |
|
226 | + // this should take care of adding to revisions as well as main post object |
|
227 | + $success = $evtobj->_add_relation_to($venue_id, 'Venue'); |
|
228 | + return ! empty($success) ? true : false; |
|
229 | + } |
|
230 | 230 | } |
@@ -51,12 +51,12 @@ discard block |
||
51 | 51 | 'registers' => array( |
52 | 52 | 'ee_event_venues' => array( |
53 | 53 | 'type' => 'js', |
54 | - 'url' => EE_VENUES_ASSETS_URL . 'ee-event-venues-admin.js', |
|
54 | + 'url' => EE_VENUES_ASSETS_URL.'ee-event-venues-admin.js', |
|
55 | 55 | 'depends' => array('jquery'), |
56 | 56 | ), |
57 | 57 | 'ee_event_venues_css' => array( |
58 | 58 | 'type' => 'css', |
59 | - 'url' => EE_VENUES_ASSETS_URL . 'ee-event-venues-admin.css', |
|
59 | + 'url' => EE_VENUES_ASSETS_URL.'ee-event-venues-admin.css', |
|
60 | 60 | ), |
61 | 61 | ), |
62 | 62 | 'enqueues' => array( |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | // first remove default venue callback |
83 | 83 | foreach ($callbacks as $key => $callback) { |
84 | 84 | if ($callback[1] == '_default_venue_update') { |
85 | - unset($callbacks[ $key ]); |
|
85 | + unset($callbacks[$key]); |
|
86 | 86 | } |
87 | 87 | } |
88 | 88 | |
@@ -110,7 +110,7 @@ discard block |
||
110 | 110 | } |
111 | 111 | |
112 | 112 | // cap checks |
113 | - if (! EE_Registry::instance()->CAP->current_user_can('ee_read_others_venues', 'get_venues')) { |
|
113 | + if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_others_venues', 'get_venues')) { |
|
114 | 114 | $vnu_where['VNU_wp_user'] = get_current_user_id(); |
115 | 115 | } |
116 | 116 | |
@@ -121,14 +121,14 @@ discard block |
||
121 | 121 | $ven_select[0] = __('Select a Venue', 'event_espresso'); |
122 | 122 | // setup venues for selector |
123 | 123 | foreach ($venues as $venue) { |
124 | - $ven_select[ $venue->ID() ] = $venue->name(); |
|
124 | + $ven_select[$venue->ID()] = $venue->name(); |
|
125 | 125 | } |
126 | 126 | |
127 | 127 | // if $ven_select does not have the existing venue attached to event then let's add that because we'll always |
128 | 128 | // show existing attached venues even if it's trashed (or some other restricted status). |
129 | 129 | |
130 | - if ($evt_venue_id && ! isset($ven_select[ $evt_venue_id ])) { |
|
131 | - $ven_select[ $evt_venue_id ] = $evt_venue->name(); |
|
130 | + if ($evt_venue_id && ! isset($ven_select[$evt_venue_id])) { |
|
131 | + $ven_select[$evt_venue_id] = $evt_venue->name(); |
|
132 | 132 | $venues = array_merge($venues, array($evt_venue)); |
133 | 133 | } |
134 | 134 | |
@@ -192,7 +192,7 @@ discard block |
||
192 | 192 | ); |
193 | 193 | |
194 | 194 | $template_path = empty($venues) ? EE_VENUES_TEMPLATE_PATH . 'event_venues_metabox_content.template.php' |
195 | - : EE_VENUES_TEMPLATE_PATH . 'event_venues_metabox_content_from_manager.template.php'; |
|
195 | + : EE_VENUES_TEMPLATE_PATH.'event_venues_metabox_content_from_manager.template.php'; |
|
196 | 196 | |
197 | 197 | // Allow events venue metabox template args filtering. |
198 | 198 | $template_args = apply_filters( |
@@ -215,7 +215,7 @@ discard block |
||
215 | 215 | $evt_venue = $evtobj->venues(); |
216 | 216 | $evt_venue = ! empty($evt_venue) ? array_shift($evt_venue) : null; |
217 | 217 | |
218 | - if (! empty($evt_venue) && $evt_venue->ID() != $venue_id) { |
|
218 | + if ( ! empty($evt_venue) && $evt_venue->ID() != $venue_id) { |
|
219 | 219 | $evtobj->_remove_relation_to($evt_venue->ID(), 'Venue'); |
220 | 220 | } |
221 | 221 |
@@ -10,9 +10,9 @@ discard block |
||
10 | 10 | $stages = glob(EE_CORE . 'data_migration_scripts/4_12_0_stages/*'); |
11 | 11 | $class_to_filepath = []; |
12 | 12 | foreach ($stages as $filepath) { |
13 | - $matches = []; |
|
14 | - preg_match('~4_12_0_stages/(.*).dmsstage.php~', $filepath, $matches); |
|
15 | - $class_to_filepath[ $matches[1] ] = $filepath; |
|
13 | + $matches = []; |
|
14 | + preg_match('~4_12_0_stages/(.*).dmsstage.php~', $filepath, $matches); |
|
15 | + $class_to_filepath[ $matches[1] ] = $filepath; |
|
16 | 16 | } |
17 | 17 | // give addons a chance to autoload their stages too |
18 | 18 | $class_to_filepath = apply_filters('FHEE__EE_DMS_4_12_0__autoloaded_stages', $class_to_filepath); |
@@ -28,63 +28,63 @@ discard block |
||
28 | 28 | */ |
29 | 29 | class EE_DMS_Core_4_12_0 extends EE_Data_Migration_Script_Base |
30 | 30 | { |
31 | - /** |
|
32 | - * |
|
33 | - * @param EE_DMS_Core_4_11_0 $dms_4_11 |
|
34 | - * @param TableManager|null $table_manager |
|
35 | - * @param TableAnalysis|null $table_analysis |
|
36 | - */ |
|
37 | - public function __construct( |
|
38 | - EE_DMS_Core_4_11_0 $dms_4_11, |
|
39 | - TableManager $table_manager = null, |
|
40 | - TableAnalysis $table_analysis = null |
|
41 | - ) { |
|
42 | - $this->previous_dms = $dms_4_11; |
|
43 | - $this->_pretty_name = esc_html__("Data Update to Event Espresso 4.12.0", "event_espresso"); |
|
44 | - $this->_priority = 10; |
|
45 | - $this->_migration_stages = [ |
|
46 | - new EE_DMS_4_12_0_Event_Venues(), |
|
47 | - ]; |
|
48 | - parent::__construct($table_manager, $table_analysis); |
|
49 | - } |
|
50 | - |
|
51 | - |
|
52 | - /** |
|
53 | - * Whether to migrate or not. |
|
54 | - * |
|
55 | - * @param array $version_array |
|
56 | - * @return bool |
|
57 | - */ |
|
58 | - public function can_migrate_from_version($version_array): bool |
|
59 | - { |
|
60 | - $version_string = $version_array['Core']; |
|
61 | - return $version_string |
|
62 | - && version_compare($version_string, '4.12.0.decaf', '<') |
|
63 | - && version_compare($version_string, '4.11.0.decaf', '>='); |
|
64 | - } |
|
65 | - |
|
66 | - |
|
67 | - /** |
|
68 | - * @return bool |
|
69 | - * @throws EE_Error |
|
70 | - * @throws ReflectionException |
|
71 | - */ |
|
72 | - public function schema_changes_before_migration(): bool |
|
73 | - { |
|
74 | - require_once EE_HELPERS . 'EEH_Activation.helper.php'; |
|
75 | - |
|
76 | - $table_name = 'esp_answer'; |
|
77 | - $sql = " ANS_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
31 | + /** |
|
32 | + * |
|
33 | + * @param EE_DMS_Core_4_11_0 $dms_4_11 |
|
34 | + * @param TableManager|null $table_manager |
|
35 | + * @param TableAnalysis|null $table_analysis |
|
36 | + */ |
|
37 | + public function __construct( |
|
38 | + EE_DMS_Core_4_11_0 $dms_4_11, |
|
39 | + TableManager $table_manager = null, |
|
40 | + TableAnalysis $table_analysis = null |
|
41 | + ) { |
|
42 | + $this->previous_dms = $dms_4_11; |
|
43 | + $this->_pretty_name = esc_html__("Data Update to Event Espresso 4.12.0", "event_espresso"); |
|
44 | + $this->_priority = 10; |
|
45 | + $this->_migration_stages = [ |
|
46 | + new EE_DMS_4_12_0_Event_Venues(), |
|
47 | + ]; |
|
48 | + parent::__construct($table_manager, $table_analysis); |
|
49 | + } |
|
50 | + |
|
51 | + |
|
52 | + /** |
|
53 | + * Whether to migrate or not. |
|
54 | + * |
|
55 | + * @param array $version_array |
|
56 | + * @return bool |
|
57 | + */ |
|
58 | + public function can_migrate_from_version($version_array): bool |
|
59 | + { |
|
60 | + $version_string = $version_array['Core']; |
|
61 | + return $version_string |
|
62 | + && version_compare($version_string, '4.12.0.decaf', '<') |
|
63 | + && version_compare($version_string, '4.11.0.decaf', '>='); |
|
64 | + } |
|
65 | + |
|
66 | + |
|
67 | + /** |
|
68 | + * @return bool |
|
69 | + * @throws EE_Error |
|
70 | + * @throws ReflectionException |
|
71 | + */ |
|
72 | + public function schema_changes_before_migration(): bool |
|
73 | + { |
|
74 | + require_once EE_HELPERS . 'EEH_Activation.helper.php'; |
|
75 | + |
|
76 | + $table_name = 'esp_answer'; |
|
77 | + $sql = " ANS_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
78 | 78 | REG_ID int(10) unsigned NOT NULL, |
79 | 79 | QST_ID int(10) unsigned NOT NULL, |
80 | 80 | ANS_value text NOT NULL, |
81 | 81 | PRIMARY KEY (ANS_ID), |
82 | 82 | KEY REG_ID (REG_ID), |
83 | 83 | KEY QST_ID (QST_ID)"; |
84 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
84 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
85 | 85 | |
86 | - $table_name = 'esp_attendee_meta'; |
|
87 | - $sql = "ATTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
86 | + $table_name = 'esp_attendee_meta'; |
|
87 | + $sql = "ATTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
88 | 88 | ATT_ID bigint(20) unsigned NOT NULL, |
89 | 89 | ATT_fname varchar(45) NOT NULL, |
90 | 90 | ATT_lname varchar(45) NOT NULL, |
@@ -101,10 +101,10 @@ discard block |
||
101 | 101 | KEY ATT_email (ATT_email(191)), |
102 | 102 | KEY ATT_lname (ATT_lname), |
103 | 103 | KEY ATT_fname (ATT_fname)"; |
104 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
104 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
105 | 105 | |
106 | - $table_name = 'esp_checkin'; |
|
107 | - $sql = "CHK_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
106 | + $table_name = 'esp_checkin'; |
|
107 | + $sql = "CHK_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
108 | 108 | REG_ID int(10) unsigned NOT NULL, |
109 | 109 | DTT_ID int(10) unsigned NOT NULL, |
110 | 110 | CHK_in tinyint(1) unsigned NOT NULL DEFAULT 1, |
@@ -112,10 +112,10 @@ discard block |
||
112 | 112 | PRIMARY KEY (CHK_ID), |
113 | 113 | KEY REG_ID (REG_ID), |
114 | 114 | KEY DTT_ID (DTT_ID)"; |
115 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
115 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
116 | 116 | |
117 | - $table_name = 'esp_country'; |
|
118 | - $sql = "CNT_ISO varchar(2) NOT NULL, |
|
117 | + $table_name = 'esp_country'; |
|
118 | + $sql = "CNT_ISO varchar(2) NOT NULL, |
|
119 | 119 | CNT_ISO3 varchar(3) NOT NULL, |
120 | 120 | RGN_ID tinyint(3) unsigned DEFAULT NULL, |
121 | 121 | CNT_name varchar(45) NOT NULL, |
@@ -131,32 +131,32 @@ discard block |
||
131 | 131 | CNT_is_EU tinyint(1) DEFAULT '0', |
132 | 132 | CNT_active tinyint(1) DEFAULT '0', |
133 | 133 | PRIMARY KEY (CNT_ISO)"; |
134 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
134 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
135 | 135 | |
136 | - $table_name = 'esp_currency'; |
|
137 | - $sql = "CUR_code varchar(6) NOT NULL, |
|
136 | + $table_name = 'esp_currency'; |
|
137 | + $sql = "CUR_code varchar(6) NOT NULL, |
|
138 | 138 | CUR_single varchar(45) DEFAULT 'dollar', |
139 | 139 | CUR_plural varchar(45) DEFAULT 'dollars', |
140 | 140 | CUR_sign varchar(45) DEFAULT '$', |
141 | 141 | CUR_dec_plc varchar(1) NOT NULL DEFAULT '2', |
142 | 142 | CUR_active tinyint(1) DEFAULT '0', |
143 | 143 | PRIMARY KEY (CUR_code)"; |
144 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
145 | - |
|
146 | - // note: although this table is no longer in use, |
|
147 | - // it hasn't been removed because then queries to the model will have errors. |
|
148 | - // but you should expect this table and its corresponding model to be removed in |
|
149 | - // the next few months |
|
150 | - $table_name = 'esp_currency_payment_method'; |
|
151 | - $sql = "CPM_ID int(11) NOT NULL AUTO_INCREMENT, |
|
144 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
145 | + |
|
146 | + // note: although this table is no longer in use, |
|
147 | + // it hasn't been removed because then queries to the model will have errors. |
|
148 | + // but you should expect this table and its corresponding model to be removed in |
|
149 | + // the next few months |
|
150 | + $table_name = 'esp_currency_payment_method'; |
|
151 | + $sql = "CPM_ID int(11) NOT NULL AUTO_INCREMENT, |
|
152 | 152 | CUR_code varchar(6) NOT NULL, |
153 | 153 | PMD_ID int(11) NOT NULL, |
154 | 154 | PRIMARY KEY (CPM_ID), |
155 | 155 | KEY PMD_ID (PMD_ID)"; |
156 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
156 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
157 | 157 | |
158 | - $table_name = 'esp_datetime'; |
|
159 | - $sql = "DTT_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
158 | + $table_name = 'esp_datetime'; |
|
159 | + $sql = "DTT_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
160 | 160 | EVT_ID bigint(20) unsigned NOT NULL, |
161 | 161 | VNU_ID bigint(20) unsigned NOT NULL DEFAULT 0, |
162 | 162 | DTT_name varchar(255) NOT NULL DEFAULT '', |
@@ -174,28 +174,28 @@ discard block |
||
174 | 174 | KEY DTT_EVT_start (DTT_EVT_start), |
175 | 175 | KEY EVT_ID (EVT_ID), |
176 | 176 | KEY DTT_is_primary (DTT_is_primary)"; |
177 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
177 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
178 | 178 | |
179 | - $table_name = "esp_datetime_ticket"; |
|
180 | - $sql = "DTK_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
179 | + $table_name = "esp_datetime_ticket"; |
|
180 | + $sql = "DTK_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
181 | 181 | DTT_ID int(10) unsigned NOT NULL, |
182 | 182 | TKT_ID int(10) unsigned NOT NULL, |
183 | 183 | PRIMARY KEY (DTK_ID), |
184 | 184 | KEY DTT_ID (DTT_ID), |
185 | 185 | KEY TKT_ID (TKT_ID)"; |
186 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
186 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
187 | 187 | |
188 | - $table_name = 'esp_event_message_template'; |
|
189 | - $sql = "EMT_ID bigint(20) unsigned NOT NULL AUTO_INCREMENT, |
|
188 | + $table_name = 'esp_event_message_template'; |
|
189 | + $sql = "EMT_ID bigint(20) unsigned NOT NULL AUTO_INCREMENT, |
|
190 | 190 | EVT_ID bigint(20) unsigned NOT NULL DEFAULT 0, |
191 | 191 | GRP_ID int(10) unsigned NOT NULL DEFAULT 0, |
192 | 192 | PRIMARY KEY (EMT_ID), |
193 | 193 | KEY EVT_ID (EVT_ID), |
194 | 194 | KEY GRP_ID (GRP_ID)"; |
195 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
195 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
196 | 196 | |
197 | - $table_name = 'esp_event_meta'; |
|
198 | - $sql = "EVTM_ID int(10) NOT NULL AUTO_INCREMENT, |
|
197 | + $table_name = 'esp_event_meta'; |
|
198 | + $sql = "EVTM_ID int(10) NOT NULL AUTO_INCREMENT, |
|
199 | 199 | EVT_ID bigint(20) unsigned NOT NULL, |
200 | 200 | VNU_ID bigint(20) unsigned NOT NULL DEFAULT 0, |
201 | 201 | EVT_display_desc tinyint(1) unsigned NOT NULL DEFAULT 1, |
@@ -212,10 +212,10 @@ discard block |
||
212 | 212 | FSC_UUID varchar(25) DEFAULT NULL, |
213 | 213 | PRIMARY KEY (EVTM_ID), |
214 | 214 | KEY EVT_ID (EVT_ID)"; |
215 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
215 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
216 | 216 | |
217 | - $table_name = 'esp_event_question_group'; |
|
218 | - $sql = "EQG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
217 | + $table_name = 'esp_event_question_group'; |
|
218 | + $sql = "EQG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
219 | 219 | EVT_ID bigint(20) unsigned NOT NULL, |
220 | 220 | QSG_ID int(10) unsigned NOT NULL, |
221 | 221 | EQG_primary tinyint(1) unsigned NOT NULL DEFAULT 0, |
@@ -223,28 +223,28 @@ discard block |
||
223 | 223 | PRIMARY KEY (EQG_ID), |
224 | 224 | KEY EVT_ID (EVT_ID), |
225 | 225 | KEY QSG_ID (QSG_ID)"; |
226 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
226 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
227 | 227 | |
228 | - $table_name = 'esp_event_venue'; |
|
229 | - $sql = "EVV_ID int(11) NOT NULL AUTO_INCREMENT, |
|
228 | + $table_name = 'esp_event_venue'; |
|
229 | + $sql = "EVV_ID int(11) NOT NULL AUTO_INCREMENT, |
|
230 | 230 | EVT_ID bigint(20) unsigned NOT NULL, |
231 | 231 | VNU_ID bigint(20) unsigned NOT NULL, |
232 | 232 | EVV_primary tinyint(1) unsigned NOT NULL DEFAULT 0, |
233 | 233 | PRIMARY KEY (EVV_ID)"; |
234 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
234 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
235 | 235 | |
236 | - $table_name = 'esp_extra_meta'; |
|
237 | - $sql = "EXM_ID int(11) NOT NULL AUTO_INCREMENT, |
|
236 | + $table_name = 'esp_extra_meta'; |
|
237 | + $sql = "EXM_ID int(11) NOT NULL AUTO_INCREMENT, |
|
238 | 238 | OBJ_ID int(11) DEFAULT NULL, |
239 | 239 | EXM_type varchar(45) DEFAULT NULL, |
240 | 240 | EXM_key varchar(45) DEFAULT NULL, |
241 | 241 | EXM_value text, |
242 | 242 | PRIMARY KEY (EXM_ID), |
243 | 243 | KEY EXM_type (EXM_type,OBJ_ID,EXM_key)"; |
244 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
244 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
245 | 245 | |
246 | - $table_name = 'esp_extra_join'; |
|
247 | - $sql = "EXJ_ID int(11) NOT NULL AUTO_INCREMENT, |
|
246 | + $table_name = 'esp_extra_join'; |
|
247 | + $sql = "EXJ_ID int(11) NOT NULL AUTO_INCREMENT, |
|
248 | 248 | EXJ_first_model_id varchar(6) NOT NULL, |
249 | 249 | EXJ_first_model_name varchar(20) NOT NULL, |
250 | 250 | EXJ_second_model_id varchar(6) NOT NULL, |
@@ -252,10 +252,10 @@ discard block |
||
252 | 252 | PRIMARY KEY (EXJ_ID), |
253 | 253 | KEY first_model (EXJ_first_model_name,EXJ_first_model_id), |
254 | 254 | KEY second_model (EXJ_second_model_name,EXJ_second_model_id)"; |
255 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
255 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
256 | 256 | |
257 | - $table_name = 'esp_form_element'; |
|
258 | - $sql = "FIN_UUID varchar(25) NOT NULL, |
|
257 | + $table_name = 'esp_form_element'; |
|
258 | + $sql = "FIN_UUID varchar(25) NOT NULL, |
|
259 | 259 | FSC_UUID varchar(25) NOT NULL, |
260 | 260 | FIN_adminOnly tinyint(1) unsigned NOT NULL DEFAULT 0, |
261 | 261 | FIN_attributes text DEFAULT NULL, |
@@ -272,10 +272,10 @@ discard block |
||
272 | 272 | KEY FSC_UUID (FSC_UUID), |
273 | 273 | KEY FIN_order (FIN_order), |
274 | 274 | KEY FIN_status (FIN_status)"; |
275 | - $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
275 | + $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
276 | 276 | |
277 | - $table_name = 'esp_form_section'; |
|
278 | - $sql = "FSC_UUID varchar(25) NOT NULL, |
|
277 | + $table_name = 'esp_form_section'; |
|
278 | + $sql = "FSC_UUID varchar(25) NOT NULL, |
|
279 | 279 | FSC_appliesTo tinytext NOT NULL, |
280 | 280 | FSC_attributes text DEFAULT NULL, |
281 | 281 | FSC_belongsTo varchar(25) DEFAULT NULL, |
@@ -287,10 +287,10 @@ discard block |
||
287 | 287 | KEY FSC_belongsTo (FSC_belongsTo), |
288 | 288 | KEY FSC_order (FSC_order), |
289 | 289 | KEY FSC_status (FSC_status)"; |
290 | - $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
290 | + $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
291 | 291 | |
292 | - $table_name = 'esp_form_submission'; |
|
293 | - $sql = "FSB_UUID varchar(25) NOT NULL, |
|
292 | + $table_name = 'esp_form_submission'; |
|
293 | + $sql = "FSB_UUID varchar(25) NOT NULL, |
|
294 | 294 | FSC_UUID varchar(25) NOT NULL, |
295 | 295 | TXN_ID int(10) DEFAULT NULL, |
296 | 296 | FSB_data mediumtext DEFAULT NULL, |
@@ -298,10 +298,10 @@ discard block |
||
298 | 298 | PRIMARY KEY (FSB_UUID), |
299 | 299 | KEY FSC_UUID (FSC_UUID), |
300 | 300 | KEY TXN_ID (TXN_ID)"; |
301 | - $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
301 | + $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
302 | 302 | |
303 | - $table_name = 'esp_line_item'; |
|
304 | - $sql = "LIN_ID int(11) NOT NULL AUTO_INCREMENT, |
|
303 | + $table_name = 'esp_line_item'; |
|
304 | + $sql = "LIN_ID int(11) NOT NULL AUTO_INCREMENT, |
|
305 | 305 | LIN_code varchar(245) NOT NULL DEFAULT '', |
306 | 306 | TXN_ID int(10) DEFAULT NULL, |
307 | 307 | LIN_name varchar(245) NOT NULL DEFAULT '', |
@@ -322,10 +322,10 @@ discard block |
||
322 | 322 | KEY txn_type_timestamp (TXN_ID,LIN_type,LIN_timestamp), |
323 | 323 | KEY txn_obj_id_obj_type (TXN_ID,OBJ_ID,OBJ_type), |
324 | 324 | KEY obj_id_obj_type (OBJ_ID,OBJ_type)"; |
325 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
325 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
326 | 326 | |
327 | - $table_name = 'esp_log'; |
|
328 | - $sql = "LOG_ID int(11) NOT NULL AUTO_INCREMENT, |
|
327 | + $table_name = 'esp_log'; |
|
328 | + $sql = "LOG_ID int(11) NOT NULL AUTO_INCREMENT, |
|
329 | 329 | LOG_time datetime DEFAULT NULL, |
330 | 330 | OBJ_ID varchar(45) DEFAULT NULL, |
331 | 331 | OBJ_type varchar(45) DEFAULT NULL, |
@@ -336,10 +336,10 @@ discard block |
||
336 | 336 | KEY LOG_time (LOG_time), |
337 | 337 | KEY OBJ (OBJ_type,OBJ_ID), |
338 | 338 | KEY LOG_type (LOG_type)"; |
339 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
339 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
340 | 340 | |
341 | - $table_name = 'esp_message'; |
|
342 | - $sql = "MSG_ID bigint(20) unsigned NOT NULL AUTO_INCREMENT, |
|
341 | + $table_name = 'esp_message'; |
|
342 | + $sql = "MSG_ID bigint(20) unsigned NOT NULL AUTO_INCREMENT, |
|
343 | 343 | GRP_ID int(10) unsigned NULL, |
344 | 344 | MSG_token varchar(255) NULL, |
345 | 345 | TXN_ID int(10) unsigned NULL, |
@@ -371,20 +371,20 @@ discard block |
||
371 | 371 | KEY STS_ID (STS_ID), |
372 | 372 | KEY MSG_created (MSG_created), |
373 | 373 | KEY MSG_modified (MSG_modified)"; |
374 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
374 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
375 | 375 | |
376 | - $table_name = 'esp_message_template'; |
|
377 | - $sql = "MTP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
376 | + $table_name = 'esp_message_template'; |
|
377 | + $sql = "MTP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
378 | 378 | GRP_ID int(10) unsigned NOT NULL, |
379 | 379 | MTP_context varchar(50) NOT NULL, |
380 | 380 | MTP_template_field varchar(30) NOT NULL, |
381 | 381 | MTP_content text NOT NULL, |
382 | 382 | PRIMARY KEY (MTP_ID), |
383 | 383 | KEY GRP_ID (GRP_ID)"; |
384 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
384 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
385 | 385 | |
386 | - $table_name = 'esp_message_template_group'; |
|
387 | - $sql = "GRP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
386 | + $table_name = 'esp_message_template_group'; |
|
387 | + $sql = "GRP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
388 | 388 | MTP_user_id int(10) NOT NULL DEFAULT '1', |
389 | 389 | MTP_name varchar(245) NOT NULL DEFAULT '', |
390 | 390 | MTP_description varchar(245) NOT NULL DEFAULT '', |
@@ -396,10 +396,10 @@ discard block |
||
396 | 396 | MTP_is_active tinyint(1) NOT NULL DEFAULT '1', |
397 | 397 | PRIMARY KEY (GRP_ID), |
398 | 398 | KEY MTP_user_id (MTP_user_id)"; |
399 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
399 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
400 | 400 | |
401 | - $table_name = 'esp_payment'; |
|
402 | - $sql = "PAY_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
401 | + $table_name = 'esp_payment'; |
|
402 | + $sql = "PAY_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
403 | 403 | TXN_ID int(10) unsigned DEFAULT NULL, |
404 | 404 | STS_ID varchar(3) DEFAULT NULL, |
405 | 405 | PAY_timestamp datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, |
@@ -416,10 +416,10 @@ discard block |
||
416 | 416 | PRIMARY KEY (PAY_ID), |
417 | 417 | KEY PAY_timestamp (PAY_timestamp), |
418 | 418 | KEY TXN_ID (TXN_ID)"; |
419 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
419 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
420 | 420 | |
421 | - $table_name = 'esp_payment_method'; |
|
422 | - $sql = "PMD_ID int(11) NOT NULL AUTO_INCREMENT, |
|
421 | + $table_name = 'esp_payment_method'; |
|
422 | + $sql = "PMD_ID int(11) NOT NULL AUTO_INCREMENT, |
|
423 | 423 | PMD_type varchar(124) DEFAULT NULL, |
424 | 424 | PMD_name varchar(255) DEFAULT NULL, |
425 | 425 | PMD_desc text, |
@@ -435,10 +435,10 @@ discard block |
||
435 | 435 | PRIMARY KEY (PMD_ID), |
436 | 436 | UNIQUE KEY PMD_slug_UNIQUE (PMD_slug), |
437 | 437 | KEY PMD_type (PMD_type)"; |
438 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
438 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
439 | 439 | |
440 | - $table_name = "esp_price"; |
|
441 | - $sql = "PRC_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
440 | + $table_name = "esp_price"; |
|
441 | + $sql = "PRC_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
442 | 442 | PRT_ID tinyint(3) unsigned NOT NULL, |
443 | 443 | PRC_amount decimal(12,3) NOT NULL DEFAULT '0.00', |
444 | 444 | PRC_name varchar(245) NOT NULL, |
@@ -451,10 +451,10 @@ discard block |
||
451 | 451 | PRC_parent int(10) unsigned DEFAULT 0, |
452 | 452 | PRIMARY KEY (PRC_ID), |
453 | 453 | KEY PRT_ID (PRT_ID)"; |
454 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
454 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
455 | 455 | |
456 | - $table_name = "esp_price_type"; |
|
457 | - $sql = "PRT_ID tinyint(3) unsigned NOT NULL AUTO_INCREMENT, |
|
456 | + $table_name = "esp_price_type"; |
|
457 | + $sql = "PRT_ID tinyint(3) unsigned NOT NULL AUTO_INCREMENT, |
|
458 | 458 | PRT_name varchar(45) NOT NULL, |
459 | 459 | PBT_ID tinyint(3) unsigned NOT NULL DEFAULT '1', |
460 | 460 | PRT_is_percent tinyint(1) NOT NULL DEFAULT '0', |
@@ -463,27 +463,27 @@ discard block |
||
463 | 463 | PRT_deleted tinyint(1) NOT NULL DEFAULT '0', |
464 | 464 | UNIQUE KEY PRT_name_UNIQUE (PRT_name), |
465 | 465 | PRIMARY KEY (PRT_ID)"; |
466 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
466 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
467 | 467 | |
468 | - $table_name = "esp_ticket_price"; |
|
469 | - $sql = "TKP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
468 | + $table_name = "esp_ticket_price"; |
|
469 | + $sql = "TKP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
470 | 470 | TKT_ID int(10) unsigned NOT NULL, |
471 | 471 | PRC_ID int(10) unsigned NOT NULL, |
472 | 472 | PRIMARY KEY (TKP_ID), |
473 | 473 | KEY TKT_ID (TKT_ID), |
474 | 474 | KEY PRC_ID (PRC_ID)"; |
475 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
475 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
476 | 476 | |
477 | - $table_name = "esp_ticket_template"; |
|
478 | - $sql = "TTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
477 | + $table_name = "esp_ticket_template"; |
|
478 | + $sql = "TTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
479 | 479 | TTM_name varchar(45) NOT NULL, |
480 | 480 | TTM_description text, |
481 | 481 | TTM_file varchar(45), |
482 | 482 | PRIMARY KEY (TTM_ID)"; |
483 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
483 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
484 | 484 | |
485 | - $table_name = 'esp_question'; |
|
486 | - $sql = 'QST_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
485 | + $table_name = 'esp_question'; |
|
486 | + $sql = 'QST_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
487 | 487 | QST_display_text text NOT NULL, |
488 | 488 | QST_admin_label varchar(255) NOT NULL, |
489 | 489 | QST_system varchar(25) DEFAULT NULL, |
@@ -497,10 +497,10 @@ discard block |
||
497 | 497 | QST_deleted tinyint(2) unsigned NOT NULL DEFAULT 0, |
498 | 498 | PRIMARY KEY (QST_ID), |
499 | 499 | KEY QST_order (QST_order)'; |
500 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
500 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
501 | 501 | |
502 | - $table_name = 'esp_question_group'; |
|
503 | - $sql = 'QSG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
502 | + $table_name = 'esp_question_group'; |
|
503 | + $sql = 'QSG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
504 | 504 | QSG_name varchar(255) NOT NULL, |
505 | 505 | QSG_identifier varchar(100) NOT NULL, |
506 | 506 | QSG_desc text NULL, |
@@ -513,20 +513,20 @@ discard block |
||
513 | 513 | PRIMARY KEY (QSG_ID), |
514 | 514 | UNIQUE KEY QSG_identifier_UNIQUE (QSG_identifier), |
515 | 515 | KEY QSG_order (QSG_order)'; |
516 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
516 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
517 | 517 | |
518 | - $table_name = 'esp_question_group_question'; |
|
519 | - $sql = "QGQ_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
518 | + $table_name = 'esp_question_group_question'; |
|
519 | + $sql = "QGQ_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
520 | 520 | QSG_ID int(10) unsigned NOT NULL, |
521 | 521 | QST_ID int(10) unsigned NOT NULL, |
522 | 522 | QGQ_order int(10) unsigned NOT NULL DEFAULT 0, |
523 | 523 | PRIMARY KEY (QGQ_ID), |
524 | 524 | KEY QST_ID (QST_ID), |
525 | 525 | KEY QSG_ID_order (QSG_ID,QGQ_order)"; |
526 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
526 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
527 | 527 | |
528 | - $table_name = 'esp_question_option'; |
|
529 | - $sql = "QSO_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
528 | + $table_name = 'esp_question_option'; |
|
529 | + $sql = "QSO_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
530 | 530 | QSO_value varchar(255) NOT NULL, |
531 | 531 | QSO_desc text NOT NULL, |
532 | 532 | QST_ID int(10) unsigned NOT NULL, |
@@ -536,10 +536,10 @@ discard block |
||
536 | 536 | PRIMARY KEY (QSO_ID), |
537 | 537 | KEY QST_ID (QST_ID), |
538 | 538 | KEY QSO_order (QSO_order)"; |
539 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
539 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
540 | 540 | |
541 | - $table_name = 'esp_registration'; |
|
542 | - $sql = "REG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
541 | + $table_name = 'esp_registration'; |
|
542 | + $sql = "REG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
543 | 543 | EVT_ID bigint(20) unsigned NOT NULL, |
544 | 544 | ATT_ID bigint(20) unsigned NOT NULL, |
545 | 545 | TXN_ID int(10) unsigned NOT NULL, |
@@ -563,20 +563,20 @@ discard block |
||
563 | 563 | KEY TKT_ID (TKT_ID), |
564 | 564 | KEY EVT_ID (EVT_ID), |
565 | 565 | KEY STS_ID (STS_ID)"; |
566 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
566 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
567 | 567 | |
568 | - $table_name = 'esp_registration_payment'; |
|
569 | - $sql = "RPY_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
568 | + $table_name = 'esp_registration_payment'; |
|
569 | + $sql = "RPY_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
570 | 570 | REG_ID int(10) unsigned NOT NULL, |
571 | 571 | PAY_ID int(10) unsigned NULL, |
572 | 572 | RPY_amount decimal(12,3) NOT NULL DEFAULT '0.00', |
573 | 573 | PRIMARY KEY (RPY_ID), |
574 | 574 | KEY REG_ID (REG_ID), |
575 | 575 | KEY PAY_ID (PAY_ID)"; |
576 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
576 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
577 | 577 | |
578 | - $table_name = 'esp_state'; |
|
579 | - $sql = "STA_ID smallint(5) unsigned NOT NULL AUTO_INCREMENT, |
|
578 | + $table_name = 'esp_state'; |
|
579 | + $sql = "STA_ID smallint(5) unsigned NOT NULL AUTO_INCREMENT, |
|
580 | 580 | CNT_ISO varchar(2) NOT NULL, |
581 | 581 | STA_abbrev varchar(24) NOT NULL, |
582 | 582 | STA_name varchar(100) NOT NULL, |
@@ -584,10 +584,10 @@ discard block |
||
584 | 584 | PRIMARY KEY (STA_ID), |
585 | 585 | KEY STA_abbrev (STA_abbrev), |
586 | 586 | KEY CNT_ISO (CNT_ISO)"; |
587 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
587 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
588 | 588 | |
589 | - $table_name = 'esp_status'; |
|
590 | - $sql = "STS_ID varchar(3) NOT NULL, |
|
589 | + $table_name = 'esp_status'; |
|
590 | + $sql = "STS_ID varchar(3) NOT NULL, |
|
591 | 591 | STS_code varchar(45) NOT NULL, |
592 | 592 | STS_type varchar(45) NOT NULL, |
593 | 593 | STS_can_edit tinyint(1) NOT NULL DEFAULT 0, |
@@ -595,10 +595,10 @@ discard block |
||
595 | 595 | STS_open tinyint(1) NOT NULL DEFAULT 1, |
596 | 596 | UNIQUE KEY STS_ID_UNIQUE (STS_ID), |
597 | 597 | KEY STS_type (STS_type)"; |
598 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
598 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
599 | 599 | |
600 | - $table_name = "esp_ticket"; |
|
601 | - $sql = "TKT_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
600 | + $table_name = "esp_ticket"; |
|
601 | + $sql = "TKT_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
602 | 602 | TTM_ID int(10) unsigned NOT NULL, |
603 | 603 | TKT_name varchar(245) NOT NULL DEFAULT '', |
604 | 604 | TKT_description text NOT NULL, |
@@ -623,10 +623,10 @@ discard block |
||
623 | 623 | TKT_visibility smallint(6) unsigned NOT NULL DEFAULT 100, |
624 | 624 | PRIMARY KEY (TKT_ID), |
625 | 625 | KEY TKT_start_date (TKT_start_date)"; |
626 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
626 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
627 | 627 | |
628 | - $table_name = 'esp_transaction'; |
|
629 | - $sql = "TXN_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
628 | + $table_name = 'esp_transaction'; |
|
629 | + $sql = "TXN_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
630 | 630 | TXN_timestamp datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, |
631 | 631 | TXN_total decimal(12,3) DEFAULT '0.00', |
632 | 632 | TXN_paid decimal(12,3) NOT NULL DEFAULT '0.00', |
@@ -638,10 +638,10 @@ discard block |
||
638 | 638 | PRIMARY KEY (TXN_ID), |
639 | 639 | KEY TXN_timestamp (TXN_timestamp), |
640 | 640 | KEY STS_ID (STS_ID)"; |
641 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
641 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
642 | 642 | |
643 | - $table_name = 'esp_venue_meta'; |
|
644 | - $sql = "VNUM_ID int(11) NOT NULL AUTO_INCREMENT, |
|
643 | + $table_name = 'esp_venue_meta'; |
|
644 | + $sql = "VNUM_ID int(11) NOT NULL AUTO_INCREMENT, |
|
645 | 645 | VNU_ID bigint(20) unsigned NOT NULL DEFAULT 0, |
646 | 646 | VNU_address varchar(255) DEFAULT NULL, |
647 | 647 | VNU_address2 varchar(255) DEFAULT NULL, |
@@ -660,18 +660,18 @@ discard block |
||
660 | 660 | KEY VNU_ID (VNU_ID), |
661 | 661 | KEY STA_ID (STA_ID), |
662 | 662 | KEY CNT_ISO (CNT_ISO)"; |
663 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
663 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
664 | 664 | |
665 | - $this->previous_dms->insert_default_data(); |
|
666 | - return true; |
|
667 | - } |
|
665 | + $this->previous_dms->insert_default_data(); |
|
666 | + return true; |
|
667 | + } |
|
668 | 668 | |
669 | 669 | |
670 | - /** |
|
671 | - * @return boolean |
|
672 | - */ |
|
673 | - public function schema_changes_after_migration(): bool |
|
674 | - { |
|
675 | - return true; |
|
676 | - } |
|
670 | + /** |
|
671 | + * @return boolean |
|
672 | + */ |
|
673 | + public function schema_changes_after_migration(): bool |
|
674 | + { |
|
675 | + return true; |
|
676 | + } |
|
677 | 677 | } |
@@ -7,12 +7,12 @@ discard block |
||
7 | 7 | // unfortunately, this needs to be done upon INCLUSION of this file, |
8 | 8 | // instead of construction, because it only gets constructed on first page load |
9 | 9 | // (all other times it gets resurrected from a wordpress option) |
10 | -$stages = glob(EE_CORE . 'data_migration_scripts/4_12_0_stages/*'); |
|
10 | +$stages = glob(EE_CORE.'data_migration_scripts/4_12_0_stages/*'); |
|
11 | 11 | $class_to_filepath = []; |
12 | 12 | foreach ($stages as $filepath) { |
13 | 13 | $matches = []; |
14 | 14 | preg_match('~4_12_0_stages/(.*).dmsstage.php~', $filepath, $matches); |
15 | - $class_to_filepath[ $matches[1] ] = $filepath; |
|
15 | + $class_to_filepath[$matches[1]] = $filepath; |
|
16 | 16 | } |
17 | 17 | // give addons a chance to autoload their stages too |
18 | 18 | $class_to_filepath = apply_filters('FHEE__EE_DMS_4_12_0__autoloaded_stages', $class_to_filepath); |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | */ |
72 | 72 | public function schema_changes_before_migration(): bool |
73 | 73 | { |
74 | - require_once EE_HELPERS . 'EEH_Activation.helper.php'; |
|
74 | + require_once EE_HELPERS.'EEH_Activation.helper.php'; |
|
75 | 75 | |
76 | 76 | $table_name = 'esp_answer'; |
77 | 77 | $sql = " ANS_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
@@ -12,54 +12,54 @@ |
||
12 | 12 | */ |
13 | 13 | class EE_DMS_4_12_0_Event_Venues extends EE_Data_Migration_Script_Stage_Table |
14 | 14 | { |
15 | - /** |
|
16 | - * @var string |
|
17 | - */ |
|
18 | - private $_event_meta; |
|
15 | + /** |
|
16 | + * @var string |
|
17 | + */ |
|
18 | + private $_event_meta; |
|
19 | 19 | |
20 | 20 | |
21 | - /** |
|
22 | - * Just initializes the status of the migration |
|
23 | - */ |
|
24 | - public function __construct() |
|
25 | - { |
|
26 | - global $wpdb; |
|
27 | - $this->_pretty_name = esc_html__('Event Venue Relations', 'event_espresso'); |
|
28 | - $this->_old_table = $wpdb->prefix . 'esp_event_venue'; |
|
29 | - $this->_event_meta = $wpdb->prefix . 'esp_event_meta'; |
|
30 | - parent::__construct(); |
|
31 | - } |
|
21 | + /** |
|
22 | + * Just initializes the status of the migration |
|
23 | + */ |
|
24 | + public function __construct() |
|
25 | + { |
|
26 | + global $wpdb; |
|
27 | + $this->_pretty_name = esc_html__('Event Venue Relations', 'event_espresso'); |
|
28 | + $this->_old_table = $wpdb->prefix . 'esp_event_venue'; |
|
29 | + $this->_event_meta = $wpdb->prefix . 'esp_event_meta'; |
|
30 | + parent::__construct(); |
|
31 | + } |
|
32 | 32 | |
33 | 33 | |
34 | - /** |
|
35 | - * Copies Venue IDs from `wp_esp_event_venue` to `wp_esp_event_meta` for each Event |
|
36 | - * |
|
37 | - * @param array $old_row an associative array where keys are column names and values are their values. |
|
38 | - * @return null |
|
39 | - */ |
|
40 | - protected function _migrate_old_row($old_row): ?bool |
|
41 | - { |
|
42 | - $EVT_ID = |
|
43 | - isset($old_row['EVT_ID']) |
|
44 | - ? absint($old_row['EVT_ID']) |
|
45 | - : 0; |
|
46 | - $VNU_ID = |
|
47 | - isset($old_row['VNU_ID']) |
|
48 | - ? absint($old_row['VNU_ID']) |
|
49 | - : 0; |
|
50 | - if ($EVT_ID && $VNU_ID) { |
|
51 | - global $wpdb; |
|
52 | - // If the question group was also for primary attendees, we should just update that row. |
|
53 | - // And we delete this row. |
|
54 | - $result = $wpdb->update( |
|
55 | - $this->_event_meta, |
|
56 | - ['VNU_ID' => $VNU_ID], // data |
|
57 | - ['EVT_ID' => $EVT_ID], // where |
|
58 | - ['%d'], // data format |
|
59 | - ['%d'] // where format |
|
60 | - ); |
|
61 | - return filter_var($result, FILTER_VALIDATE_BOOLEAN); |
|
62 | - } |
|
63 | - return false; |
|
64 | - } |
|
34 | + /** |
|
35 | + * Copies Venue IDs from `wp_esp_event_venue` to `wp_esp_event_meta` for each Event |
|
36 | + * |
|
37 | + * @param array $old_row an associative array where keys are column names and values are their values. |
|
38 | + * @return null |
|
39 | + */ |
|
40 | + protected function _migrate_old_row($old_row): ?bool |
|
41 | + { |
|
42 | + $EVT_ID = |
|
43 | + isset($old_row['EVT_ID']) |
|
44 | + ? absint($old_row['EVT_ID']) |
|
45 | + : 0; |
|
46 | + $VNU_ID = |
|
47 | + isset($old_row['VNU_ID']) |
|
48 | + ? absint($old_row['VNU_ID']) |
|
49 | + : 0; |
|
50 | + if ($EVT_ID && $VNU_ID) { |
|
51 | + global $wpdb; |
|
52 | + // If the question group was also for primary attendees, we should just update that row. |
|
53 | + // And we delete this row. |
|
54 | + $result = $wpdb->update( |
|
55 | + $this->_event_meta, |
|
56 | + ['VNU_ID' => $VNU_ID], // data |
|
57 | + ['EVT_ID' => $EVT_ID], // where |
|
58 | + ['%d'], // data format |
|
59 | + ['%d'] // where format |
|
60 | + ); |
|
61 | + return filter_var($result, FILTER_VALIDATE_BOOLEAN); |
|
62 | + } |
|
63 | + return false; |
|
64 | + } |
|
65 | 65 | } |
@@ -25,8 +25,8 @@ discard block |
||
25 | 25 | { |
26 | 26 | global $wpdb; |
27 | 27 | $this->_pretty_name = esc_html__('Event Venue Relations', 'event_espresso'); |
28 | - $this->_old_table = $wpdb->prefix . 'esp_event_venue'; |
|
29 | - $this->_event_meta = $wpdb->prefix . 'esp_event_meta'; |
|
28 | + $this->_old_table = $wpdb->prefix.'esp_event_venue'; |
|
29 | + $this->_event_meta = $wpdb->prefix.'esp_event_meta'; |
|
30 | 30 | parent::__construct(); |
31 | 31 | } |
32 | 32 | |
@@ -53,9 +53,9 @@ discard block |
||
53 | 53 | // And we delete this row. |
54 | 54 | $result = $wpdb->update( |
55 | 55 | $this->_event_meta, |
56 | - ['VNU_ID' => $VNU_ID], // data |
|
57 | - ['EVT_ID' => $EVT_ID], // where |
|
58 | - ['%d'], // data format |
|
56 | + ['VNU_ID' => $VNU_ID], // data |
|
57 | + ['EVT_ID' => $EVT_ID], // where |
|
58 | + ['%d'], // data format |
|
59 | 59 | ['%d'] // where format |
60 | 60 | ); |
61 | 61 | return filter_var($result, FILTER_VALIDATE_BOOLEAN); |
@@ -13,842 +13,842 @@ |
||
13 | 13 | class EEM_Datetime extends EEM_Soft_Delete_Base |
14 | 14 | { |
15 | 15 | |
16 | - /** |
|
17 | - * @var EEM_Datetime $_instance |
|
18 | - */ |
|
19 | - protected static $_instance; |
|
20 | - |
|
21 | - |
|
22 | - /** |
|
23 | - * private constructor to prevent direct creation |
|
24 | - * |
|
25 | - * @param string $timezone A string representing the timezone we want to set for returned Date Time Strings |
|
26 | - * (and any incoming timezone data that gets saved). |
|
27 | - * Note this just sends the timezone info to the date time model field objects. |
|
28 | - * Default is NULL |
|
29 | - * (and will be assumed using the set timezone in the 'timezone_string' wp option) |
|
30 | - * @throws EE_Error |
|
31 | - * @throws InvalidArgumentException |
|
32 | - * @throws InvalidArgumentException |
|
33 | - */ |
|
34 | - protected function __construct($timezone) |
|
35 | - { |
|
36 | - $this->singular_item = esc_html__('Datetime', 'event_espresso'); |
|
37 | - $this->plural_item = esc_html__('Datetimes', 'event_espresso'); |
|
38 | - $this->_tables = [ |
|
39 | - 'Datetime' => new EE_Primary_Table('esp_datetime', 'DTT_ID'), |
|
40 | - ]; |
|
41 | - $this->_fields = [ |
|
42 | - 'Datetime' => [ |
|
43 | - 'DTT_ID' => new EE_Primary_Key_Int_Field( |
|
44 | - 'DTT_ID', |
|
45 | - esc_html__('Datetime ID', 'event_espresso') |
|
46 | - ), |
|
47 | - 'EVT_ID' => new EE_Foreign_Key_Int_Field( |
|
48 | - 'EVT_ID', |
|
49 | - esc_html__('Event ID', 'event_espresso'), |
|
50 | - false, |
|
51 | - 0, |
|
52 | - 'Event' |
|
53 | - ), |
|
54 | - 'VNU_ID' => new EE_Foreign_Key_Int_Field( |
|
55 | - 'VNU_ID', |
|
56 | - __('Venue ID', 'event_espresso'), |
|
57 | - false, |
|
58 | - 0, |
|
59 | - 'Venue' |
|
60 | - ), |
|
61 | - 'DTT_name' => new EE_Plain_Text_Field( |
|
62 | - 'DTT_name', |
|
63 | - esc_html__('Datetime Name', 'event_espresso'), |
|
64 | - false, |
|
65 | - '' |
|
66 | - ), |
|
67 | - 'DTT_description' => new EE_Post_Content_Field( |
|
68 | - 'DTT_description', |
|
69 | - esc_html__('Description for Datetime', 'event_espresso'), |
|
70 | - false, |
|
71 | - '' |
|
72 | - ), |
|
73 | - 'DTT_EVT_start' => new EE_Datetime_Field( |
|
74 | - 'DTT_EVT_start', |
|
75 | - esc_html__('Start time/date of Event', 'event_espresso'), |
|
76 | - false, |
|
77 | - EE_Datetime_Field::now, |
|
78 | - $timezone |
|
79 | - ), |
|
80 | - 'DTT_EVT_end' => new EE_Datetime_Field( |
|
81 | - 'DTT_EVT_end', |
|
82 | - esc_html__('End time/date of Event', 'event_espresso'), |
|
83 | - false, |
|
84 | - EE_Datetime_Field::now, |
|
85 | - $timezone |
|
86 | - ), |
|
87 | - 'DTT_reg_limit' => new EE_Infinite_Integer_Field( |
|
88 | - 'DTT_reg_limit', |
|
89 | - esc_html__('Registration Limit for this time', 'event_espresso'), |
|
90 | - true, |
|
91 | - EE_INF |
|
92 | - ), |
|
93 | - 'DTT_sold' => new EE_Integer_Field( |
|
94 | - 'DTT_sold', |
|
95 | - esc_html__('How many sales for this Datetime that have occurred', 'event_espresso'), |
|
96 | - true, |
|
97 | - 0 |
|
98 | - ), |
|
99 | - 'DTT_reserved' => new EE_Integer_Field( |
|
100 | - 'DTT_reserved', |
|
101 | - esc_html__('Quantity of tickets reserved, but not yet fully purchased', 'event_espresso'), |
|
102 | - false, |
|
103 | - 0 |
|
104 | - ), |
|
105 | - 'DTT_is_primary' => new EE_Boolean_Field( |
|
106 | - 'DTT_is_primary', |
|
107 | - esc_html__('Flag indicating datetime is primary one for event', 'event_espresso'), |
|
108 | - false, |
|
109 | - false |
|
110 | - ), |
|
111 | - 'DTT_order' => new EE_Integer_Field( |
|
112 | - 'DTT_order', |
|
113 | - esc_html__('The order in which the Datetime is displayed', 'event_espresso'), |
|
114 | - false, |
|
115 | - 0 |
|
116 | - ), |
|
117 | - 'DTT_parent' => new EE_Integer_Field( |
|
118 | - 'DTT_parent', |
|
119 | - esc_html__('Indicates what DTT_ID is the parent of this DTT_ID', 'event_espresso'), |
|
120 | - true, |
|
121 | - 0 |
|
122 | - ), |
|
123 | - 'DTT_deleted' => new EE_Trashed_Flag_Field( |
|
124 | - 'DTT_deleted', |
|
125 | - esc_html__('Flag indicating datetime is archived', 'event_espresso'), |
|
126 | - false, |
|
127 | - false |
|
128 | - ), |
|
129 | - ], |
|
130 | - ]; |
|
131 | - $this->_model_relations = [ |
|
132 | - 'Ticket' => new EE_HABTM_Relation('Datetime_Ticket'), |
|
133 | - 'Event' => new EE_Belongs_To_Relation(), |
|
134 | - 'Checkin' => new EE_Has_Many_Relation(), |
|
135 | - 'Datetime_Ticket' => new EE_Has_Many_Relation(), |
|
136 | - 'Venue' => new EE_Belongs_To_Relation(), |
|
137 | - ]; |
|
138 | - $path_to_event_model = 'Event'; |
|
139 | - $this->model_chain_to_password = $path_to_event_model; |
|
140 | - $this->_model_chain_to_wp_user = $path_to_event_model; |
|
141 | - // this model is generally available for reading |
|
142 | - $this->_cap_restriction_generators[ EEM_Base::caps_read ] = |
|
143 | - new EE_Restriction_Generator_Event_Related_Public( |
|
144 | - $path_to_event_model |
|
145 | - ); |
|
146 | - $this->_cap_restriction_generators[ EEM_Base::caps_read_admin ] = |
|
147 | - new EE_Restriction_Generator_Event_Related_Protected( |
|
148 | - $path_to_event_model |
|
149 | - ); |
|
150 | - $this->_cap_restriction_generators[ EEM_Base::caps_edit ] = |
|
151 | - new EE_Restriction_Generator_Event_Related_Protected( |
|
152 | - $path_to_event_model |
|
153 | - ); |
|
154 | - $this->_cap_restriction_generators[ EEM_Base::caps_delete ] = |
|
155 | - new EE_Restriction_Generator_Event_Related_Protected( |
|
156 | - $path_to_event_model, |
|
157 | - EEM_Base::caps_edit |
|
158 | - ); |
|
159 | - parent::__construct($timezone); |
|
160 | - } |
|
161 | - |
|
162 | - |
|
163 | - /** |
|
164 | - * create new blank datetime |
|
165 | - * |
|
166 | - * @access public |
|
167 | - * @return EE_Datetime[] array on success, FALSE on fail |
|
168 | - * @throws EE_Error |
|
169 | - * @throws InvalidArgumentException |
|
170 | - * @throws InvalidDataTypeException |
|
171 | - * @throws ReflectionException |
|
172 | - * @throws InvalidInterfaceException |
|
173 | - */ |
|
174 | - public function create_new_blank_datetime() |
|
175 | - { |
|
176 | - // makes sure timezone is always set. |
|
177 | - $timezone_string = $this->get_timezone(); |
|
178 | - /** |
|
179 | - * Filters the initial start date for the new datetime. |
|
180 | - * Any time included in this value will be overridden later so use additional filters to modify the time. |
|
181 | - * |
|
182 | - * @param int $start_date Unix timestamp representing now + 30 days in seconds. |
|
183 | - * @return int Unix timestamp |
|
184 | - */ |
|
185 | - $start_date = apply_filters( |
|
186 | - 'FHEE__EEM_Datetime__create_new_blank_datetime__start_date', |
|
187 | - $this->current_time_for_query('DTT_EVT_start', true) + MONTH_IN_SECONDS |
|
188 | - ); |
|
189 | - /** |
|
190 | - * Filters the initial end date for the new datetime. |
|
191 | - * Any time included in this value will be overridden later so use additional filters to modify the time. |
|
192 | - * |
|
193 | - * @param int $end_data Unix timestamp representing now + 30 days in seconds. |
|
194 | - * @return int Unix timestamp |
|
195 | - */ |
|
196 | - $end_date = apply_filters( |
|
197 | - 'FHEE__EEM_Datetime__create_new_blank_datetime__end_date', |
|
198 | - $this->current_time_for_query('DTT_EVT_end', true) + MONTH_IN_SECONDS |
|
199 | - ); |
|
200 | - $blank_datetime = EE_Datetime::new_instance( |
|
201 | - [ |
|
202 | - 'DTT_EVT_start' => $start_date, |
|
203 | - 'DTT_EVT_end' => $end_date, |
|
204 | - 'DTT_order' => 1, |
|
205 | - 'DTT_reg_limit' => EE_INF, |
|
206 | - ], |
|
207 | - $timezone_string |
|
208 | - ); |
|
209 | - /** |
|
210 | - * Filters the initial start time and format for the new EE_Datetime instance. |
|
211 | - * |
|
212 | - * @param array $start_time An array having size 2. First element is the time, second element is the time |
|
213 | - * format. |
|
214 | - * @return array |
|
215 | - */ |
|
216 | - $start_time = apply_filters( |
|
217 | - 'FHEE__EEM_Datetime__create_new_blank_datetime__start_time', |
|
218 | - ['8am', 'ga'] |
|
219 | - ); |
|
220 | - /** |
|
221 | - * Filters the initial end time and format for the new EE_Datetime instance. |
|
222 | - * |
|
223 | - * @param array $end_time An array having size 2. First element is the time, second element is the time |
|
224 | - * format |
|
225 | - * @return array |
|
226 | - */ |
|
227 | - $end_time = apply_filters( |
|
228 | - 'FHEE__EEM_Datetime__create_new_blank_datetime__end_time', |
|
229 | - ['5pm', 'ga'] |
|
230 | - ); |
|
231 | - $this->validateStartAndEndTimeForBlankDate($start_time, $end_time); |
|
232 | - $blank_datetime->set_start_time( |
|
233 | - $this->convert_datetime_for_query( |
|
234 | - 'DTT_EVT_start', |
|
235 | - $start_time[0], |
|
236 | - $start_time[1], |
|
237 | - $timezone_string |
|
238 | - ) |
|
239 | - ); |
|
240 | - $blank_datetime->set_end_time( |
|
241 | - $this->convert_datetime_for_query( |
|
242 | - 'DTT_EVT_end', |
|
243 | - $end_time[0], |
|
244 | - $end_time[1], |
|
245 | - $timezone_string |
|
246 | - ) |
|
247 | - ); |
|
248 | - return [$blank_datetime]; |
|
249 | - } |
|
250 | - |
|
251 | - |
|
252 | - /** |
|
253 | - * Validates whether the start_time and end_time are in the expected format. |
|
254 | - * |
|
255 | - * @param array $start_time |
|
256 | - * @param array $end_time |
|
257 | - * @throws InvalidArgumentException |
|
258 | - * @throws InvalidDataTypeException |
|
259 | - */ |
|
260 | - private function validateStartAndEndTimeForBlankDate(array $start_time, array $end_time) |
|
261 | - { |
|
262 | - if (! is_array($start_time)) { |
|
263 | - throw new InvalidDataTypeException('start_time', $start_time, 'array'); |
|
264 | - } |
|
265 | - if (! is_array($end_time)) { |
|
266 | - throw new InvalidDataTypeException('end_time', $end_time, 'array'); |
|
267 | - } |
|
268 | - if (count($start_time) !== 2) { |
|
269 | - throw new InvalidArgumentException( |
|
270 | - sprintf( |
|
271 | - 'The variable %1$s is expected to be an array with two elements. The first item in the ' |
|
272 | - . 'array should be a valid time string, the second item in the array should be a valid time format', |
|
273 | - '$start_time' |
|
274 | - ) |
|
275 | - ); |
|
276 | - } |
|
277 | - if (count($end_time) !== 2) { |
|
278 | - throw new InvalidArgumentException( |
|
279 | - sprintf( |
|
280 | - 'The variable %1$s is expected to be an array with two elements. The first item in the ' |
|
281 | - . 'array should be a valid time string, the second item in the array should be a valid time format', |
|
282 | - '$end_time' |
|
283 | - ) |
|
284 | - ); |
|
285 | - } |
|
286 | - } |
|
287 | - |
|
288 | - |
|
289 | - /** |
|
290 | - * get event start date from db |
|
291 | - * |
|
292 | - * @access public |
|
293 | - * @param int $EVT_ID |
|
294 | - * @return EE_Datetime[] array on success, FALSE on fail |
|
295 | - * @throws EE_Error |
|
296 | - * @throws ReflectionException |
|
297 | - */ |
|
298 | - public function get_all_event_dates($EVT_ID = 0) |
|
299 | - { |
|
300 | - if (! $EVT_ID) { // on add_new_event event_id gets set to 0 |
|
301 | - return $this->create_new_blank_datetime(); |
|
302 | - } |
|
303 | - $results = $this->get_datetimes_for_event_ordered_by_DTT_order($EVT_ID); |
|
304 | - if (empty($results)) { |
|
305 | - return $this->create_new_blank_datetime(); |
|
306 | - } |
|
307 | - return $results; |
|
308 | - } |
|
309 | - |
|
310 | - |
|
311 | - /** |
|
312 | - * get all datetimes attached to an event ordered by the DTT_order field |
|
313 | - * |
|
314 | - * @public |
|
315 | - * @param int $EVT_ID event id |
|
316 | - * @param boolean $include_expired |
|
317 | - * @param boolean $include_deleted |
|
318 | - * @param int $limit If included then limit the count of results by |
|
319 | - * the given number |
|
320 | - * @return EE_Datetime[] |
|
321 | - * @throws EE_Error |
|
322 | - */ |
|
323 | - public function get_datetimes_for_event_ordered_by_DTT_order( |
|
324 | - int $EVT_ID, |
|
325 | - bool $include_expired = true, |
|
326 | - bool $include_deleted = true, |
|
327 | - $limit = 0 |
|
328 | - ) { |
|
329 | - $prev_data_prep_value = $this->prepModelForQuery(); |
|
330 | - $where_params = ['Event.EVT_ID' => absint($EVT_ID)]; |
|
331 | - $query_params[0] = $this->addDefaultWhereParams($where_params, $include_deleted, $include_expired); |
|
332 | - $query_params = $this->addDefaultWhereConditions($query_params); |
|
333 | - $query_params = $this->addDefaultQueryParams($query_params, $limit, 'DTT_order'); |
|
334 | - return $this->getDatetimesAndRestoreModel($query_params, $prev_data_prep_value); |
|
335 | - } |
|
336 | - |
|
337 | - |
|
338 | - /** |
|
339 | - * Gets the datetimes for the event (with the given limit), and orders them by "importance". |
|
340 | - * By importance, we mean that the primary datetimes are most important (DEPRECATED FOR NOW), |
|
341 | - * and then the earlier datetimes are the most important. |
|
342 | - * Maybe we'll want this to take into account datetimes that haven't already passed, but we don't yet. |
|
343 | - * |
|
344 | - * @param int $EVT_ID |
|
345 | - * @param int $limit |
|
346 | - * @return EE_Datetime[]|EE_Base_Class[] |
|
347 | - * @throws EE_Error |
|
348 | - */ |
|
349 | - public function get_datetimes_for_event_ordered_by_importance(int $EVT_ID, $limit = 0) |
|
350 | - { |
|
351 | - $query_params[0] = ['Event.EVT_ID' => absint($EVT_ID)]; |
|
352 | - $query_params = $this->addDefaultWhereConditions($query_params); |
|
353 | - $query_params = $this->addDefaultQueryParams($query_params, $limit); |
|
354 | - return $this->get_all($query_params); |
|
355 | - } |
|
356 | - |
|
357 | - |
|
358 | - /** |
|
359 | - * @param int $EVT_ID |
|
360 | - * @param boolean $include_expired |
|
361 | - * @param boolean $include_deleted |
|
362 | - * @return EE_Datetime |
|
363 | - * @throws EE_Error |
|
364 | - */ |
|
365 | - public function get_oldest_datetime_for_event( |
|
366 | - int $EVT_ID, |
|
367 | - bool $include_expired = false, |
|
368 | - bool $include_deleted = false |
|
369 | - ) { |
|
370 | - $results = $this->get_datetimes_for_event_ordered_by_start_time( |
|
371 | - $EVT_ID, |
|
372 | - $include_expired, |
|
373 | - $include_deleted, |
|
374 | - 1 |
|
375 | - ); |
|
376 | - if ($results) { |
|
377 | - return array_shift($results); |
|
378 | - } |
|
379 | - return null; |
|
380 | - } |
|
381 | - |
|
382 | - |
|
383 | - /** |
|
384 | - * Gets the 'primary' datetime for an event. |
|
385 | - * |
|
386 | - * @param int $EVT_ID |
|
387 | - * @param bool $try_to_exclude_expired |
|
388 | - * @param bool $try_to_exclude_deleted |
|
389 | - * @return EE_Datetime |
|
390 | - * @throws EE_Error |
|
391 | - */ |
|
392 | - public function get_primary_datetime_for_event( |
|
393 | - int $EVT_ID, |
|
394 | - bool $try_to_exclude_expired = true, |
|
395 | - bool $try_to_exclude_deleted = true |
|
396 | - ) { |
|
397 | - if ($try_to_exclude_expired) { |
|
398 | - $non_expired = $this->get_oldest_datetime_for_event($EVT_ID, false, false); |
|
399 | - if ($non_expired) { |
|
400 | - return $non_expired; |
|
401 | - } |
|
402 | - } |
|
403 | - if ($try_to_exclude_deleted) { |
|
404 | - $expired_even = $this->get_oldest_datetime_for_event($EVT_ID, true); |
|
405 | - if ($expired_even) { |
|
406 | - return $expired_even; |
|
407 | - } |
|
408 | - } |
|
409 | - return $this->get_oldest_datetime_for_event($EVT_ID, true, true); |
|
410 | - } |
|
411 | - |
|
412 | - |
|
413 | - /** |
|
414 | - * Gets ALL the datetimes for an event (including trashed ones, for now), ordered |
|
415 | - * only by start date |
|
416 | - * |
|
417 | - * @param int $EVT_ID |
|
418 | - * @param boolean $include_expired |
|
419 | - * @param boolean $include_deleted |
|
420 | - * @param int $limit |
|
421 | - * @return EE_Datetime[] |
|
422 | - * @throws EE_Error |
|
423 | - */ |
|
424 | - public function get_datetimes_for_event_ordered_by_start_time( |
|
425 | - int $EVT_ID, |
|
426 | - bool $include_expired = true, |
|
427 | - bool $include_deleted = true, |
|
428 | - $limit = 0 |
|
429 | - ) { |
|
430 | - $prev_data_prep_value = $this->prepModelForQuery(); |
|
431 | - $where_params = ['Event.EVT_ID' => absint($EVT_ID)]; |
|
432 | - $query_params[0] = $this->addDefaultWhereParams($where_params, $include_deleted, $include_expired); |
|
433 | - $query_params = $this->addDefaultWhereConditions( |
|
434 | - $query_params, |
|
435 | - EEM_Base::default_where_conditions_this_only |
|
436 | - ); |
|
437 | - $query_params = $this->addDefaultQueryParams($query_params, $limit, 'DTT_order'); |
|
438 | - return $this->getDatetimesAndRestoreModel($query_params, $prev_data_prep_value); |
|
439 | - } |
|
440 | - |
|
441 | - |
|
442 | - /** |
|
443 | - * Gets ALL the datetimes for an ticket (including trashed ones, for now), ordered |
|
444 | - * only by start date |
|
445 | - * |
|
446 | - * @param int $TKT_ID |
|
447 | - * @param boolean $include_expired |
|
448 | - * @param boolean $include_deleted |
|
449 | - * @param int $limit |
|
450 | - * @return EE_Datetime[] |
|
451 | - * @throws EE_Error |
|
452 | - */ |
|
453 | - public function get_datetimes_for_ticket_ordered_by_start_time( |
|
454 | - int $TKT_ID, |
|
455 | - bool $include_expired = true, |
|
456 | - bool $include_deleted = true, |
|
457 | - $limit = 0 |
|
458 | - ) { |
|
459 | - $prev_data_prep_value = $this->prepModelForQuery(); |
|
460 | - $where_params = ['Ticket.TKT_ID' => absint($TKT_ID)]; |
|
461 | - $query_params[0] = $this->addDefaultWhereParams($where_params, $include_deleted, $include_expired); |
|
462 | - $query_params = $this->addDefaultQueryParams($query_params, $limit); |
|
463 | - return $this->getDatetimesAndRestoreModel($query_params, $prev_data_prep_value); |
|
464 | - } |
|
465 | - |
|
466 | - |
|
467 | - /** |
|
468 | - * Gets all the datetimes for a ticket (including trashed ones, for now), ordered by the DTT_order for the |
|
469 | - * datetimes. |
|
470 | - * |
|
471 | - * @param int $TKT_ID ID of ticket to retrieve the datetimes for |
|
472 | - * @param boolean $include_expired whether to include expired datetimes or not |
|
473 | - * @param boolean $include_deleted whether to include trashed datetimes or not. |
|
474 | - * @param int|null $limit if null, no limit, if int then limit results by |
|
475 | - * that number |
|
476 | - * @return EE_Datetime[] |
|
477 | - * @throws EE_Error |
|
478 | - */ |
|
479 | - public function get_datetimes_for_ticket_ordered_by_DTT_order( |
|
480 | - int $TKT_ID, |
|
481 | - bool $include_expired = true, |
|
482 | - bool $include_deleted = true, |
|
483 | - $limit = 0 |
|
484 | - ) { |
|
485 | - $prev_data_prep_value = $this->prepModelForQuery(); |
|
486 | - $where_params = ['Ticket.TKT_ID' => absint($TKT_ID)]; |
|
487 | - $query_params[0] = $this->addDefaultWhereParams($where_params, $include_deleted, $include_expired); |
|
488 | - $query_params = $this->addDefaultQueryParams($query_params, $limit, 'DTT_order'); |
|
489 | - return $this->getDatetimesAndRestoreModel($query_params, $prev_data_prep_value); |
|
490 | - } |
|
491 | - |
|
492 | - |
|
493 | - /** |
|
494 | - * Gets the most important datetime for a particular event (ie, the primary event usually. But if for some WACK |
|
495 | - * reason it doesn't exist, we consider the earliest event the most important) |
|
496 | - * |
|
497 | - * @param int $EVT_ID |
|
498 | - * @return EE_Datetime |
|
499 | - * @throws EE_Error |
|
500 | - */ |
|
501 | - public function get_most_important_datetime_for_event(int $EVT_ID) |
|
502 | - { |
|
503 | - $results = $this->get_datetimes_for_event_ordered_by_importance($EVT_ID, 1); |
|
504 | - if ($results) { |
|
505 | - return array_shift($results); |
|
506 | - } |
|
507 | - return null; |
|
508 | - } |
|
509 | - |
|
510 | - |
|
511 | - /** |
|
512 | - * This returns a wpdb->results Array of all DTT month and years matching the incoming query params and |
|
513 | - * grouped by month and year. |
|
514 | - * |
|
515 | - * @param array $where_params @see |
|
516 | - * https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md#0-where-conditions |
|
517 | - * @param string $evt_active_status A string representing the evt active status to filter the months by. |
|
518 | - * Can be: |
|
519 | - * - '' = no filter |
|
520 | - * - upcoming = Published events with at least one upcoming datetime. |
|
521 | - * - expired = Events with all datetimes expired. |
|
522 | - * - active = Events that are published and have at least one datetime that |
|
523 | - * starts before now and ends after now. |
|
524 | - * - inactive = Events that are either not published. |
|
525 | - * @return EE_Base_Class[] |
|
526 | - * @throws EE_Error |
|
527 | - * @throws InvalidArgumentException |
|
528 | - * @throws InvalidArgumentException |
|
529 | - */ |
|
530 | - public function get_dtt_months_and_years(array $where_params, $evt_active_status = '') |
|
531 | - { |
|
532 | - $current_time_for_DTT_EVT_start = $this->current_time_for_query('DTT_EVT_start'); |
|
533 | - $current_time_for_DTT_EVT_end = $this->current_time_for_query('DTT_EVT_end'); |
|
534 | - switch ($evt_active_status) { |
|
535 | - case 'upcoming': |
|
536 | - $where_params['Event.status'] = 'publish'; |
|
537 | - // if there are already query_params matching DTT_EVT_start then we need to modify that to add them. |
|
538 | - if (isset($where_params['DTT_EVT_start'])) { |
|
539 | - $where_params['DTT_EVT_start*****'] = $where_params['DTT_EVT_start']; |
|
540 | - } |
|
541 | - $where_params['DTT_EVT_start'] = ['>', $current_time_for_DTT_EVT_start]; |
|
542 | - break; |
|
543 | - case 'expired': |
|
544 | - if (isset($where_params['Event.status'])) { |
|
545 | - unset($where_params['Event.status']); |
|
546 | - } |
|
547 | - // get events to exclude |
|
548 | - $exclude_query[0] = array_merge( |
|
549 | - $where_params, |
|
550 | - ['DTT_EVT_end' => ['>', $current_time_for_DTT_EVT_end]] |
|
551 | - ); |
|
552 | - // first get all events that have datetimes where its not expired. |
|
553 | - $event_ids = $this->_get_all_wpdb_results( |
|
554 | - $exclude_query, |
|
555 | - OBJECT_K, |
|
556 | - 'Datetime.EVT_ID' |
|
557 | - ); |
|
558 | - $event_ids = array_keys($event_ids); |
|
559 | - if (isset($where_params['DTT_EVT_end'])) { |
|
560 | - $where_params['DTT_EVT_end****'] = $where_params['DTT_EVT_end']; |
|
561 | - } |
|
562 | - $where_params['DTT_EVT_end'] = ['<', $current_time_for_DTT_EVT_end]; |
|
563 | - $where_params['Event.EVT_ID'] = ['NOT IN', $event_ids]; |
|
564 | - break; |
|
565 | - case 'active': |
|
566 | - $where_params['Event.status'] = 'publish'; |
|
567 | - if (isset($where_params['DTT_EVT_start'])) { |
|
568 | - $where_params['Datetime.DTT_EVT_start******'] = $where_params['DTT_EVT_start']; |
|
569 | - } |
|
570 | - if (isset($where_params['Datetime.DTT_EVT_end'])) { |
|
571 | - $where_params['Datetime.DTT_EVT_end*****'] = $where_params['DTT_EVT_end']; |
|
572 | - } |
|
573 | - $where_params['DTT_EVT_start'] = ['<', $current_time_for_DTT_EVT_start]; |
|
574 | - $where_params['DTT_EVT_end'] = ['>', $current_time_for_DTT_EVT_end]; |
|
575 | - break; |
|
576 | - case 'inactive': |
|
577 | - if (isset($where_params['Event.status'])) { |
|
578 | - unset($where_params['Event.status']); |
|
579 | - } |
|
580 | - if (isset($where_params['OR'])) { |
|
581 | - $where_params['AND']['OR'] = $where_params['OR']; |
|
582 | - } |
|
583 | - if (isset($where_params['DTT_EVT_end'])) { |
|
584 | - $where_params['AND']['DTT_EVT_end****'] = $where_params['DTT_EVT_end']; |
|
585 | - unset($where_params['DTT_EVT_end']); |
|
586 | - } |
|
587 | - if (isset($where_params['DTT_EVT_start'])) { |
|
588 | - $where_params['AND']['DTT_EVT_start'] = $where_params['DTT_EVT_start']; |
|
589 | - unset($where_params['DTT_EVT_start']); |
|
590 | - } |
|
591 | - $where_params['AND']['Event.status'] = ['!=', 'publish']; |
|
592 | - break; |
|
593 | - } |
|
594 | - $query_params[0] = $where_params; |
|
595 | - $query_params['group_by'] = ['dtt_year', 'dtt_month']; |
|
596 | - $query_params = $this->addOrderByQueryParams($query_params, 'DTT_EVT_start', 'DESC'); |
|
597 | - |
|
598 | - $query_interval = EEH_DTT_Helper::get_sql_query_interval_for_offset( |
|
599 | - $this->get_timezone(), |
|
600 | - 'DTT_EVT_start' |
|
601 | - ); |
|
602 | - $columns_to_select = [ |
|
603 | - 'dtt_year' => ['YEAR(' . $query_interval . ')', '%s'], |
|
604 | - 'dtt_month' => ['MONTHNAME(' . $query_interval . ')', '%s'], |
|
605 | - 'dtt_month_num' => ['MONTH(' . $query_interval . ')', '%s'], |
|
606 | - ]; |
|
607 | - return $this->_get_all_wpdb_results($query_params, OBJECT, $columns_to_select); |
|
608 | - } |
|
609 | - |
|
610 | - |
|
611 | - /** |
|
612 | - * Updates the DTT_sold attribute on each datetime (based on the registrations |
|
613 | - * for the tickets for each datetime) |
|
614 | - * |
|
615 | - * @param EE_Base_Class[]|EE_Datetime[] $datetimes |
|
616 | - * @throws EE_Error |
|
617 | - * @throws ReflectionException |
|
618 | - */ |
|
619 | - public function update_sold(array $datetimes) |
|
620 | - { |
|
621 | - EE_Error::doing_it_wrong( |
|
622 | - __FUNCTION__, |
|
623 | - esc_html__( |
|
624 | - 'Please use \EEM_Ticket::update_tickets_sold() instead which will in turn correctly update both the Ticket AND Datetime counts.', |
|
625 | - 'event_espresso' |
|
626 | - ), |
|
627 | - '4.9.32.rc.005' |
|
628 | - ); |
|
629 | - foreach ($datetimes as $datetime) { |
|
630 | - $datetime->update_sold(); |
|
631 | - } |
|
632 | - } |
|
633 | - |
|
634 | - |
|
635 | - /** |
|
636 | - * Gets the total number of tickets available at a particular datetime |
|
637 | - * (does NOT take into account the datetime's spaces available) |
|
638 | - * |
|
639 | - * @param int $DTT_ID |
|
640 | - * @param array $query_params |
|
641 | - * @return int of tickets available. If sold out, return less than 1. If infinite, returns EE_INF, IF there are NO |
|
642 | - * tickets attached to datetime then FALSE is returned. |
|
643 | - * @throws EE_Error |
|
644 | - * @throws ReflectionException |
|
645 | - */ |
|
646 | - public function sum_tickets_currently_available_at_datetime(int $DTT_ID, array $query_params = []) |
|
647 | - { |
|
648 | - $datetime = $this->get_one_by_ID($DTT_ID); |
|
649 | - if ($datetime instanceof EE_Datetime) { |
|
650 | - return $datetime->tickets_remaining($query_params); |
|
651 | - } |
|
652 | - return 0; |
|
653 | - } |
|
654 | - |
|
655 | - |
|
656 | - /** |
|
657 | - * This returns an array of counts of datetimes in the database for each Datetime status that can be queried. |
|
658 | - * |
|
659 | - * @param array $stati_to_include If included you can restrict the statuses we return counts for by including the |
|
660 | - * stati you want counts for as values in the array. An empty array returns counts |
|
661 | - * for all valid stati. |
|
662 | - * @param array $query_params If included can be used to refine the conditions for returning the count (i.e. |
|
663 | - * only for Datetimes connected to a specific event, or specific ticket. |
|
664 | - * @return array The value returned is an array indexed by Datetime Status and the values are the counts. The |
|
665 | - * @throws EE_Error |
|
666 | - * stati used as index keys are: EE_Datetime::active EE_Datetime::upcoming |
|
667 | - * EE_Datetime::expired |
|
668 | - */ |
|
669 | - public function get_datetime_counts_by_status(array $stati_to_include = [], array $query_params = []) |
|
670 | - { |
|
671 | - // only accept where conditions for this query. |
|
672 | - $_where = isset($query_params[0]) ? $query_params[0] : []; |
|
673 | - $status_query_args = [ |
|
674 | - EE_Datetime::active => array_merge( |
|
675 | - $_where, |
|
676 | - ['DTT_EVT_start' => ['<', time()], 'DTT_EVT_end' => ['>', time()]] |
|
677 | - ), |
|
678 | - EE_Datetime::upcoming => array_merge( |
|
679 | - $_where, |
|
680 | - ['DTT_EVT_start' => ['>', time()]] |
|
681 | - ), |
|
682 | - EE_Datetime::expired => array_merge( |
|
683 | - $_where, |
|
684 | - ['DTT_EVT_end' => ['<', time()]] |
|
685 | - ), |
|
686 | - ]; |
|
687 | - if (! empty($stati_to_include)) { |
|
688 | - foreach (array_keys($status_query_args) as $status) { |
|
689 | - if (! in_array($status, $stati_to_include, true)) { |
|
690 | - unset($status_query_args[ $status ]); |
|
691 | - } |
|
692 | - } |
|
693 | - } |
|
694 | - // loop through and query counts for each stati. |
|
695 | - $status_query_results = []; |
|
696 | - foreach ($status_query_args as $status => $status_where_conditions) { |
|
697 | - $status_query_results[ $status ] = EEM_Datetime::count( |
|
698 | - [$status_where_conditions], |
|
699 | - 'DTT_ID', |
|
700 | - true |
|
701 | - ); |
|
702 | - } |
|
703 | - return $status_query_results; |
|
704 | - } |
|
705 | - |
|
706 | - |
|
707 | - /** |
|
708 | - * Returns the specific count for a given Datetime status matching any given query_params. |
|
709 | - * |
|
710 | - * @param string $status Valid string representation for Datetime status requested. (Defaults to Active). |
|
711 | - * @param array $query_params |
|
712 | - * @return int |
|
713 | - * @throws EE_Error |
|
714 | - */ |
|
715 | - public function get_datetime_count_for_status($status = EE_Datetime::active, array $query_params = []) |
|
716 | - { |
|
717 | - $count = $this->get_datetime_counts_by_status([$status], $query_params); |
|
718 | - return ! empty($count[ $status ]) ? $count[ $status ] : 0; |
|
719 | - } |
|
720 | - |
|
721 | - |
|
722 | - /** |
|
723 | - * @return bool|int |
|
724 | - * @since $VID:$ |
|
725 | - */ |
|
726 | - private function prepModelForQuery() |
|
727 | - { |
|
728 | - $prev_data_prep_value = $this->get_assumption_concerning_values_already_prepared_by_model_object(); |
|
729 | - $this->assume_values_already_prepared_by_model_object(EEM_Base::prepared_for_use_in_db); |
|
730 | - return $prev_data_prep_value; |
|
731 | - } |
|
732 | - |
|
733 | - |
|
734 | - /** |
|
735 | - * @param array $query_params |
|
736 | - * @param bool|int $prev_data_prep_value |
|
737 | - * @return EE_Base_Class[]|EE_Datetime[] |
|
738 | - * @throws EE_Error |
|
739 | - * @since $VID:$ |
|
740 | - */ |
|
741 | - private function getDatetimesAndRestoreModel(array $query_params, $prev_data_prep_value) |
|
742 | - { |
|
743 | - $result = $this->get_all($query_params); |
|
744 | - $this->assume_values_already_prepared_by_model_object($prev_data_prep_value); |
|
745 | - return $result; |
|
746 | - } |
|
747 | - |
|
748 | - |
|
749 | - /** |
|
750 | - * @param array $query_params |
|
751 | - * @param int $limit |
|
752 | - * @param string $order_by |
|
753 | - * @param string $order |
|
754 | - * @return array |
|
755 | - * @since $VID:$ |
|
756 | - */ |
|
757 | - private function addDefaultQueryParams(array $query_params, $limit = 0, $order_by = 'DTT_EVT_start', $order = 'ASC') |
|
758 | - { |
|
759 | - $query_params = $this->addOrderByQueryParams($query_params, $order_by, $order); |
|
760 | - $query_params = $this->addLimitQueryParams($query_params, $limit); |
|
761 | - return $query_params; |
|
762 | - } |
|
763 | - |
|
764 | - |
|
765 | - /** |
|
766 | - * @param array $query_params |
|
767 | - * @param string $default_where_conditions |
|
768 | - * @return array |
|
769 | - * @since $VID:$ |
|
770 | - */ |
|
771 | - private function addDefaultWhereConditions( |
|
772 | - array $query_params, |
|
773 | - $default_where_conditions = EEM_Base::default_where_conditions_none |
|
774 | - ) { |
|
775 | - $query_params['default_where_conditions'] = $default_where_conditions; |
|
776 | - return $query_params; |
|
777 | - } |
|
778 | - |
|
779 | - |
|
780 | - /** |
|
781 | - * @param array $where_params |
|
782 | - * @param bool $include_deleted |
|
783 | - * @param bool $include_expired |
|
784 | - * @return array |
|
785 | - * @since $VID:$ |
|
786 | - */ |
|
787 | - private function addDefaultWhereParams(array $where_params, bool $include_deleted = true, bool $include_expired = true) |
|
788 | - { |
|
789 | - $where_params = $this->addExpiredWhereParams($where_params, $include_expired); |
|
790 | - $where_params = $this->addDeletedWhereParams($where_params, $include_deleted); |
|
791 | - return $where_params; |
|
792 | - } |
|
793 | - |
|
794 | - |
|
795 | - /** |
|
796 | - * @param array $where_params |
|
797 | - * @param bool $include_deleted |
|
798 | - * @return array |
|
799 | - * @since $VID:$ |
|
800 | - */ |
|
801 | - private function addDeletedWhereParams(array $where_params, bool $include_deleted = true) |
|
802 | - { |
|
803 | - $deleted = $include_deleted ? [true, false] : [false]; |
|
804 | - $where_params['DTT_deleted'] = ['IN', $deleted]; |
|
805 | - return $where_params; |
|
806 | - } |
|
807 | - |
|
808 | - |
|
809 | - /** |
|
810 | - * @param array $where_params |
|
811 | - * @param bool $include_expired |
|
812 | - * @return array |
|
813 | - * @since $VID:$ |
|
814 | - */ |
|
815 | - private function addExpiredWhereParams(array $where_params, bool $include_expired = true) |
|
816 | - { |
|
817 | - if (! $include_expired) { |
|
818 | - $where_params['DTT_EVT_end'] = ['>=', current_time('mysql', true)]; |
|
819 | - } |
|
820 | - return $where_params; |
|
821 | - } |
|
822 | - |
|
823 | - |
|
824 | - /** |
|
825 | - * @param array $query_params |
|
826 | - * @param int $limit |
|
827 | - * @return array |
|
828 | - * @since $VID:$ |
|
829 | - */ |
|
830 | - private function addLimitQueryParams(array $query_params, $limit = 0) |
|
831 | - { |
|
832 | - if ($limit) { |
|
833 | - $query_params['limit'] = $limit; |
|
834 | - } |
|
835 | - return $query_params; |
|
836 | - } |
|
837 | - |
|
838 | - |
|
839 | - /** |
|
840 | - * @param array $query_params |
|
841 | - * @param string $order_by |
|
842 | - * @param string $order |
|
843 | - * @return array |
|
844 | - * @since $VID:$ |
|
845 | - */ |
|
846 | - private function addOrderByQueryParams(array $query_params, $order_by = 'DTT_EVT_start', $order = 'ASC') |
|
847 | - { |
|
848 | - $order = $order === 'ASC' ? 'ASC' : 'DESC'; |
|
849 | - $valid_order_columns = ['DTT_ID', 'DTT_EVT_start', 'DTT_EVT_end', 'DTT_order']; |
|
850 | - $order_by = in_array($order_by, $valid_order_columns, true) ? $order_by : 'DTT_EVT_start'; |
|
851 | - $query_params['order_by'] = [$order_by => $order]; |
|
852 | - return $query_params; |
|
853 | - } |
|
16 | + /** |
|
17 | + * @var EEM_Datetime $_instance |
|
18 | + */ |
|
19 | + protected static $_instance; |
|
20 | + |
|
21 | + |
|
22 | + /** |
|
23 | + * private constructor to prevent direct creation |
|
24 | + * |
|
25 | + * @param string $timezone A string representing the timezone we want to set for returned Date Time Strings |
|
26 | + * (and any incoming timezone data that gets saved). |
|
27 | + * Note this just sends the timezone info to the date time model field objects. |
|
28 | + * Default is NULL |
|
29 | + * (and will be assumed using the set timezone in the 'timezone_string' wp option) |
|
30 | + * @throws EE_Error |
|
31 | + * @throws InvalidArgumentException |
|
32 | + * @throws InvalidArgumentException |
|
33 | + */ |
|
34 | + protected function __construct($timezone) |
|
35 | + { |
|
36 | + $this->singular_item = esc_html__('Datetime', 'event_espresso'); |
|
37 | + $this->plural_item = esc_html__('Datetimes', 'event_espresso'); |
|
38 | + $this->_tables = [ |
|
39 | + 'Datetime' => new EE_Primary_Table('esp_datetime', 'DTT_ID'), |
|
40 | + ]; |
|
41 | + $this->_fields = [ |
|
42 | + 'Datetime' => [ |
|
43 | + 'DTT_ID' => new EE_Primary_Key_Int_Field( |
|
44 | + 'DTT_ID', |
|
45 | + esc_html__('Datetime ID', 'event_espresso') |
|
46 | + ), |
|
47 | + 'EVT_ID' => new EE_Foreign_Key_Int_Field( |
|
48 | + 'EVT_ID', |
|
49 | + esc_html__('Event ID', 'event_espresso'), |
|
50 | + false, |
|
51 | + 0, |
|
52 | + 'Event' |
|
53 | + ), |
|
54 | + 'VNU_ID' => new EE_Foreign_Key_Int_Field( |
|
55 | + 'VNU_ID', |
|
56 | + __('Venue ID', 'event_espresso'), |
|
57 | + false, |
|
58 | + 0, |
|
59 | + 'Venue' |
|
60 | + ), |
|
61 | + 'DTT_name' => new EE_Plain_Text_Field( |
|
62 | + 'DTT_name', |
|
63 | + esc_html__('Datetime Name', 'event_espresso'), |
|
64 | + false, |
|
65 | + '' |
|
66 | + ), |
|
67 | + 'DTT_description' => new EE_Post_Content_Field( |
|
68 | + 'DTT_description', |
|
69 | + esc_html__('Description for Datetime', 'event_espresso'), |
|
70 | + false, |
|
71 | + '' |
|
72 | + ), |
|
73 | + 'DTT_EVT_start' => new EE_Datetime_Field( |
|
74 | + 'DTT_EVT_start', |
|
75 | + esc_html__('Start time/date of Event', 'event_espresso'), |
|
76 | + false, |
|
77 | + EE_Datetime_Field::now, |
|
78 | + $timezone |
|
79 | + ), |
|
80 | + 'DTT_EVT_end' => new EE_Datetime_Field( |
|
81 | + 'DTT_EVT_end', |
|
82 | + esc_html__('End time/date of Event', 'event_espresso'), |
|
83 | + false, |
|
84 | + EE_Datetime_Field::now, |
|
85 | + $timezone |
|
86 | + ), |
|
87 | + 'DTT_reg_limit' => new EE_Infinite_Integer_Field( |
|
88 | + 'DTT_reg_limit', |
|
89 | + esc_html__('Registration Limit for this time', 'event_espresso'), |
|
90 | + true, |
|
91 | + EE_INF |
|
92 | + ), |
|
93 | + 'DTT_sold' => new EE_Integer_Field( |
|
94 | + 'DTT_sold', |
|
95 | + esc_html__('How many sales for this Datetime that have occurred', 'event_espresso'), |
|
96 | + true, |
|
97 | + 0 |
|
98 | + ), |
|
99 | + 'DTT_reserved' => new EE_Integer_Field( |
|
100 | + 'DTT_reserved', |
|
101 | + esc_html__('Quantity of tickets reserved, but not yet fully purchased', 'event_espresso'), |
|
102 | + false, |
|
103 | + 0 |
|
104 | + ), |
|
105 | + 'DTT_is_primary' => new EE_Boolean_Field( |
|
106 | + 'DTT_is_primary', |
|
107 | + esc_html__('Flag indicating datetime is primary one for event', 'event_espresso'), |
|
108 | + false, |
|
109 | + false |
|
110 | + ), |
|
111 | + 'DTT_order' => new EE_Integer_Field( |
|
112 | + 'DTT_order', |
|
113 | + esc_html__('The order in which the Datetime is displayed', 'event_espresso'), |
|
114 | + false, |
|
115 | + 0 |
|
116 | + ), |
|
117 | + 'DTT_parent' => new EE_Integer_Field( |
|
118 | + 'DTT_parent', |
|
119 | + esc_html__('Indicates what DTT_ID is the parent of this DTT_ID', 'event_espresso'), |
|
120 | + true, |
|
121 | + 0 |
|
122 | + ), |
|
123 | + 'DTT_deleted' => new EE_Trashed_Flag_Field( |
|
124 | + 'DTT_deleted', |
|
125 | + esc_html__('Flag indicating datetime is archived', 'event_espresso'), |
|
126 | + false, |
|
127 | + false |
|
128 | + ), |
|
129 | + ], |
|
130 | + ]; |
|
131 | + $this->_model_relations = [ |
|
132 | + 'Ticket' => new EE_HABTM_Relation('Datetime_Ticket'), |
|
133 | + 'Event' => new EE_Belongs_To_Relation(), |
|
134 | + 'Checkin' => new EE_Has_Many_Relation(), |
|
135 | + 'Datetime_Ticket' => new EE_Has_Many_Relation(), |
|
136 | + 'Venue' => new EE_Belongs_To_Relation(), |
|
137 | + ]; |
|
138 | + $path_to_event_model = 'Event'; |
|
139 | + $this->model_chain_to_password = $path_to_event_model; |
|
140 | + $this->_model_chain_to_wp_user = $path_to_event_model; |
|
141 | + // this model is generally available for reading |
|
142 | + $this->_cap_restriction_generators[ EEM_Base::caps_read ] = |
|
143 | + new EE_Restriction_Generator_Event_Related_Public( |
|
144 | + $path_to_event_model |
|
145 | + ); |
|
146 | + $this->_cap_restriction_generators[ EEM_Base::caps_read_admin ] = |
|
147 | + new EE_Restriction_Generator_Event_Related_Protected( |
|
148 | + $path_to_event_model |
|
149 | + ); |
|
150 | + $this->_cap_restriction_generators[ EEM_Base::caps_edit ] = |
|
151 | + new EE_Restriction_Generator_Event_Related_Protected( |
|
152 | + $path_to_event_model |
|
153 | + ); |
|
154 | + $this->_cap_restriction_generators[ EEM_Base::caps_delete ] = |
|
155 | + new EE_Restriction_Generator_Event_Related_Protected( |
|
156 | + $path_to_event_model, |
|
157 | + EEM_Base::caps_edit |
|
158 | + ); |
|
159 | + parent::__construct($timezone); |
|
160 | + } |
|
161 | + |
|
162 | + |
|
163 | + /** |
|
164 | + * create new blank datetime |
|
165 | + * |
|
166 | + * @access public |
|
167 | + * @return EE_Datetime[] array on success, FALSE on fail |
|
168 | + * @throws EE_Error |
|
169 | + * @throws InvalidArgumentException |
|
170 | + * @throws InvalidDataTypeException |
|
171 | + * @throws ReflectionException |
|
172 | + * @throws InvalidInterfaceException |
|
173 | + */ |
|
174 | + public function create_new_blank_datetime() |
|
175 | + { |
|
176 | + // makes sure timezone is always set. |
|
177 | + $timezone_string = $this->get_timezone(); |
|
178 | + /** |
|
179 | + * Filters the initial start date for the new datetime. |
|
180 | + * Any time included in this value will be overridden later so use additional filters to modify the time. |
|
181 | + * |
|
182 | + * @param int $start_date Unix timestamp representing now + 30 days in seconds. |
|
183 | + * @return int Unix timestamp |
|
184 | + */ |
|
185 | + $start_date = apply_filters( |
|
186 | + 'FHEE__EEM_Datetime__create_new_blank_datetime__start_date', |
|
187 | + $this->current_time_for_query('DTT_EVT_start', true) + MONTH_IN_SECONDS |
|
188 | + ); |
|
189 | + /** |
|
190 | + * Filters the initial end date for the new datetime. |
|
191 | + * Any time included in this value will be overridden later so use additional filters to modify the time. |
|
192 | + * |
|
193 | + * @param int $end_data Unix timestamp representing now + 30 days in seconds. |
|
194 | + * @return int Unix timestamp |
|
195 | + */ |
|
196 | + $end_date = apply_filters( |
|
197 | + 'FHEE__EEM_Datetime__create_new_blank_datetime__end_date', |
|
198 | + $this->current_time_for_query('DTT_EVT_end', true) + MONTH_IN_SECONDS |
|
199 | + ); |
|
200 | + $blank_datetime = EE_Datetime::new_instance( |
|
201 | + [ |
|
202 | + 'DTT_EVT_start' => $start_date, |
|
203 | + 'DTT_EVT_end' => $end_date, |
|
204 | + 'DTT_order' => 1, |
|
205 | + 'DTT_reg_limit' => EE_INF, |
|
206 | + ], |
|
207 | + $timezone_string |
|
208 | + ); |
|
209 | + /** |
|
210 | + * Filters the initial start time and format for the new EE_Datetime instance. |
|
211 | + * |
|
212 | + * @param array $start_time An array having size 2. First element is the time, second element is the time |
|
213 | + * format. |
|
214 | + * @return array |
|
215 | + */ |
|
216 | + $start_time = apply_filters( |
|
217 | + 'FHEE__EEM_Datetime__create_new_blank_datetime__start_time', |
|
218 | + ['8am', 'ga'] |
|
219 | + ); |
|
220 | + /** |
|
221 | + * Filters the initial end time and format for the new EE_Datetime instance. |
|
222 | + * |
|
223 | + * @param array $end_time An array having size 2. First element is the time, second element is the time |
|
224 | + * format |
|
225 | + * @return array |
|
226 | + */ |
|
227 | + $end_time = apply_filters( |
|
228 | + 'FHEE__EEM_Datetime__create_new_blank_datetime__end_time', |
|
229 | + ['5pm', 'ga'] |
|
230 | + ); |
|
231 | + $this->validateStartAndEndTimeForBlankDate($start_time, $end_time); |
|
232 | + $blank_datetime->set_start_time( |
|
233 | + $this->convert_datetime_for_query( |
|
234 | + 'DTT_EVT_start', |
|
235 | + $start_time[0], |
|
236 | + $start_time[1], |
|
237 | + $timezone_string |
|
238 | + ) |
|
239 | + ); |
|
240 | + $blank_datetime->set_end_time( |
|
241 | + $this->convert_datetime_for_query( |
|
242 | + 'DTT_EVT_end', |
|
243 | + $end_time[0], |
|
244 | + $end_time[1], |
|
245 | + $timezone_string |
|
246 | + ) |
|
247 | + ); |
|
248 | + return [$blank_datetime]; |
|
249 | + } |
|
250 | + |
|
251 | + |
|
252 | + /** |
|
253 | + * Validates whether the start_time and end_time are in the expected format. |
|
254 | + * |
|
255 | + * @param array $start_time |
|
256 | + * @param array $end_time |
|
257 | + * @throws InvalidArgumentException |
|
258 | + * @throws InvalidDataTypeException |
|
259 | + */ |
|
260 | + private function validateStartAndEndTimeForBlankDate(array $start_time, array $end_time) |
|
261 | + { |
|
262 | + if (! is_array($start_time)) { |
|
263 | + throw new InvalidDataTypeException('start_time', $start_time, 'array'); |
|
264 | + } |
|
265 | + if (! is_array($end_time)) { |
|
266 | + throw new InvalidDataTypeException('end_time', $end_time, 'array'); |
|
267 | + } |
|
268 | + if (count($start_time) !== 2) { |
|
269 | + throw new InvalidArgumentException( |
|
270 | + sprintf( |
|
271 | + 'The variable %1$s is expected to be an array with two elements. The first item in the ' |
|
272 | + . 'array should be a valid time string, the second item in the array should be a valid time format', |
|
273 | + '$start_time' |
|
274 | + ) |
|
275 | + ); |
|
276 | + } |
|
277 | + if (count($end_time) !== 2) { |
|
278 | + throw new InvalidArgumentException( |
|
279 | + sprintf( |
|
280 | + 'The variable %1$s is expected to be an array with two elements. The first item in the ' |
|
281 | + . 'array should be a valid time string, the second item in the array should be a valid time format', |
|
282 | + '$end_time' |
|
283 | + ) |
|
284 | + ); |
|
285 | + } |
|
286 | + } |
|
287 | + |
|
288 | + |
|
289 | + /** |
|
290 | + * get event start date from db |
|
291 | + * |
|
292 | + * @access public |
|
293 | + * @param int $EVT_ID |
|
294 | + * @return EE_Datetime[] array on success, FALSE on fail |
|
295 | + * @throws EE_Error |
|
296 | + * @throws ReflectionException |
|
297 | + */ |
|
298 | + public function get_all_event_dates($EVT_ID = 0) |
|
299 | + { |
|
300 | + if (! $EVT_ID) { // on add_new_event event_id gets set to 0 |
|
301 | + return $this->create_new_blank_datetime(); |
|
302 | + } |
|
303 | + $results = $this->get_datetimes_for_event_ordered_by_DTT_order($EVT_ID); |
|
304 | + if (empty($results)) { |
|
305 | + return $this->create_new_blank_datetime(); |
|
306 | + } |
|
307 | + return $results; |
|
308 | + } |
|
309 | + |
|
310 | + |
|
311 | + /** |
|
312 | + * get all datetimes attached to an event ordered by the DTT_order field |
|
313 | + * |
|
314 | + * @public |
|
315 | + * @param int $EVT_ID event id |
|
316 | + * @param boolean $include_expired |
|
317 | + * @param boolean $include_deleted |
|
318 | + * @param int $limit If included then limit the count of results by |
|
319 | + * the given number |
|
320 | + * @return EE_Datetime[] |
|
321 | + * @throws EE_Error |
|
322 | + */ |
|
323 | + public function get_datetimes_for_event_ordered_by_DTT_order( |
|
324 | + int $EVT_ID, |
|
325 | + bool $include_expired = true, |
|
326 | + bool $include_deleted = true, |
|
327 | + $limit = 0 |
|
328 | + ) { |
|
329 | + $prev_data_prep_value = $this->prepModelForQuery(); |
|
330 | + $where_params = ['Event.EVT_ID' => absint($EVT_ID)]; |
|
331 | + $query_params[0] = $this->addDefaultWhereParams($where_params, $include_deleted, $include_expired); |
|
332 | + $query_params = $this->addDefaultWhereConditions($query_params); |
|
333 | + $query_params = $this->addDefaultQueryParams($query_params, $limit, 'DTT_order'); |
|
334 | + return $this->getDatetimesAndRestoreModel($query_params, $prev_data_prep_value); |
|
335 | + } |
|
336 | + |
|
337 | + |
|
338 | + /** |
|
339 | + * Gets the datetimes for the event (with the given limit), and orders them by "importance". |
|
340 | + * By importance, we mean that the primary datetimes are most important (DEPRECATED FOR NOW), |
|
341 | + * and then the earlier datetimes are the most important. |
|
342 | + * Maybe we'll want this to take into account datetimes that haven't already passed, but we don't yet. |
|
343 | + * |
|
344 | + * @param int $EVT_ID |
|
345 | + * @param int $limit |
|
346 | + * @return EE_Datetime[]|EE_Base_Class[] |
|
347 | + * @throws EE_Error |
|
348 | + */ |
|
349 | + public function get_datetimes_for_event_ordered_by_importance(int $EVT_ID, $limit = 0) |
|
350 | + { |
|
351 | + $query_params[0] = ['Event.EVT_ID' => absint($EVT_ID)]; |
|
352 | + $query_params = $this->addDefaultWhereConditions($query_params); |
|
353 | + $query_params = $this->addDefaultQueryParams($query_params, $limit); |
|
354 | + return $this->get_all($query_params); |
|
355 | + } |
|
356 | + |
|
357 | + |
|
358 | + /** |
|
359 | + * @param int $EVT_ID |
|
360 | + * @param boolean $include_expired |
|
361 | + * @param boolean $include_deleted |
|
362 | + * @return EE_Datetime |
|
363 | + * @throws EE_Error |
|
364 | + */ |
|
365 | + public function get_oldest_datetime_for_event( |
|
366 | + int $EVT_ID, |
|
367 | + bool $include_expired = false, |
|
368 | + bool $include_deleted = false |
|
369 | + ) { |
|
370 | + $results = $this->get_datetimes_for_event_ordered_by_start_time( |
|
371 | + $EVT_ID, |
|
372 | + $include_expired, |
|
373 | + $include_deleted, |
|
374 | + 1 |
|
375 | + ); |
|
376 | + if ($results) { |
|
377 | + return array_shift($results); |
|
378 | + } |
|
379 | + return null; |
|
380 | + } |
|
381 | + |
|
382 | + |
|
383 | + /** |
|
384 | + * Gets the 'primary' datetime for an event. |
|
385 | + * |
|
386 | + * @param int $EVT_ID |
|
387 | + * @param bool $try_to_exclude_expired |
|
388 | + * @param bool $try_to_exclude_deleted |
|
389 | + * @return EE_Datetime |
|
390 | + * @throws EE_Error |
|
391 | + */ |
|
392 | + public function get_primary_datetime_for_event( |
|
393 | + int $EVT_ID, |
|
394 | + bool $try_to_exclude_expired = true, |
|
395 | + bool $try_to_exclude_deleted = true |
|
396 | + ) { |
|
397 | + if ($try_to_exclude_expired) { |
|
398 | + $non_expired = $this->get_oldest_datetime_for_event($EVT_ID, false, false); |
|
399 | + if ($non_expired) { |
|
400 | + return $non_expired; |
|
401 | + } |
|
402 | + } |
|
403 | + if ($try_to_exclude_deleted) { |
|
404 | + $expired_even = $this->get_oldest_datetime_for_event($EVT_ID, true); |
|
405 | + if ($expired_even) { |
|
406 | + return $expired_even; |
|
407 | + } |
|
408 | + } |
|
409 | + return $this->get_oldest_datetime_for_event($EVT_ID, true, true); |
|
410 | + } |
|
411 | + |
|
412 | + |
|
413 | + /** |
|
414 | + * Gets ALL the datetimes for an event (including trashed ones, for now), ordered |
|
415 | + * only by start date |
|
416 | + * |
|
417 | + * @param int $EVT_ID |
|
418 | + * @param boolean $include_expired |
|
419 | + * @param boolean $include_deleted |
|
420 | + * @param int $limit |
|
421 | + * @return EE_Datetime[] |
|
422 | + * @throws EE_Error |
|
423 | + */ |
|
424 | + public function get_datetimes_for_event_ordered_by_start_time( |
|
425 | + int $EVT_ID, |
|
426 | + bool $include_expired = true, |
|
427 | + bool $include_deleted = true, |
|
428 | + $limit = 0 |
|
429 | + ) { |
|
430 | + $prev_data_prep_value = $this->prepModelForQuery(); |
|
431 | + $where_params = ['Event.EVT_ID' => absint($EVT_ID)]; |
|
432 | + $query_params[0] = $this->addDefaultWhereParams($where_params, $include_deleted, $include_expired); |
|
433 | + $query_params = $this->addDefaultWhereConditions( |
|
434 | + $query_params, |
|
435 | + EEM_Base::default_where_conditions_this_only |
|
436 | + ); |
|
437 | + $query_params = $this->addDefaultQueryParams($query_params, $limit, 'DTT_order'); |
|
438 | + return $this->getDatetimesAndRestoreModel($query_params, $prev_data_prep_value); |
|
439 | + } |
|
440 | + |
|
441 | + |
|
442 | + /** |
|
443 | + * Gets ALL the datetimes for an ticket (including trashed ones, for now), ordered |
|
444 | + * only by start date |
|
445 | + * |
|
446 | + * @param int $TKT_ID |
|
447 | + * @param boolean $include_expired |
|
448 | + * @param boolean $include_deleted |
|
449 | + * @param int $limit |
|
450 | + * @return EE_Datetime[] |
|
451 | + * @throws EE_Error |
|
452 | + */ |
|
453 | + public function get_datetimes_for_ticket_ordered_by_start_time( |
|
454 | + int $TKT_ID, |
|
455 | + bool $include_expired = true, |
|
456 | + bool $include_deleted = true, |
|
457 | + $limit = 0 |
|
458 | + ) { |
|
459 | + $prev_data_prep_value = $this->prepModelForQuery(); |
|
460 | + $where_params = ['Ticket.TKT_ID' => absint($TKT_ID)]; |
|
461 | + $query_params[0] = $this->addDefaultWhereParams($where_params, $include_deleted, $include_expired); |
|
462 | + $query_params = $this->addDefaultQueryParams($query_params, $limit); |
|
463 | + return $this->getDatetimesAndRestoreModel($query_params, $prev_data_prep_value); |
|
464 | + } |
|
465 | + |
|
466 | + |
|
467 | + /** |
|
468 | + * Gets all the datetimes for a ticket (including trashed ones, for now), ordered by the DTT_order for the |
|
469 | + * datetimes. |
|
470 | + * |
|
471 | + * @param int $TKT_ID ID of ticket to retrieve the datetimes for |
|
472 | + * @param boolean $include_expired whether to include expired datetimes or not |
|
473 | + * @param boolean $include_deleted whether to include trashed datetimes or not. |
|
474 | + * @param int|null $limit if null, no limit, if int then limit results by |
|
475 | + * that number |
|
476 | + * @return EE_Datetime[] |
|
477 | + * @throws EE_Error |
|
478 | + */ |
|
479 | + public function get_datetimes_for_ticket_ordered_by_DTT_order( |
|
480 | + int $TKT_ID, |
|
481 | + bool $include_expired = true, |
|
482 | + bool $include_deleted = true, |
|
483 | + $limit = 0 |
|
484 | + ) { |
|
485 | + $prev_data_prep_value = $this->prepModelForQuery(); |
|
486 | + $where_params = ['Ticket.TKT_ID' => absint($TKT_ID)]; |
|
487 | + $query_params[0] = $this->addDefaultWhereParams($where_params, $include_deleted, $include_expired); |
|
488 | + $query_params = $this->addDefaultQueryParams($query_params, $limit, 'DTT_order'); |
|
489 | + return $this->getDatetimesAndRestoreModel($query_params, $prev_data_prep_value); |
|
490 | + } |
|
491 | + |
|
492 | + |
|
493 | + /** |
|
494 | + * Gets the most important datetime for a particular event (ie, the primary event usually. But if for some WACK |
|
495 | + * reason it doesn't exist, we consider the earliest event the most important) |
|
496 | + * |
|
497 | + * @param int $EVT_ID |
|
498 | + * @return EE_Datetime |
|
499 | + * @throws EE_Error |
|
500 | + */ |
|
501 | + public function get_most_important_datetime_for_event(int $EVT_ID) |
|
502 | + { |
|
503 | + $results = $this->get_datetimes_for_event_ordered_by_importance($EVT_ID, 1); |
|
504 | + if ($results) { |
|
505 | + return array_shift($results); |
|
506 | + } |
|
507 | + return null; |
|
508 | + } |
|
509 | + |
|
510 | + |
|
511 | + /** |
|
512 | + * This returns a wpdb->results Array of all DTT month and years matching the incoming query params and |
|
513 | + * grouped by month and year. |
|
514 | + * |
|
515 | + * @param array $where_params @see |
|
516 | + * https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md#0-where-conditions |
|
517 | + * @param string $evt_active_status A string representing the evt active status to filter the months by. |
|
518 | + * Can be: |
|
519 | + * - '' = no filter |
|
520 | + * - upcoming = Published events with at least one upcoming datetime. |
|
521 | + * - expired = Events with all datetimes expired. |
|
522 | + * - active = Events that are published and have at least one datetime that |
|
523 | + * starts before now and ends after now. |
|
524 | + * - inactive = Events that are either not published. |
|
525 | + * @return EE_Base_Class[] |
|
526 | + * @throws EE_Error |
|
527 | + * @throws InvalidArgumentException |
|
528 | + * @throws InvalidArgumentException |
|
529 | + */ |
|
530 | + public function get_dtt_months_and_years(array $where_params, $evt_active_status = '') |
|
531 | + { |
|
532 | + $current_time_for_DTT_EVT_start = $this->current_time_for_query('DTT_EVT_start'); |
|
533 | + $current_time_for_DTT_EVT_end = $this->current_time_for_query('DTT_EVT_end'); |
|
534 | + switch ($evt_active_status) { |
|
535 | + case 'upcoming': |
|
536 | + $where_params['Event.status'] = 'publish'; |
|
537 | + // if there are already query_params matching DTT_EVT_start then we need to modify that to add them. |
|
538 | + if (isset($where_params['DTT_EVT_start'])) { |
|
539 | + $where_params['DTT_EVT_start*****'] = $where_params['DTT_EVT_start']; |
|
540 | + } |
|
541 | + $where_params['DTT_EVT_start'] = ['>', $current_time_for_DTT_EVT_start]; |
|
542 | + break; |
|
543 | + case 'expired': |
|
544 | + if (isset($where_params['Event.status'])) { |
|
545 | + unset($where_params['Event.status']); |
|
546 | + } |
|
547 | + // get events to exclude |
|
548 | + $exclude_query[0] = array_merge( |
|
549 | + $where_params, |
|
550 | + ['DTT_EVT_end' => ['>', $current_time_for_DTT_EVT_end]] |
|
551 | + ); |
|
552 | + // first get all events that have datetimes where its not expired. |
|
553 | + $event_ids = $this->_get_all_wpdb_results( |
|
554 | + $exclude_query, |
|
555 | + OBJECT_K, |
|
556 | + 'Datetime.EVT_ID' |
|
557 | + ); |
|
558 | + $event_ids = array_keys($event_ids); |
|
559 | + if (isset($where_params['DTT_EVT_end'])) { |
|
560 | + $where_params['DTT_EVT_end****'] = $where_params['DTT_EVT_end']; |
|
561 | + } |
|
562 | + $where_params['DTT_EVT_end'] = ['<', $current_time_for_DTT_EVT_end]; |
|
563 | + $where_params['Event.EVT_ID'] = ['NOT IN', $event_ids]; |
|
564 | + break; |
|
565 | + case 'active': |
|
566 | + $where_params['Event.status'] = 'publish'; |
|
567 | + if (isset($where_params['DTT_EVT_start'])) { |
|
568 | + $where_params['Datetime.DTT_EVT_start******'] = $where_params['DTT_EVT_start']; |
|
569 | + } |
|
570 | + if (isset($where_params['Datetime.DTT_EVT_end'])) { |
|
571 | + $where_params['Datetime.DTT_EVT_end*****'] = $where_params['DTT_EVT_end']; |
|
572 | + } |
|
573 | + $where_params['DTT_EVT_start'] = ['<', $current_time_for_DTT_EVT_start]; |
|
574 | + $where_params['DTT_EVT_end'] = ['>', $current_time_for_DTT_EVT_end]; |
|
575 | + break; |
|
576 | + case 'inactive': |
|
577 | + if (isset($where_params['Event.status'])) { |
|
578 | + unset($where_params['Event.status']); |
|
579 | + } |
|
580 | + if (isset($where_params['OR'])) { |
|
581 | + $where_params['AND']['OR'] = $where_params['OR']; |
|
582 | + } |
|
583 | + if (isset($where_params['DTT_EVT_end'])) { |
|
584 | + $where_params['AND']['DTT_EVT_end****'] = $where_params['DTT_EVT_end']; |
|
585 | + unset($where_params['DTT_EVT_end']); |
|
586 | + } |
|
587 | + if (isset($where_params['DTT_EVT_start'])) { |
|
588 | + $where_params['AND']['DTT_EVT_start'] = $where_params['DTT_EVT_start']; |
|
589 | + unset($where_params['DTT_EVT_start']); |
|
590 | + } |
|
591 | + $where_params['AND']['Event.status'] = ['!=', 'publish']; |
|
592 | + break; |
|
593 | + } |
|
594 | + $query_params[0] = $where_params; |
|
595 | + $query_params['group_by'] = ['dtt_year', 'dtt_month']; |
|
596 | + $query_params = $this->addOrderByQueryParams($query_params, 'DTT_EVT_start', 'DESC'); |
|
597 | + |
|
598 | + $query_interval = EEH_DTT_Helper::get_sql_query_interval_for_offset( |
|
599 | + $this->get_timezone(), |
|
600 | + 'DTT_EVT_start' |
|
601 | + ); |
|
602 | + $columns_to_select = [ |
|
603 | + 'dtt_year' => ['YEAR(' . $query_interval . ')', '%s'], |
|
604 | + 'dtt_month' => ['MONTHNAME(' . $query_interval . ')', '%s'], |
|
605 | + 'dtt_month_num' => ['MONTH(' . $query_interval . ')', '%s'], |
|
606 | + ]; |
|
607 | + return $this->_get_all_wpdb_results($query_params, OBJECT, $columns_to_select); |
|
608 | + } |
|
609 | + |
|
610 | + |
|
611 | + /** |
|
612 | + * Updates the DTT_sold attribute on each datetime (based on the registrations |
|
613 | + * for the tickets for each datetime) |
|
614 | + * |
|
615 | + * @param EE_Base_Class[]|EE_Datetime[] $datetimes |
|
616 | + * @throws EE_Error |
|
617 | + * @throws ReflectionException |
|
618 | + */ |
|
619 | + public function update_sold(array $datetimes) |
|
620 | + { |
|
621 | + EE_Error::doing_it_wrong( |
|
622 | + __FUNCTION__, |
|
623 | + esc_html__( |
|
624 | + 'Please use \EEM_Ticket::update_tickets_sold() instead which will in turn correctly update both the Ticket AND Datetime counts.', |
|
625 | + 'event_espresso' |
|
626 | + ), |
|
627 | + '4.9.32.rc.005' |
|
628 | + ); |
|
629 | + foreach ($datetimes as $datetime) { |
|
630 | + $datetime->update_sold(); |
|
631 | + } |
|
632 | + } |
|
633 | + |
|
634 | + |
|
635 | + /** |
|
636 | + * Gets the total number of tickets available at a particular datetime |
|
637 | + * (does NOT take into account the datetime's spaces available) |
|
638 | + * |
|
639 | + * @param int $DTT_ID |
|
640 | + * @param array $query_params |
|
641 | + * @return int of tickets available. If sold out, return less than 1. If infinite, returns EE_INF, IF there are NO |
|
642 | + * tickets attached to datetime then FALSE is returned. |
|
643 | + * @throws EE_Error |
|
644 | + * @throws ReflectionException |
|
645 | + */ |
|
646 | + public function sum_tickets_currently_available_at_datetime(int $DTT_ID, array $query_params = []) |
|
647 | + { |
|
648 | + $datetime = $this->get_one_by_ID($DTT_ID); |
|
649 | + if ($datetime instanceof EE_Datetime) { |
|
650 | + return $datetime->tickets_remaining($query_params); |
|
651 | + } |
|
652 | + return 0; |
|
653 | + } |
|
654 | + |
|
655 | + |
|
656 | + /** |
|
657 | + * This returns an array of counts of datetimes in the database for each Datetime status that can be queried. |
|
658 | + * |
|
659 | + * @param array $stati_to_include If included you can restrict the statuses we return counts for by including the |
|
660 | + * stati you want counts for as values in the array. An empty array returns counts |
|
661 | + * for all valid stati. |
|
662 | + * @param array $query_params If included can be used to refine the conditions for returning the count (i.e. |
|
663 | + * only for Datetimes connected to a specific event, or specific ticket. |
|
664 | + * @return array The value returned is an array indexed by Datetime Status and the values are the counts. The |
|
665 | + * @throws EE_Error |
|
666 | + * stati used as index keys are: EE_Datetime::active EE_Datetime::upcoming |
|
667 | + * EE_Datetime::expired |
|
668 | + */ |
|
669 | + public function get_datetime_counts_by_status(array $stati_to_include = [], array $query_params = []) |
|
670 | + { |
|
671 | + // only accept where conditions for this query. |
|
672 | + $_where = isset($query_params[0]) ? $query_params[0] : []; |
|
673 | + $status_query_args = [ |
|
674 | + EE_Datetime::active => array_merge( |
|
675 | + $_where, |
|
676 | + ['DTT_EVT_start' => ['<', time()], 'DTT_EVT_end' => ['>', time()]] |
|
677 | + ), |
|
678 | + EE_Datetime::upcoming => array_merge( |
|
679 | + $_where, |
|
680 | + ['DTT_EVT_start' => ['>', time()]] |
|
681 | + ), |
|
682 | + EE_Datetime::expired => array_merge( |
|
683 | + $_where, |
|
684 | + ['DTT_EVT_end' => ['<', time()]] |
|
685 | + ), |
|
686 | + ]; |
|
687 | + if (! empty($stati_to_include)) { |
|
688 | + foreach (array_keys($status_query_args) as $status) { |
|
689 | + if (! in_array($status, $stati_to_include, true)) { |
|
690 | + unset($status_query_args[ $status ]); |
|
691 | + } |
|
692 | + } |
|
693 | + } |
|
694 | + // loop through and query counts for each stati. |
|
695 | + $status_query_results = []; |
|
696 | + foreach ($status_query_args as $status => $status_where_conditions) { |
|
697 | + $status_query_results[ $status ] = EEM_Datetime::count( |
|
698 | + [$status_where_conditions], |
|
699 | + 'DTT_ID', |
|
700 | + true |
|
701 | + ); |
|
702 | + } |
|
703 | + return $status_query_results; |
|
704 | + } |
|
705 | + |
|
706 | + |
|
707 | + /** |
|
708 | + * Returns the specific count for a given Datetime status matching any given query_params. |
|
709 | + * |
|
710 | + * @param string $status Valid string representation for Datetime status requested. (Defaults to Active). |
|
711 | + * @param array $query_params |
|
712 | + * @return int |
|
713 | + * @throws EE_Error |
|
714 | + */ |
|
715 | + public function get_datetime_count_for_status($status = EE_Datetime::active, array $query_params = []) |
|
716 | + { |
|
717 | + $count = $this->get_datetime_counts_by_status([$status], $query_params); |
|
718 | + return ! empty($count[ $status ]) ? $count[ $status ] : 0; |
|
719 | + } |
|
720 | + |
|
721 | + |
|
722 | + /** |
|
723 | + * @return bool|int |
|
724 | + * @since $VID:$ |
|
725 | + */ |
|
726 | + private function prepModelForQuery() |
|
727 | + { |
|
728 | + $prev_data_prep_value = $this->get_assumption_concerning_values_already_prepared_by_model_object(); |
|
729 | + $this->assume_values_already_prepared_by_model_object(EEM_Base::prepared_for_use_in_db); |
|
730 | + return $prev_data_prep_value; |
|
731 | + } |
|
732 | + |
|
733 | + |
|
734 | + /** |
|
735 | + * @param array $query_params |
|
736 | + * @param bool|int $prev_data_prep_value |
|
737 | + * @return EE_Base_Class[]|EE_Datetime[] |
|
738 | + * @throws EE_Error |
|
739 | + * @since $VID:$ |
|
740 | + */ |
|
741 | + private function getDatetimesAndRestoreModel(array $query_params, $prev_data_prep_value) |
|
742 | + { |
|
743 | + $result = $this->get_all($query_params); |
|
744 | + $this->assume_values_already_prepared_by_model_object($prev_data_prep_value); |
|
745 | + return $result; |
|
746 | + } |
|
747 | + |
|
748 | + |
|
749 | + /** |
|
750 | + * @param array $query_params |
|
751 | + * @param int $limit |
|
752 | + * @param string $order_by |
|
753 | + * @param string $order |
|
754 | + * @return array |
|
755 | + * @since $VID:$ |
|
756 | + */ |
|
757 | + private function addDefaultQueryParams(array $query_params, $limit = 0, $order_by = 'DTT_EVT_start', $order = 'ASC') |
|
758 | + { |
|
759 | + $query_params = $this->addOrderByQueryParams($query_params, $order_by, $order); |
|
760 | + $query_params = $this->addLimitQueryParams($query_params, $limit); |
|
761 | + return $query_params; |
|
762 | + } |
|
763 | + |
|
764 | + |
|
765 | + /** |
|
766 | + * @param array $query_params |
|
767 | + * @param string $default_where_conditions |
|
768 | + * @return array |
|
769 | + * @since $VID:$ |
|
770 | + */ |
|
771 | + private function addDefaultWhereConditions( |
|
772 | + array $query_params, |
|
773 | + $default_where_conditions = EEM_Base::default_where_conditions_none |
|
774 | + ) { |
|
775 | + $query_params['default_where_conditions'] = $default_where_conditions; |
|
776 | + return $query_params; |
|
777 | + } |
|
778 | + |
|
779 | + |
|
780 | + /** |
|
781 | + * @param array $where_params |
|
782 | + * @param bool $include_deleted |
|
783 | + * @param bool $include_expired |
|
784 | + * @return array |
|
785 | + * @since $VID:$ |
|
786 | + */ |
|
787 | + private function addDefaultWhereParams(array $where_params, bool $include_deleted = true, bool $include_expired = true) |
|
788 | + { |
|
789 | + $where_params = $this->addExpiredWhereParams($where_params, $include_expired); |
|
790 | + $where_params = $this->addDeletedWhereParams($where_params, $include_deleted); |
|
791 | + return $where_params; |
|
792 | + } |
|
793 | + |
|
794 | + |
|
795 | + /** |
|
796 | + * @param array $where_params |
|
797 | + * @param bool $include_deleted |
|
798 | + * @return array |
|
799 | + * @since $VID:$ |
|
800 | + */ |
|
801 | + private function addDeletedWhereParams(array $where_params, bool $include_deleted = true) |
|
802 | + { |
|
803 | + $deleted = $include_deleted ? [true, false] : [false]; |
|
804 | + $where_params['DTT_deleted'] = ['IN', $deleted]; |
|
805 | + return $where_params; |
|
806 | + } |
|
807 | + |
|
808 | + |
|
809 | + /** |
|
810 | + * @param array $where_params |
|
811 | + * @param bool $include_expired |
|
812 | + * @return array |
|
813 | + * @since $VID:$ |
|
814 | + */ |
|
815 | + private function addExpiredWhereParams(array $where_params, bool $include_expired = true) |
|
816 | + { |
|
817 | + if (! $include_expired) { |
|
818 | + $where_params['DTT_EVT_end'] = ['>=', current_time('mysql', true)]; |
|
819 | + } |
|
820 | + return $where_params; |
|
821 | + } |
|
822 | + |
|
823 | + |
|
824 | + /** |
|
825 | + * @param array $query_params |
|
826 | + * @param int $limit |
|
827 | + * @return array |
|
828 | + * @since $VID:$ |
|
829 | + */ |
|
830 | + private function addLimitQueryParams(array $query_params, $limit = 0) |
|
831 | + { |
|
832 | + if ($limit) { |
|
833 | + $query_params['limit'] = $limit; |
|
834 | + } |
|
835 | + return $query_params; |
|
836 | + } |
|
837 | + |
|
838 | + |
|
839 | + /** |
|
840 | + * @param array $query_params |
|
841 | + * @param string $order_by |
|
842 | + * @param string $order |
|
843 | + * @return array |
|
844 | + * @since $VID:$ |
|
845 | + */ |
|
846 | + private function addOrderByQueryParams(array $query_params, $order_by = 'DTT_EVT_start', $order = 'ASC') |
|
847 | + { |
|
848 | + $order = $order === 'ASC' ? 'ASC' : 'DESC'; |
|
849 | + $valid_order_columns = ['DTT_ID', 'DTT_EVT_start', 'DTT_EVT_end', 'DTT_order']; |
|
850 | + $order_by = in_array($order_by, $valid_order_columns, true) ? $order_by : 'DTT_EVT_start'; |
|
851 | + $query_params['order_by'] = [$order_by => $order]; |
|
852 | + return $query_params; |
|
853 | + } |
|
854 | 854 | } |