X-Git-Url: https://git.cweiske.de/grauphel.git/blobdiff_plain/81e8558ddd30541782bfefd3b2b0912d1cb6803a..6c8ad60e9888fa5625dad2460ca073f93ac1ae0d:/controller/guicontroller.php?ds=sidebyside diff --git a/controller/guicontroller.php b/controller/guicontroller.php index 0cb8e91..6f0a15c 100644 --- a/controller/guicontroller.php +++ b/controller/guicontroller.php @@ -111,6 +111,7 @@ class GuiController extends Controller $this->user->getUid(), 'access' ), 'client' => new Client(), + 'username' => $this->user->getUid(), ) ); $this->addNavigation($res, null); @@ -118,6 +119,41 @@ class GuiController extends Controller return $res; } + /** + * Allow the user to clear his database + * + * @NoAdminRequired + * @NoCSRFRequired + */ + public function database($reset = null) + { + $res = new TemplateResponse('grauphel', 'gui-database'); + $res->setParams(array('reset' => $reset)); + $this->addNavigation($res, null); + $this->addStats($res); + + return $res; + } + + /** + * Resets the database by deleting all notes and deleting the user's + * sync data. + * + * @NoAdminRequired + */ + public function databaseReset() + { + $reset = false; + if ($_POST['username'] != '' && $_POST['username'] == $this->user->getUid()) { + $notes = $this->getNotes(); + $notes->deleteAll(); + $notes->deleteSyncData(); + $reset = true; + } + + return $this->database($reset); + } + protected function addNavigation(TemplateResponse $res, $selectedRawtag = null) { $nav = new \OCP\Template('grauphel', 'appnavigation', '');