Welcome to mirror list, hosted at ThFree Co, Russian Federation.

PageController.php « Controller « lib - github.com/CarnetApp/CarnetNextcloud.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 163f02eb158b3edc0098ebe2003d20e4d4d1b0d1 (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
<?php
namespace OCA\Carnet\Controller;

use OCP\IRequest;
use OCP\AppFramework\Http\ContentSecurityPolicy;
use OCP\AppFramework\Http\TemplateResponse;
use OCP\AppFramework\Http\DataResponse;
use OCP\AppFramework\Controller;

class PageController extends Controller {
	private $userId;
	private $config;
	public function __construct($AppName, IRequest $request, $UserId, $Config){
		parent::__construct($AppName, $request);
		$this->userId = $UserId;
		$this->config = $Config;
	}

	/**
	 * CAUTION: the @Stuff turns off security checks; for this page no admin is
	 *          required and no CSRF check. If you don't know what CSRF is, read
	 *          it up in the docs or you might create a security hole. This is
	 *          basically the only required method to add this exemption, don't
	 *          add it to any other method if you don't exactly know what it does
	 *
	 * @NoAdminRequired
	 * @NoCSRFRequired
	 */
	public function index() {
		$parameters = [
			'nc_version' => \OCP\Util::getVersion()[0],
			'carnet_display_fullscreen' => $this->config->getAppValue('carnet', 'carnetDisplayFullscreen', 'no'),
		];
		$response = new TemplateResponse($this->appName,"index",$parameters);
		$policy = new ContentSecurityPolicy();
        $policy->addAllowedFrameDomain('\'self\'');
        $response->setContentSecurityPolicy($policy); // allow iframe
		return $response;
	}

	/**
	* @NoAdminRequired
	* @NoCSRFRequired
	*/
   public function settings() {
	$parameters = [
		'carnet_display_fullscreen' => $this->config->getAppValue('carnet', 'carnetDisplayFullscreen', 'no'),
	];
	   return new TemplateResponse($this->appName,"settings", $parameters); // templates/writer.php
   }

}