@@ -35,118 +35,118 @@ |
||
35 | 35 | |
36 | 36 | abstract class AbstractDatabase { |
37 | 37 | |
38 | - /** @var IL10N */ |
|
39 | - protected $trans; |
|
40 | - /** @var string */ |
|
41 | - protected $dbUser; |
|
42 | - /** @var string */ |
|
43 | - protected $dbPassword; |
|
44 | - /** @var string */ |
|
45 | - protected $dbName; |
|
46 | - /** @var string */ |
|
47 | - protected $dbHost; |
|
48 | - /** @var string */ |
|
49 | - protected $dbPort; |
|
50 | - /** @var string */ |
|
51 | - protected $tablePrefix; |
|
52 | - /** @var SystemConfig */ |
|
53 | - protected $config; |
|
54 | - /** @var ILogger */ |
|
55 | - protected $logger; |
|
56 | - /** @var ISecureRandom */ |
|
57 | - protected $random; |
|
38 | + /** @var IL10N */ |
|
39 | + protected $trans; |
|
40 | + /** @var string */ |
|
41 | + protected $dbUser; |
|
42 | + /** @var string */ |
|
43 | + protected $dbPassword; |
|
44 | + /** @var string */ |
|
45 | + protected $dbName; |
|
46 | + /** @var string */ |
|
47 | + protected $dbHost; |
|
48 | + /** @var string */ |
|
49 | + protected $dbPort; |
|
50 | + /** @var string */ |
|
51 | + protected $tablePrefix; |
|
52 | + /** @var SystemConfig */ |
|
53 | + protected $config; |
|
54 | + /** @var ILogger */ |
|
55 | + protected $logger; |
|
56 | + /** @var ISecureRandom */ |
|
57 | + protected $random; |
|
58 | 58 | |
59 | - public function __construct(IL10N $trans, SystemConfig $config, ILogger $logger, ISecureRandom $random) { |
|
60 | - $this->trans = $trans; |
|
61 | - $this->config = $config; |
|
62 | - $this->logger = $logger; |
|
63 | - $this->random = $random; |
|
64 | - } |
|
59 | + public function __construct(IL10N $trans, SystemConfig $config, ILogger $logger, ISecureRandom $random) { |
|
60 | + $this->trans = $trans; |
|
61 | + $this->config = $config; |
|
62 | + $this->logger = $logger; |
|
63 | + $this->random = $random; |
|
64 | + } |
|
65 | 65 | |
66 | - public function validate($config) { |
|
67 | - $errors = array(); |
|
68 | - if(empty($config['dbuser']) && empty($config['dbname'])) { |
|
69 | - $errors[] = $this->trans->t("%s enter the database username and name.", array($this->dbprettyname)); |
|
70 | - } else if(empty($config['dbuser'])) { |
|
71 | - $errors[] = $this->trans->t("%s enter the database username.", array($this->dbprettyname)); |
|
72 | - } else if(empty($config['dbname'])) { |
|
73 | - $errors[] = $this->trans->t("%s enter the database name.", array($this->dbprettyname)); |
|
74 | - } |
|
75 | - if(substr_count($config['dbname'], '.') >= 1) { |
|
76 | - $errors[] = $this->trans->t("%s you may not use dots in the database name", array($this->dbprettyname)); |
|
77 | - } |
|
78 | - return $errors; |
|
79 | - } |
|
66 | + public function validate($config) { |
|
67 | + $errors = array(); |
|
68 | + if(empty($config['dbuser']) && empty($config['dbname'])) { |
|
69 | + $errors[] = $this->trans->t("%s enter the database username and name.", array($this->dbprettyname)); |
|
70 | + } else if(empty($config['dbuser'])) { |
|
71 | + $errors[] = $this->trans->t("%s enter the database username.", array($this->dbprettyname)); |
|
72 | + } else if(empty($config['dbname'])) { |
|
73 | + $errors[] = $this->trans->t("%s enter the database name.", array($this->dbprettyname)); |
|
74 | + } |
|
75 | + if(substr_count($config['dbname'], '.') >= 1) { |
|
76 | + $errors[] = $this->trans->t("%s you may not use dots in the database name", array($this->dbprettyname)); |
|
77 | + } |
|
78 | + return $errors; |
|
79 | + } |
|
80 | 80 | |
81 | - public function initialize($config) { |
|
82 | - $dbUser = $config['dbuser']; |
|
83 | - $dbPass = $config['dbpass']; |
|
84 | - $dbName = $config['dbname']; |
|
85 | - $dbHost = !empty($config['dbhost']) ? $config['dbhost'] : 'localhost'; |
|
86 | - $dbPort = !empty($config['dbport']) ? $config['dbport'] : ''; |
|
87 | - $dbTablePrefix = isset($config['dbtableprefix']) ? $config['dbtableprefix'] : 'oc_'; |
|
81 | + public function initialize($config) { |
|
82 | + $dbUser = $config['dbuser']; |
|
83 | + $dbPass = $config['dbpass']; |
|
84 | + $dbName = $config['dbname']; |
|
85 | + $dbHost = !empty($config['dbhost']) ? $config['dbhost'] : 'localhost'; |
|
86 | + $dbPort = !empty($config['dbport']) ? $config['dbport'] : ''; |
|
87 | + $dbTablePrefix = isset($config['dbtableprefix']) ? $config['dbtableprefix'] : 'oc_'; |
|
88 | 88 | |
89 | - $this->config->setValues([ |
|
90 | - 'dbname' => $dbName, |
|
91 | - 'dbhost' => $dbHost, |
|
92 | - 'dbport' => $dbPort, |
|
93 | - 'dbtableprefix' => $dbTablePrefix, |
|
94 | - ]); |
|
89 | + $this->config->setValues([ |
|
90 | + 'dbname' => $dbName, |
|
91 | + 'dbhost' => $dbHost, |
|
92 | + 'dbport' => $dbPort, |
|
93 | + 'dbtableprefix' => $dbTablePrefix, |
|
94 | + ]); |
|
95 | 95 | |
96 | - $this->dbUser = $dbUser; |
|
97 | - $this->dbPassword = $dbPass; |
|
98 | - $this->dbName = $dbName; |
|
99 | - $this->dbHost = $dbHost; |
|
100 | - $this->dbPort = $dbPort; |
|
101 | - $this->tablePrefix = $dbTablePrefix; |
|
102 | - } |
|
96 | + $this->dbUser = $dbUser; |
|
97 | + $this->dbPassword = $dbPass; |
|
98 | + $this->dbName = $dbName; |
|
99 | + $this->dbHost = $dbHost; |
|
100 | + $this->dbPort = $dbPort; |
|
101 | + $this->tablePrefix = $dbTablePrefix; |
|
102 | + } |
|
103 | 103 | |
104 | - /** |
|
105 | - * @param array $configOverwrite |
|
106 | - * @return \OC\DB\Connection |
|
107 | - */ |
|
108 | - protected function connect(array $configOverwrite = []) { |
|
109 | - $connectionParams = array( |
|
110 | - 'host' => $this->dbHost, |
|
111 | - 'user' => $this->dbUser, |
|
112 | - 'password' => $this->dbPassword, |
|
113 | - 'tablePrefix' => $this->tablePrefix, |
|
114 | - 'dbname' => $this->dbName |
|
115 | - ); |
|
104 | + /** |
|
105 | + * @param array $configOverwrite |
|
106 | + * @return \OC\DB\Connection |
|
107 | + */ |
|
108 | + protected function connect(array $configOverwrite = []) { |
|
109 | + $connectionParams = array( |
|
110 | + 'host' => $this->dbHost, |
|
111 | + 'user' => $this->dbUser, |
|
112 | + 'password' => $this->dbPassword, |
|
113 | + 'tablePrefix' => $this->tablePrefix, |
|
114 | + 'dbname' => $this->dbName |
|
115 | + ); |
|
116 | 116 | |
117 | - // adding port support through installer |
|
118 | - if (!empty($this->dbPort)) { |
|
119 | - if (ctype_digit($this->dbPort)) { |
|
120 | - $connectionParams['port'] = $this->dbPort; |
|
121 | - } else { |
|
122 | - $connectionParams['unix_socket'] = $this->dbPort; |
|
123 | - } |
|
124 | - } else if (strpos($this->dbHost, ':')) { |
|
125 | - // Host variable may carry a port or socket. |
|
126 | - list($host, $portOrSocket) = explode(':', $this->dbHost, 2); |
|
127 | - if (ctype_digit($portOrSocket)) { |
|
128 | - $connectionParams['port'] = $portOrSocket; |
|
129 | - } else { |
|
130 | - $connectionParams['unix_socket'] = $portOrSocket; |
|
131 | - } |
|
132 | - $connectionParams['host'] = $host; |
|
133 | - } |
|
117 | + // adding port support through installer |
|
118 | + if (!empty($this->dbPort)) { |
|
119 | + if (ctype_digit($this->dbPort)) { |
|
120 | + $connectionParams['port'] = $this->dbPort; |
|
121 | + } else { |
|
122 | + $connectionParams['unix_socket'] = $this->dbPort; |
|
123 | + } |
|
124 | + } else if (strpos($this->dbHost, ':')) { |
|
125 | + // Host variable may carry a port or socket. |
|
126 | + list($host, $portOrSocket) = explode(':', $this->dbHost, 2); |
|
127 | + if (ctype_digit($portOrSocket)) { |
|
128 | + $connectionParams['port'] = $portOrSocket; |
|
129 | + } else { |
|
130 | + $connectionParams['unix_socket'] = $portOrSocket; |
|
131 | + } |
|
132 | + $connectionParams['host'] = $host; |
|
133 | + } |
|
134 | 134 | |
135 | - $connectionParams = array_merge($connectionParams, $configOverwrite); |
|
136 | - $cf = new ConnectionFactory($this->config); |
|
137 | - return $cf->getConnection($this->config->getValue('dbtype', 'sqlite'), $connectionParams); |
|
138 | - } |
|
135 | + $connectionParams = array_merge($connectionParams, $configOverwrite); |
|
136 | + $cf = new ConnectionFactory($this->config); |
|
137 | + return $cf->getConnection($this->config->getValue('dbtype', 'sqlite'), $connectionParams); |
|
138 | + } |
|
139 | 139 | |
140 | - /** |
|
141 | - * @param string $userName |
|
142 | - */ |
|
143 | - abstract public function setupDatabase($userName); |
|
140 | + /** |
|
141 | + * @param string $userName |
|
142 | + */ |
|
143 | + abstract public function setupDatabase($userName); |
|
144 | 144 | |
145 | - public function runMigrations() { |
|
146 | - if (!is_dir(\OC::$SERVERROOT."/core/Migrations")) { |
|
147 | - return; |
|
148 | - } |
|
149 | - $ms = new MigrationService('core', \OC::$server->getDatabaseConnection()); |
|
150 | - $ms->migrate(); |
|
151 | - } |
|
145 | + public function runMigrations() { |
|
146 | + if (!is_dir(\OC::$SERVERROOT."/core/Migrations")) { |
|
147 | + return; |
|
148 | + } |
|
149 | + $ms = new MigrationService('core', \OC::$server->getDatabaseConnection()); |
|
150 | + $ms->migrate(); |
|
151 | + } |
|
152 | 152 | } |
@@ -29,68 +29,68 @@ |
||
29 | 29 | use OCP\Diagnostics\IQueryLogger; |
30 | 30 | |
31 | 31 | class QueryLogger implements IQueryLogger { |
32 | - /** |
|
33 | - * @var \OC\Diagnostics\Query |
|
34 | - */ |
|
35 | - protected $activeQuery; |
|
32 | + /** |
|
33 | + * @var \OC\Diagnostics\Query |
|
34 | + */ |
|
35 | + protected $activeQuery; |
|
36 | 36 | |
37 | - /** |
|
38 | - * @var CappedMemoryCache |
|
39 | - */ |
|
40 | - protected $queries; |
|
37 | + /** |
|
38 | + * @var CappedMemoryCache |
|
39 | + */ |
|
40 | + protected $queries; |
|
41 | 41 | |
42 | - /** |
|
43 | - * QueryLogger constructor. |
|
44 | - */ |
|
45 | - public function __construct() { |
|
46 | - $this->queries = new CappedMemoryCache(1024); |
|
47 | - } |
|
42 | + /** |
|
43 | + * QueryLogger constructor. |
|
44 | + */ |
|
45 | + public function __construct() { |
|
46 | + $this->queries = new CappedMemoryCache(1024); |
|
47 | + } |
|
48 | 48 | |
49 | 49 | |
50 | - /** |
|
51 | - * @var bool - Module needs to be activated by some app |
|
52 | - */ |
|
53 | - private $activated = false; |
|
50 | + /** |
|
51 | + * @var bool - Module needs to be activated by some app |
|
52 | + */ |
|
53 | + private $activated = false; |
|
54 | 54 | |
55 | - /** |
|
56 | - * @inheritdoc |
|
57 | - */ |
|
58 | - public function startQuery($sql, array $params = null, array $types = null) { |
|
59 | - if ($this->activated) { |
|
60 | - $this->activeQuery = new Query($sql, $params, microtime(true), $this->getStack()); |
|
61 | - } |
|
62 | - } |
|
55 | + /** |
|
56 | + * @inheritdoc |
|
57 | + */ |
|
58 | + public function startQuery($sql, array $params = null, array $types = null) { |
|
59 | + if ($this->activated) { |
|
60 | + $this->activeQuery = new Query($sql, $params, microtime(true), $this->getStack()); |
|
61 | + } |
|
62 | + } |
|
63 | 63 | |
64 | - private function getStack() { |
|
65 | - $stack = debug_backtrace(); |
|
66 | - array_shift($stack); |
|
67 | - array_shift($stack); |
|
68 | - array_shift($stack); |
|
69 | - return $stack; |
|
70 | - } |
|
64 | + private function getStack() { |
|
65 | + $stack = debug_backtrace(); |
|
66 | + array_shift($stack); |
|
67 | + array_shift($stack); |
|
68 | + array_shift($stack); |
|
69 | + return $stack; |
|
70 | + } |
|
71 | 71 | |
72 | - /** |
|
73 | - * @inheritdoc |
|
74 | - */ |
|
75 | - public function stopQuery() { |
|
76 | - if ($this->activated && $this->activeQuery) { |
|
77 | - $this->activeQuery->end(microtime(true)); |
|
78 | - $this->queries[] = $this->activeQuery; |
|
79 | - $this->activeQuery = null; |
|
80 | - } |
|
81 | - } |
|
72 | + /** |
|
73 | + * @inheritdoc |
|
74 | + */ |
|
75 | + public function stopQuery() { |
|
76 | + if ($this->activated && $this->activeQuery) { |
|
77 | + $this->activeQuery->end(microtime(true)); |
|
78 | + $this->queries[] = $this->activeQuery; |
|
79 | + $this->activeQuery = null; |
|
80 | + } |
|
81 | + } |
|
82 | 82 | |
83 | - /** |
|
84 | - * @inheritdoc |
|
85 | - */ |
|
86 | - public function getQueries() { |
|
87 | - return $this->queries->getData(); |
|
88 | - } |
|
83 | + /** |
|
84 | + * @inheritdoc |
|
85 | + */ |
|
86 | + public function getQueries() { |
|
87 | + return $this->queries->getData(); |
|
88 | + } |
|
89 | 89 | |
90 | - /** |
|
91 | - * @inheritdoc |
|
92 | - */ |
|
93 | - public function activate() { |
|
94 | - $this->activated = true; |
|
95 | - } |
|
90 | + /** |
|
91 | + * @inheritdoc |
|
92 | + */ |
|
93 | + public function activate() { |
|
94 | + $this->activated = true; |
|
95 | + } |
|
96 | 96 | } |
@@ -24,15 +24,15 @@ |
||
24 | 24 | namespace OC\Hooks; |
25 | 25 | |
26 | 26 | abstract class LegacyEmitter extends BasicEmitter { |
27 | - /** |
|
28 | - * @param string $scope |
|
29 | - * @param string $method |
|
30 | - * @param array $arguments |
|
31 | - * |
|
32 | - * @suppress PhanAccessMethodProtected |
|
33 | - */ |
|
34 | - protected function emit($scope, $method, array $arguments = array()) { |
|
35 | - \OC_Hook::emit($scope, $method, $arguments); |
|
36 | - parent::emit($scope, $method, $arguments); |
|
37 | - } |
|
27 | + /** |
|
28 | + * @param string $scope |
|
29 | + * @param string $method |
|
30 | + * @param array $arguments |
|
31 | + * |
|
32 | + * @suppress PhanAccessMethodProtected |
|
33 | + */ |
|
34 | + protected function emit($scope, $method, array $arguments = array()) { |
|
35 | + \OC_Hook::emit($scope, $method, $arguments); |
|
36 | + parent::emit($scope, $method, $arguments); |
|
37 | + } |
|
38 | 38 | } |
@@ -24,14 +24,14 @@ |
||
24 | 24 | namespace OC\Hooks; |
25 | 25 | |
26 | 26 | class PublicEmitter extends BasicEmitter { |
27 | - /** |
|
28 | - * @param string $scope |
|
29 | - * @param string $method |
|
30 | - * @param array $arguments optional |
|
31 | - * |
|
32 | - * @suppress PhanAccessMethodProtected |
|
33 | - */ |
|
34 | - public function emit($scope, $method, array $arguments = array()) { |
|
35 | - parent::emit($scope, $method, $arguments); |
|
36 | - } |
|
27 | + /** |
|
28 | + * @param string $scope |
|
29 | + * @param string $method |
|
30 | + * @param array $arguments optional |
|
31 | + * |
|
32 | + * @suppress PhanAccessMethodProtected |
|
33 | + */ |
|
34 | + public function emit($scope, $method, array $arguments = array()) { |
|
35 | + parent::emit($scope, $method, $arguments); |
|
36 | + } |
|
37 | 37 | } |
@@ -27,72 +27,72 @@ |
||
27 | 27 | |
28 | 28 | class FileDeleted implements ISetting { |
29 | 29 | |
30 | - /** @var IL10N */ |
|
31 | - protected $l; |
|
30 | + /** @var IL10N */ |
|
31 | + protected $l; |
|
32 | 32 | |
33 | - /** |
|
34 | - * @param IL10N $l |
|
35 | - */ |
|
36 | - public function __construct(IL10N $l) { |
|
37 | - $this->l = $l; |
|
38 | - } |
|
33 | + /** |
|
34 | + * @param IL10N $l |
|
35 | + */ |
|
36 | + public function __construct(IL10N $l) { |
|
37 | + $this->l = $l; |
|
38 | + } |
|
39 | 39 | |
40 | - /** |
|
41 | - * @return string Lowercase a-z and underscore only identifier |
|
42 | - * @since 11.0.0 |
|
43 | - */ |
|
44 | - public function getIdentifier() { |
|
45 | - return 'file_deleted'; |
|
46 | - } |
|
40 | + /** |
|
41 | + * @return string Lowercase a-z and underscore only identifier |
|
42 | + * @since 11.0.0 |
|
43 | + */ |
|
44 | + public function getIdentifier() { |
|
45 | + return 'file_deleted'; |
|
46 | + } |
|
47 | 47 | |
48 | - /** |
|
49 | - * @return string A translated string |
|
50 | - * @since 11.0.0 |
|
51 | - */ |
|
52 | - public function getName() { |
|
53 | - return $this->l->t('A file or folder has been <strong>deleted</strong>'); |
|
54 | - } |
|
48 | + /** |
|
49 | + * @return string A translated string |
|
50 | + * @since 11.0.0 |
|
51 | + */ |
|
52 | + public function getName() { |
|
53 | + return $this->l->t('A file or folder has been <strong>deleted</strong>'); |
|
54 | + } |
|
55 | 55 | |
56 | - /** |
|
57 | - * @return int whether the filter should be rather on the top or bottom of |
|
58 | - * the admin section. The filters are arranged in ascending order of the |
|
59 | - * priority values. It is required to return a value between 0 and 100. |
|
60 | - * @since 11.0.0 |
|
61 | - */ |
|
62 | - public function getPriority() { |
|
63 | - return 3; |
|
64 | - } |
|
56 | + /** |
|
57 | + * @return int whether the filter should be rather on the top or bottom of |
|
58 | + * the admin section. The filters are arranged in ascending order of the |
|
59 | + * priority values. It is required to return a value between 0 and 100. |
|
60 | + * @since 11.0.0 |
|
61 | + */ |
|
62 | + public function getPriority() { |
|
63 | + return 3; |
|
64 | + } |
|
65 | 65 | |
66 | - /** |
|
67 | - * @return bool True when the option can be changed for the stream |
|
68 | - * @since 11.0.0 |
|
69 | - */ |
|
70 | - public function canChangeStream() { |
|
71 | - return true; |
|
72 | - } |
|
66 | + /** |
|
67 | + * @return bool True when the option can be changed for the stream |
|
68 | + * @since 11.0.0 |
|
69 | + */ |
|
70 | + public function canChangeStream() { |
|
71 | + return true; |
|
72 | + } |
|
73 | 73 | |
74 | - /** |
|
75 | - * @return bool True when the option can be changed for the stream |
|
76 | - * @since 11.0.0 |
|
77 | - */ |
|
78 | - public function isDefaultEnabledStream() { |
|
79 | - return true; |
|
80 | - } |
|
74 | + /** |
|
75 | + * @return bool True when the option can be changed for the stream |
|
76 | + * @since 11.0.0 |
|
77 | + */ |
|
78 | + public function isDefaultEnabledStream() { |
|
79 | + return true; |
|
80 | + } |
|
81 | 81 | |
82 | - /** |
|
83 | - * @return bool True when the option can be changed for the mail |
|
84 | - * @since 11.0.0 |
|
85 | - */ |
|
86 | - public function canChangeMail() { |
|
87 | - return true; |
|
88 | - } |
|
82 | + /** |
|
83 | + * @return bool True when the option can be changed for the mail |
|
84 | + * @since 11.0.0 |
|
85 | + */ |
|
86 | + public function canChangeMail() { |
|
87 | + return true; |
|
88 | + } |
|
89 | 89 | |
90 | - /** |
|
91 | - * @return bool True when the option can be changed for the stream |
|
92 | - * @since 11.0.0 |
|
93 | - */ |
|
94 | - public function isDefaultEnabledMail() { |
|
95 | - return false; |
|
96 | - } |
|
90 | + /** |
|
91 | + * @return bool True when the option can be changed for the stream |
|
92 | + * @since 11.0.0 |
|
93 | + */ |
|
94 | + public function isDefaultEnabledMail() { |
|
95 | + return false; |
|
96 | + } |
|
97 | 97 | } |
98 | 98 |
@@ -27,72 +27,72 @@ |
||
27 | 27 | |
28 | 28 | class FileRestored implements ISetting { |
29 | 29 | |
30 | - /** @var IL10N */ |
|
31 | - protected $l; |
|
30 | + /** @var IL10N */ |
|
31 | + protected $l; |
|
32 | 32 | |
33 | - /** |
|
34 | - * @param IL10N $l |
|
35 | - */ |
|
36 | - public function __construct(IL10N $l) { |
|
37 | - $this->l = $l; |
|
38 | - } |
|
33 | + /** |
|
34 | + * @param IL10N $l |
|
35 | + */ |
|
36 | + public function __construct(IL10N $l) { |
|
37 | + $this->l = $l; |
|
38 | + } |
|
39 | 39 | |
40 | - /** |
|
41 | - * @return string Lowercase a-z and underscore only identifier |
|
42 | - * @since 11.0.0 |
|
43 | - */ |
|
44 | - public function getIdentifier() { |
|
45 | - return 'file_restored'; |
|
46 | - } |
|
40 | + /** |
|
41 | + * @return string Lowercase a-z and underscore only identifier |
|
42 | + * @since 11.0.0 |
|
43 | + */ |
|
44 | + public function getIdentifier() { |
|
45 | + return 'file_restored'; |
|
46 | + } |
|
47 | 47 | |
48 | - /** |
|
49 | - * @return string A translated string |
|
50 | - * @since 11.0.0 |
|
51 | - */ |
|
52 | - public function getName() { |
|
53 | - return $this->l->t('A file or folder has been <strong>restored</strong>'); |
|
54 | - } |
|
48 | + /** |
|
49 | + * @return string A translated string |
|
50 | + * @since 11.0.0 |
|
51 | + */ |
|
52 | + public function getName() { |
|
53 | + return $this->l->t('A file or folder has been <strong>restored</strong>'); |
|
54 | + } |
|
55 | 55 | |
56 | - /** |
|
57 | - * @return int whether the filter should be rather on the top or bottom of |
|
58 | - * the admin section. The filters are arranged in ascending order of the |
|
59 | - * priority values. It is required to return a value between 0 and 100. |
|
60 | - * @since 11.0.0 |
|
61 | - */ |
|
62 | - public function getPriority() { |
|
63 | - return 4; |
|
64 | - } |
|
56 | + /** |
|
57 | + * @return int whether the filter should be rather on the top or bottom of |
|
58 | + * the admin section. The filters are arranged in ascending order of the |
|
59 | + * priority values. It is required to return a value between 0 and 100. |
|
60 | + * @since 11.0.0 |
|
61 | + */ |
|
62 | + public function getPriority() { |
|
63 | + return 4; |
|
64 | + } |
|
65 | 65 | |
66 | - /** |
|
67 | - * @return bool True when the option can be changed for the stream |
|
68 | - * @since 11.0.0 |
|
69 | - */ |
|
70 | - public function canChangeStream() { |
|
71 | - return true; |
|
72 | - } |
|
66 | + /** |
|
67 | + * @return bool True when the option can be changed for the stream |
|
68 | + * @since 11.0.0 |
|
69 | + */ |
|
70 | + public function canChangeStream() { |
|
71 | + return true; |
|
72 | + } |
|
73 | 73 | |
74 | - /** |
|
75 | - * @return bool True when the option can be changed for the stream |
|
76 | - * @since 11.0.0 |
|
77 | - */ |
|
78 | - public function isDefaultEnabledStream() { |
|
79 | - return true; |
|
80 | - } |
|
74 | + /** |
|
75 | + * @return bool True when the option can be changed for the stream |
|
76 | + * @since 11.0.0 |
|
77 | + */ |
|
78 | + public function isDefaultEnabledStream() { |
|
79 | + return true; |
|
80 | + } |
|
81 | 81 | |
82 | - /** |
|
83 | - * @return bool True when the option can be changed for the mail |
|
84 | - * @since 11.0.0 |
|
85 | - */ |
|
86 | - public function canChangeMail() { |
|
87 | - return true; |
|
88 | - } |
|
82 | + /** |
|
83 | + * @return bool True when the option can be changed for the mail |
|
84 | + * @since 11.0.0 |
|
85 | + */ |
|
86 | + public function canChangeMail() { |
|
87 | + return true; |
|
88 | + } |
|
89 | 89 | |
90 | - /** |
|
91 | - * @return bool True when the option can be changed for the stream |
|
92 | - * @since 11.0.0 |
|
93 | - */ |
|
94 | - public function isDefaultEnabledMail() { |
|
95 | - return false; |
|
96 | - } |
|
90 | + /** |
|
91 | + * @return bool True when the option can be changed for the stream |
|
92 | + * @since 11.0.0 |
|
93 | + */ |
|
94 | + public function isDefaultEnabledMail() { |
|
95 | + return false; |
|
96 | + } |
|
97 | 97 | } |
98 | 98 |
@@ -44,116 +44,116 @@ |
||
44 | 44 | */ |
45 | 45 | abstract class Controller { |
46 | 46 | |
47 | - /** |
|
48 | - * app name |
|
49 | - * @var string |
|
50 | - * @since 7.0.0 |
|
51 | - */ |
|
52 | - protected $appName; |
|
53 | - |
|
54 | - /** |
|
55 | - * current request |
|
56 | - * @var \OCP\IRequest |
|
57 | - * @since 6.0.0 |
|
58 | - */ |
|
59 | - protected $request; |
|
60 | - |
|
61 | - /** |
|
62 | - * @var array |
|
63 | - * @since 7.0.0 |
|
64 | - */ |
|
65 | - private $responders; |
|
66 | - |
|
67 | - /** |
|
68 | - * constructor of the controller |
|
69 | - * @param string $appName the name of the app |
|
70 | - * @param IRequest $request an instance of the request |
|
71 | - * @since 6.0.0 - parameter $appName was added in 7.0.0 - parameter $app was removed in 7.0.0 |
|
72 | - */ |
|
73 | - public function __construct($appName, |
|
74 | - IRequest $request) { |
|
75 | - $this->appName = $appName; |
|
76 | - $this->request = $request; |
|
77 | - |
|
78 | - // default responders |
|
79 | - $this->responders = array( |
|
80 | - 'json' => function ($data) { |
|
81 | - if ($data instanceof DataResponse) { |
|
82 | - $response = new JSONResponse( |
|
83 | - $data->getData(), |
|
84 | - $data->getStatus() |
|
85 | - ); |
|
86 | - $dataHeaders = $data->getHeaders(); |
|
87 | - $headers = $response->getHeaders(); |
|
88 | - // do not overwrite Content-Type if it already exists |
|
89 | - if (isset($dataHeaders['Content-Type'])) { |
|
90 | - unset($headers['Content-Type']); |
|
91 | - } |
|
92 | - $response->setHeaders(array_merge($dataHeaders, $headers)); |
|
93 | - return $response; |
|
94 | - } |
|
95 | - return new JSONResponse($data); |
|
96 | - } |
|
97 | - ); |
|
98 | - } |
|
99 | - |
|
100 | - |
|
101 | - /** |
|
102 | - * Parses an HTTP accept header and returns the supported responder type |
|
103 | - * @param string $acceptHeader |
|
104 | - * @param string $default |
|
105 | - * @return string the responder type |
|
106 | - * @since 7.0.0 |
|
107 | - * @since 9.1.0 Added default parameter |
|
108 | - */ |
|
109 | - public function getResponderByHTTPHeader($acceptHeader, $default='json') { |
|
110 | - $headers = explode(',', $acceptHeader); |
|
111 | - |
|
112 | - // return the first matching responder |
|
113 | - foreach ($headers as $header) { |
|
114 | - $header = strtolower(trim($header)); |
|
115 | - |
|
116 | - $responder = str_replace('application/', '', $header); |
|
117 | - |
|
118 | - if (array_key_exists($responder, $this->responders)) { |
|
119 | - return $responder; |
|
120 | - } |
|
121 | - } |
|
122 | - |
|
123 | - // no matching header return default |
|
124 | - return $default; |
|
125 | - } |
|
126 | - |
|
127 | - |
|
128 | - /** |
|
129 | - * Registers a formatter for a type |
|
130 | - * @param string $format |
|
131 | - * @param \Closure $responder |
|
132 | - * @since 7.0.0 |
|
133 | - */ |
|
134 | - protected function registerResponder($format, \Closure $responder) { |
|
135 | - $this->responders[$format] = $responder; |
|
136 | - } |
|
137 | - |
|
138 | - |
|
139 | - /** |
|
140 | - * Serializes and formats a response |
|
141 | - * @param mixed $response the value that was returned from a controller and |
|
142 | - * is not a Response instance |
|
143 | - * @param string $format the format for which a formatter has been registered |
|
144 | - * @throws \DomainException if format does not match a registered formatter |
|
145 | - * @return Response |
|
146 | - * @since 7.0.0 |
|
147 | - */ |
|
148 | - public function buildResponse($response, $format='json') { |
|
149 | - if(array_key_exists($format, $this->responders)) { |
|
150 | - |
|
151 | - $responder = $this->responders[$format]; |
|
152 | - |
|
153 | - return $responder($response); |
|
154 | - |
|
155 | - } |
|
156 | - throw new \DomainException('No responder registered for format '. |
|
157 | - $format . '!'); |
|
158 | - } |
|
47 | + /** |
|
48 | + * app name |
|
49 | + * @var string |
|
50 | + * @since 7.0.0 |
|
51 | + */ |
|
52 | + protected $appName; |
|
53 | + |
|
54 | + /** |
|
55 | + * current request |
|
56 | + * @var \OCP\IRequest |
|
57 | + * @since 6.0.0 |
|
58 | + */ |
|
59 | + protected $request; |
|
60 | + |
|
61 | + /** |
|
62 | + * @var array |
|
63 | + * @since 7.0.0 |
|
64 | + */ |
|
65 | + private $responders; |
|
66 | + |
|
67 | + /** |
|
68 | + * constructor of the controller |
|
69 | + * @param string $appName the name of the app |
|
70 | + * @param IRequest $request an instance of the request |
|
71 | + * @since 6.0.0 - parameter $appName was added in 7.0.0 - parameter $app was removed in 7.0.0 |
|
72 | + */ |
|
73 | + public function __construct($appName, |
|
74 | + IRequest $request) { |
|
75 | + $this->appName = $appName; |
|
76 | + $this->request = $request; |
|
77 | + |
|
78 | + // default responders |
|
79 | + $this->responders = array( |
|
80 | + 'json' => function ($data) { |
|
81 | + if ($data instanceof DataResponse) { |
|
82 | + $response = new JSONResponse( |
|
83 | + $data->getData(), |
|
84 | + $data->getStatus() |
|
85 | + ); |
|
86 | + $dataHeaders = $data->getHeaders(); |
|
87 | + $headers = $response->getHeaders(); |
|
88 | + // do not overwrite Content-Type if it already exists |
|
89 | + if (isset($dataHeaders['Content-Type'])) { |
|
90 | + unset($headers['Content-Type']); |
|
91 | + } |
|
92 | + $response->setHeaders(array_merge($dataHeaders, $headers)); |
|
93 | + return $response; |
|
94 | + } |
|
95 | + return new JSONResponse($data); |
|
96 | + } |
|
97 | + ); |
|
98 | + } |
|
99 | + |
|
100 | + |
|
101 | + /** |
|
102 | + * Parses an HTTP accept header and returns the supported responder type |
|
103 | + * @param string $acceptHeader |
|
104 | + * @param string $default |
|
105 | + * @return string the responder type |
|
106 | + * @since 7.0.0 |
|
107 | + * @since 9.1.0 Added default parameter |
|
108 | + */ |
|
109 | + public function getResponderByHTTPHeader($acceptHeader, $default='json') { |
|
110 | + $headers = explode(',', $acceptHeader); |
|
111 | + |
|
112 | + // return the first matching responder |
|
113 | + foreach ($headers as $header) { |
|
114 | + $header = strtolower(trim($header)); |
|
115 | + |
|
116 | + $responder = str_replace('application/', '', $header); |
|
117 | + |
|
118 | + if (array_key_exists($responder, $this->responders)) { |
|
119 | + return $responder; |
|
120 | + } |
|
121 | + } |
|
122 | + |
|
123 | + // no matching header return default |
|
124 | + return $default; |
|
125 | + } |
|
126 | + |
|
127 | + |
|
128 | + /** |
|
129 | + * Registers a formatter for a type |
|
130 | + * @param string $format |
|
131 | + * @param \Closure $responder |
|
132 | + * @since 7.0.0 |
|
133 | + */ |
|
134 | + protected function registerResponder($format, \Closure $responder) { |
|
135 | + $this->responders[$format] = $responder; |
|
136 | + } |
|
137 | + |
|
138 | + |
|
139 | + /** |
|
140 | + * Serializes and formats a response |
|
141 | + * @param mixed $response the value that was returned from a controller and |
|
142 | + * is not a Response instance |
|
143 | + * @param string $format the format for which a formatter has been registered |
|
144 | + * @throws \DomainException if format does not match a registered formatter |
|
145 | + * @return Response |
|
146 | + * @since 7.0.0 |
|
147 | + */ |
|
148 | + public function buildResponse($response, $format='json') { |
|
149 | + if(array_key_exists($format, $this->responders)) { |
|
150 | + |
|
151 | + $responder = $this->responders[$format]; |
|
152 | + |
|
153 | + return $responder($response); |
|
154 | + |
|
155 | + } |
|
156 | + throw new \DomainException('No responder registered for format '. |
|
157 | + $format . '!'); |
|
158 | + } |
|
159 | 159 | } |
@@ -38,21 +38,21 @@ discard block |
||
38 | 38 | |
39 | 39 | // Backends |
40 | 40 | $authBackend = new OCA\DAV\Connector\PublicAuth( |
41 | - \OC::$server->getRequest(), |
|
42 | - \OC::$server->getShareManager(), |
|
43 | - \OC::$server->getSession() |
|
41 | + \OC::$server->getRequest(), |
|
42 | + \OC::$server->getShareManager(), |
|
43 | + \OC::$server->getSession() |
|
44 | 44 | ); |
45 | 45 | $authPlugin = new \Sabre\DAV\Auth\Plugin($authBackend); |
46 | 46 | |
47 | 47 | $serverFactory = new OCA\DAV\Connector\Sabre\ServerFactory( |
48 | - \OC::$server->getConfig(), |
|
49 | - \OC::$server->getLogger(), |
|
50 | - \OC::$server->getDatabaseConnection(), |
|
51 | - \OC::$server->getUserSession(), |
|
52 | - \OC::$server->getMountManager(), |
|
53 | - \OC::$server->getTagManager(), |
|
54 | - \OC::$server->getRequest(), |
|
55 | - \OC::$server->getPreviewManager() |
|
48 | + \OC::$server->getConfig(), |
|
49 | + \OC::$server->getLogger(), |
|
50 | + \OC::$server->getDatabaseConnection(), |
|
51 | + \OC::$server->getUserSession(), |
|
52 | + \OC::$server->getMountManager(), |
|
53 | + \OC::$server->getTagManager(), |
|
54 | + \OC::$server->getRequest(), |
|
55 | + \OC::$server->getPreviewManager() |
|
56 | 56 | ); |
57 | 57 | |
58 | 58 | $requestUri = \OC::$server->getRequest()->getRequestUri(); |
@@ -61,43 +61,43 @@ discard block |
||
61 | 61 | $filesDropPlugin = new \OCA\DAV\Files\Sharing\FilesDropPlugin(); |
62 | 62 | |
63 | 63 | $server = $serverFactory->createServer($baseuri, $requestUri, $authPlugin, function (\Sabre\DAV\Server $server) use ($authBackend, $linkCheckPlugin, $filesDropPlugin) { |
64 | - $isAjax = (isset($_SERVER['HTTP_X_REQUESTED_WITH']) && $_SERVER['HTTP_X_REQUESTED_WITH'] === 'XMLHttpRequest'); |
|
65 | - $federatedSharingApp = new \OCA\FederatedFileSharing\AppInfo\Application(); |
|
66 | - $federatedShareProvider = $federatedSharingApp->getFederatedShareProvider(); |
|
67 | - if ($federatedShareProvider->isOutgoingServer2serverShareEnabled() === false && !$isAjax) { |
|
68 | - // this is what is thrown when trying to access a non-existing share |
|
69 | - throw new \Sabre\DAV\Exception\NotAuthenticated(); |
|
70 | - } |
|
71 | - |
|
72 | - $share = $authBackend->getShare(); |
|
73 | - $owner = $share->getShareOwner(); |
|
74 | - $isReadable = $share->getPermissions() & \OCP\Constants::PERMISSION_READ; |
|
75 | - $fileId = $share->getNodeId(); |
|
76 | - |
|
77 | - // FIXME: should not add storage wrappers outside of preSetup, need to find a better way |
|
78 | - $previousLog = \OC\Files\Filesystem::logWarningWhenAddingStorageWrapper(false); |
|
79 | - \OC\Files\Filesystem::addStorageWrapper('sharePermissions', function ($mountPoint, $storage) use ($share) { |
|
80 | - return new \OC\Files\Storage\Wrapper\PermissionsMask(array('storage' => $storage, 'mask' => $share->getPermissions() | \OCP\Constants::PERMISSION_SHARE)); |
|
81 | - }); |
|
82 | - |
|
83 | - \OC\Files\Filesystem::logWarningWhenAddingStorageWrapper($previousLog); |
|
84 | - |
|
85 | - OC_Util::tearDownFS(); |
|
86 | - OC_Util::setupFS($owner); |
|
87 | - $ownerView = new \OC\Files\View('/'. $owner . '/files'); |
|
88 | - $path = $ownerView->getPath($fileId); |
|
89 | - $fileInfo = $ownerView->getFileInfo($path); |
|
90 | - $linkCheckPlugin->setFileInfo($fileInfo); |
|
91 | - |
|
92 | - // If not readble (files_drop) enable the filesdrop plugin |
|
93 | - if (!$isReadable) { |
|
94 | - $filesDropPlugin->enable(); |
|
95 | - } |
|
96 | - |
|
97 | - $view = new \OC\Files\View($ownerView->getAbsolutePath($path)); |
|
98 | - $filesDropPlugin->setView($view); |
|
99 | - |
|
100 | - return $view; |
|
64 | + $isAjax = (isset($_SERVER['HTTP_X_REQUESTED_WITH']) && $_SERVER['HTTP_X_REQUESTED_WITH'] === 'XMLHttpRequest'); |
|
65 | + $federatedSharingApp = new \OCA\FederatedFileSharing\AppInfo\Application(); |
|
66 | + $federatedShareProvider = $federatedSharingApp->getFederatedShareProvider(); |
|
67 | + if ($federatedShareProvider->isOutgoingServer2serverShareEnabled() === false && !$isAjax) { |
|
68 | + // this is what is thrown when trying to access a non-existing share |
|
69 | + throw new \Sabre\DAV\Exception\NotAuthenticated(); |
|
70 | + } |
|
71 | + |
|
72 | + $share = $authBackend->getShare(); |
|
73 | + $owner = $share->getShareOwner(); |
|
74 | + $isReadable = $share->getPermissions() & \OCP\Constants::PERMISSION_READ; |
|
75 | + $fileId = $share->getNodeId(); |
|
76 | + |
|
77 | + // FIXME: should not add storage wrappers outside of preSetup, need to find a better way |
|
78 | + $previousLog = \OC\Files\Filesystem::logWarningWhenAddingStorageWrapper(false); |
|
79 | + \OC\Files\Filesystem::addStorageWrapper('sharePermissions', function ($mountPoint, $storage) use ($share) { |
|
80 | + return new \OC\Files\Storage\Wrapper\PermissionsMask(array('storage' => $storage, 'mask' => $share->getPermissions() | \OCP\Constants::PERMISSION_SHARE)); |
|
81 | + }); |
|
82 | + |
|
83 | + \OC\Files\Filesystem::logWarningWhenAddingStorageWrapper($previousLog); |
|
84 | + |
|
85 | + OC_Util::tearDownFS(); |
|
86 | + OC_Util::setupFS($owner); |
|
87 | + $ownerView = new \OC\Files\View('/'. $owner . '/files'); |
|
88 | + $path = $ownerView->getPath($fileId); |
|
89 | + $fileInfo = $ownerView->getFileInfo($path); |
|
90 | + $linkCheckPlugin->setFileInfo($fileInfo); |
|
91 | + |
|
92 | + // If not readble (files_drop) enable the filesdrop plugin |
|
93 | + if (!$isReadable) { |
|
94 | + $filesDropPlugin->enable(); |
|
95 | + } |
|
96 | + |
|
97 | + $view = new \OC\Files\View($ownerView->getAbsolutePath($path)); |
|
98 | + $filesDropPlugin->setView($view); |
|
99 | + |
|
100 | + return $view; |
|
101 | 101 | }); |
102 | 102 | |
103 | 103 | $server->addPlugin($linkCheckPlugin); |
@@ -27,55 +27,55 @@ |
||
27 | 27 | use OCP\DB\QueryBuilder\IQueryFunction; |
28 | 28 | |
29 | 29 | class QuoteHelper { |
30 | - /** |
|
31 | - * @param array|string|ILiteral|IParameter|IQueryFunction $strings string, Literal or Parameter |
|
32 | - * @return array|string |
|
33 | - */ |
|
34 | - public function quoteColumnNames($strings) { |
|
35 | - if (!is_array($strings)) { |
|
36 | - return $this->quoteColumnName($strings); |
|
37 | - } |
|
30 | + /** |
|
31 | + * @param array|string|ILiteral|IParameter|IQueryFunction $strings string, Literal or Parameter |
|
32 | + * @return array|string |
|
33 | + */ |
|
34 | + public function quoteColumnNames($strings) { |
|
35 | + if (!is_array($strings)) { |
|
36 | + return $this->quoteColumnName($strings); |
|
37 | + } |
|
38 | 38 | |
39 | - $return = []; |
|
40 | - foreach ($strings as $string) { |
|
41 | - $return[] = $this->quoteColumnName($string); |
|
42 | - } |
|
39 | + $return = []; |
|
40 | + foreach ($strings as $string) { |
|
41 | + $return[] = $this->quoteColumnName($string); |
|
42 | + } |
|
43 | 43 | |
44 | - return $return; |
|
45 | - } |
|
44 | + return $return; |
|
45 | + } |
|
46 | 46 | |
47 | - /** |
|
48 | - * @param string|ILiteral|IParameter|IQueryFunction $string string, Literal or Parameter |
|
49 | - * @return string |
|
50 | - */ |
|
51 | - public function quoteColumnName($string) { |
|
52 | - if ($string instanceof IParameter || $string instanceof ILiteral || $string instanceof IQueryFunction) { |
|
53 | - return (string) $string; |
|
54 | - } |
|
47 | + /** |
|
48 | + * @param string|ILiteral|IParameter|IQueryFunction $string string, Literal or Parameter |
|
49 | + * @return string |
|
50 | + */ |
|
51 | + public function quoteColumnName($string) { |
|
52 | + if ($string instanceof IParameter || $string instanceof ILiteral || $string instanceof IQueryFunction) { |
|
53 | + return (string) $string; |
|
54 | + } |
|
55 | 55 | |
56 | - if ($string === null || $string === 'null' || $string === '*') { |
|
57 | - return $string; |
|
58 | - } |
|
56 | + if ($string === null || $string === 'null' || $string === '*') { |
|
57 | + return $string; |
|
58 | + } |
|
59 | 59 | |
60 | - if (!is_string($string)) { |
|
61 | - throw new \InvalidArgumentException('Only strings, Literals and Parameters are allowed'); |
|
62 | - } |
|
60 | + if (!is_string($string)) { |
|
61 | + throw new \InvalidArgumentException('Only strings, Literals and Parameters are allowed'); |
|
62 | + } |
|
63 | 63 | |
64 | - $string = str_replace(' AS ', ' as ', $string); |
|
65 | - if (substr_count($string, ' as ')) { |
|
66 | - return implode(' as ', array_map([$this, 'quoteColumnName'], explode(' as ', $string, 2))); |
|
67 | - } |
|
64 | + $string = str_replace(' AS ', ' as ', $string); |
|
65 | + if (substr_count($string, ' as ')) { |
|
66 | + return implode(' as ', array_map([$this, 'quoteColumnName'], explode(' as ', $string, 2))); |
|
67 | + } |
|
68 | 68 | |
69 | - if (substr_count($string, '.')) { |
|
70 | - list($alias, $columnName) = explode('.', $string, 2); |
|
69 | + if (substr_count($string, '.')) { |
|
70 | + list($alias, $columnName) = explode('.', $string, 2); |
|
71 | 71 | |
72 | - if ($columnName === '*') { |
|
73 | - return '`' . $alias . '`.*'; |
|
74 | - } |
|
72 | + if ($columnName === '*') { |
|
73 | + return '`' . $alias . '`.*'; |
|
74 | + } |
|
75 | 75 | |
76 | - return '`' . $alias . '`.`' . $columnName . '`'; |
|
77 | - } |
|
76 | + return '`' . $alias . '`.`' . $columnName . '`'; |
|
77 | + } |
|
78 | 78 | |
79 | - return '`' . $string . '`'; |
|
80 | - } |
|
79 | + return '`' . $string . '`'; |
|
80 | + } |
|
81 | 81 | } |