summaryrefslogtreecommitdiffstats
path: root/apps/files_sharing/lib/capabilities.php
blob: 6e14a60921bfbc3f128ff8b718246cc696c195ac (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
61
62
63
64
<?php
/**
 * Copyright (c) Roeland Jago Douma <roeland@famdouma.nl>
 * This file is licensed under the Affero General Public License version 3 or
 * later.
 * See the COPYING-README file.
 */
 
namespace OCA\Files_Sharing;


/**
 * Class Capabilities
 *
 * @package OCA\Files_Sharing
 */
class Capabilities {

	private $config;

	/*
	 * @codeCoverageIgnore
	 */
	public function __construct($config) {
		$this->config = $config;
	}

	/*
	 * @codeCoverageIgnore
	 */
	public static function getCapabilities() {
		$config = \OC::$server->getConfig();
		$cap = new Capabilities($config);
		return $cap->getCaps();
	}


	/**
	 * @return \OC_OCS_Result
	 */
	public function getCaps() {
		$res = array();
		if ($this->config->getAppValue('core', 'shareapi_allow_links', 'yes') === 'yes') {
			$res['allow_links'] = true;

			if ($this->config->getAppValue('core', 'shareapi_enforce_links_password', 'yes') === 'yes') {
				$res['enforce_links_password'] = true;
			} 

			if ($this->config->getAppValue('core', 'shareapi_allow_public_upload', 'yes') === 'yes') {
				$res['allow_public_upload'] = true;
			}

			$res = array('sharing' => $res);
		}

		return new \OC_OCS_Result(array(
			'capabilities' => array(
				'files' => $res
				),
			));
	}
	
}