/** * @NoAdminRequired */ public function activate() { $pId = $this->params('id'); $pActive = $this->params('active'); try { $book = Addressbook::find($pId); // is owner access check } catch (Exception $e) { } if (!Addressbook::setActive($pId, $pActive)) { \OCP\Util::writeLog($this->appName, 'Error activating addressbook: ' . $pId, \OCP\Util::ERROR); $params = ['status' => 'error', 'data' => ['message' => (string) $this->l10n->t('Error (de)activating addressbook.')]]; $response = new JSONResponse($params); return $response; } $params = ['status' => 'success', 'active' => Addressbook::isActive($pId), 'id' => $pId, 'addressbook' => $book]; $response = new JSONResponse($params); return $response; }