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