. * */ namespace OCA\Tasks\Controller; use \OCP\AppFramework\Controller; use \OCP\AppFramework\Http\JSONResponse; class SettingsController extends Controller { private $userId; private $settings; public function __construct($appName, IRequest $request, $userId, IConfig $settings){ parent::__construct($appName, $request); $this->userId = $userId; $this->settings = $settings; } /** * @NoAdminRequired */ public function get(){ $settings = array( array( 'id' => 'various', 'showHidden' => (int)$this->settings->getUserValue($this->userId, $this->appName,'various_showHidden'), 'startOfWeek' => (int)$this->settings->getUserValue($this->userId, $this->appName,'various_startOfWeek'), 'userID' => $this->userId ) ); $result = array( 'data' => array( 'settings' => $settings ) ); $response = new JSONResponse(); $response->setData($result); return $response; } /** * @NoAdminRequired */ public function set(){ $this->settings->setUserValue($this->userId, $this->appName, $this->params('type').'_'.$this->params('setting'), $this->params('value')); $response = new JSONResponse(); return $response; } }