@@ -38,102 +38,102 @@ |
||
38 | 38 | * @package OCA\DAV\CalDAV\BirthdayCalendar |
39 | 39 | */ |
40 | 40 | class EnablePlugin extends ServerPlugin { |
41 | - const NS_Nextcloud = 'http://nextcloud.com/ns'; |
|
42 | - |
|
43 | - /** |
|
44 | - * @var IConfig |
|
45 | - */ |
|
46 | - protected $config; |
|
47 | - |
|
48 | - /** |
|
49 | - * @var BirthdayService |
|
50 | - */ |
|
51 | - protected $birthdayService; |
|
52 | - |
|
53 | - /** |
|
54 | - * @var Server |
|
55 | - */ |
|
56 | - protected $server; |
|
57 | - |
|
58 | - /** |
|
59 | - * PublishPlugin constructor. |
|
60 | - * |
|
61 | - * @param IConfig $config |
|
62 | - * @param BirthdayService $birthdayService |
|
63 | - */ |
|
64 | - public function __construct(IConfig $config, BirthdayService $birthdayService) { |
|
65 | - $this->config = $config; |
|
66 | - $this->birthdayService = $birthdayService; |
|
67 | - } |
|
68 | - |
|
69 | - /** |
|
70 | - * This method should return a list of server-features. |
|
71 | - * |
|
72 | - * This is for example 'versioning' and is added to the DAV: header |
|
73 | - * in an OPTIONS response. |
|
74 | - * |
|
75 | - * @return string[] |
|
76 | - */ |
|
77 | - public function getFeatures() { |
|
78 | - return ['nc-enable-birthday-calendar']; |
|
79 | - } |
|
80 | - |
|
81 | - /** |
|
82 | - * Returns a plugin name. |
|
83 | - * |
|
84 | - * Using this name other plugins will be able to access other plugins |
|
85 | - * using Sabre\DAV\Server::getPlugin |
|
86 | - * |
|
87 | - * @return string |
|
88 | - */ |
|
89 | - public function getPluginName() { |
|
90 | - return 'nc-enable-birthday-calendar'; |
|
91 | - } |
|
92 | - |
|
93 | - /** |
|
94 | - * This initializes the plugin. |
|
95 | - * |
|
96 | - * This function is called by Sabre\DAV\Server, after |
|
97 | - * addPlugin is called. |
|
98 | - * |
|
99 | - * This method should set up the required event subscriptions. |
|
100 | - * |
|
101 | - * @param Server $server |
|
102 | - */ |
|
103 | - public function initialize(Server $server) { |
|
104 | - $this->server = $server; |
|
105 | - |
|
106 | - $this->server->on('method:POST', [$this, 'httpPost']); |
|
107 | - } |
|
108 | - |
|
109 | - /** |
|
110 | - * We intercept this to handle POST requests on calendar homes. |
|
111 | - * |
|
112 | - * @param RequestInterface $request |
|
113 | - * @param ResponseInterface $response |
|
114 | - * |
|
115 | - * @return bool|void |
|
116 | - */ |
|
117 | - public function httpPost(RequestInterface $request, ResponseInterface $response) { |
|
118 | - $node = $this->server->tree->getNodeForPath($this->server->getRequestUri()); |
|
119 | - if (!($node instanceof CalendarHome)) { |
|
120 | - return; |
|
121 | - } |
|
122 | - |
|
123 | - $requestBody = $request->getBodyAsString(); |
|
124 | - $this->server->xml->parse($requestBody, $request->getUrl(), $documentType); |
|
125 | - if ($documentType !== '{'.self::NS_Nextcloud.'}enable-birthday-calendar') { |
|
126 | - return; |
|
127 | - } |
|
128 | - |
|
129 | - $principalUri = $node->getOwner(); |
|
130 | - $userId = substr($principalUri, 17); |
|
131 | - |
|
132 | - $this->config->setUserValue($userId, 'dav', 'generateBirthdayCalendar', 'yes'); |
|
133 | - $this->birthdayService->syncUser($userId); |
|
134 | - |
|
135 | - $this->server->httpResponse->setStatus(204); |
|
136 | - |
|
137 | - return false; |
|
138 | - } |
|
41 | + const NS_Nextcloud = 'http://nextcloud.com/ns'; |
|
42 | + |
|
43 | + /** |
|
44 | + * @var IConfig |
|
45 | + */ |
|
46 | + protected $config; |
|
47 | + |
|
48 | + /** |
|
49 | + * @var BirthdayService |
|
50 | + */ |
|
51 | + protected $birthdayService; |
|
52 | + |
|
53 | + /** |
|
54 | + * @var Server |
|
55 | + */ |
|
56 | + protected $server; |
|
57 | + |
|
58 | + /** |
|
59 | + * PublishPlugin constructor. |
|
60 | + * |
|
61 | + * @param IConfig $config |
|
62 | + * @param BirthdayService $birthdayService |
|
63 | + */ |
|
64 | + public function __construct(IConfig $config, BirthdayService $birthdayService) { |
|
65 | + $this->config = $config; |
|
66 | + $this->birthdayService = $birthdayService; |
|
67 | + } |
|
68 | + |
|
69 | + /** |
|
70 | + * This method should return a list of server-features. |
|
71 | + * |
|
72 | + * This is for example 'versioning' and is added to the DAV: header |
|
73 | + * in an OPTIONS response. |
|
74 | + * |
|
75 | + * @return string[] |
|
76 | + */ |
|
77 | + public function getFeatures() { |
|
78 | + return ['nc-enable-birthday-calendar']; |
|
79 | + } |
|
80 | + |
|
81 | + /** |
|
82 | + * Returns a plugin name. |
|
83 | + * |
|
84 | + * Using this name other plugins will be able to access other plugins |
|
85 | + * using Sabre\DAV\Server::getPlugin |
|
86 | + * |
|
87 | + * @return string |
|
88 | + */ |
|
89 | + public function getPluginName() { |
|
90 | + return 'nc-enable-birthday-calendar'; |
|
91 | + } |
|
92 | + |
|
93 | + /** |
|
94 | + * This initializes the plugin. |
|
95 | + * |
|
96 | + * This function is called by Sabre\DAV\Server, after |
|
97 | + * addPlugin is called. |
|
98 | + * |
|
99 | + * This method should set up the required event subscriptions. |
|
100 | + * |
|
101 | + * @param Server $server |
|
102 | + */ |
|
103 | + public function initialize(Server $server) { |
|
104 | + $this->server = $server; |
|
105 | + |
|
106 | + $this->server->on('method:POST', [$this, 'httpPost']); |
|
107 | + } |
|
108 | + |
|
109 | + /** |
|
110 | + * We intercept this to handle POST requests on calendar homes. |
|
111 | + * |
|
112 | + * @param RequestInterface $request |
|
113 | + * @param ResponseInterface $response |
|
114 | + * |
|
115 | + * @return bool|void |
|
116 | + */ |
|
117 | + public function httpPost(RequestInterface $request, ResponseInterface $response) { |
|
118 | + $node = $this->server->tree->getNodeForPath($this->server->getRequestUri()); |
|
119 | + if (!($node instanceof CalendarHome)) { |
|
120 | + return; |
|
121 | + } |
|
122 | + |
|
123 | + $requestBody = $request->getBodyAsString(); |
|
124 | + $this->server->xml->parse($requestBody, $request->getUrl(), $documentType); |
|
125 | + if ($documentType !== '{'.self::NS_Nextcloud.'}enable-birthday-calendar') { |
|
126 | + return; |
|
127 | + } |
|
128 | + |
|
129 | + $principalUri = $node->getOwner(); |
|
130 | + $userId = substr($principalUri, 17); |
|
131 | + |
|
132 | + $this->config->setUserValue($userId, 'dav', 'generateBirthdayCalendar', 'yes'); |
|
133 | + $this->birthdayService->syncUser($userId); |
|
134 | + |
|
135 | + $this->server->httpResponse->setStatus(204); |
|
136 | + |
|
137 | + return false; |
|
138 | + } |
|
139 | 139 | } |
@@ -32,114 +32,114 @@ |
||
32 | 32 | |
33 | 33 | class CalendarObject extends \Sabre\CalDAV\CalendarObject { |
34 | 34 | |
35 | - /** |
|
36 | - * CalendarObject constructor. |
|
37 | - * |
|
38 | - * @param CalDavBackend $caldavBackend |
|
39 | - * @param array $calendarInfo |
|
40 | - * @param array $objectData |
|
41 | - */ |
|
42 | - public function __construct(CalDavBackend $caldavBackend, array $calendarInfo, |
|
43 | - array $objectData) { |
|
44 | - parent::__construct($caldavBackend, $calendarInfo, $objectData); |
|
45 | - |
|
46 | - if ($this->isShared()) { |
|
47 | - unset($this->objectData['size']); |
|
48 | - } |
|
49 | - } |
|
50 | - |
|
51 | - /** |
|
52 | - * @inheritdoc |
|
53 | - */ |
|
54 | - function get() { |
|
55 | - $data = parent::get(); |
|
56 | - |
|
57 | - if (!$this->isShared()) { |
|
58 | - return $data; |
|
59 | - } |
|
60 | - |
|
61 | - $vObject = Reader::read($data); |
|
62 | - |
|
63 | - // remove VAlarms if calendar is shared read-only |
|
64 | - if (!$this->canWrite()) { |
|
65 | - $this->removeVAlarms($vObject); |
|
66 | - } |
|
67 | - |
|
68 | - // shows as busy if event is declared confidential |
|
69 | - if ($this->objectData['classification'] === CalDavBackend::CLASSIFICATION_CONFIDENTIAL) { |
|
70 | - $this->createConfidentialObject($vObject); |
|
71 | - } |
|
72 | - |
|
73 | - return $vObject->serialize(); |
|
74 | - } |
|
75 | - |
|
76 | - protected function isShared() { |
|
77 | - if (!isset($this->calendarInfo['{http://owncloud.org/ns}owner-principal'])) { |
|
78 | - return false; |
|
79 | - } |
|
80 | - |
|
81 | - return $this->calendarInfo['{http://owncloud.org/ns}owner-principal'] !== $this->calendarInfo['principaluri']; |
|
82 | - } |
|
83 | - |
|
84 | - /** |
|
85 | - * @param Component\VCalendar $vObject |
|
86 | - * @return void |
|
87 | - */ |
|
88 | - private static function createConfidentialObject(Component\VCalendar $vObject) { |
|
89 | - /** @var Component $vElement */ |
|
90 | - $vElement = null; |
|
91 | - if(isset($vObject->VEVENT)) { |
|
92 | - $vElement = $vObject->VEVENT; |
|
93 | - } |
|
94 | - if(isset($vObject->VJOURNAL)) { |
|
95 | - $vElement = $vObject->VJOURNAL; |
|
96 | - } |
|
97 | - if(isset($vObject->VTODO)) { |
|
98 | - $vElement = $vObject->VTODO; |
|
99 | - } |
|
100 | - if(!is_null($vElement)) { |
|
101 | - foreach ($vElement->children() as &$property) { |
|
102 | - /** @var Property $property */ |
|
103 | - switch($property->name) { |
|
104 | - case 'CREATED': |
|
105 | - case 'DTSTART': |
|
106 | - case 'RRULE': |
|
107 | - case 'DURATION': |
|
108 | - case 'DTEND': |
|
109 | - case 'CLASS': |
|
110 | - case 'UID': |
|
111 | - break; |
|
112 | - case 'SUMMARY': |
|
113 | - $property->setValue('Busy'); |
|
114 | - break; |
|
115 | - default: |
|
116 | - $vElement->__unset($property->name); |
|
117 | - unset($property); |
|
118 | - break; |
|
119 | - } |
|
120 | - } |
|
121 | - } |
|
122 | - } |
|
123 | - |
|
124 | - /** |
|
125 | - * @param Component\VCalendar $vObject |
|
126 | - * @return void |
|
127 | - */ |
|
128 | - private function removeVAlarms(Component\VCalendar $vObject) { |
|
129 | - $subcomponents = $vObject->getComponents(); |
|
130 | - |
|
131 | - foreach($subcomponents as $subcomponent) { |
|
132 | - unset($subcomponent->VALARM); |
|
133 | - } |
|
134 | - } |
|
135 | - |
|
136 | - /** |
|
137 | - * @return bool |
|
138 | - */ |
|
139 | - private function canWrite() { |
|
140 | - if (isset($this->calendarInfo['{http://owncloud.org/ns}read-only'])) { |
|
141 | - return !$this->calendarInfo['{http://owncloud.org/ns}read-only']; |
|
142 | - } |
|
143 | - return true; |
|
144 | - } |
|
35 | + /** |
|
36 | + * CalendarObject constructor. |
|
37 | + * |
|
38 | + * @param CalDavBackend $caldavBackend |
|
39 | + * @param array $calendarInfo |
|
40 | + * @param array $objectData |
|
41 | + */ |
|
42 | + public function __construct(CalDavBackend $caldavBackend, array $calendarInfo, |
|
43 | + array $objectData) { |
|
44 | + parent::__construct($caldavBackend, $calendarInfo, $objectData); |
|
45 | + |
|
46 | + if ($this->isShared()) { |
|
47 | + unset($this->objectData['size']); |
|
48 | + } |
|
49 | + } |
|
50 | + |
|
51 | + /** |
|
52 | + * @inheritdoc |
|
53 | + */ |
|
54 | + function get() { |
|
55 | + $data = parent::get(); |
|
56 | + |
|
57 | + if (!$this->isShared()) { |
|
58 | + return $data; |
|
59 | + } |
|
60 | + |
|
61 | + $vObject = Reader::read($data); |
|
62 | + |
|
63 | + // remove VAlarms if calendar is shared read-only |
|
64 | + if (!$this->canWrite()) { |
|
65 | + $this->removeVAlarms($vObject); |
|
66 | + } |
|
67 | + |
|
68 | + // shows as busy if event is declared confidential |
|
69 | + if ($this->objectData['classification'] === CalDavBackend::CLASSIFICATION_CONFIDENTIAL) { |
|
70 | + $this->createConfidentialObject($vObject); |
|
71 | + } |
|
72 | + |
|
73 | + return $vObject->serialize(); |
|
74 | + } |
|
75 | + |
|
76 | + protected function isShared() { |
|
77 | + if (!isset($this->calendarInfo['{http://owncloud.org/ns}owner-principal'])) { |
|
78 | + return false; |
|
79 | + } |
|
80 | + |
|
81 | + return $this->calendarInfo['{http://owncloud.org/ns}owner-principal'] !== $this->calendarInfo['principaluri']; |
|
82 | + } |
|
83 | + |
|
84 | + /** |
|
85 | + * @param Component\VCalendar $vObject |
|
86 | + * @return void |
|
87 | + */ |
|
88 | + private static function createConfidentialObject(Component\VCalendar $vObject) { |
|
89 | + /** @var Component $vElement */ |
|
90 | + $vElement = null; |
|
91 | + if(isset($vObject->VEVENT)) { |
|
92 | + $vElement = $vObject->VEVENT; |
|
93 | + } |
|
94 | + if(isset($vObject->VJOURNAL)) { |
|
95 | + $vElement = $vObject->VJOURNAL; |
|
96 | + } |
|
97 | + if(isset($vObject->VTODO)) { |
|
98 | + $vElement = $vObject->VTODO; |
|
99 | + } |
|
100 | + if(!is_null($vElement)) { |
|
101 | + foreach ($vElement->children() as &$property) { |
|
102 | + /** @var Property $property */ |
|
103 | + switch($property->name) { |
|
104 | + case 'CREATED': |
|
105 | + case 'DTSTART': |
|
106 | + case 'RRULE': |
|
107 | + case 'DURATION': |
|
108 | + case 'DTEND': |
|
109 | + case 'CLASS': |
|
110 | + case 'UID': |
|
111 | + break; |
|
112 | + case 'SUMMARY': |
|
113 | + $property->setValue('Busy'); |
|
114 | + break; |
|
115 | + default: |
|
116 | + $vElement->__unset($property->name); |
|
117 | + unset($property); |
|
118 | + break; |
|
119 | + } |
|
120 | + } |
|
121 | + } |
|
122 | + } |
|
123 | + |
|
124 | + /** |
|
125 | + * @param Component\VCalendar $vObject |
|
126 | + * @return void |
|
127 | + */ |
|
128 | + private function removeVAlarms(Component\VCalendar $vObject) { |
|
129 | + $subcomponents = $vObject->getComponents(); |
|
130 | + |
|
131 | + foreach($subcomponents as $subcomponent) { |
|
132 | + unset($subcomponent->VALARM); |
|
133 | + } |
|
134 | + } |
|
135 | + |
|
136 | + /** |
|
137 | + * @return bool |
|
138 | + */ |
|
139 | + private function canWrite() { |
|
140 | + if (isset($this->calendarInfo['{http://owncloud.org/ns}read-only'])) { |
|
141 | + return !$this->calendarInfo['{http://owncloud.org/ns}read-only']; |
|
142 | + } |
|
143 | + return true; |
|
144 | + } |
|
145 | 145 | } |
@@ -30,12 +30,12 @@ |
||
30 | 30 | */ |
31 | 31 | interface IReporter { |
32 | 32 | |
33 | - /** |
|
34 | - * Report an (unhandled) exception |
|
35 | - * |
|
36 | - * @since 13.0.0 |
|
37 | - * @param Exception|Throwable $exception |
|
38 | - * @param array $context |
|
39 | - */ |
|
40 | - public function report($exception, array $context = []); |
|
33 | + /** |
|
34 | + * Report an (unhandled) exception |
|
35 | + * |
|
36 | + * @since 13.0.0 |
|
37 | + * @param Exception|Throwable $exception |
|
38 | + * @param array $context |
|
39 | + */ |
|
40 | + public function report($exception, array $context = []); |
|
41 | 41 | } |
@@ -24,80 +24,80 @@ |
||
24 | 24 | |
25 | 25 | trait EmitterTrait { |
26 | 26 | |
27 | - /** |
|
28 | - * @var callable[][] $listeners |
|
29 | - */ |
|
30 | - protected $listeners = array(); |
|
27 | + /** |
|
28 | + * @var callable[][] $listeners |
|
29 | + */ |
|
30 | + protected $listeners = array(); |
|
31 | 31 | |
32 | - /** |
|
33 | - * @param string $scope |
|
34 | - * @param string $method |
|
35 | - * @param callable $callback |
|
36 | - */ |
|
37 | - public function listen($scope, $method, callable $callback) { |
|
38 | - $eventName = $scope . '::' . $method; |
|
39 | - if (!isset($this->listeners[$eventName])) { |
|
40 | - $this->listeners[$eventName] = array(); |
|
41 | - } |
|
42 | - if (array_search($callback, $this->listeners[$eventName], true) === false) { |
|
43 | - $this->listeners[$eventName][] = $callback; |
|
44 | - } |
|
45 | - } |
|
32 | + /** |
|
33 | + * @param string $scope |
|
34 | + * @param string $method |
|
35 | + * @param callable $callback |
|
36 | + */ |
|
37 | + public function listen($scope, $method, callable $callback) { |
|
38 | + $eventName = $scope . '::' . $method; |
|
39 | + if (!isset($this->listeners[$eventName])) { |
|
40 | + $this->listeners[$eventName] = array(); |
|
41 | + } |
|
42 | + if (array_search($callback, $this->listeners[$eventName], true) === false) { |
|
43 | + $this->listeners[$eventName][] = $callback; |
|
44 | + } |
|
45 | + } |
|
46 | 46 | |
47 | - /** |
|
48 | - * @param string $scope optional |
|
49 | - * @param string $method optional |
|
50 | - * @param callable $callback optional |
|
51 | - */ |
|
52 | - public function removeListener($scope = null, $method = null, callable $callback = null) { |
|
53 | - $names = array(); |
|
54 | - $allNames = array_keys($this->listeners); |
|
55 | - if ($scope and $method) { |
|
56 | - $name = $scope . '::' . $method; |
|
57 | - if (isset($this->listeners[$name])) { |
|
58 | - $names[] = $name; |
|
59 | - } |
|
60 | - } elseif ($scope) { |
|
61 | - foreach ($allNames as $name) { |
|
62 | - $parts = explode('::', $name, 2); |
|
63 | - if ($parts[0] == $scope) { |
|
64 | - $names[] = $name; |
|
65 | - } |
|
66 | - } |
|
67 | - } elseif ($method) { |
|
68 | - foreach ($allNames as $name) { |
|
69 | - $parts = explode('::', $name, 2); |
|
70 | - if ($parts[1] == $method) { |
|
71 | - $names[] = $name; |
|
72 | - } |
|
73 | - } |
|
74 | - } else { |
|
75 | - $names = $allNames; |
|
76 | - } |
|
47 | + /** |
|
48 | + * @param string $scope optional |
|
49 | + * @param string $method optional |
|
50 | + * @param callable $callback optional |
|
51 | + */ |
|
52 | + public function removeListener($scope = null, $method = null, callable $callback = null) { |
|
53 | + $names = array(); |
|
54 | + $allNames = array_keys($this->listeners); |
|
55 | + if ($scope and $method) { |
|
56 | + $name = $scope . '::' . $method; |
|
57 | + if (isset($this->listeners[$name])) { |
|
58 | + $names[] = $name; |
|
59 | + } |
|
60 | + } elseif ($scope) { |
|
61 | + foreach ($allNames as $name) { |
|
62 | + $parts = explode('::', $name, 2); |
|
63 | + if ($parts[0] == $scope) { |
|
64 | + $names[] = $name; |
|
65 | + } |
|
66 | + } |
|
67 | + } elseif ($method) { |
|
68 | + foreach ($allNames as $name) { |
|
69 | + $parts = explode('::', $name, 2); |
|
70 | + if ($parts[1] == $method) { |
|
71 | + $names[] = $name; |
|
72 | + } |
|
73 | + } |
|
74 | + } else { |
|
75 | + $names = $allNames; |
|
76 | + } |
|
77 | 77 | |
78 | - foreach ($names as $name) { |
|
79 | - if ($callback) { |
|
80 | - $index = array_search($callback, $this->listeners[$name], true); |
|
81 | - if ($index !== false) { |
|
82 | - unset($this->listeners[$name][$index]); |
|
83 | - } |
|
84 | - } else { |
|
85 | - $this->listeners[$name] = array(); |
|
86 | - } |
|
87 | - } |
|
88 | - } |
|
78 | + foreach ($names as $name) { |
|
79 | + if ($callback) { |
|
80 | + $index = array_search($callback, $this->listeners[$name], true); |
|
81 | + if ($index !== false) { |
|
82 | + unset($this->listeners[$name][$index]); |
|
83 | + } |
|
84 | + } else { |
|
85 | + $this->listeners[$name] = array(); |
|
86 | + } |
|
87 | + } |
|
88 | + } |
|
89 | 89 | |
90 | - /** |
|
91 | - * @param string $scope |
|
92 | - * @param string $method |
|
93 | - * @param array $arguments optional |
|
94 | - */ |
|
95 | - protected function emit($scope, $method, array $arguments = array()) { |
|
96 | - $eventName = $scope . '::' . $method; |
|
97 | - if (isset($this->listeners[$eventName])) { |
|
98 | - foreach ($this->listeners[$eventName] as $callback) { |
|
99 | - call_user_func_array($callback, $arguments); |
|
100 | - } |
|
101 | - } |
|
102 | - } |
|
90 | + /** |
|
91 | + * @param string $scope |
|
92 | + * @param string $method |
|
93 | + * @param array $arguments optional |
|
94 | + */ |
|
95 | + protected function emit($scope, $method, array $arguments = array()) { |
|
96 | + $eventName = $scope . '::' . $method; |
|
97 | + if (isset($this->listeners[$eventName])) { |
|
98 | + foreach ($this->listeners[$eventName] as $callback) { |
|
99 | + call_user_func_array($callback, $arguments); |
|
100 | + } |
|
101 | + } |
|
102 | + } |
|
103 | 103 | } |
@@ -40,186 +40,186 @@ |
||
40 | 40 | */ |
41 | 41 | class Defaults { |
42 | 42 | |
43 | - /** |
|
44 | - * \OC_Defaults instance to retrieve the defaults |
|
45 | - * @since 6.0.0 |
|
46 | - */ |
|
47 | - private $defaults; |
|
48 | - |
|
49 | - /** |
|
50 | - * creates a \OC_Defaults instance which is used in all methods to retrieve the |
|
51 | - * actual defaults |
|
52 | - * @since 6.0.0 |
|
53 | - */ |
|
54 | - public function __construct(\OC_Defaults $defaults = null) { |
|
55 | - if ($defaults === null) { |
|
56 | - $defaults = \OC::$server->getThemingDefaults(); |
|
57 | - } |
|
58 | - $this->defaults = $defaults; |
|
59 | - } |
|
60 | - |
|
61 | - /** |
|
62 | - * get base URL for the organisation behind your ownCloud instance |
|
63 | - * @return string |
|
64 | - * @since 6.0.0 |
|
65 | - */ |
|
66 | - public function getBaseUrl() { |
|
67 | - return $this->defaults->getBaseUrl(); |
|
68 | - } |
|
69 | - |
|
70 | - /** |
|
71 | - * link to the desktop sync client |
|
72 | - * @return string |
|
73 | - * @since 6.0.0 |
|
74 | - */ |
|
75 | - public function getSyncClientUrl() { |
|
76 | - return $this->defaults->getSyncClientUrl(); |
|
77 | - } |
|
78 | - |
|
79 | - /** |
|
80 | - * link to the iOS client |
|
81 | - * @return string |
|
82 | - * @since 8.0.0 |
|
83 | - */ |
|
84 | - public function getiOSClientUrl() { |
|
85 | - return $this->defaults->getiOSClientUrl(); |
|
86 | - } |
|
87 | - |
|
88 | - /** |
|
89 | - * link to the Android client |
|
90 | - * @return string |
|
91 | - * @since 8.0.0 |
|
92 | - */ |
|
93 | - public function getAndroidClientUrl() { |
|
94 | - return $this->defaults->getAndroidClientUrl(); |
|
95 | - } |
|
96 | - |
|
97 | - /** |
|
98 | - * base URL to the documentation of your ownCloud instance |
|
99 | - * @return string |
|
100 | - * @since 6.0.0 |
|
101 | - */ |
|
102 | - public function getDocBaseUrl() { |
|
103 | - return $this->defaults->getDocBaseUrl(); |
|
104 | - } |
|
105 | - |
|
106 | - /** |
|
107 | - * name of your ownCloud instance |
|
108 | - * @return string |
|
109 | - * @since 6.0.0 |
|
110 | - */ |
|
111 | - public function getName() { |
|
112 | - return $this->defaults->getName(); |
|
113 | - } |
|
114 | - |
|
115 | - /** |
|
116 | - * name of your ownCloud instance containing HTML styles |
|
117 | - * @return string |
|
118 | - * @since 8.0.0 |
|
119 | - */ |
|
120 | - public function getHTMLName() { |
|
121 | - return $this->defaults->getHTMLName(); |
|
122 | - } |
|
123 | - |
|
124 | - /** |
|
125 | - * Entity behind your onwCloud instance |
|
126 | - * @return string |
|
127 | - * @since 6.0.0 |
|
128 | - */ |
|
129 | - public function getEntity() { |
|
130 | - return $this->defaults->getEntity(); |
|
131 | - } |
|
132 | - |
|
133 | - /** |
|
134 | - * ownCloud slogan |
|
135 | - * @return string |
|
136 | - * @since 6.0.0 |
|
137 | - */ |
|
138 | - public function getSlogan() { |
|
139 | - return $this->defaults->getSlogan(); |
|
140 | - } |
|
141 | - |
|
142 | - /** |
|
143 | - * logo claim |
|
144 | - * @return string |
|
145 | - * @since 6.0.0 |
|
146 | - * @deprecated 13.0.0 |
|
147 | - */ |
|
148 | - public function getLogoClaim() { |
|
149 | - return ''; |
|
150 | - } |
|
151 | - |
|
152 | - /** |
|
153 | - * footer, short version |
|
154 | - * @return string |
|
155 | - * @since 6.0.0 |
|
156 | - */ |
|
157 | - public function getShortFooter() { |
|
158 | - return $this->defaults->getShortFooter(); |
|
159 | - } |
|
160 | - |
|
161 | - /** |
|
162 | - * footer, long version |
|
163 | - * @return string |
|
164 | - * @since 6.0.0 |
|
165 | - */ |
|
166 | - public function getLongFooter() { |
|
167 | - return $this->defaults->getLongFooter(); |
|
168 | - } |
|
169 | - |
|
170 | - /** |
|
171 | - * Returns the AppId for the App Store for the iOS Client |
|
172 | - * @return string AppId |
|
173 | - * @since 8.0.0 |
|
174 | - */ |
|
175 | - public function getiTunesAppId() { |
|
176 | - return $this->defaults->getiTunesAppId(); |
|
177 | - } |
|
178 | - |
|
179 | - /** |
|
180 | - * Themed logo url |
|
181 | - * |
|
182 | - * @param bool $useSvg Whether to point to the SVG image or a fallback |
|
183 | - * @return string |
|
184 | - * @since 12.0.0 |
|
185 | - */ |
|
186 | - public function getLogo($useSvg = true) { |
|
187 | - return $this->defaults->getLogo($useSvg); |
|
188 | - } |
|
189 | - |
|
190 | - /** |
|
191 | - * Returns primary color |
|
192 | - * @return string |
|
193 | - * @since 12.0.0 |
|
194 | - */ |
|
195 | - public function getColorPrimary() { |
|
196 | - return $this->defaults->getColorPrimary(); |
|
197 | - } |
|
198 | - |
|
199 | - /** |
|
200 | - * @param string $key |
|
201 | - * @return string URL to doc with key |
|
202 | - * @since 12.0.0 |
|
203 | - */ |
|
204 | - public function buildDocLinkToKey($key) { |
|
205 | - return $this->defaults->buildDocLinkToKey($key); |
|
206 | - } |
|
207 | - |
|
208 | - /** |
|
209 | - * Returns the title |
|
210 | - * @return string title |
|
211 | - * @since 12.0.0 |
|
212 | - */ |
|
213 | - public function getTitle() { |
|
214 | - return $this->defaults->getTitle(); |
|
215 | - } |
|
216 | - |
|
217 | - /** |
|
218 | - * Returns primary color |
|
219 | - * @return string |
|
220 | - * @since 13.0.0 |
|
221 | - */ |
|
222 | - public function getTextColorPrimary() { |
|
223 | - return $this->defaults->getTextColorPrimary(); |
|
224 | - } |
|
43 | + /** |
|
44 | + * \OC_Defaults instance to retrieve the defaults |
|
45 | + * @since 6.0.0 |
|
46 | + */ |
|
47 | + private $defaults; |
|
48 | + |
|
49 | + /** |
|
50 | + * creates a \OC_Defaults instance which is used in all methods to retrieve the |
|
51 | + * actual defaults |
|
52 | + * @since 6.0.0 |
|
53 | + */ |
|
54 | + public function __construct(\OC_Defaults $defaults = null) { |
|
55 | + if ($defaults === null) { |
|
56 | + $defaults = \OC::$server->getThemingDefaults(); |
|
57 | + } |
|
58 | + $this->defaults = $defaults; |
|
59 | + } |
|
60 | + |
|
61 | + /** |
|
62 | + * get base URL for the organisation behind your ownCloud instance |
|
63 | + * @return string |
|
64 | + * @since 6.0.0 |
|
65 | + */ |
|
66 | + public function getBaseUrl() { |
|
67 | + return $this->defaults->getBaseUrl(); |
|
68 | + } |
|
69 | + |
|
70 | + /** |
|
71 | + * link to the desktop sync client |
|
72 | + * @return string |
|
73 | + * @since 6.0.0 |
|
74 | + */ |
|
75 | + public function getSyncClientUrl() { |
|
76 | + return $this->defaults->getSyncClientUrl(); |
|
77 | + } |
|
78 | + |
|
79 | + /** |
|
80 | + * link to the iOS client |
|
81 | + * @return string |
|
82 | + * @since 8.0.0 |
|
83 | + */ |
|
84 | + public function getiOSClientUrl() { |
|
85 | + return $this->defaults->getiOSClientUrl(); |
|
86 | + } |
|
87 | + |
|
88 | + /** |
|
89 | + * link to the Android client |
|
90 | + * @return string |
|
91 | + * @since 8.0.0 |
|
92 | + */ |
|
93 | + public function getAndroidClientUrl() { |
|
94 | + return $this->defaults->getAndroidClientUrl(); |
|
95 | + } |
|
96 | + |
|
97 | + /** |
|
98 | + * base URL to the documentation of your ownCloud instance |
|
99 | + * @return string |
|
100 | + * @since 6.0.0 |
|
101 | + */ |
|
102 | + public function getDocBaseUrl() { |
|
103 | + return $this->defaults->getDocBaseUrl(); |
|
104 | + } |
|
105 | + |
|
106 | + /** |
|
107 | + * name of your ownCloud instance |
|
108 | + * @return string |
|
109 | + * @since 6.0.0 |
|
110 | + */ |
|
111 | + public function getName() { |
|
112 | + return $this->defaults->getName(); |
|
113 | + } |
|
114 | + |
|
115 | + /** |
|
116 | + * name of your ownCloud instance containing HTML styles |
|
117 | + * @return string |
|
118 | + * @since 8.0.0 |
|
119 | + */ |
|
120 | + public function getHTMLName() { |
|
121 | + return $this->defaults->getHTMLName(); |
|
122 | + } |
|
123 | + |
|
124 | + /** |
|
125 | + * Entity behind your onwCloud instance |
|
126 | + * @return string |
|
127 | + * @since 6.0.0 |
|
128 | + */ |
|
129 | + public function getEntity() { |
|
130 | + return $this->defaults->getEntity(); |
|
131 | + } |
|
132 | + |
|
133 | + /** |
|
134 | + * ownCloud slogan |
|
135 | + * @return string |
|
136 | + * @since 6.0.0 |
|
137 | + */ |
|
138 | + public function getSlogan() { |
|
139 | + return $this->defaults->getSlogan(); |
|
140 | + } |
|
141 | + |
|
142 | + /** |
|
143 | + * logo claim |
|
144 | + * @return string |
|
145 | + * @since 6.0.0 |
|
146 | + * @deprecated 13.0.0 |
|
147 | + */ |
|
148 | + public function getLogoClaim() { |
|
149 | + return ''; |
|
150 | + } |
|
151 | + |
|
152 | + /** |
|
153 | + * footer, short version |
|
154 | + * @return string |
|
155 | + * @since 6.0.0 |
|
156 | + */ |
|
157 | + public function getShortFooter() { |
|
158 | + return $this->defaults->getShortFooter(); |
|
159 | + } |
|
160 | + |
|
161 | + /** |
|
162 | + * footer, long version |
|
163 | + * @return string |
|
164 | + * @since 6.0.0 |
|
165 | + */ |
|
166 | + public function getLongFooter() { |
|
167 | + return $this->defaults->getLongFooter(); |
|
168 | + } |
|
169 | + |
|
170 | + /** |
|
171 | + * Returns the AppId for the App Store for the iOS Client |
|
172 | + * @return string AppId |
|
173 | + * @since 8.0.0 |
|
174 | + */ |
|
175 | + public function getiTunesAppId() { |
|
176 | + return $this->defaults->getiTunesAppId(); |
|
177 | + } |
|
178 | + |
|
179 | + /** |
|
180 | + * Themed logo url |
|
181 | + * |
|
182 | + * @param bool $useSvg Whether to point to the SVG image or a fallback |
|
183 | + * @return string |
|
184 | + * @since 12.0.0 |
|
185 | + */ |
|
186 | + public function getLogo($useSvg = true) { |
|
187 | + return $this->defaults->getLogo($useSvg); |
|
188 | + } |
|
189 | + |
|
190 | + /** |
|
191 | + * Returns primary color |
|
192 | + * @return string |
|
193 | + * @since 12.0.0 |
|
194 | + */ |
|
195 | + public function getColorPrimary() { |
|
196 | + return $this->defaults->getColorPrimary(); |
|
197 | + } |
|
198 | + |
|
199 | + /** |
|
200 | + * @param string $key |
|
201 | + * @return string URL to doc with key |
|
202 | + * @since 12.0.0 |
|
203 | + */ |
|
204 | + public function buildDocLinkToKey($key) { |
|
205 | + return $this->defaults->buildDocLinkToKey($key); |
|
206 | + } |
|
207 | + |
|
208 | + /** |
|
209 | + * Returns the title |
|
210 | + * @return string title |
|
211 | + * @since 12.0.0 |
|
212 | + */ |
|
213 | + public function getTitle() { |
|
214 | + return $this->defaults->getTitle(); |
|
215 | + } |
|
216 | + |
|
217 | + /** |
|
218 | + * Returns primary color |
|
219 | + * @return string |
|
220 | + * @since 13.0.0 |
|
221 | + */ |
|
222 | + public function getTextColorPrimary() { |
|
223 | + return $this->defaults->getTextColorPrimary(); |
|
224 | + } |
|
225 | 225 | } |
@@ -29,49 +29,49 @@ |
||
29 | 29 | |
30 | 30 | class CalendarManager { |
31 | 31 | |
32 | - /** @var CalDavBackend */ |
|
33 | - private $backend; |
|
32 | + /** @var CalDavBackend */ |
|
33 | + private $backend; |
|
34 | 34 | |
35 | - /** @var IL10N */ |
|
36 | - private $l10n; |
|
35 | + /** @var IL10N */ |
|
36 | + private $l10n; |
|
37 | 37 | |
38 | - /** @var IConfig */ |
|
39 | - private $config; |
|
38 | + /** @var IConfig */ |
|
39 | + private $config; |
|
40 | 40 | |
41 | - /** |
|
42 | - * CalendarManager constructor. |
|
43 | - * |
|
44 | - * @param CalDavBackend $backend |
|
45 | - * @param IL10N $l10n |
|
46 | - * @param IConfig $config |
|
47 | - */ |
|
48 | - public function __construct(CalDavBackend $backend, IL10N $l10n, IConfig $config) { |
|
49 | - $this->backend = $backend; |
|
50 | - $this->l10n = $l10n; |
|
51 | - $this->config = $config; |
|
52 | - } |
|
41 | + /** |
|
42 | + * CalendarManager constructor. |
|
43 | + * |
|
44 | + * @param CalDavBackend $backend |
|
45 | + * @param IL10N $l10n |
|
46 | + * @param IConfig $config |
|
47 | + */ |
|
48 | + public function __construct(CalDavBackend $backend, IL10N $l10n, IConfig $config) { |
|
49 | + $this->backend = $backend; |
|
50 | + $this->l10n = $l10n; |
|
51 | + $this->config = $config; |
|
52 | + } |
|
53 | 53 | |
54 | - /** |
|
55 | - * @param IManager $cm |
|
56 | - * @param string $userId |
|
57 | - */ |
|
58 | - public function setupCalendarProvider(IManager $cm, $userId) { |
|
59 | - $calendars = $this->backend->getCalendarsForUser("principals/users/$userId"); |
|
60 | - $this->register($cm, $calendars); |
|
61 | - } |
|
54 | + /** |
|
55 | + * @param IManager $cm |
|
56 | + * @param string $userId |
|
57 | + */ |
|
58 | + public function setupCalendarProvider(IManager $cm, $userId) { |
|
59 | + $calendars = $this->backend->getCalendarsForUser("principals/users/$userId"); |
|
60 | + $this->register($cm, $calendars); |
|
61 | + } |
|
62 | 62 | |
63 | - /** |
|
64 | - * @param IManager $cm |
|
65 | - * @param array $calendars |
|
66 | - */ |
|
67 | - private function register(IManager $cm, array $calendars) { |
|
68 | - foreach($calendars as $calendarInfo) { |
|
69 | - $calendar = new Calendar($this->backend, $calendarInfo, $this->l10n, $this->config); |
|
70 | - $cm->registerCalendar(new CalendarImpl( |
|
71 | - $calendar, |
|
72 | - $calendarInfo, |
|
73 | - $this->backend |
|
74 | - )); |
|
75 | - } |
|
76 | - } |
|
63 | + /** |
|
64 | + * @param IManager $cm |
|
65 | + * @param array $calendars |
|
66 | + */ |
|
67 | + private function register(IManager $cm, array $calendars) { |
|
68 | + foreach($calendars as $calendarInfo) { |
|
69 | + $calendar = new Calendar($this->backend, $calendarInfo, $this->l10n, $this->config); |
|
70 | + $cm->registerCalendar(new CalendarImpl( |
|
71 | + $calendar, |
|
72 | + $calendarInfo, |
|
73 | + $this->backend |
|
74 | + )); |
|
75 | + } |
|
76 | + } |
|
77 | 77 | } |
@@ -27,17 +27,17 @@ |
||
27 | 27 | * @since 13.0.0 |
28 | 28 | */ |
29 | 29 | interface ICachedMountFileInfo extends ICachedMountInfo { |
30 | - /** |
|
31 | - * Return the path for the file within the cached mount |
|
32 | - * |
|
33 | - * @return string |
|
34 | - * @since 13.0.0 |
|
35 | - */ |
|
36 | - public function getInternalPath(); |
|
30 | + /** |
|
31 | + * Return the path for the file within the cached mount |
|
32 | + * |
|
33 | + * @return string |
|
34 | + * @since 13.0.0 |
|
35 | + */ |
|
36 | + public function getInternalPath(); |
|
37 | 37 | |
38 | - /** |
|
39 | - * @return string |
|
40 | - * @since 13.0.0 |
|
41 | - */ |
|
42 | - public function getPath(); |
|
38 | + /** |
|
39 | + * @return string |
|
40 | + * @since 13.0.0 |
|
41 | + */ |
|
42 | + public function getPath(); |
|
43 | 43 | } |
@@ -32,33 +32,33 @@ |
||
32 | 32 | |
33 | 33 | class UpdateTheme extends UpdateJS { |
34 | 34 | |
35 | - /** @var IMimeTypeDetector */ |
|
36 | - protected $mimetypeDetector; |
|
35 | + /** @var IMimeTypeDetector */ |
|
36 | + protected $mimetypeDetector; |
|
37 | 37 | |
38 | - /** @var ICacheFactory */ |
|
39 | - protected $cacheFactory; |
|
38 | + /** @var ICacheFactory */ |
|
39 | + protected $cacheFactory; |
|
40 | 40 | |
41 | - public function __construct( |
|
42 | - IMimeTypeDetector $mimetypeDetector, |
|
43 | - ICacheFactory $cacheFactory |
|
44 | - ) { |
|
45 | - parent::__construct($mimetypeDetector); |
|
46 | - $this->cacheFactory = $cacheFactory; |
|
47 | - } |
|
41 | + public function __construct( |
|
42 | + IMimeTypeDetector $mimetypeDetector, |
|
43 | + ICacheFactory $cacheFactory |
|
44 | + ) { |
|
45 | + parent::__construct($mimetypeDetector); |
|
46 | + $this->cacheFactory = $cacheFactory; |
|
47 | + } |
|
48 | 48 | |
49 | - protected function configure() { |
|
50 | - $this |
|
51 | - ->setName('maintenance:theme:update') |
|
52 | - ->setDescription('Apply custom theme changes'); |
|
53 | - } |
|
49 | + protected function configure() { |
|
50 | + $this |
|
51 | + ->setName('maintenance:theme:update') |
|
52 | + ->setDescription('Apply custom theme changes'); |
|
53 | + } |
|
54 | 54 | |
55 | - protected function execute(InputInterface $input, OutputInterface $output) { |
|
56 | - // run mimetypelist.js update since themes might change mimetype icons |
|
57 | - parent::execute($input, $output); |
|
55 | + protected function execute(InputInterface $input, OutputInterface $output) { |
|
56 | + // run mimetypelist.js update since themes might change mimetype icons |
|
57 | + parent::execute($input, $output); |
|
58 | 58 | |
59 | - // cleanup image cache |
|
60 | - $c = $this->cacheFactory->createDistributed('imagePath'); |
|
61 | - $c->clear(''); |
|
62 | - $output->writeln('<info>Image cache cleared'); |
|
63 | - } |
|
59 | + // cleanup image cache |
|
60 | + $c = $this->cacheFactory->createDistributed('imagePath'); |
|
61 | + $c->clear(''); |
|
62 | + $output->writeln('<info>Image cache cleared'); |
|
63 | + } |
|
64 | 64 | } |
@@ -23,8 +23,8 @@ discard block |
||
23 | 23 | require '../../../../3rdparty/autoload.php'; |
24 | 24 | |
25 | 25 | if ($argc !== 6) { |
26 | - echo "Invalid number of arguments" . PHP_EOL; |
|
27 | - exit; |
|
26 | + echo "Invalid number of arguments" . PHP_EOL; |
|
27 | + exit; |
|
28 | 28 | } |
29 | 29 | |
30 | 30 | /** |
@@ -33,15 +33,15 @@ discard block |
||
33 | 33 | * @return mixed |
34 | 34 | */ |
35 | 35 | function request($client, $method, $uploadUrl, $data = null, $headers = []) { |
36 | - echo "$method $uploadUrl ... "; |
|
37 | - $t0 = microtime(true); |
|
38 | - $result = $client->request($method, $uploadUrl, $data, $headers); |
|
39 | - $t1 = microtime(true); |
|
40 | - echo $result['statusCode'] . " - " . ($t1 - $t0) . ' seconds' . PHP_EOL; |
|
41 | - if (!in_array($result['statusCode'], [200, 201])) { |
|
42 | - echo $result['body'] . PHP_EOL; |
|
43 | - } |
|
44 | - return $result; |
|
36 | + echo "$method $uploadUrl ... "; |
|
37 | + $t0 = microtime(true); |
|
38 | + $result = $client->request($method, $uploadUrl, $data, $headers); |
|
39 | + $t1 = microtime(true); |
|
40 | + echo $result['statusCode'] . " - " . ($t1 - $t0) . ' seconds' . PHP_EOL; |
|
41 | + if (!in_array($result['statusCode'], [200, 201])) { |
|
42 | + echo $result['body'] . PHP_EOL; |
|
43 | + } |
|
44 | + return $result; |
|
45 | 45 | } |
46 | 46 | |
47 | 47 | $baseUri = $argv[1]; |
@@ -51,9 +51,9 @@ discard block |
||
51 | 51 | $chunkSize = $argv[5] * 1024 * 1024; |
52 | 52 | |
53 | 53 | $client = new \Sabre\DAV\Client([ |
54 | - 'baseUri' => $baseUri, |
|
55 | - 'userName' => $userName, |
|
56 | - 'password' => $password |
|
54 | + 'baseUri' => $baseUri, |
|
55 | + 'userName' => $userName, |
|
56 | + 'password' => $password |
|
57 | 57 | ]); |
58 | 58 | |
59 | 59 | $transfer = uniqid('transfer', true); |
@@ -66,14 +66,14 @@ discard block |
||
66 | 66 | |
67 | 67 | $index = 0; |
68 | 68 | while(!feof($stream)) { |
69 | - request($client, 'PUT', "$uploadUrl/$index", fread($stream, $chunkSize)); |
|
70 | - $index++; |
|
69 | + request($client, 'PUT', "$uploadUrl/$index", fread($stream, $chunkSize)); |
|
70 | + $index++; |
|
71 | 71 | } |
72 | 72 | |
73 | 73 | $destination = pathinfo($file, PATHINFO_BASENAME); |
74 | 74 | //echo "Moving $uploadUrl/.file to it's final destination $baseUri/files/$userName/$destination" . PHP_EOL; |
75 | 75 | request($client, 'MOVE', "$uploadUrl/.file", null, [ |
76 | - 'Destination' => "$baseUri/files/$userName/$destination", |
|
77 | - 'OC-Total-Length' => filesize($file), |
|
78 | - 'X-OC-MTime' => filemtime($file) |
|
76 | + 'Destination' => "$baseUri/files/$userName/$destination", |
|
77 | + 'OC-Total-Length' => filesize($file), |
|
78 | + 'X-OC-MTime' => filemtime($file) |
|
79 | 79 | ]); |