@@ -29,61 +29,61 @@ |
||
29 | 29 | |
30 | 30 | class ContactsStore { |
31 | 31 | |
32 | - /** @var IManager */ |
|
33 | - private $contactsManager; |
|
34 | - |
|
35 | - /** |
|
36 | - * @param IManager $contactsManager |
|
37 | - */ |
|
38 | - public function __construct(IManager $contactsManager) { |
|
39 | - $this->contactsManager = $contactsManager; |
|
40 | - } |
|
41 | - |
|
42 | - /** |
|
43 | - * @param string|null $filter |
|
44 | - * @return IEntry[] |
|
45 | - */ |
|
46 | - public function getContacts($filter) { |
|
47 | - $allContacts = $this->contactsManager->search($filter ?: '', [ |
|
48 | - 'FN', |
|
49 | - ]); |
|
50 | - |
|
51 | - return array_map(function(array $contact) { |
|
52 | - return $this->contactArrayToEntry($contact); |
|
53 | - }, $allContacts); |
|
54 | - } |
|
55 | - |
|
56 | - /** |
|
57 | - * @param array $contact |
|
58 | - * @return Entry |
|
59 | - */ |
|
60 | - private function contactArrayToEntry(array $contact) { |
|
61 | - $entry = new Entry(); |
|
62 | - |
|
63 | - if (isset($contact['id'])) { |
|
64 | - $entry->setId($contact['id']); |
|
65 | - } |
|
66 | - |
|
67 | - if (isset($contact['FN'])) { |
|
68 | - $entry->setFullName($contact['FN']); |
|
69 | - } |
|
70 | - |
|
71 | - $avatarPrefix = "VALUE=uri:"; |
|
72 | - if (isset($contact['PHOTO']) && strpos($contact['PHOTO'], $avatarPrefix) === 0) { |
|
73 | - $entry->setAvatar(substr($contact['PHOTO'], strlen($avatarPrefix))); |
|
74 | - } |
|
75 | - |
|
76 | - if (isset($contact['EMAIL'])) { |
|
77 | - foreach ($contact['EMAIL'] as $email) { |
|
78 | - $entry->addEMailAddress($email); |
|
79 | - } |
|
80 | - } |
|
81 | - |
|
82 | - // Attach all other properties to the entry too because some |
|
83 | - // providers might make use of it. |
|
84 | - $entry->setProperties($contact); |
|
85 | - |
|
86 | - return $entry; |
|
87 | - } |
|
32 | + /** @var IManager */ |
|
33 | + private $contactsManager; |
|
34 | + |
|
35 | + /** |
|
36 | + * @param IManager $contactsManager |
|
37 | + */ |
|
38 | + public function __construct(IManager $contactsManager) { |
|
39 | + $this->contactsManager = $contactsManager; |
|
40 | + } |
|
41 | + |
|
42 | + /** |
|
43 | + * @param string|null $filter |
|
44 | + * @return IEntry[] |
|
45 | + */ |
|
46 | + public function getContacts($filter) { |
|
47 | + $allContacts = $this->contactsManager->search($filter ?: '', [ |
|
48 | + 'FN', |
|
49 | + ]); |
|
50 | + |
|
51 | + return array_map(function(array $contact) { |
|
52 | + return $this->contactArrayToEntry($contact); |
|
53 | + }, $allContacts); |
|
54 | + } |
|
55 | + |
|
56 | + /** |
|
57 | + * @param array $contact |
|
58 | + * @return Entry |
|
59 | + */ |
|
60 | + private function contactArrayToEntry(array $contact) { |
|
61 | + $entry = new Entry(); |
|
62 | + |
|
63 | + if (isset($contact['id'])) { |
|
64 | + $entry->setId($contact['id']); |
|
65 | + } |
|
66 | + |
|
67 | + if (isset($contact['FN'])) { |
|
68 | + $entry->setFullName($contact['FN']); |
|
69 | + } |
|
70 | + |
|
71 | + $avatarPrefix = "VALUE=uri:"; |
|
72 | + if (isset($contact['PHOTO']) && strpos($contact['PHOTO'], $avatarPrefix) === 0) { |
|
73 | + $entry->setAvatar(substr($contact['PHOTO'], strlen($avatarPrefix))); |
|
74 | + } |
|
75 | + |
|
76 | + if (isset($contact['EMAIL'])) { |
|
77 | + foreach ($contact['EMAIL'] as $email) { |
|
78 | + $entry->addEMailAddress($email); |
|
79 | + } |
|
80 | + } |
|
81 | + |
|
82 | + // Attach all other properties to the entry too because some |
|
83 | + // providers might make use of it. |
|
84 | + $entry->setProperties($contact); |
|
85 | + |
|
86 | + return $entry; |
|
87 | + } |
|
88 | 88 | |
89 | 89 | } |
@@ -29,141 +29,141 @@ |
||
29 | 29 | |
30 | 30 | class Entry implements IEntry { |
31 | 31 | |
32 | - /** @var string|int|null */ |
|
33 | - private $id = null; |
|
34 | - |
|
35 | - /** @var string */ |
|
36 | - private $fullName = ''; |
|
37 | - |
|
38 | - /** @var string[] */ |
|
39 | - private $emailAddresses = []; |
|
40 | - |
|
41 | - /** @var string|null */ |
|
42 | - private $avatar; |
|
43 | - |
|
44 | - /** @var IAction[] */ |
|
45 | - private $actions = []; |
|
46 | - |
|
47 | - /** @var array */ |
|
48 | - private $properties = []; |
|
49 | - |
|
50 | - /** |
|
51 | - * @param string $id |
|
52 | - */ |
|
53 | - public function setId($id) { |
|
54 | - $this->id = $id; |
|
55 | - } |
|
56 | - |
|
57 | - /** |
|
58 | - * @param string $displayName |
|
59 | - */ |
|
60 | - public function setFullName($displayName) { |
|
61 | - $this->fullName = $displayName; |
|
62 | - } |
|
63 | - |
|
64 | - /** |
|
65 | - * @return string |
|
66 | - */ |
|
67 | - public function getFullName() { |
|
68 | - return $this->fullName; |
|
69 | - } |
|
70 | - |
|
71 | - /** |
|
72 | - * @param string $address |
|
73 | - */ |
|
74 | - public function addEMailAddress($address) { |
|
75 | - $this->emailAddresses[] = $address; |
|
76 | - } |
|
77 | - |
|
78 | - /** |
|
79 | - * @return string |
|
80 | - */ |
|
81 | - public function getEMailAddresses() { |
|
82 | - return $this->emailAddresses; |
|
83 | - } |
|
84 | - |
|
85 | - /** |
|
86 | - * @param string $avatar |
|
87 | - */ |
|
88 | - public function setAvatar($avatar) { |
|
89 | - $this->avatar = $avatar; |
|
90 | - } |
|
91 | - |
|
92 | - /** |
|
93 | - * @return string |
|
94 | - */ |
|
95 | - public function getAvatar() { |
|
96 | - return $this->avatar; |
|
97 | - } |
|
98 | - |
|
99 | - /** |
|
100 | - * @param IAction $action |
|
101 | - */ |
|
102 | - public function addAction(IAction $action) { |
|
103 | - $this->actions[] = $action; |
|
104 | - $this->sortActions(); |
|
105 | - } |
|
106 | - |
|
107 | - /** |
|
108 | - * @return IAction[] |
|
109 | - */ |
|
110 | - public function getActions() { |
|
111 | - return $this->actions; |
|
112 | - } |
|
113 | - |
|
114 | - /** |
|
115 | - * sort the actions by priority and name |
|
116 | - */ |
|
117 | - private function sortActions() { |
|
118 | - usort($this->actions, function(IAction $action1, IAction $action2) { |
|
119 | - $prio1 = $action1->getPriority(); |
|
120 | - $prio2 = $action2->getPriority(); |
|
121 | - |
|
122 | - if ($prio1 === $prio2) { |
|
123 | - // Ascending order for same priority |
|
124 | - return strcasecmp($action1->getName(), $action2->getName()); |
|
125 | - } |
|
126 | - |
|
127 | - // Descending order when priority differs |
|
128 | - return $prio2 - $prio1; |
|
129 | - }); |
|
130 | - } |
|
131 | - |
|
132 | - /** |
|
133 | - * @param array $contact key-value array containing additional properties |
|
134 | - */ |
|
135 | - public function setProperties(array $contact) { |
|
136 | - $this->properties = $contact; |
|
137 | - } |
|
138 | - |
|
139 | - /** |
|
140 | - * @param string $key |
|
141 | - * @return mixed |
|
142 | - */ |
|
143 | - public function getProperty($key) { |
|
144 | - if (!isset($this->properties[$key])) { |
|
145 | - return null; |
|
146 | - } |
|
147 | - return $this->properties[$key]; |
|
148 | - } |
|
149 | - |
|
150 | - /** |
|
151 | - * @return array |
|
152 | - */ |
|
153 | - public function jsonSerialize() { |
|
154 | - $topAction = !empty($this->actions) ? $this->actions[0]->jsonSerialize() : null; |
|
155 | - $otherActions = array_map(function(IAction $action) { |
|
156 | - return $action->jsonSerialize(); |
|
157 | - }, array_slice($this->actions, 1)); |
|
158 | - |
|
159 | - return [ |
|
160 | - 'id' => $this->id, |
|
161 | - 'fullName' => $this->fullName, |
|
162 | - 'avatar' => $this->getAvatar(), |
|
163 | - 'topAction' => $topAction, |
|
164 | - 'actions' => $otherActions, |
|
165 | - 'lastMessage' => '', |
|
166 | - ]; |
|
167 | - } |
|
32 | + /** @var string|int|null */ |
|
33 | + private $id = null; |
|
34 | + |
|
35 | + /** @var string */ |
|
36 | + private $fullName = ''; |
|
37 | + |
|
38 | + /** @var string[] */ |
|
39 | + private $emailAddresses = []; |
|
40 | + |
|
41 | + /** @var string|null */ |
|
42 | + private $avatar; |
|
43 | + |
|
44 | + /** @var IAction[] */ |
|
45 | + private $actions = []; |
|
46 | + |
|
47 | + /** @var array */ |
|
48 | + private $properties = []; |
|
49 | + |
|
50 | + /** |
|
51 | + * @param string $id |
|
52 | + */ |
|
53 | + public function setId($id) { |
|
54 | + $this->id = $id; |
|
55 | + } |
|
56 | + |
|
57 | + /** |
|
58 | + * @param string $displayName |
|
59 | + */ |
|
60 | + public function setFullName($displayName) { |
|
61 | + $this->fullName = $displayName; |
|
62 | + } |
|
63 | + |
|
64 | + /** |
|
65 | + * @return string |
|
66 | + */ |
|
67 | + public function getFullName() { |
|
68 | + return $this->fullName; |
|
69 | + } |
|
70 | + |
|
71 | + /** |
|
72 | + * @param string $address |
|
73 | + */ |
|
74 | + public function addEMailAddress($address) { |
|
75 | + $this->emailAddresses[] = $address; |
|
76 | + } |
|
77 | + |
|
78 | + /** |
|
79 | + * @return string |
|
80 | + */ |
|
81 | + public function getEMailAddresses() { |
|
82 | + return $this->emailAddresses; |
|
83 | + } |
|
84 | + |
|
85 | + /** |
|
86 | + * @param string $avatar |
|
87 | + */ |
|
88 | + public function setAvatar($avatar) { |
|
89 | + $this->avatar = $avatar; |
|
90 | + } |
|
91 | + |
|
92 | + /** |
|
93 | + * @return string |
|
94 | + */ |
|
95 | + public function getAvatar() { |
|
96 | + return $this->avatar; |
|
97 | + } |
|
98 | + |
|
99 | + /** |
|
100 | + * @param IAction $action |
|
101 | + */ |
|
102 | + public function addAction(IAction $action) { |
|
103 | + $this->actions[] = $action; |
|
104 | + $this->sortActions(); |
|
105 | + } |
|
106 | + |
|
107 | + /** |
|
108 | + * @return IAction[] |
|
109 | + */ |
|
110 | + public function getActions() { |
|
111 | + return $this->actions; |
|
112 | + } |
|
113 | + |
|
114 | + /** |
|
115 | + * sort the actions by priority and name |
|
116 | + */ |
|
117 | + private function sortActions() { |
|
118 | + usort($this->actions, function(IAction $action1, IAction $action2) { |
|
119 | + $prio1 = $action1->getPriority(); |
|
120 | + $prio2 = $action2->getPriority(); |
|
121 | + |
|
122 | + if ($prio1 === $prio2) { |
|
123 | + // Ascending order for same priority |
|
124 | + return strcasecmp($action1->getName(), $action2->getName()); |
|
125 | + } |
|
126 | + |
|
127 | + // Descending order when priority differs |
|
128 | + return $prio2 - $prio1; |
|
129 | + }); |
|
130 | + } |
|
131 | + |
|
132 | + /** |
|
133 | + * @param array $contact key-value array containing additional properties |
|
134 | + */ |
|
135 | + public function setProperties(array $contact) { |
|
136 | + $this->properties = $contact; |
|
137 | + } |
|
138 | + |
|
139 | + /** |
|
140 | + * @param string $key |
|
141 | + * @return mixed |
|
142 | + */ |
|
143 | + public function getProperty($key) { |
|
144 | + if (!isset($this->properties[$key])) { |
|
145 | + return null; |
|
146 | + } |
|
147 | + return $this->properties[$key]; |
|
148 | + } |
|
149 | + |
|
150 | + /** |
|
151 | + * @return array |
|
152 | + */ |
|
153 | + public function jsonSerialize() { |
|
154 | + $topAction = !empty($this->actions) ? $this->actions[0]->jsonSerialize() : null; |
|
155 | + $otherActions = array_map(function(IAction $action) { |
|
156 | + return $action->jsonSerialize(); |
|
157 | + }, array_slice($this->actions, 1)); |
|
158 | + |
|
159 | + return [ |
|
160 | + 'id' => $this->id, |
|
161 | + 'fullName' => $this->fullName, |
|
162 | + 'avatar' => $this->getAvatar(), |
|
163 | + 'topAction' => $topAction, |
|
164 | + 'actions' => $otherActions, |
|
165 | + 'lastMessage' => '', |
|
166 | + ]; |
|
167 | + } |
|
168 | 168 | |
169 | 169 | } |
@@ -31,36 +31,36 @@ |
||
31 | 31 | */ |
32 | 32 | interface IEntry extends JsonSerializable { |
33 | 33 | |
34 | - /** |
|
35 | - * @since 12.0 |
|
36 | - * @return string |
|
37 | - */ |
|
38 | - public function getFullName(); |
|
34 | + /** |
|
35 | + * @since 12.0 |
|
36 | + * @return string |
|
37 | + */ |
|
38 | + public function getFullName(); |
|
39 | 39 | |
40 | - /** |
|
41 | - * @since 12.0 |
|
42 | - * @return string[] |
|
43 | - */ |
|
44 | - public function getEMailAddresses(); |
|
40 | + /** |
|
41 | + * @since 12.0 |
|
42 | + * @return string[] |
|
43 | + */ |
|
44 | + public function getEMailAddresses(); |
|
45 | 45 | |
46 | - /** |
|
47 | - * @since 12.0 |
|
48 | - * @return string|null image URI |
|
49 | - */ |
|
50 | - public function getAvatar(); |
|
46 | + /** |
|
47 | + * @since 12.0 |
|
48 | + * @return string|null image URI |
|
49 | + */ |
|
50 | + public function getAvatar(); |
|
51 | 51 | |
52 | - /** |
|
53 | - * @since 12.0 |
|
54 | - * @param IAction $action an action to show in the contacts menu |
|
55 | - */ |
|
56 | - public function addAction(IAction $action); |
|
52 | + /** |
|
53 | + * @since 12.0 |
|
54 | + * @param IAction $action an action to show in the contacts menu |
|
55 | + */ |
|
56 | + public function addAction(IAction $action); |
|
57 | 57 | |
58 | - /** |
|
59 | - * Get an arbitrary property from the contact |
|
60 | - * |
|
61 | - * @since 12.0 |
|
62 | - * @param string $key |
|
63 | - * @return mixed the value of the property or null |
|
64 | - */ |
|
65 | - public function getProperty($key); |
|
58 | + /** |
|
59 | + * Get an arbitrary property from the contact |
|
60 | + * |
|
61 | + * @since 12.0 |
|
62 | + * @param string $key |
|
63 | + * @return mixed the value of the property or null |
|
64 | + */ |
|
65 | + public function getProperty($key); |
|
66 | 66 | } |
@@ -35,36 +35,36 @@ discard block |
||
35 | 35 | |
36 | 36 | $application = new Application(); |
37 | 37 | $application->registerRoutes($this, [ |
38 | - 'routes' => [ |
|
39 | - ['name' => 'lost#email', 'url' => '/lostpassword/email', 'verb' => 'POST'], |
|
40 | - ['name' => 'lost#resetform', 'url' => '/lostpassword/reset/form/{token}/{userId}', 'verb' => 'GET'], |
|
41 | - ['name' => 'lost#setPassword', 'url' => '/lostpassword/set/{token}/{userId}', 'verb' => 'POST'], |
|
42 | - ['name' => 'user#getDisplayNames', 'url' => '/displaynames', 'verb' => 'POST'], |
|
43 | - ['name' => 'avatar#getAvatar', 'url' => '/avatar/{userId}/{size}', 'verb' => 'GET'], |
|
44 | - ['name' => 'avatar#deleteAvatar', 'url' => '/avatar/', 'verb' => 'DELETE'], |
|
45 | - ['name' => 'avatar#postCroppedAvatar', 'url' => '/avatar/cropped', 'verb' => 'POST'], |
|
46 | - ['name' => 'avatar#getTmpAvatar', 'url' => '/avatar/tmp', 'verb' => 'GET'], |
|
47 | - ['name' => 'avatar#postAvatar', 'url' => '/avatar/', 'verb' => 'POST'], |
|
48 | - ['name' => 'login#tryLogin', 'url' => '/login', 'verb' => 'POST'], |
|
49 | - ['name' => 'login#confirmPassword', 'url' => '/login/confirm', 'verb' => 'POST'], |
|
50 | - ['name' => 'login#showLoginForm', 'url' => '/login', 'verb' => 'GET'], |
|
51 | - ['name' => 'login#logout', 'url' => '/logout', 'verb' => 'GET'], |
|
52 | - ['name' => 'TwoFactorChallenge#selectChallenge', 'url' => '/login/selectchallenge', 'verb' => 'GET'], |
|
53 | - ['name' => 'TwoFactorChallenge#showChallenge', 'url' => '/login/challenge/{challengeProviderId}', 'verb' => 'GET'], |
|
54 | - ['name' => 'TwoFactorChallenge#solveChallenge', 'url' => '/login/challenge/{challengeProviderId}', 'verb' => 'POST'], |
|
55 | - ['name' => 'OCJS#getConfig', 'url' => '/core/js/oc.js', 'verb' => 'GET'], |
|
56 | - ['name' => 'Preview#getPreview', 'url' => '/core/preview', 'verb' => 'GET'], |
|
57 | - ['name' => 'Preview#getPreview', 'url' => '/core/preview.png', 'verb' => 'GET'], |
|
58 | - ['name' => 'Css#getCss', 'url' => '/css/{appName}/{fileName}', 'verb' => 'GET'], |
|
59 | - ['name' => 'Js#getJs', 'url' => '/js/{appName}/{fileName}', 'verb' => 'GET'], |
|
60 | - ['name' => 'contactsMenu#index', 'url' => '/contactsmenu/contacts', 'verb' => 'GET'], |
|
61 | - ], |
|
62 | - 'ocs' => [ |
|
63 | - ['root' => '/cloud', 'name' => 'OCS#getCapabilities', 'url' => '/capabilities', 'verb' => 'GET'], |
|
64 | - ['root' => '', 'name' => 'OCS#getConfig', 'url' => '/config', 'verb' => 'GET'], |
|
65 | - ['root' => '/person', 'name' => 'OCS#personCheck', 'url' => '/check', 'verb' => 'POST'], |
|
66 | - ['root' => '/identityproof', 'name' => 'OCS#getIdentityProof', 'url' => '/key/{cloudId}', 'verb' => 'GET'], |
|
67 | - ], |
|
38 | + 'routes' => [ |
|
39 | + ['name' => 'lost#email', 'url' => '/lostpassword/email', 'verb' => 'POST'], |
|
40 | + ['name' => 'lost#resetform', 'url' => '/lostpassword/reset/form/{token}/{userId}', 'verb' => 'GET'], |
|
41 | + ['name' => 'lost#setPassword', 'url' => '/lostpassword/set/{token}/{userId}', 'verb' => 'POST'], |
|
42 | + ['name' => 'user#getDisplayNames', 'url' => '/displaynames', 'verb' => 'POST'], |
|
43 | + ['name' => 'avatar#getAvatar', 'url' => '/avatar/{userId}/{size}', 'verb' => 'GET'], |
|
44 | + ['name' => 'avatar#deleteAvatar', 'url' => '/avatar/', 'verb' => 'DELETE'], |
|
45 | + ['name' => 'avatar#postCroppedAvatar', 'url' => '/avatar/cropped', 'verb' => 'POST'], |
|
46 | + ['name' => 'avatar#getTmpAvatar', 'url' => '/avatar/tmp', 'verb' => 'GET'], |
|
47 | + ['name' => 'avatar#postAvatar', 'url' => '/avatar/', 'verb' => 'POST'], |
|
48 | + ['name' => 'login#tryLogin', 'url' => '/login', 'verb' => 'POST'], |
|
49 | + ['name' => 'login#confirmPassword', 'url' => '/login/confirm', 'verb' => 'POST'], |
|
50 | + ['name' => 'login#showLoginForm', 'url' => '/login', 'verb' => 'GET'], |
|
51 | + ['name' => 'login#logout', 'url' => '/logout', 'verb' => 'GET'], |
|
52 | + ['name' => 'TwoFactorChallenge#selectChallenge', 'url' => '/login/selectchallenge', 'verb' => 'GET'], |
|
53 | + ['name' => 'TwoFactorChallenge#showChallenge', 'url' => '/login/challenge/{challengeProviderId}', 'verb' => 'GET'], |
|
54 | + ['name' => 'TwoFactorChallenge#solveChallenge', 'url' => '/login/challenge/{challengeProviderId}', 'verb' => 'POST'], |
|
55 | + ['name' => 'OCJS#getConfig', 'url' => '/core/js/oc.js', 'verb' => 'GET'], |
|
56 | + ['name' => 'Preview#getPreview', 'url' => '/core/preview', 'verb' => 'GET'], |
|
57 | + ['name' => 'Preview#getPreview', 'url' => '/core/preview.png', 'verb' => 'GET'], |
|
58 | + ['name' => 'Css#getCss', 'url' => '/css/{appName}/{fileName}', 'verb' => 'GET'], |
|
59 | + ['name' => 'Js#getJs', 'url' => '/js/{appName}/{fileName}', 'verb' => 'GET'], |
|
60 | + ['name' => 'contactsMenu#index', 'url' => '/contactsmenu/contacts', 'verb' => 'GET'], |
|
61 | + ], |
|
62 | + 'ocs' => [ |
|
63 | + ['root' => '/cloud', 'name' => 'OCS#getCapabilities', 'url' => '/capabilities', 'verb' => 'GET'], |
|
64 | + ['root' => '', 'name' => 'OCS#getConfig', 'url' => '/config', 'verb' => 'GET'], |
|
65 | + ['root' => '/person', 'name' => 'OCS#personCheck', 'url' => '/check', 'verb' => 'POST'], |
|
66 | + ['root' => '/identityproof', 'name' => 'OCS#getIdentityProof', 'url' => '/key/{cloudId}', 'verb' => 'GET'], |
|
67 | + ], |
|
68 | 68 | ]); |
69 | 69 | |
70 | 70 | // Post installation check |
@@ -73,62 +73,62 @@ discard block |
||
73 | 73 | // Core ajax actions |
74 | 74 | // Search |
75 | 75 | $this->create('search_ajax_search', '/core/search') |
76 | - ->actionInclude('core/search/ajax/search.php'); |
|
76 | + ->actionInclude('core/search/ajax/search.php'); |
|
77 | 77 | // Routing |
78 | 78 | $this->create('core_ajax_update', '/core/ajax/update.php') |
79 | - ->actionInclude('core/ajax/update.php'); |
|
79 | + ->actionInclude('core/ajax/update.php'); |
|
80 | 80 | |
81 | 81 | // File routes |
82 | 82 | $this->create('files.viewcontroller.showFile', '/f/{fileid}')->action(function($urlParams) { |
83 | - $app = new \OCA\Files\AppInfo\Application($urlParams); |
|
84 | - $app->dispatch('ViewController', 'index'); |
|
83 | + $app = new \OCA\Files\AppInfo\Application($urlParams); |
|
84 | + $app->dispatch('ViewController', 'index'); |
|
85 | 85 | }); |
86 | 86 | |
87 | 87 | // Call routes |
88 | 88 | $this->create('spreed.pagecontroller.showCall', '/call/{token}')->action(function($urlParams) { |
89 | - if (class_exists(\OCA\Spreed\AppInfo\Application::class, false)) { |
|
90 | - $app = new \OCA\Spreed\AppInfo\Application($urlParams); |
|
91 | - $app->dispatch('PageController', 'index'); |
|
92 | - } else { |
|
93 | - throw new \OC\HintException('App spreed is not enabled'); |
|
94 | - } |
|
89 | + if (class_exists(\OCA\Spreed\AppInfo\Application::class, false)) { |
|
90 | + $app = new \OCA\Spreed\AppInfo\Application($urlParams); |
|
91 | + $app->dispatch('PageController', 'index'); |
|
92 | + } else { |
|
93 | + throw new \OC\HintException('App spreed is not enabled'); |
|
94 | + } |
|
95 | 95 | }); |
96 | 96 | |
97 | 97 | // Sharing routes |
98 | 98 | $this->create('files_sharing.sharecontroller.showShare', '/s/{token}')->action(function($urlParams) { |
99 | - if (class_exists(\OCA\Files_Sharing\AppInfo\Application::class, false)) { |
|
100 | - $app = new \OCA\Files_Sharing\AppInfo\Application($urlParams); |
|
101 | - $app->dispatch('ShareController', 'showShare'); |
|
102 | - } else { |
|
103 | - throw new \OC\HintException('App file sharing is not enabled'); |
|
104 | - } |
|
99 | + if (class_exists(\OCA\Files_Sharing\AppInfo\Application::class, false)) { |
|
100 | + $app = new \OCA\Files_Sharing\AppInfo\Application($urlParams); |
|
101 | + $app->dispatch('ShareController', 'showShare'); |
|
102 | + } else { |
|
103 | + throw new \OC\HintException('App file sharing is not enabled'); |
|
104 | + } |
|
105 | 105 | }); |
106 | 106 | $this->create('files_sharing.sharecontroller.authenticate', '/s/{token}/authenticate')->post()->action(function($urlParams) { |
107 | - if (class_exists(\OCA\Files_Sharing\AppInfo\Application::class, false)) { |
|
108 | - $app = new \OCA\Files_Sharing\AppInfo\Application($urlParams); |
|
109 | - $app->dispatch('ShareController', 'authenticate'); |
|
110 | - } else { |
|
111 | - throw new \OC\HintException('App file sharing is not enabled'); |
|
112 | - } |
|
107 | + if (class_exists(\OCA\Files_Sharing\AppInfo\Application::class, false)) { |
|
108 | + $app = new \OCA\Files_Sharing\AppInfo\Application($urlParams); |
|
109 | + $app->dispatch('ShareController', 'authenticate'); |
|
110 | + } else { |
|
111 | + throw new \OC\HintException('App file sharing is not enabled'); |
|
112 | + } |
|
113 | 113 | }); |
114 | 114 | $this->create('files_sharing.sharecontroller.showAuthenticate', '/s/{token}/authenticate')->get()->action(function($urlParams) { |
115 | - if (class_exists(\OCA\Files_Sharing\AppInfo\Application::class, false)) { |
|
116 | - $app = new \OCA\Files_Sharing\AppInfo\Application($urlParams); |
|
117 | - $app->dispatch('ShareController', 'showAuthenticate'); |
|
118 | - } else { |
|
119 | - throw new \OC\HintException('App file sharing is not enabled'); |
|
120 | - } |
|
115 | + if (class_exists(\OCA\Files_Sharing\AppInfo\Application::class, false)) { |
|
116 | + $app = new \OCA\Files_Sharing\AppInfo\Application($urlParams); |
|
117 | + $app->dispatch('ShareController', 'showAuthenticate'); |
|
118 | + } else { |
|
119 | + throw new \OC\HintException('App file sharing is not enabled'); |
|
120 | + } |
|
121 | 121 | }); |
122 | 122 | $this->create('files_sharing.sharecontroller.downloadShare', '/s/{token}/download')->get()->action(function($urlParams) { |
123 | - if (class_exists(\OCA\Files_Sharing\AppInfo\Application::class, false)) { |
|
124 | - $app = new \OCA\Files_Sharing\AppInfo\Application($urlParams); |
|
125 | - $app->dispatch('ShareController', 'downloadShare'); |
|
126 | - } else { |
|
127 | - throw new \OC\HintException('App file sharing is not enabled'); |
|
128 | - } |
|
123 | + if (class_exists(\OCA\Files_Sharing\AppInfo\Application::class, false)) { |
|
124 | + $app = new \OCA\Files_Sharing\AppInfo\Application($urlParams); |
|
125 | + $app->dispatch('ShareController', 'downloadShare'); |
|
126 | + } else { |
|
127 | + throw new \OC\HintException('App file sharing is not enabled'); |
|
128 | + } |
|
129 | 129 | }); |
130 | 130 | |
131 | 131 | // used for heartbeat |
132 | 132 | $this->create('heartbeat', '/heartbeat')->action(function(){ |
133 | - // do nothing |
|
133 | + // do nothing |
|
134 | 134 | }); |
@@ -44,330 +44,330 @@ |
||
44 | 44 | */ |
45 | 45 | class OC_Template extends \OC\Template\Base { |
46 | 46 | |
47 | - /** @var string */ |
|
48 | - private $renderAs; // Create a full page? |
|
49 | - |
|
50 | - /** @var string */ |
|
51 | - private $path; // The path to the template |
|
52 | - |
|
53 | - /** @var array */ |
|
54 | - private $headers = array(); //custom headers |
|
55 | - |
|
56 | - /** @var string */ |
|
57 | - protected $app; // app id |
|
58 | - |
|
59 | - protected static $initTemplateEngineFirstRun = true; |
|
60 | - |
|
61 | - /** |
|
62 | - * Constructor |
|
63 | - * |
|
64 | - * @param string $app app providing the template |
|
65 | - * @param string $name of the template file (without suffix) |
|
66 | - * @param string $renderAs If $renderAs is set, OC_Template will try to |
|
67 | - * produce a full page in the according layout. For |
|
68 | - * now, $renderAs can be set to "guest", "user" or |
|
69 | - * "admin". |
|
70 | - * @param bool $registerCall = true |
|
71 | - */ |
|
72 | - public function __construct( $app, $name, $renderAs = "", $registerCall = true ) { |
|
73 | - // Read the selected theme from the config file |
|
74 | - self::initTemplateEngine($renderAs); |
|
75 | - |
|
76 | - $theme = OC_Util::getTheme(); |
|
77 | - |
|
78 | - $requestToken = (OC::$server->getSession() && $registerCall) ? \OCP\Util::callRegister() : ''; |
|
79 | - |
|
80 | - $parts = explode('/', $app); // fix translation when app is something like core/lostpassword |
|
81 | - $l10n = \OC::$server->getL10N($parts[0]); |
|
82 | - $themeDefaults = \OC::$server->getThemingDefaults(); |
|
83 | - |
|
84 | - list($path, $template) = $this->findTemplate($theme, $app, $name); |
|
85 | - |
|
86 | - // Set the private data |
|
87 | - $this->renderAs = $renderAs; |
|
88 | - $this->path = $path; |
|
89 | - $this->app = $app; |
|
90 | - |
|
91 | - parent::__construct($template, $requestToken, $l10n, $themeDefaults); |
|
92 | - } |
|
93 | - |
|
94 | - /** |
|
95 | - * @param string $renderAs |
|
96 | - */ |
|
97 | - public static function initTemplateEngine($renderAs) { |
|
98 | - if (self::$initTemplateEngineFirstRun){ |
|
99 | - |
|
100 | - //apps that started before the template initialization can load their own scripts/styles |
|
101 | - //so to make sure this scripts/styles here are loaded first we use OC_Util::addScript() with $prepend=true |
|
102 | - //meaning the last script/style in this list will be loaded first |
|
103 | - if (\OC::$server->getSystemConfig()->getValue ('installed', false) && $renderAs !== 'error' && !\OCP\Util::needUpgrade()) { |
|
104 | - if (\OC::$server->getConfig ()->getAppValue ( 'core', 'backgroundjobs_mode', 'ajax' ) == 'ajax') { |
|
105 | - OC_Util::addScript ( 'backgroundjobs', null, true ); |
|
106 | - } |
|
107 | - } |
|
108 | - |
|
109 | - OC_Util::addStyle('jquery-ui-fixes',null,true); |
|
110 | - OC_Util::addVendorStyle('jquery-ui/themes/base/jquery-ui',null,true); |
|
111 | - OC_Util::addStyle('server', null, true); |
|
112 | - OC_Util::addVendorStyle('select2/select2', null, true); |
|
113 | - OC_Util::addStyle('jquery.ocdialog'); |
|
114 | - OC_Util::addTranslations("core", null, true); |
|
115 | - OC_Util::addScript('search', 'search', true); |
|
116 | - OC_Util::addScript('merged-template-prepend', null, true); |
|
117 | - OC_Util::addScript('jquery-ui-fixes'); |
|
118 | - OC_Util::addScript('files/fileinfo'); |
|
119 | - OC_Util::addScript('files/client'); |
|
120 | - OC_Util::addScript('contactsmenu'); |
|
121 | - |
|
122 | - if (\OC::$server->getConfig()->getSystemValue('debug')) { |
|
123 | - // Add the stuff we need always |
|
124 | - // following logic will import all vendor libraries that are |
|
125 | - // specified in core/js/core.json |
|
126 | - $fileContent = file_get_contents(OC::$SERVERROOT . '/core/js/core.json'); |
|
127 | - if($fileContent !== false) { |
|
128 | - $coreDependencies = json_decode($fileContent, true); |
|
129 | - foreach(array_reverse($coreDependencies['vendor']) as $vendorLibrary) { |
|
130 | - //remove trailing ".js" as addVendorScript will append it |
|
131 | - OC_Util::addVendorScript( |
|
132 | - substr($vendorLibrary, 0, strlen($vendorLibrary) - 3),null,true); |
|
133 | - } |
|
134 | - } else { |
|
135 | - throw new \Exception('Cannot read core/js/core.json'); |
|
136 | - } |
|
137 | - } else { |
|
138 | - // Import all (combined) default vendor libraries |
|
139 | - OC_Util::addVendorScript('core', null, true); |
|
140 | - } |
|
141 | - |
|
142 | - if (\OC::$server->getRequest()->isUserAgent([\OC\AppFramework\Http\Request::USER_AGENT_IE])) { |
|
143 | - // polyfill for btoa/atob for IE friends |
|
144 | - OC_Util::addVendorScript('base64/base64'); |
|
145 | - // shim for the davclient.js library |
|
146 | - \OCP\Util::addScript('files/iedavclient'); |
|
147 | - } |
|
148 | - |
|
149 | - self::$initTemplateEngineFirstRun = false; |
|
150 | - } |
|
151 | - |
|
152 | - } |
|
153 | - |
|
154 | - |
|
155 | - /** |
|
156 | - * find the template with the given name |
|
157 | - * @param string $name of the template file (without suffix) |
|
158 | - * |
|
159 | - * Will select the template file for the selected theme. |
|
160 | - * Checking all the possible locations. |
|
161 | - * @param string $theme |
|
162 | - * @param string $app |
|
163 | - * @return string[] |
|
164 | - */ |
|
165 | - protected function findTemplate($theme, $app, $name) { |
|
166 | - // Check if it is a app template or not. |
|
167 | - if( $app !== '' ) { |
|
168 | - $dirs = $this->getAppTemplateDirs($theme, $app, OC::$SERVERROOT, OC_App::getAppPath($app)); |
|
169 | - } else { |
|
170 | - $dirs = $this->getCoreTemplateDirs($theme, OC::$SERVERROOT); |
|
171 | - } |
|
172 | - $locator = new \OC\Template\TemplateFileLocator( $dirs ); |
|
173 | - $template = $locator->find($name); |
|
174 | - $path = $locator->getPath(); |
|
175 | - return array($path, $template); |
|
176 | - } |
|
177 | - |
|
178 | - /** |
|
179 | - * Add a custom element to the header |
|
180 | - * @param string $tag tag name of the element |
|
181 | - * @param array $attributes array of attributes for the element |
|
182 | - * @param string $text the text content for the element. If $text is null then the |
|
183 | - * element will be written as empty element. So use "" to get a closing tag. |
|
184 | - */ |
|
185 | - public function addHeader($tag, $attributes, $text=null) { |
|
186 | - $this->headers[]= array( |
|
187 | - 'tag' => $tag, |
|
188 | - 'attributes' => $attributes, |
|
189 | - 'text' => $text |
|
190 | - ); |
|
191 | - } |
|
192 | - |
|
193 | - /** |
|
194 | - * Process the template |
|
195 | - * @return boolean|string |
|
196 | - * |
|
197 | - * This function process the template. If $this->renderAs is set, it |
|
198 | - * will produce a full page. |
|
199 | - */ |
|
200 | - public function fetchPage($additionalParams = null) { |
|
201 | - $data = parent::fetchPage($additionalParams); |
|
202 | - |
|
203 | - if( $this->renderAs ) { |
|
204 | - $page = new TemplateLayout($this->renderAs, $this->app); |
|
205 | - |
|
206 | - // Add custom headers |
|
207 | - $headers = ''; |
|
208 | - foreach(OC_Util::$headers as $header) { |
|
209 | - $headers .= '<'.\OCP\Util::sanitizeHTML($header['tag']); |
|
210 | - foreach($header['attributes'] as $name=>$value) { |
|
211 | - $headers .= ' '.\OCP\Util::sanitizeHTML($name).'="'.\OCP\Util::sanitizeHTML($value).'"'; |
|
212 | - } |
|
213 | - if ($header['text'] !== null) { |
|
214 | - $headers .= '>'.\OCP\Util::sanitizeHTML($header['text']).'</'.\OCP\Util::sanitizeHTML($header['tag']).'>'; |
|
215 | - } else { |
|
216 | - $headers .= '/>'; |
|
217 | - } |
|
218 | - } |
|
219 | - |
|
220 | - $page->assign('headers', $headers); |
|
221 | - |
|
222 | - $page->assign('content', $data); |
|
223 | - return $page->fetchPage(); |
|
224 | - } |
|
225 | - |
|
226 | - return $data; |
|
227 | - } |
|
228 | - |
|
229 | - /** |
|
230 | - * Include template |
|
231 | - * |
|
232 | - * @param string $file |
|
233 | - * @param array|null $additionalParams |
|
234 | - * @return string returns content of included template |
|
235 | - * |
|
236 | - * Includes another template. use <?php echo $this->inc('template'); ?> to |
|
237 | - * do this. |
|
238 | - */ |
|
239 | - public function inc( $file, $additionalParams = null ) { |
|
240 | - return $this->load($this->path.$file.'.php', $additionalParams); |
|
241 | - } |
|
242 | - |
|
243 | - /** |
|
244 | - * Shortcut to print a simple page for users |
|
245 | - * @param string $application The application we render the template for |
|
246 | - * @param string $name Name of the template |
|
247 | - * @param array $parameters Parameters for the template |
|
248 | - * @return boolean|null |
|
249 | - */ |
|
250 | - public static function printUserPage( $application, $name, $parameters = array() ) { |
|
251 | - $content = new OC_Template( $application, $name, "user" ); |
|
252 | - foreach( $parameters as $key => $value ) { |
|
253 | - $content->assign( $key, $value ); |
|
254 | - } |
|
255 | - print $content->printPage(); |
|
256 | - } |
|
257 | - |
|
258 | - /** |
|
259 | - * Shortcut to print a simple page for admins |
|
260 | - * @param string $application The application we render the template for |
|
261 | - * @param string $name Name of the template |
|
262 | - * @param array $parameters Parameters for the template |
|
263 | - * @return bool |
|
264 | - */ |
|
265 | - public static function printAdminPage( $application, $name, $parameters = array() ) { |
|
266 | - $content = new OC_Template( $application, $name, "admin" ); |
|
267 | - foreach( $parameters as $key => $value ) { |
|
268 | - $content->assign( $key, $value ); |
|
269 | - } |
|
270 | - return $content->printPage(); |
|
271 | - } |
|
272 | - |
|
273 | - /** |
|
274 | - * Shortcut to print a simple page for guests |
|
275 | - * @param string $application The application we render the template for |
|
276 | - * @param string $name Name of the template |
|
277 | - * @param array|string $parameters Parameters for the template |
|
278 | - * @return bool |
|
279 | - */ |
|
280 | - public static function printGuestPage( $application, $name, $parameters = array() ) { |
|
281 | - $content = new OC_Template( $application, $name, "guest" ); |
|
282 | - foreach( $parameters as $key => $value ) { |
|
283 | - $content->assign( $key, $value ); |
|
284 | - } |
|
285 | - return $content->printPage(); |
|
286 | - } |
|
287 | - |
|
288 | - /** |
|
289 | - * Print a fatal error page and terminates the script |
|
290 | - * @param string $error_msg The error message to show |
|
291 | - * @param string $hint An optional hint message - needs to be properly escaped |
|
292 | - */ |
|
293 | - public static function printErrorPage( $error_msg, $hint = '' ) { |
|
294 | - if ($error_msg === $hint) { |
|
295 | - // If the hint is the same as the message there is no need to display it twice. |
|
296 | - $hint = ''; |
|
297 | - } |
|
298 | - |
|
299 | - try { |
|
300 | - $content = new \OC_Template( '', 'error', 'error', false ); |
|
301 | - $errors = array(array('error' => $error_msg, 'hint' => $hint)); |
|
302 | - $content->assign( 'errors', $errors ); |
|
303 | - $content->printPage(); |
|
304 | - } catch (\Exception $e) { |
|
305 | - $logger = \OC::$server->getLogger(); |
|
306 | - $logger->error("$error_msg $hint", ['app' => 'core']); |
|
307 | - $logger->logException($e, ['app' => 'core']); |
|
308 | - |
|
309 | - header(self::getHttpProtocol() . ' 500 Internal Server Error'); |
|
310 | - header('Content-Type: text/plain; charset=utf-8'); |
|
311 | - print("$error_msg $hint"); |
|
312 | - } |
|
313 | - die(); |
|
314 | - } |
|
315 | - |
|
316 | - /** |
|
317 | - * print error page using Exception details |
|
318 | - * @param Exception | Throwable $exception |
|
319 | - */ |
|
320 | - public static function printExceptionErrorPage($exception, $fetchPage = false) { |
|
321 | - try { |
|
322 | - $request = \OC::$server->getRequest(); |
|
323 | - $content = new \OC_Template('', 'exception', 'error', false); |
|
324 | - $content->assign('errorClass', get_class($exception)); |
|
325 | - $content->assign('errorMsg', $exception->getMessage()); |
|
326 | - $content->assign('errorCode', $exception->getCode()); |
|
327 | - $content->assign('file', $exception->getFile()); |
|
328 | - $content->assign('line', $exception->getLine()); |
|
329 | - $content->assign('trace', $exception->getTraceAsString()); |
|
330 | - $content->assign('debugMode', \OC::$server->getSystemConfig()->getValue('debug', false)); |
|
331 | - $content->assign('remoteAddr', $request->getRemoteAddress()); |
|
332 | - $content->assign('requestID', $request->getId()); |
|
333 | - if ($fetchPage) { |
|
334 | - return $content->fetchPage(); |
|
335 | - } |
|
336 | - $content->printPage(); |
|
337 | - } catch (\Exception $e) { |
|
338 | - $logger = \OC::$server->getLogger(); |
|
339 | - $logger->logException($exception, ['app' => 'core']); |
|
340 | - $logger->logException($e, ['app' => 'core']); |
|
341 | - |
|
342 | - header(self::getHttpProtocol() . ' 500 Internal Server Error'); |
|
343 | - header('Content-Type: text/plain; charset=utf-8'); |
|
344 | - print("Internal Server Error\n\n"); |
|
345 | - print("The server encountered an internal error and was unable to complete your request.\n"); |
|
346 | - print("Please contact the server administrator if this error reappears multiple times, please include the technical details below in your report.\n"); |
|
347 | - print("More details can be found in the server log.\n"); |
|
348 | - } |
|
349 | - die(); |
|
350 | - } |
|
351 | - |
|
352 | - /** |
|
353 | - * This is only here to reduce the dependencies in case of an exception to |
|
354 | - * still be able to print a plain error message. |
|
355 | - * |
|
356 | - * Returns the used HTTP protocol. |
|
357 | - * |
|
358 | - * @return string HTTP protocol. HTTP/2, HTTP/1.1 or HTTP/1.0. |
|
359 | - * @internal Don't use this - use AppFramework\Http\Request->getHttpProtocol instead |
|
360 | - */ |
|
361 | - protected static function getHttpProtocol() { |
|
362 | - $claimedProtocol = strtoupper($_SERVER['SERVER_PROTOCOL']); |
|
363 | - $validProtocols = [ |
|
364 | - 'HTTP/1.0', |
|
365 | - 'HTTP/1.1', |
|
366 | - 'HTTP/2', |
|
367 | - ]; |
|
368 | - if(in_array($claimedProtocol, $validProtocols, true)) { |
|
369 | - return $claimedProtocol; |
|
370 | - } |
|
371 | - return 'HTTP/1.1'; |
|
372 | - } |
|
47 | + /** @var string */ |
|
48 | + private $renderAs; // Create a full page? |
|
49 | + |
|
50 | + /** @var string */ |
|
51 | + private $path; // The path to the template |
|
52 | + |
|
53 | + /** @var array */ |
|
54 | + private $headers = array(); //custom headers |
|
55 | + |
|
56 | + /** @var string */ |
|
57 | + protected $app; // app id |
|
58 | + |
|
59 | + protected static $initTemplateEngineFirstRun = true; |
|
60 | + |
|
61 | + /** |
|
62 | + * Constructor |
|
63 | + * |
|
64 | + * @param string $app app providing the template |
|
65 | + * @param string $name of the template file (without suffix) |
|
66 | + * @param string $renderAs If $renderAs is set, OC_Template will try to |
|
67 | + * produce a full page in the according layout. For |
|
68 | + * now, $renderAs can be set to "guest", "user" or |
|
69 | + * "admin". |
|
70 | + * @param bool $registerCall = true |
|
71 | + */ |
|
72 | + public function __construct( $app, $name, $renderAs = "", $registerCall = true ) { |
|
73 | + // Read the selected theme from the config file |
|
74 | + self::initTemplateEngine($renderAs); |
|
75 | + |
|
76 | + $theme = OC_Util::getTheme(); |
|
77 | + |
|
78 | + $requestToken = (OC::$server->getSession() && $registerCall) ? \OCP\Util::callRegister() : ''; |
|
79 | + |
|
80 | + $parts = explode('/', $app); // fix translation when app is something like core/lostpassword |
|
81 | + $l10n = \OC::$server->getL10N($parts[0]); |
|
82 | + $themeDefaults = \OC::$server->getThemingDefaults(); |
|
83 | + |
|
84 | + list($path, $template) = $this->findTemplate($theme, $app, $name); |
|
85 | + |
|
86 | + // Set the private data |
|
87 | + $this->renderAs = $renderAs; |
|
88 | + $this->path = $path; |
|
89 | + $this->app = $app; |
|
90 | + |
|
91 | + parent::__construct($template, $requestToken, $l10n, $themeDefaults); |
|
92 | + } |
|
93 | + |
|
94 | + /** |
|
95 | + * @param string $renderAs |
|
96 | + */ |
|
97 | + public static function initTemplateEngine($renderAs) { |
|
98 | + if (self::$initTemplateEngineFirstRun){ |
|
99 | + |
|
100 | + //apps that started before the template initialization can load their own scripts/styles |
|
101 | + //so to make sure this scripts/styles here are loaded first we use OC_Util::addScript() with $prepend=true |
|
102 | + //meaning the last script/style in this list will be loaded first |
|
103 | + if (\OC::$server->getSystemConfig()->getValue ('installed', false) && $renderAs !== 'error' && !\OCP\Util::needUpgrade()) { |
|
104 | + if (\OC::$server->getConfig ()->getAppValue ( 'core', 'backgroundjobs_mode', 'ajax' ) == 'ajax') { |
|
105 | + OC_Util::addScript ( 'backgroundjobs', null, true ); |
|
106 | + } |
|
107 | + } |
|
108 | + |
|
109 | + OC_Util::addStyle('jquery-ui-fixes',null,true); |
|
110 | + OC_Util::addVendorStyle('jquery-ui/themes/base/jquery-ui',null,true); |
|
111 | + OC_Util::addStyle('server', null, true); |
|
112 | + OC_Util::addVendorStyle('select2/select2', null, true); |
|
113 | + OC_Util::addStyle('jquery.ocdialog'); |
|
114 | + OC_Util::addTranslations("core", null, true); |
|
115 | + OC_Util::addScript('search', 'search', true); |
|
116 | + OC_Util::addScript('merged-template-prepend', null, true); |
|
117 | + OC_Util::addScript('jquery-ui-fixes'); |
|
118 | + OC_Util::addScript('files/fileinfo'); |
|
119 | + OC_Util::addScript('files/client'); |
|
120 | + OC_Util::addScript('contactsmenu'); |
|
121 | + |
|
122 | + if (\OC::$server->getConfig()->getSystemValue('debug')) { |
|
123 | + // Add the stuff we need always |
|
124 | + // following logic will import all vendor libraries that are |
|
125 | + // specified in core/js/core.json |
|
126 | + $fileContent = file_get_contents(OC::$SERVERROOT . '/core/js/core.json'); |
|
127 | + if($fileContent !== false) { |
|
128 | + $coreDependencies = json_decode($fileContent, true); |
|
129 | + foreach(array_reverse($coreDependencies['vendor']) as $vendorLibrary) { |
|
130 | + //remove trailing ".js" as addVendorScript will append it |
|
131 | + OC_Util::addVendorScript( |
|
132 | + substr($vendorLibrary, 0, strlen($vendorLibrary) - 3),null,true); |
|
133 | + } |
|
134 | + } else { |
|
135 | + throw new \Exception('Cannot read core/js/core.json'); |
|
136 | + } |
|
137 | + } else { |
|
138 | + // Import all (combined) default vendor libraries |
|
139 | + OC_Util::addVendorScript('core', null, true); |
|
140 | + } |
|
141 | + |
|
142 | + if (\OC::$server->getRequest()->isUserAgent([\OC\AppFramework\Http\Request::USER_AGENT_IE])) { |
|
143 | + // polyfill for btoa/atob for IE friends |
|
144 | + OC_Util::addVendorScript('base64/base64'); |
|
145 | + // shim for the davclient.js library |
|
146 | + \OCP\Util::addScript('files/iedavclient'); |
|
147 | + } |
|
148 | + |
|
149 | + self::$initTemplateEngineFirstRun = false; |
|
150 | + } |
|
151 | + |
|
152 | + } |
|
153 | + |
|
154 | + |
|
155 | + /** |
|
156 | + * find the template with the given name |
|
157 | + * @param string $name of the template file (without suffix) |
|
158 | + * |
|
159 | + * Will select the template file for the selected theme. |
|
160 | + * Checking all the possible locations. |
|
161 | + * @param string $theme |
|
162 | + * @param string $app |
|
163 | + * @return string[] |
|
164 | + */ |
|
165 | + protected function findTemplate($theme, $app, $name) { |
|
166 | + // Check if it is a app template or not. |
|
167 | + if( $app !== '' ) { |
|
168 | + $dirs = $this->getAppTemplateDirs($theme, $app, OC::$SERVERROOT, OC_App::getAppPath($app)); |
|
169 | + } else { |
|
170 | + $dirs = $this->getCoreTemplateDirs($theme, OC::$SERVERROOT); |
|
171 | + } |
|
172 | + $locator = new \OC\Template\TemplateFileLocator( $dirs ); |
|
173 | + $template = $locator->find($name); |
|
174 | + $path = $locator->getPath(); |
|
175 | + return array($path, $template); |
|
176 | + } |
|
177 | + |
|
178 | + /** |
|
179 | + * Add a custom element to the header |
|
180 | + * @param string $tag tag name of the element |
|
181 | + * @param array $attributes array of attributes for the element |
|
182 | + * @param string $text the text content for the element. If $text is null then the |
|
183 | + * element will be written as empty element. So use "" to get a closing tag. |
|
184 | + */ |
|
185 | + public function addHeader($tag, $attributes, $text=null) { |
|
186 | + $this->headers[]= array( |
|
187 | + 'tag' => $tag, |
|
188 | + 'attributes' => $attributes, |
|
189 | + 'text' => $text |
|
190 | + ); |
|
191 | + } |
|
192 | + |
|
193 | + /** |
|
194 | + * Process the template |
|
195 | + * @return boolean|string |
|
196 | + * |
|
197 | + * This function process the template. If $this->renderAs is set, it |
|
198 | + * will produce a full page. |
|
199 | + */ |
|
200 | + public function fetchPage($additionalParams = null) { |
|
201 | + $data = parent::fetchPage($additionalParams); |
|
202 | + |
|
203 | + if( $this->renderAs ) { |
|
204 | + $page = new TemplateLayout($this->renderAs, $this->app); |
|
205 | + |
|
206 | + // Add custom headers |
|
207 | + $headers = ''; |
|
208 | + foreach(OC_Util::$headers as $header) { |
|
209 | + $headers .= '<'.\OCP\Util::sanitizeHTML($header['tag']); |
|
210 | + foreach($header['attributes'] as $name=>$value) { |
|
211 | + $headers .= ' '.\OCP\Util::sanitizeHTML($name).'="'.\OCP\Util::sanitizeHTML($value).'"'; |
|
212 | + } |
|
213 | + if ($header['text'] !== null) { |
|
214 | + $headers .= '>'.\OCP\Util::sanitizeHTML($header['text']).'</'.\OCP\Util::sanitizeHTML($header['tag']).'>'; |
|
215 | + } else { |
|
216 | + $headers .= '/>'; |
|
217 | + } |
|
218 | + } |
|
219 | + |
|
220 | + $page->assign('headers', $headers); |
|
221 | + |
|
222 | + $page->assign('content', $data); |
|
223 | + return $page->fetchPage(); |
|
224 | + } |
|
225 | + |
|
226 | + return $data; |
|
227 | + } |
|
228 | + |
|
229 | + /** |
|
230 | + * Include template |
|
231 | + * |
|
232 | + * @param string $file |
|
233 | + * @param array|null $additionalParams |
|
234 | + * @return string returns content of included template |
|
235 | + * |
|
236 | + * Includes another template. use <?php echo $this->inc('template'); ?> to |
|
237 | + * do this. |
|
238 | + */ |
|
239 | + public function inc( $file, $additionalParams = null ) { |
|
240 | + return $this->load($this->path.$file.'.php', $additionalParams); |
|
241 | + } |
|
242 | + |
|
243 | + /** |
|
244 | + * Shortcut to print a simple page for users |
|
245 | + * @param string $application The application we render the template for |
|
246 | + * @param string $name Name of the template |
|
247 | + * @param array $parameters Parameters for the template |
|
248 | + * @return boolean|null |
|
249 | + */ |
|
250 | + public static function printUserPage( $application, $name, $parameters = array() ) { |
|
251 | + $content = new OC_Template( $application, $name, "user" ); |
|
252 | + foreach( $parameters as $key => $value ) { |
|
253 | + $content->assign( $key, $value ); |
|
254 | + } |
|
255 | + print $content->printPage(); |
|
256 | + } |
|
257 | + |
|
258 | + /** |
|
259 | + * Shortcut to print a simple page for admins |
|
260 | + * @param string $application The application we render the template for |
|
261 | + * @param string $name Name of the template |
|
262 | + * @param array $parameters Parameters for the template |
|
263 | + * @return bool |
|
264 | + */ |
|
265 | + public static function printAdminPage( $application, $name, $parameters = array() ) { |
|
266 | + $content = new OC_Template( $application, $name, "admin" ); |
|
267 | + foreach( $parameters as $key => $value ) { |
|
268 | + $content->assign( $key, $value ); |
|
269 | + } |
|
270 | + return $content->printPage(); |
|
271 | + } |
|
272 | + |
|
273 | + /** |
|
274 | + * Shortcut to print a simple page for guests |
|
275 | + * @param string $application The application we render the template for |
|
276 | + * @param string $name Name of the template |
|
277 | + * @param array|string $parameters Parameters for the template |
|
278 | + * @return bool |
|
279 | + */ |
|
280 | + public static function printGuestPage( $application, $name, $parameters = array() ) { |
|
281 | + $content = new OC_Template( $application, $name, "guest" ); |
|
282 | + foreach( $parameters as $key => $value ) { |
|
283 | + $content->assign( $key, $value ); |
|
284 | + } |
|
285 | + return $content->printPage(); |
|
286 | + } |
|
287 | + |
|
288 | + /** |
|
289 | + * Print a fatal error page and terminates the script |
|
290 | + * @param string $error_msg The error message to show |
|
291 | + * @param string $hint An optional hint message - needs to be properly escaped |
|
292 | + */ |
|
293 | + public static function printErrorPage( $error_msg, $hint = '' ) { |
|
294 | + if ($error_msg === $hint) { |
|
295 | + // If the hint is the same as the message there is no need to display it twice. |
|
296 | + $hint = ''; |
|
297 | + } |
|
298 | + |
|
299 | + try { |
|
300 | + $content = new \OC_Template( '', 'error', 'error', false ); |
|
301 | + $errors = array(array('error' => $error_msg, 'hint' => $hint)); |
|
302 | + $content->assign( 'errors', $errors ); |
|
303 | + $content->printPage(); |
|
304 | + } catch (\Exception $e) { |
|
305 | + $logger = \OC::$server->getLogger(); |
|
306 | + $logger->error("$error_msg $hint", ['app' => 'core']); |
|
307 | + $logger->logException($e, ['app' => 'core']); |
|
308 | + |
|
309 | + header(self::getHttpProtocol() . ' 500 Internal Server Error'); |
|
310 | + header('Content-Type: text/plain; charset=utf-8'); |
|
311 | + print("$error_msg $hint"); |
|
312 | + } |
|
313 | + die(); |
|
314 | + } |
|
315 | + |
|
316 | + /** |
|
317 | + * print error page using Exception details |
|
318 | + * @param Exception | Throwable $exception |
|
319 | + */ |
|
320 | + public static function printExceptionErrorPage($exception, $fetchPage = false) { |
|
321 | + try { |
|
322 | + $request = \OC::$server->getRequest(); |
|
323 | + $content = new \OC_Template('', 'exception', 'error', false); |
|
324 | + $content->assign('errorClass', get_class($exception)); |
|
325 | + $content->assign('errorMsg', $exception->getMessage()); |
|
326 | + $content->assign('errorCode', $exception->getCode()); |
|
327 | + $content->assign('file', $exception->getFile()); |
|
328 | + $content->assign('line', $exception->getLine()); |
|
329 | + $content->assign('trace', $exception->getTraceAsString()); |
|
330 | + $content->assign('debugMode', \OC::$server->getSystemConfig()->getValue('debug', false)); |
|
331 | + $content->assign('remoteAddr', $request->getRemoteAddress()); |
|
332 | + $content->assign('requestID', $request->getId()); |
|
333 | + if ($fetchPage) { |
|
334 | + return $content->fetchPage(); |
|
335 | + } |
|
336 | + $content->printPage(); |
|
337 | + } catch (\Exception $e) { |
|
338 | + $logger = \OC::$server->getLogger(); |
|
339 | + $logger->logException($exception, ['app' => 'core']); |
|
340 | + $logger->logException($e, ['app' => 'core']); |
|
341 | + |
|
342 | + header(self::getHttpProtocol() . ' 500 Internal Server Error'); |
|
343 | + header('Content-Type: text/plain; charset=utf-8'); |
|
344 | + print("Internal Server Error\n\n"); |
|
345 | + print("The server encountered an internal error and was unable to complete your request.\n"); |
|
346 | + print("Please contact the server administrator if this error reappears multiple times, please include the technical details below in your report.\n"); |
|
347 | + print("More details can be found in the server log.\n"); |
|
348 | + } |
|
349 | + die(); |
|
350 | + } |
|
351 | + |
|
352 | + /** |
|
353 | + * This is only here to reduce the dependencies in case of an exception to |
|
354 | + * still be able to print a plain error message. |
|
355 | + * |
|
356 | + * Returns the used HTTP protocol. |
|
357 | + * |
|
358 | + * @return string HTTP protocol. HTTP/2, HTTP/1.1 or HTTP/1.0. |
|
359 | + * @internal Don't use this - use AppFramework\Http\Request->getHttpProtocol instead |
|
360 | + */ |
|
361 | + protected static function getHttpProtocol() { |
|
362 | + $claimedProtocol = strtoupper($_SERVER['SERVER_PROTOCOL']); |
|
363 | + $validProtocols = [ |
|
364 | + 'HTTP/1.0', |
|
365 | + 'HTTP/1.1', |
|
366 | + 'HTTP/2', |
|
367 | + ]; |
|
368 | + if(in_array($claimedProtocol, $validProtocols, true)) { |
|
369 | + return $claimedProtocol; |
|
370 | + } |
|
371 | + return 'HTTP/1.1'; |
|
372 | + } |
|
373 | 373 | } |
@@ -118,1590 +118,1590 @@ |
||
118 | 118 | * TODO: hookup all manager classes |
119 | 119 | */ |
120 | 120 | class Server extends ServerContainer implements IServerContainer { |
121 | - /** @var string */ |
|
122 | - private $webRoot; |
|
123 | - |
|
124 | - /** |
|
125 | - * @param string $webRoot |
|
126 | - * @param \OC\Config $config |
|
127 | - */ |
|
128 | - public function __construct($webRoot, \OC\Config $config) { |
|
129 | - parent::__construct(); |
|
130 | - $this->webRoot = $webRoot; |
|
131 | - |
|
132 | - $this->registerAlias(\OCP\Contacts\IManager::class, \OC\ContactsManager::class); |
|
133 | - $this->registerAlias('ContactsManager', \OCP\Contacts\IManager::class); |
|
134 | - |
|
135 | - $this->registerAlias(IActionFactory::class, ActionFactory::class); |
|
136 | - |
|
137 | - $this->registerService(\OCP\IPreview::class, function (Server $c) { |
|
138 | - return new PreviewManager( |
|
139 | - $c->getConfig(), |
|
140 | - $c->getRootFolder(), |
|
141 | - $c->getAppDataDir('preview'), |
|
142 | - $c->getEventDispatcher(), |
|
143 | - $c->getSession()->get('user_id') |
|
144 | - ); |
|
145 | - }); |
|
146 | - $this->registerAlias('PreviewManager', \OCP\IPreview::class); |
|
147 | - |
|
148 | - $this->registerService(\OC\Preview\Watcher::class, function (Server $c) { |
|
149 | - return new \OC\Preview\Watcher( |
|
150 | - $c->getAppDataDir('preview') |
|
151 | - ); |
|
152 | - }); |
|
153 | - |
|
154 | - $this->registerService('EncryptionManager', function (Server $c) { |
|
155 | - $view = new View(); |
|
156 | - $util = new Encryption\Util( |
|
157 | - $view, |
|
158 | - $c->getUserManager(), |
|
159 | - $c->getGroupManager(), |
|
160 | - $c->getConfig() |
|
161 | - ); |
|
162 | - return new Encryption\Manager( |
|
163 | - $c->getConfig(), |
|
164 | - $c->getLogger(), |
|
165 | - $c->getL10N('core'), |
|
166 | - new View(), |
|
167 | - $util, |
|
168 | - new ArrayCache() |
|
169 | - ); |
|
170 | - }); |
|
171 | - |
|
172 | - $this->registerService('EncryptionFileHelper', function (Server $c) { |
|
173 | - $util = new Encryption\Util( |
|
174 | - new View(), |
|
175 | - $c->getUserManager(), |
|
176 | - $c->getGroupManager(), |
|
177 | - $c->getConfig() |
|
178 | - ); |
|
179 | - return new Encryption\File($util); |
|
180 | - }); |
|
181 | - |
|
182 | - $this->registerService('EncryptionKeyStorage', function (Server $c) { |
|
183 | - $view = new View(); |
|
184 | - $util = new Encryption\Util( |
|
185 | - $view, |
|
186 | - $c->getUserManager(), |
|
187 | - $c->getGroupManager(), |
|
188 | - $c->getConfig() |
|
189 | - ); |
|
190 | - |
|
191 | - return new Encryption\Keys\Storage($view, $util); |
|
192 | - }); |
|
193 | - $this->registerService('TagMapper', function (Server $c) { |
|
194 | - return new TagMapper($c->getDatabaseConnection()); |
|
195 | - }); |
|
196 | - |
|
197 | - $this->registerService(\OCP\ITagManager::class, function (Server $c) { |
|
198 | - $tagMapper = $c->query('TagMapper'); |
|
199 | - return new TagManager($tagMapper, $c->getUserSession()); |
|
200 | - }); |
|
201 | - $this->registerAlias('TagManager', \OCP\ITagManager::class); |
|
202 | - |
|
203 | - $this->registerService('SystemTagManagerFactory', function (Server $c) { |
|
204 | - $config = $c->getConfig(); |
|
205 | - $factoryClass = $config->getSystemValue('systemtags.managerFactory', '\OC\SystemTag\ManagerFactory'); |
|
206 | - /** @var \OC\SystemTag\ManagerFactory $factory */ |
|
207 | - $factory = new $factoryClass($this); |
|
208 | - return $factory; |
|
209 | - }); |
|
210 | - $this->registerService(\OCP\SystemTag\ISystemTagManager::class, function (Server $c) { |
|
211 | - return $c->query('SystemTagManagerFactory')->getManager(); |
|
212 | - }); |
|
213 | - $this->registerAlias('SystemTagManager', \OCP\SystemTag\ISystemTagManager::class); |
|
214 | - |
|
215 | - $this->registerService(\OCP\SystemTag\ISystemTagObjectMapper::class, function (Server $c) { |
|
216 | - return $c->query('SystemTagManagerFactory')->getObjectMapper(); |
|
217 | - }); |
|
218 | - $this->registerService('RootFolder', function (Server $c) { |
|
219 | - $manager = \OC\Files\Filesystem::getMountManager(null); |
|
220 | - $view = new View(); |
|
221 | - $root = new Root( |
|
222 | - $manager, |
|
223 | - $view, |
|
224 | - null, |
|
225 | - $c->getUserMountCache(), |
|
226 | - $this->getLogger(), |
|
227 | - $this->getUserManager() |
|
228 | - ); |
|
229 | - $connector = new HookConnector($root, $view); |
|
230 | - $connector->viewToNode(); |
|
231 | - |
|
232 | - $previewConnector = new \OC\Preview\WatcherConnector($root, $c->getSystemConfig()); |
|
233 | - $previewConnector->connectWatcher(); |
|
234 | - |
|
235 | - return $root; |
|
236 | - }); |
|
237 | - $this->registerAlias('SystemTagObjectMapper', \OCP\SystemTag\ISystemTagObjectMapper::class); |
|
238 | - |
|
239 | - $this->registerService(\OCP\Files\IRootFolder::class, function(Server $c) { |
|
240 | - return new LazyRoot(function() use ($c) { |
|
241 | - return $c->query('RootFolder'); |
|
242 | - }); |
|
243 | - }); |
|
244 | - $this->registerAlias('LazyRootFolder', \OCP\Files\IRootFolder::class); |
|
245 | - |
|
246 | - $this->registerService(\OCP\IUserManager::class, function (Server $c) { |
|
247 | - $config = $c->getConfig(); |
|
248 | - return new \OC\User\Manager($config); |
|
249 | - }); |
|
250 | - $this->registerAlias('UserManager', \OCP\IUserManager::class); |
|
251 | - |
|
252 | - $this->registerService(\OCP\IGroupManager::class, function (Server $c) { |
|
253 | - $groupManager = new \OC\Group\Manager($this->getUserManager(), $this->getLogger()); |
|
254 | - $groupManager->listen('\OC\Group', 'preCreate', function ($gid) { |
|
255 | - \OC_Hook::emit('OC_Group', 'pre_createGroup', array('run' => true, 'gid' => $gid)); |
|
256 | - }); |
|
257 | - $groupManager->listen('\OC\Group', 'postCreate', function (\OC\Group\Group $gid) { |
|
258 | - \OC_Hook::emit('OC_User', 'post_createGroup', array('gid' => $gid->getGID())); |
|
259 | - }); |
|
260 | - $groupManager->listen('\OC\Group', 'preDelete', function (\OC\Group\Group $group) { |
|
261 | - \OC_Hook::emit('OC_Group', 'pre_deleteGroup', array('run' => true, 'gid' => $group->getGID())); |
|
262 | - }); |
|
263 | - $groupManager->listen('\OC\Group', 'postDelete', function (\OC\Group\Group $group) { |
|
264 | - \OC_Hook::emit('OC_User', 'post_deleteGroup', array('gid' => $group->getGID())); |
|
265 | - }); |
|
266 | - $groupManager->listen('\OC\Group', 'preAddUser', function (\OC\Group\Group $group, \OC\User\User $user) { |
|
267 | - \OC_Hook::emit('OC_Group', 'pre_addToGroup', array('run' => true, 'uid' => $user->getUID(), 'gid' => $group->getGID())); |
|
268 | - }); |
|
269 | - $groupManager->listen('\OC\Group', 'postAddUser', function (\OC\Group\Group $group, \OC\User\User $user) { |
|
270 | - \OC_Hook::emit('OC_Group', 'post_addToGroup', array('uid' => $user->getUID(), 'gid' => $group->getGID())); |
|
271 | - //Minimal fix to keep it backward compatible TODO: clean up all the GroupManager hooks |
|
272 | - \OC_Hook::emit('OC_User', 'post_addToGroup', array('uid' => $user->getUID(), 'gid' => $group->getGID())); |
|
273 | - }); |
|
274 | - return $groupManager; |
|
275 | - }); |
|
276 | - $this->registerAlias('GroupManager', \OCP\IGroupManager::class); |
|
277 | - |
|
278 | - $this->registerService(Store::class, function(Server $c) { |
|
279 | - $session = $c->getSession(); |
|
280 | - if (\OC::$server->getSystemConfig()->getValue('installed', false)) { |
|
281 | - $tokenProvider = $c->query('OC\Authentication\Token\IProvider'); |
|
282 | - } else { |
|
283 | - $tokenProvider = null; |
|
284 | - } |
|
285 | - $logger = $c->getLogger(); |
|
286 | - return new Store($session, $logger, $tokenProvider); |
|
287 | - }); |
|
288 | - $this->registerAlias(IStore::class, Store::class); |
|
289 | - $this->registerService('OC\Authentication\Token\DefaultTokenMapper', function (Server $c) { |
|
290 | - $dbConnection = $c->getDatabaseConnection(); |
|
291 | - return new Authentication\Token\DefaultTokenMapper($dbConnection); |
|
292 | - }); |
|
293 | - $this->registerService('OC\Authentication\Token\DefaultTokenProvider', function (Server $c) { |
|
294 | - $mapper = $c->query('OC\Authentication\Token\DefaultTokenMapper'); |
|
295 | - $crypto = $c->getCrypto(); |
|
296 | - $config = $c->getConfig(); |
|
297 | - $logger = $c->getLogger(); |
|
298 | - $timeFactory = new TimeFactory(); |
|
299 | - return new \OC\Authentication\Token\DefaultTokenProvider($mapper, $crypto, $config, $logger, $timeFactory); |
|
300 | - }); |
|
301 | - $this->registerAlias('OC\Authentication\Token\IProvider', 'OC\Authentication\Token\DefaultTokenProvider'); |
|
302 | - |
|
303 | - $this->registerService(\OCP\IUserSession::class, function (Server $c) { |
|
304 | - $manager = $c->getUserManager(); |
|
305 | - $session = new \OC\Session\Memory(''); |
|
306 | - $timeFactory = new TimeFactory(); |
|
307 | - // Token providers might require a working database. This code |
|
308 | - // might however be called when ownCloud is not yet setup. |
|
309 | - if (\OC::$server->getSystemConfig()->getValue('installed', false)) { |
|
310 | - $defaultTokenProvider = $c->query('OC\Authentication\Token\IProvider'); |
|
311 | - } else { |
|
312 | - $defaultTokenProvider = null; |
|
313 | - } |
|
314 | - |
|
315 | - $userSession = new \OC\User\Session($manager, $session, $timeFactory, $defaultTokenProvider, $c->getConfig(), $c->getSecureRandom()); |
|
316 | - $userSession->listen('\OC\User', 'preCreateUser', function ($uid, $password) { |
|
317 | - \OC_Hook::emit('OC_User', 'pre_createUser', array('run' => true, 'uid' => $uid, 'password' => $password)); |
|
318 | - }); |
|
319 | - $userSession->listen('\OC\User', 'postCreateUser', function ($user, $password) { |
|
320 | - /** @var $user \OC\User\User */ |
|
321 | - \OC_Hook::emit('OC_User', 'post_createUser', array('uid' => $user->getUID(), 'password' => $password)); |
|
322 | - }); |
|
323 | - $userSession->listen('\OC\User', 'preDelete', function ($user) { |
|
324 | - /** @var $user \OC\User\User */ |
|
325 | - \OC_Hook::emit('OC_User', 'pre_deleteUser', array('run' => true, 'uid' => $user->getUID())); |
|
326 | - }); |
|
327 | - $userSession->listen('\OC\User', 'postDelete', function ($user) { |
|
328 | - /** @var $user \OC\User\User */ |
|
329 | - \OC_Hook::emit('OC_User', 'post_deleteUser', array('uid' => $user->getUID())); |
|
330 | - }); |
|
331 | - $userSession->listen('\OC\User', 'preSetPassword', function ($user, $password, $recoveryPassword) { |
|
332 | - /** @var $user \OC\User\User */ |
|
333 | - \OC_Hook::emit('OC_User', 'pre_setPassword', array('run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword)); |
|
334 | - }); |
|
335 | - $userSession->listen('\OC\User', 'postSetPassword', function ($user, $password, $recoveryPassword) { |
|
336 | - /** @var $user \OC\User\User */ |
|
337 | - \OC_Hook::emit('OC_User', 'post_setPassword', array('run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword)); |
|
338 | - }); |
|
339 | - $userSession->listen('\OC\User', 'preLogin', function ($uid, $password) { |
|
340 | - \OC_Hook::emit('OC_User', 'pre_login', array('run' => true, 'uid' => $uid, 'password' => $password)); |
|
341 | - }); |
|
342 | - $userSession->listen('\OC\User', 'postLogin', function ($user, $password) { |
|
343 | - /** @var $user \OC\User\User */ |
|
344 | - \OC_Hook::emit('OC_User', 'post_login', array('run' => true, 'uid' => $user->getUID(), 'password' => $password)); |
|
345 | - }); |
|
346 | - $userSession->listen('\OC\User', 'logout', function () { |
|
347 | - \OC_Hook::emit('OC_User', 'logout', array()); |
|
348 | - }); |
|
349 | - $userSession->listen('\OC\User', 'changeUser', function ($user, $feature, $value) { |
|
350 | - /** @var $user \OC\User\User */ |
|
351 | - \OC_Hook::emit('OC_User', 'changeUser', array('run' => true, 'user' => $user, 'feature' => $feature, 'value' => $value)); |
|
352 | - }); |
|
353 | - return $userSession; |
|
354 | - }); |
|
355 | - $this->registerAlias('UserSession', \OCP\IUserSession::class); |
|
356 | - |
|
357 | - $this->registerService(\OC\Authentication\TwoFactorAuth\Manager::class, function (Server $c) { |
|
358 | - return new \OC\Authentication\TwoFactorAuth\Manager($c->getAppManager(), $c->getSession(), $c->getConfig(), $c->getActivityManager(), $c->getLogger()); |
|
359 | - }); |
|
360 | - |
|
361 | - $this->registerAlias(\OCP\INavigationManager::class, \OC\NavigationManager::class); |
|
362 | - $this->registerAlias('NavigationManager', \OCP\INavigationManager::class); |
|
363 | - |
|
364 | - $this->registerService(\OC\AllConfig::class, function (Server $c) { |
|
365 | - return new \OC\AllConfig( |
|
366 | - $c->getSystemConfig() |
|
367 | - ); |
|
368 | - }); |
|
369 | - $this->registerAlias('AllConfig', \OC\AllConfig::class); |
|
370 | - $this->registerAlias(\OCP\IConfig::class, \OC\AllConfig::class); |
|
371 | - |
|
372 | - $this->registerService('SystemConfig', function ($c) use ($config) { |
|
373 | - return new \OC\SystemConfig($config); |
|
374 | - }); |
|
375 | - |
|
376 | - $this->registerService(\OC\AppConfig::class, function (Server $c) { |
|
377 | - return new \OC\AppConfig($c->getDatabaseConnection()); |
|
378 | - }); |
|
379 | - $this->registerAlias('AppConfig', \OC\AppConfig::class); |
|
380 | - $this->registerAlias(\OCP\IAppConfig::class, \OC\AppConfig::class); |
|
381 | - |
|
382 | - $this->registerService(\OCP\L10N\IFactory::class, function (Server $c) { |
|
383 | - return new \OC\L10N\Factory( |
|
384 | - $c->getConfig(), |
|
385 | - $c->getRequest(), |
|
386 | - $c->getUserSession(), |
|
387 | - \OC::$SERVERROOT |
|
388 | - ); |
|
389 | - }); |
|
390 | - $this->registerAlias('L10NFactory', \OCP\L10N\IFactory::class); |
|
391 | - |
|
392 | - $this->registerService(\OCP\IURLGenerator::class, function (Server $c) { |
|
393 | - $config = $c->getConfig(); |
|
394 | - $cacheFactory = $c->getMemCacheFactory(); |
|
395 | - return new \OC\URLGenerator( |
|
396 | - $config, |
|
397 | - $cacheFactory |
|
398 | - ); |
|
399 | - }); |
|
400 | - $this->registerAlias('URLGenerator', \OCP\IURLGenerator::class); |
|
401 | - |
|
402 | - $this->registerService('AppHelper', function ($c) { |
|
403 | - return new \OC\AppHelper(); |
|
404 | - }); |
|
405 | - $this->registerService('AppFetcher', function ($c) { |
|
406 | - return new AppFetcher( |
|
407 | - $this->getAppDataDir('appstore'), |
|
408 | - $this->getHTTPClientService(), |
|
409 | - $this->query(TimeFactory::class), |
|
410 | - $this->getConfig() |
|
411 | - ); |
|
412 | - }); |
|
413 | - $this->registerService('CategoryFetcher', function ($c) { |
|
414 | - return new CategoryFetcher( |
|
415 | - $this->getAppDataDir('appstore'), |
|
416 | - $this->getHTTPClientService(), |
|
417 | - $this->query(TimeFactory::class), |
|
418 | - $this->getConfig() |
|
419 | - ); |
|
420 | - }); |
|
421 | - |
|
422 | - $this->registerService(\OCP\ICache::class, function ($c) { |
|
423 | - return new Cache\File(); |
|
424 | - }); |
|
425 | - $this->registerAlias('UserCache', \OCP\ICache::class); |
|
426 | - |
|
427 | - $this->registerService(Factory::class, function (Server $c) { |
|
428 | - $config = $c->getConfig(); |
|
429 | - |
|
430 | - if ($config->getSystemValue('installed', false) && !(defined('PHPUNIT_RUN') && PHPUNIT_RUN)) { |
|
431 | - $v = \OC_App::getAppVersions(); |
|
432 | - $v['core'] = md5(file_get_contents(\OC::$SERVERROOT . '/version.php')); |
|
433 | - $version = implode(',', $v); |
|
434 | - $instanceId = \OC_Util::getInstanceId(); |
|
435 | - $path = \OC::$SERVERROOT; |
|
436 | - $prefix = md5($instanceId . '-' . $version . '-' . $path . '-' . \OC::$WEBROOT); |
|
437 | - return new \OC\Memcache\Factory($prefix, $c->getLogger(), |
|
438 | - $config->getSystemValue('memcache.local', null), |
|
439 | - $config->getSystemValue('memcache.distributed', null), |
|
440 | - $config->getSystemValue('memcache.locking', null) |
|
441 | - ); |
|
442 | - } |
|
443 | - |
|
444 | - return new \OC\Memcache\Factory('', $c->getLogger(), |
|
445 | - '\\OC\\Memcache\\ArrayCache', |
|
446 | - '\\OC\\Memcache\\ArrayCache', |
|
447 | - '\\OC\\Memcache\\ArrayCache' |
|
448 | - ); |
|
449 | - }); |
|
450 | - $this->registerAlias('MemCacheFactory', Factory::class); |
|
451 | - $this->registerAlias(ICacheFactory::class, Factory::class); |
|
452 | - |
|
453 | - $this->registerService('RedisFactory', function (Server $c) { |
|
454 | - $systemConfig = $c->getSystemConfig(); |
|
455 | - return new RedisFactory($systemConfig); |
|
456 | - }); |
|
457 | - |
|
458 | - $this->registerService(\OCP\Activity\IManager::class, function (Server $c) { |
|
459 | - return new \OC\Activity\Manager( |
|
460 | - $c->getRequest(), |
|
461 | - $c->getUserSession(), |
|
462 | - $c->getConfig(), |
|
463 | - $c->query(IValidator::class) |
|
464 | - ); |
|
465 | - }); |
|
466 | - $this->registerAlias('ActivityManager', \OCP\Activity\IManager::class); |
|
467 | - |
|
468 | - $this->registerService(\OCP\Activity\IEventMerger::class, function (Server $c) { |
|
469 | - return new \OC\Activity\EventMerger( |
|
470 | - $c->getL10N('lib') |
|
471 | - ); |
|
472 | - }); |
|
473 | - $this->registerAlias(IValidator::class, Validator::class); |
|
474 | - |
|
475 | - $this->registerService(\OCP\IAvatarManager::class, function (Server $c) { |
|
476 | - return new AvatarManager( |
|
477 | - $c->getUserManager(), |
|
478 | - $c->getAppDataDir('avatar'), |
|
479 | - $c->getL10N('lib'), |
|
480 | - $c->getLogger(), |
|
481 | - $c->getConfig() |
|
482 | - ); |
|
483 | - }); |
|
484 | - $this->registerAlias('AvatarManager', \OCP\IAvatarManager::class); |
|
485 | - |
|
486 | - $this->registerService(\OCP\ILogger::class, function (Server $c) { |
|
487 | - $logType = $c->query('AllConfig')->getSystemValue('log_type', 'file'); |
|
488 | - $logger = Log::getLogClass($logType); |
|
489 | - call_user_func(array($logger, 'init')); |
|
490 | - |
|
491 | - return new Log($logger); |
|
492 | - }); |
|
493 | - $this->registerAlias('Logger', \OCP\ILogger::class); |
|
494 | - |
|
495 | - $this->registerService(\OCP\BackgroundJob\IJobList::class, function (Server $c) { |
|
496 | - $config = $c->getConfig(); |
|
497 | - return new \OC\BackgroundJob\JobList( |
|
498 | - $c->getDatabaseConnection(), |
|
499 | - $config, |
|
500 | - new TimeFactory() |
|
501 | - ); |
|
502 | - }); |
|
503 | - $this->registerAlias('JobList', \OCP\BackgroundJob\IJobList::class); |
|
504 | - |
|
505 | - $this->registerService(\OCP\Route\IRouter::class, function (Server $c) { |
|
506 | - $cacheFactory = $c->getMemCacheFactory(); |
|
507 | - $logger = $c->getLogger(); |
|
508 | - if ($cacheFactory->isAvailable()) { |
|
509 | - $router = new \OC\Route\CachingRouter($cacheFactory->create('route'), $logger); |
|
510 | - } else { |
|
511 | - $router = new \OC\Route\Router($logger); |
|
512 | - } |
|
513 | - return $router; |
|
514 | - }); |
|
515 | - $this->registerAlias('Router', \OCP\Route\IRouter::class); |
|
516 | - |
|
517 | - $this->registerService(\OCP\ISearch::class, function ($c) { |
|
518 | - return new Search(); |
|
519 | - }); |
|
520 | - $this->registerAlias('Search', \OCP\ISearch::class); |
|
521 | - |
|
522 | - $this->registerService(\OCP\Security\ISecureRandom::class, function ($c) { |
|
523 | - return new SecureRandom(); |
|
524 | - }); |
|
525 | - $this->registerAlias('SecureRandom', \OCP\Security\ISecureRandom::class); |
|
526 | - |
|
527 | - $this->registerService(\OCP\Security\ICrypto::class, function (Server $c) { |
|
528 | - return new Crypto($c->getConfig(), $c->getSecureRandom()); |
|
529 | - }); |
|
530 | - $this->registerAlias('Crypto', \OCP\Security\ICrypto::class); |
|
531 | - |
|
532 | - $this->registerService(\OCP\Security\IHasher::class, function (Server $c) { |
|
533 | - return new Hasher($c->getConfig()); |
|
534 | - }); |
|
535 | - $this->registerAlias('Hasher', \OCP\Security\IHasher::class); |
|
536 | - |
|
537 | - $this->registerService(\OCP\Security\ICredentialsManager::class, function (Server $c) { |
|
538 | - return new CredentialsManager($c->getCrypto(), $c->getDatabaseConnection()); |
|
539 | - }); |
|
540 | - $this->registerAlias('CredentialsManager', \OCP\Security\ICredentialsManager::class); |
|
541 | - |
|
542 | - $this->registerService(IDBConnection::class, function (Server $c) { |
|
543 | - $systemConfig = $c->getSystemConfig(); |
|
544 | - $factory = new \OC\DB\ConnectionFactory($systemConfig); |
|
545 | - $type = $systemConfig->getValue('dbtype', 'sqlite'); |
|
546 | - if (!$factory->isValidType($type)) { |
|
547 | - throw new \OC\DatabaseException('Invalid database type'); |
|
548 | - } |
|
549 | - $connectionParams = $factory->createConnectionParams(); |
|
550 | - $connection = $factory->getConnection($type, $connectionParams); |
|
551 | - $connection->getConfiguration()->setSQLLogger($c->getQueryLogger()); |
|
552 | - return $connection; |
|
553 | - }); |
|
554 | - $this->registerAlias('DatabaseConnection', IDBConnection::class); |
|
555 | - |
|
556 | - $this->registerService('HTTPHelper', function (Server $c) { |
|
557 | - $config = $c->getConfig(); |
|
558 | - return new HTTPHelper( |
|
559 | - $config, |
|
560 | - $c->getHTTPClientService() |
|
561 | - ); |
|
562 | - }); |
|
563 | - |
|
564 | - $this->registerService(\OCP\Http\Client\IClientService::class, function (Server $c) { |
|
565 | - $user = \OC_User::getUser(); |
|
566 | - $uid = $user ? $user : null; |
|
567 | - return new ClientService( |
|
568 | - $c->getConfig(), |
|
569 | - new \OC\Security\CertificateManager($uid, new View(), $c->getConfig(), $c->getLogger()) |
|
570 | - ); |
|
571 | - }); |
|
572 | - $this->registerAlias('HttpClientService', \OCP\Http\Client\IClientService::class); |
|
573 | - |
|
574 | - $this->registerService(\OCP\Diagnostics\IEventLogger::class, function (Server $c) { |
|
575 | - if ($c->getSystemConfig()->getValue('debug', false)) { |
|
576 | - return new EventLogger(); |
|
577 | - } else { |
|
578 | - return new NullEventLogger(); |
|
579 | - } |
|
580 | - }); |
|
581 | - $this->registerAlias('EventLogger', \OCP\Diagnostics\IEventLogger::class); |
|
582 | - |
|
583 | - $this->registerService(\OCP\Diagnostics\IQueryLogger::class, function (Server $c) { |
|
584 | - if ($c->getSystemConfig()->getValue('debug', false)) { |
|
585 | - return new QueryLogger(); |
|
586 | - } else { |
|
587 | - return new NullQueryLogger(); |
|
588 | - } |
|
589 | - }); |
|
590 | - $this->registerAlias('QueryLogger', \OCP\Diagnostics\IQueryLogger::class); |
|
591 | - |
|
592 | - $this->registerService(TempManager::class, function (Server $c) { |
|
593 | - return new TempManager( |
|
594 | - $c->getLogger(), |
|
595 | - $c->getConfig() |
|
596 | - ); |
|
597 | - }); |
|
598 | - $this->registerAlias('TempManager', TempManager::class); |
|
599 | - $this->registerAlias(ITempManager::class, TempManager::class); |
|
600 | - |
|
601 | - $this->registerService(AppManager::class, function (Server $c) { |
|
602 | - return new \OC\App\AppManager( |
|
603 | - $c->getUserSession(), |
|
604 | - $c->getAppConfig(), |
|
605 | - $c->getGroupManager(), |
|
606 | - $c->getMemCacheFactory(), |
|
607 | - $c->getEventDispatcher() |
|
608 | - ); |
|
609 | - }); |
|
610 | - $this->registerAlias('AppManager', AppManager::class); |
|
611 | - $this->registerAlias(IAppManager::class, AppManager::class); |
|
612 | - |
|
613 | - $this->registerService(\OCP\IDateTimeZone::class, function (Server $c) { |
|
614 | - return new DateTimeZone( |
|
615 | - $c->getConfig(), |
|
616 | - $c->getSession() |
|
617 | - ); |
|
618 | - }); |
|
619 | - $this->registerAlias('DateTimeZone', \OCP\IDateTimeZone::class); |
|
620 | - |
|
621 | - $this->registerService(\OCP\IDateTimeFormatter::class, function (Server $c) { |
|
622 | - $language = $c->getConfig()->getUserValue($c->getSession()->get('user_id'), 'core', 'lang', null); |
|
623 | - |
|
624 | - return new DateTimeFormatter( |
|
625 | - $c->getDateTimeZone()->getTimeZone(), |
|
626 | - $c->getL10N('lib', $language) |
|
627 | - ); |
|
628 | - }); |
|
629 | - $this->registerAlias('DateTimeFormatter', \OCP\IDateTimeFormatter::class); |
|
630 | - |
|
631 | - $this->registerService(\OCP\Files\Config\IUserMountCache::class, function (Server $c) { |
|
632 | - $mountCache = new UserMountCache($c->getDatabaseConnection(), $c->getUserManager(), $c->getLogger()); |
|
633 | - $listener = new UserMountCacheListener($mountCache); |
|
634 | - $listener->listen($c->getUserManager()); |
|
635 | - return $mountCache; |
|
636 | - }); |
|
637 | - $this->registerAlias('UserMountCache', \OCP\Files\Config\IUserMountCache::class); |
|
638 | - |
|
639 | - $this->registerService(\OCP\Files\Config\IMountProviderCollection::class, function (Server $c) { |
|
640 | - $loader = \OC\Files\Filesystem::getLoader(); |
|
641 | - $mountCache = $c->query('UserMountCache'); |
|
642 | - $manager = new \OC\Files\Config\MountProviderCollection($loader, $mountCache); |
|
643 | - |
|
644 | - // builtin providers |
|
645 | - |
|
646 | - $config = $c->getConfig(); |
|
647 | - $manager->registerProvider(new CacheMountProvider($config)); |
|
648 | - $manager->registerHomeProvider(new LocalHomeMountProvider()); |
|
649 | - $manager->registerHomeProvider(new ObjectHomeMountProvider($config)); |
|
650 | - |
|
651 | - return $manager; |
|
652 | - }); |
|
653 | - $this->registerAlias('MountConfigManager', \OCP\Files\Config\IMountProviderCollection::class); |
|
654 | - |
|
655 | - $this->registerService('IniWrapper', function ($c) { |
|
656 | - return new IniGetWrapper(); |
|
657 | - }); |
|
658 | - $this->registerService('AsyncCommandBus', function (Server $c) { |
|
659 | - $jobList = $c->getJobList(); |
|
660 | - return new AsyncBus($jobList); |
|
661 | - }); |
|
662 | - $this->registerService('TrustedDomainHelper', function ($c) { |
|
663 | - return new TrustedDomainHelper($this->getConfig()); |
|
664 | - }); |
|
665 | - $this->registerService('Throttler', function(Server $c) { |
|
666 | - return new Throttler( |
|
667 | - $c->getDatabaseConnection(), |
|
668 | - new TimeFactory(), |
|
669 | - $c->getLogger(), |
|
670 | - $c->getConfig() |
|
671 | - ); |
|
672 | - }); |
|
673 | - $this->registerService('IntegrityCodeChecker', function (Server $c) { |
|
674 | - // IConfig and IAppManager requires a working database. This code |
|
675 | - // might however be called when ownCloud is not yet setup. |
|
676 | - if(\OC::$server->getSystemConfig()->getValue('installed', false)) { |
|
677 | - $config = $c->getConfig(); |
|
678 | - $appManager = $c->getAppManager(); |
|
679 | - } else { |
|
680 | - $config = null; |
|
681 | - $appManager = null; |
|
682 | - } |
|
683 | - |
|
684 | - return new Checker( |
|
685 | - new EnvironmentHelper(), |
|
686 | - new FileAccessHelper(), |
|
687 | - new AppLocator(), |
|
688 | - $config, |
|
689 | - $c->getMemCacheFactory(), |
|
690 | - $appManager, |
|
691 | - $c->getTempManager() |
|
692 | - ); |
|
693 | - }); |
|
694 | - $this->registerService(\OCP\IRequest::class, function ($c) { |
|
695 | - if (isset($this['urlParams'])) { |
|
696 | - $urlParams = $this['urlParams']; |
|
697 | - } else { |
|
698 | - $urlParams = []; |
|
699 | - } |
|
700 | - |
|
701 | - if (defined('PHPUNIT_RUN') && PHPUNIT_RUN |
|
702 | - && in_array('fakeinput', stream_get_wrappers()) |
|
703 | - ) { |
|
704 | - $stream = 'fakeinput://data'; |
|
705 | - } else { |
|
706 | - $stream = 'php://input'; |
|
707 | - } |
|
708 | - |
|
709 | - return new Request( |
|
710 | - [ |
|
711 | - 'get' => $_GET, |
|
712 | - 'post' => $_POST, |
|
713 | - 'files' => $_FILES, |
|
714 | - 'server' => $_SERVER, |
|
715 | - 'env' => $_ENV, |
|
716 | - 'cookies' => $_COOKIE, |
|
717 | - 'method' => (isset($_SERVER) && isset($_SERVER['REQUEST_METHOD'])) |
|
718 | - ? $_SERVER['REQUEST_METHOD'] |
|
719 | - : null, |
|
720 | - 'urlParams' => $urlParams, |
|
721 | - ], |
|
722 | - $this->getSecureRandom(), |
|
723 | - $this->getConfig(), |
|
724 | - $this->getCsrfTokenManager(), |
|
725 | - $stream |
|
726 | - ); |
|
727 | - }); |
|
728 | - $this->registerAlias('Request', \OCP\IRequest::class); |
|
729 | - |
|
730 | - $this->registerService(\OCP\Mail\IMailer::class, function (Server $c) { |
|
731 | - return new Mailer( |
|
732 | - $c->getConfig(), |
|
733 | - $c->getLogger(), |
|
734 | - $c->getThemingDefaults() |
|
735 | - ); |
|
736 | - }); |
|
737 | - $this->registerAlias('Mailer', \OCP\Mail\IMailer::class); |
|
738 | - |
|
739 | - $this->registerService('LDAPProvider', function(Server $c) { |
|
740 | - $config = $c->getConfig(); |
|
741 | - $factoryClass = $config->getSystemValue('ldapProviderFactory', null); |
|
742 | - if(is_null($factoryClass)) { |
|
743 | - throw new \Exception('ldapProviderFactory not set'); |
|
744 | - } |
|
745 | - /** @var \OCP\LDAP\ILDAPProviderFactory $factory */ |
|
746 | - $factory = new $factoryClass($this); |
|
747 | - return $factory->getLDAPProvider(); |
|
748 | - }); |
|
749 | - $this->registerService('LockingProvider', function (Server $c) { |
|
750 | - $ini = $c->getIniWrapper(); |
|
751 | - $config = $c->getConfig(); |
|
752 | - $ttl = $config->getSystemValue('filelocking.ttl', max(3600, $ini->getNumeric('max_execution_time'))); |
|
753 | - if ($config->getSystemValue('filelocking.enabled', true) or (defined('PHPUNIT_RUN') && PHPUNIT_RUN)) { |
|
754 | - /** @var \OC\Memcache\Factory $memcacheFactory */ |
|
755 | - $memcacheFactory = $c->getMemCacheFactory(); |
|
756 | - $memcache = $memcacheFactory->createLocking('lock'); |
|
757 | - if (!($memcache instanceof \OC\Memcache\NullCache)) { |
|
758 | - return new MemcacheLockingProvider($memcache, $ttl); |
|
759 | - } |
|
760 | - return new DBLockingProvider($c->getDatabaseConnection(), $c->getLogger(), new TimeFactory(), $ttl); |
|
761 | - } |
|
762 | - return new NoopLockingProvider(); |
|
763 | - }); |
|
764 | - |
|
765 | - $this->registerService(\OCP\Files\Mount\IMountManager::class, function () { |
|
766 | - return new \OC\Files\Mount\Manager(); |
|
767 | - }); |
|
768 | - $this->registerAlias('MountManager', \OCP\Files\Mount\IMountManager::class); |
|
769 | - |
|
770 | - $this->registerService(\OCP\Files\IMimeTypeDetector::class, function (Server $c) { |
|
771 | - return new \OC\Files\Type\Detection( |
|
772 | - $c->getURLGenerator(), |
|
773 | - \OC::$configDir, |
|
774 | - \OC::$SERVERROOT . '/resources/config/' |
|
775 | - ); |
|
776 | - }); |
|
777 | - $this->registerAlias('MimeTypeDetector', \OCP\Files\IMimeTypeDetector::class); |
|
778 | - |
|
779 | - $this->registerService(\OCP\Files\IMimeTypeLoader::class, function (Server $c) { |
|
780 | - return new \OC\Files\Type\Loader( |
|
781 | - $c->getDatabaseConnection() |
|
782 | - ); |
|
783 | - }); |
|
784 | - $this->registerAlias('MimeTypeLoader', \OCP\Files\IMimeTypeLoader::class); |
|
785 | - |
|
786 | - $this->registerService(\OCP\Notification\IManager::class, function (Server $c) { |
|
787 | - return new Manager( |
|
788 | - $c->query(IValidator::class) |
|
789 | - ); |
|
790 | - }); |
|
791 | - $this->registerAlias('NotificationManager', \OCP\Notification\IManager::class); |
|
792 | - |
|
793 | - $this->registerService(\OC\CapabilitiesManager::class, function (Server $c) { |
|
794 | - $manager = new \OC\CapabilitiesManager($c->getLogger()); |
|
795 | - $manager->registerCapability(function () use ($c) { |
|
796 | - return new \OC\OCS\CoreCapabilities($c->getConfig()); |
|
797 | - }); |
|
798 | - return $manager; |
|
799 | - }); |
|
800 | - $this->registerAlias('CapabilitiesManager', \OC\CapabilitiesManager::class); |
|
801 | - |
|
802 | - $this->registerService(\OCP\Comments\ICommentsManager::class, function(Server $c) { |
|
803 | - $config = $c->getConfig(); |
|
804 | - $factoryClass = $config->getSystemValue('comments.managerFactory', '\OC\Comments\ManagerFactory'); |
|
805 | - /** @var \OCP\Comments\ICommentsManagerFactory $factory */ |
|
806 | - $factory = new $factoryClass($this); |
|
807 | - return $factory->getManager(); |
|
808 | - }); |
|
809 | - $this->registerAlias('CommentsManager', \OCP\Comments\ICommentsManager::class); |
|
810 | - |
|
811 | - $this->registerService('ThemingDefaults', function(Server $c) { |
|
812 | - /* |
|
121 | + /** @var string */ |
|
122 | + private $webRoot; |
|
123 | + |
|
124 | + /** |
|
125 | + * @param string $webRoot |
|
126 | + * @param \OC\Config $config |
|
127 | + */ |
|
128 | + public function __construct($webRoot, \OC\Config $config) { |
|
129 | + parent::__construct(); |
|
130 | + $this->webRoot = $webRoot; |
|
131 | + |
|
132 | + $this->registerAlias(\OCP\Contacts\IManager::class, \OC\ContactsManager::class); |
|
133 | + $this->registerAlias('ContactsManager', \OCP\Contacts\IManager::class); |
|
134 | + |
|
135 | + $this->registerAlias(IActionFactory::class, ActionFactory::class); |
|
136 | + |
|
137 | + $this->registerService(\OCP\IPreview::class, function (Server $c) { |
|
138 | + return new PreviewManager( |
|
139 | + $c->getConfig(), |
|
140 | + $c->getRootFolder(), |
|
141 | + $c->getAppDataDir('preview'), |
|
142 | + $c->getEventDispatcher(), |
|
143 | + $c->getSession()->get('user_id') |
|
144 | + ); |
|
145 | + }); |
|
146 | + $this->registerAlias('PreviewManager', \OCP\IPreview::class); |
|
147 | + |
|
148 | + $this->registerService(\OC\Preview\Watcher::class, function (Server $c) { |
|
149 | + return new \OC\Preview\Watcher( |
|
150 | + $c->getAppDataDir('preview') |
|
151 | + ); |
|
152 | + }); |
|
153 | + |
|
154 | + $this->registerService('EncryptionManager', function (Server $c) { |
|
155 | + $view = new View(); |
|
156 | + $util = new Encryption\Util( |
|
157 | + $view, |
|
158 | + $c->getUserManager(), |
|
159 | + $c->getGroupManager(), |
|
160 | + $c->getConfig() |
|
161 | + ); |
|
162 | + return new Encryption\Manager( |
|
163 | + $c->getConfig(), |
|
164 | + $c->getLogger(), |
|
165 | + $c->getL10N('core'), |
|
166 | + new View(), |
|
167 | + $util, |
|
168 | + new ArrayCache() |
|
169 | + ); |
|
170 | + }); |
|
171 | + |
|
172 | + $this->registerService('EncryptionFileHelper', function (Server $c) { |
|
173 | + $util = new Encryption\Util( |
|
174 | + new View(), |
|
175 | + $c->getUserManager(), |
|
176 | + $c->getGroupManager(), |
|
177 | + $c->getConfig() |
|
178 | + ); |
|
179 | + return new Encryption\File($util); |
|
180 | + }); |
|
181 | + |
|
182 | + $this->registerService('EncryptionKeyStorage', function (Server $c) { |
|
183 | + $view = new View(); |
|
184 | + $util = new Encryption\Util( |
|
185 | + $view, |
|
186 | + $c->getUserManager(), |
|
187 | + $c->getGroupManager(), |
|
188 | + $c->getConfig() |
|
189 | + ); |
|
190 | + |
|
191 | + return new Encryption\Keys\Storage($view, $util); |
|
192 | + }); |
|
193 | + $this->registerService('TagMapper', function (Server $c) { |
|
194 | + return new TagMapper($c->getDatabaseConnection()); |
|
195 | + }); |
|
196 | + |
|
197 | + $this->registerService(\OCP\ITagManager::class, function (Server $c) { |
|
198 | + $tagMapper = $c->query('TagMapper'); |
|
199 | + return new TagManager($tagMapper, $c->getUserSession()); |
|
200 | + }); |
|
201 | + $this->registerAlias('TagManager', \OCP\ITagManager::class); |
|
202 | + |
|
203 | + $this->registerService('SystemTagManagerFactory', function (Server $c) { |
|
204 | + $config = $c->getConfig(); |
|
205 | + $factoryClass = $config->getSystemValue('systemtags.managerFactory', '\OC\SystemTag\ManagerFactory'); |
|
206 | + /** @var \OC\SystemTag\ManagerFactory $factory */ |
|
207 | + $factory = new $factoryClass($this); |
|
208 | + return $factory; |
|
209 | + }); |
|
210 | + $this->registerService(\OCP\SystemTag\ISystemTagManager::class, function (Server $c) { |
|
211 | + return $c->query('SystemTagManagerFactory')->getManager(); |
|
212 | + }); |
|
213 | + $this->registerAlias('SystemTagManager', \OCP\SystemTag\ISystemTagManager::class); |
|
214 | + |
|
215 | + $this->registerService(\OCP\SystemTag\ISystemTagObjectMapper::class, function (Server $c) { |
|
216 | + return $c->query('SystemTagManagerFactory')->getObjectMapper(); |
|
217 | + }); |
|
218 | + $this->registerService('RootFolder', function (Server $c) { |
|
219 | + $manager = \OC\Files\Filesystem::getMountManager(null); |
|
220 | + $view = new View(); |
|
221 | + $root = new Root( |
|
222 | + $manager, |
|
223 | + $view, |
|
224 | + null, |
|
225 | + $c->getUserMountCache(), |
|
226 | + $this->getLogger(), |
|
227 | + $this->getUserManager() |
|
228 | + ); |
|
229 | + $connector = new HookConnector($root, $view); |
|
230 | + $connector->viewToNode(); |
|
231 | + |
|
232 | + $previewConnector = new \OC\Preview\WatcherConnector($root, $c->getSystemConfig()); |
|
233 | + $previewConnector->connectWatcher(); |
|
234 | + |
|
235 | + return $root; |
|
236 | + }); |
|
237 | + $this->registerAlias('SystemTagObjectMapper', \OCP\SystemTag\ISystemTagObjectMapper::class); |
|
238 | + |
|
239 | + $this->registerService(\OCP\Files\IRootFolder::class, function(Server $c) { |
|
240 | + return new LazyRoot(function() use ($c) { |
|
241 | + return $c->query('RootFolder'); |
|
242 | + }); |
|
243 | + }); |
|
244 | + $this->registerAlias('LazyRootFolder', \OCP\Files\IRootFolder::class); |
|
245 | + |
|
246 | + $this->registerService(\OCP\IUserManager::class, function (Server $c) { |
|
247 | + $config = $c->getConfig(); |
|
248 | + return new \OC\User\Manager($config); |
|
249 | + }); |
|
250 | + $this->registerAlias('UserManager', \OCP\IUserManager::class); |
|
251 | + |
|
252 | + $this->registerService(\OCP\IGroupManager::class, function (Server $c) { |
|
253 | + $groupManager = new \OC\Group\Manager($this->getUserManager(), $this->getLogger()); |
|
254 | + $groupManager->listen('\OC\Group', 'preCreate', function ($gid) { |
|
255 | + \OC_Hook::emit('OC_Group', 'pre_createGroup', array('run' => true, 'gid' => $gid)); |
|
256 | + }); |
|
257 | + $groupManager->listen('\OC\Group', 'postCreate', function (\OC\Group\Group $gid) { |
|
258 | + \OC_Hook::emit('OC_User', 'post_createGroup', array('gid' => $gid->getGID())); |
|
259 | + }); |
|
260 | + $groupManager->listen('\OC\Group', 'preDelete', function (\OC\Group\Group $group) { |
|
261 | + \OC_Hook::emit('OC_Group', 'pre_deleteGroup', array('run' => true, 'gid' => $group->getGID())); |
|
262 | + }); |
|
263 | + $groupManager->listen('\OC\Group', 'postDelete', function (\OC\Group\Group $group) { |
|
264 | + \OC_Hook::emit('OC_User', 'post_deleteGroup', array('gid' => $group->getGID())); |
|
265 | + }); |
|
266 | + $groupManager->listen('\OC\Group', 'preAddUser', function (\OC\Group\Group $group, \OC\User\User $user) { |
|
267 | + \OC_Hook::emit('OC_Group', 'pre_addToGroup', array('run' => true, 'uid' => $user->getUID(), 'gid' => $group->getGID())); |
|
268 | + }); |
|
269 | + $groupManager->listen('\OC\Group', 'postAddUser', function (\OC\Group\Group $group, \OC\User\User $user) { |
|
270 | + \OC_Hook::emit('OC_Group', 'post_addToGroup', array('uid' => $user->getUID(), 'gid' => $group->getGID())); |
|
271 | + //Minimal fix to keep it backward compatible TODO: clean up all the GroupManager hooks |
|
272 | + \OC_Hook::emit('OC_User', 'post_addToGroup', array('uid' => $user->getUID(), 'gid' => $group->getGID())); |
|
273 | + }); |
|
274 | + return $groupManager; |
|
275 | + }); |
|
276 | + $this->registerAlias('GroupManager', \OCP\IGroupManager::class); |
|
277 | + |
|
278 | + $this->registerService(Store::class, function(Server $c) { |
|
279 | + $session = $c->getSession(); |
|
280 | + if (\OC::$server->getSystemConfig()->getValue('installed', false)) { |
|
281 | + $tokenProvider = $c->query('OC\Authentication\Token\IProvider'); |
|
282 | + } else { |
|
283 | + $tokenProvider = null; |
|
284 | + } |
|
285 | + $logger = $c->getLogger(); |
|
286 | + return new Store($session, $logger, $tokenProvider); |
|
287 | + }); |
|
288 | + $this->registerAlias(IStore::class, Store::class); |
|
289 | + $this->registerService('OC\Authentication\Token\DefaultTokenMapper', function (Server $c) { |
|
290 | + $dbConnection = $c->getDatabaseConnection(); |
|
291 | + return new Authentication\Token\DefaultTokenMapper($dbConnection); |
|
292 | + }); |
|
293 | + $this->registerService('OC\Authentication\Token\DefaultTokenProvider', function (Server $c) { |
|
294 | + $mapper = $c->query('OC\Authentication\Token\DefaultTokenMapper'); |
|
295 | + $crypto = $c->getCrypto(); |
|
296 | + $config = $c->getConfig(); |
|
297 | + $logger = $c->getLogger(); |
|
298 | + $timeFactory = new TimeFactory(); |
|
299 | + return new \OC\Authentication\Token\DefaultTokenProvider($mapper, $crypto, $config, $logger, $timeFactory); |
|
300 | + }); |
|
301 | + $this->registerAlias('OC\Authentication\Token\IProvider', 'OC\Authentication\Token\DefaultTokenProvider'); |
|
302 | + |
|
303 | + $this->registerService(\OCP\IUserSession::class, function (Server $c) { |
|
304 | + $manager = $c->getUserManager(); |
|
305 | + $session = new \OC\Session\Memory(''); |
|
306 | + $timeFactory = new TimeFactory(); |
|
307 | + // Token providers might require a working database. This code |
|
308 | + // might however be called when ownCloud is not yet setup. |
|
309 | + if (\OC::$server->getSystemConfig()->getValue('installed', false)) { |
|
310 | + $defaultTokenProvider = $c->query('OC\Authentication\Token\IProvider'); |
|
311 | + } else { |
|
312 | + $defaultTokenProvider = null; |
|
313 | + } |
|
314 | + |
|
315 | + $userSession = new \OC\User\Session($manager, $session, $timeFactory, $defaultTokenProvider, $c->getConfig(), $c->getSecureRandom()); |
|
316 | + $userSession->listen('\OC\User', 'preCreateUser', function ($uid, $password) { |
|
317 | + \OC_Hook::emit('OC_User', 'pre_createUser', array('run' => true, 'uid' => $uid, 'password' => $password)); |
|
318 | + }); |
|
319 | + $userSession->listen('\OC\User', 'postCreateUser', function ($user, $password) { |
|
320 | + /** @var $user \OC\User\User */ |
|
321 | + \OC_Hook::emit('OC_User', 'post_createUser', array('uid' => $user->getUID(), 'password' => $password)); |
|
322 | + }); |
|
323 | + $userSession->listen('\OC\User', 'preDelete', function ($user) { |
|
324 | + /** @var $user \OC\User\User */ |
|
325 | + \OC_Hook::emit('OC_User', 'pre_deleteUser', array('run' => true, 'uid' => $user->getUID())); |
|
326 | + }); |
|
327 | + $userSession->listen('\OC\User', 'postDelete', function ($user) { |
|
328 | + /** @var $user \OC\User\User */ |
|
329 | + \OC_Hook::emit('OC_User', 'post_deleteUser', array('uid' => $user->getUID())); |
|
330 | + }); |
|
331 | + $userSession->listen('\OC\User', 'preSetPassword', function ($user, $password, $recoveryPassword) { |
|
332 | + /** @var $user \OC\User\User */ |
|
333 | + \OC_Hook::emit('OC_User', 'pre_setPassword', array('run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword)); |
|
334 | + }); |
|
335 | + $userSession->listen('\OC\User', 'postSetPassword', function ($user, $password, $recoveryPassword) { |
|
336 | + /** @var $user \OC\User\User */ |
|
337 | + \OC_Hook::emit('OC_User', 'post_setPassword', array('run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword)); |
|
338 | + }); |
|
339 | + $userSession->listen('\OC\User', 'preLogin', function ($uid, $password) { |
|
340 | + \OC_Hook::emit('OC_User', 'pre_login', array('run' => true, 'uid' => $uid, 'password' => $password)); |
|
341 | + }); |
|
342 | + $userSession->listen('\OC\User', 'postLogin', function ($user, $password) { |
|
343 | + /** @var $user \OC\User\User */ |
|
344 | + \OC_Hook::emit('OC_User', 'post_login', array('run' => true, 'uid' => $user->getUID(), 'password' => $password)); |
|
345 | + }); |
|
346 | + $userSession->listen('\OC\User', 'logout', function () { |
|
347 | + \OC_Hook::emit('OC_User', 'logout', array()); |
|
348 | + }); |
|
349 | + $userSession->listen('\OC\User', 'changeUser', function ($user, $feature, $value) { |
|
350 | + /** @var $user \OC\User\User */ |
|
351 | + \OC_Hook::emit('OC_User', 'changeUser', array('run' => true, 'user' => $user, 'feature' => $feature, 'value' => $value)); |
|
352 | + }); |
|
353 | + return $userSession; |
|
354 | + }); |
|
355 | + $this->registerAlias('UserSession', \OCP\IUserSession::class); |
|
356 | + |
|
357 | + $this->registerService(\OC\Authentication\TwoFactorAuth\Manager::class, function (Server $c) { |
|
358 | + return new \OC\Authentication\TwoFactorAuth\Manager($c->getAppManager(), $c->getSession(), $c->getConfig(), $c->getActivityManager(), $c->getLogger()); |
|
359 | + }); |
|
360 | + |
|
361 | + $this->registerAlias(\OCP\INavigationManager::class, \OC\NavigationManager::class); |
|
362 | + $this->registerAlias('NavigationManager', \OCP\INavigationManager::class); |
|
363 | + |
|
364 | + $this->registerService(\OC\AllConfig::class, function (Server $c) { |
|
365 | + return new \OC\AllConfig( |
|
366 | + $c->getSystemConfig() |
|
367 | + ); |
|
368 | + }); |
|
369 | + $this->registerAlias('AllConfig', \OC\AllConfig::class); |
|
370 | + $this->registerAlias(\OCP\IConfig::class, \OC\AllConfig::class); |
|
371 | + |
|
372 | + $this->registerService('SystemConfig', function ($c) use ($config) { |
|
373 | + return new \OC\SystemConfig($config); |
|
374 | + }); |
|
375 | + |
|
376 | + $this->registerService(\OC\AppConfig::class, function (Server $c) { |
|
377 | + return new \OC\AppConfig($c->getDatabaseConnection()); |
|
378 | + }); |
|
379 | + $this->registerAlias('AppConfig', \OC\AppConfig::class); |
|
380 | + $this->registerAlias(\OCP\IAppConfig::class, \OC\AppConfig::class); |
|
381 | + |
|
382 | + $this->registerService(\OCP\L10N\IFactory::class, function (Server $c) { |
|
383 | + return new \OC\L10N\Factory( |
|
384 | + $c->getConfig(), |
|
385 | + $c->getRequest(), |
|
386 | + $c->getUserSession(), |
|
387 | + \OC::$SERVERROOT |
|
388 | + ); |
|
389 | + }); |
|
390 | + $this->registerAlias('L10NFactory', \OCP\L10N\IFactory::class); |
|
391 | + |
|
392 | + $this->registerService(\OCP\IURLGenerator::class, function (Server $c) { |
|
393 | + $config = $c->getConfig(); |
|
394 | + $cacheFactory = $c->getMemCacheFactory(); |
|
395 | + return new \OC\URLGenerator( |
|
396 | + $config, |
|
397 | + $cacheFactory |
|
398 | + ); |
|
399 | + }); |
|
400 | + $this->registerAlias('URLGenerator', \OCP\IURLGenerator::class); |
|
401 | + |
|
402 | + $this->registerService('AppHelper', function ($c) { |
|
403 | + return new \OC\AppHelper(); |
|
404 | + }); |
|
405 | + $this->registerService('AppFetcher', function ($c) { |
|
406 | + return new AppFetcher( |
|
407 | + $this->getAppDataDir('appstore'), |
|
408 | + $this->getHTTPClientService(), |
|
409 | + $this->query(TimeFactory::class), |
|
410 | + $this->getConfig() |
|
411 | + ); |
|
412 | + }); |
|
413 | + $this->registerService('CategoryFetcher', function ($c) { |
|
414 | + return new CategoryFetcher( |
|
415 | + $this->getAppDataDir('appstore'), |
|
416 | + $this->getHTTPClientService(), |
|
417 | + $this->query(TimeFactory::class), |
|
418 | + $this->getConfig() |
|
419 | + ); |
|
420 | + }); |
|
421 | + |
|
422 | + $this->registerService(\OCP\ICache::class, function ($c) { |
|
423 | + return new Cache\File(); |
|
424 | + }); |
|
425 | + $this->registerAlias('UserCache', \OCP\ICache::class); |
|
426 | + |
|
427 | + $this->registerService(Factory::class, function (Server $c) { |
|
428 | + $config = $c->getConfig(); |
|
429 | + |
|
430 | + if ($config->getSystemValue('installed', false) && !(defined('PHPUNIT_RUN') && PHPUNIT_RUN)) { |
|
431 | + $v = \OC_App::getAppVersions(); |
|
432 | + $v['core'] = md5(file_get_contents(\OC::$SERVERROOT . '/version.php')); |
|
433 | + $version = implode(',', $v); |
|
434 | + $instanceId = \OC_Util::getInstanceId(); |
|
435 | + $path = \OC::$SERVERROOT; |
|
436 | + $prefix = md5($instanceId . '-' . $version . '-' . $path . '-' . \OC::$WEBROOT); |
|
437 | + return new \OC\Memcache\Factory($prefix, $c->getLogger(), |
|
438 | + $config->getSystemValue('memcache.local', null), |
|
439 | + $config->getSystemValue('memcache.distributed', null), |
|
440 | + $config->getSystemValue('memcache.locking', null) |
|
441 | + ); |
|
442 | + } |
|
443 | + |
|
444 | + return new \OC\Memcache\Factory('', $c->getLogger(), |
|
445 | + '\\OC\\Memcache\\ArrayCache', |
|
446 | + '\\OC\\Memcache\\ArrayCache', |
|
447 | + '\\OC\\Memcache\\ArrayCache' |
|
448 | + ); |
|
449 | + }); |
|
450 | + $this->registerAlias('MemCacheFactory', Factory::class); |
|
451 | + $this->registerAlias(ICacheFactory::class, Factory::class); |
|
452 | + |
|
453 | + $this->registerService('RedisFactory', function (Server $c) { |
|
454 | + $systemConfig = $c->getSystemConfig(); |
|
455 | + return new RedisFactory($systemConfig); |
|
456 | + }); |
|
457 | + |
|
458 | + $this->registerService(\OCP\Activity\IManager::class, function (Server $c) { |
|
459 | + return new \OC\Activity\Manager( |
|
460 | + $c->getRequest(), |
|
461 | + $c->getUserSession(), |
|
462 | + $c->getConfig(), |
|
463 | + $c->query(IValidator::class) |
|
464 | + ); |
|
465 | + }); |
|
466 | + $this->registerAlias('ActivityManager', \OCP\Activity\IManager::class); |
|
467 | + |
|
468 | + $this->registerService(\OCP\Activity\IEventMerger::class, function (Server $c) { |
|
469 | + return new \OC\Activity\EventMerger( |
|
470 | + $c->getL10N('lib') |
|
471 | + ); |
|
472 | + }); |
|
473 | + $this->registerAlias(IValidator::class, Validator::class); |
|
474 | + |
|
475 | + $this->registerService(\OCP\IAvatarManager::class, function (Server $c) { |
|
476 | + return new AvatarManager( |
|
477 | + $c->getUserManager(), |
|
478 | + $c->getAppDataDir('avatar'), |
|
479 | + $c->getL10N('lib'), |
|
480 | + $c->getLogger(), |
|
481 | + $c->getConfig() |
|
482 | + ); |
|
483 | + }); |
|
484 | + $this->registerAlias('AvatarManager', \OCP\IAvatarManager::class); |
|
485 | + |
|
486 | + $this->registerService(\OCP\ILogger::class, function (Server $c) { |
|
487 | + $logType = $c->query('AllConfig')->getSystemValue('log_type', 'file'); |
|
488 | + $logger = Log::getLogClass($logType); |
|
489 | + call_user_func(array($logger, 'init')); |
|
490 | + |
|
491 | + return new Log($logger); |
|
492 | + }); |
|
493 | + $this->registerAlias('Logger', \OCP\ILogger::class); |
|
494 | + |
|
495 | + $this->registerService(\OCP\BackgroundJob\IJobList::class, function (Server $c) { |
|
496 | + $config = $c->getConfig(); |
|
497 | + return new \OC\BackgroundJob\JobList( |
|
498 | + $c->getDatabaseConnection(), |
|
499 | + $config, |
|
500 | + new TimeFactory() |
|
501 | + ); |
|
502 | + }); |
|
503 | + $this->registerAlias('JobList', \OCP\BackgroundJob\IJobList::class); |
|
504 | + |
|
505 | + $this->registerService(\OCP\Route\IRouter::class, function (Server $c) { |
|
506 | + $cacheFactory = $c->getMemCacheFactory(); |
|
507 | + $logger = $c->getLogger(); |
|
508 | + if ($cacheFactory->isAvailable()) { |
|
509 | + $router = new \OC\Route\CachingRouter($cacheFactory->create('route'), $logger); |
|
510 | + } else { |
|
511 | + $router = new \OC\Route\Router($logger); |
|
512 | + } |
|
513 | + return $router; |
|
514 | + }); |
|
515 | + $this->registerAlias('Router', \OCP\Route\IRouter::class); |
|
516 | + |
|
517 | + $this->registerService(\OCP\ISearch::class, function ($c) { |
|
518 | + return new Search(); |
|
519 | + }); |
|
520 | + $this->registerAlias('Search', \OCP\ISearch::class); |
|
521 | + |
|
522 | + $this->registerService(\OCP\Security\ISecureRandom::class, function ($c) { |
|
523 | + return new SecureRandom(); |
|
524 | + }); |
|
525 | + $this->registerAlias('SecureRandom', \OCP\Security\ISecureRandom::class); |
|
526 | + |
|
527 | + $this->registerService(\OCP\Security\ICrypto::class, function (Server $c) { |
|
528 | + return new Crypto($c->getConfig(), $c->getSecureRandom()); |
|
529 | + }); |
|
530 | + $this->registerAlias('Crypto', \OCP\Security\ICrypto::class); |
|
531 | + |
|
532 | + $this->registerService(\OCP\Security\IHasher::class, function (Server $c) { |
|
533 | + return new Hasher($c->getConfig()); |
|
534 | + }); |
|
535 | + $this->registerAlias('Hasher', \OCP\Security\IHasher::class); |
|
536 | + |
|
537 | + $this->registerService(\OCP\Security\ICredentialsManager::class, function (Server $c) { |
|
538 | + return new CredentialsManager($c->getCrypto(), $c->getDatabaseConnection()); |
|
539 | + }); |
|
540 | + $this->registerAlias('CredentialsManager', \OCP\Security\ICredentialsManager::class); |
|
541 | + |
|
542 | + $this->registerService(IDBConnection::class, function (Server $c) { |
|
543 | + $systemConfig = $c->getSystemConfig(); |
|
544 | + $factory = new \OC\DB\ConnectionFactory($systemConfig); |
|
545 | + $type = $systemConfig->getValue('dbtype', 'sqlite'); |
|
546 | + if (!$factory->isValidType($type)) { |
|
547 | + throw new \OC\DatabaseException('Invalid database type'); |
|
548 | + } |
|
549 | + $connectionParams = $factory->createConnectionParams(); |
|
550 | + $connection = $factory->getConnection($type, $connectionParams); |
|
551 | + $connection->getConfiguration()->setSQLLogger($c->getQueryLogger()); |
|
552 | + return $connection; |
|
553 | + }); |
|
554 | + $this->registerAlias('DatabaseConnection', IDBConnection::class); |
|
555 | + |
|
556 | + $this->registerService('HTTPHelper', function (Server $c) { |
|
557 | + $config = $c->getConfig(); |
|
558 | + return new HTTPHelper( |
|
559 | + $config, |
|
560 | + $c->getHTTPClientService() |
|
561 | + ); |
|
562 | + }); |
|
563 | + |
|
564 | + $this->registerService(\OCP\Http\Client\IClientService::class, function (Server $c) { |
|
565 | + $user = \OC_User::getUser(); |
|
566 | + $uid = $user ? $user : null; |
|
567 | + return new ClientService( |
|
568 | + $c->getConfig(), |
|
569 | + new \OC\Security\CertificateManager($uid, new View(), $c->getConfig(), $c->getLogger()) |
|
570 | + ); |
|
571 | + }); |
|
572 | + $this->registerAlias('HttpClientService', \OCP\Http\Client\IClientService::class); |
|
573 | + |
|
574 | + $this->registerService(\OCP\Diagnostics\IEventLogger::class, function (Server $c) { |
|
575 | + if ($c->getSystemConfig()->getValue('debug', false)) { |
|
576 | + return new EventLogger(); |
|
577 | + } else { |
|
578 | + return new NullEventLogger(); |
|
579 | + } |
|
580 | + }); |
|
581 | + $this->registerAlias('EventLogger', \OCP\Diagnostics\IEventLogger::class); |
|
582 | + |
|
583 | + $this->registerService(\OCP\Diagnostics\IQueryLogger::class, function (Server $c) { |
|
584 | + if ($c->getSystemConfig()->getValue('debug', false)) { |
|
585 | + return new QueryLogger(); |
|
586 | + } else { |
|
587 | + return new NullQueryLogger(); |
|
588 | + } |
|
589 | + }); |
|
590 | + $this->registerAlias('QueryLogger', \OCP\Diagnostics\IQueryLogger::class); |
|
591 | + |
|
592 | + $this->registerService(TempManager::class, function (Server $c) { |
|
593 | + return new TempManager( |
|
594 | + $c->getLogger(), |
|
595 | + $c->getConfig() |
|
596 | + ); |
|
597 | + }); |
|
598 | + $this->registerAlias('TempManager', TempManager::class); |
|
599 | + $this->registerAlias(ITempManager::class, TempManager::class); |
|
600 | + |
|
601 | + $this->registerService(AppManager::class, function (Server $c) { |
|
602 | + return new \OC\App\AppManager( |
|
603 | + $c->getUserSession(), |
|
604 | + $c->getAppConfig(), |
|
605 | + $c->getGroupManager(), |
|
606 | + $c->getMemCacheFactory(), |
|
607 | + $c->getEventDispatcher() |
|
608 | + ); |
|
609 | + }); |
|
610 | + $this->registerAlias('AppManager', AppManager::class); |
|
611 | + $this->registerAlias(IAppManager::class, AppManager::class); |
|
612 | + |
|
613 | + $this->registerService(\OCP\IDateTimeZone::class, function (Server $c) { |
|
614 | + return new DateTimeZone( |
|
615 | + $c->getConfig(), |
|
616 | + $c->getSession() |
|
617 | + ); |
|
618 | + }); |
|
619 | + $this->registerAlias('DateTimeZone', \OCP\IDateTimeZone::class); |
|
620 | + |
|
621 | + $this->registerService(\OCP\IDateTimeFormatter::class, function (Server $c) { |
|
622 | + $language = $c->getConfig()->getUserValue($c->getSession()->get('user_id'), 'core', 'lang', null); |
|
623 | + |
|
624 | + return new DateTimeFormatter( |
|
625 | + $c->getDateTimeZone()->getTimeZone(), |
|
626 | + $c->getL10N('lib', $language) |
|
627 | + ); |
|
628 | + }); |
|
629 | + $this->registerAlias('DateTimeFormatter', \OCP\IDateTimeFormatter::class); |
|
630 | + |
|
631 | + $this->registerService(\OCP\Files\Config\IUserMountCache::class, function (Server $c) { |
|
632 | + $mountCache = new UserMountCache($c->getDatabaseConnection(), $c->getUserManager(), $c->getLogger()); |
|
633 | + $listener = new UserMountCacheListener($mountCache); |
|
634 | + $listener->listen($c->getUserManager()); |
|
635 | + return $mountCache; |
|
636 | + }); |
|
637 | + $this->registerAlias('UserMountCache', \OCP\Files\Config\IUserMountCache::class); |
|
638 | + |
|
639 | + $this->registerService(\OCP\Files\Config\IMountProviderCollection::class, function (Server $c) { |
|
640 | + $loader = \OC\Files\Filesystem::getLoader(); |
|
641 | + $mountCache = $c->query('UserMountCache'); |
|
642 | + $manager = new \OC\Files\Config\MountProviderCollection($loader, $mountCache); |
|
643 | + |
|
644 | + // builtin providers |
|
645 | + |
|
646 | + $config = $c->getConfig(); |
|
647 | + $manager->registerProvider(new CacheMountProvider($config)); |
|
648 | + $manager->registerHomeProvider(new LocalHomeMountProvider()); |
|
649 | + $manager->registerHomeProvider(new ObjectHomeMountProvider($config)); |
|
650 | + |
|
651 | + return $manager; |
|
652 | + }); |
|
653 | + $this->registerAlias('MountConfigManager', \OCP\Files\Config\IMountProviderCollection::class); |
|
654 | + |
|
655 | + $this->registerService('IniWrapper', function ($c) { |
|
656 | + return new IniGetWrapper(); |
|
657 | + }); |
|
658 | + $this->registerService('AsyncCommandBus', function (Server $c) { |
|
659 | + $jobList = $c->getJobList(); |
|
660 | + return new AsyncBus($jobList); |
|
661 | + }); |
|
662 | + $this->registerService('TrustedDomainHelper', function ($c) { |
|
663 | + return new TrustedDomainHelper($this->getConfig()); |
|
664 | + }); |
|
665 | + $this->registerService('Throttler', function(Server $c) { |
|
666 | + return new Throttler( |
|
667 | + $c->getDatabaseConnection(), |
|
668 | + new TimeFactory(), |
|
669 | + $c->getLogger(), |
|
670 | + $c->getConfig() |
|
671 | + ); |
|
672 | + }); |
|
673 | + $this->registerService('IntegrityCodeChecker', function (Server $c) { |
|
674 | + // IConfig and IAppManager requires a working database. This code |
|
675 | + // might however be called when ownCloud is not yet setup. |
|
676 | + if(\OC::$server->getSystemConfig()->getValue('installed', false)) { |
|
677 | + $config = $c->getConfig(); |
|
678 | + $appManager = $c->getAppManager(); |
|
679 | + } else { |
|
680 | + $config = null; |
|
681 | + $appManager = null; |
|
682 | + } |
|
683 | + |
|
684 | + return new Checker( |
|
685 | + new EnvironmentHelper(), |
|
686 | + new FileAccessHelper(), |
|
687 | + new AppLocator(), |
|
688 | + $config, |
|
689 | + $c->getMemCacheFactory(), |
|
690 | + $appManager, |
|
691 | + $c->getTempManager() |
|
692 | + ); |
|
693 | + }); |
|
694 | + $this->registerService(\OCP\IRequest::class, function ($c) { |
|
695 | + if (isset($this['urlParams'])) { |
|
696 | + $urlParams = $this['urlParams']; |
|
697 | + } else { |
|
698 | + $urlParams = []; |
|
699 | + } |
|
700 | + |
|
701 | + if (defined('PHPUNIT_RUN') && PHPUNIT_RUN |
|
702 | + && in_array('fakeinput', stream_get_wrappers()) |
|
703 | + ) { |
|
704 | + $stream = 'fakeinput://data'; |
|
705 | + } else { |
|
706 | + $stream = 'php://input'; |
|
707 | + } |
|
708 | + |
|
709 | + return new Request( |
|
710 | + [ |
|
711 | + 'get' => $_GET, |
|
712 | + 'post' => $_POST, |
|
713 | + 'files' => $_FILES, |
|
714 | + 'server' => $_SERVER, |
|
715 | + 'env' => $_ENV, |
|
716 | + 'cookies' => $_COOKIE, |
|
717 | + 'method' => (isset($_SERVER) && isset($_SERVER['REQUEST_METHOD'])) |
|
718 | + ? $_SERVER['REQUEST_METHOD'] |
|
719 | + : null, |
|
720 | + 'urlParams' => $urlParams, |
|
721 | + ], |
|
722 | + $this->getSecureRandom(), |
|
723 | + $this->getConfig(), |
|
724 | + $this->getCsrfTokenManager(), |
|
725 | + $stream |
|
726 | + ); |
|
727 | + }); |
|
728 | + $this->registerAlias('Request', \OCP\IRequest::class); |
|
729 | + |
|
730 | + $this->registerService(\OCP\Mail\IMailer::class, function (Server $c) { |
|
731 | + return new Mailer( |
|
732 | + $c->getConfig(), |
|
733 | + $c->getLogger(), |
|
734 | + $c->getThemingDefaults() |
|
735 | + ); |
|
736 | + }); |
|
737 | + $this->registerAlias('Mailer', \OCP\Mail\IMailer::class); |
|
738 | + |
|
739 | + $this->registerService('LDAPProvider', function(Server $c) { |
|
740 | + $config = $c->getConfig(); |
|
741 | + $factoryClass = $config->getSystemValue('ldapProviderFactory', null); |
|
742 | + if(is_null($factoryClass)) { |
|
743 | + throw new \Exception('ldapProviderFactory not set'); |
|
744 | + } |
|
745 | + /** @var \OCP\LDAP\ILDAPProviderFactory $factory */ |
|
746 | + $factory = new $factoryClass($this); |
|
747 | + return $factory->getLDAPProvider(); |
|
748 | + }); |
|
749 | + $this->registerService('LockingProvider', function (Server $c) { |
|
750 | + $ini = $c->getIniWrapper(); |
|
751 | + $config = $c->getConfig(); |
|
752 | + $ttl = $config->getSystemValue('filelocking.ttl', max(3600, $ini->getNumeric('max_execution_time'))); |
|
753 | + if ($config->getSystemValue('filelocking.enabled', true) or (defined('PHPUNIT_RUN') && PHPUNIT_RUN)) { |
|
754 | + /** @var \OC\Memcache\Factory $memcacheFactory */ |
|
755 | + $memcacheFactory = $c->getMemCacheFactory(); |
|
756 | + $memcache = $memcacheFactory->createLocking('lock'); |
|
757 | + if (!($memcache instanceof \OC\Memcache\NullCache)) { |
|
758 | + return new MemcacheLockingProvider($memcache, $ttl); |
|
759 | + } |
|
760 | + return new DBLockingProvider($c->getDatabaseConnection(), $c->getLogger(), new TimeFactory(), $ttl); |
|
761 | + } |
|
762 | + return new NoopLockingProvider(); |
|
763 | + }); |
|
764 | + |
|
765 | + $this->registerService(\OCP\Files\Mount\IMountManager::class, function () { |
|
766 | + return new \OC\Files\Mount\Manager(); |
|
767 | + }); |
|
768 | + $this->registerAlias('MountManager', \OCP\Files\Mount\IMountManager::class); |
|
769 | + |
|
770 | + $this->registerService(\OCP\Files\IMimeTypeDetector::class, function (Server $c) { |
|
771 | + return new \OC\Files\Type\Detection( |
|
772 | + $c->getURLGenerator(), |
|
773 | + \OC::$configDir, |
|
774 | + \OC::$SERVERROOT . '/resources/config/' |
|
775 | + ); |
|
776 | + }); |
|
777 | + $this->registerAlias('MimeTypeDetector', \OCP\Files\IMimeTypeDetector::class); |
|
778 | + |
|
779 | + $this->registerService(\OCP\Files\IMimeTypeLoader::class, function (Server $c) { |
|
780 | + return new \OC\Files\Type\Loader( |
|
781 | + $c->getDatabaseConnection() |
|
782 | + ); |
|
783 | + }); |
|
784 | + $this->registerAlias('MimeTypeLoader', \OCP\Files\IMimeTypeLoader::class); |
|
785 | + |
|
786 | + $this->registerService(\OCP\Notification\IManager::class, function (Server $c) { |
|
787 | + return new Manager( |
|
788 | + $c->query(IValidator::class) |
|
789 | + ); |
|
790 | + }); |
|
791 | + $this->registerAlias('NotificationManager', \OCP\Notification\IManager::class); |
|
792 | + |
|
793 | + $this->registerService(\OC\CapabilitiesManager::class, function (Server $c) { |
|
794 | + $manager = new \OC\CapabilitiesManager($c->getLogger()); |
|
795 | + $manager->registerCapability(function () use ($c) { |
|
796 | + return new \OC\OCS\CoreCapabilities($c->getConfig()); |
|
797 | + }); |
|
798 | + return $manager; |
|
799 | + }); |
|
800 | + $this->registerAlias('CapabilitiesManager', \OC\CapabilitiesManager::class); |
|
801 | + |
|
802 | + $this->registerService(\OCP\Comments\ICommentsManager::class, function(Server $c) { |
|
803 | + $config = $c->getConfig(); |
|
804 | + $factoryClass = $config->getSystemValue('comments.managerFactory', '\OC\Comments\ManagerFactory'); |
|
805 | + /** @var \OCP\Comments\ICommentsManagerFactory $factory */ |
|
806 | + $factory = new $factoryClass($this); |
|
807 | + return $factory->getManager(); |
|
808 | + }); |
|
809 | + $this->registerAlias('CommentsManager', \OCP\Comments\ICommentsManager::class); |
|
810 | + |
|
811 | + $this->registerService('ThemingDefaults', function(Server $c) { |
|
812 | + /* |
|
813 | 813 | * Dark magic for autoloader. |
814 | 814 | * If we do a class_exists it will try to load the class which will |
815 | 815 | * make composer cache the result. Resulting in errors when enabling |
816 | 816 | * the theming app. |
817 | 817 | */ |
818 | - $prefixes = \OC::$composerAutoloader->getPrefixesPsr4(); |
|
819 | - if (isset($prefixes['OCA\\Theming\\'])) { |
|
820 | - $classExists = true; |
|
821 | - } else { |
|
822 | - $classExists = false; |
|
823 | - } |
|
824 | - |
|
825 | - if ($classExists && $c->getConfig()->getSystemValue('installed', false) && $c->getAppManager()->isInstalled('theming')) { |
|
826 | - return new ThemingDefaults( |
|
827 | - $c->getConfig(), |
|
828 | - $c->getL10N('theming'), |
|
829 | - $c->getURLGenerator(), |
|
830 | - new \OC_Defaults(), |
|
831 | - $c->getLazyRootFolder(), |
|
832 | - $c->getMemCacheFactory() |
|
833 | - ); |
|
834 | - } |
|
835 | - return new \OC_Defaults(); |
|
836 | - }); |
|
837 | - $this->registerService(EventDispatcher::class, function () { |
|
838 | - return new EventDispatcher(); |
|
839 | - }); |
|
840 | - $this->registerAlias('EventDispatcher', EventDispatcher::class); |
|
841 | - $this->registerAlias(EventDispatcherInterface::class, EventDispatcher::class); |
|
842 | - |
|
843 | - $this->registerService('CryptoWrapper', function (Server $c) { |
|
844 | - // FIXME: Instantiiated here due to cyclic dependency |
|
845 | - $request = new Request( |
|
846 | - [ |
|
847 | - 'get' => $_GET, |
|
848 | - 'post' => $_POST, |
|
849 | - 'files' => $_FILES, |
|
850 | - 'server' => $_SERVER, |
|
851 | - 'env' => $_ENV, |
|
852 | - 'cookies' => $_COOKIE, |
|
853 | - 'method' => (isset($_SERVER) && isset($_SERVER['REQUEST_METHOD'])) |
|
854 | - ? $_SERVER['REQUEST_METHOD'] |
|
855 | - : null, |
|
856 | - ], |
|
857 | - $c->getSecureRandom(), |
|
858 | - $c->getConfig() |
|
859 | - ); |
|
860 | - |
|
861 | - return new CryptoWrapper( |
|
862 | - $c->getConfig(), |
|
863 | - $c->getCrypto(), |
|
864 | - $c->getSecureRandom(), |
|
865 | - $request |
|
866 | - ); |
|
867 | - }); |
|
868 | - $this->registerService('CsrfTokenManager', function (Server $c) { |
|
869 | - $tokenGenerator = new CsrfTokenGenerator($c->getSecureRandom()); |
|
870 | - |
|
871 | - return new CsrfTokenManager( |
|
872 | - $tokenGenerator, |
|
873 | - $c->query(SessionStorage::class) |
|
874 | - ); |
|
875 | - }); |
|
876 | - $this->registerService(SessionStorage::class, function (Server $c) { |
|
877 | - return new SessionStorage($c->getSession()); |
|
878 | - }); |
|
879 | - $this->registerService(\OCP\Security\IContentSecurityPolicyManager::class, function (Server $c) { |
|
880 | - return new ContentSecurityPolicyManager(); |
|
881 | - }); |
|
882 | - $this->registerAlias('ContentSecurityPolicyManager', \OCP\Security\IContentSecurityPolicyManager::class); |
|
883 | - |
|
884 | - $this->registerService('ContentSecurityPolicyNonceManager', function(Server $c) { |
|
885 | - return new ContentSecurityPolicyNonceManager( |
|
886 | - $c->getCsrfTokenManager(), |
|
887 | - $c->getRequest() |
|
888 | - ); |
|
889 | - }); |
|
890 | - |
|
891 | - $this->registerService(\OCP\Share\IManager::class, function(Server $c) { |
|
892 | - $config = $c->getConfig(); |
|
893 | - $factoryClass = $config->getSystemValue('sharing.managerFactory', '\OC\Share20\ProviderFactory'); |
|
894 | - /** @var \OCP\Share\IProviderFactory $factory */ |
|
895 | - $factory = new $factoryClass($this); |
|
896 | - |
|
897 | - $manager = new \OC\Share20\Manager( |
|
898 | - $c->getLogger(), |
|
899 | - $c->getConfig(), |
|
900 | - $c->getSecureRandom(), |
|
901 | - $c->getHasher(), |
|
902 | - $c->getMountManager(), |
|
903 | - $c->getGroupManager(), |
|
904 | - $c->getL10N('core'), |
|
905 | - $factory, |
|
906 | - $c->getUserManager(), |
|
907 | - $c->getLazyRootFolder(), |
|
908 | - $c->getEventDispatcher() |
|
909 | - ); |
|
910 | - |
|
911 | - return $manager; |
|
912 | - }); |
|
913 | - $this->registerAlias('ShareManager', \OCP\Share\IManager::class); |
|
914 | - |
|
915 | - $this->registerService('SettingsManager', function(Server $c) { |
|
916 | - $manager = new \OC\Settings\Manager( |
|
917 | - $c->getLogger(), |
|
918 | - $c->getDatabaseConnection(), |
|
919 | - $c->getL10N('lib'), |
|
920 | - $c->getConfig(), |
|
921 | - $c->getEncryptionManager(), |
|
922 | - $c->getUserManager(), |
|
923 | - $c->getLockingProvider(), |
|
924 | - $c->getRequest(), |
|
925 | - new \OC\Settings\Mapper($c->getDatabaseConnection()), |
|
926 | - $c->getURLGenerator() |
|
927 | - ); |
|
928 | - return $manager; |
|
929 | - }); |
|
930 | - $this->registerService(\OC\Files\AppData\Factory::class, function (Server $c) { |
|
931 | - return new \OC\Files\AppData\Factory( |
|
932 | - $c->getRootFolder(), |
|
933 | - $c->getSystemConfig() |
|
934 | - ); |
|
935 | - }); |
|
936 | - |
|
937 | - $this->registerService('LockdownManager', function (Server $c) { |
|
938 | - return new LockdownManager(); |
|
939 | - }); |
|
940 | - |
|
941 | - $this->registerService(ICloudIdManager::class, function (Server $c) { |
|
942 | - return new CloudIdManager(); |
|
943 | - }); |
|
944 | - |
|
945 | - /* To trick DI since we don't extend the DIContainer here */ |
|
946 | - $this->registerService(CleanPreviewsBackgroundJob::class, function (Server $c) { |
|
947 | - return new CleanPreviewsBackgroundJob( |
|
948 | - $c->getRootFolder(), |
|
949 | - $c->getLogger(), |
|
950 | - $c->getJobList(), |
|
951 | - new TimeFactory() |
|
952 | - ); |
|
953 | - }); |
|
954 | - |
|
955 | - $this->registerAlias(\OCP\AppFramework\Utility\IControllerMethodReflector::class, \OC\AppFramework\Utility\ControllerMethodReflector::class); |
|
956 | - $this->registerAlias('ControllerMethodReflector', \OCP\AppFramework\Utility\IControllerMethodReflector::class); |
|
957 | - |
|
958 | - $this->registerAlias(\OCP\AppFramework\Utility\ITimeFactory::class, \OC\AppFramework\Utility\TimeFactory::class); |
|
959 | - $this->registerAlias('TimeFactory', \OCP\AppFramework\Utility\ITimeFactory::class); |
|
960 | - |
|
961 | - $this->registerService(\OCP\ISession::class, function(SimpleContainer $c) { |
|
962 | - return $c->query(\OCP\IUserSession::class)->getSession(); |
|
963 | - }); |
|
964 | - } |
|
965 | - |
|
966 | - /** |
|
967 | - * @return \OCP\Contacts\IManager |
|
968 | - */ |
|
969 | - public function getContactsManager() { |
|
970 | - return $this->query('ContactsManager'); |
|
971 | - } |
|
972 | - |
|
973 | - /** |
|
974 | - * @return \OC\Encryption\Manager |
|
975 | - */ |
|
976 | - public function getEncryptionManager() { |
|
977 | - return $this->query('EncryptionManager'); |
|
978 | - } |
|
979 | - |
|
980 | - /** |
|
981 | - * @return \OC\Encryption\File |
|
982 | - */ |
|
983 | - public function getEncryptionFilesHelper() { |
|
984 | - return $this->query('EncryptionFileHelper'); |
|
985 | - } |
|
986 | - |
|
987 | - /** |
|
988 | - * @return \OCP\Encryption\Keys\IStorage |
|
989 | - */ |
|
990 | - public function getEncryptionKeyStorage() { |
|
991 | - return $this->query('EncryptionKeyStorage'); |
|
992 | - } |
|
993 | - |
|
994 | - /** |
|
995 | - * The current request object holding all information about the request |
|
996 | - * currently being processed is returned from this method. |
|
997 | - * In case the current execution was not initiated by a web request null is returned |
|
998 | - * |
|
999 | - * @return \OCP\IRequest |
|
1000 | - */ |
|
1001 | - public function getRequest() { |
|
1002 | - return $this->query('Request'); |
|
1003 | - } |
|
1004 | - |
|
1005 | - /** |
|
1006 | - * Returns the preview manager which can create preview images for a given file |
|
1007 | - * |
|
1008 | - * @return \OCP\IPreview |
|
1009 | - */ |
|
1010 | - public function getPreviewManager() { |
|
1011 | - return $this->query('PreviewManager'); |
|
1012 | - } |
|
1013 | - |
|
1014 | - /** |
|
1015 | - * Returns the tag manager which can get and set tags for different object types |
|
1016 | - * |
|
1017 | - * @see \OCP\ITagManager::load() |
|
1018 | - * @return \OCP\ITagManager |
|
1019 | - */ |
|
1020 | - public function getTagManager() { |
|
1021 | - return $this->query('TagManager'); |
|
1022 | - } |
|
1023 | - |
|
1024 | - /** |
|
1025 | - * Returns the system-tag manager |
|
1026 | - * |
|
1027 | - * @return \OCP\SystemTag\ISystemTagManager |
|
1028 | - * |
|
1029 | - * @since 9.0.0 |
|
1030 | - */ |
|
1031 | - public function getSystemTagManager() { |
|
1032 | - return $this->query('SystemTagManager'); |
|
1033 | - } |
|
1034 | - |
|
1035 | - /** |
|
1036 | - * Returns the system-tag object mapper |
|
1037 | - * |
|
1038 | - * @return \OCP\SystemTag\ISystemTagObjectMapper |
|
1039 | - * |
|
1040 | - * @since 9.0.0 |
|
1041 | - */ |
|
1042 | - public function getSystemTagObjectMapper() { |
|
1043 | - return $this->query('SystemTagObjectMapper'); |
|
1044 | - } |
|
1045 | - |
|
1046 | - /** |
|
1047 | - * Returns the avatar manager, used for avatar functionality |
|
1048 | - * |
|
1049 | - * @return \OCP\IAvatarManager |
|
1050 | - */ |
|
1051 | - public function getAvatarManager() { |
|
1052 | - return $this->query('AvatarManager'); |
|
1053 | - } |
|
1054 | - |
|
1055 | - /** |
|
1056 | - * Returns the root folder of ownCloud's data directory |
|
1057 | - * |
|
1058 | - * @return \OCP\Files\IRootFolder |
|
1059 | - */ |
|
1060 | - public function getRootFolder() { |
|
1061 | - return $this->query('LazyRootFolder'); |
|
1062 | - } |
|
1063 | - |
|
1064 | - /** |
|
1065 | - * Returns the root folder of ownCloud's data directory |
|
1066 | - * This is the lazy variant so this gets only initialized once it |
|
1067 | - * is actually used. |
|
1068 | - * |
|
1069 | - * @return \OCP\Files\IRootFolder |
|
1070 | - */ |
|
1071 | - public function getLazyRootFolder() { |
|
1072 | - return $this->query('LazyRootFolder'); |
|
1073 | - } |
|
1074 | - |
|
1075 | - /** |
|
1076 | - * Returns a view to ownCloud's files folder |
|
1077 | - * |
|
1078 | - * @param string $userId user ID |
|
1079 | - * @return \OCP\Files\Folder|null |
|
1080 | - */ |
|
1081 | - public function getUserFolder($userId = null) { |
|
1082 | - if ($userId === null) { |
|
1083 | - $user = $this->getUserSession()->getUser(); |
|
1084 | - if (!$user) { |
|
1085 | - return null; |
|
1086 | - } |
|
1087 | - $userId = $user->getUID(); |
|
1088 | - } |
|
1089 | - $root = $this->getRootFolder(); |
|
1090 | - return $root->getUserFolder($userId); |
|
1091 | - } |
|
1092 | - |
|
1093 | - /** |
|
1094 | - * Returns an app-specific view in ownClouds data directory |
|
1095 | - * |
|
1096 | - * @return \OCP\Files\Folder |
|
1097 | - * @deprecated since 9.2.0 use IAppData |
|
1098 | - */ |
|
1099 | - public function getAppFolder() { |
|
1100 | - $dir = '/' . \OC_App::getCurrentApp(); |
|
1101 | - $root = $this->getRootFolder(); |
|
1102 | - if (!$root->nodeExists($dir)) { |
|
1103 | - $folder = $root->newFolder($dir); |
|
1104 | - } else { |
|
1105 | - $folder = $root->get($dir); |
|
1106 | - } |
|
1107 | - return $folder; |
|
1108 | - } |
|
1109 | - |
|
1110 | - /** |
|
1111 | - * @return \OC\User\Manager |
|
1112 | - */ |
|
1113 | - public function getUserManager() { |
|
1114 | - return $this->query('UserManager'); |
|
1115 | - } |
|
1116 | - |
|
1117 | - /** |
|
1118 | - * @return \OC\Group\Manager |
|
1119 | - */ |
|
1120 | - public function getGroupManager() { |
|
1121 | - return $this->query('GroupManager'); |
|
1122 | - } |
|
1123 | - |
|
1124 | - /** |
|
1125 | - * @return \OC\User\Session |
|
1126 | - */ |
|
1127 | - public function getUserSession() { |
|
1128 | - return $this->query('UserSession'); |
|
1129 | - } |
|
1130 | - |
|
1131 | - /** |
|
1132 | - * @return \OCP\ISession |
|
1133 | - */ |
|
1134 | - public function getSession() { |
|
1135 | - return $this->query('UserSession')->getSession(); |
|
1136 | - } |
|
1137 | - |
|
1138 | - /** |
|
1139 | - * @param \OCP\ISession $session |
|
1140 | - */ |
|
1141 | - public function setSession(\OCP\ISession $session) { |
|
1142 | - $this->query(SessionStorage::class)->setSession($session); |
|
1143 | - $this->query('UserSession')->setSession($session); |
|
1144 | - $this->query(Store::class)->setSession($session); |
|
1145 | - } |
|
1146 | - |
|
1147 | - /** |
|
1148 | - * @return \OC\Authentication\TwoFactorAuth\Manager |
|
1149 | - */ |
|
1150 | - public function getTwoFactorAuthManager() { |
|
1151 | - return $this->query('\OC\Authentication\TwoFactorAuth\Manager'); |
|
1152 | - } |
|
1153 | - |
|
1154 | - /** |
|
1155 | - * @return \OC\NavigationManager |
|
1156 | - */ |
|
1157 | - public function getNavigationManager() { |
|
1158 | - return $this->query('NavigationManager'); |
|
1159 | - } |
|
1160 | - |
|
1161 | - /** |
|
1162 | - * @return \OCP\IConfig |
|
1163 | - */ |
|
1164 | - public function getConfig() { |
|
1165 | - return $this->query('AllConfig'); |
|
1166 | - } |
|
1167 | - |
|
1168 | - /** |
|
1169 | - * @internal For internal use only |
|
1170 | - * @return \OC\SystemConfig |
|
1171 | - */ |
|
1172 | - public function getSystemConfig() { |
|
1173 | - return $this->query('SystemConfig'); |
|
1174 | - } |
|
1175 | - |
|
1176 | - /** |
|
1177 | - * Returns the app config manager |
|
1178 | - * |
|
1179 | - * @return \OCP\IAppConfig |
|
1180 | - */ |
|
1181 | - public function getAppConfig() { |
|
1182 | - return $this->query('AppConfig'); |
|
1183 | - } |
|
1184 | - |
|
1185 | - /** |
|
1186 | - * @return \OCP\L10N\IFactory |
|
1187 | - */ |
|
1188 | - public function getL10NFactory() { |
|
1189 | - return $this->query('L10NFactory'); |
|
1190 | - } |
|
1191 | - |
|
1192 | - /** |
|
1193 | - * get an L10N instance |
|
1194 | - * |
|
1195 | - * @param string $app appid |
|
1196 | - * @param string $lang |
|
1197 | - * @return IL10N |
|
1198 | - */ |
|
1199 | - public function getL10N($app, $lang = null) { |
|
1200 | - return $this->getL10NFactory()->get($app, $lang); |
|
1201 | - } |
|
1202 | - |
|
1203 | - /** |
|
1204 | - * @return \OCP\IURLGenerator |
|
1205 | - */ |
|
1206 | - public function getURLGenerator() { |
|
1207 | - return $this->query('URLGenerator'); |
|
1208 | - } |
|
1209 | - |
|
1210 | - /** |
|
1211 | - * @return \OCP\IHelper |
|
1212 | - */ |
|
1213 | - public function getHelper() { |
|
1214 | - return $this->query('AppHelper'); |
|
1215 | - } |
|
1216 | - |
|
1217 | - /** |
|
1218 | - * @return AppFetcher |
|
1219 | - */ |
|
1220 | - public function getAppFetcher() { |
|
1221 | - return $this->query('AppFetcher'); |
|
1222 | - } |
|
1223 | - |
|
1224 | - /** |
|
1225 | - * Returns an ICache instance. Since 8.1.0 it returns a fake cache. Use |
|
1226 | - * getMemCacheFactory() instead. |
|
1227 | - * |
|
1228 | - * @return \OCP\ICache |
|
1229 | - * @deprecated 8.1.0 use getMemCacheFactory to obtain a proper cache |
|
1230 | - */ |
|
1231 | - public function getCache() { |
|
1232 | - return $this->query('UserCache'); |
|
1233 | - } |
|
1234 | - |
|
1235 | - /** |
|
1236 | - * Returns an \OCP\CacheFactory instance |
|
1237 | - * |
|
1238 | - * @return \OCP\ICacheFactory |
|
1239 | - */ |
|
1240 | - public function getMemCacheFactory() { |
|
1241 | - return $this->query('MemCacheFactory'); |
|
1242 | - } |
|
1243 | - |
|
1244 | - /** |
|
1245 | - * Returns an \OC\RedisFactory instance |
|
1246 | - * |
|
1247 | - * @return \OC\RedisFactory |
|
1248 | - */ |
|
1249 | - public function getGetRedisFactory() { |
|
1250 | - return $this->query('RedisFactory'); |
|
1251 | - } |
|
1252 | - |
|
1253 | - |
|
1254 | - /** |
|
1255 | - * Returns the current session |
|
1256 | - * |
|
1257 | - * @return \OCP\IDBConnection |
|
1258 | - */ |
|
1259 | - public function getDatabaseConnection() { |
|
1260 | - return $this->query('DatabaseConnection'); |
|
1261 | - } |
|
1262 | - |
|
1263 | - /** |
|
1264 | - * Returns the activity manager |
|
1265 | - * |
|
1266 | - * @return \OCP\Activity\IManager |
|
1267 | - */ |
|
1268 | - public function getActivityManager() { |
|
1269 | - return $this->query('ActivityManager'); |
|
1270 | - } |
|
1271 | - |
|
1272 | - /** |
|
1273 | - * Returns an job list for controlling background jobs |
|
1274 | - * |
|
1275 | - * @return \OCP\BackgroundJob\IJobList |
|
1276 | - */ |
|
1277 | - public function getJobList() { |
|
1278 | - return $this->query('JobList'); |
|
1279 | - } |
|
1280 | - |
|
1281 | - /** |
|
1282 | - * Returns a logger instance |
|
1283 | - * |
|
1284 | - * @return \OCP\ILogger |
|
1285 | - */ |
|
1286 | - public function getLogger() { |
|
1287 | - return $this->query('Logger'); |
|
1288 | - } |
|
1289 | - |
|
1290 | - /** |
|
1291 | - * Returns a router for generating and matching urls |
|
1292 | - * |
|
1293 | - * @return \OCP\Route\IRouter |
|
1294 | - */ |
|
1295 | - public function getRouter() { |
|
1296 | - return $this->query('Router'); |
|
1297 | - } |
|
1298 | - |
|
1299 | - /** |
|
1300 | - * Returns a search instance |
|
1301 | - * |
|
1302 | - * @return \OCP\ISearch |
|
1303 | - */ |
|
1304 | - public function getSearch() { |
|
1305 | - return $this->query('Search'); |
|
1306 | - } |
|
1307 | - |
|
1308 | - /** |
|
1309 | - * Returns a SecureRandom instance |
|
1310 | - * |
|
1311 | - * @return \OCP\Security\ISecureRandom |
|
1312 | - */ |
|
1313 | - public function getSecureRandom() { |
|
1314 | - return $this->query('SecureRandom'); |
|
1315 | - } |
|
1316 | - |
|
1317 | - /** |
|
1318 | - * Returns a Crypto instance |
|
1319 | - * |
|
1320 | - * @return \OCP\Security\ICrypto |
|
1321 | - */ |
|
1322 | - public function getCrypto() { |
|
1323 | - return $this->query('Crypto'); |
|
1324 | - } |
|
1325 | - |
|
1326 | - /** |
|
1327 | - * Returns a Hasher instance |
|
1328 | - * |
|
1329 | - * @return \OCP\Security\IHasher |
|
1330 | - */ |
|
1331 | - public function getHasher() { |
|
1332 | - return $this->query('Hasher'); |
|
1333 | - } |
|
1334 | - |
|
1335 | - /** |
|
1336 | - * Returns a CredentialsManager instance |
|
1337 | - * |
|
1338 | - * @return \OCP\Security\ICredentialsManager |
|
1339 | - */ |
|
1340 | - public function getCredentialsManager() { |
|
1341 | - return $this->query('CredentialsManager'); |
|
1342 | - } |
|
1343 | - |
|
1344 | - /** |
|
1345 | - * Returns an instance of the HTTP helper class |
|
1346 | - * |
|
1347 | - * @deprecated Use getHTTPClientService() |
|
1348 | - * @return \OC\HTTPHelper |
|
1349 | - */ |
|
1350 | - public function getHTTPHelper() { |
|
1351 | - return $this->query('HTTPHelper'); |
|
1352 | - } |
|
1353 | - |
|
1354 | - /** |
|
1355 | - * Get the certificate manager for the user |
|
1356 | - * |
|
1357 | - * @param string $userId (optional) if not specified the current loggedin user is used, use null to get the system certificate manager |
|
1358 | - * @return \OCP\ICertificateManager | null if $uid is null and no user is logged in |
|
1359 | - */ |
|
1360 | - public function getCertificateManager($userId = '') { |
|
1361 | - if ($userId === '') { |
|
1362 | - $userSession = $this->getUserSession(); |
|
1363 | - $user = $userSession->getUser(); |
|
1364 | - if (is_null($user)) { |
|
1365 | - return null; |
|
1366 | - } |
|
1367 | - $userId = $user->getUID(); |
|
1368 | - } |
|
1369 | - return new CertificateManager($userId, new View(), $this->getConfig(), $this->getLogger()); |
|
1370 | - } |
|
1371 | - |
|
1372 | - /** |
|
1373 | - * Returns an instance of the HTTP client service |
|
1374 | - * |
|
1375 | - * @return \OCP\Http\Client\IClientService |
|
1376 | - */ |
|
1377 | - public function getHTTPClientService() { |
|
1378 | - return $this->query('HttpClientService'); |
|
1379 | - } |
|
1380 | - |
|
1381 | - /** |
|
1382 | - * Create a new event source |
|
1383 | - * |
|
1384 | - * @return \OCP\IEventSource |
|
1385 | - */ |
|
1386 | - public function createEventSource() { |
|
1387 | - return new \OC_EventSource(); |
|
1388 | - } |
|
1389 | - |
|
1390 | - /** |
|
1391 | - * Get the active event logger |
|
1392 | - * |
|
1393 | - * The returned logger only logs data when debug mode is enabled |
|
1394 | - * |
|
1395 | - * @return \OCP\Diagnostics\IEventLogger |
|
1396 | - */ |
|
1397 | - public function getEventLogger() { |
|
1398 | - return $this->query('EventLogger'); |
|
1399 | - } |
|
1400 | - |
|
1401 | - /** |
|
1402 | - * Get the active query logger |
|
1403 | - * |
|
1404 | - * The returned logger only logs data when debug mode is enabled |
|
1405 | - * |
|
1406 | - * @return \OCP\Diagnostics\IQueryLogger |
|
1407 | - */ |
|
1408 | - public function getQueryLogger() { |
|
1409 | - return $this->query('QueryLogger'); |
|
1410 | - } |
|
1411 | - |
|
1412 | - /** |
|
1413 | - * Get the manager for temporary files and folders |
|
1414 | - * |
|
1415 | - * @return \OCP\ITempManager |
|
1416 | - */ |
|
1417 | - public function getTempManager() { |
|
1418 | - return $this->query('TempManager'); |
|
1419 | - } |
|
1420 | - |
|
1421 | - /** |
|
1422 | - * Get the app manager |
|
1423 | - * |
|
1424 | - * @return \OCP\App\IAppManager |
|
1425 | - */ |
|
1426 | - public function getAppManager() { |
|
1427 | - return $this->query('AppManager'); |
|
1428 | - } |
|
1429 | - |
|
1430 | - /** |
|
1431 | - * Creates a new mailer |
|
1432 | - * |
|
1433 | - * @return \OCP\Mail\IMailer |
|
1434 | - */ |
|
1435 | - public function getMailer() { |
|
1436 | - return $this->query('Mailer'); |
|
1437 | - } |
|
1438 | - |
|
1439 | - /** |
|
1440 | - * Get the webroot |
|
1441 | - * |
|
1442 | - * @return string |
|
1443 | - */ |
|
1444 | - public function getWebRoot() { |
|
1445 | - return $this->webRoot; |
|
1446 | - } |
|
1447 | - |
|
1448 | - /** |
|
1449 | - * @return \OC\OCSClient |
|
1450 | - */ |
|
1451 | - public function getOcsClient() { |
|
1452 | - return $this->query('OcsClient'); |
|
1453 | - } |
|
1454 | - |
|
1455 | - /** |
|
1456 | - * @return \OCP\IDateTimeZone |
|
1457 | - */ |
|
1458 | - public function getDateTimeZone() { |
|
1459 | - return $this->query('DateTimeZone'); |
|
1460 | - } |
|
1461 | - |
|
1462 | - /** |
|
1463 | - * @return \OCP\IDateTimeFormatter |
|
1464 | - */ |
|
1465 | - public function getDateTimeFormatter() { |
|
1466 | - return $this->query('DateTimeFormatter'); |
|
1467 | - } |
|
1468 | - |
|
1469 | - /** |
|
1470 | - * @return \OCP\Files\Config\IMountProviderCollection |
|
1471 | - */ |
|
1472 | - public function getMountProviderCollection() { |
|
1473 | - return $this->query('MountConfigManager'); |
|
1474 | - } |
|
1475 | - |
|
1476 | - /** |
|
1477 | - * Get the IniWrapper |
|
1478 | - * |
|
1479 | - * @return IniGetWrapper |
|
1480 | - */ |
|
1481 | - public function getIniWrapper() { |
|
1482 | - return $this->query('IniWrapper'); |
|
1483 | - } |
|
1484 | - |
|
1485 | - /** |
|
1486 | - * @return \OCP\Command\IBus |
|
1487 | - */ |
|
1488 | - public function getCommandBus() { |
|
1489 | - return $this->query('AsyncCommandBus'); |
|
1490 | - } |
|
1491 | - |
|
1492 | - /** |
|
1493 | - * Get the trusted domain helper |
|
1494 | - * |
|
1495 | - * @return TrustedDomainHelper |
|
1496 | - */ |
|
1497 | - public function getTrustedDomainHelper() { |
|
1498 | - return $this->query('TrustedDomainHelper'); |
|
1499 | - } |
|
1500 | - |
|
1501 | - /** |
|
1502 | - * Get the locking provider |
|
1503 | - * |
|
1504 | - * @return \OCP\Lock\ILockingProvider |
|
1505 | - * @since 8.1.0 |
|
1506 | - */ |
|
1507 | - public function getLockingProvider() { |
|
1508 | - return $this->query('LockingProvider'); |
|
1509 | - } |
|
1510 | - |
|
1511 | - /** |
|
1512 | - * @return \OCP\Files\Mount\IMountManager |
|
1513 | - **/ |
|
1514 | - function getMountManager() { |
|
1515 | - return $this->query('MountManager'); |
|
1516 | - } |
|
1517 | - |
|
1518 | - /** @return \OCP\Files\Config\IUserMountCache */ |
|
1519 | - function getUserMountCache() { |
|
1520 | - return $this->query('UserMountCache'); |
|
1521 | - } |
|
1522 | - |
|
1523 | - /** |
|
1524 | - * Get the MimeTypeDetector |
|
1525 | - * |
|
1526 | - * @return \OCP\Files\IMimeTypeDetector |
|
1527 | - */ |
|
1528 | - public function getMimeTypeDetector() { |
|
1529 | - return $this->query('MimeTypeDetector'); |
|
1530 | - } |
|
1531 | - |
|
1532 | - /** |
|
1533 | - * Get the MimeTypeLoader |
|
1534 | - * |
|
1535 | - * @return \OCP\Files\IMimeTypeLoader |
|
1536 | - */ |
|
1537 | - public function getMimeTypeLoader() { |
|
1538 | - return $this->query('MimeTypeLoader'); |
|
1539 | - } |
|
1540 | - |
|
1541 | - /** |
|
1542 | - * Get the manager of all the capabilities |
|
1543 | - * |
|
1544 | - * @return \OC\CapabilitiesManager |
|
1545 | - */ |
|
1546 | - public function getCapabilitiesManager() { |
|
1547 | - return $this->query('CapabilitiesManager'); |
|
1548 | - } |
|
1549 | - |
|
1550 | - /** |
|
1551 | - * Get the EventDispatcher |
|
1552 | - * |
|
1553 | - * @return EventDispatcherInterface |
|
1554 | - * @since 8.2.0 |
|
1555 | - */ |
|
1556 | - public function getEventDispatcher() { |
|
1557 | - return $this->query('EventDispatcher'); |
|
1558 | - } |
|
1559 | - |
|
1560 | - /** |
|
1561 | - * Get the Notification Manager |
|
1562 | - * |
|
1563 | - * @return \OCP\Notification\IManager |
|
1564 | - * @since 8.2.0 |
|
1565 | - */ |
|
1566 | - public function getNotificationManager() { |
|
1567 | - return $this->query('NotificationManager'); |
|
1568 | - } |
|
1569 | - |
|
1570 | - /** |
|
1571 | - * @return \OCP\Comments\ICommentsManager |
|
1572 | - */ |
|
1573 | - public function getCommentsManager() { |
|
1574 | - return $this->query('CommentsManager'); |
|
1575 | - } |
|
1576 | - |
|
1577 | - /** |
|
1578 | - * @return \OC_Defaults |
|
1579 | - */ |
|
1580 | - public function getThemingDefaults() { |
|
1581 | - return $this->query('ThemingDefaults'); |
|
1582 | - } |
|
1583 | - |
|
1584 | - /** |
|
1585 | - * @return \OC\IntegrityCheck\Checker |
|
1586 | - */ |
|
1587 | - public function getIntegrityCodeChecker() { |
|
1588 | - return $this->query('IntegrityCodeChecker'); |
|
1589 | - } |
|
1590 | - |
|
1591 | - /** |
|
1592 | - * @return \OC\Session\CryptoWrapper |
|
1593 | - */ |
|
1594 | - public function getSessionCryptoWrapper() { |
|
1595 | - return $this->query('CryptoWrapper'); |
|
1596 | - } |
|
1597 | - |
|
1598 | - /** |
|
1599 | - * @return CsrfTokenManager |
|
1600 | - */ |
|
1601 | - public function getCsrfTokenManager() { |
|
1602 | - return $this->query('CsrfTokenManager'); |
|
1603 | - } |
|
1604 | - |
|
1605 | - /** |
|
1606 | - * @return Throttler |
|
1607 | - */ |
|
1608 | - public function getBruteForceThrottler() { |
|
1609 | - return $this->query('Throttler'); |
|
1610 | - } |
|
1611 | - |
|
1612 | - /** |
|
1613 | - * @return IContentSecurityPolicyManager |
|
1614 | - */ |
|
1615 | - public function getContentSecurityPolicyManager() { |
|
1616 | - return $this->query('ContentSecurityPolicyManager'); |
|
1617 | - } |
|
1618 | - |
|
1619 | - /** |
|
1620 | - * @return ContentSecurityPolicyNonceManager |
|
1621 | - */ |
|
1622 | - public function getContentSecurityPolicyNonceManager() { |
|
1623 | - return $this->query('ContentSecurityPolicyNonceManager'); |
|
1624 | - } |
|
1625 | - |
|
1626 | - /** |
|
1627 | - * Not a public API as of 8.2, wait for 9.0 |
|
1628 | - * |
|
1629 | - * @return \OCA\Files_External\Service\BackendService |
|
1630 | - */ |
|
1631 | - public function getStoragesBackendService() { |
|
1632 | - return $this->query('OCA\\Files_External\\Service\\BackendService'); |
|
1633 | - } |
|
1634 | - |
|
1635 | - /** |
|
1636 | - * Not a public API as of 8.2, wait for 9.0 |
|
1637 | - * |
|
1638 | - * @return \OCA\Files_External\Service\GlobalStoragesService |
|
1639 | - */ |
|
1640 | - public function getGlobalStoragesService() { |
|
1641 | - return $this->query('OCA\\Files_External\\Service\\GlobalStoragesService'); |
|
1642 | - } |
|
1643 | - |
|
1644 | - /** |
|
1645 | - * Not a public API as of 8.2, wait for 9.0 |
|
1646 | - * |
|
1647 | - * @return \OCA\Files_External\Service\UserGlobalStoragesService |
|
1648 | - */ |
|
1649 | - public function getUserGlobalStoragesService() { |
|
1650 | - return $this->query('OCA\\Files_External\\Service\\UserGlobalStoragesService'); |
|
1651 | - } |
|
1652 | - |
|
1653 | - /** |
|
1654 | - * Not a public API as of 8.2, wait for 9.0 |
|
1655 | - * |
|
1656 | - * @return \OCA\Files_External\Service\UserStoragesService |
|
1657 | - */ |
|
1658 | - public function getUserStoragesService() { |
|
1659 | - return $this->query('OCA\\Files_External\\Service\\UserStoragesService'); |
|
1660 | - } |
|
1661 | - |
|
1662 | - /** |
|
1663 | - * @return \OCP\Share\IManager |
|
1664 | - */ |
|
1665 | - public function getShareManager() { |
|
1666 | - return $this->query('ShareManager'); |
|
1667 | - } |
|
1668 | - |
|
1669 | - /** |
|
1670 | - * Returns the LDAP Provider |
|
1671 | - * |
|
1672 | - * @return \OCP\LDAP\ILDAPProvider |
|
1673 | - */ |
|
1674 | - public function getLDAPProvider() { |
|
1675 | - return $this->query('LDAPProvider'); |
|
1676 | - } |
|
1677 | - |
|
1678 | - /** |
|
1679 | - * @return \OCP\Settings\IManager |
|
1680 | - */ |
|
1681 | - public function getSettingsManager() { |
|
1682 | - return $this->query('SettingsManager'); |
|
1683 | - } |
|
1684 | - |
|
1685 | - /** |
|
1686 | - * @return \OCP\Files\IAppData |
|
1687 | - */ |
|
1688 | - public function getAppDataDir($app) { |
|
1689 | - /** @var \OC\Files\AppData\Factory $factory */ |
|
1690 | - $factory = $this->query(\OC\Files\AppData\Factory::class); |
|
1691 | - return $factory->get($app); |
|
1692 | - } |
|
1693 | - |
|
1694 | - /** |
|
1695 | - * @return \OCP\Lockdown\ILockdownManager |
|
1696 | - */ |
|
1697 | - public function getLockdownManager() { |
|
1698 | - return $this->query('LockdownManager'); |
|
1699 | - } |
|
1700 | - |
|
1701 | - /** |
|
1702 | - * @return \OCP\Federation\ICloudIdManager |
|
1703 | - */ |
|
1704 | - public function getCloudIdManager() { |
|
1705 | - return $this->query(ICloudIdManager::class); |
|
1706 | - } |
|
818 | + $prefixes = \OC::$composerAutoloader->getPrefixesPsr4(); |
|
819 | + if (isset($prefixes['OCA\\Theming\\'])) { |
|
820 | + $classExists = true; |
|
821 | + } else { |
|
822 | + $classExists = false; |
|
823 | + } |
|
824 | + |
|
825 | + if ($classExists && $c->getConfig()->getSystemValue('installed', false) && $c->getAppManager()->isInstalled('theming')) { |
|
826 | + return new ThemingDefaults( |
|
827 | + $c->getConfig(), |
|
828 | + $c->getL10N('theming'), |
|
829 | + $c->getURLGenerator(), |
|
830 | + new \OC_Defaults(), |
|
831 | + $c->getLazyRootFolder(), |
|
832 | + $c->getMemCacheFactory() |
|
833 | + ); |
|
834 | + } |
|
835 | + return new \OC_Defaults(); |
|
836 | + }); |
|
837 | + $this->registerService(EventDispatcher::class, function () { |
|
838 | + return new EventDispatcher(); |
|
839 | + }); |
|
840 | + $this->registerAlias('EventDispatcher', EventDispatcher::class); |
|
841 | + $this->registerAlias(EventDispatcherInterface::class, EventDispatcher::class); |
|
842 | + |
|
843 | + $this->registerService('CryptoWrapper', function (Server $c) { |
|
844 | + // FIXME: Instantiiated here due to cyclic dependency |
|
845 | + $request = new Request( |
|
846 | + [ |
|
847 | + 'get' => $_GET, |
|
848 | + 'post' => $_POST, |
|
849 | + 'files' => $_FILES, |
|
850 | + 'server' => $_SERVER, |
|
851 | + 'env' => $_ENV, |
|
852 | + 'cookies' => $_COOKIE, |
|
853 | + 'method' => (isset($_SERVER) && isset($_SERVER['REQUEST_METHOD'])) |
|
854 | + ? $_SERVER['REQUEST_METHOD'] |
|
855 | + : null, |
|
856 | + ], |
|
857 | + $c->getSecureRandom(), |
|
858 | + $c->getConfig() |
|
859 | + ); |
|
860 | + |
|
861 | + return new CryptoWrapper( |
|
862 | + $c->getConfig(), |
|
863 | + $c->getCrypto(), |
|
864 | + $c->getSecureRandom(), |
|
865 | + $request |
|
866 | + ); |
|
867 | + }); |
|
868 | + $this->registerService('CsrfTokenManager', function (Server $c) { |
|
869 | + $tokenGenerator = new CsrfTokenGenerator($c->getSecureRandom()); |
|
870 | + |
|
871 | + return new CsrfTokenManager( |
|
872 | + $tokenGenerator, |
|
873 | + $c->query(SessionStorage::class) |
|
874 | + ); |
|
875 | + }); |
|
876 | + $this->registerService(SessionStorage::class, function (Server $c) { |
|
877 | + return new SessionStorage($c->getSession()); |
|
878 | + }); |
|
879 | + $this->registerService(\OCP\Security\IContentSecurityPolicyManager::class, function (Server $c) { |
|
880 | + return new ContentSecurityPolicyManager(); |
|
881 | + }); |
|
882 | + $this->registerAlias('ContentSecurityPolicyManager', \OCP\Security\IContentSecurityPolicyManager::class); |
|
883 | + |
|
884 | + $this->registerService('ContentSecurityPolicyNonceManager', function(Server $c) { |
|
885 | + return new ContentSecurityPolicyNonceManager( |
|
886 | + $c->getCsrfTokenManager(), |
|
887 | + $c->getRequest() |
|
888 | + ); |
|
889 | + }); |
|
890 | + |
|
891 | + $this->registerService(\OCP\Share\IManager::class, function(Server $c) { |
|
892 | + $config = $c->getConfig(); |
|
893 | + $factoryClass = $config->getSystemValue('sharing.managerFactory', '\OC\Share20\ProviderFactory'); |
|
894 | + /** @var \OCP\Share\IProviderFactory $factory */ |
|
895 | + $factory = new $factoryClass($this); |
|
896 | + |
|
897 | + $manager = new \OC\Share20\Manager( |
|
898 | + $c->getLogger(), |
|
899 | + $c->getConfig(), |
|
900 | + $c->getSecureRandom(), |
|
901 | + $c->getHasher(), |
|
902 | + $c->getMountManager(), |
|
903 | + $c->getGroupManager(), |
|
904 | + $c->getL10N('core'), |
|
905 | + $factory, |
|
906 | + $c->getUserManager(), |
|
907 | + $c->getLazyRootFolder(), |
|
908 | + $c->getEventDispatcher() |
|
909 | + ); |
|
910 | + |
|
911 | + return $manager; |
|
912 | + }); |
|
913 | + $this->registerAlias('ShareManager', \OCP\Share\IManager::class); |
|
914 | + |
|
915 | + $this->registerService('SettingsManager', function(Server $c) { |
|
916 | + $manager = new \OC\Settings\Manager( |
|
917 | + $c->getLogger(), |
|
918 | + $c->getDatabaseConnection(), |
|
919 | + $c->getL10N('lib'), |
|
920 | + $c->getConfig(), |
|
921 | + $c->getEncryptionManager(), |
|
922 | + $c->getUserManager(), |
|
923 | + $c->getLockingProvider(), |
|
924 | + $c->getRequest(), |
|
925 | + new \OC\Settings\Mapper($c->getDatabaseConnection()), |
|
926 | + $c->getURLGenerator() |
|
927 | + ); |
|
928 | + return $manager; |
|
929 | + }); |
|
930 | + $this->registerService(\OC\Files\AppData\Factory::class, function (Server $c) { |
|
931 | + return new \OC\Files\AppData\Factory( |
|
932 | + $c->getRootFolder(), |
|
933 | + $c->getSystemConfig() |
|
934 | + ); |
|
935 | + }); |
|
936 | + |
|
937 | + $this->registerService('LockdownManager', function (Server $c) { |
|
938 | + return new LockdownManager(); |
|
939 | + }); |
|
940 | + |
|
941 | + $this->registerService(ICloudIdManager::class, function (Server $c) { |
|
942 | + return new CloudIdManager(); |
|
943 | + }); |
|
944 | + |
|
945 | + /* To trick DI since we don't extend the DIContainer here */ |
|
946 | + $this->registerService(CleanPreviewsBackgroundJob::class, function (Server $c) { |
|
947 | + return new CleanPreviewsBackgroundJob( |
|
948 | + $c->getRootFolder(), |
|
949 | + $c->getLogger(), |
|
950 | + $c->getJobList(), |
|
951 | + new TimeFactory() |
|
952 | + ); |
|
953 | + }); |
|
954 | + |
|
955 | + $this->registerAlias(\OCP\AppFramework\Utility\IControllerMethodReflector::class, \OC\AppFramework\Utility\ControllerMethodReflector::class); |
|
956 | + $this->registerAlias('ControllerMethodReflector', \OCP\AppFramework\Utility\IControllerMethodReflector::class); |
|
957 | + |
|
958 | + $this->registerAlias(\OCP\AppFramework\Utility\ITimeFactory::class, \OC\AppFramework\Utility\TimeFactory::class); |
|
959 | + $this->registerAlias('TimeFactory', \OCP\AppFramework\Utility\ITimeFactory::class); |
|
960 | + |
|
961 | + $this->registerService(\OCP\ISession::class, function(SimpleContainer $c) { |
|
962 | + return $c->query(\OCP\IUserSession::class)->getSession(); |
|
963 | + }); |
|
964 | + } |
|
965 | + |
|
966 | + /** |
|
967 | + * @return \OCP\Contacts\IManager |
|
968 | + */ |
|
969 | + public function getContactsManager() { |
|
970 | + return $this->query('ContactsManager'); |
|
971 | + } |
|
972 | + |
|
973 | + /** |
|
974 | + * @return \OC\Encryption\Manager |
|
975 | + */ |
|
976 | + public function getEncryptionManager() { |
|
977 | + return $this->query('EncryptionManager'); |
|
978 | + } |
|
979 | + |
|
980 | + /** |
|
981 | + * @return \OC\Encryption\File |
|
982 | + */ |
|
983 | + public function getEncryptionFilesHelper() { |
|
984 | + return $this->query('EncryptionFileHelper'); |
|
985 | + } |
|
986 | + |
|
987 | + /** |
|
988 | + * @return \OCP\Encryption\Keys\IStorage |
|
989 | + */ |
|
990 | + public function getEncryptionKeyStorage() { |
|
991 | + return $this->query('EncryptionKeyStorage'); |
|
992 | + } |
|
993 | + |
|
994 | + /** |
|
995 | + * The current request object holding all information about the request |
|
996 | + * currently being processed is returned from this method. |
|
997 | + * In case the current execution was not initiated by a web request null is returned |
|
998 | + * |
|
999 | + * @return \OCP\IRequest |
|
1000 | + */ |
|
1001 | + public function getRequest() { |
|
1002 | + return $this->query('Request'); |
|
1003 | + } |
|
1004 | + |
|
1005 | + /** |
|
1006 | + * Returns the preview manager which can create preview images for a given file |
|
1007 | + * |
|
1008 | + * @return \OCP\IPreview |
|
1009 | + */ |
|
1010 | + public function getPreviewManager() { |
|
1011 | + return $this->query('PreviewManager'); |
|
1012 | + } |
|
1013 | + |
|
1014 | + /** |
|
1015 | + * Returns the tag manager which can get and set tags for different object types |
|
1016 | + * |
|
1017 | + * @see \OCP\ITagManager::load() |
|
1018 | + * @return \OCP\ITagManager |
|
1019 | + */ |
|
1020 | + public function getTagManager() { |
|
1021 | + return $this->query('TagManager'); |
|
1022 | + } |
|
1023 | + |
|
1024 | + /** |
|
1025 | + * Returns the system-tag manager |
|
1026 | + * |
|
1027 | + * @return \OCP\SystemTag\ISystemTagManager |
|
1028 | + * |
|
1029 | + * @since 9.0.0 |
|
1030 | + */ |
|
1031 | + public function getSystemTagManager() { |
|
1032 | + return $this->query('SystemTagManager'); |
|
1033 | + } |
|
1034 | + |
|
1035 | + /** |
|
1036 | + * Returns the system-tag object mapper |
|
1037 | + * |
|
1038 | + * @return \OCP\SystemTag\ISystemTagObjectMapper |
|
1039 | + * |
|
1040 | + * @since 9.0.0 |
|
1041 | + */ |
|
1042 | + public function getSystemTagObjectMapper() { |
|
1043 | + return $this->query('SystemTagObjectMapper'); |
|
1044 | + } |
|
1045 | + |
|
1046 | + /** |
|
1047 | + * Returns the avatar manager, used for avatar functionality |
|
1048 | + * |
|
1049 | + * @return \OCP\IAvatarManager |
|
1050 | + */ |
|
1051 | + public function getAvatarManager() { |
|
1052 | + return $this->query('AvatarManager'); |
|
1053 | + } |
|
1054 | + |
|
1055 | + /** |
|
1056 | + * Returns the root folder of ownCloud's data directory |
|
1057 | + * |
|
1058 | + * @return \OCP\Files\IRootFolder |
|
1059 | + */ |
|
1060 | + public function getRootFolder() { |
|
1061 | + return $this->query('LazyRootFolder'); |
|
1062 | + } |
|
1063 | + |
|
1064 | + /** |
|
1065 | + * Returns the root folder of ownCloud's data directory |
|
1066 | + * This is the lazy variant so this gets only initialized once it |
|
1067 | + * is actually used. |
|
1068 | + * |
|
1069 | + * @return \OCP\Files\IRootFolder |
|
1070 | + */ |
|
1071 | + public function getLazyRootFolder() { |
|
1072 | + return $this->query('LazyRootFolder'); |
|
1073 | + } |
|
1074 | + |
|
1075 | + /** |
|
1076 | + * Returns a view to ownCloud's files folder |
|
1077 | + * |
|
1078 | + * @param string $userId user ID |
|
1079 | + * @return \OCP\Files\Folder|null |
|
1080 | + */ |
|
1081 | + public function getUserFolder($userId = null) { |
|
1082 | + if ($userId === null) { |
|
1083 | + $user = $this->getUserSession()->getUser(); |
|
1084 | + if (!$user) { |
|
1085 | + return null; |
|
1086 | + } |
|
1087 | + $userId = $user->getUID(); |
|
1088 | + } |
|
1089 | + $root = $this->getRootFolder(); |
|
1090 | + return $root->getUserFolder($userId); |
|
1091 | + } |
|
1092 | + |
|
1093 | + /** |
|
1094 | + * Returns an app-specific view in ownClouds data directory |
|
1095 | + * |
|
1096 | + * @return \OCP\Files\Folder |
|
1097 | + * @deprecated since 9.2.0 use IAppData |
|
1098 | + */ |
|
1099 | + public function getAppFolder() { |
|
1100 | + $dir = '/' . \OC_App::getCurrentApp(); |
|
1101 | + $root = $this->getRootFolder(); |
|
1102 | + if (!$root->nodeExists($dir)) { |
|
1103 | + $folder = $root->newFolder($dir); |
|
1104 | + } else { |
|
1105 | + $folder = $root->get($dir); |
|
1106 | + } |
|
1107 | + return $folder; |
|
1108 | + } |
|
1109 | + |
|
1110 | + /** |
|
1111 | + * @return \OC\User\Manager |
|
1112 | + */ |
|
1113 | + public function getUserManager() { |
|
1114 | + return $this->query('UserManager'); |
|
1115 | + } |
|
1116 | + |
|
1117 | + /** |
|
1118 | + * @return \OC\Group\Manager |
|
1119 | + */ |
|
1120 | + public function getGroupManager() { |
|
1121 | + return $this->query('GroupManager'); |
|
1122 | + } |
|
1123 | + |
|
1124 | + /** |
|
1125 | + * @return \OC\User\Session |
|
1126 | + */ |
|
1127 | + public function getUserSession() { |
|
1128 | + return $this->query('UserSession'); |
|
1129 | + } |
|
1130 | + |
|
1131 | + /** |
|
1132 | + * @return \OCP\ISession |
|
1133 | + */ |
|
1134 | + public function getSession() { |
|
1135 | + return $this->query('UserSession')->getSession(); |
|
1136 | + } |
|
1137 | + |
|
1138 | + /** |
|
1139 | + * @param \OCP\ISession $session |
|
1140 | + */ |
|
1141 | + public function setSession(\OCP\ISession $session) { |
|
1142 | + $this->query(SessionStorage::class)->setSession($session); |
|
1143 | + $this->query('UserSession')->setSession($session); |
|
1144 | + $this->query(Store::class)->setSession($session); |
|
1145 | + } |
|
1146 | + |
|
1147 | + /** |
|
1148 | + * @return \OC\Authentication\TwoFactorAuth\Manager |
|
1149 | + */ |
|
1150 | + public function getTwoFactorAuthManager() { |
|
1151 | + return $this->query('\OC\Authentication\TwoFactorAuth\Manager'); |
|
1152 | + } |
|
1153 | + |
|
1154 | + /** |
|
1155 | + * @return \OC\NavigationManager |
|
1156 | + */ |
|
1157 | + public function getNavigationManager() { |
|
1158 | + return $this->query('NavigationManager'); |
|
1159 | + } |
|
1160 | + |
|
1161 | + /** |
|
1162 | + * @return \OCP\IConfig |
|
1163 | + */ |
|
1164 | + public function getConfig() { |
|
1165 | + return $this->query('AllConfig'); |
|
1166 | + } |
|
1167 | + |
|
1168 | + /** |
|
1169 | + * @internal For internal use only |
|
1170 | + * @return \OC\SystemConfig |
|
1171 | + */ |
|
1172 | + public function getSystemConfig() { |
|
1173 | + return $this->query('SystemConfig'); |
|
1174 | + } |
|
1175 | + |
|
1176 | + /** |
|
1177 | + * Returns the app config manager |
|
1178 | + * |
|
1179 | + * @return \OCP\IAppConfig |
|
1180 | + */ |
|
1181 | + public function getAppConfig() { |
|
1182 | + return $this->query('AppConfig'); |
|
1183 | + } |
|
1184 | + |
|
1185 | + /** |
|
1186 | + * @return \OCP\L10N\IFactory |
|
1187 | + */ |
|
1188 | + public function getL10NFactory() { |
|
1189 | + return $this->query('L10NFactory'); |
|
1190 | + } |
|
1191 | + |
|
1192 | + /** |
|
1193 | + * get an L10N instance |
|
1194 | + * |
|
1195 | + * @param string $app appid |
|
1196 | + * @param string $lang |
|
1197 | + * @return IL10N |
|
1198 | + */ |
|
1199 | + public function getL10N($app, $lang = null) { |
|
1200 | + return $this->getL10NFactory()->get($app, $lang); |
|
1201 | + } |
|
1202 | + |
|
1203 | + /** |
|
1204 | + * @return \OCP\IURLGenerator |
|
1205 | + */ |
|
1206 | + public function getURLGenerator() { |
|
1207 | + return $this->query('URLGenerator'); |
|
1208 | + } |
|
1209 | + |
|
1210 | + /** |
|
1211 | + * @return \OCP\IHelper |
|
1212 | + */ |
|
1213 | + public function getHelper() { |
|
1214 | + return $this->query('AppHelper'); |
|
1215 | + } |
|
1216 | + |
|
1217 | + /** |
|
1218 | + * @return AppFetcher |
|
1219 | + */ |
|
1220 | + public function getAppFetcher() { |
|
1221 | + return $this->query('AppFetcher'); |
|
1222 | + } |
|
1223 | + |
|
1224 | + /** |
|
1225 | + * Returns an ICache instance. Since 8.1.0 it returns a fake cache. Use |
|
1226 | + * getMemCacheFactory() instead. |
|
1227 | + * |
|
1228 | + * @return \OCP\ICache |
|
1229 | + * @deprecated 8.1.0 use getMemCacheFactory to obtain a proper cache |
|
1230 | + */ |
|
1231 | + public function getCache() { |
|
1232 | + return $this->query('UserCache'); |
|
1233 | + } |
|
1234 | + |
|
1235 | + /** |
|
1236 | + * Returns an \OCP\CacheFactory instance |
|
1237 | + * |
|
1238 | + * @return \OCP\ICacheFactory |
|
1239 | + */ |
|
1240 | + public function getMemCacheFactory() { |
|
1241 | + return $this->query('MemCacheFactory'); |
|
1242 | + } |
|
1243 | + |
|
1244 | + /** |
|
1245 | + * Returns an \OC\RedisFactory instance |
|
1246 | + * |
|
1247 | + * @return \OC\RedisFactory |
|
1248 | + */ |
|
1249 | + public function getGetRedisFactory() { |
|
1250 | + return $this->query('RedisFactory'); |
|
1251 | + } |
|
1252 | + |
|
1253 | + |
|
1254 | + /** |
|
1255 | + * Returns the current session |
|
1256 | + * |
|
1257 | + * @return \OCP\IDBConnection |
|
1258 | + */ |
|
1259 | + public function getDatabaseConnection() { |
|
1260 | + return $this->query('DatabaseConnection'); |
|
1261 | + } |
|
1262 | + |
|
1263 | + /** |
|
1264 | + * Returns the activity manager |
|
1265 | + * |
|
1266 | + * @return \OCP\Activity\IManager |
|
1267 | + */ |
|
1268 | + public function getActivityManager() { |
|
1269 | + return $this->query('ActivityManager'); |
|
1270 | + } |
|
1271 | + |
|
1272 | + /** |
|
1273 | + * Returns an job list for controlling background jobs |
|
1274 | + * |
|
1275 | + * @return \OCP\BackgroundJob\IJobList |
|
1276 | + */ |
|
1277 | + public function getJobList() { |
|
1278 | + return $this->query('JobList'); |
|
1279 | + } |
|
1280 | + |
|
1281 | + /** |
|
1282 | + * Returns a logger instance |
|
1283 | + * |
|
1284 | + * @return \OCP\ILogger |
|
1285 | + */ |
|
1286 | + public function getLogger() { |
|
1287 | + return $this->query('Logger'); |
|
1288 | + } |
|
1289 | + |
|
1290 | + /** |
|
1291 | + * Returns a router for generating and matching urls |
|
1292 | + * |
|
1293 | + * @return \OCP\Route\IRouter |
|
1294 | + */ |
|
1295 | + public function getRouter() { |
|
1296 | + return $this->query('Router'); |
|
1297 | + } |
|
1298 | + |
|
1299 | + /** |
|
1300 | + * Returns a search instance |
|
1301 | + * |
|
1302 | + * @return \OCP\ISearch |
|
1303 | + */ |
|
1304 | + public function getSearch() { |
|
1305 | + return $this->query('Search'); |
|
1306 | + } |
|
1307 | + |
|
1308 | + /** |
|
1309 | + * Returns a SecureRandom instance |
|
1310 | + * |
|
1311 | + * @return \OCP\Security\ISecureRandom |
|
1312 | + */ |
|
1313 | + public function getSecureRandom() { |
|
1314 | + return $this->query('SecureRandom'); |
|
1315 | + } |
|
1316 | + |
|
1317 | + /** |
|
1318 | + * Returns a Crypto instance |
|
1319 | + * |
|
1320 | + * @return \OCP\Security\ICrypto |
|
1321 | + */ |
|
1322 | + public function getCrypto() { |
|
1323 | + return $this->query('Crypto'); |
|
1324 | + } |
|
1325 | + |
|
1326 | + /** |
|
1327 | + * Returns a Hasher instance |
|
1328 | + * |
|
1329 | + * @return \OCP\Security\IHasher |
|
1330 | + */ |
|
1331 | + public function getHasher() { |
|
1332 | + return $this->query('Hasher'); |
|
1333 | + } |
|
1334 | + |
|
1335 | + /** |
|
1336 | + * Returns a CredentialsManager instance |
|
1337 | + * |
|
1338 | + * @return \OCP\Security\ICredentialsManager |
|
1339 | + */ |
|
1340 | + public function getCredentialsManager() { |
|
1341 | + return $this->query('CredentialsManager'); |
|
1342 | + } |
|
1343 | + |
|
1344 | + /** |
|
1345 | + * Returns an instance of the HTTP helper class |
|
1346 | + * |
|
1347 | + * @deprecated Use getHTTPClientService() |
|
1348 | + * @return \OC\HTTPHelper |
|
1349 | + */ |
|
1350 | + public function getHTTPHelper() { |
|
1351 | + return $this->query('HTTPHelper'); |
|
1352 | + } |
|
1353 | + |
|
1354 | + /** |
|
1355 | + * Get the certificate manager for the user |
|
1356 | + * |
|
1357 | + * @param string $userId (optional) if not specified the current loggedin user is used, use null to get the system certificate manager |
|
1358 | + * @return \OCP\ICertificateManager | null if $uid is null and no user is logged in |
|
1359 | + */ |
|
1360 | + public function getCertificateManager($userId = '') { |
|
1361 | + if ($userId === '') { |
|
1362 | + $userSession = $this->getUserSession(); |
|
1363 | + $user = $userSession->getUser(); |
|
1364 | + if (is_null($user)) { |
|
1365 | + return null; |
|
1366 | + } |
|
1367 | + $userId = $user->getUID(); |
|
1368 | + } |
|
1369 | + return new CertificateManager($userId, new View(), $this->getConfig(), $this->getLogger()); |
|
1370 | + } |
|
1371 | + |
|
1372 | + /** |
|
1373 | + * Returns an instance of the HTTP client service |
|
1374 | + * |
|
1375 | + * @return \OCP\Http\Client\IClientService |
|
1376 | + */ |
|
1377 | + public function getHTTPClientService() { |
|
1378 | + return $this->query('HttpClientService'); |
|
1379 | + } |
|
1380 | + |
|
1381 | + /** |
|
1382 | + * Create a new event source |
|
1383 | + * |
|
1384 | + * @return \OCP\IEventSource |
|
1385 | + */ |
|
1386 | + public function createEventSource() { |
|
1387 | + return new \OC_EventSource(); |
|
1388 | + } |
|
1389 | + |
|
1390 | + /** |
|
1391 | + * Get the active event logger |
|
1392 | + * |
|
1393 | + * The returned logger only logs data when debug mode is enabled |
|
1394 | + * |
|
1395 | + * @return \OCP\Diagnostics\IEventLogger |
|
1396 | + */ |
|
1397 | + public function getEventLogger() { |
|
1398 | + return $this->query('EventLogger'); |
|
1399 | + } |
|
1400 | + |
|
1401 | + /** |
|
1402 | + * Get the active query logger |
|
1403 | + * |
|
1404 | + * The returned logger only logs data when debug mode is enabled |
|
1405 | + * |
|
1406 | + * @return \OCP\Diagnostics\IQueryLogger |
|
1407 | + */ |
|
1408 | + public function getQueryLogger() { |
|
1409 | + return $this->query('QueryLogger'); |
|
1410 | + } |
|
1411 | + |
|
1412 | + /** |
|
1413 | + * Get the manager for temporary files and folders |
|
1414 | + * |
|
1415 | + * @return \OCP\ITempManager |
|
1416 | + */ |
|
1417 | + public function getTempManager() { |
|
1418 | + return $this->query('TempManager'); |
|
1419 | + } |
|
1420 | + |
|
1421 | + /** |
|
1422 | + * Get the app manager |
|
1423 | + * |
|
1424 | + * @return \OCP\App\IAppManager |
|
1425 | + */ |
|
1426 | + public function getAppManager() { |
|
1427 | + return $this->query('AppManager'); |
|
1428 | + } |
|
1429 | + |
|
1430 | + /** |
|
1431 | + * Creates a new mailer |
|
1432 | + * |
|
1433 | + * @return \OCP\Mail\IMailer |
|
1434 | + */ |
|
1435 | + public function getMailer() { |
|
1436 | + return $this->query('Mailer'); |
|
1437 | + } |
|
1438 | + |
|
1439 | + /** |
|
1440 | + * Get the webroot |
|
1441 | + * |
|
1442 | + * @return string |
|
1443 | + */ |
|
1444 | + public function getWebRoot() { |
|
1445 | + return $this->webRoot; |
|
1446 | + } |
|
1447 | + |
|
1448 | + /** |
|
1449 | + * @return \OC\OCSClient |
|
1450 | + */ |
|
1451 | + public function getOcsClient() { |
|
1452 | + return $this->query('OcsClient'); |
|
1453 | + } |
|
1454 | + |
|
1455 | + /** |
|
1456 | + * @return \OCP\IDateTimeZone |
|
1457 | + */ |
|
1458 | + public function getDateTimeZone() { |
|
1459 | + return $this->query('DateTimeZone'); |
|
1460 | + } |
|
1461 | + |
|
1462 | + /** |
|
1463 | + * @return \OCP\IDateTimeFormatter |
|
1464 | + */ |
|
1465 | + public function getDateTimeFormatter() { |
|
1466 | + return $this->query('DateTimeFormatter'); |
|
1467 | + } |
|
1468 | + |
|
1469 | + /** |
|
1470 | + * @return \OCP\Files\Config\IMountProviderCollection |
|
1471 | + */ |
|
1472 | + public function getMountProviderCollection() { |
|
1473 | + return $this->query('MountConfigManager'); |
|
1474 | + } |
|
1475 | + |
|
1476 | + /** |
|
1477 | + * Get the IniWrapper |
|
1478 | + * |
|
1479 | + * @return IniGetWrapper |
|
1480 | + */ |
|
1481 | + public function getIniWrapper() { |
|
1482 | + return $this->query('IniWrapper'); |
|
1483 | + } |
|
1484 | + |
|
1485 | + /** |
|
1486 | + * @return \OCP\Command\IBus |
|
1487 | + */ |
|
1488 | + public function getCommandBus() { |
|
1489 | + return $this->query('AsyncCommandBus'); |
|
1490 | + } |
|
1491 | + |
|
1492 | + /** |
|
1493 | + * Get the trusted domain helper |
|
1494 | + * |
|
1495 | + * @return TrustedDomainHelper |
|
1496 | + */ |
|
1497 | + public function getTrustedDomainHelper() { |
|
1498 | + return $this->query('TrustedDomainHelper'); |
|
1499 | + } |
|
1500 | + |
|
1501 | + /** |
|
1502 | + * Get the locking provider |
|
1503 | + * |
|
1504 | + * @return \OCP\Lock\ILockingProvider |
|
1505 | + * @since 8.1.0 |
|
1506 | + */ |
|
1507 | + public function getLockingProvider() { |
|
1508 | + return $this->query('LockingProvider'); |
|
1509 | + } |
|
1510 | + |
|
1511 | + /** |
|
1512 | + * @return \OCP\Files\Mount\IMountManager |
|
1513 | + **/ |
|
1514 | + function getMountManager() { |
|
1515 | + return $this->query('MountManager'); |
|
1516 | + } |
|
1517 | + |
|
1518 | + /** @return \OCP\Files\Config\IUserMountCache */ |
|
1519 | + function getUserMountCache() { |
|
1520 | + return $this->query('UserMountCache'); |
|
1521 | + } |
|
1522 | + |
|
1523 | + /** |
|
1524 | + * Get the MimeTypeDetector |
|
1525 | + * |
|
1526 | + * @return \OCP\Files\IMimeTypeDetector |
|
1527 | + */ |
|
1528 | + public function getMimeTypeDetector() { |
|
1529 | + return $this->query('MimeTypeDetector'); |
|
1530 | + } |
|
1531 | + |
|
1532 | + /** |
|
1533 | + * Get the MimeTypeLoader |
|
1534 | + * |
|
1535 | + * @return \OCP\Files\IMimeTypeLoader |
|
1536 | + */ |
|
1537 | + public function getMimeTypeLoader() { |
|
1538 | + return $this->query('MimeTypeLoader'); |
|
1539 | + } |
|
1540 | + |
|
1541 | + /** |
|
1542 | + * Get the manager of all the capabilities |
|
1543 | + * |
|
1544 | + * @return \OC\CapabilitiesManager |
|
1545 | + */ |
|
1546 | + public function getCapabilitiesManager() { |
|
1547 | + return $this->query('CapabilitiesManager'); |
|
1548 | + } |
|
1549 | + |
|
1550 | + /** |
|
1551 | + * Get the EventDispatcher |
|
1552 | + * |
|
1553 | + * @return EventDispatcherInterface |
|
1554 | + * @since 8.2.0 |
|
1555 | + */ |
|
1556 | + public function getEventDispatcher() { |
|
1557 | + return $this->query('EventDispatcher'); |
|
1558 | + } |
|
1559 | + |
|
1560 | + /** |
|
1561 | + * Get the Notification Manager |
|
1562 | + * |
|
1563 | + * @return \OCP\Notification\IManager |
|
1564 | + * @since 8.2.0 |
|
1565 | + */ |
|
1566 | + public function getNotificationManager() { |
|
1567 | + return $this->query('NotificationManager'); |
|
1568 | + } |
|
1569 | + |
|
1570 | + /** |
|
1571 | + * @return \OCP\Comments\ICommentsManager |
|
1572 | + */ |
|
1573 | + public function getCommentsManager() { |
|
1574 | + return $this->query('CommentsManager'); |
|
1575 | + } |
|
1576 | + |
|
1577 | + /** |
|
1578 | + * @return \OC_Defaults |
|
1579 | + */ |
|
1580 | + public function getThemingDefaults() { |
|
1581 | + return $this->query('ThemingDefaults'); |
|
1582 | + } |
|
1583 | + |
|
1584 | + /** |
|
1585 | + * @return \OC\IntegrityCheck\Checker |
|
1586 | + */ |
|
1587 | + public function getIntegrityCodeChecker() { |
|
1588 | + return $this->query('IntegrityCodeChecker'); |
|
1589 | + } |
|
1590 | + |
|
1591 | + /** |
|
1592 | + * @return \OC\Session\CryptoWrapper |
|
1593 | + */ |
|
1594 | + public function getSessionCryptoWrapper() { |
|
1595 | + return $this->query('CryptoWrapper'); |
|
1596 | + } |
|
1597 | + |
|
1598 | + /** |
|
1599 | + * @return CsrfTokenManager |
|
1600 | + */ |
|
1601 | + public function getCsrfTokenManager() { |
|
1602 | + return $this->query('CsrfTokenManager'); |
|
1603 | + } |
|
1604 | + |
|
1605 | + /** |
|
1606 | + * @return Throttler |
|
1607 | + */ |
|
1608 | + public function getBruteForceThrottler() { |
|
1609 | + return $this->query('Throttler'); |
|
1610 | + } |
|
1611 | + |
|
1612 | + /** |
|
1613 | + * @return IContentSecurityPolicyManager |
|
1614 | + */ |
|
1615 | + public function getContentSecurityPolicyManager() { |
|
1616 | + return $this->query('ContentSecurityPolicyManager'); |
|
1617 | + } |
|
1618 | + |
|
1619 | + /** |
|
1620 | + * @return ContentSecurityPolicyNonceManager |
|
1621 | + */ |
|
1622 | + public function getContentSecurityPolicyNonceManager() { |
|
1623 | + return $this->query('ContentSecurityPolicyNonceManager'); |
|
1624 | + } |
|
1625 | + |
|
1626 | + /** |
|
1627 | + * Not a public API as of 8.2, wait for 9.0 |
|
1628 | + * |
|
1629 | + * @return \OCA\Files_External\Service\BackendService |
|
1630 | + */ |
|
1631 | + public function getStoragesBackendService() { |
|
1632 | + return $this->query('OCA\\Files_External\\Service\\BackendService'); |
|
1633 | + } |
|
1634 | + |
|
1635 | + /** |
|
1636 | + * Not a public API as of 8.2, wait for 9.0 |
|
1637 | + * |
|
1638 | + * @return \OCA\Files_External\Service\GlobalStoragesService |
|
1639 | + */ |
|
1640 | + public function getGlobalStoragesService() { |
|
1641 | + return $this->query('OCA\\Files_External\\Service\\GlobalStoragesService'); |
|
1642 | + } |
|
1643 | + |
|
1644 | + /** |
|
1645 | + * Not a public API as of 8.2, wait for 9.0 |
|
1646 | + * |
|
1647 | + * @return \OCA\Files_External\Service\UserGlobalStoragesService |
|
1648 | + */ |
|
1649 | + public function getUserGlobalStoragesService() { |
|
1650 | + return $this->query('OCA\\Files_External\\Service\\UserGlobalStoragesService'); |
|
1651 | + } |
|
1652 | + |
|
1653 | + /** |
|
1654 | + * Not a public API as of 8.2, wait for 9.0 |
|
1655 | + * |
|
1656 | + * @return \OCA\Files_External\Service\UserStoragesService |
|
1657 | + */ |
|
1658 | + public function getUserStoragesService() { |
|
1659 | + return $this->query('OCA\\Files_External\\Service\\UserStoragesService'); |
|
1660 | + } |
|
1661 | + |
|
1662 | + /** |
|
1663 | + * @return \OCP\Share\IManager |
|
1664 | + */ |
|
1665 | + public function getShareManager() { |
|
1666 | + return $this->query('ShareManager'); |
|
1667 | + } |
|
1668 | + |
|
1669 | + /** |
|
1670 | + * Returns the LDAP Provider |
|
1671 | + * |
|
1672 | + * @return \OCP\LDAP\ILDAPProvider |
|
1673 | + */ |
|
1674 | + public function getLDAPProvider() { |
|
1675 | + return $this->query('LDAPProvider'); |
|
1676 | + } |
|
1677 | + |
|
1678 | + /** |
|
1679 | + * @return \OCP\Settings\IManager |
|
1680 | + */ |
|
1681 | + public function getSettingsManager() { |
|
1682 | + return $this->query('SettingsManager'); |
|
1683 | + } |
|
1684 | + |
|
1685 | + /** |
|
1686 | + * @return \OCP\Files\IAppData |
|
1687 | + */ |
|
1688 | + public function getAppDataDir($app) { |
|
1689 | + /** @var \OC\Files\AppData\Factory $factory */ |
|
1690 | + $factory = $this->query(\OC\Files\AppData\Factory::class); |
|
1691 | + return $factory->get($app); |
|
1692 | + } |
|
1693 | + |
|
1694 | + /** |
|
1695 | + * @return \OCP\Lockdown\ILockdownManager |
|
1696 | + */ |
|
1697 | + public function getLockdownManager() { |
|
1698 | + return $this->query('LockdownManager'); |
|
1699 | + } |
|
1700 | + |
|
1701 | + /** |
|
1702 | + * @return \OCP\Federation\ICloudIdManager |
|
1703 | + */ |
|
1704 | + public function getCloudIdManager() { |
|
1705 | + return $this->query(ICloudIdManager::class); |
|
1706 | + } |
|
1707 | 1707 | } |
@@ -134,7 +134,7 @@ discard block |
||
134 | 134 | |
135 | 135 | $this->registerAlias(IActionFactory::class, ActionFactory::class); |
136 | 136 | |
137 | - $this->registerService(\OCP\IPreview::class, function (Server $c) { |
|
137 | + $this->registerService(\OCP\IPreview::class, function(Server $c) { |
|
138 | 138 | return new PreviewManager( |
139 | 139 | $c->getConfig(), |
140 | 140 | $c->getRootFolder(), |
@@ -145,13 +145,13 @@ discard block |
||
145 | 145 | }); |
146 | 146 | $this->registerAlias('PreviewManager', \OCP\IPreview::class); |
147 | 147 | |
148 | - $this->registerService(\OC\Preview\Watcher::class, function (Server $c) { |
|
148 | + $this->registerService(\OC\Preview\Watcher::class, function(Server $c) { |
|
149 | 149 | return new \OC\Preview\Watcher( |
150 | 150 | $c->getAppDataDir('preview') |
151 | 151 | ); |
152 | 152 | }); |
153 | 153 | |
154 | - $this->registerService('EncryptionManager', function (Server $c) { |
|
154 | + $this->registerService('EncryptionManager', function(Server $c) { |
|
155 | 155 | $view = new View(); |
156 | 156 | $util = new Encryption\Util( |
157 | 157 | $view, |
@@ -169,7 +169,7 @@ discard block |
||
169 | 169 | ); |
170 | 170 | }); |
171 | 171 | |
172 | - $this->registerService('EncryptionFileHelper', function (Server $c) { |
|
172 | + $this->registerService('EncryptionFileHelper', function(Server $c) { |
|
173 | 173 | $util = new Encryption\Util( |
174 | 174 | new View(), |
175 | 175 | $c->getUserManager(), |
@@ -179,7 +179,7 @@ discard block |
||
179 | 179 | return new Encryption\File($util); |
180 | 180 | }); |
181 | 181 | |
182 | - $this->registerService('EncryptionKeyStorage', function (Server $c) { |
|
182 | + $this->registerService('EncryptionKeyStorage', function(Server $c) { |
|
183 | 183 | $view = new View(); |
184 | 184 | $util = new Encryption\Util( |
185 | 185 | $view, |
@@ -190,32 +190,32 @@ discard block |
||
190 | 190 | |
191 | 191 | return new Encryption\Keys\Storage($view, $util); |
192 | 192 | }); |
193 | - $this->registerService('TagMapper', function (Server $c) { |
|
193 | + $this->registerService('TagMapper', function(Server $c) { |
|
194 | 194 | return new TagMapper($c->getDatabaseConnection()); |
195 | 195 | }); |
196 | 196 | |
197 | - $this->registerService(\OCP\ITagManager::class, function (Server $c) { |
|
197 | + $this->registerService(\OCP\ITagManager::class, function(Server $c) { |
|
198 | 198 | $tagMapper = $c->query('TagMapper'); |
199 | 199 | return new TagManager($tagMapper, $c->getUserSession()); |
200 | 200 | }); |
201 | 201 | $this->registerAlias('TagManager', \OCP\ITagManager::class); |
202 | 202 | |
203 | - $this->registerService('SystemTagManagerFactory', function (Server $c) { |
|
203 | + $this->registerService('SystemTagManagerFactory', function(Server $c) { |
|
204 | 204 | $config = $c->getConfig(); |
205 | 205 | $factoryClass = $config->getSystemValue('systemtags.managerFactory', '\OC\SystemTag\ManagerFactory'); |
206 | 206 | /** @var \OC\SystemTag\ManagerFactory $factory */ |
207 | 207 | $factory = new $factoryClass($this); |
208 | 208 | return $factory; |
209 | 209 | }); |
210 | - $this->registerService(\OCP\SystemTag\ISystemTagManager::class, function (Server $c) { |
|
210 | + $this->registerService(\OCP\SystemTag\ISystemTagManager::class, function(Server $c) { |
|
211 | 211 | return $c->query('SystemTagManagerFactory')->getManager(); |
212 | 212 | }); |
213 | 213 | $this->registerAlias('SystemTagManager', \OCP\SystemTag\ISystemTagManager::class); |
214 | 214 | |
215 | - $this->registerService(\OCP\SystemTag\ISystemTagObjectMapper::class, function (Server $c) { |
|
215 | + $this->registerService(\OCP\SystemTag\ISystemTagObjectMapper::class, function(Server $c) { |
|
216 | 216 | return $c->query('SystemTagManagerFactory')->getObjectMapper(); |
217 | 217 | }); |
218 | - $this->registerService('RootFolder', function (Server $c) { |
|
218 | + $this->registerService('RootFolder', function(Server $c) { |
|
219 | 219 | $manager = \OC\Files\Filesystem::getMountManager(null); |
220 | 220 | $view = new View(); |
221 | 221 | $root = new Root( |
@@ -243,30 +243,30 @@ discard block |
||
243 | 243 | }); |
244 | 244 | $this->registerAlias('LazyRootFolder', \OCP\Files\IRootFolder::class); |
245 | 245 | |
246 | - $this->registerService(\OCP\IUserManager::class, function (Server $c) { |
|
246 | + $this->registerService(\OCP\IUserManager::class, function(Server $c) { |
|
247 | 247 | $config = $c->getConfig(); |
248 | 248 | return new \OC\User\Manager($config); |
249 | 249 | }); |
250 | 250 | $this->registerAlias('UserManager', \OCP\IUserManager::class); |
251 | 251 | |
252 | - $this->registerService(\OCP\IGroupManager::class, function (Server $c) { |
|
252 | + $this->registerService(\OCP\IGroupManager::class, function(Server $c) { |
|
253 | 253 | $groupManager = new \OC\Group\Manager($this->getUserManager(), $this->getLogger()); |
254 | - $groupManager->listen('\OC\Group', 'preCreate', function ($gid) { |
|
254 | + $groupManager->listen('\OC\Group', 'preCreate', function($gid) { |
|
255 | 255 | \OC_Hook::emit('OC_Group', 'pre_createGroup', array('run' => true, 'gid' => $gid)); |
256 | 256 | }); |
257 | - $groupManager->listen('\OC\Group', 'postCreate', function (\OC\Group\Group $gid) { |
|
257 | + $groupManager->listen('\OC\Group', 'postCreate', function(\OC\Group\Group $gid) { |
|
258 | 258 | \OC_Hook::emit('OC_User', 'post_createGroup', array('gid' => $gid->getGID())); |
259 | 259 | }); |
260 | - $groupManager->listen('\OC\Group', 'preDelete', function (\OC\Group\Group $group) { |
|
260 | + $groupManager->listen('\OC\Group', 'preDelete', function(\OC\Group\Group $group) { |
|
261 | 261 | \OC_Hook::emit('OC_Group', 'pre_deleteGroup', array('run' => true, 'gid' => $group->getGID())); |
262 | 262 | }); |
263 | - $groupManager->listen('\OC\Group', 'postDelete', function (\OC\Group\Group $group) { |
|
263 | + $groupManager->listen('\OC\Group', 'postDelete', function(\OC\Group\Group $group) { |
|
264 | 264 | \OC_Hook::emit('OC_User', 'post_deleteGroup', array('gid' => $group->getGID())); |
265 | 265 | }); |
266 | - $groupManager->listen('\OC\Group', 'preAddUser', function (\OC\Group\Group $group, \OC\User\User $user) { |
|
266 | + $groupManager->listen('\OC\Group', 'preAddUser', function(\OC\Group\Group $group, \OC\User\User $user) { |
|
267 | 267 | \OC_Hook::emit('OC_Group', 'pre_addToGroup', array('run' => true, 'uid' => $user->getUID(), 'gid' => $group->getGID())); |
268 | 268 | }); |
269 | - $groupManager->listen('\OC\Group', 'postAddUser', function (\OC\Group\Group $group, \OC\User\User $user) { |
|
269 | + $groupManager->listen('\OC\Group', 'postAddUser', function(\OC\Group\Group $group, \OC\User\User $user) { |
|
270 | 270 | \OC_Hook::emit('OC_Group', 'post_addToGroup', array('uid' => $user->getUID(), 'gid' => $group->getGID())); |
271 | 271 | //Minimal fix to keep it backward compatible TODO: clean up all the GroupManager hooks |
272 | 272 | \OC_Hook::emit('OC_User', 'post_addToGroup', array('uid' => $user->getUID(), 'gid' => $group->getGID())); |
@@ -286,11 +286,11 @@ discard block |
||
286 | 286 | return new Store($session, $logger, $tokenProvider); |
287 | 287 | }); |
288 | 288 | $this->registerAlias(IStore::class, Store::class); |
289 | - $this->registerService('OC\Authentication\Token\DefaultTokenMapper', function (Server $c) { |
|
289 | + $this->registerService('OC\Authentication\Token\DefaultTokenMapper', function(Server $c) { |
|
290 | 290 | $dbConnection = $c->getDatabaseConnection(); |
291 | 291 | return new Authentication\Token\DefaultTokenMapper($dbConnection); |
292 | 292 | }); |
293 | - $this->registerService('OC\Authentication\Token\DefaultTokenProvider', function (Server $c) { |
|
293 | + $this->registerService('OC\Authentication\Token\DefaultTokenProvider', function(Server $c) { |
|
294 | 294 | $mapper = $c->query('OC\Authentication\Token\DefaultTokenMapper'); |
295 | 295 | $crypto = $c->getCrypto(); |
296 | 296 | $config = $c->getConfig(); |
@@ -300,7 +300,7 @@ discard block |
||
300 | 300 | }); |
301 | 301 | $this->registerAlias('OC\Authentication\Token\IProvider', 'OC\Authentication\Token\DefaultTokenProvider'); |
302 | 302 | |
303 | - $this->registerService(\OCP\IUserSession::class, function (Server $c) { |
|
303 | + $this->registerService(\OCP\IUserSession::class, function(Server $c) { |
|
304 | 304 | $manager = $c->getUserManager(); |
305 | 305 | $session = new \OC\Session\Memory(''); |
306 | 306 | $timeFactory = new TimeFactory(); |
@@ -313,40 +313,40 @@ discard block |
||
313 | 313 | } |
314 | 314 | |
315 | 315 | $userSession = new \OC\User\Session($manager, $session, $timeFactory, $defaultTokenProvider, $c->getConfig(), $c->getSecureRandom()); |
316 | - $userSession->listen('\OC\User', 'preCreateUser', function ($uid, $password) { |
|
316 | + $userSession->listen('\OC\User', 'preCreateUser', function($uid, $password) { |
|
317 | 317 | \OC_Hook::emit('OC_User', 'pre_createUser', array('run' => true, 'uid' => $uid, 'password' => $password)); |
318 | 318 | }); |
319 | - $userSession->listen('\OC\User', 'postCreateUser', function ($user, $password) { |
|
319 | + $userSession->listen('\OC\User', 'postCreateUser', function($user, $password) { |
|
320 | 320 | /** @var $user \OC\User\User */ |
321 | 321 | \OC_Hook::emit('OC_User', 'post_createUser', array('uid' => $user->getUID(), 'password' => $password)); |
322 | 322 | }); |
323 | - $userSession->listen('\OC\User', 'preDelete', function ($user) { |
|
323 | + $userSession->listen('\OC\User', 'preDelete', function($user) { |
|
324 | 324 | /** @var $user \OC\User\User */ |
325 | 325 | \OC_Hook::emit('OC_User', 'pre_deleteUser', array('run' => true, 'uid' => $user->getUID())); |
326 | 326 | }); |
327 | - $userSession->listen('\OC\User', 'postDelete', function ($user) { |
|
327 | + $userSession->listen('\OC\User', 'postDelete', function($user) { |
|
328 | 328 | /** @var $user \OC\User\User */ |
329 | 329 | \OC_Hook::emit('OC_User', 'post_deleteUser', array('uid' => $user->getUID())); |
330 | 330 | }); |
331 | - $userSession->listen('\OC\User', 'preSetPassword', function ($user, $password, $recoveryPassword) { |
|
331 | + $userSession->listen('\OC\User', 'preSetPassword', function($user, $password, $recoveryPassword) { |
|
332 | 332 | /** @var $user \OC\User\User */ |
333 | 333 | \OC_Hook::emit('OC_User', 'pre_setPassword', array('run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword)); |
334 | 334 | }); |
335 | - $userSession->listen('\OC\User', 'postSetPassword', function ($user, $password, $recoveryPassword) { |
|
335 | + $userSession->listen('\OC\User', 'postSetPassword', function($user, $password, $recoveryPassword) { |
|
336 | 336 | /** @var $user \OC\User\User */ |
337 | 337 | \OC_Hook::emit('OC_User', 'post_setPassword', array('run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword)); |
338 | 338 | }); |
339 | - $userSession->listen('\OC\User', 'preLogin', function ($uid, $password) { |
|
339 | + $userSession->listen('\OC\User', 'preLogin', function($uid, $password) { |
|
340 | 340 | \OC_Hook::emit('OC_User', 'pre_login', array('run' => true, 'uid' => $uid, 'password' => $password)); |
341 | 341 | }); |
342 | - $userSession->listen('\OC\User', 'postLogin', function ($user, $password) { |
|
342 | + $userSession->listen('\OC\User', 'postLogin', function($user, $password) { |
|
343 | 343 | /** @var $user \OC\User\User */ |
344 | 344 | \OC_Hook::emit('OC_User', 'post_login', array('run' => true, 'uid' => $user->getUID(), 'password' => $password)); |
345 | 345 | }); |
346 | - $userSession->listen('\OC\User', 'logout', function () { |
|
346 | + $userSession->listen('\OC\User', 'logout', function() { |
|
347 | 347 | \OC_Hook::emit('OC_User', 'logout', array()); |
348 | 348 | }); |
349 | - $userSession->listen('\OC\User', 'changeUser', function ($user, $feature, $value) { |
|
349 | + $userSession->listen('\OC\User', 'changeUser', function($user, $feature, $value) { |
|
350 | 350 | /** @var $user \OC\User\User */ |
351 | 351 | \OC_Hook::emit('OC_User', 'changeUser', array('run' => true, 'user' => $user, 'feature' => $feature, 'value' => $value)); |
352 | 352 | }); |
@@ -354,14 +354,14 @@ discard block |
||
354 | 354 | }); |
355 | 355 | $this->registerAlias('UserSession', \OCP\IUserSession::class); |
356 | 356 | |
357 | - $this->registerService(\OC\Authentication\TwoFactorAuth\Manager::class, function (Server $c) { |
|
357 | + $this->registerService(\OC\Authentication\TwoFactorAuth\Manager::class, function(Server $c) { |
|
358 | 358 | return new \OC\Authentication\TwoFactorAuth\Manager($c->getAppManager(), $c->getSession(), $c->getConfig(), $c->getActivityManager(), $c->getLogger()); |
359 | 359 | }); |
360 | 360 | |
361 | 361 | $this->registerAlias(\OCP\INavigationManager::class, \OC\NavigationManager::class); |
362 | 362 | $this->registerAlias('NavigationManager', \OCP\INavigationManager::class); |
363 | 363 | |
364 | - $this->registerService(\OC\AllConfig::class, function (Server $c) { |
|
364 | + $this->registerService(\OC\AllConfig::class, function(Server $c) { |
|
365 | 365 | return new \OC\AllConfig( |
366 | 366 | $c->getSystemConfig() |
367 | 367 | ); |
@@ -369,17 +369,17 @@ discard block |
||
369 | 369 | $this->registerAlias('AllConfig', \OC\AllConfig::class); |
370 | 370 | $this->registerAlias(\OCP\IConfig::class, \OC\AllConfig::class); |
371 | 371 | |
372 | - $this->registerService('SystemConfig', function ($c) use ($config) { |
|
372 | + $this->registerService('SystemConfig', function($c) use ($config) { |
|
373 | 373 | return new \OC\SystemConfig($config); |
374 | 374 | }); |
375 | 375 | |
376 | - $this->registerService(\OC\AppConfig::class, function (Server $c) { |
|
376 | + $this->registerService(\OC\AppConfig::class, function(Server $c) { |
|
377 | 377 | return new \OC\AppConfig($c->getDatabaseConnection()); |
378 | 378 | }); |
379 | 379 | $this->registerAlias('AppConfig', \OC\AppConfig::class); |
380 | 380 | $this->registerAlias(\OCP\IAppConfig::class, \OC\AppConfig::class); |
381 | 381 | |
382 | - $this->registerService(\OCP\L10N\IFactory::class, function (Server $c) { |
|
382 | + $this->registerService(\OCP\L10N\IFactory::class, function(Server $c) { |
|
383 | 383 | return new \OC\L10N\Factory( |
384 | 384 | $c->getConfig(), |
385 | 385 | $c->getRequest(), |
@@ -389,7 +389,7 @@ discard block |
||
389 | 389 | }); |
390 | 390 | $this->registerAlias('L10NFactory', \OCP\L10N\IFactory::class); |
391 | 391 | |
392 | - $this->registerService(\OCP\IURLGenerator::class, function (Server $c) { |
|
392 | + $this->registerService(\OCP\IURLGenerator::class, function(Server $c) { |
|
393 | 393 | $config = $c->getConfig(); |
394 | 394 | $cacheFactory = $c->getMemCacheFactory(); |
395 | 395 | return new \OC\URLGenerator( |
@@ -399,10 +399,10 @@ discard block |
||
399 | 399 | }); |
400 | 400 | $this->registerAlias('URLGenerator', \OCP\IURLGenerator::class); |
401 | 401 | |
402 | - $this->registerService('AppHelper', function ($c) { |
|
402 | + $this->registerService('AppHelper', function($c) { |
|
403 | 403 | return new \OC\AppHelper(); |
404 | 404 | }); |
405 | - $this->registerService('AppFetcher', function ($c) { |
|
405 | + $this->registerService('AppFetcher', function($c) { |
|
406 | 406 | return new AppFetcher( |
407 | 407 | $this->getAppDataDir('appstore'), |
408 | 408 | $this->getHTTPClientService(), |
@@ -410,7 +410,7 @@ discard block |
||
410 | 410 | $this->getConfig() |
411 | 411 | ); |
412 | 412 | }); |
413 | - $this->registerService('CategoryFetcher', function ($c) { |
|
413 | + $this->registerService('CategoryFetcher', function($c) { |
|
414 | 414 | return new CategoryFetcher( |
415 | 415 | $this->getAppDataDir('appstore'), |
416 | 416 | $this->getHTTPClientService(), |
@@ -419,21 +419,21 @@ discard block |
||
419 | 419 | ); |
420 | 420 | }); |
421 | 421 | |
422 | - $this->registerService(\OCP\ICache::class, function ($c) { |
|
422 | + $this->registerService(\OCP\ICache::class, function($c) { |
|
423 | 423 | return new Cache\File(); |
424 | 424 | }); |
425 | 425 | $this->registerAlias('UserCache', \OCP\ICache::class); |
426 | 426 | |
427 | - $this->registerService(Factory::class, function (Server $c) { |
|
427 | + $this->registerService(Factory::class, function(Server $c) { |
|
428 | 428 | $config = $c->getConfig(); |
429 | 429 | |
430 | 430 | if ($config->getSystemValue('installed', false) && !(defined('PHPUNIT_RUN') && PHPUNIT_RUN)) { |
431 | 431 | $v = \OC_App::getAppVersions(); |
432 | - $v['core'] = md5(file_get_contents(\OC::$SERVERROOT . '/version.php')); |
|
432 | + $v['core'] = md5(file_get_contents(\OC::$SERVERROOT.'/version.php')); |
|
433 | 433 | $version = implode(',', $v); |
434 | 434 | $instanceId = \OC_Util::getInstanceId(); |
435 | 435 | $path = \OC::$SERVERROOT; |
436 | - $prefix = md5($instanceId . '-' . $version . '-' . $path . '-' . \OC::$WEBROOT); |
|
436 | + $prefix = md5($instanceId.'-'.$version.'-'.$path.'-'.\OC::$WEBROOT); |
|
437 | 437 | return new \OC\Memcache\Factory($prefix, $c->getLogger(), |
438 | 438 | $config->getSystemValue('memcache.local', null), |
439 | 439 | $config->getSystemValue('memcache.distributed', null), |
@@ -450,12 +450,12 @@ discard block |
||
450 | 450 | $this->registerAlias('MemCacheFactory', Factory::class); |
451 | 451 | $this->registerAlias(ICacheFactory::class, Factory::class); |
452 | 452 | |
453 | - $this->registerService('RedisFactory', function (Server $c) { |
|
453 | + $this->registerService('RedisFactory', function(Server $c) { |
|
454 | 454 | $systemConfig = $c->getSystemConfig(); |
455 | 455 | return new RedisFactory($systemConfig); |
456 | 456 | }); |
457 | 457 | |
458 | - $this->registerService(\OCP\Activity\IManager::class, function (Server $c) { |
|
458 | + $this->registerService(\OCP\Activity\IManager::class, function(Server $c) { |
|
459 | 459 | return new \OC\Activity\Manager( |
460 | 460 | $c->getRequest(), |
461 | 461 | $c->getUserSession(), |
@@ -465,14 +465,14 @@ discard block |
||
465 | 465 | }); |
466 | 466 | $this->registerAlias('ActivityManager', \OCP\Activity\IManager::class); |
467 | 467 | |
468 | - $this->registerService(\OCP\Activity\IEventMerger::class, function (Server $c) { |
|
468 | + $this->registerService(\OCP\Activity\IEventMerger::class, function(Server $c) { |
|
469 | 469 | return new \OC\Activity\EventMerger( |
470 | 470 | $c->getL10N('lib') |
471 | 471 | ); |
472 | 472 | }); |
473 | 473 | $this->registerAlias(IValidator::class, Validator::class); |
474 | 474 | |
475 | - $this->registerService(\OCP\IAvatarManager::class, function (Server $c) { |
|
475 | + $this->registerService(\OCP\IAvatarManager::class, function(Server $c) { |
|
476 | 476 | return new AvatarManager( |
477 | 477 | $c->getUserManager(), |
478 | 478 | $c->getAppDataDir('avatar'), |
@@ -483,7 +483,7 @@ discard block |
||
483 | 483 | }); |
484 | 484 | $this->registerAlias('AvatarManager', \OCP\IAvatarManager::class); |
485 | 485 | |
486 | - $this->registerService(\OCP\ILogger::class, function (Server $c) { |
|
486 | + $this->registerService(\OCP\ILogger::class, function(Server $c) { |
|
487 | 487 | $logType = $c->query('AllConfig')->getSystemValue('log_type', 'file'); |
488 | 488 | $logger = Log::getLogClass($logType); |
489 | 489 | call_user_func(array($logger, 'init')); |
@@ -492,7 +492,7 @@ discard block |
||
492 | 492 | }); |
493 | 493 | $this->registerAlias('Logger', \OCP\ILogger::class); |
494 | 494 | |
495 | - $this->registerService(\OCP\BackgroundJob\IJobList::class, function (Server $c) { |
|
495 | + $this->registerService(\OCP\BackgroundJob\IJobList::class, function(Server $c) { |
|
496 | 496 | $config = $c->getConfig(); |
497 | 497 | return new \OC\BackgroundJob\JobList( |
498 | 498 | $c->getDatabaseConnection(), |
@@ -502,7 +502,7 @@ discard block |
||
502 | 502 | }); |
503 | 503 | $this->registerAlias('JobList', \OCP\BackgroundJob\IJobList::class); |
504 | 504 | |
505 | - $this->registerService(\OCP\Route\IRouter::class, function (Server $c) { |
|
505 | + $this->registerService(\OCP\Route\IRouter::class, function(Server $c) { |
|
506 | 506 | $cacheFactory = $c->getMemCacheFactory(); |
507 | 507 | $logger = $c->getLogger(); |
508 | 508 | if ($cacheFactory->isAvailable()) { |
@@ -514,32 +514,32 @@ discard block |
||
514 | 514 | }); |
515 | 515 | $this->registerAlias('Router', \OCP\Route\IRouter::class); |
516 | 516 | |
517 | - $this->registerService(\OCP\ISearch::class, function ($c) { |
|
517 | + $this->registerService(\OCP\ISearch::class, function($c) { |
|
518 | 518 | return new Search(); |
519 | 519 | }); |
520 | 520 | $this->registerAlias('Search', \OCP\ISearch::class); |
521 | 521 | |
522 | - $this->registerService(\OCP\Security\ISecureRandom::class, function ($c) { |
|
522 | + $this->registerService(\OCP\Security\ISecureRandom::class, function($c) { |
|
523 | 523 | return new SecureRandom(); |
524 | 524 | }); |
525 | 525 | $this->registerAlias('SecureRandom', \OCP\Security\ISecureRandom::class); |
526 | 526 | |
527 | - $this->registerService(\OCP\Security\ICrypto::class, function (Server $c) { |
|
527 | + $this->registerService(\OCP\Security\ICrypto::class, function(Server $c) { |
|
528 | 528 | return new Crypto($c->getConfig(), $c->getSecureRandom()); |
529 | 529 | }); |
530 | 530 | $this->registerAlias('Crypto', \OCP\Security\ICrypto::class); |
531 | 531 | |
532 | - $this->registerService(\OCP\Security\IHasher::class, function (Server $c) { |
|
532 | + $this->registerService(\OCP\Security\IHasher::class, function(Server $c) { |
|
533 | 533 | return new Hasher($c->getConfig()); |
534 | 534 | }); |
535 | 535 | $this->registerAlias('Hasher', \OCP\Security\IHasher::class); |
536 | 536 | |
537 | - $this->registerService(\OCP\Security\ICredentialsManager::class, function (Server $c) { |
|
537 | + $this->registerService(\OCP\Security\ICredentialsManager::class, function(Server $c) { |
|
538 | 538 | return new CredentialsManager($c->getCrypto(), $c->getDatabaseConnection()); |
539 | 539 | }); |
540 | 540 | $this->registerAlias('CredentialsManager', \OCP\Security\ICredentialsManager::class); |
541 | 541 | |
542 | - $this->registerService(IDBConnection::class, function (Server $c) { |
|
542 | + $this->registerService(IDBConnection::class, function(Server $c) { |
|
543 | 543 | $systemConfig = $c->getSystemConfig(); |
544 | 544 | $factory = new \OC\DB\ConnectionFactory($systemConfig); |
545 | 545 | $type = $systemConfig->getValue('dbtype', 'sqlite'); |
@@ -553,7 +553,7 @@ discard block |
||
553 | 553 | }); |
554 | 554 | $this->registerAlias('DatabaseConnection', IDBConnection::class); |
555 | 555 | |
556 | - $this->registerService('HTTPHelper', function (Server $c) { |
|
556 | + $this->registerService('HTTPHelper', function(Server $c) { |
|
557 | 557 | $config = $c->getConfig(); |
558 | 558 | return new HTTPHelper( |
559 | 559 | $config, |
@@ -561,7 +561,7 @@ discard block |
||
561 | 561 | ); |
562 | 562 | }); |
563 | 563 | |
564 | - $this->registerService(\OCP\Http\Client\IClientService::class, function (Server $c) { |
|
564 | + $this->registerService(\OCP\Http\Client\IClientService::class, function(Server $c) { |
|
565 | 565 | $user = \OC_User::getUser(); |
566 | 566 | $uid = $user ? $user : null; |
567 | 567 | return new ClientService( |
@@ -571,7 +571,7 @@ discard block |
||
571 | 571 | }); |
572 | 572 | $this->registerAlias('HttpClientService', \OCP\Http\Client\IClientService::class); |
573 | 573 | |
574 | - $this->registerService(\OCP\Diagnostics\IEventLogger::class, function (Server $c) { |
|
574 | + $this->registerService(\OCP\Diagnostics\IEventLogger::class, function(Server $c) { |
|
575 | 575 | if ($c->getSystemConfig()->getValue('debug', false)) { |
576 | 576 | return new EventLogger(); |
577 | 577 | } else { |
@@ -580,7 +580,7 @@ discard block |
||
580 | 580 | }); |
581 | 581 | $this->registerAlias('EventLogger', \OCP\Diagnostics\IEventLogger::class); |
582 | 582 | |
583 | - $this->registerService(\OCP\Diagnostics\IQueryLogger::class, function (Server $c) { |
|
583 | + $this->registerService(\OCP\Diagnostics\IQueryLogger::class, function(Server $c) { |
|
584 | 584 | if ($c->getSystemConfig()->getValue('debug', false)) { |
585 | 585 | return new QueryLogger(); |
586 | 586 | } else { |
@@ -589,7 +589,7 @@ discard block |
||
589 | 589 | }); |
590 | 590 | $this->registerAlias('QueryLogger', \OCP\Diagnostics\IQueryLogger::class); |
591 | 591 | |
592 | - $this->registerService(TempManager::class, function (Server $c) { |
|
592 | + $this->registerService(TempManager::class, function(Server $c) { |
|
593 | 593 | return new TempManager( |
594 | 594 | $c->getLogger(), |
595 | 595 | $c->getConfig() |
@@ -598,7 +598,7 @@ discard block |
||
598 | 598 | $this->registerAlias('TempManager', TempManager::class); |
599 | 599 | $this->registerAlias(ITempManager::class, TempManager::class); |
600 | 600 | |
601 | - $this->registerService(AppManager::class, function (Server $c) { |
|
601 | + $this->registerService(AppManager::class, function(Server $c) { |
|
602 | 602 | return new \OC\App\AppManager( |
603 | 603 | $c->getUserSession(), |
604 | 604 | $c->getAppConfig(), |
@@ -610,7 +610,7 @@ discard block |
||
610 | 610 | $this->registerAlias('AppManager', AppManager::class); |
611 | 611 | $this->registerAlias(IAppManager::class, AppManager::class); |
612 | 612 | |
613 | - $this->registerService(\OCP\IDateTimeZone::class, function (Server $c) { |
|
613 | + $this->registerService(\OCP\IDateTimeZone::class, function(Server $c) { |
|
614 | 614 | return new DateTimeZone( |
615 | 615 | $c->getConfig(), |
616 | 616 | $c->getSession() |
@@ -618,7 +618,7 @@ discard block |
||
618 | 618 | }); |
619 | 619 | $this->registerAlias('DateTimeZone', \OCP\IDateTimeZone::class); |
620 | 620 | |
621 | - $this->registerService(\OCP\IDateTimeFormatter::class, function (Server $c) { |
|
621 | + $this->registerService(\OCP\IDateTimeFormatter::class, function(Server $c) { |
|
622 | 622 | $language = $c->getConfig()->getUserValue($c->getSession()->get('user_id'), 'core', 'lang', null); |
623 | 623 | |
624 | 624 | return new DateTimeFormatter( |
@@ -628,7 +628,7 @@ discard block |
||
628 | 628 | }); |
629 | 629 | $this->registerAlias('DateTimeFormatter', \OCP\IDateTimeFormatter::class); |
630 | 630 | |
631 | - $this->registerService(\OCP\Files\Config\IUserMountCache::class, function (Server $c) { |
|
631 | + $this->registerService(\OCP\Files\Config\IUserMountCache::class, function(Server $c) { |
|
632 | 632 | $mountCache = new UserMountCache($c->getDatabaseConnection(), $c->getUserManager(), $c->getLogger()); |
633 | 633 | $listener = new UserMountCacheListener($mountCache); |
634 | 634 | $listener->listen($c->getUserManager()); |
@@ -636,10 +636,10 @@ discard block |
||
636 | 636 | }); |
637 | 637 | $this->registerAlias('UserMountCache', \OCP\Files\Config\IUserMountCache::class); |
638 | 638 | |
639 | - $this->registerService(\OCP\Files\Config\IMountProviderCollection::class, function (Server $c) { |
|
639 | + $this->registerService(\OCP\Files\Config\IMountProviderCollection::class, function(Server $c) { |
|
640 | 640 | $loader = \OC\Files\Filesystem::getLoader(); |
641 | 641 | $mountCache = $c->query('UserMountCache'); |
642 | - $manager = new \OC\Files\Config\MountProviderCollection($loader, $mountCache); |
|
642 | + $manager = new \OC\Files\Config\MountProviderCollection($loader, $mountCache); |
|
643 | 643 | |
644 | 644 | // builtin providers |
645 | 645 | |
@@ -652,14 +652,14 @@ discard block |
||
652 | 652 | }); |
653 | 653 | $this->registerAlias('MountConfigManager', \OCP\Files\Config\IMountProviderCollection::class); |
654 | 654 | |
655 | - $this->registerService('IniWrapper', function ($c) { |
|
655 | + $this->registerService('IniWrapper', function($c) { |
|
656 | 656 | return new IniGetWrapper(); |
657 | 657 | }); |
658 | - $this->registerService('AsyncCommandBus', function (Server $c) { |
|
658 | + $this->registerService('AsyncCommandBus', function(Server $c) { |
|
659 | 659 | $jobList = $c->getJobList(); |
660 | 660 | return new AsyncBus($jobList); |
661 | 661 | }); |
662 | - $this->registerService('TrustedDomainHelper', function ($c) { |
|
662 | + $this->registerService('TrustedDomainHelper', function($c) { |
|
663 | 663 | return new TrustedDomainHelper($this->getConfig()); |
664 | 664 | }); |
665 | 665 | $this->registerService('Throttler', function(Server $c) { |
@@ -670,10 +670,10 @@ discard block |
||
670 | 670 | $c->getConfig() |
671 | 671 | ); |
672 | 672 | }); |
673 | - $this->registerService('IntegrityCodeChecker', function (Server $c) { |
|
673 | + $this->registerService('IntegrityCodeChecker', function(Server $c) { |
|
674 | 674 | // IConfig and IAppManager requires a working database. This code |
675 | 675 | // might however be called when ownCloud is not yet setup. |
676 | - if(\OC::$server->getSystemConfig()->getValue('installed', false)) { |
|
676 | + if (\OC::$server->getSystemConfig()->getValue('installed', false)) { |
|
677 | 677 | $config = $c->getConfig(); |
678 | 678 | $appManager = $c->getAppManager(); |
679 | 679 | } else { |
@@ -691,7 +691,7 @@ discard block |
||
691 | 691 | $c->getTempManager() |
692 | 692 | ); |
693 | 693 | }); |
694 | - $this->registerService(\OCP\IRequest::class, function ($c) { |
|
694 | + $this->registerService(\OCP\IRequest::class, function($c) { |
|
695 | 695 | if (isset($this['urlParams'])) { |
696 | 696 | $urlParams = $this['urlParams']; |
697 | 697 | } else { |
@@ -727,7 +727,7 @@ discard block |
||
727 | 727 | }); |
728 | 728 | $this->registerAlias('Request', \OCP\IRequest::class); |
729 | 729 | |
730 | - $this->registerService(\OCP\Mail\IMailer::class, function (Server $c) { |
|
730 | + $this->registerService(\OCP\Mail\IMailer::class, function(Server $c) { |
|
731 | 731 | return new Mailer( |
732 | 732 | $c->getConfig(), |
733 | 733 | $c->getLogger(), |
@@ -739,14 +739,14 @@ discard block |
||
739 | 739 | $this->registerService('LDAPProvider', function(Server $c) { |
740 | 740 | $config = $c->getConfig(); |
741 | 741 | $factoryClass = $config->getSystemValue('ldapProviderFactory', null); |
742 | - if(is_null($factoryClass)) { |
|
742 | + if (is_null($factoryClass)) { |
|
743 | 743 | throw new \Exception('ldapProviderFactory not set'); |
744 | 744 | } |
745 | 745 | /** @var \OCP\LDAP\ILDAPProviderFactory $factory */ |
746 | 746 | $factory = new $factoryClass($this); |
747 | 747 | return $factory->getLDAPProvider(); |
748 | 748 | }); |
749 | - $this->registerService('LockingProvider', function (Server $c) { |
|
749 | + $this->registerService('LockingProvider', function(Server $c) { |
|
750 | 750 | $ini = $c->getIniWrapper(); |
751 | 751 | $config = $c->getConfig(); |
752 | 752 | $ttl = $config->getSystemValue('filelocking.ttl', max(3600, $ini->getNumeric('max_execution_time'))); |
@@ -762,37 +762,37 @@ discard block |
||
762 | 762 | return new NoopLockingProvider(); |
763 | 763 | }); |
764 | 764 | |
765 | - $this->registerService(\OCP\Files\Mount\IMountManager::class, function () { |
|
765 | + $this->registerService(\OCP\Files\Mount\IMountManager::class, function() { |
|
766 | 766 | return new \OC\Files\Mount\Manager(); |
767 | 767 | }); |
768 | 768 | $this->registerAlias('MountManager', \OCP\Files\Mount\IMountManager::class); |
769 | 769 | |
770 | - $this->registerService(\OCP\Files\IMimeTypeDetector::class, function (Server $c) { |
|
770 | + $this->registerService(\OCP\Files\IMimeTypeDetector::class, function(Server $c) { |
|
771 | 771 | return new \OC\Files\Type\Detection( |
772 | 772 | $c->getURLGenerator(), |
773 | 773 | \OC::$configDir, |
774 | - \OC::$SERVERROOT . '/resources/config/' |
|
774 | + \OC::$SERVERROOT.'/resources/config/' |
|
775 | 775 | ); |
776 | 776 | }); |
777 | 777 | $this->registerAlias('MimeTypeDetector', \OCP\Files\IMimeTypeDetector::class); |
778 | 778 | |
779 | - $this->registerService(\OCP\Files\IMimeTypeLoader::class, function (Server $c) { |
|
779 | + $this->registerService(\OCP\Files\IMimeTypeLoader::class, function(Server $c) { |
|
780 | 780 | return new \OC\Files\Type\Loader( |
781 | 781 | $c->getDatabaseConnection() |
782 | 782 | ); |
783 | 783 | }); |
784 | 784 | $this->registerAlias('MimeTypeLoader', \OCP\Files\IMimeTypeLoader::class); |
785 | 785 | |
786 | - $this->registerService(\OCP\Notification\IManager::class, function (Server $c) { |
|
786 | + $this->registerService(\OCP\Notification\IManager::class, function(Server $c) { |
|
787 | 787 | return new Manager( |
788 | 788 | $c->query(IValidator::class) |
789 | 789 | ); |
790 | 790 | }); |
791 | 791 | $this->registerAlias('NotificationManager', \OCP\Notification\IManager::class); |
792 | 792 | |
793 | - $this->registerService(\OC\CapabilitiesManager::class, function (Server $c) { |
|
793 | + $this->registerService(\OC\CapabilitiesManager::class, function(Server $c) { |
|
794 | 794 | $manager = new \OC\CapabilitiesManager($c->getLogger()); |
795 | - $manager->registerCapability(function () use ($c) { |
|
795 | + $manager->registerCapability(function() use ($c) { |
|
796 | 796 | return new \OC\OCS\CoreCapabilities($c->getConfig()); |
797 | 797 | }); |
798 | 798 | return $manager; |
@@ -834,13 +834,13 @@ discard block |
||
834 | 834 | } |
835 | 835 | return new \OC_Defaults(); |
836 | 836 | }); |
837 | - $this->registerService(EventDispatcher::class, function () { |
|
837 | + $this->registerService(EventDispatcher::class, function() { |
|
838 | 838 | return new EventDispatcher(); |
839 | 839 | }); |
840 | 840 | $this->registerAlias('EventDispatcher', EventDispatcher::class); |
841 | 841 | $this->registerAlias(EventDispatcherInterface::class, EventDispatcher::class); |
842 | 842 | |
843 | - $this->registerService('CryptoWrapper', function (Server $c) { |
|
843 | + $this->registerService('CryptoWrapper', function(Server $c) { |
|
844 | 844 | // FIXME: Instantiiated here due to cyclic dependency |
845 | 845 | $request = new Request( |
846 | 846 | [ |
@@ -865,7 +865,7 @@ discard block |
||
865 | 865 | $request |
866 | 866 | ); |
867 | 867 | }); |
868 | - $this->registerService('CsrfTokenManager', function (Server $c) { |
|
868 | + $this->registerService('CsrfTokenManager', function(Server $c) { |
|
869 | 869 | $tokenGenerator = new CsrfTokenGenerator($c->getSecureRandom()); |
870 | 870 | |
871 | 871 | return new CsrfTokenManager( |
@@ -873,10 +873,10 @@ discard block |
||
873 | 873 | $c->query(SessionStorage::class) |
874 | 874 | ); |
875 | 875 | }); |
876 | - $this->registerService(SessionStorage::class, function (Server $c) { |
|
876 | + $this->registerService(SessionStorage::class, function(Server $c) { |
|
877 | 877 | return new SessionStorage($c->getSession()); |
878 | 878 | }); |
879 | - $this->registerService(\OCP\Security\IContentSecurityPolicyManager::class, function (Server $c) { |
|
879 | + $this->registerService(\OCP\Security\IContentSecurityPolicyManager::class, function(Server $c) { |
|
880 | 880 | return new ContentSecurityPolicyManager(); |
881 | 881 | }); |
882 | 882 | $this->registerAlias('ContentSecurityPolicyManager', \OCP\Security\IContentSecurityPolicyManager::class); |
@@ -927,23 +927,23 @@ discard block |
||
927 | 927 | ); |
928 | 928 | return $manager; |
929 | 929 | }); |
930 | - $this->registerService(\OC\Files\AppData\Factory::class, function (Server $c) { |
|
930 | + $this->registerService(\OC\Files\AppData\Factory::class, function(Server $c) { |
|
931 | 931 | return new \OC\Files\AppData\Factory( |
932 | 932 | $c->getRootFolder(), |
933 | 933 | $c->getSystemConfig() |
934 | 934 | ); |
935 | 935 | }); |
936 | 936 | |
937 | - $this->registerService('LockdownManager', function (Server $c) { |
|
937 | + $this->registerService('LockdownManager', function(Server $c) { |
|
938 | 938 | return new LockdownManager(); |
939 | 939 | }); |
940 | 940 | |
941 | - $this->registerService(ICloudIdManager::class, function (Server $c) { |
|
941 | + $this->registerService(ICloudIdManager::class, function(Server $c) { |
|
942 | 942 | return new CloudIdManager(); |
943 | 943 | }); |
944 | 944 | |
945 | 945 | /* To trick DI since we don't extend the DIContainer here */ |
946 | - $this->registerService(CleanPreviewsBackgroundJob::class, function (Server $c) { |
|
946 | + $this->registerService(CleanPreviewsBackgroundJob::class, function(Server $c) { |
|
947 | 947 | return new CleanPreviewsBackgroundJob( |
948 | 948 | $c->getRootFolder(), |
949 | 949 | $c->getLogger(), |
@@ -1097,7 +1097,7 @@ discard block |
||
1097 | 1097 | * @deprecated since 9.2.0 use IAppData |
1098 | 1098 | */ |
1099 | 1099 | public function getAppFolder() { |
1100 | - $dir = '/' . \OC_App::getCurrentApp(); |
|
1100 | + $dir = '/'.\OC_App::getCurrentApp(); |
|
1101 | 1101 | $root = $this->getRootFolder(); |
1102 | 1102 | if (!$root->nodeExists($dir)) { |
1103 | 1103 | $folder = $root->newFolder($dir); |