| | |
| | | <?php |
| | | namespace JVBase\rest\routes; |
| | | |
| | | use JVBase\Instance; |
| | | use JVBase\JVB; |
| | | use JVBase\rest\PermissionHandler; |
| | | use JVBase\rest\Rest; |
| | |
| | | } |
| | | class SettingsRoutes extends Rest |
| | | { |
| | | use Instance; |
| | | protected int $count; |
| | | public function __construct() |
| | | { |
| | | $this->cacheName = 'user_settings'; |
| | | parent::__construct(); |
| | | $this->cache = Cache::for($this->cacheName, null, $this->cacheTtl); |
| | | // $this->action = 'dash-'; |
| | | // $this->operation_type = 'user_settings'; |
| | | $this->count = 1; |
| | |
| | | { |
| | | |
| | | $data = $request->get_params(); |
| | | error_log('User: '.print_r($data['user'], true)); |
| | | error_log('Settings routes data: '.print_r($data, true)); |
| | | $user_id = absint($data['user']??0); |
| | | if ($user_id === 0) { |
| | | |
| | | $user_id = get_current_user_id(); |
| | | if (!$user_id) { |
| | | return $this->unauthorized(); |
| | | } |
| | | |
| | |
| | | $data['notification_preferences'] = $add; |
| | | } |
| | | |
| | | JVB()->queue()->queueOperation( |
| | | Queue::getInstance()->queueOperation( |
| | | 'user_settings', |
| | | $user_id, |
| | | $data, |
| | |
| | | } |
| | | $this->cache->flush(); |
| | | } |
| | | $tempMeta->save(); |
| | | $meta->save(); |
| | | |
| | | return [ |
| | | 'success' => true, |
| | | 'result' => $results, |