aboutsummaryrefslogtreecommitdiffstats
path: root/apps/dav/lib
diff options
context:
space:
mode:
authorGeorg Ehrke <developer@georgehrke.com>2017-10-20 13:29:59 +0200
committerGeorg Ehrke <developer@georgehrke.com>2017-11-09 17:12:06 +0100
commit8b22bfea4f1609605c3cebd40a50ed7a77929d3f (patch)
tree92908a37e88227f798938f4b691b7346825b7314 /apps/dav/lib
parentc7e5bc0f9ab6f58bf9a47dd0c3795e1183419652 (diff)
downloadnextcloud-server-8b22bfea4f1609605c3cebd40a50ed7a77929d3f.tar.gz
nextcloud-server-8b22bfea4f1609605c3cebd40a50ed7a77929d3f.zip
Add admin checkbox to disable birthday calendars
Signed-off-by: Georg Ehrke <developer@georgehrke.com>
Diffstat (limited to 'apps/dav/lib')
-rw-r--r--apps/dav/lib/Controller/BirthdayCalendarController.php81
-rw-r--r--apps/dav/lib/Settings/CalDAVSettings.php1
2 files changed, 82 insertions, 0 deletions
diff --git a/apps/dav/lib/Controller/BirthdayCalendarController.php b/apps/dav/lib/Controller/BirthdayCalendarController.php
new file mode 100644
index 00000000000..c7172c29053
--- /dev/null
+++ b/apps/dav/lib/Controller/BirthdayCalendarController.php
@@ -0,0 +1,81 @@
+<?php
+/**
+ * @copyright 2017, Georg Ehrke <oc.list@georgehrke.com>
+ *
+ * @author Georg Ehrke <oc.list@georgehrke.com>
+ *
+ * @license GNU AGPL version 3 or any later version
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+namespace OCA\DAV\Controller;
+
+use OCP\AppFramework\Controller;
+use OCP\AppFramework\Http\JSONResponse;
+use OCP\AppFramework\Http\Response;
+use OCP\IConfig;
+use OCP\IDBConnection;
+use OCP\IRequest;
+
+class BirthdayCalendarController extends Controller {
+
+ /**
+ * @var IDBConnection
+ */
+ protected $db;
+
+ /**
+ * @var IConfig
+ */
+ protected $config;
+
+ /**
+ * BirthdayCalendar constructor.
+ *
+ * @param string $appName
+ * @param IRequest $request
+ * @param IDBConnection $db
+ * @param IConfig $config
+ */
+ public function __construct($appName, IRequest $request,
+ IDBConnection $db, IConfig $config){
+ parent::__construct($appName, $request);
+ $this->db = $db;
+ $this->config = $config;
+ }
+
+ /**
+ * @return Response
+ */
+ public function enable() {
+ $this->config->setAppValue($this->appName, 'generateBirthdayCalendar', 'yes');
+
+ // TODO schedule background job to regenerate
+
+ return new JSONResponse([]);
+ }
+
+ /**
+ * @return Response
+ */
+ public function disable() {
+ $this->config->setAppValue($this->appName, 'generateBirthdayCalendar', 'no');
+
+ // TODO delete all birthday calendars
+
+ return new JSONResponse([]);
+ }
+}
diff --git a/apps/dav/lib/Settings/CalDAVSettings.php b/apps/dav/lib/Settings/CalDAVSettings.php
index 1c85d19432c..a419afa1c55 100644
--- a/apps/dav/lib/Settings/CalDAVSettings.php
+++ b/apps/dav/lib/Settings/CalDAVSettings.php
@@ -47,6 +47,7 @@ class CalDAVSettings implements ISettings {
public function getForm() {
$parameters = [
'send_invitations' => $this->config->getAppValue('dav', 'sendInvitations', 'yes'),
+ 'generate_birthday_calendar' => $this->config->getAppValue('dav', 'generateBirthdayCalendar', 'yes'),
];
return new TemplateResponse('dav', 'settings-admin-caldav', $parameters);