summaryrefslogtreecommitdiffstats
path: root/apps/files_sharing/controller/adminsettingscontroller.php
blob: fed3147a99c401b253dcb631c569314c9eefb369 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
<?php

namespace OCA\Files_Sharing\Controller;

use \OCP\AppFramework\ApiController;
use \OCP\IRequest;
use \OCP\AppFramework\Http\JSONResponse;

class AdminSettingsController extends ApiController {

	public function __construct($appName, IRequest $request) {
		parent::__construct($appName, $request);
	}

	/**
	 * @param string $theme
	 * @param string $template
	 * @return \OCA\Files_Sharing\Http\MailTemplateResponse
	 */
	public function render( $theme, $template ) {
		try {
			$template = new \OCA\Files_Sharing\MailTemplate( $theme, $template );
			return $template->getResponse();
		} catch (\Exception $ex) {
			return new JSONResponse(array('message' => $ex->getMessage()), $ex->getCode());
		}
	}

	/**
	 * @param string $theme
	 * @param string $template
	 * @param string $content
	 * @return JSONResponse
	 */
	public function update( $theme, $template, $content ) {
		try {
			$template = new \OCA\Files_Sharing\MailTemplate( $theme, $template );
			$template->setContent( $content );
			return new JSONResponse();
		} catch (\Exception $ex) {
			return new JSONResponse(array('message' => $ex->getMessage()), $ex->getCode());
		}
	}

	/**
	 * @param string $theme
	 * @param string $template
	 * @return JSONResponse
	 */
	public function reset( $theme, $template ) {
		try {
			$template = new \OCA\Files_Sharing\MailTemplate( $theme, $template );
			$template->reset();
			return new JSONResponse();
		} catch (\Exception $ex) {
			return new JSONResponse(array('message' => $ex->getMessage()), $ex->getCode());
		}
	}

}