@@ -14,19 +14,19 @@ |
||
14 | 14 | */ |
15 | 15 | class EspressoEventEditorAddNew extends RouteMatchSpecification |
16 | 16 | { |
17 | - /** |
|
18 | - * returns true if current request matches specification |
|
19 | - * |
|
20 | - * @since 4.9.71.p |
|
21 | - * @return boolean |
|
22 | - */ |
|
23 | - public function isMatchingRoute() |
|
24 | - { |
|
25 | - global $pagenow; |
|
26 | - return $pagenow |
|
27 | - && $pagenow === 'admin.php' |
|
28 | - && $this->request->isAdmin() |
|
29 | - && $this->request->getRequestParam('page') === 'espresso_events' |
|
30 | - && $this->request->getRequestParam('action') === 'create_new'; |
|
31 | - } |
|
17 | + /** |
|
18 | + * returns true if current request matches specification |
|
19 | + * |
|
20 | + * @since 4.9.71.p |
|
21 | + * @return boolean |
|
22 | + */ |
|
23 | + public function isMatchingRoute() |
|
24 | + { |
|
25 | + global $pagenow; |
|
26 | + return $pagenow |
|
27 | + && $pagenow === 'admin.php' |
|
28 | + && $this->request->isAdmin() |
|
29 | + && $this->request->getRequestParam('page') === 'espresso_events' |
|
30 | + && $this->request->getRequestParam('action') === 'create_new'; |
|
31 | + } |
|
32 | 32 | } |
@@ -14,18 +14,18 @@ |
||
14 | 14 | */ |
15 | 15 | class EspressoVenueEditorEdit extends RouteMatchSpecification |
16 | 16 | { |
17 | - /** |
|
18 | - * returns true if current request matches specification |
|
19 | - * |
|
20 | - * @since 4.9.71.p |
|
21 | - * @return boolean |
|
22 | - */ |
|
23 | - public function isMatchingRoute() |
|
24 | - { |
|
25 | - global $pagenow; |
|
26 | - return $pagenow |
|
27 | - && $pagenow === 'admin.php' |
|
28 | - && $this->request->getRequestParam('page') === 'espresso_venues' |
|
29 | - && $this->request->getRequestParam('action') === 'edit'; |
|
30 | - } |
|
17 | + /** |
|
18 | + * returns true if current request matches specification |
|
19 | + * |
|
20 | + * @since 4.9.71.p |
|
21 | + * @return boolean |
|
22 | + */ |
|
23 | + public function isMatchingRoute() |
|
24 | + { |
|
25 | + global $pagenow; |
|
26 | + return $pagenow |
|
27 | + && $pagenow === 'admin.php' |
|
28 | + && $this->request->getRequestParam('page') === 'espresso_venues' |
|
29 | + && $this->request->getRequestParam('action') === 'edit'; |
|
30 | + } |
|
31 | 31 | } |
@@ -15,15 +15,15 @@ |
||
15 | 15 | */ |
16 | 16 | class WordPressPostTypeEditor extends RouteMatchSpecification |
17 | 17 | { |
18 | - /** |
|
19 | - * returns true if current request matches specification |
|
20 | - * |
|
21 | - * @since 4.9.71.p |
|
22 | - * @return boolean |
|
23 | - */ |
|
24 | - public function isMatchingRoute() |
|
25 | - { |
|
26 | - global $pagenow; |
|
27 | - return $pagenow && ($pagenow === 'post.php' || $pagenow === 'post-new.php'); |
|
28 | - } |
|
18 | + /** |
|
19 | + * returns true if current request matches specification |
|
20 | + * |
|
21 | + * @since 4.9.71.p |
|
22 | + * @return boolean |
|
23 | + */ |
|
24 | + public function isMatchingRoute() |
|
25 | + { |
|
26 | + global $pagenow; |
|
27 | + return $pagenow && ($pagenow === 'post.php' || $pagenow === 'post-new.php'); |
|
28 | + } |
|
29 | 29 | } |
@@ -14,17 +14,17 @@ |
||
14 | 14 | */ |
15 | 15 | class WordPressPageEditorAddNew extends RouteMatchSpecification |
16 | 16 | { |
17 | - /** |
|
18 | - * returns true if current request matches specification |
|
19 | - * |
|
20 | - * @since 4.9.71.p |
|
21 | - * @return boolean |
|
22 | - */ |
|
23 | - public function isMatchingRoute() |
|
24 | - { |
|
25 | - global $pagenow; |
|
26 | - return $pagenow |
|
27 | - && $pagenow === 'post-new.php' |
|
28 | - && $this->request->getRequestParam('post_type', 'post') === 'page'; |
|
29 | - } |
|
17 | + /** |
|
18 | + * returns true if current request matches specification |
|
19 | + * |
|
20 | + * @since 4.9.71.p |
|
21 | + * @return boolean |
|
22 | + */ |
|
23 | + public function isMatchingRoute() |
|
24 | + { |
|
25 | + global $pagenow; |
|
26 | + return $pagenow |
|
27 | + && $pagenow === 'post-new.php' |
|
28 | + && $this->request->getRequestParam('post_type', 'post') === 'page'; |
|
29 | + } |
|
30 | 30 | } |
@@ -14,18 +14,18 @@ |
||
14 | 14 | */ |
15 | 15 | class EspressoAttendeePostTypeEditor extends RouteMatchSpecification |
16 | 16 | { |
17 | - /** |
|
18 | - * returns true if current request matches specification |
|
19 | - * |
|
20 | - * @since 4.9.71.p |
|
21 | - * @return boolean |
|
22 | - */ |
|
23 | - public function isMatchingRoute() |
|
24 | - { |
|
25 | - global $pagenow; |
|
26 | - return $pagenow |
|
27 | - && $pagenow === 'admin.php' |
|
28 | - && $this->request->getRequestParam('page') === 'espresso_registrations' |
|
29 | - && $this->request->getRequestParam('action') === 'edit_attendee'; |
|
30 | - } |
|
17 | + /** |
|
18 | + * returns true if current request matches specification |
|
19 | + * |
|
20 | + * @since 4.9.71.p |
|
21 | + * @return boolean |
|
22 | + */ |
|
23 | + public function isMatchingRoute() |
|
24 | + { |
|
25 | + global $pagenow; |
|
26 | + return $pagenow |
|
27 | + && $pagenow === 'admin.php' |
|
28 | + && $this->request->getRequestParam('page') === 'espresso_registrations' |
|
29 | + && $this->request->getRequestParam('action') === 'edit_attendee'; |
|
30 | + } |
|
31 | 31 | } |
@@ -15,17 +15,17 @@ |
||
15 | 15 | */ |
16 | 16 | class WordPressPostsEditorAddNew extends RouteMatchSpecification |
17 | 17 | { |
18 | - /** |
|
19 | - * returns true if current request matches specification |
|
20 | - * |
|
21 | - * @since 4.9.71.p |
|
22 | - * @return boolean |
|
23 | - */ |
|
24 | - public function isMatchingRoute() |
|
25 | - { |
|
26 | - global $pagenow; |
|
27 | - return $pagenow |
|
28 | - && $pagenow === 'post-new.php' |
|
29 | - && $this->request->getRequestParam('post_type', 'post') === 'post'; |
|
30 | - } |
|
18 | + /** |
|
19 | + * returns true if current request matches specification |
|
20 | + * |
|
21 | + * @since 4.9.71.p |
|
22 | + * @return boolean |
|
23 | + */ |
|
24 | + public function isMatchingRoute() |
|
25 | + { |
|
26 | + global $pagenow; |
|
27 | + return $pagenow |
|
28 | + && $pagenow === 'post-new.php' |
|
29 | + && $this->request->getRequestParam('post_type', 'post') === 'post'; |
|
30 | + } |
|
31 | 31 | } |
@@ -16,18 +16,18 @@ |
||
16 | 16 | */ |
17 | 17 | class WordPressPageEditorEdit extends RouteMatchSpecification |
18 | 18 | { |
19 | - /** |
|
20 | - * returns true if current request matches specification |
|
21 | - * |
|
22 | - * @since 4.9.71.p |
|
23 | - * @return boolean |
|
24 | - */ |
|
25 | - public function isMatchingRoute() |
|
26 | - { |
|
27 | - global $pagenow; |
|
28 | - return $pagenow |
|
29 | - && $pagenow === 'plugins.php' |
|
30 | - && $this->request->getRequestParam('post_type', 'post') === 'page' |
|
31 | - && $this->request->getRequestParam('action') === 'edit'; |
|
32 | - } |
|
19 | + /** |
|
20 | + * returns true if current request matches specification |
|
21 | + * |
|
22 | + * @since 4.9.71.p |
|
23 | + * @return boolean |
|
24 | + */ |
|
25 | + public function isMatchingRoute() |
|
26 | + { |
|
27 | + global $pagenow; |
|
28 | + return $pagenow |
|
29 | + && $pagenow === 'plugins.php' |
|
30 | + && $this->request->getRequestParam('post_type', 'post') === 'page' |
|
31 | + && $this->request->getRequestParam('action') === 'edit'; |
|
32 | + } |
|
33 | 33 | } |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | // @link http://josscrowcroft.github.io/accounting.js/ |
84 | 84 | $this->addJavascript( |
85 | 85 | LegacyAccountingAssetManager::JS_HANDLE_ACCOUNTING_CORE, |
86 | - EE_THIRD_PARTY_URL . 'accounting/accounting.js', |
|
86 | + EE_THIRD_PARTY_URL.'accounting/accounting.js', |
|
87 | 87 | [LegacyAccountingAssetManager::JS_HANDLE_UNDERSCORE], |
88 | 88 | true, |
89 | 89 | '0.3.2' |
@@ -91,11 +91,11 @@ discard block |
||
91 | 91 | |
92 | 92 | $this->addJavascript( |
93 | 93 | LegacyAccountingAssetManager::JS_HANDLE_ACCOUNTING, |
94 | - EE_GLOBAL_ASSETS_URL . 'scripts/ee-accounting-config.js', |
|
94 | + EE_GLOBAL_ASSETS_URL.'scripts/ee-accounting-config.js', |
|
95 | 95 | [LegacyAccountingAssetManager::JS_HANDLE_ACCOUNTING_CORE] |
96 | 96 | ) |
97 | 97 | ->setInlineDataCallback( |
98 | - function () { |
|
98 | + function() { |
|
99 | 99 | wp_localize_script( |
100 | 100 | LegacyAccountingAssetManager::JS_HANDLE_ACCOUNTING, |
101 | 101 | 'EE_ACCOUNTING_CFG', |
@@ -24,125 +24,125 @@ |
||
24 | 24 | class LegacyAccountingAssetManager extends AssetManager |
25 | 25 | { |
26 | 26 | |
27 | - const JS_HANDLE_UNDERSCORE = 'underscore'; |
|
28 | - |
|
29 | - const JS_HANDLE_ACCOUNTING_CORE = 'ee-accounting-core'; |
|
30 | - |
|
31 | - const JS_HANDLE_ACCOUNTING = 'ee-accounting'; |
|
32 | - |
|
33 | - |
|
34 | - /** |
|
35 | - * @var EE_Currency_Config $currency_config |
|
36 | - */ |
|
37 | - protected $currency_config; |
|
38 | - |
|
39 | - /** |
|
40 | - * CoreAssetRegister constructor. |
|
41 | - * |
|
42 | - * @param AssetCollection $assets |
|
43 | - * @param DomainInterface $domain |
|
44 | - * @param Registry $registry |
|
45 | - * @param EE_Currency_Config $currency_config |
|
46 | - */ |
|
47 | - public function __construct( |
|
48 | - AssetCollection $assets, |
|
49 | - DomainInterface $domain, |
|
50 | - Registry $registry, |
|
51 | - EE_Currency_Config $currency_config |
|
52 | - ) { |
|
53 | - $this->currency_config = $currency_config; |
|
54 | - parent::__construct($domain, $assets, $registry); |
|
55 | - } |
|
56 | - |
|
57 | - |
|
58 | - |
|
59 | - /** |
|
60 | - * @throws InvalidDataTypeException |
|
61 | - * @throws InvalidEntityException |
|
62 | - * @throws DuplicateCollectionIdentifierException |
|
63 | - * @throws DomainException |
|
64 | - */ |
|
65 | - public function addAssets() |
|
66 | - { |
|
67 | - $this->loadAccountingJs(); |
|
68 | - add_action('admin_enqueue_scripts', [$this, 'enqueueLegacyAccountingAssets'], 100); |
|
69 | - } |
|
70 | - |
|
71 | - |
|
72 | - /** |
|
73 | - * accounting.js for performing client-side calculations |
|
74 | - * |
|
75 | - * @throws DomainException |
|
76 | - * @throws DuplicateCollectionIdentifierException |
|
77 | - * @throws InvalidDataTypeException |
|
78 | - * @throws InvalidEntityException |
|
79 | - * @since $VID:$ |
|
80 | - */ |
|
81 | - private function loadAccountingJs() |
|
82 | - { |
|
83 | - //accounting.js library |
|
84 | - // @link http://josscrowcroft.github.io/accounting.js/ |
|
85 | - $this->addJavascript( |
|
86 | - LegacyAccountingAssetManager::JS_HANDLE_ACCOUNTING_CORE, |
|
87 | - EE_THIRD_PARTY_URL . 'accounting/accounting.js', |
|
88 | - [LegacyAccountingAssetManager::JS_HANDLE_UNDERSCORE], |
|
89 | - true, |
|
90 | - '0.3.2' |
|
91 | - ); |
|
92 | - |
|
93 | - $this->addJavascript( |
|
94 | - LegacyAccountingAssetManager::JS_HANDLE_ACCOUNTING, |
|
95 | - EE_GLOBAL_ASSETS_URL . 'scripts/ee-accounting-config.js', |
|
96 | - [LegacyAccountingAssetManager::JS_HANDLE_ACCOUNTING_CORE] |
|
97 | - ) |
|
98 | - ->setInlineDataCallback( |
|
99 | - function () { |
|
100 | - wp_localize_script( |
|
101 | - LegacyAccountingAssetManager::JS_HANDLE_ACCOUNTING, |
|
102 | - 'EE_ACCOUNTING_CFG', |
|
103 | - $this->getAccountingSettings() |
|
104 | - ); |
|
105 | - } |
|
106 | - ); |
|
107 | - } |
|
108 | - |
|
109 | - |
|
110 | - /** |
|
111 | - * Returns configuration data for the accounting-js library. |
|
112 | - * |
|
113 | - * @return array |
|
114 | - * @since $VID:$ |
|
115 | - */ |
|
116 | - private function getAccountingSettings() |
|
117 | - { |
|
118 | - return [ |
|
119 | - 'currency' => [ |
|
120 | - 'symbol' => $this->currency_config->sign, |
|
121 | - 'format' => [ |
|
122 | - 'pos' => $this->currency_config->sign_b4 ? '%s%v' : '%v%s', |
|
123 | - 'neg' => $this->currency_config->sign_b4 ? '- %s%v' : '- %v%s', |
|
124 | - 'zero' => $this->currency_config->sign_b4 ? '%s--' : '--%s', |
|
125 | - ], |
|
126 | - 'decimal' => $this->currency_config->dec_mrk, |
|
127 | - 'thousand' => $this->currency_config->thsnds, |
|
128 | - 'precision' => $this->currency_config->dec_plc, |
|
129 | - ], |
|
130 | - 'number' => [ |
|
131 | - 'precision' => $this->currency_config->dec_plc, |
|
132 | - 'thousand' => $this->currency_config->thsnds, |
|
133 | - 'decimal' => $this->currency_config->dec_mrk, |
|
134 | - ], |
|
135 | - ]; |
|
136 | - } |
|
137 | - |
|
138 | - |
|
139 | - /** |
|
140 | - * enqueue_scripts - Load the scripts and css |
|
141 | - * |
|
142 | - * @return void |
|
143 | - */ |
|
144 | - public function enqueueLegacyAccountingAssets() |
|
145 | - { |
|
146 | - $this->enqueueAsset(LegacyAccountingAssetManager::JS_HANDLE_ACCOUNTING); |
|
147 | - } |
|
27 | + const JS_HANDLE_UNDERSCORE = 'underscore'; |
|
28 | + |
|
29 | + const JS_HANDLE_ACCOUNTING_CORE = 'ee-accounting-core'; |
|
30 | + |
|
31 | + const JS_HANDLE_ACCOUNTING = 'ee-accounting'; |
|
32 | + |
|
33 | + |
|
34 | + /** |
|
35 | + * @var EE_Currency_Config $currency_config |
|
36 | + */ |
|
37 | + protected $currency_config; |
|
38 | + |
|
39 | + /** |
|
40 | + * CoreAssetRegister constructor. |
|
41 | + * |
|
42 | + * @param AssetCollection $assets |
|
43 | + * @param DomainInterface $domain |
|
44 | + * @param Registry $registry |
|
45 | + * @param EE_Currency_Config $currency_config |
|
46 | + */ |
|
47 | + public function __construct( |
|
48 | + AssetCollection $assets, |
|
49 | + DomainInterface $domain, |
|
50 | + Registry $registry, |
|
51 | + EE_Currency_Config $currency_config |
|
52 | + ) { |
|
53 | + $this->currency_config = $currency_config; |
|
54 | + parent::__construct($domain, $assets, $registry); |
|
55 | + } |
|
56 | + |
|
57 | + |
|
58 | + |
|
59 | + /** |
|
60 | + * @throws InvalidDataTypeException |
|
61 | + * @throws InvalidEntityException |
|
62 | + * @throws DuplicateCollectionIdentifierException |
|
63 | + * @throws DomainException |
|
64 | + */ |
|
65 | + public function addAssets() |
|
66 | + { |
|
67 | + $this->loadAccountingJs(); |
|
68 | + add_action('admin_enqueue_scripts', [$this, 'enqueueLegacyAccountingAssets'], 100); |
|
69 | + } |
|
70 | + |
|
71 | + |
|
72 | + /** |
|
73 | + * accounting.js for performing client-side calculations |
|
74 | + * |
|
75 | + * @throws DomainException |
|
76 | + * @throws DuplicateCollectionIdentifierException |
|
77 | + * @throws InvalidDataTypeException |
|
78 | + * @throws InvalidEntityException |
|
79 | + * @since $VID:$ |
|
80 | + */ |
|
81 | + private function loadAccountingJs() |
|
82 | + { |
|
83 | + //accounting.js library |
|
84 | + // @link http://josscrowcroft.github.io/accounting.js/ |
|
85 | + $this->addJavascript( |
|
86 | + LegacyAccountingAssetManager::JS_HANDLE_ACCOUNTING_CORE, |
|
87 | + EE_THIRD_PARTY_URL . 'accounting/accounting.js', |
|
88 | + [LegacyAccountingAssetManager::JS_HANDLE_UNDERSCORE], |
|
89 | + true, |
|
90 | + '0.3.2' |
|
91 | + ); |
|
92 | + |
|
93 | + $this->addJavascript( |
|
94 | + LegacyAccountingAssetManager::JS_HANDLE_ACCOUNTING, |
|
95 | + EE_GLOBAL_ASSETS_URL . 'scripts/ee-accounting-config.js', |
|
96 | + [LegacyAccountingAssetManager::JS_HANDLE_ACCOUNTING_CORE] |
|
97 | + ) |
|
98 | + ->setInlineDataCallback( |
|
99 | + function () { |
|
100 | + wp_localize_script( |
|
101 | + LegacyAccountingAssetManager::JS_HANDLE_ACCOUNTING, |
|
102 | + 'EE_ACCOUNTING_CFG', |
|
103 | + $this->getAccountingSettings() |
|
104 | + ); |
|
105 | + } |
|
106 | + ); |
|
107 | + } |
|
108 | + |
|
109 | + |
|
110 | + /** |
|
111 | + * Returns configuration data for the accounting-js library. |
|
112 | + * |
|
113 | + * @return array |
|
114 | + * @since $VID:$ |
|
115 | + */ |
|
116 | + private function getAccountingSettings() |
|
117 | + { |
|
118 | + return [ |
|
119 | + 'currency' => [ |
|
120 | + 'symbol' => $this->currency_config->sign, |
|
121 | + 'format' => [ |
|
122 | + 'pos' => $this->currency_config->sign_b4 ? '%s%v' : '%v%s', |
|
123 | + 'neg' => $this->currency_config->sign_b4 ? '- %s%v' : '- %v%s', |
|
124 | + 'zero' => $this->currency_config->sign_b4 ? '%s--' : '--%s', |
|
125 | + ], |
|
126 | + 'decimal' => $this->currency_config->dec_mrk, |
|
127 | + 'thousand' => $this->currency_config->thsnds, |
|
128 | + 'precision' => $this->currency_config->dec_plc, |
|
129 | + ], |
|
130 | + 'number' => [ |
|
131 | + 'precision' => $this->currency_config->dec_plc, |
|
132 | + 'thousand' => $this->currency_config->thsnds, |
|
133 | + 'decimal' => $this->currency_config->dec_mrk, |
|
134 | + ], |
|
135 | + ]; |
|
136 | + } |
|
137 | + |
|
138 | + |
|
139 | + /** |
|
140 | + * enqueue_scripts - Load the scripts and css |
|
141 | + * |
|
142 | + * @return void |
|
143 | + */ |
|
144 | + public function enqueueLegacyAccountingAssets() |
|
145 | + { |
|
146 | + $this->enqueueAsset(LegacyAccountingAssetManager::JS_HANDLE_ACCOUNTING); |
|
147 | + } |
|
148 | 148 | } |
@@ -112,10 +112,10 @@ |
||
112 | 112 | ]; |
113 | 113 | $this->_wp_core_model = true; |
114 | 114 | $this->_caps_slug = 'users'; |
115 | - $this->_cap_contexts_to_cap_action_map[ EEM_Base::caps_read ] = 'list'; |
|
116 | - $this->_cap_contexts_to_cap_action_map[ EEM_Base::caps_read_admin ] = 'list'; |
|
115 | + $this->_cap_contexts_to_cap_action_map[EEM_Base::caps_read] = 'list'; |
|
116 | + $this->_cap_contexts_to_cap_action_map[EEM_Base::caps_read_admin] = 'list'; |
|
117 | 117 | foreach ($this->_cap_contexts_to_cap_action_map as $context => $action) { |
118 | - $this->_cap_restriction_generators[ $context ] = new EE_Restriction_Generator_WP_User(); |
|
118 | + $this->_cap_restriction_generators[$context] = new EE_Restriction_Generator_WP_User(); |
|
119 | 119 | } |
120 | 120 | // @todo: account for create_users controls whether they can create users at all |
121 | 121 | parent::__construct($timezone); |
@@ -12,132 +12,132 @@ |
||
12 | 12 | */ |
13 | 13 | class EEM_WP_User extends EEM_Base |
14 | 14 | { |
15 | - /** |
|
16 | - * private instance of the EEM_WP_User object |
|
17 | - * |
|
18 | - * @type EEM_WP_User |
|
19 | - */ |
|
20 | - protected static $_instance; |
|
15 | + /** |
|
16 | + * private instance of the EEM_WP_User object |
|
17 | + * |
|
18 | + * @type EEM_WP_User |
|
19 | + */ |
|
20 | + protected static $_instance; |
|
21 | 21 | |
22 | 22 | |
23 | - /** |
|
24 | - * constructor |
|
25 | - * |
|
26 | - * @param null $timezone |
|
27 | - * @param ModelFieldFactory $model_field_factory |
|
28 | - * @throws EE_Error |
|
29 | - * @throws InvalidArgumentException |
|
30 | - */ |
|
31 | - protected function __construct($timezone, ModelFieldFactory $model_field_factory) |
|
32 | - { |
|
33 | - $this->singular_item = esc_html__('WP_User', 'event_espresso'); |
|
34 | - $this->plural_item = esc_html__('WP_Users', 'event_espresso'); |
|
35 | - global $wpdb; |
|
36 | - $this->_tables = array( |
|
37 | - 'WP_User' => new EE_Primary_Table($wpdb->users, 'ID', true), |
|
38 | - ); |
|
39 | - $this->_fields = array( |
|
40 | - 'WP_User' => array( |
|
41 | - 'ID' => $model_field_factory->createPrimaryKeyIntField( |
|
42 | - 'ID', |
|
43 | - esc_html__('WP_User ID', 'event_espresso') |
|
44 | - ), |
|
45 | - 'user_login' => $model_field_factory->createPlainTextField( |
|
46 | - 'user_login', |
|
47 | - esc_html__('User Login', 'event_espresso'), |
|
48 | - false |
|
49 | - ), |
|
50 | - 'user_pass' => $model_field_factory->createPlainTextField( |
|
51 | - 'user_pass', |
|
52 | - esc_html__('User Password', 'event_espresso'), |
|
53 | - false |
|
54 | - ), |
|
55 | - 'user_nicename' => $model_field_factory->createPlainTextField( |
|
56 | - 'user_nicename', |
|
57 | - esc_html__(' User Nice Name', 'event_espresso'), |
|
58 | - false |
|
59 | - ), |
|
60 | - 'user_email' => $model_field_factory->createEmailField( |
|
61 | - 'user_email', |
|
62 | - esc_html__('User Email', 'event_espresso'), |
|
63 | - false |
|
64 | - ), |
|
65 | - 'user_registered' => $model_field_factory->createDatetimeField( |
|
66 | - 'user_registered', |
|
67 | - esc_html__('Date User Registered', 'event_espresso'), |
|
68 | - $timezone |
|
69 | - ), |
|
70 | - 'user_activation_key' => $model_field_factory->createPlainTextField( |
|
71 | - 'user_activation_key', |
|
72 | - esc_html__('User Activation Key', 'event_espresso'), |
|
73 | - false |
|
74 | - ), |
|
75 | - 'user_status' => $model_field_factory->createIntegerField( |
|
76 | - 'user_status', |
|
77 | - esc_html__('User Status', 'event_espresso') |
|
78 | - ), |
|
79 | - 'display_name' => $model_field_factory->createPlainTextField( |
|
80 | - 'display_name', |
|
81 | - esc_html__('Display Name', 'event_espresso'), |
|
82 | - false |
|
83 | - ), |
|
84 | - ), |
|
85 | - ); |
|
86 | - $this->_model_relations = array( |
|
87 | - 'Attendee' => new EE_Has_Many_Relation(), |
|
88 | - // all models are related to the change log |
|
89 | - // 'Change_Log' => new EE_Has_Many_Relation(), |
|
90 | - 'Event' => new EE_Has_Many_Relation(), |
|
91 | - 'Message' => new EE_Has_Many_Relation(), |
|
92 | - 'Payment_Method' => new EE_Has_Many_Relation(), |
|
93 | - 'Price' => new EE_Has_Many_Relation(), |
|
94 | - 'Price_Type' => new EE_Has_Many_Relation(), |
|
95 | - 'Question' => new EE_Has_Many_Relation(), |
|
96 | - 'Question_Group' => new EE_Has_Many_Relation(), |
|
97 | - 'Ticket' => new EE_Has_Many_Relation(), |
|
98 | - 'Venue' => new EE_Has_Many_Relation(), |
|
99 | - ); |
|
100 | - $this->foreign_key_aliases = [ |
|
101 | - 'Event.EVT_wp_user' => 'WP_User.ID', |
|
102 | - 'Payment_Method.PMD_wp_user' => 'WP_User.ID', |
|
103 | - 'Price.PRC_wp_user' => 'WP_User.ID', |
|
104 | - 'Price_Type.PRT_wp_user' => 'WP_User.ID', |
|
105 | - 'Question.QST_wp_user' => 'WP_User.ID', |
|
106 | - 'Question_Group.QSG_wp_user' => 'WP_User.ID', |
|
107 | - 'Ticket.VNU_wp_user' => 'WP_User.ID', |
|
108 | - 'Venue.TKT_wp_user' => 'WP_User.ID', |
|
109 | - ]; |
|
110 | - $this->_wp_core_model = true; |
|
111 | - $this->_caps_slug = 'users'; |
|
112 | - $this->_cap_contexts_to_cap_action_map[ EEM_Base::caps_read ] = 'list'; |
|
113 | - $this->_cap_contexts_to_cap_action_map[ EEM_Base::caps_read_admin ] = 'list'; |
|
114 | - foreach ($this->_cap_contexts_to_cap_action_map as $context => $action) { |
|
115 | - $this->_cap_restriction_generators[ $context ] = new EE_Restriction_Generator_WP_User(); |
|
116 | - } |
|
117 | - // @todo: account for create_users controls whether they can create users at all |
|
118 | - parent::__construct($timezone); |
|
119 | - } |
|
23 | + /** |
|
24 | + * constructor |
|
25 | + * |
|
26 | + * @param null $timezone |
|
27 | + * @param ModelFieldFactory $model_field_factory |
|
28 | + * @throws EE_Error |
|
29 | + * @throws InvalidArgumentException |
|
30 | + */ |
|
31 | + protected function __construct($timezone, ModelFieldFactory $model_field_factory) |
|
32 | + { |
|
33 | + $this->singular_item = esc_html__('WP_User', 'event_espresso'); |
|
34 | + $this->plural_item = esc_html__('WP_Users', 'event_espresso'); |
|
35 | + global $wpdb; |
|
36 | + $this->_tables = array( |
|
37 | + 'WP_User' => new EE_Primary_Table($wpdb->users, 'ID', true), |
|
38 | + ); |
|
39 | + $this->_fields = array( |
|
40 | + 'WP_User' => array( |
|
41 | + 'ID' => $model_field_factory->createPrimaryKeyIntField( |
|
42 | + 'ID', |
|
43 | + esc_html__('WP_User ID', 'event_espresso') |
|
44 | + ), |
|
45 | + 'user_login' => $model_field_factory->createPlainTextField( |
|
46 | + 'user_login', |
|
47 | + esc_html__('User Login', 'event_espresso'), |
|
48 | + false |
|
49 | + ), |
|
50 | + 'user_pass' => $model_field_factory->createPlainTextField( |
|
51 | + 'user_pass', |
|
52 | + esc_html__('User Password', 'event_espresso'), |
|
53 | + false |
|
54 | + ), |
|
55 | + 'user_nicename' => $model_field_factory->createPlainTextField( |
|
56 | + 'user_nicename', |
|
57 | + esc_html__(' User Nice Name', 'event_espresso'), |
|
58 | + false |
|
59 | + ), |
|
60 | + 'user_email' => $model_field_factory->createEmailField( |
|
61 | + 'user_email', |
|
62 | + esc_html__('User Email', 'event_espresso'), |
|
63 | + false |
|
64 | + ), |
|
65 | + 'user_registered' => $model_field_factory->createDatetimeField( |
|
66 | + 'user_registered', |
|
67 | + esc_html__('Date User Registered', 'event_espresso'), |
|
68 | + $timezone |
|
69 | + ), |
|
70 | + 'user_activation_key' => $model_field_factory->createPlainTextField( |
|
71 | + 'user_activation_key', |
|
72 | + esc_html__('User Activation Key', 'event_espresso'), |
|
73 | + false |
|
74 | + ), |
|
75 | + 'user_status' => $model_field_factory->createIntegerField( |
|
76 | + 'user_status', |
|
77 | + esc_html__('User Status', 'event_espresso') |
|
78 | + ), |
|
79 | + 'display_name' => $model_field_factory->createPlainTextField( |
|
80 | + 'display_name', |
|
81 | + esc_html__('Display Name', 'event_espresso'), |
|
82 | + false |
|
83 | + ), |
|
84 | + ), |
|
85 | + ); |
|
86 | + $this->_model_relations = array( |
|
87 | + 'Attendee' => new EE_Has_Many_Relation(), |
|
88 | + // all models are related to the change log |
|
89 | + // 'Change_Log' => new EE_Has_Many_Relation(), |
|
90 | + 'Event' => new EE_Has_Many_Relation(), |
|
91 | + 'Message' => new EE_Has_Many_Relation(), |
|
92 | + 'Payment_Method' => new EE_Has_Many_Relation(), |
|
93 | + 'Price' => new EE_Has_Many_Relation(), |
|
94 | + 'Price_Type' => new EE_Has_Many_Relation(), |
|
95 | + 'Question' => new EE_Has_Many_Relation(), |
|
96 | + 'Question_Group' => new EE_Has_Many_Relation(), |
|
97 | + 'Ticket' => new EE_Has_Many_Relation(), |
|
98 | + 'Venue' => new EE_Has_Many_Relation(), |
|
99 | + ); |
|
100 | + $this->foreign_key_aliases = [ |
|
101 | + 'Event.EVT_wp_user' => 'WP_User.ID', |
|
102 | + 'Payment_Method.PMD_wp_user' => 'WP_User.ID', |
|
103 | + 'Price.PRC_wp_user' => 'WP_User.ID', |
|
104 | + 'Price_Type.PRT_wp_user' => 'WP_User.ID', |
|
105 | + 'Question.QST_wp_user' => 'WP_User.ID', |
|
106 | + 'Question_Group.QSG_wp_user' => 'WP_User.ID', |
|
107 | + 'Ticket.VNU_wp_user' => 'WP_User.ID', |
|
108 | + 'Venue.TKT_wp_user' => 'WP_User.ID', |
|
109 | + ]; |
|
110 | + $this->_wp_core_model = true; |
|
111 | + $this->_caps_slug = 'users'; |
|
112 | + $this->_cap_contexts_to_cap_action_map[ EEM_Base::caps_read ] = 'list'; |
|
113 | + $this->_cap_contexts_to_cap_action_map[ EEM_Base::caps_read_admin ] = 'list'; |
|
114 | + foreach ($this->_cap_contexts_to_cap_action_map as $context => $action) { |
|
115 | + $this->_cap_restriction_generators[ $context ] = new EE_Restriction_Generator_WP_User(); |
|
116 | + } |
|
117 | + // @todo: account for create_users controls whether they can create users at all |
|
118 | + parent::__construct($timezone); |
|
119 | + } |
|
120 | 120 | |
121 | 121 | |
122 | - /** |
|
123 | - * We don't need a foreign key to the WP_User model, we just need its primary key |
|
124 | - * |
|
125 | - * @return string |
|
126 | - * @throws EE_Error |
|
127 | - */ |
|
128 | - public function wp_user_field_name() |
|
129 | - { |
|
130 | - return $this->primary_key_name(); |
|
131 | - } |
|
122 | + /** |
|
123 | + * We don't need a foreign key to the WP_User model, we just need its primary key |
|
124 | + * |
|
125 | + * @return string |
|
126 | + * @throws EE_Error |
|
127 | + */ |
|
128 | + public function wp_user_field_name() |
|
129 | + { |
|
130 | + return $this->primary_key_name(); |
|
131 | + } |
|
132 | 132 | |
133 | 133 | |
134 | - /** |
|
135 | - * This WP_User model IS owned, even though it doesn't have a foreign key to itself |
|
136 | - * |
|
137 | - * @return boolean |
|
138 | - */ |
|
139 | - public function is_owned() |
|
140 | - { |
|
141 | - return true; |
|
142 | - } |
|
134 | + /** |
|
135 | + * This WP_User model IS owned, even though it doesn't have a foreign key to itself |
|
136 | + * |
|
137 | + * @return boolean |
|
138 | + */ |
|
139 | + public function is_owned() |
|
140 | + { |
|
141 | + return true; |
|
142 | + } |
|
143 | 143 | } |