Modifies JSON API to use AccessControl
This commit is contained in:
@ -1,24 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace MailPoet\API\JSON\v1;
|
||||
|
||||
use MailPoet\API\JSON\Endpoint as APIEndpoint;
|
||||
use MailPoet\API\JSON\Error as APIError;
|
||||
use MailPoet\Config\AccessControl;
|
||||
use MailPoet\Models\Setting;
|
||||
use MailPoet\Services\Bridge;
|
||||
|
||||
if(!defined('ABSPATH')) exit;
|
||||
|
||||
class Settings extends APIEndpoint {
|
||||
public $permissions = array(
|
||||
'global' => AccessControl::PERMISSION_MANAGE_SETTINGS
|
||||
);
|
||||
|
||||
function get() {
|
||||
return $this->successResponse(Setting::getAll());
|
||||
}
|
||||
|
||||
function set($settings = array()) {
|
||||
if(empty($settings)) {
|
||||
return $this->badRequest(array(
|
||||
APIError::BAD_REQUEST =>
|
||||
__('You have not specified any settings to be saved.', 'mailpoet')
|
||||
));
|
||||
return $this->badRequest(
|
||||
array(
|
||||
APIError::BAD_REQUEST =>
|
||||
__('You have not specified any settings to be saved.', 'mailpoet')
|
||||
));
|
||||
} else {
|
||||
foreach($settings as $name => $value) {
|
||||
Setting::setValue($name, $value);
|
||||
|
Reference in New Issue
Block a user