Analytics.php
3 years ago
AutomatedLatestContent.php
2 months ago
AutomaticEmails.php
3 years ago
Captcha.php
1 year ago
Coupons.php
2 years ago
CustomFields.php
2 months ago
DynamicProducts.php
1 year ago
DynamicSegments.php
2 months ago
FeatureFlags.php
3 years ago
Forms.php
2 months ago
Help.php
1 year ago
ImportExport.php
2 months ago
Mailer.php
1 year ago
NewsletterLinks.php
2 months ago
NewsletterTemplates.php
2 months ago
Newsletters.php
2 months ago
Premium.php
10 months ago
RedirectResponse.php
1 year ago
Segments.php
2 months ago
SendingQueue.php
2 months ago
Services.php
6 months ago
Settings.php
2 months ago
Setup.php
1 year ago
StatisticsExport.php
3 months ago
SubscriberStats.php
1 month ago
Subscribers.php
2 months ago
Tags.php
3 years ago
UserFlags.php
2 years ago
WoocommerceProductVariations.php
2 months ago
WoocommerceSettings.php
3 years ago
index.php
3 years ago
UserFlags.php
44 lines
| 1 | <?php // phpcs:ignore SlevomatCodingStandard.TypeHints.DeclareStrictTypes.DeclareStrictTypesMissing |
| 2 | |
| 3 | namespace MailPoet\API\JSON\v1; |
| 4 | |
| 5 | if (!defined('ABSPATH')) exit; |
| 6 | |
| 7 | |
| 8 | use MailPoet\API\JSON\Endpoint as APIEndpoint; |
| 9 | use MailPoet\API\JSON\Error as APIError; |
| 10 | use MailPoet\Config\AccessControl; |
| 11 | use MailPoet\Settings\UserFlagsController; |
| 12 | |
| 13 | class UserFlags extends APIEndpoint { |
| 14 | |
| 15 | /** @var UserFlagsController */ |
| 16 | private $userFlags; |
| 17 | |
| 18 | public $permissions = [ |
| 19 | 'global' => AccessControl::ALL_ROLES_ACCESS, |
| 20 | ]; |
| 21 | |
| 22 | public function __construct( |
| 23 | UserFlagsController $userFlags |
| 24 | ) { |
| 25 | $this->userFlags = $userFlags; |
| 26 | } |
| 27 | |
| 28 | public function set(array $flags = []) { |
| 29 | if (empty($flags)) { |
| 30 | return $this->badRequest( |
| 31 | [ |
| 32 | APIError::BAD_REQUEST => |
| 33 | __('You have not specified any user flags to be saved.', 'mailpoet'), |
| 34 | ] |
| 35 | ); |
| 36 | } else { |
| 37 | foreach ($flags as $name => $value) { |
| 38 | $this->userFlags->set($name, $value); |
| 39 | } |
| 40 | return $this->successResponse([]); |
| 41 | } |
| 42 | } |
| 43 | } |
| 44 |