← All changes
|
visualcomposer/Modules/Editors/Templates/Controller.php
+6
-16
45.2.0
→
45.16.4
View file →
| @@ -130,12 +130,10 @@ | ||
| 130 | 130 | $type, |
| 131 | 131 | CurrentUser $currentUserAccessHelper, |
| 132 | 132 | EditorTemplates $editorTemplatesHelper |
| 133 | 133 | ) { |
| 134 | - $haveAccess = $currentUserAccessHelper->wpAll('edit_posts')->get(); | |
| 135 | - if (vcvenv('VCV_ADDON_ROLE_MANAGER_ENABLED')) { | |
| 136 | - $haveAccess = $currentUserAccessHelper->part('editor_content')->can('user_templates_management')->get(); | |
| 137 | - } | |
| 134 | + $haveAccess = $currentUserAccessHelper->wpAll('edit_posts') | |
| 135 | + ->part('editor_content')->can('user_templates_management')->get(); | |
| 138 | 136 | if ($haveAccess) { |
| 139 | 137 | $templateId = $editorTemplatesHelper->create($type); |
| 140 | 138 | if ($templateId) { |
| 141 | 139 | return $templateId; |
| @@ -214,9 +212,9 @@ | ||
| 214 | 212 | EditorTemplates $editorTemplatesHelper, |
| 215 | 213 | CurrentUser $currentUserHelper |
| 216 | 214 | ) { |
| 217 | 215 | $id = $requestHelper->input('vcv-template-id'); |
| 218 | - if ($currentUserHelper->wpAll(['read_post', $id])) { | |
| 216 | + if ($currentUserHelper->wpAll(['read_post', $id])->get()) { | |
| 219 | 217 | $template = $editorTemplatesHelper->read($id); |
| 220 | 218 | if ($template) { |
| 221 | 219 | $optionsHelper = vchelper('Options'); |
| 222 | 220 | // Most used count updates |
| @@ -224,17 +222,8 @@ | ||
| 224 | 222 | 'vcv:ajax:usageCount:updateUsage:adminNonce', |
| 225 | 223 | [], |
| 226 | 224 | ['tag' => 'template/' . $id] |
| 227 | 225 | ); |
| 228 | - // Data usage statistics | |
| 229 | - $isAllowed = $optionsHelper->get('settings-itemdatacollection-enabled', false); | |
| 230 | - if ($isAllowed) { | |
| 231 | - $sourceId = $requestHelper->input('vcv-source-id'); | |
| 232 | - vcevent( | |
| 233 | - 'vcv:saveTemplateUsage', | |
| 234 | - ['response' => [], 'payload' => ['sourceId' => $sourceId, 'templateId' => $id]] | |
| 235 | - ); | |
| 236 | - } | |
| 237 | 226 | |
| 238 | 227 | return $template; |
| 239 | 228 | } |
| 240 | 229 | } |
| @@ -266,13 +255,14 @@ | ||
| 266 | 255 | if (!get_post_meta($sourceId, '_' . VCV_PREFIX . 'id', true)) { |
| 267 | 256 | update_post_meta($sourceId, '_' . VCV_PREFIX . 'id', uniqid('', true)); |
| 268 | 257 | } |
| 269 | 258 | |
| 270 | - return [ | |
| 259 | + // we already checked for access: skip ->canEdit check in DataAjax/Controller. | |
| 260 | + // Must be an object, not an array - request JSON is always decoded assoc. | |
| 261 | + return (object)[ | |
| 271 | 262 | 'status' => true, |
| 272 | 263 | 'sourceId' => $templateId, |
| 273 | 264 | 'accessCheck' => false, |
| 274 | - // we already checked for access: skip ->canEdit check in DataAjax/Controller | |
| 275 | 265 | ]; |
| 276 | 266 | } |
| 277 | 267 | |
| 278 | 268 | return ['status' => false]; |