capabilities.php 2.47 KB
Newer Older
1
2
<?php
/**
Roeland Jago Douma's avatar
Roeland Jago Douma committed
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
 * @author Roeland Jago Douma <roeland@famdouma.nl>
 *
 * @copyright Copyright (c) 2015, ownCloud, Inc.
 * @license AGPL-3.0
 *
 * This code is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License, version 3,
 * as published by the Free Software Foundation.
 *
 * 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, version 3,
 * along with this program.  If not, see <http://www.gnu.org/licenses/>
 *
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
 */
namespace OCA\Files_Sharing;

use \OCP\IConfig;

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

	/** @var IConfig */
	private $config;

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

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


	/**
	 * @return \OC_OCS_Result
	 */
	public function getCaps() {
Roeland Jago Douma's avatar
Roeland Jago Douma committed
56
		$res = [];
57

Roeland Jago Douma's avatar
Roeland Jago Douma committed
58
		$public = [];
Roeland Jago Douma's avatar
Roeland Jago Douma committed
59
60
		$public['enabled'] = $this->config->getAppValue('core', 'shareapi_allow_links', 'yes') === 'yes';
		if ($public['enabled']) {
Roeland Jago Douma's avatar
Roeland Jago Douma committed
61
62
			$public['password'] = [];
			$public['password']['enforced'] = ($this->config->getAppValue('core', 'shareapi_enforce_links_password', 'yes') === 'yes');
63

Roeland Jago Douma's avatar
Roeland Jago Douma committed
64
			$public['expire_date'] = [];
Roeland Jago Douma's avatar
Roeland Jago Douma committed
65
66
			$public['expire_date']['enabled'] = $this->config->getAppValue('core', 'shareapi_default_expire_date', 'yes') === 'yes';
			if ($public['expire_date']['enabled']) {
67
				$public['expire_date']['days'] = $this->config->getAppValue('core', 'shareapi_expire_after_n_days', '7');
Roeland Jago Douma's avatar
Roeland Jago Douma committed
68
				$public['expire_date']['enforced'] = $this->config->getAppValue('core', 'shareapi_enforce_expire_date', 'yes') === 'yes';
69
70
71
72
73
74
75
76
77
78
79
			}

			$public['send_mail'] = $this->config->getAppValue('core', 'shareapi_allow_public_notification', 'yes') === 'yes';
		}
		$res["public"] = $public;

		$res['user']['send_mail'] = $this->config->getAppValue('core', 'shareapi_allow_mail_notification', 'yes') === 'yes';

		$res['resharing'] = $this->config->getAppValue('core', 'shareapi_allow_resharing', 'yes') === 'yes';


Roeland Jago Douma's avatar
Roeland Jago Douma committed
80
81
		return new \OC_OCS_Result([
			'capabilities' => [
82
				'files_sharing' => $res
Roeland Jago Douma's avatar
Roeland Jago Douma committed
83
84
				],
			]);
85
86
87
	}
	
}