@@ -51,6 +51,9 @@ discard block |
||
51 | 51 | ]; |
52 | 52 | } |
53 | 53 | |
54 | + /** |
|
55 | + * @param string $type |
|
56 | + */ |
|
54 | 57 | protected function formatSections($sections, $currentSection, $type) { |
55 | 58 | $templateParameters = []; |
56 | 59 | /** @var \OCP\Settings\ISection[] $prioritizedSections */ |
@@ -81,6 +84,9 @@ discard block |
||
81 | 84 | return $templateParameters; |
82 | 85 | } |
83 | 86 | |
87 | + /** |
|
88 | + * @param string $currentSections |
|
89 | + */ |
|
84 | 90 | protected function formatPersonalSections($currentSections) { |
85 | 91 | $sections = $this->settingsManager->getPersonalSections(); |
86 | 92 | $templateParameters = $this->formatSections($sections, $currentSections, 'personal'); |
@@ -88,6 +94,9 @@ discard block |
||
88 | 94 | return $templateParameters; |
89 | 95 | } |
90 | 96 | |
97 | + /** |
|
98 | + * @param string $currentSections |
|
99 | + */ |
|
91 | 100 | protected function formatAdminSections($currentSections) { |
92 | 101 | $sections = $this->settingsManager->getAdminSections(); |
93 | 102 | $templateParameters = $this->formatSections($sections, $currentSections, 'admin'); |
@@ -111,6 +120,9 @@ discard block |
||
111 | 120 | return ['content' => $html]; |
112 | 121 | } |
113 | 122 | |
123 | + /** |
|
124 | + * @param string $section |
|
125 | + */ |
|
114 | 126 | private function getIndexResponse($section) { |
115 | 127 | $templateParams = []; |
116 | 128 | $templateParams = array_merge($templateParams, $this->getNavigationParameters($section)); |
@@ -29,95 +29,95 @@ |
||
29 | 29 | use OCP\Settings\ISettings; |
30 | 30 | |
31 | 31 | trait CommonSettingsTrait { |
32 | - /** @var ISettingsManager */ |
|
33 | - private $settingsManager; |
|
34 | - |
|
35 | - /** |
|
36 | - * @param string $currentSection |
|
37 | - * @return array |
|
38 | - */ |
|
39 | - private function getNavigationParameters($currentSection) { |
|
40 | - $templateParameters = [ |
|
41 | - 'personal' => $this->formatPersonalSections($currentSection), |
|
42 | - 'admin' => [] |
|
43 | - ]; |
|
44 | - |
|
45 | - if(\OC_User::isAdminUser(\OC_User::getUser())) { |
|
46 | - $templateParameters['admin'] = $this->formatAdminSections($currentSection); |
|
47 | - } |
|
48 | - |
|
49 | - return [ |
|
50 | - 'forms' => $templateParameters |
|
51 | - ]; |
|
52 | - } |
|
53 | - |
|
54 | - protected function formatSections($sections, $currentSection, $type) { |
|
55 | - $templateParameters = []; |
|
56 | - /** @var \OCP\Settings\ISection[] $prioritizedSections */ |
|
57 | - foreach($sections as $prioritizedSections) { |
|
58 | - foreach ($prioritizedSections as $section) { |
|
59 | - if($type === 'admin') { |
|
60 | - $settings = $this->settingsManager->getAdminSettings($section->getID()); |
|
61 | - } else if($type === 'personal') { |
|
62 | - $settings = $this->settingsManager->getPersonalSettings($section->getID()); |
|
63 | - } |
|
64 | - if (empty($settings)) { |
|
65 | - continue; |
|
66 | - } |
|
67 | - |
|
68 | - $icon = ''; |
|
69 | - if ($section instanceof IIconSection) { |
|
70 | - $icon = $section->getIcon(); |
|
71 | - } |
|
72 | - |
|
73 | - $templateParameters[] = [ |
|
74 | - 'anchor' => $section->getID(), |
|
75 | - 'section-name' => $section->getName(), |
|
76 | - 'active' => $section->getID() === $currentSection, |
|
77 | - 'icon' => $icon, |
|
78 | - ]; |
|
79 | - } |
|
80 | - } |
|
81 | - return $templateParameters; |
|
82 | - } |
|
83 | - |
|
84 | - protected function formatPersonalSections($currentSections) { |
|
85 | - $sections = $this->settingsManager->getPersonalSections(); |
|
86 | - $templateParameters = $this->formatSections($sections, $currentSections, 'personal'); |
|
87 | - |
|
88 | - return $templateParameters; |
|
89 | - } |
|
90 | - |
|
91 | - protected function formatAdminSections($currentSections) { |
|
92 | - $sections = $this->settingsManager->getAdminSections(); |
|
93 | - $templateParameters = $this->formatSections($sections, $currentSections, 'admin'); |
|
94 | - |
|
95 | - return $templateParameters; |
|
96 | - } |
|
97 | - |
|
98 | - /** |
|
99 | - * @param ISettings[] $settings |
|
100 | - * @return array |
|
101 | - */ |
|
102 | - private function formatSettings($settings) { |
|
103 | - $html = ''; |
|
104 | - foreach ($settings as $prioritizedSettings) { |
|
105 | - foreach ($prioritizedSettings as $setting) { |
|
106 | - /** @var \OCP\Settings\ISettings $setting */ |
|
107 | - $form = $setting->getForm(); |
|
108 | - $html .= $form->renderAs('')->render(); |
|
109 | - } |
|
110 | - } |
|
111 | - return ['content' => $html]; |
|
112 | - } |
|
113 | - |
|
114 | - private function getIndexResponse($section) { |
|
115 | - $templateParams = []; |
|
116 | - $templateParams = array_merge($templateParams, $this->getNavigationParameters($section)); |
|
117 | - $templateParams = array_merge($templateParams, $this->getSettings($section)); |
|
118 | - |
|
119 | - return new TemplateResponse('settings', 'settings/frame', $templateParams); |
|
120 | - } |
|
121 | - |
|
122 | - abstract public function getSettings($section); |
|
32 | + /** @var ISettingsManager */ |
|
33 | + private $settingsManager; |
|
34 | + |
|
35 | + /** |
|
36 | + * @param string $currentSection |
|
37 | + * @return array |
|
38 | + */ |
|
39 | + private function getNavigationParameters($currentSection) { |
|
40 | + $templateParameters = [ |
|
41 | + 'personal' => $this->formatPersonalSections($currentSection), |
|
42 | + 'admin' => [] |
|
43 | + ]; |
|
44 | + |
|
45 | + if(\OC_User::isAdminUser(\OC_User::getUser())) { |
|
46 | + $templateParameters['admin'] = $this->formatAdminSections($currentSection); |
|
47 | + } |
|
48 | + |
|
49 | + return [ |
|
50 | + 'forms' => $templateParameters |
|
51 | + ]; |
|
52 | + } |
|
53 | + |
|
54 | + protected function formatSections($sections, $currentSection, $type) { |
|
55 | + $templateParameters = []; |
|
56 | + /** @var \OCP\Settings\ISection[] $prioritizedSections */ |
|
57 | + foreach($sections as $prioritizedSections) { |
|
58 | + foreach ($prioritizedSections as $section) { |
|
59 | + if($type === 'admin') { |
|
60 | + $settings = $this->settingsManager->getAdminSettings($section->getID()); |
|
61 | + } else if($type === 'personal') { |
|
62 | + $settings = $this->settingsManager->getPersonalSettings($section->getID()); |
|
63 | + } |
|
64 | + if (empty($settings)) { |
|
65 | + continue; |
|
66 | + } |
|
67 | + |
|
68 | + $icon = ''; |
|
69 | + if ($section instanceof IIconSection) { |
|
70 | + $icon = $section->getIcon(); |
|
71 | + } |
|
72 | + |
|
73 | + $templateParameters[] = [ |
|
74 | + 'anchor' => $section->getID(), |
|
75 | + 'section-name' => $section->getName(), |
|
76 | + 'active' => $section->getID() === $currentSection, |
|
77 | + 'icon' => $icon, |
|
78 | + ]; |
|
79 | + } |
|
80 | + } |
|
81 | + return $templateParameters; |
|
82 | + } |
|
83 | + |
|
84 | + protected function formatPersonalSections($currentSections) { |
|
85 | + $sections = $this->settingsManager->getPersonalSections(); |
|
86 | + $templateParameters = $this->formatSections($sections, $currentSections, 'personal'); |
|
87 | + |
|
88 | + return $templateParameters; |
|
89 | + } |
|
90 | + |
|
91 | + protected function formatAdminSections($currentSections) { |
|
92 | + $sections = $this->settingsManager->getAdminSections(); |
|
93 | + $templateParameters = $this->formatSections($sections, $currentSections, 'admin'); |
|
94 | + |
|
95 | + return $templateParameters; |
|
96 | + } |
|
97 | + |
|
98 | + /** |
|
99 | + * @param ISettings[] $settings |
|
100 | + * @return array |
|
101 | + */ |
|
102 | + private function formatSettings($settings) { |
|
103 | + $html = ''; |
|
104 | + foreach ($settings as $prioritizedSettings) { |
|
105 | + foreach ($prioritizedSettings as $setting) { |
|
106 | + /** @var \OCP\Settings\ISettings $setting */ |
|
107 | + $form = $setting->getForm(); |
|
108 | + $html .= $form->renderAs('')->render(); |
|
109 | + } |
|
110 | + } |
|
111 | + return ['content' => $html]; |
|
112 | + } |
|
113 | + |
|
114 | + private function getIndexResponse($section) { |
|
115 | + $templateParams = []; |
|
116 | + $templateParams = array_merge($templateParams, $this->getNavigationParameters($section)); |
|
117 | + $templateParams = array_merge($templateParams, $this->getSettings($section)); |
|
118 | + |
|
119 | + return new TemplateResponse('settings', 'settings/frame', $templateParams); |
|
120 | + } |
|
121 | + |
|
122 | + abstract public function getSettings($section); |
|
123 | 123 | } |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | use OCP\Settings\IIconSection; |
29 | 29 | use OCP\Settings\ISettings; |
30 | 30 | |
31 | -trait CommonSettingsTrait { |
|
31 | +trait CommonSettingsTrait { |
|
32 | 32 | /** @var ISettingsManager */ |
33 | 33 | private $settingsManager; |
34 | 34 | |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | 'admin' => [] |
43 | 43 | ]; |
44 | 44 | |
45 | - if(\OC_User::isAdminUser(\OC_User::getUser())) { |
|
45 | + if (\OC_User::isAdminUser(\OC_User::getUser())) { |
|
46 | 46 | $templateParameters['admin'] = $this->formatAdminSections($currentSection); |
47 | 47 | } |
48 | 48 | |
@@ -54,11 +54,11 @@ discard block |
||
54 | 54 | protected function formatSections($sections, $currentSection, $type) { |
55 | 55 | $templateParameters = []; |
56 | 56 | /** @var \OCP\Settings\ISection[] $prioritizedSections */ |
57 | - foreach($sections as $prioritizedSections) { |
|
57 | + foreach ($sections as $prioritizedSections) { |
|
58 | 58 | foreach ($prioritizedSections as $section) { |
59 | - if($type === 'admin') { |
|
59 | + if ($type === 'admin') { |
|
60 | 60 | $settings = $this->settingsManager->getAdminSettings($section->getID()); |
61 | - } else if($type === 'personal') { |
|
61 | + } else if ($type === 'personal') { |
|
62 | 62 | $settings = $this->settingsManager->getPersonalSettings($section->getID()); |
63 | 63 | } |
64 | 64 | if (empty($settings)) { |
@@ -34,130 +34,130 @@ |
||
34 | 34 | use OCP\Settings\ISettings; |
35 | 35 | |
36 | 36 | class PersonalInfo implements ISettings { |
37 | - /** @var IConfig */ |
|
38 | - private $config; |
|
39 | - /** @var IUserManager */ |
|
40 | - private $userManager; |
|
41 | - /** @var AccountManager */ |
|
42 | - private $accountManager; |
|
43 | - /** @var IGroupManager */ |
|
44 | - private $groupManager; |
|
45 | - /** @var IFactory */ |
|
46 | - private $l10nFactory; |
|
47 | - |
|
48 | - /** |
|
49 | - * @param IConfig $config |
|
50 | - * @param IUserManager $userManager |
|
51 | - * @param IGroupManager $groupManager |
|
52 | - * @param AccountManager $accountManager |
|
53 | - * @param IFactory $l10nFactory |
|
54 | - */ |
|
55 | - public function __construct(IConfig $config, IUserManager $userManager, IGroupManager $groupManager, AccountManager $accountManager, IFactory $l10nFactory) { |
|
56 | - $this->config = $config; |
|
57 | - $this->userManager = $userManager; |
|
58 | - $this->accountManager = $accountManager; |
|
59 | - $this->groupManager = $groupManager; |
|
60 | - $this->l10nFactory = $l10nFactory; |
|
61 | - } |
|
62 | - |
|
63 | - /** |
|
64 | - * @return TemplateResponse returns the instance with all parameters set, ready to be rendered |
|
65 | - * @since 9.1 |
|
66 | - */ |
|
67 | - public function getForm() { |
|
68 | - $lookupServerUploadEnabled = $this->config->getAppValue('files_sharing', 'lookupServerUploadEnabled', 'yes'); |
|
69 | - $lookupServerUploadEnabled = $lookupServerUploadEnabled === 'yes'; |
|
70 | - |
|
71 | - $uid = \OC_User::getUser(); |
|
72 | - $user = $this->userManager->get($uid); |
|
73 | - |
|
74 | - $userData = $this->accountManager->getUser($user); |
|
75 | - |
|
76 | - $parameters = [ |
|
77 | - 'avatarChangeSupported' => \OC_User::canUserChangeAvatar($uid), |
|
78 | - 'lookupServerUploadEnabled' => $lookupServerUploadEnabled, |
|
79 | - 'avatar_scope' => $userData[AccountManager::PROPERTY_AVATAR]['scope'], |
|
80 | - 'displayNameChangeSupported' => \OC_User::canUserChangeDisplayName($uid), |
|
81 | - 'displayName' => $userData[AccountManager::PROPERTY_DISPLAYNAME]['value'], |
|
82 | - 'email' => $userData[AccountManager::PROPERTY_EMAIL]['value'], |
|
83 | - 'emailScope' => $userData[AccountManager::PROPERTY_EMAIL]['scope'], |
|
84 | - 'emailMesage' => '', |
|
85 | - 'emailVerification' => $userData[AccountManager::PROPERTY_EMAIL]['verified'], |
|
86 | - 'phone' => $userData[AccountManager::PROPERTY_PHONE]['value'], |
|
87 | - 'phoneScope' => $userData[AccountManager::PROPERTY_PHONE]['scope'], |
|
88 | - 'address', $userData[AccountManager::PROPERTY_ADDRESS]['value'], |
|
89 | - 'addressScope', $userData[AccountManager::PROPERTY_ADDRESS]['scope'], |
|
90 | - 'website' => $userData[AccountManager::PROPERTY_WEBSITE]['value'], |
|
91 | - 'websiteScope' => $userData[AccountManager::PROPERTY_WEBSITE]['scope'], |
|
92 | - 'websiteVerification' => $userData[AccountManager::PROPERTY_WEBSITE]['verified'], |
|
93 | - 'twitter' => $userData[AccountManager::PROPERTY_TWITTER]['value'], |
|
94 | - 'twitterScope' => $userData[AccountManager::PROPERTY_TWITTER]['scope'], |
|
95 | - 'twitterVerification' => $userData[AccountManager::PROPERTY_TWITTER]['verified'], |
|
96 | - 'groups' => $this->groupManager->getUserGroups($user), |
|
97 | - 'passwordChangeSupported' => \OC_User::canUserChangePassword($uid), |
|
98 | - 'activelanguage' => $this->getLanguage($user), |
|
99 | - ]; |
|
100 | - |
|
101 | - |
|
102 | - return new TemplateResponse('settings', 'settings/personal/personal.info', $parameters, ''); |
|
103 | - } |
|
104 | - |
|
105 | - /** |
|
106 | - * @return string the section ID, e.g. 'sharing' |
|
107 | - * @since 9.1 |
|
108 | - */ |
|
109 | - public function getSection() { |
|
110 | - return 'personal-info'; |
|
111 | - } |
|
112 | - |
|
113 | - /** |
|
114 | - * @return int whether the form should be rather on the top or bottom of |
|
115 | - * the admin section. The forms are arranged in ascending order of the |
|
116 | - * priority values. It is required to return a value between 0 and 100. |
|
117 | - * |
|
118 | - * E.g.: 70 |
|
119 | - * @since 9.1 |
|
120 | - */ |
|
121 | - public function getPriority() { |
|
122 | - return 10; |
|
123 | - } |
|
124 | - |
|
125 | - private function getLanguage(IUser $user) { |
|
126 | - $uid = $user->getUID(); |
|
127 | - |
|
128 | - $userLang = $this->config->getUserValue($uid, 'core', 'lang', $this->l10nFactory->findLanguage()); |
|
129 | - $languageCodes = $this->l10nFactory->findAvailableLanguages(); |
|
130 | - foreach($languageCodes as $lang) { |
|
131 | - $l = \OC::$server->getL10N('settings', $lang); |
|
132 | - // TRANSLATORS this is the language name for the language switcher in the personal settings and should be the localized version |
|
133 | - $potentialName = (string) $l->t('__language_name__'); |
|
134 | - if($l->getLanguageCode() === $lang && substr($potentialName, 0, 1) !== '_') {//first check if the language name is in the translation file |
|
135 | - $ln = array('code' => $lang, 'name' => $potentialName); |
|
136 | - } elseif ($lang === 'en') { |
|
137 | - $ln = ['code' => $lang, 'name' => 'English (US)']; |
|
138 | - }else{//fallback to language code |
|
139 | - $ln=array('code'=>$lang, 'name'=>$lang); |
|
140 | - } |
|
141 | - |
|
142 | - // put appropriate languages into appropriate arrays, to print them sorted |
|
143 | - // used language -> common languages -> divider -> other languages |
|
144 | - if ($lang === $userLang) { |
|
145 | - $userLang = $ln; |
|
146 | - } elseif (in_array($lang, $commonLangCodes)) { |
|
147 | - $commonLanguages[array_search($lang, $commonLangCodes)]=$ln; |
|
148 | - } else { |
|
149 | - $languages[]=$ln; |
|
150 | - } |
|
151 | - } |
|
152 | - |
|
153 | - // if user language is not available but set somehow: show the actual code as name |
|
154 | - if (!is_array($userLang)) { |
|
155 | - $userLang = [ |
|
156 | - 'code' => $userLang, |
|
157 | - 'name' => $userLang, |
|
158 | - ]; |
|
159 | - } |
|
160 | - |
|
161 | - return $userLang; |
|
162 | - } |
|
37 | + /** @var IConfig */ |
|
38 | + private $config; |
|
39 | + /** @var IUserManager */ |
|
40 | + private $userManager; |
|
41 | + /** @var AccountManager */ |
|
42 | + private $accountManager; |
|
43 | + /** @var IGroupManager */ |
|
44 | + private $groupManager; |
|
45 | + /** @var IFactory */ |
|
46 | + private $l10nFactory; |
|
47 | + |
|
48 | + /** |
|
49 | + * @param IConfig $config |
|
50 | + * @param IUserManager $userManager |
|
51 | + * @param IGroupManager $groupManager |
|
52 | + * @param AccountManager $accountManager |
|
53 | + * @param IFactory $l10nFactory |
|
54 | + */ |
|
55 | + public function __construct(IConfig $config, IUserManager $userManager, IGroupManager $groupManager, AccountManager $accountManager, IFactory $l10nFactory) { |
|
56 | + $this->config = $config; |
|
57 | + $this->userManager = $userManager; |
|
58 | + $this->accountManager = $accountManager; |
|
59 | + $this->groupManager = $groupManager; |
|
60 | + $this->l10nFactory = $l10nFactory; |
|
61 | + } |
|
62 | + |
|
63 | + /** |
|
64 | + * @return TemplateResponse returns the instance with all parameters set, ready to be rendered |
|
65 | + * @since 9.1 |
|
66 | + */ |
|
67 | + public function getForm() { |
|
68 | + $lookupServerUploadEnabled = $this->config->getAppValue('files_sharing', 'lookupServerUploadEnabled', 'yes'); |
|
69 | + $lookupServerUploadEnabled = $lookupServerUploadEnabled === 'yes'; |
|
70 | + |
|
71 | + $uid = \OC_User::getUser(); |
|
72 | + $user = $this->userManager->get($uid); |
|
73 | + |
|
74 | + $userData = $this->accountManager->getUser($user); |
|
75 | + |
|
76 | + $parameters = [ |
|
77 | + 'avatarChangeSupported' => \OC_User::canUserChangeAvatar($uid), |
|
78 | + 'lookupServerUploadEnabled' => $lookupServerUploadEnabled, |
|
79 | + 'avatar_scope' => $userData[AccountManager::PROPERTY_AVATAR]['scope'], |
|
80 | + 'displayNameChangeSupported' => \OC_User::canUserChangeDisplayName($uid), |
|
81 | + 'displayName' => $userData[AccountManager::PROPERTY_DISPLAYNAME]['value'], |
|
82 | + 'email' => $userData[AccountManager::PROPERTY_EMAIL]['value'], |
|
83 | + 'emailScope' => $userData[AccountManager::PROPERTY_EMAIL]['scope'], |
|
84 | + 'emailMesage' => '', |
|
85 | + 'emailVerification' => $userData[AccountManager::PROPERTY_EMAIL]['verified'], |
|
86 | + 'phone' => $userData[AccountManager::PROPERTY_PHONE]['value'], |
|
87 | + 'phoneScope' => $userData[AccountManager::PROPERTY_PHONE]['scope'], |
|
88 | + 'address', $userData[AccountManager::PROPERTY_ADDRESS]['value'], |
|
89 | + 'addressScope', $userData[AccountManager::PROPERTY_ADDRESS]['scope'], |
|
90 | + 'website' => $userData[AccountManager::PROPERTY_WEBSITE]['value'], |
|
91 | + 'websiteScope' => $userData[AccountManager::PROPERTY_WEBSITE]['scope'], |
|
92 | + 'websiteVerification' => $userData[AccountManager::PROPERTY_WEBSITE]['verified'], |
|
93 | + 'twitter' => $userData[AccountManager::PROPERTY_TWITTER]['value'], |
|
94 | + 'twitterScope' => $userData[AccountManager::PROPERTY_TWITTER]['scope'], |
|
95 | + 'twitterVerification' => $userData[AccountManager::PROPERTY_TWITTER]['verified'], |
|
96 | + 'groups' => $this->groupManager->getUserGroups($user), |
|
97 | + 'passwordChangeSupported' => \OC_User::canUserChangePassword($uid), |
|
98 | + 'activelanguage' => $this->getLanguage($user), |
|
99 | + ]; |
|
100 | + |
|
101 | + |
|
102 | + return new TemplateResponse('settings', 'settings/personal/personal.info', $parameters, ''); |
|
103 | + } |
|
104 | + |
|
105 | + /** |
|
106 | + * @return string the section ID, e.g. 'sharing' |
|
107 | + * @since 9.1 |
|
108 | + */ |
|
109 | + public function getSection() { |
|
110 | + return 'personal-info'; |
|
111 | + } |
|
112 | + |
|
113 | + /** |
|
114 | + * @return int whether the form should be rather on the top or bottom of |
|
115 | + * the admin section. The forms are arranged in ascending order of the |
|
116 | + * priority values. It is required to return a value between 0 and 100. |
|
117 | + * |
|
118 | + * E.g.: 70 |
|
119 | + * @since 9.1 |
|
120 | + */ |
|
121 | + public function getPriority() { |
|
122 | + return 10; |
|
123 | + } |
|
124 | + |
|
125 | + private function getLanguage(IUser $user) { |
|
126 | + $uid = $user->getUID(); |
|
127 | + |
|
128 | + $userLang = $this->config->getUserValue($uid, 'core', 'lang', $this->l10nFactory->findLanguage()); |
|
129 | + $languageCodes = $this->l10nFactory->findAvailableLanguages(); |
|
130 | + foreach($languageCodes as $lang) { |
|
131 | + $l = \OC::$server->getL10N('settings', $lang); |
|
132 | + // TRANSLATORS this is the language name for the language switcher in the personal settings and should be the localized version |
|
133 | + $potentialName = (string) $l->t('__language_name__'); |
|
134 | + if($l->getLanguageCode() === $lang && substr($potentialName, 0, 1) !== '_') {//first check if the language name is in the translation file |
|
135 | + $ln = array('code' => $lang, 'name' => $potentialName); |
|
136 | + } elseif ($lang === 'en') { |
|
137 | + $ln = ['code' => $lang, 'name' => 'English (US)']; |
|
138 | + }else{//fallback to language code |
|
139 | + $ln=array('code'=>$lang, 'name'=>$lang); |
|
140 | + } |
|
141 | + |
|
142 | + // put appropriate languages into appropriate arrays, to print them sorted |
|
143 | + // used language -> common languages -> divider -> other languages |
|
144 | + if ($lang === $userLang) { |
|
145 | + $userLang = $ln; |
|
146 | + } elseif (in_array($lang, $commonLangCodes)) { |
|
147 | + $commonLanguages[array_search($lang, $commonLangCodes)]=$ln; |
|
148 | + } else { |
|
149 | + $languages[]=$ln; |
|
150 | + } |
|
151 | + } |
|
152 | + |
|
153 | + // if user language is not available but set somehow: show the actual code as name |
|
154 | + if (!is_array($userLang)) { |
|
155 | + $userLang = [ |
|
156 | + 'code' => $userLang, |
|
157 | + 'name' => $userLang, |
|
158 | + ]; |
|
159 | + } |
|
160 | + |
|
161 | + return $userLang; |
|
162 | + } |
|
163 | 163 | } |
@@ -127,16 +127,16 @@ discard block |
||
127 | 127 | |
128 | 128 | $userLang = $this->config->getUserValue($uid, 'core', 'lang', $this->l10nFactory->findLanguage()); |
129 | 129 | $languageCodes = $this->l10nFactory->findAvailableLanguages(); |
130 | - foreach($languageCodes as $lang) { |
|
130 | + foreach ($languageCodes as $lang) { |
|
131 | 131 | $l = \OC::$server->getL10N('settings', $lang); |
132 | 132 | // TRANSLATORS this is the language name for the language switcher in the personal settings and should be the localized version |
133 | 133 | $potentialName = (string) $l->t('__language_name__'); |
134 | - if($l->getLanguageCode() === $lang && substr($potentialName, 0, 1) !== '_') {//first check if the language name is in the translation file |
|
134 | + if ($l->getLanguageCode() === $lang && substr($potentialName, 0, 1) !== '_') {//first check if the language name is in the translation file |
|
135 | 135 | $ln = array('code' => $lang, 'name' => $potentialName); |
136 | 136 | } elseif ($lang === 'en') { |
137 | 137 | $ln = ['code' => $lang, 'name' => 'English (US)']; |
138 | - }else{//fallback to language code |
|
139 | - $ln=array('code'=>$lang, 'name'=>$lang); |
|
138 | + } else {//fallback to language code |
|
139 | + $ln = array('code'=>$lang, 'name'=>$lang); |
|
140 | 140 | } |
141 | 141 | |
142 | 142 | // put appropriate languages into appropriate arrays, to print them sorted |
@@ -144,9 +144,9 @@ discard block |
||
144 | 144 | if ($lang === $userLang) { |
145 | 145 | $userLang = $ln; |
146 | 146 | } elseif (in_array($lang, $commonLangCodes)) { |
147 | - $commonLanguages[array_search($lang, $commonLangCodes)]=$ln; |
|
147 | + $commonLanguages[array_search($lang, $commonLangCodes)] = $ln; |
|
148 | 148 | } else { |
149 | - $languages[]=$ln; |
|
149 | + $languages[] = $ln; |
|
150 | 150 | } |
151 | 151 | } |
152 | 152 |
@@ -135,7 +135,7 @@ |
||
135 | 135 | $ln = array('code' => $lang, 'name' => $potentialName); |
136 | 136 | } elseif ($lang === 'en') { |
137 | 137 | $ln = ['code' => $lang, 'name' => 'English (US)']; |
138 | - }else{//fallback to language code |
|
138 | + } else{//fallback to language code |
|
139 | 139 | $ln=array('code'=>$lang, 'name'=>$lang); |
140 | 140 | } |
141 | 141 |
@@ -41,375 +41,375 @@ |
||
41 | 41 | use OCP\Settings\ISection; |
42 | 42 | |
43 | 43 | class Manager implements IManager { |
44 | - const TABLE_ADMIN_SETTINGS = 'admin_settings'; |
|
45 | - const TABLE_ADMIN_SECTIONS = 'admin_sections'; |
|
46 | - |
|
47 | - /** @var ILogger */ |
|
48 | - private $log; |
|
49 | - /** @var IDBConnection */ |
|
50 | - private $dbc; |
|
51 | - /** @var Mapper */ |
|
52 | - private $mapper; |
|
53 | - /** @var IL10N */ |
|
54 | - private $l; |
|
55 | - /** @var IConfig */ |
|
56 | - private $config; |
|
57 | - /** @var EncryptionManager */ |
|
58 | - private $encryptionManager; |
|
59 | - /** @var IUserManager */ |
|
60 | - private $userManager; |
|
61 | - /** @var ILockingProvider */ |
|
62 | - private $lockingProvider; |
|
63 | - /** @var IRequest */ |
|
64 | - private $request; |
|
65 | - /** @var IURLGenerator */ |
|
66 | - private $url; |
|
67 | - /** @var AccountManager */ |
|
68 | - private $accountManager; |
|
69 | - /** @var IGroupManager */ |
|
70 | - private $groupManager; |
|
71 | - /** @var IFactory */ |
|
72 | - private $l10nFactory; |
|
73 | - |
|
74 | - /** |
|
75 | - * @param ILogger $log |
|
76 | - * @param IDBConnection $dbc |
|
77 | - * @param IL10N $l |
|
78 | - * @param IConfig $config |
|
79 | - * @param EncryptionManager $encryptionManager |
|
80 | - * @param IUserManager $userManager |
|
81 | - * @param ILockingProvider $lockingProvider |
|
82 | - * @param IRequest $request |
|
83 | - * @param Mapper $mapper |
|
84 | - * @param IURLGenerator $url |
|
85 | - * @param AccountManager $accountManager |
|
86 | - * @param IGroupManager $groupManager |
|
87 | - * @param IFactory $l10nFactory |
|
88 | - */ |
|
89 | - public function __construct( |
|
90 | - ILogger $log, |
|
91 | - IDBConnection $dbc, |
|
92 | - IL10N $l, |
|
93 | - IConfig $config, |
|
94 | - EncryptionManager $encryptionManager, |
|
95 | - IUserManager $userManager, |
|
96 | - ILockingProvider $lockingProvider, |
|
97 | - IRequest $request, |
|
98 | - Mapper $mapper, |
|
99 | - IURLGenerator $url, |
|
100 | - AccountManager $accountManager, |
|
101 | - IGroupManager $groupManager, |
|
102 | - IFactory $l10nFactory |
|
103 | - ) { |
|
104 | - $this->log = $log; |
|
105 | - $this->dbc = $dbc; |
|
106 | - $this->mapper = $mapper; |
|
107 | - $this->l = $l; |
|
108 | - $this->config = $config; |
|
109 | - $this->encryptionManager = $encryptionManager; |
|
110 | - $this->userManager = $userManager; |
|
111 | - $this->lockingProvider = $lockingProvider; |
|
112 | - $this->request = $request; |
|
113 | - $this->url = $url; |
|
114 | - $this->accountManager = $accountManager; |
|
115 | - $this->groupManager = $groupManager; |
|
116 | - $this->l10nFactory = $l10nFactory; |
|
117 | - } |
|
118 | - |
|
119 | - /** |
|
120 | - * @inheritdoc |
|
121 | - */ |
|
122 | - public function setupSettings(array $settings) { |
|
123 | - if (isset($settings[IManager::KEY_ADMIN_SECTION])) { |
|
124 | - $this->setupAdminSection($settings[IManager::KEY_ADMIN_SECTION]); |
|
125 | - } |
|
126 | - if (isset($settings[IManager::KEY_ADMIN_SETTINGS])) { |
|
127 | - $this->setupAdminSettings($settings[IManager::KEY_ADMIN_SETTINGS]); |
|
128 | - } |
|
129 | - } |
|
130 | - |
|
131 | - /** |
|
132 | - * attempts to remove an apps section and/or settings entry. A listener is |
|
133 | - * added centrally making sure that this method is called ones an app was |
|
134 | - * disabled. |
|
135 | - * |
|
136 | - * @param string $appId |
|
137 | - * @since 9.1.0 |
|
138 | - */ |
|
139 | - public function onAppDisabled($appId) { |
|
140 | - $appInfo = \OC_App::getAppInfo($appId); // hello static legacy |
|
141 | - |
|
142 | - if (isset($appInfo['settings'][IManager::KEY_ADMIN_SECTION])) { |
|
143 | - $this->mapper->remove(self::TABLE_ADMIN_SECTIONS, trim($appInfo['settings'][IManager::KEY_ADMIN_SECTION], '\\')); |
|
144 | - } |
|
145 | - if (isset($appInfo['settings'][IManager::KEY_ADMIN_SETTINGS])) { |
|
146 | - $this->mapper->remove(self::TABLE_ADMIN_SETTINGS, trim($appInfo['settings'][IManager::KEY_ADMIN_SETTINGS], '\\')); |
|
147 | - } |
|
148 | - } |
|
149 | - |
|
150 | - public function checkForOrphanedClassNames() { |
|
151 | - $tables = [self::TABLE_ADMIN_SECTIONS, self::TABLE_ADMIN_SETTINGS]; |
|
152 | - foreach ($tables as $table) { |
|
153 | - $classes = $this->mapper->getClasses($table); |
|
154 | - foreach ($classes as $className) { |
|
155 | - try { |
|
156 | - \OC::$server->query($className); |
|
157 | - } catch (QueryException $e) { |
|
158 | - $this->mapper->remove($table, $className); |
|
159 | - } |
|
160 | - } |
|
161 | - } |
|
162 | - } |
|
163 | - |
|
164 | - /** |
|
165 | - * @param string $sectionClassName |
|
166 | - */ |
|
167 | - private function setupAdminSection($sectionClassName) { |
|
168 | - if (!class_exists($sectionClassName)) { |
|
169 | - $this->log->debug('Could not find admin section class ' . $sectionClassName); |
|
170 | - return; |
|
171 | - } |
|
172 | - try { |
|
173 | - $section = $this->query($sectionClassName); |
|
174 | - } catch (QueryException $e) { |
|
175 | - // cancel |
|
176 | - return; |
|
177 | - } |
|
178 | - |
|
179 | - if (!$section instanceof ISection) { |
|
180 | - $this->log->error( |
|
181 | - 'Admin section instance must implement \OCP\ISection. Invalid class: {class}', |
|
182 | - ['class' => $sectionClassName] |
|
183 | - ); |
|
184 | - return; |
|
185 | - } |
|
186 | - if (!$this->hasAdminSection(get_class($section))) { |
|
187 | - $this->addAdminSection($section); |
|
188 | - } else { |
|
189 | - $this->updateAdminSection($section); |
|
190 | - } |
|
191 | - } |
|
192 | - |
|
193 | - private function addAdminSection(ISection $section) { |
|
194 | - $this->mapper->add(self::TABLE_ADMIN_SECTIONS, [ |
|
195 | - 'id' => $section->getID(), |
|
196 | - 'class' => get_class($section), |
|
197 | - 'priority' => $section->getPriority(), |
|
198 | - ]); |
|
199 | - } |
|
200 | - |
|
201 | - private function addAdminSettings(ISettings $settings) { |
|
202 | - $this->mapper->add(self::TABLE_ADMIN_SETTINGS, [ |
|
203 | - 'class' => get_class($settings), |
|
204 | - 'section' => $settings->getSection(), |
|
205 | - 'priority' => $settings->getPriority(), |
|
206 | - ]); |
|
207 | - } |
|
208 | - |
|
209 | - private function updateAdminSettings(ISettings $settings) { |
|
210 | - $this->mapper->update( |
|
211 | - self::TABLE_ADMIN_SETTINGS, |
|
212 | - 'class', |
|
213 | - get_class($settings), |
|
214 | - [ |
|
215 | - 'section' => $settings->getSection(), |
|
216 | - 'priority' => $settings->getPriority(), |
|
217 | - ] |
|
218 | - ); |
|
219 | - } |
|
220 | - |
|
221 | - private function updateAdminSection(ISection $section) { |
|
222 | - $this->mapper->update( |
|
223 | - self::TABLE_ADMIN_SECTIONS, |
|
224 | - 'class', |
|
225 | - get_class($section), |
|
226 | - [ |
|
227 | - 'id' => $section->getID(), |
|
228 | - 'priority' => $section->getPriority(), |
|
229 | - ] |
|
230 | - ); |
|
231 | - } |
|
232 | - |
|
233 | - /** |
|
234 | - * @param string $className |
|
235 | - * @return bool |
|
236 | - */ |
|
237 | - private function hasAdminSection($className) { |
|
238 | - return $this->mapper->has(self::TABLE_ADMIN_SECTIONS, $className); |
|
239 | - } |
|
240 | - |
|
241 | - /** |
|
242 | - * @param string $className |
|
243 | - * @return bool |
|
244 | - */ |
|
245 | - private function hasAdminSettings($className) { |
|
246 | - return $this->mapper->has(self::TABLE_ADMIN_SETTINGS, $className); |
|
247 | - } |
|
248 | - |
|
249 | - private function setupAdminSettings($settingsClassName) { |
|
250 | - if (!class_exists($settingsClassName)) { |
|
251 | - $this->log->debug('Could not find admin section class ' . $settingsClassName); |
|
252 | - return; |
|
253 | - } |
|
254 | - |
|
255 | - try { |
|
256 | - /** @var ISettings $settings */ |
|
257 | - $settings = $this->query($settingsClassName); |
|
258 | - } catch (QueryException $e) { |
|
259 | - // cancel |
|
260 | - return; |
|
261 | - } |
|
262 | - |
|
263 | - if (!$settings instanceof ISettings) { |
|
264 | - $this->log->error( |
|
265 | - 'Admin section instance must implement \OCP\Settings\ISection. Invalid class: {class}', |
|
266 | - ['class' => $settingsClassName] |
|
267 | - ); |
|
268 | - return; |
|
269 | - } |
|
270 | - if (!$this->hasAdminSettings(get_class($settings))) { |
|
271 | - $this->addAdminSettings($settings); |
|
272 | - } else { |
|
273 | - $this->updateAdminSettings($settings); |
|
274 | - } |
|
275 | - } |
|
276 | - |
|
277 | - private function query($className) { |
|
278 | - try { |
|
279 | - return \OC::$server->query($className); |
|
280 | - } catch (QueryException $e) { |
|
281 | - $this->log->logException($e); |
|
282 | - throw $e; |
|
283 | - } |
|
284 | - } |
|
285 | - |
|
286 | - /** |
|
287 | - * @inheritdoc |
|
288 | - */ |
|
289 | - public function getAdminSections() { |
|
290 | - // built-in sections |
|
291 | - $sections = [ |
|
292 | - 0 => [new Section('server', $this->l->t('Basic settings'), 0, $this->url->imagePath('settings', 'admin.svg'))], |
|
293 | - 5 => [new Section('sharing', $this->l->t('Sharing'), 0, $this->url->imagePath('core', 'actions/share.svg'))], |
|
294 | - 10 => [new Section('security', $this->l->t('Security'), 0, $this->url->imagePath('core', 'actions/password.svg'))], |
|
295 | - 45 => [new Section('encryption', $this->l->t('Encryption'), 0, $this->url->imagePath('core', 'actions/password.svg'))], |
|
296 | - 98 => [new Section('additional', $this->l->t('Additional settings'), 0, $this->url->imagePath('core', 'actions/settings-dark.svg'))], |
|
297 | - 99 => [new Section('tips-tricks', $this->l->t('Tips & tricks'), 0, $this->url->imagePath('settings', 'help.svg'))], |
|
298 | - ]; |
|
299 | - |
|
300 | - $rows = $this->mapper->getAdminSectionsFromDB(); |
|
301 | - |
|
302 | - foreach ($rows as $row) { |
|
303 | - if (!isset($sections[$row['priority']])) { |
|
304 | - $sections[$row['priority']] = []; |
|
305 | - } |
|
306 | - try { |
|
307 | - $sections[$row['priority']][] = $this->query($row['class']); |
|
308 | - } catch (QueryException $e) { |
|
309 | - // skip |
|
310 | - } |
|
311 | - } |
|
312 | - |
|
313 | - ksort($sections); |
|
314 | - |
|
315 | - return $sections; |
|
316 | - } |
|
317 | - |
|
318 | - /** |
|
319 | - * @param string $section |
|
320 | - * @return ISection[] |
|
321 | - */ |
|
322 | - private function getBuiltInAdminSettings($section) { |
|
323 | - $forms = []; |
|
324 | - try { |
|
325 | - if ($section === 'server') { |
|
326 | - /** @var ISettings $form */ |
|
327 | - $form = new Admin\Server($this->dbc, $this->request, $this->config, $this->lockingProvider, $this->l); |
|
328 | - $forms[$form->getPriority()] = [$form]; |
|
329 | - $form = new Admin\ServerDevNotice(); |
|
330 | - $forms[$form->getPriority()] = [$form]; |
|
331 | - } |
|
332 | - if ($section === 'encryption') { |
|
333 | - /** @var ISettings $form */ |
|
334 | - $form = new Admin\Encryption($this->encryptionManager, $this->userManager); |
|
335 | - $forms[$form->getPriority()] = [$form]; |
|
336 | - } |
|
337 | - if ($section === 'sharing') { |
|
338 | - /** @var ISettings $form */ |
|
339 | - $form = new Admin\Sharing($this->config); |
|
340 | - $forms[$form->getPriority()] = [$form]; |
|
341 | - } |
|
342 | - if ($section === 'additional') { |
|
343 | - /** @var ISettings $form */ |
|
344 | - $form = new Admin\Additional($this->config); |
|
345 | - $forms[$form->getPriority()] = [$form]; |
|
346 | - } |
|
347 | - if ($section === 'tips-tricks') { |
|
348 | - /** @var ISettings $form */ |
|
349 | - $form = new Admin\TipsTricks($this->config); |
|
350 | - $forms[$form->getPriority()] = [$form]; |
|
351 | - } |
|
352 | - } catch (QueryException $e) { |
|
353 | - // skip |
|
354 | - } |
|
355 | - return $forms; |
|
356 | - } |
|
357 | - |
|
358 | - /** |
|
359 | - * @param string $section |
|
360 | - * @return ISection[] |
|
361 | - */ |
|
362 | - private function getBuiltInPersonalSettings($section) { |
|
363 | - $forms = []; |
|
364 | - try { |
|
365 | - if ($section === 'personal-info') { |
|
366 | - /** @var ISettings $form */ |
|
367 | - $form = new Personal\PersonalInfo($this->config, $this->userManager, $this->groupManager, $this->accountManager, $this->l10nFactory); |
|
368 | - $forms[$form->getPriority()] = [$form]; |
|
369 | - } |
|
370 | - } catch (QueryException $e) { |
|
371 | - // skip |
|
372 | - } |
|
373 | - return $forms; |
|
374 | - } |
|
375 | - |
|
376 | - /** |
|
377 | - * @inheritdoc |
|
378 | - */ |
|
379 | - public function getAdminSettings($section) { |
|
380 | - $settings = $this->getBuiltInAdminSettings($section); |
|
381 | - $dbRows = $this->mapper->getAdminSettingsFromDB($section); |
|
382 | - |
|
383 | - foreach ($dbRows as $row) { |
|
384 | - if (!isset($settings[$row['priority']])) { |
|
385 | - $settings[$row['priority']] = []; |
|
386 | - } |
|
387 | - try { |
|
388 | - $settings[$row['priority']][] = $this->query($row['class']); |
|
389 | - } catch (QueryException $e) { |
|
390 | - // skip |
|
391 | - } |
|
392 | - } |
|
393 | - |
|
394 | - ksort($settings); |
|
395 | - return $settings; |
|
396 | - } |
|
397 | - |
|
398 | - /** |
|
399 | - * @inheritdoc |
|
400 | - */ |
|
401 | - public function getPersonalSections() { |
|
402 | - $sections = [ |
|
403 | - 0 => [new Section('personal-info', $this->l->t('Personal info'), 0, $this->url->imagePath('core', 'actions/info.svg'))], |
|
404 | - ]; |
|
405 | - return $sections; |
|
406 | - } |
|
407 | - |
|
408 | - /** |
|
409 | - * @inheritdoc |
|
410 | - */ |
|
411 | - public function getPersonalSettings($section) { |
|
412 | - $settings = $this->getBuiltInPersonalSettings($section); |
|
413 | - return $settings; |
|
414 | - } |
|
44 | + const TABLE_ADMIN_SETTINGS = 'admin_settings'; |
|
45 | + const TABLE_ADMIN_SECTIONS = 'admin_sections'; |
|
46 | + |
|
47 | + /** @var ILogger */ |
|
48 | + private $log; |
|
49 | + /** @var IDBConnection */ |
|
50 | + private $dbc; |
|
51 | + /** @var Mapper */ |
|
52 | + private $mapper; |
|
53 | + /** @var IL10N */ |
|
54 | + private $l; |
|
55 | + /** @var IConfig */ |
|
56 | + private $config; |
|
57 | + /** @var EncryptionManager */ |
|
58 | + private $encryptionManager; |
|
59 | + /** @var IUserManager */ |
|
60 | + private $userManager; |
|
61 | + /** @var ILockingProvider */ |
|
62 | + private $lockingProvider; |
|
63 | + /** @var IRequest */ |
|
64 | + private $request; |
|
65 | + /** @var IURLGenerator */ |
|
66 | + private $url; |
|
67 | + /** @var AccountManager */ |
|
68 | + private $accountManager; |
|
69 | + /** @var IGroupManager */ |
|
70 | + private $groupManager; |
|
71 | + /** @var IFactory */ |
|
72 | + private $l10nFactory; |
|
73 | + |
|
74 | + /** |
|
75 | + * @param ILogger $log |
|
76 | + * @param IDBConnection $dbc |
|
77 | + * @param IL10N $l |
|
78 | + * @param IConfig $config |
|
79 | + * @param EncryptionManager $encryptionManager |
|
80 | + * @param IUserManager $userManager |
|
81 | + * @param ILockingProvider $lockingProvider |
|
82 | + * @param IRequest $request |
|
83 | + * @param Mapper $mapper |
|
84 | + * @param IURLGenerator $url |
|
85 | + * @param AccountManager $accountManager |
|
86 | + * @param IGroupManager $groupManager |
|
87 | + * @param IFactory $l10nFactory |
|
88 | + */ |
|
89 | + public function __construct( |
|
90 | + ILogger $log, |
|
91 | + IDBConnection $dbc, |
|
92 | + IL10N $l, |
|
93 | + IConfig $config, |
|
94 | + EncryptionManager $encryptionManager, |
|
95 | + IUserManager $userManager, |
|
96 | + ILockingProvider $lockingProvider, |
|
97 | + IRequest $request, |
|
98 | + Mapper $mapper, |
|
99 | + IURLGenerator $url, |
|
100 | + AccountManager $accountManager, |
|
101 | + IGroupManager $groupManager, |
|
102 | + IFactory $l10nFactory |
|
103 | + ) { |
|
104 | + $this->log = $log; |
|
105 | + $this->dbc = $dbc; |
|
106 | + $this->mapper = $mapper; |
|
107 | + $this->l = $l; |
|
108 | + $this->config = $config; |
|
109 | + $this->encryptionManager = $encryptionManager; |
|
110 | + $this->userManager = $userManager; |
|
111 | + $this->lockingProvider = $lockingProvider; |
|
112 | + $this->request = $request; |
|
113 | + $this->url = $url; |
|
114 | + $this->accountManager = $accountManager; |
|
115 | + $this->groupManager = $groupManager; |
|
116 | + $this->l10nFactory = $l10nFactory; |
|
117 | + } |
|
118 | + |
|
119 | + /** |
|
120 | + * @inheritdoc |
|
121 | + */ |
|
122 | + public function setupSettings(array $settings) { |
|
123 | + if (isset($settings[IManager::KEY_ADMIN_SECTION])) { |
|
124 | + $this->setupAdminSection($settings[IManager::KEY_ADMIN_SECTION]); |
|
125 | + } |
|
126 | + if (isset($settings[IManager::KEY_ADMIN_SETTINGS])) { |
|
127 | + $this->setupAdminSettings($settings[IManager::KEY_ADMIN_SETTINGS]); |
|
128 | + } |
|
129 | + } |
|
130 | + |
|
131 | + /** |
|
132 | + * attempts to remove an apps section and/or settings entry. A listener is |
|
133 | + * added centrally making sure that this method is called ones an app was |
|
134 | + * disabled. |
|
135 | + * |
|
136 | + * @param string $appId |
|
137 | + * @since 9.1.0 |
|
138 | + */ |
|
139 | + public function onAppDisabled($appId) { |
|
140 | + $appInfo = \OC_App::getAppInfo($appId); // hello static legacy |
|
141 | + |
|
142 | + if (isset($appInfo['settings'][IManager::KEY_ADMIN_SECTION])) { |
|
143 | + $this->mapper->remove(self::TABLE_ADMIN_SECTIONS, trim($appInfo['settings'][IManager::KEY_ADMIN_SECTION], '\\')); |
|
144 | + } |
|
145 | + if (isset($appInfo['settings'][IManager::KEY_ADMIN_SETTINGS])) { |
|
146 | + $this->mapper->remove(self::TABLE_ADMIN_SETTINGS, trim($appInfo['settings'][IManager::KEY_ADMIN_SETTINGS], '\\')); |
|
147 | + } |
|
148 | + } |
|
149 | + |
|
150 | + public function checkForOrphanedClassNames() { |
|
151 | + $tables = [self::TABLE_ADMIN_SECTIONS, self::TABLE_ADMIN_SETTINGS]; |
|
152 | + foreach ($tables as $table) { |
|
153 | + $classes = $this->mapper->getClasses($table); |
|
154 | + foreach ($classes as $className) { |
|
155 | + try { |
|
156 | + \OC::$server->query($className); |
|
157 | + } catch (QueryException $e) { |
|
158 | + $this->mapper->remove($table, $className); |
|
159 | + } |
|
160 | + } |
|
161 | + } |
|
162 | + } |
|
163 | + |
|
164 | + /** |
|
165 | + * @param string $sectionClassName |
|
166 | + */ |
|
167 | + private function setupAdminSection($sectionClassName) { |
|
168 | + if (!class_exists($sectionClassName)) { |
|
169 | + $this->log->debug('Could not find admin section class ' . $sectionClassName); |
|
170 | + return; |
|
171 | + } |
|
172 | + try { |
|
173 | + $section = $this->query($sectionClassName); |
|
174 | + } catch (QueryException $e) { |
|
175 | + // cancel |
|
176 | + return; |
|
177 | + } |
|
178 | + |
|
179 | + if (!$section instanceof ISection) { |
|
180 | + $this->log->error( |
|
181 | + 'Admin section instance must implement \OCP\ISection. Invalid class: {class}', |
|
182 | + ['class' => $sectionClassName] |
|
183 | + ); |
|
184 | + return; |
|
185 | + } |
|
186 | + if (!$this->hasAdminSection(get_class($section))) { |
|
187 | + $this->addAdminSection($section); |
|
188 | + } else { |
|
189 | + $this->updateAdminSection($section); |
|
190 | + } |
|
191 | + } |
|
192 | + |
|
193 | + private function addAdminSection(ISection $section) { |
|
194 | + $this->mapper->add(self::TABLE_ADMIN_SECTIONS, [ |
|
195 | + 'id' => $section->getID(), |
|
196 | + 'class' => get_class($section), |
|
197 | + 'priority' => $section->getPriority(), |
|
198 | + ]); |
|
199 | + } |
|
200 | + |
|
201 | + private function addAdminSettings(ISettings $settings) { |
|
202 | + $this->mapper->add(self::TABLE_ADMIN_SETTINGS, [ |
|
203 | + 'class' => get_class($settings), |
|
204 | + 'section' => $settings->getSection(), |
|
205 | + 'priority' => $settings->getPriority(), |
|
206 | + ]); |
|
207 | + } |
|
208 | + |
|
209 | + private function updateAdminSettings(ISettings $settings) { |
|
210 | + $this->mapper->update( |
|
211 | + self::TABLE_ADMIN_SETTINGS, |
|
212 | + 'class', |
|
213 | + get_class($settings), |
|
214 | + [ |
|
215 | + 'section' => $settings->getSection(), |
|
216 | + 'priority' => $settings->getPriority(), |
|
217 | + ] |
|
218 | + ); |
|
219 | + } |
|
220 | + |
|
221 | + private function updateAdminSection(ISection $section) { |
|
222 | + $this->mapper->update( |
|
223 | + self::TABLE_ADMIN_SECTIONS, |
|
224 | + 'class', |
|
225 | + get_class($section), |
|
226 | + [ |
|
227 | + 'id' => $section->getID(), |
|
228 | + 'priority' => $section->getPriority(), |
|
229 | + ] |
|
230 | + ); |
|
231 | + } |
|
232 | + |
|
233 | + /** |
|
234 | + * @param string $className |
|
235 | + * @return bool |
|
236 | + */ |
|
237 | + private function hasAdminSection($className) { |
|
238 | + return $this->mapper->has(self::TABLE_ADMIN_SECTIONS, $className); |
|
239 | + } |
|
240 | + |
|
241 | + /** |
|
242 | + * @param string $className |
|
243 | + * @return bool |
|
244 | + */ |
|
245 | + private function hasAdminSettings($className) { |
|
246 | + return $this->mapper->has(self::TABLE_ADMIN_SETTINGS, $className); |
|
247 | + } |
|
248 | + |
|
249 | + private function setupAdminSettings($settingsClassName) { |
|
250 | + if (!class_exists($settingsClassName)) { |
|
251 | + $this->log->debug('Could not find admin section class ' . $settingsClassName); |
|
252 | + return; |
|
253 | + } |
|
254 | + |
|
255 | + try { |
|
256 | + /** @var ISettings $settings */ |
|
257 | + $settings = $this->query($settingsClassName); |
|
258 | + } catch (QueryException $e) { |
|
259 | + // cancel |
|
260 | + return; |
|
261 | + } |
|
262 | + |
|
263 | + if (!$settings instanceof ISettings) { |
|
264 | + $this->log->error( |
|
265 | + 'Admin section instance must implement \OCP\Settings\ISection. Invalid class: {class}', |
|
266 | + ['class' => $settingsClassName] |
|
267 | + ); |
|
268 | + return; |
|
269 | + } |
|
270 | + if (!$this->hasAdminSettings(get_class($settings))) { |
|
271 | + $this->addAdminSettings($settings); |
|
272 | + } else { |
|
273 | + $this->updateAdminSettings($settings); |
|
274 | + } |
|
275 | + } |
|
276 | + |
|
277 | + private function query($className) { |
|
278 | + try { |
|
279 | + return \OC::$server->query($className); |
|
280 | + } catch (QueryException $e) { |
|
281 | + $this->log->logException($e); |
|
282 | + throw $e; |
|
283 | + } |
|
284 | + } |
|
285 | + |
|
286 | + /** |
|
287 | + * @inheritdoc |
|
288 | + */ |
|
289 | + public function getAdminSections() { |
|
290 | + // built-in sections |
|
291 | + $sections = [ |
|
292 | + 0 => [new Section('server', $this->l->t('Basic settings'), 0, $this->url->imagePath('settings', 'admin.svg'))], |
|
293 | + 5 => [new Section('sharing', $this->l->t('Sharing'), 0, $this->url->imagePath('core', 'actions/share.svg'))], |
|
294 | + 10 => [new Section('security', $this->l->t('Security'), 0, $this->url->imagePath('core', 'actions/password.svg'))], |
|
295 | + 45 => [new Section('encryption', $this->l->t('Encryption'), 0, $this->url->imagePath('core', 'actions/password.svg'))], |
|
296 | + 98 => [new Section('additional', $this->l->t('Additional settings'), 0, $this->url->imagePath('core', 'actions/settings-dark.svg'))], |
|
297 | + 99 => [new Section('tips-tricks', $this->l->t('Tips & tricks'), 0, $this->url->imagePath('settings', 'help.svg'))], |
|
298 | + ]; |
|
299 | + |
|
300 | + $rows = $this->mapper->getAdminSectionsFromDB(); |
|
301 | + |
|
302 | + foreach ($rows as $row) { |
|
303 | + if (!isset($sections[$row['priority']])) { |
|
304 | + $sections[$row['priority']] = []; |
|
305 | + } |
|
306 | + try { |
|
307 | + $sections[$row['priority']][] = $this->query($row['class']); |
|
308 | + } catch (QueryException $e) { |
|
309 | + // skip |
|
310 | + } |
|
311 | + } |
|
312 | + |
|
313 | + ksort($sections); |
|
314 | + |
|
315 | + return $sections; |
|
316 | + } |
|
317 | + |
|
318 | + /** |
|
319 | + * @param string $section |
|
320 | + * @return ISection[] |
|
321 | + */ |
|
322 | + private function getBuiltInAdminSettings($section) { |
|
323 | + $forms = []; |
|
324 | + try { |
|
325 | + if ($section === 'server') { |
|
326 | + /** @var ISettings $form */ |
|
327 | + $form = new Admin\Server($this->dbc, $this->request, $this->config, $this->lockingProvider, $this->l); |
|
328 | + $forms[$form->getPriority()] = [$form]; |
|
329 | + $form = new Admin\ServerDevNotice(); |
|
330 | + $forms[$form->getPriority()] = [$form]; |
|
331 | + } |
|
332 | + if ($section === 'encryption') { |
|
333 | + /** @var ISettings $form */ |
|
334 | + $form = new Admin\Encryption($this->encryptionManager, $this->userManager); |
|
335 | + $forms[$form->getPriority()] = [$form]; |
|
336 | + } |
|
337 | + if ($section === 'sharing') { |
|
338 | + /** @var ISettings $form */ |
|
339 | + $form = new Admin\Sharing($this->config); |
|
340 | + $forms[$form->getPriority()] = [$form]; |
|
341 | + } |
|
342 | + if ($section === 'additional') { |
|
343 | + /** @var ISettings $form */ |
|
344 | + $form = new Admin\Additional($this->config); |
|
345 | + $forms[$form->getPriority()] = [$form]; |
|
346 | + } |
|
347 | + if ($section === 'tips-tricks') { |
|
348 | + /** @var ISettings $form */ |
|
349 | + $form = new Admin\TipsTricks($this->config); |
|
350 | + $forms[$form->getPriority()] = [$form]; |
|
351 | + } |
|
352 | + } catch (QueryException $e) { |
|
353 | + // skip |
|
354 | + } |
|
355 | + return $forms; |
|
356 | + } |
|
357 | + |
|
358 | + /** |
|
359 | + * @param string $section |
|
360 | + * @return ISection[] |
|
361 | + */ |
|
362 | + private function getBuiltInPersonalSettings($section) { |
|
363 | + $forms = []; |
|
364 | + try { |
|
365 | + if ($section === 'personal-info') { |
|
366 | + /** @var ISettings $form */ |
|
367 | + $form = new Personal\PersonalInfo($this->config, $this->userManager, $this->groupManager, $this->accountManager, $this->l10nFactory); |
|
368 | + $forms[$form->getPriority()] = [$form]; |
|
369 | + } |
|
370 | + } catch (QueryException $e) { |
|
371 | + // skip |
|
372 | + } |
|
373 | + return $forms; |
|
374 | + } |
|
375 | + |
|
376 | + /** |
|
377 | + * @inheritdoc |
|
378 | + */ |
|
379 | + public function getAdminSettings($section) { |
|
380 | + $settings = $this->getBuiltInAdminSettings($section); |
|
381 | + $dbRows = $this->mapper->getAdminSettingsFromDB($section); |
|
382 | + |
|
383 | + foreach ($dbRows as $row) { |
|
384 | + if (!isset($settings[$row['priority']])) { |
|
385 | + $settings[$row['priority']] = []; |
|
386 | + } |
|
387 | + try { |
|
388 | + $settings[$row['priority']][] = $this->query($row['class']); |
|
389 | + } catch (QueryException $e) { |
|
390 | + // skip |
|
391 | + } |
|
392 | + } |
|
393 | + |
|
394 | + ksort($settings); |
|
395 | + return $settings; |
|
396 | + } |
|
397 | + |
|
398 | + /** |
|
399 | + * @inheritdoc |
|
400 | + */ |
|
401 | + public function getPersonalSections() { |
|
402 | + $sections = [ |
|
403 | + 0 => [new Section('personal-info', $this->l->t('Personal info'), 0, $this->url->imagePath('core', 'actions/info.svg'))], |
|
404 | + ]; |
|
405 | + return $sections; |
|
406 | + } |
|
407 | + |
|
408 | + /** |
|
409 | + * @inheritdoc |
|
410 | + */ |
|
411 | + public function getPersonalSettings($section) { |
|
412 | + $settings = $this->getBuiltInPersonalSettings($section); |
|
413 | + return $settings; |
|
414 | + } |
|
415 | 415 | } |
@@ -127,1641 +127,1641 @@ |
||
127 | 127 | * TODO: hookup all manager classes |
128 | 128 | */ |
129 | 129 | class Server extends ServerContainer implements IServerContainer { |
130 | - /** @var string */ |
|
131 | - private $webRoot; |
|
132 | - |
|
133 | - /** |
|
134 | - * @param string $webRoot |
|
135 | - * @param \OC\Config $config |
|
136 | - */ |
|
137 | - public function __construct($webRoot, \OC\Config $config) { |
|
138 | - parent::__construct(); |
|
139 | - $this->webRoot = $webRoot; |
|
140 | - |
|
141 | - $this->registerService(\OCP\IServerContainer::class, function(IServerContainer $c) { |
|
142 | - return $c; |
|
143 | - }); |
|
144 | - |
|
145 | - $this->registerAlias(\OCP\Contacts\IManager::class, \OC\ContactsManager::class); |
|
146 | - $this->registerAlias('ContactsManager', \OCP\Contacts\IManager::class); |
|
147 | - |
|
148 | - $this->registerAlias(IActionFactory::class, ActionFactory::class); |
|
149 | - |
|
150 | - |
|
151 | - |
|
152 | - $this->registerService(\OCP\IPreview::class, function (Server $c) { |
|
153 | - return new PreviewManager( |
|
154 | - $c->getConfig(), |
|
155 | - $c->getRootFolder(), |
|
156 | - $c->getAppDataDir('preview'), |
|
157 | - $c->getEventDispatcher(), |
|
158 | - $c->getSession()->get('user_id') |
|
159 | - ); |
|
160 | - }); |
|
161 | - $this->registerAlias('PreviewManager', \OCP\IPreview::class); |
|
162 | - |
|
163 | - $this->registerService(\OC\Preview\Watcher::class, function (Server $c) { |
|
164 | - return new \OC\Preview\Watcher( |
|
165 | - $c->getAppDataDir('preview') |
|
166 | - ); |
|
167 | - }); |
|
168 | - |
|
169 | - $this->registerService('EncryptionManager', function (Server $c) { |
|
170 | - $view = new View(); |
|
171 | - $util = new Encryption\Util( |
|
172 | - $view, |
|
173 | - $c->getUserManager(), |
|
174 | - $c->getGroupManager(), |
|
175 | - $c->getConfig() |
|
176 | - ); |
|
177 | - return new Encryption\Manager( |
|
178 | - $c->getConfig(), |
|
179 | - $c->getLogger(), |
|
180 | - $c->getL10N('core'), |
|
181 | - new View(), |
|
182 | - $util, |
|
183 | - new ArrayCache() |
|
184 | - ); |
|
185 | - }); |
|
186 | - |
|
187 | - $this->registerService('EncryptionFileHelper', function (Server $c) { |
|
188 | - $util = new Encryption\Util( |
|
189 | - new View(), |
|
190 | - $c->getUserManager(), |
|
191 | - $c->getGroupManager(), |
|
192 | - $c->getConfig() |
|
193 | - ); |
|
194 | - return new Encryption\File( |
|
195 | - $util, |
|
196 | - $c->getRootFolder(), |
|
197 | - $c->getShareManager() |
|
198 | - ); |
|
199 | - }); |
|
200 | - |
|
201 | - $this->registerService('EncryptionKeyStorage', function (Server $c) { |
|
202 | - $view = new View(); |
|
203 | - $util = new Encryption\Util( |
|
204 | - $view, |
|
205 | - $c->getUserManager(), |
|
206 | - $c->getGroupManager(), |
|
207 | - $c->getConfig() |
|
208 | - ); |
|
209 | - |
|
210 | - return new Encryption\Keys\Storage($view, $util); |
|
211 | - }); |
|
212 | - $this->registerService('TagMapper', function (Server $c) { |
|
213 | - return new TagMapper($c->getDatabaseConnection()); |
|
214 | - }); |
|
215 | - |
|
216 | - $this->registerService(\OCP\ITagManager::class, function (Server $c) { |
|
217 | - $tagMapper = $c->query('TagMapper'); |
|
218 | - return new TagManager($tagMapper, $c->getUserSession()); |
|
219 | - }); |
|
220 | - $this->registerAlias('TagManager', \OCP\ITagManager::class); |
|
221 | - |
|
222 | - $this->registerService('SystemTagManagerFactory', function (Server $c) { |
|
223 | - $config = $c->getConfig(); |
|
224 | - $factoryClass = $config->getSystemValue('systemtags.managerFactory', '\OC\SystemTag\ManagerFactory'); |
|
225 | - /** @var \OC\SystemTag\ManagerFactory $factory */ |
|
226 | - $factory = new $factoryClass($this); |
|
227 | - return $factory; |
|
228 | - }); |
|
229 | - $this->registerService(\OCP\SystemTag\ISystemTagManager::class, function (Server $c) { |
|
230 | - return $c->query('SystemTagManagerFactory')->getManager(); |
|
231 | - }); |
|
232 | - $this->registerAlias('SystemTagManager', \OCP\SystemTag\ISystemTagManager::class); |
|
233 | - |
|
234 | - $this->registerService(\OCP\SystemTag\ISystemTagObjectMapper::class, function (Server $c) { |
|
235 | - return $c->query('SystemTagManagerFactory')->getObjectMapper(); |
|
236 | - }); |
|
237 | - $this->registerService('RootFolder', function (Server $c) { |
|
238 | - $manager = \OC\Files\Filesystem::getMountManager(null); |
|
239 | - $view = new View(); |
|
240 | - $root = new Root( |
|
241 | - $manager, |
|
242 | - $view, |
|
243 | - null, |
|
244 | - $c->getUserMountCache(), |
|
245 | - $this->getLogger(), |
|
246 | - $this->getUserManager() |
|
247 | - ); |
|
248 | - $connector = new HookConnector($root, $view); |
|
249 | - $connector->viewToNode(); |
|
250 | - |
|
251 | - $previewConnector = new \OC\Preview\WatcherConnector($root, $c->getSystemConfig()); |
|
252 | - $previewConnector->connectWatcher(); |
|
253 | - |
|
254 | - return $root; |
|
255 | - }); |
|
256 | - $this->registerAlias('SystemTagObjectMapper', \OCP\SystemTag\ISystemTagObjectMapper::class); |
|
257 | - |
|
258 | - $this->registerService(\OCP\Files\IRootFolder::class, function(Server $c) { |
|
259 | - return new LazyRoot(function() use ($c) { |
|
260 | - return $c->query('RootFolder'); |
|
261 | - }); |
|
262 | - }); |
|
263 | - $this->registerAlias('LazyRootFolder', \OCP\Files\IRootFolder::class); |
|
264 | - |
|
265 | - $this->registerService(\OCP\IUserManager::class, function (Server $c) { |
|
266 | - $config = $c->getConfig(); |
|
267 | - return new \OC\User\Manager($config); |
|
268 | - }); |
|
269 | - $this->registerAlias('UserManager', \OCP\IUserManager::class); |
|
270 | - |
|
271 | - $this->registerService(\OCP\IGroupManager::class, function (Server $c) { |
|
272 | - $groupManager = new \OC\Group\Manager($this->getUserManager(), $this->getLogger()); |
|
273 | - $groupManager->listen('\OC\Group', 'preCreate', function ($gid) { |
|
274 | - \OC_Hook::emit('OC_Group', 'pre_createGroup', array('run' => true, 'gid' => $gid)); |
|
275 | - }); |
|
276 | - $groupManager->listen('\OC\Group', 'postCreate', function (\OC\Group\Group $gid) { |
|
277 | - \OC_Hook::emit('OC_User', 'post_createGroup', array('gid' => $gid->getGID())); |
|
278 | - }); |
|
279 | - $groupManager->listen('\OC\Group', 'preDelete', function (\OC\Group\Group $group) { |
|
280 | - \OC_Hook::emit('OC_Group', 'pre_deleteGroup', array('run' => true, 'gid' => $group->getGID())); |
|
281 | - }); |
|
282 | - $groupManager->listen('\OC\Group', 'postDelete', function (\OC\Group\Group $group) { |
|
283 | - \OC_Hook::emit('OC_User', 'post_deleteGroup', array('gid' => $group->getGID())); |
|
284 | - }); |
|
285 | - $groupManager->listen('\OC\Group', 'preAddUser', function (\OC\Group\Group $group, \OC\User\User $user) { |
|
286 | - \OC_Hook::emit('OC_Group', 'pre_addToGroup', array('run' => true, 'uid' => $user->getUID(), 'gid' => $group->getGID())); |
|
287 | - }); |
|
288 | - $groupManager->listen('\OC\Group', 'postAddUser', function (\OC\Group\Group $group, \OC\User\User $user) { |
|
289 | - \OC_Hook::emit('OC_Group', 'post_addToGroup', array('uid' => $user->getUID(), 'gid' => $group->getGID())); |
|
290 | - //Minimal fix to keep it backward compatible TODO: clean up all the GroupManager hooks |
|
291 | - \OC_Hook::emit('OC_User', 'post_addToGroup', array('uid' => $user->getUID(), 'gid' => $group->getGID())); |
|
292 | - }); |
|
293 | - return $groupManager; |
|
294 | - }); |
|
295 | - $this->registerAlias('GroupManager', \OCP\IGroupManager::class); |
|
296 | - |
|
297 | - $this->registerService(Store::class, function(Server $c) { |
|
298 | - $session = $c->getSession(); |
|
299 | - if (\OC::$server->getSystemConfig()->getValue('installed', false)) { |
|
300 | - $tokenProvider = $c->query('OC\Authentication\Token\IProvider'); |
|
301 | - } else { |
|
302 | - $tokenProvider = null; |
|
303 | - } |
|
304 | - $logger = $c->getLogger(); |
|
305 | - return new Store($session, $logger, $tokenProvider); |
|
306 | - }); |
|
307 | - $this->registerAlias(IStore::class, Store::class); |
|
308 | - $this->registerService('OC\Authentication\Token\DefaultTokenMapper', function (Server $c) { |
|
309 | - $dbConnection = $c->getDatabaseConnection(); |
|
310 | - return new Authentication\Token\DefaultTokenMapper($dbConnection); |
|
311 | - }); |
|
312 | - $this->registerService('OC\Authentication\Token\DefaultTokenProvider', function (Server $c) { |
|
313 | - $mapper = $c->query('OC\Authentication\Token\DefaultTokenMapper'); |
|
314 | - $crypto = $c->getCrypto(); |
|
315 | - $config = $c->getConfig(); |
|
316 | - $logger = $c->getLogger(); |
|
317 | - $timeFactory = new TimeFactory(); |
|
318 | - return new \OC\Authentication\Token\DefaultTokenProvider($mapper, $crypto, $config, $logger, $timeFactory); |
|
319 | - }); |
|
320 | - $this->registerAlias('OC\Authentication\Token\IProvider', 'OC\Authentication\Token\DefaultTokenProvider'); |
|
321 | - |
|
322 | - $this->registerService(\OCP\IUserSession::class, function (Server $c) { |
|
323 | - $manager = $c->getUserManager(); |
|
324 | - $session = new \OC\Session\Memory(''); |
|
325 | - $timeFactory = new TimeFactory(); |
|
326 | - // Token providers might require a working database. This code |
|
327 | - // might however be called when ownCloud is not yet setup. |
|
328 | - if (\OC::$server->getSystemConfig()->getValue('installed', false)) { |
|
329 | - $defaultTokenProvider = $c->query('OC\Authentication\Token\IProvider'); |
|
330 | - } else { |
|
331 | - $defaultTokenProvider = null; |
|
332 | - } |
|
333 | - |
|
334 | - $userSession = new \OC\User\Session($manager, $session, $timeFactory, $defaultTokenProvider, $c->getConfig(), $c->getSecureRandom(), $c->getLockdownManager()); |
|
335 | - $userSession->listen('\OC\User', 'preCreateUser', function ($uid, $password) { |
|
336 | - \OC_Hook::emit('OC_User', 'pre_createUser', array('run' => true, 'uid' => $uid, 'password' => $password)); |
|
337 | - }); |
|
338 | - $userSession->listen('\OC\User', 'postCreateUser', function ($user, $password) { |
|
339 | - /** @var $user \OC\User\User */ |
|
340 | - \OC_Hook::emit('OC_User', 'post_createUser', array('uid' => $user->getUID(), 'password' => $password)); |
|
341 | - }); |
|
342 | - $userSession->listen('\OC\User', 'preDelete', function ($user) { |
|
343 | - /** @var $user \OC\User\User */ |
|
344 | - \OC_Hook::emit('OC_User', 'pre_deleteUser', array('run' => true, 'uid' => $user->getUID())); |
|
345 | - }); |
|
346 | - $userSession->listen('\OC\User', 'postDelete', function ($user) { |
|
347 | - /** @var $user \OC\User\User */ |
|
348 | - \OC_Hook::emit('OC_User', 'post_deleteUser', array('uid' => $user->getUID())); |
|
349 | - }); |
|
350 | - $userSession->listen('\OC\User', 'preSetPassword', function ($user, $password, $recoveryPassword) { |
|
351 | - /** @var $user \OC\User\User */ |
|
352 | - \OC_Hook::emit('OC_User', 'pre_setPassword', array('run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword)); |
|
353 | - }); |
|
354 | - $userSession->listen('\OC\User', 'postSetPassword', function ($user, $password, $recoveryPassword) { |
|
355 | - /** @var $user \OC\User\User */ |
|
356 | - \OC_Hook::emit('OC_User', 'post_setPassword', array('run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword)); |
|
357 | - }); |
|
358 | - $userSession->listen('\OC\User', 'preLogin', function ($uid, $password) { |
|
359 | - \OC_Hook::emit('OC_User', 'pre_login', array('run' => true, 'uid' => $uid, 'password' => $password)); |
|
360 | - }); |
|
361 | - $userSession->listen('\OC\User', 'postLogin', function ($user, $password) { |
|
362 | - /** @var $user \OC\User\User */ |
|
363 | - \OC_Hook::emit('OC_User', 'post_login', array('run' => true, 'uid' => $user->getUID(), 'password' => $password)); |
|
364 | - }); |
|
365 | - $userSession->listen('\OC\User', 'logout', function () { |
|
366 | - \OC_Hook::emit('OC_User', 'logout', array()); |
|
367 | - }); |
|
368 | - $userSession->listen('\OC\User', 'changeUser', function ($user, $feature, $value, $oldValue) { |
|
369 | - /** @var $user \OC\User\User */ |
|
370 | - \OC_Hook::emit('OC_User', 'changeUser', array('run' => true, 'user' => $user, 'feature' => $feature, 'value' => $value, 'old_value' => $oldValue)); |
|
371 | - }); |
|
372 | - return $userSession; |
|
373 | - }); |
|
374 | - $this->registerAlias('UserSession', \OCP\IUserSession::class); |
|
375 | - |
|
376 | - $this->registerService(\OC\Authentication\TwoFactorAuth\Manager::class, function (Server $c) { |
|
377 | - return new \OC\Authentication\TwoFactorAuth\Manager($c->getAppManager(), $c->getSession(), $c->getConfig(), $c->getActivityManager(), $c->getLogger()); |
|
378 | - }); |
|
379 | - |
|
380 | - $this->registerAlias(\OCP\INavigationManager::class, \OC\NavigationManager::class); |
|
381 | - $this->registerAlias('NavigationManager', \OCP\INavigationManager::class); |
|
382 | - |
|
383 | - $this->registerService(\OC\AllConfig::class, function (Server $c) { |
|
384 | - return new \OC\AllConfig( |
|
385 | - $c->getSystemConfig() |
|
386 | - ); |
|
387 | - }); |
|
388 | - $this->registerAlias('AllConfig', \OC\AllConfig::class); |
|
389 | - $this->registerAlias(\OCP\IConfig::class, \OC\AllConfig::class); |
|
390 | - |
|
391 | - $this->registerService('SystemConfig', function ($c) use ($config) { |
|
392 | - return new \OC\SystemConfig($config); |
|
393 | - }); |
|
394 | - |
|
395 | - $this->registerService(\OC\AppConfig::class, function (Server $c) { |
|
396 | - return new \OC\AppConfig($c->getDatabaseConnection()); |
|
397 | - }); |
|
398 | - $this->registerAlias('AppConfig', \OC\AppConfig::class); |
|
399 | - $this->registerAlias(\OCP\IAppConfig::class, \OC\AppConfig::class); |
|
400 | - |
|
401 | - $this->registerService(\OCP\L10N\IFactory::class, function (Server $c) { |
|
402 | - return new \OC\L10N\Factory( |
|
403 | - $c->getConfig(), |
|
404 | - $c->getRequest(), |
|
405 | - $c->getUserSession(), |
|
406 | - \OC::$SERVERROOT |
|
407 | - ); |
|
408 | - }); |
|
409 | - $this->registerAlias('L10NFactory', \OCP\L10N\IFactory::class); |
|
410 | - |
|
411 | - $this->registerService(\OCP\IURLGenerator::class, function (Server $c) { |
|
412 | - $config = $c->getConfig(); |
|
413 | - $cacheFactory = $c->getMemCacheFactory(); |
|
414 | - return new \OC\URLGenerator( |
|
415 | - $config, |
|
416 | - $cacheFactory |
|
417 | - ); |
|
418 | - }); |
|
419 | - $this->registerAlias('URLGenerator', \OCP\IURLGenerator::class); |
|
420 | - |
|
421 | - $this->registerService('AppHelper', function ($c) { |
|
422 | - return new \OC\AppHelper(); |
|
423 | - }); |
|
424 | - $this->registerAlias('AppFetcher', AppFetcher::class); |
|
425 | - $this->registerAlias('CategoryFetcher', CategoryFetcher::class); |
|
426 | - |
|
427 | - $this->registerService(\OCP\ICache::class, function ($c) { |
|
428 | - return new Cache\File(); |
|
429 | - }); |
|
430 | - $this->registerAlias('UserCache', \OCP\ICache::class); |
|
431 | - |
|
432 | - $this->registerService(Factory::class, function (Server $c) { |
|
433 | - $config = $c->getConfig(); |
|
434 | - |
|
435 | - if ($config->getSystemValue('installed', false) && !(defined('PHPUNIT_RUN') && PHPUNIT_RUN)) { |
|
436 | - $v = \OC_App::getAppVersions(); |
|
437 | - $v['core'] = md5(file_get_contents(\OC::$SERVERROOT . '/version.php')); |
|
438 | - $version = implode(',', $v); |
|
439 | - $instanceId = \OC_Util::getInstanceId(); |
|
440 | - $path = \OC::$SERVERROOT; |
|
441 | - $prefix = md5($instanceId . '-' . $version . '-' . $path . '-' . \OC::$WEBROOT); |
|
442 | - return new \OC\Memcache\Factory($prefix, $c->getLogger(), |
|
443 | - $config->getSystemValue('memcache.local', null), |
|
444 | - $config->getSystemValue('memcache.distributed', null), |
|
445 | - $config->getSystemValue('memcache.locking', null) |
|
446 | - ); |
|
447 | - } |
|
448 | - |
|
449 | - return new \OC\Memcache\Factory('', $c->getLogger(), |
|
450 | - '\\OC\\Memcache\\ArrayCache', |
|
451 | - '\\OC\\Memcache\\ArrayCache', |
|
452 | - '\\OC\\Memcache\\ArrayCache' |
|
453 | - ); |
|
454 | - }); |
|
455 | - $this->registerAlias('MemCacheFactory', Factory::class); |
|
456 | - $this->registerAlias(ICacheFactory::class, Factory::class); |
|
457 | - |
|
458 | - $this->registerService('RedisFactory', function (Server $c) { |
|
459 | - $systemConfig = $c->getSystemConfig(); |
|
460 | - return new RedisFactory($systemConfig); |
|
461 | - }); |
|
462 | - |
|
463 | - $this->registerService(\OCP\Activity\IManager::class, function (Server $c) { |
|
464 | - return new \OC\Activity\Manager( |
|
465 | - $c->getRequest(), |
|
466 | - $c->getUserSession(), |
|
467 | - $c->getConfig(), |
|
468 | - $c->query(IValidator::class) |
|
469 | - ); |
|
470 | - }); |
|
471 | - $this->registerAlias('ActivityManager', \OCP\Activity\IManager::class); |
|
472 | - |
|
473 | - $this->registerService(\OCP\Activity\IEventMerger::class, function (Server $c) { |
|
474 | - return new \OC\Activity\EventMerger( |
|
475 | - $c->getL10N('lib') |
|
476 | - ); |
|
477 | - }); |
|
478 | - $this->registerAlias(IValidator::class, Validator::class); |
|
479 | - |
|
480 | - $this->registerService(\OCP\IAvatarManager::class, function (Server $c) { |
|
481 | - return new AvatarManager( |
|
482 | - $c->getUserManager(), |
|
483 | - $c->getAppDataDir('avatar'), |
|
484 | - $c->getL10N('lib'), |
|
485 | - $c->getLogger(), |
|
486 | - $c->getConfig() |
|
487 | - ); |
|
488 | - }); |
|
489 | - $this->registerAlias('AvatarManager', \OCP\IAvatarManager::class); |
|
490 | - |
|
491 | - $this->registerService(\OCP\ILogger::class, function (Server $c) { |
|
492 | - $logType = $c->query('AllConfig')->getSystemValue('log_type', 'file'); |
|
493 | - $logger = Log::getLogClass($logType); |
|
494 | - call_user_func(array($logger, 'init')); |
|
495 | - |
|
496 | - return new Log($logger); |
|
497 | - }); |
|
498 | - $this->registerAlias('Logger', \OCP\ILogger::class); |
|
499 | - |
|
500 | - $this->registerService(\OCP\BackgroundJob\IJobList::class, function (Server $c) { |
|
501 | - $config = $c->getConfig(); |
|
502 | - return new \OC\BackgroundJob\JobList( |
|
503 | - $c->getDatabaseConnection(), |
|
504 | - $config, |
|
505 | - new TimeFactory() |
|
506 | - ); |
|
507 | - }); |
|
508 | - $this->registerAlias('JobList', \OCP\BackgroundJob\IJobList::class); |
|
509 | - |
|
510 | - $this->registerService(\OCP\Route\IRouter::class, function (Server $c) { |
|
511 | - $cacheFactory = $c->getMemCacheFactory(); |
|
512 | - $logger = $c->getLogger(); |
|
513 | - if ($cacheFactory->isAvailable()) { |
|
514 | - $router = new \OC\Route\CachingRouter($cacheFactory->create('route'), $logger); |
|
515 | - } else { |
|
516 | - $router = new \OC\Route\Router($logger); |
|
517 | - } |
|
518 | - return $router; |
|
519 | - }); |
|
520 | - $this->registerAlias('Router', \OCP\Route\IRouter::class); |
|
521 | - |
|
522 | - $this->registerService(\OCP\ISearch::class, function ($c) { |
|
523 | - return new Search(); |
|
524 | - }); |
|
525 | - $this->registerAlias('Search', \OCP\ISearch::class); |
|
526 | - |
|
527 | - $this->registerService(\OC\Security\RateLimiting\Limiter::class, function($c) { |
|
528 | - return new \OC\Security\RateLimiting\Limiter( |
|
529 | - $this->getUserSession(), |
|
530 | - $this->getRequest(), |
|
531 | - new \OC\AppFramework\Utility\TimeFactory(), |
|
532 | - $c->query(\OC\Security\RateLimiting\Backend\IBackend::class) |
|
533 | - ); |
|
534 | - }); |
|
535 | - $this->registerService(\OC\Security\RateLimiting\Backend\IBackend::class, function($c) { |
|
536 | - return new \OC\Security\RateLimiting\Backend\MemoryCache( |
|
537 | - $this->getMemCacheFactory(), |
|
538 | - new \OC\AppFramework\Utility\TimeFactory() |
|
539 | - ); |
|
540 | - }); |
|
541 | - |
|
542 | - $this->registerService(\OCP\Security\ISecureRandom::class, function ($c) { |
|
543 | - return new SecureRandom(); |
|
544 | - }); |
|
545 | - $this->registerAlias('SecureRandom', \OCP\Security\ISecureRandom::class); |
|
546 | - |
|
547 | - $this->registerService(\OCP\Security\ICrypto::class, function (Server $c) { |
|
548 | - return new Crypto($c->getConfig(), $c->getSecureRandom()); |
|
549 | - }); |
|
550 | - $this->registerAlias('Crypto', \OCP\Security\ICrypto::class); |
|
551 | - |
|
552 | - $this->registerService(\OCP\Security\IHasher::class, function (Server $c) { |
|
553 | - return new Hasher($c->getConfig()); |
|
554 | - }); |
|
555 | - $this->registerAlias('Hasher', \OCP\Security\IHasher::class); |
|
556 | - |
|
557 | - $this->registerService(\OCP\Security\ICredentialsManager::class, function (Server $c) { |
|
558 | - return new CredentialsManager($c->getCrypto(), $c->getDatabaseConnection()); |
|
559 | - }); |
|
560 | - $this->registerAlias('CredentialsManager', \OCP\Security\ICredentialsManager::class); |
|
561 | - |
|
562 | - $this->registerService(IDBConnection::class, function (Server $c) { |
|
563 | - $systemConfig = $c->getSystemConfig(); |
|
564 | - $factory = new \OC\DB\ConnectionFactory($systemConfig); |
|
565 | - $type = $systemConfig->getValue('dbtype', 'sqlite'); |
|
566 | - if (!$factory->isValidType($type)) { |
|
567 | - throw new \OC\DatabaseException('Invalid database type'); |
|
568 | - } |
|
569 | - $connectionParams = $factory->createConnectionParams(); |
|
570 | - $connection = $factory->getConnection($type, $connectionParams); |
|
571 | - $connection->getConfiguration()->setSQLLogger($c->getQueryLogger()); |
|
572 | - return $connection; |
|
573 | - }); |
|
574 | - $this->registerAlias('DatabaseConnection', IDBConnection::class); |
|
575 | - |
|
576 | - $this->registerService('HTTPHelper', function (Server $c) { |
|
577 | - $config = $c->getConfig(); |
|
578 | - return new HTTPHelper( |
|
579 | - $config, |
|
580 | - $c->getHTTPClientService() |
|
581 | - ); |
|
582 | - }); |
|
583 | - |
|
584 | - $this->registerService(\OCP\Http\Client\IClientService::class, function (Server $c) { |
|
585 | - $user = \OC_User::getUser(); |
|
586 | - $uid = $user ? $user : null; |
|
587 | - return new ClientService( |
|
588 | - $c->getConfig(), |
|
589 | - new \OC\Security\CertificateManager($uid, new View(), $c->getConfig(), $c->getLogger()) |
|
590 | - ); |
|
591 | - }); |
|
592 | - $this->registerAlias('HttpClientService', \OCP\Http\Client\IClientService::class); |
|
593 | - $this->registerService(\OCP\Diagnostics\IEventLogger::class, function (Server $c) { |
|
594 | - $eventLogger = new EventLogger(); |
|
595 | - if ($c->getSystemConfig()->getValue('debug', false)) { |
|
596 | - // In debug mode, module is being activated by default |
|
597 | - $eventLogger->activate(); |
|
598 | - } |
|
599 | - return $eventLogger; |
|
600 | - }); |
|
601 | - $this->registerAlias('EventLogger', \OCP\Diagnostics\IEventLogger::class); |
|
602 | - |
|
603 | - $this->registerService(\OCP\Diagnostics\IQueryLogger::class, function (Server $c) { |
|
604 | - $queryLogger = new QueryLogger(); |
|
605 | - if ($c->getSystemConfig()->getValue('debug', false)) { |
|
606 | - // In debug mode, module is being activated by default |
|
607 | - $queryLogger->activate(); |
|
608 | - } |
|
609 | - return $queryLogger; |
|
610 | - }); |
|
611 | - $this->registerAlias('QueryLogger', \OCP\Diagnostics\IQueryLogger::class); |
|
612 | - |
|
613 | - $this->registerService(TempManager::class, function (Server $c) { |
|
614 | - return new TempManager( |
|
615 | - $c->getLogger(), |
|
616 | - $c->getConfig() |
|
617 | - ); |
|
618 | - }); |
|
619 | - $this->registerAlias('TempManager', TempManager::class); |
|
620 | - $this->registerAlias(ITempManager::class, TempManager::class); |
|
621 | - |
|
622 | - $this->registerService(AppManager::class, function (Server $c) { |
|
623 | - return new \OC\App\AppManager( |
|
624 | - $c->getUserSession(), |
|
625 | - $c->getAppConfig(), |
|
626 | - $c->getGroupManager(), |
|
627 | - $c->getMemCacheFactory(), |
|
628 | - $c->getEventDispatcher() |
|
629 | - ); |
|
630 | - }); |
|
631 | - $this->registerAlias('AppManager', AppManager::class); |
|
632 | - $this->registerAlias(IAppManager::class, AppManager::class); |
|
633 | - |
|
634 | - $this->registerService(\OCP\IDateTimeZone::class, function (Server $c) { |
|
635 | - return new DateTimeZone( |
|
636 | - $c->getConfig(), |
|
637 | - $c->getSession() |
|
638 | - ); |
|
639 | - }); |
|
640 | - $this->registerAlias('DateTimeZone', \OCP\IDateTimeZone::class); |
|
641 | - |
|
642 | - $this->registerService(\OCP\IDateTimeFormatter::class, function (Server $c) { |
|
643 | - $language = $c->getConfig()->getUserValue($c->getSession()->get('user_id'), 'core', 'lang', null); |
|
644 | - |
|
645 | - return new DateTimeFormatter( |
|
646 | - $c->getDateTimeZone()->getTimeZone(), |
|
647 | - $c->getL10N('lib', $language) |
|
648 | - ); |
|
649 | - }); |
|
650 | - $this->registerAlias('DateTimeFormatter', \OCP\IDateTimeFormatter::class); |
|
651 | - |
|
652 | - $this->registerService(\OCP\Files\Config\IUserMountCache::class, function (Server $c) { |
|
653 | - $mountCache = new UserMountCache($c->getDatabaseConnection(), $c->getUserManager(), $c->getLogger()); |
|
654 | - $listener = new UserMountCacheListener($mountCache); |
|
655 | - $listener->listen($c->getUserManager()); |
|
656 | - return $mountCache; |
|
657 | - }); |
|
658 | - $this->registerAlias('UserMountCache', \OCP\Files\Config\IUserMountCache::class); |
|
659 | - |
|
660 | - $this->registerService(\OCP\Files\Config\IMountProviderCollection::class, function (Server $c) { |
|
661 | - $loader = \OC\Files\Filesystem::getLoader(); |
|
662 | - $mountCache = $c->query('UserMountCache'); |
|
663 | - $manager = new \OC\Files\Config\MountProviderCollection($loader, $mountCache); |
|
664 | - |
|
665 | - // builtin providers |
|
666 | - |
|
667 | - $config = $c->getConfig(); |
|
668 | - $manager->registerProvider(new CacheMountProvider($config)); |
|
669 | - $manager->registerHomeProvider(new LocalHomeMountProvider()); |
|
670 | - $manager->registerHomeProvider(new ObjectHomeMountProvider($config)); |
|
671 | - |
|
672 | - return $manager; |
|
673 | - }); |
|
674 | - $this->registerAlias('MountConfigManager', \OCP\Files\Config\IMountProviderCollection::class); |
|
675 | - |
|
676 | - $this->registerService('IniWrapper', function ($c) { |
|
677 | - return new IniGetWrapper(); |
|
678 | - }); |
|
679 | - $this->registerService('AsyncCommandBus', function (Server $c) { |
|
680 | - $jobList = $c->getJobList(); |
|
681 | - return new AsyncBus($jobList); |
|
682 | - }); |
|
683 | - $this->registerService('TrustedDomainHelper', function ($c) { |
|
684 | - return new TrustedDomainHelper($this->getConfig()); |
|
685 | - }); |
|
686 | - $this->registerService('Throttler', function(Server $c) { |
|
687 | - return new Throttler( |
|
688 | - $c->getDatabaseConnection(), |
|
689 | - new TimeFactory(), |
|
690 | - $c->getLogger(), |
|
691 | - $c->getConfig() |
|
692 | - ); |
|
693 | - }); |
|
694 | - $this->registerService('IntegrityCodeChecker', function (Server $c) { |
|
695 | - // IConfig and IAppManager requires a working database. This code |
|
696 | - // might however be called when ownCloud is not yet setup. |
|
697 | - if(\OC::$server->getSystemConfig()->getValue('installed', false)) { |
|
698 | - $config = $c->getConfig(); |
|
699 | - $appManager = $c->getAppManager(); |
|
700 | - } else { |
|
701 | - $config = null; |
|
702 | - $appManager = null; |
|
703 | - } |
|
704 | - |
|
705 | - return new Checker( |
|
706 | - new EnvironmentHelper(), |
|
707 | - new FileAccessHelper(), |
|
708 | - new AppLocator(), |
|
709 | - $config, |
|
710 | - $c->getMemCacheFactory(), |
|
711 | - $appManager, |
|
712 | - $c->getTempManager() |
|
713 | - ); |
|
714 | - }); |
|
715 | - $this->registerService(\OCP\IRequest::class, function ($c) { |
|
716 | - if (isset($this['urlParams'])) { |
|
717 | - $urlParams = $this['urlParams']; |
|
718 | - } else { |
|
719 | - $urlParams = []; |
|
720 | - } |
|
721 | - |
|
722 | - if (defined('PHPUNIT_RUN') && PHPUNIT_RUN |
|
723 | - && in_array('fakeinput', stream_get_wrappers()) |
|
724 | - ) { |
|
725 | - $stream = 'fakeinput://data'; |
|
726 | - } else { |
|
727 | - $stream = 'php://input'; |
|
728 | - } |
|
729 | - |
|
730 | - return new Request( |
|
731 | - [ |
|
732 | - 'get' => $_GET, |
|
733 | - 'post' => $_POST, |
|
734 | - 'files' => $_FILES, |
|
735 | - 'server' => $_SERVER, |
|
736 | - 'env' => $_ENV, |
|
737 | - 'cookies' => $_COOKIE, |
|
738 | - 'method' => (isset($_SERVER) && isset($_SERVER['REQUEST_METHOD'])) |
|
739 | - ? $_SERVER['REQUEST_METHOD'] |
|
740 | - : null, |
|
741 | - 'urlParams' => $urlParams, |
|
742 | - ], |
|
743 | - $this->getSecureRandom(), |
|
744 | - $this->getConfig(), |
|
745 | - $this->getCsrfTokenManager(), |
|
746 | - $stream |
|
747 | - ); |
|
748 | - }); |
|
749 | - $this->registerAlias('Request', \OCP\IRequest::class); |
|
750 | - |
|
751 | - $this->registerService(\OCP\Mail\IMailer::class, function (Server $c) { |
|
752 | - return new Mailer( |
|
753 | - $c->getConfig(), |
|
754 | - $c->getLogger(), |
|
755 | - $c->query(Defaults::class), |
|
756 | - $c->getURLGenerator(), |
|
757 | - $c->getL10N('lib') |
|
758 | - ); |
|
759 | - }); |
|
760 | - $this->registerAlias('Mailer', \OCP\Mail\IMailer::class); |
|
761 | - |
|
762 | - $this->registerService('LDAPProvider', function(Server $c) { |
|
763 | - $config = $c->getConfig(); |
|
764 | - $factoryClass = $config->getSystemValue('ldapProviderFactory', null); |
|
765 | - if(is_null($factoryClass)) { |
|
766 | - throw new \Exception('ldapProviderFactory not set'); |
|
767 | - } |
|
768 | - /** @var \OCP\LDAP\ILDAPProviderFactory $factory */ |
|
769 | - $factory = new $factoryClass($this); |
|
770 | - return $factory->getLDAPProvider(); |
|
771 | - }); |
|
772 | - $this->registerService('LockingProvider', function (Server $c) { |
|
773 | - $ini = $c->getIniWrapper(); |
|
774 | - $config = $c->getConfig(); |
|
775 | - $ttl = $config->getSystemValue('filelocking.ttl', max(3600, $ini->getNumeric('max_execution_time'))); |
|
776 | - if ($config->getSystemValue('filelocking.enabled', true) or (defined('PHPUNIT_RUN') && PHPUNIT_RUN)) { |
|
777 | - /** @var \OC\Memcache\Factory $memcacheFactory */ |
|
778 | - $memcacheFactory = $c->getMemCacheFactory(); |
|
779 | - $memcache = $memcacheFactory->createLocking('lock'); |
|
780 | - if (!($memcache instanceof \OC\Memcache\NullCache)) { |
|
781 | - return new MemcacheLockingProvider($memcache, $ttl); |
|
782 | - } |
|
783 | - return new DBLockingProvider($c->getDatabaseConnection(), $c->getLogger(), new TimeFactory(), $ttl); |
|
784 | - } |
|
785 | - return new NoopLockingProvider(); |
|
786 | - }); |
|
787 | - |
|
788 | - $this->registerService(\OCP\Files\Mount\IMountManager::class, function () { |
|
789 | - return new \OC\Files\Mount\Manager(); |
|
790 | - }); |
|
791 | - $this->registerAlias('MountManager', \OCP\Files\Mount\IMountManager::class); |
|
792 | - |
|
793 | - $this->registerService(\OCP\Files\IMimeTypeDetector::class, function (Server $c) { |
|
794 | - return new \OC\Files\Type\Detection( |
|
795 | - $c->getURLGenerator(), |
|
796 | - \OC::$configDir, |
|
797 | - \OC::$SERVERROOT . '/resources/config/' |
|
798 | - ); |
|
799 | - }); |
|
800 | - $this->registerAlias('MimeTypeDetector', \OCP\Files\IMimeTypeDetector::class); |
|
801 | - |
|
802 | - $this->registerService(\OCP\Files\IMimeTypeLoader::class, function (Server $c) { |
|
803 | - return new \OC\Files\Type\Loader( |
|
804 | - $c->getDatabaseConnection() |
|
805 | - ); |
|
806 | - }); |
|
807 | - $this->registerAlias('MimeTypeLoader', \OCP\Files\IMimeTypeLoader::class); |
|
808 | - $this->registerService(BundleFetcher::class, function () { |
|
809 | - return new BundleFetcher($this->getL10N('lib')); |
|
810 | - }); |
|
811 | - $this->registerService(\OCP\Notification\IManager::class, function (Server $c) { |
|
812 | - return new Manager( |
|
813 | - $c->query(IValidator::class) |
|
814 | - ); |
|
815 | - }); |
|
816 | - $this->registerAlias('NotificationManager', \OCP\Notification\IManager::class); |
|
817 | - |
|
818 | - $this->registerService(\OC\CapabilitiesManager::class, function (Server $c) { |
|
819 | - $manager = new \OC\CapabilitiesManager($c->getLogger()); |
|
820 | - $manager->registerCapability(function () use ($c) { |
|
821 | - return new \OC\OCS\CoreCapabilities($c->getConfig()); |
|
822 | - }); |
|
823 | - return $manager; |
|
824 | - }); |
|
825 | - $this->registerAlias('CapabilitiesManager', \OC\CapabilitiesManager::class); |
|
826 | - |
|
827 | - $this->registerService(\OCP\Comments\ICommentsManager::class, function(Server $c) { |
|
828 | - $config = $c->getConfig(); |
|
829 | - $factoryClass = $config->getSystemValue('comments.managerFactory', '\OC\Comments\ManagerFactory'); |
|
830 | - /** @var \OCP\Comments\ICommentsManagerFactory $factory */ |
|
831 | - $factory = new $factoryClass($this); |
|
832 | - return $factory->getManager(); |
|
833 | - }); |
|
834 | - $this->registerAlias('CommentsManager', \OCP\Comments\ICommentsManager::class); |
|
835 | - |
|
836 | - $this->registerService('ThemingDefaults', function(Server $c) { |
|
837 | - /* |
|
130 | + /** @var string */ |
|
131 | + private $webRoot; |
|
132 | + |
|
133 | + /** |
|
134 | + * @param string $webRoot |
|
135 | + * @param \OC\Config $config |
|
136 | + */ |
|
137 | + public function __construct($webRoot, \OC\Config $config) { |
|
138 | + parent::__construct(); |
|
139 | + $this->webRoot = $webRoot; |
|
140 | + |
|
141 | + $this->registerService(\OCP\IServerContainer::class, function(IServerContainer $c) { |
|
142 | + return $c; |
|
143 | + }); |
|
144 | + |
|
145 | + $this->registerAlias(\OCP\Contacts\IManager::class, \OC\ContactsManager::class); |
|
146 | + $this->registerAlias('ContactsManager', \OCP\Contacts\IManager::class); |
|
147 | + |
|
148 | + $this->registerAlias(IActionFactory::class, ActionFactory::class); |
|
149 | + |
|
150 | + |
|
151 | + |
|
152 | + $this->registerService(\OCP\IPreview::class, function (Server $c) { |
|
153 | + return new PreviewManager( |
|
154 | + $c->getConfig(), |
|
155 | + $c->getRootFolder(), |
|
156 | + $c->getAppDataDir('preview'), |
|
157 | + $c->getEventDispatcher(), |
|
158 | + $c->getSession()->get('user_id') |
|
159 | + ); |
|
160 | + }); |
|
161 | + $this->registerAlias('PreviewManager', \OCP\IPreview::class); |
|
162 | + |
|
163 | + $this->registerService(\OC\Preview\Watcher::class, function (Server $c) { |
|
164 | + return new \OC\Preview\Watcher( |
|
165 | + $c->getAppDataDir('preview') |
|
166 | + ); |
|
167 | + }); |
|
168 | + |
|
169 | + $this->registerService('EncryptionManager', function (Server $c) { |
|
170 | + $view = new View(); |
|
171 | + $util = new Encryption\Util( |
|
172 | + $view, |
|
173 | + $c->getUserManager(), |
|
174 | + $c->getGroupManager(), |
|
175 | + $c->getConfig() |
|
176 | + ); |
|
177 | + return new Encryption\Manager( |
|
178 | + $c->getConfig(), |
|
179 | + $c->getLogger(), |
|
180 | + $c->getL10N('core'), |
|
181 | + new View(), |
|
182 | + $util, |
|
183 | + new ArrayCache() |
|
184 | + ); |
|
185 | + }); |
|
186 | + |
|
187 | + $this->registerService('EncryptionFileHelper', function (Server $c) { |
|
188 | + $util = new Encryption\Util( |
|
189 | + new View(), |
|
190 | + $c->getUserManager(), |
|
191 | + $c->getGroupManager(), |
|
192 | + $c->getConfig() |
|
193 | + ); |
|
194 | + return new Encryption\File( |
|
195 | + $util, |
|
196 | + $c->getRootFolder(), |
|
197 | + $c->getShareManager() |
|
198 | + ); |
|
199 | + }); |
|
200 | + |
|
201 | + $this->registerService('EncryptionKeyStorage', function (Server $c) { |
|
202 | + $view = new View(); |
|
203 | + $util = new Encryption\Util( |
|
204 | + $view, |
|
205 | + $c->getUserManager(), |
|
206 | + $c->getGroupManager(), |
|
207 | + $c->getConfig() |
|
208 | + ); |
|
209 | + |
|
210 | + return new Encryption\Keys\Storage($view, $util); |
|
211 | + }); |
|
212 | + $this->registerService('TagMapper', function (Server $c) { |
|
213 | + return new TagMapper($c->getDatabaseConnection()); |
|
214 | + }); |
|
215 | + |
|
216 | + $this->registerService(\OCP\ITagManager::class, function (Server $c) { |
|
217 | + $tagMapper = $c->query('TagMapper'); |
|
218 | + return new TagManager($tagMapper, $c->getUserSession()); |
|
219 | + }); |
|
220 | + $this->registerAlias('TagManager', \OCP\ITagManager::class); |
|
221 | + |
|
222 | + $this->registerService('SystemTagManagerFactory', function (Server $c) { |
|
223 | + $config = $c->getConfig(); |
|
224 | + $factoryClass = $config->getSystemValue('systemtags.managerFactory', '\OC\SystemTag\ManagerFactory'); |
|
225 | + /** @var \OC\SystemTag\ManagerFactory $factory */ |
|
226 | + $factory = new $factoryClass($this); |
|
227 | + return $factory; |
|
228 | + }); |
|
229 | + $this->registerService(\OCP\SystemTag\ISystemTagManager::class, function (Server $c) { |
|
230 | + return $c->query('SystemTagManagerFactory')->getManager(); |
|
231 | + }); |
|
232 | + $this->registerAlias('SystemTagManager', \OCP\SystemTag\ISystemTagManager::class); |
|
233 | + |
|
234 | + $this->registerService(\OCP\SystemTag\ISystemTagObjectMapper::class, function (Server $c) { |
|
235 | + return $c->query('SystemTagManagerFactory')->getObjectMapper(); |
|
236 | + }); |
|
237 | + $this->registerService('RootFolder', function (Server $c) { |
|
238 | + $manager = \OC\Files\Filesystem::getMountManager(null); |
|
239 | + $view = new View(); |
|
240 | + $root = new Root( |
|
241 | + $manager, |
|
242 | + $view, |
|
243 | + null, |
|
244 | + $c->getUserMountCache(), |
|
245 | + $this->getLogger(), |
|
246 | + $this->getUserManager() |
|
247 | + ); |
|
248 | + $connector = new HookConnector($root, $view); |
|
249 | + $connector->viewToNode(); |
|
250 | + |
|
251 | + $previewConnector = new \OC\Preview\WatcherConnector($root, $c->getSystemConfig()); |
|
252 | + $previewConnector->connectWatcher(); |
|
253 | + |
|
254 | + return $root; |
|
255 | + }); |
|
256 | + $this->registerAlias('SystemTagObjectMapper', \OCP\SystemTag\ISystemTagObjectMapper::class); |
|
257 | + |
|
258 | + $this->registerService(\OCP\Files\IRootFolder::class, function(Server $c) { |
|
259 | + return new LazyRoot(function() use ($c) { |
|
260 | + return $c->query('RootFolder'); |
|
261 | + }); |
|
262 | + }); |
|
263 | + $this->registerAlias('LazyRootFolder', \OCP\Files\IRootFolder::class); |
|
264 | + |
|
265 | + $this->registerService(\OCP\IUserManager::class, function (Server $c) { |
|
266 | + $config = $c->getConfig(); |
|
267 | + return new \OC\User\Manager($config); |
|
268 | + }); |
|
269 | + $this->registerAlias('UserManager', \OCP\IUserManager::class); |
|
270 | + |
|
271 | + $this->registerService(\OCP\IGroupManager::class, function (Server $c) { |
|
272 | + $groupManager = new \OC\Group\Manager($this->getUserManager(), $this->getLogger()); |
|
273 | + $groupManager->listen('\OC\Group', 'preCreate', function ($gid) { |
|
274 | + \OC_Hook::emit('OC_Group', 'pre_createGroup', array('run' => true, 'gid' => $gid)); |
|
275 | + }); |
|
276 | + $groupManager->listen('\OC\Group', 'postCreate', function (\OC\Group\Group $gid) { |
|
277 | + \OC_Hook::emit('OC_User', 'post_createGroup', array('gid' => $gid->getGID())); |
|
278 | + }); |
|
279 | + $groupManager->listen('\OC\Group', 'preDelete', function (\OC\Group\Group $group) { |
|
280 | + \OC_Hook::emit('OC_Group', 'pre_deleteGroup', array('run' => true, 'gid' => $group->getGID())); |
|
281 | + }); |
|
282 | + $groupManager->listen('\OC\Group', 'postDelete', function (\OC\Group\Group $group) { |
|
283 | + \OC_Hook::emit('OC_User', 'post_deleteGroup', array('gid' => $group->getGID())); |
|
284 | + }); |
|
285 | + $groupManager->listen('\OC\Group', 'preAddUser', function (\OC\Group\Group $group, \OC\User\User $user) { |
|
286 | + \OC_Hook::emit('OC_Group', 'pre_addToGroup', array('run' => true, 'uid' => $user->getUID(), 'gid' => $group->getGID())); |
|
287 | + }); |
|
288 | + $groupManager->listen('\OC\Group', 'postAddUser', function (\OC\Group\Group $group, \OC\User\User $user) { |
|
289 | + \OC_Hook::emit('OC_Group', 'post_addToGroup', array('uid' => $user->getUID(), 'gid' => $group->getGID())); |
|
290 | + //Minimal fix to keep it backward compatible TODO: clean up all the GroupManager hooks |
|
291 | + \OC_Hook::emit('OC_User', 'post_addToGroup', array('uid' => $user->getUID(), 'gid' => $group->getGID())); |
|
292 | + }); |
|
293 | + return $groupManager; |
|
294 | + }); |
|
295 | + $this->registerAlias('GroupManager', \OCP\IGroupManager::class); |
|
296 | + |
|
297 | + $this->registerService(Store::class, function(Server $c) { |
|
298 | + $session = $c->getSession(); |
|
299 | + if (\OC::$server->getSystemConfig()->getValue('installed', false)) { |
|
300 | + $tokenProvider = $c->query('OC\Authentication\Token\IProvider'); |
|
301 | + } else { |
|
302 | + $tokenProvider = null; |
|
303 | + } |
|
304 | + $logger = $c->getLogger(); |
|
305 | + return new Store($session, $logger, $tokenProvider); |
|
306 | + }); |
|
307 | + $this->registerAlias(IStore::class, Store::class); |
|
308 | + $this->registerService('OC\Authentication\Token\DefaultTokenMapper', function (Server $c) { |
|
309 | + $dbConnection = $c->getDatabaseConnection(); |
|
310 | + return new Authentication\Token\DefaultTokenMapper($dbConnection); |
|
311 | + }); |
|
312 | + $this->registerService('OC\Authentication\Token\DefaultTokenProvider', function (Server $c) { |
|
313 | + $mapper = $c->query('OC\Authentication\Token\DefaultTokenMapper'); |
|
314 | + $crypto = $c->getCrypto(); |
|
315 | + $config = $c->getConfig(); |
|
316 | + $logger = $c->getLogger(); |
|
317 | + $timeFactory = new TimeFactory(); |
|
318 | + return new \OC\Authentication\Token\DefaultTokenProvider($mapper, $crypto, $config, $logger, $timeFactory); |
|
319 | + }); |
|
320 | + $this->registerAlias('OC\Authentication\Token\IProvider', 'OC\Authentication\Token\DefaultTokenProvider'); |
|
321 | + |
|
322 | + $this->registerService(\OCP\IUserSession::class, function (Server $c) { |
|
323 | + $manager = $c->getUserManager(); |
|
324 | + $session = new \OC\Session\Memory(''); |
|
325 | + $timeFactory = new TimeFactory(); |
|
326 | + // Token providers might require a working database. This code |
|
327 | + // might however be called when ownCloud is not yet setup. |
|
328 | + if (\OC::$server->getSystemConfig()->getValue('installed', false)) { |
|
329 | + $defaultTokenProvider = $c->query('OC\Authentication\Token\IProvider'); |
|
330 | + } else { |
|
331 | + $defaultTokenProvider = null; |
|
332 | + } |
|
333 | + |
|
334 | + $userSession = new \OC\User\Session($manager, $session, $timeFactory, $defaultTokenProvider, $c->getConfig(), $c->getSecureRandom(), $c->getLockdownManager()); |
|
335 | + $userSession->listen('\OC\User', 'preCreateUser', function ($uid, $password) { |
|
336 | + \OC_Hook::emit('OC_User', 'pre_createUser', array('run' => true, 'uid' => $uid, 'password' => $password)); |
|
337 | + }); |
|
338 | + $userSession->listen('\OC\User', 'postCreateUser', function ($user, $password) { |
|
339 | + /** @var $user \OC\User\User */ |
|
340 | + \OC_Hook::emit('OC_User', 'post_createUser', array('uid' => $user->getUID(), 'password' => $password)); |
|
341 | + }); |
|
342 | + $userSession->listen('\OC\User', 'preDelete', function ($user) { |
|
343 | + /** @var $user \OC\User\User */ |
|
344 | + \OC_Hook::emit('OC_User', 'pre_deleteUser', array('run' => true, 'uid' => $user->getUID())); |
|
345 | + }); |
|
346 | + $userSession->listen('\OC\User', 'postDelete', function ($user) { |
|
347 | + /** @var $user \OC\User\User */ |
|
348 | + \OC_Hook::emit('OC_User', 'post_deleteUser', array('uid' => $user->getUID())); |
|
349 | + }); |
|
350 | + $userSession->listen('\OC\User', 'preSetPassword', function ($user, $password, $recoveryPassword) { |
|
351 | + /** @var $user \OC\User\User */ |
|
352 | + \OC_Hook::emit('OC_User', 'pre_setPassword', array('run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword)); |
|
353 | + }); |
|
354 | + $userSession->listen('\OC\User', 'postSetPassword', function ($user, $password, $recoveryPassword) { |
|
355 | + /** @var $user \OC\User\User */ |
|
356 | + \OC_Hook::emit('OC_User', 'post_setPassword', array('run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword)); |
|
357 | + }); |
|
358 | + $userSession->listen('\OC\User', 'preLogin', function ($uid, $password) { |
|
359 | + \OC_Hook::emit('OC_User', 'pre_login', array('run' => true, 'uid' => $uid, 'password' => $password)); |
|
360 | + }); |
|
361 | + $userSession->listen('\OC\User', 'postLogin', function ($user, $password) { |
|
362 | + /** @var $user \OC\User\User */ |
|
363 | + \OC_Hook::emit('OC_User', 'post_login', array('run' => true, 'uid' => $user->getUID(), 'password' => $password)); |
|
364 | + }); |
|
365 | + $userSession->listen('\OC\User', 'logout', function () { |
|
366 | + \OC_Hook::emit('OC_User', 'logout', array()); |
|
367 | + }); |
|
368 | + $userSession->listen('\OC\User', 'changeUser', function ($user, $feature, $value, $oldValue) { |
|
369 | + /** @var $user \OC\User\User */ |
|
370 | + \OC_Hook::emit('OC_User', 'changeUser', array('run' => true, 'user' => $user, 'feature' => $feature, 'value' => $value, 'old_value' => $oldValue)); |
|
371 | + }); |
|
372 | + return $userSession; |
|
373 | + }); |
|
374 | + $this->registerAlias('UserSession', \OCP\IUserSession::class); |
|
375 | + |
|
376 | + $this->registerService(\OC\Authentication\TwoFactorAuth\Manager::class, function (Server $c) { |
|
377 | + return new \OC\Authentication\TwoFactorAuth\Manager($c->getAppManager(), $c->getSession(), $c->getConfig(), $c->getActivityManager(), $c->getLogger()); |
|
378 | + }); |
|
379 | + |
|
380 | + $this->registerAlias(\OCP\INavigationManager::class, \OC\NavigationManager::class); |
|
381 | + $this->registerAlias('NavigationManager', \OCP\INavigationManager::class); |
|
382 | + |
|
383 | + $this->registerService(\OC\AllConfig::class, function (Server $c) { |
|
384 | + return new \OC\AllConfig( |
|
385 | + $c->getSystemConfig() |
|
386 | + ); |
|
387 | + }); |
|
388 | + $this->registerAlias('AllConfig', \OC\AllConfig::class); |
|
389 | + $this->registerAlias(\OCP\IConfig::class, \OC\AllConfig::class); |
|
390 | + |
|
391 | + $this->registerService('SystemConfig', function ($c) use ($config) { |
|
392 | + return new \OC\SystemConfig($config); |
|
393 | + }); |
|
394 | + |
|
395 | + $this->registerService(\OC\AppConfig::class, function (Server $c) { |
|
396 | + return new \OC\AppConfig($c->getDatabaseConnection()); |
|
397 | + }); |
|
398 | + $this->registerAlias('AppConfig', \OC\AppConfig::class); |
|
399 | + $this->registerAlias(\OCP\IAppConfig::class, \OC\AppConfig::class); |
|
400 | + |
|
401 | + $this->registerService(\OCP\L10N\IFactory::class, function (Server $c) { |
|
402 | + return new \OC\L10N\Factory( |
|
403 | + $c->getConfig(), |
|
404 | + $c->getRequest(), |
|
405 | + $c->getUserSession(), |
|
406 | + \OC::$SERVERROOT |
|
407 | + ); |
|
408 | + }); |
|
409 | + $this->registerAlias('L10NFactory', \OCP\L10N\IFactory::class); |
|
410 | + |
|
411 | + $this->registerService(\OCP\IURLGenerator::class, function (Server $c) { |
|
412 | + $config = $c->getConfig(); |
|
413 | + $cacheFactory = $c->getMemCacheFactory(); |
|
414 | + return new \OC\URLGenerator( |
|
415 | + $config, |
|
416 | + $cacheFactory |
|
417 | + ); |
|
418 | + }); |
|
419 | + $this->registerAlias('URLGenerator', \OCP\IURLGenerator::class); |
|
420 | + |
|
421 | + $this->registerService('AppHelper', function ($c) { |
|
422 | + return new \OC\AppHelper(); |
|
423 | + }); |
|
424 | + $this->registerAlias('AppFetcher', AppFetcher::class); |
|
425 | + $this->registerAlias('CategoryFetcher', CategoryFetcher::class); |
|
426 | + |
|
427 | + $this->registerService(\OCP\ICache::class, function ($c) { |
|
428 | + return new Cache\File(); |
|
429 | + }); |
|
430 | + $this->registerAlias('UserCache', \OCP\ICache::class); |
|
431 | + |
|
432 | + $this->registerService(Factory::class, function (Server $c) { |
|
433 | + $config = $c->getConfig(); |
|
434 | + |
|
435 | + if ($config->getSystemValue('installed', false) && !(defined('PHPUNIT_RUN') && PHPUNIT_RUN)) { |
|
436 | + $v = \OC_App::getAppVersions(); |
|
437 | + $v['core'] = md5(file_get_contents(\OC::$SERVERROOT . '/version.php')); |
|
438 | + $version = implode(',', $v); |
|
439 | + $instanceId = \OC_Util::getInstanceId(); |
|
440 | + $path = \OC::$SERVERROOT; |
|
441 | + $prefix = md5($instanceId . '-' . $version . '-' . $path . '-' . \OC::$WEBROOT); |
|
442 | + return new \OC\Memcache\Factory($prefix, $c->getLogger(), |
|
443 | + $config->getSystemValue('memcache.local', null), |
|
444 | + $config->getSystemValue('memcache.distributed', null), |
|
445 | + $config->getSystemValue('memcache.locking', null) |
|
446 | + ); |
|
447 | + } |
|
448 | + |
|
449 | + return new \OC\Memcache\Factory('', $c->getLogger(), |
|
450 | + '\\OC\\Memcache\\ArrayCache', |
|
451 | + '\\OC\\Memcache\\ArrayCache', |
|
452 | + '\\OC\\Memcache\\ArrayCache' |
|
453 | + ); |
|
454 | + }); |
|
455 | + $this->registerAlias('MemCacheFactory', Factory::class); |
|
456 | + $this->registerAlias(ICacheFactory::class, Factory::class); |
|
457 | + |
|
458 | + $this->registerService('RedisFactory', function (Server $c) { |
|
459 | + $systemConfig = $c->getSystemConfig(); |
|
460 | + return new RedisFactory($systemConfig); |
|
461 | + }); |
|
462 | + |
|
463 | + $this->registerService(\OCP\Activity\IManager::class, function (Server $c) { |
|
464 | + return new \OC\Activity\Manager( |
|
465 | + $c->getRequest(), |
|
466 | + $c->getUserSession(), |
|
467 | + $c->getConfig(), |
|
468 | + $c->query(IValidator::class) |
|
469 | + ); |
|
470 | + }); |
|
471 | + $this->registerAlias('ActivityManager', \OCP\Activity\IManager::class); |
|
472 | + |
|
473 | + $this->registerService(\OCP\Activity\IEventMerger::class, function (Server $c) { |
|
474 | + return new \OC\Activity\EventMerger( |
|
475 | + $c->getL10N('lib') |
|
476 | + ); |
|
477 | + }); |
|
478 | + $this->registerAlias(IValidator::class, Validator::class); |
|
479 | + |
|
480 | + $this->registerService(\OCP\IAvatarManager::class, function (Server $c) { |
|
481 | + return new AvatarManager( |
|
482 | + $c->getUserManager(), |
|
483 | + $c->getAppDataDir('avatar'), |
|
484 | + $c->getL10N('lib'), |
|
485 | + $c->getLogger(), |
|
486 | + $c->getConfig() |
|
487 | + ); |
|
488 | + }); |
|
489 | + $this->registerAlias('AvatarManager', \OCP\IAvatarManager::class); |
|
490 | + |
|
491 | + $this->registerService(\OCP\ILogger::class, function (Server $c) { |
|
492 | + $logType = $c->query('AllConfig')->getSystemValue('log_type', 'file'); |
|
493 | + $logger = Log::getLogClass($logType); |
|
494 | + call_user_func(array($logger, 'init')); |
|
495 | + |
|
496 | + return new Log($logger); |
|
497 | + }); |
|
498 | + $this->registerAlias('Logger', \OCP\ILogger::class); |
|
499 | + |
|
500 | + $this->registerService(\OCP\BackgroundJob\IJobList::class, function (Server $c) { |
|
501 | + $config = $c->getConfig(); |
|
502 | + return new \OC\BackgroundJob\JobList( |
|
503 | + $c->getDatabaseConnection(), |
|
504 | + $config, |
|
505 | + new TimeFactory() |
|
506 | + ); |
|
507 | + }); |
|
508 | + $this->registerAlias('JobList', \OCP\BackgroundJob\IJobList::class); |
|
509 | + |
|
510 | + $this->registerService(\OCP\Route\IRouter::class, function (Server $c) { |
|
511 | + $cacheFactory = $c->getMemCacheFactory(); |
|
512 | + $logger = $c->getLogger(); |
|
513 | + if ($cacheFactory->isAvailable()) { |
|
514 | + $router = new \OC\Route\CachingRouter($cacheFactory->create('route'), $logger); |
|
515 | + } else { |
|
516 | + $router = new \OC\Route\Router($logger); |
|
517 | + } |
|
518 | + return $router; |
|
519 | + }); |
|
520 | + $this->registerAlias('Router', \OCP\Route\IRouter::class); |
|
521 | + |
|
522 | + $this->registerService(\OCP\ISearch::class, function ($c) { |
|
523 | + return new Search(); |
|
524 | + }); |
|
525 | + $this->registerAlias('Search', \OCP\ISearch::class); |
|
526 | + |
|
527 | + $this->registerService(\OC\Security\RateLimiting\Limiter::class, function($c) { |
|
528 | + return new \OC\Security\RateLimiting\Limiter( |
|
529 | + $this->getUserSession(), |
|
530 | + $this->getRequest(), |
|
531 | + new \OC\AppFramework\Utility\TimeFactory(), |
|
532 | + $c->query(\OC\Security\RateLimiting\Backend\IBackend::class) |
|
533 | + ); |
|
534 | + }); |
|
535 | + $this->registerService(\OC\Security\RateLimiting\Backend\IBackend::class, function($c) { |
|
536 | + return new \OC\Security\RateLimiting\Backend\MemoryCache( |
|
537 | + $this->getMemCacheFactory(), |
|
538 | + new \OC\AppFramework\Utility\TimeFactory() |
|
539 | + ); |
|
540 | + }); |
|
541 | + |
|
542 | + $this->registerService(\OCP\Security\ISecureRandom::class, function ($c) { |
|
543 | + return new SecureRandom(); |
|
544 | + }); |
|
545 | + $this->registerAlias('SecureRandom', \OCP\Security\ISecureRandom::class); |
|
546 | + |
|
547 | + $this->registerService(\OCP\Security\ICrypto::class, function (Server $c) { |
|
548 | + return new Crypto($c->getConfig(), $c->getSecureRandom()); |
|
549 | + }); |
|
550 | + $this->registerAlias('Crypto', \OCP\Security\ICrypto::class); |
|
551 | + |
|
552 | + $this->registerService(\OCP\Security\IHasher::class, function (Server $c) { |
|
553 | + return new Hasher($c->getConfig()); |
|
554 | + }); |
|
555 | + $this->registerAlias('Hasher', \OCP\Security\IHasher::class); |
|
556 | + |
|
557 | + $this->registerService(\OCP\Security\ICredentialsManager::class, function (Server $c) { |
|
558 | + return new CredentialsManager($c->getCrypto(), $c->getDatabaseConnection()); |
|
559 | + }); |
|
560 | + $this->registerAlias('CredentialsManager', \OCP\Security\ICredentialsManager::class); |
|
561 | + |
|
562 | + $this->registerService(IDBConnection::class, function (Server $c) { |
|
563 | + $systemConfig = $c->getSystemConfig(); |
|
564 | + $factory = new \OC\DB\ConnectionFactory($systemConfig); |
|
565 | + $type = $systemConfig->getValue('dbtype', 'sqlite'); |
|
566 | + if (!$factory->isValidType($type)) { |
|
567 | + throw new \OC\DatabaseException('Invalid database type'); |
|
568 | + } |
|
569 | + $connectionParams = $factory->createConnectionParams(); |
|
570 | + $connection = $factory->getConnection($type, $connectionParams); |
|
571 | + $connection->getConfiguration()->setSQLLogger($c->getQueryLogger()); |
|
572 | + return $connection; |
|
573 | + }); |
|
574 | + $this->registerAlias('DatabaseConnection', IDBConnection::class); |
|
575 | + |
|
576 | + $this->registerService('HTTPHelper', function (Server $c) { |
|
577 | + $config = $c->getConfig(); |
|
578 | + return new HTTPHelper( |
|
579 | + $config, |
|
580 | + $c->getHTTPClientService() |
|
581 | + ); |
|
582 | + }); |
|
583 | + |
|
584 | + $this->registerService(\OCP\Http\Client\IClientService::class, function (Server $c) { |
|
585 | + $user = \OC_User::getUser(); |
|
586 | + $uid = $user ? $user : null; |
|
587 | + return new ClientService( |
|
588 | + $c->getConfig(), |
|
589 | + new \OC\Security\CertificateManager($uid, new View(), $c->getConfig(), $c->getLogger()) |
|
590 | + ); |
|
591 | + }); |
|
592 | + $this->registerAlias('HttpClientService', \OCP\Http\Client\IClientService::class); |
|
593 | + $this->registerService(\OCP\Diagnostics\IEventLogger::class, function (Server $c) { |
|
594 | + $eventLogger = new EventLogger(); |
|
595 | + if ($c->getSystemConfig()->getValue('debug', false)) { |
|
596 | + // In debug mode, module is being activated by default |
|
597 | + $eventLogger->activate(); |
|
598 | + } |
|
599 | + return $eventLogger; |
|
600 | + }); |
|
601 | + $this->registerAlias('EventLogger', \OCP\Diagnostics\IEventLogger::class); |
|
602 | + |
|
603 | + $this->registerService(\OCP\Diagnostics\IQueryLogger::class, function (Server $c) { |
|
604 | + $queryLogger = new QueryLogger(); |
|
605 | + if ($c->getSystemConfig()->getValue('debug', false)) { |
|
606 | + // In debug mode, module is being activated by default |
|
607 | + $queryLogger->activate(); |
|
608 | + } |
|
609 | + return $queryLogger; |
|
610 | + }); |
|
611 | + $this->registerAlias('QueryLogger', \OCP\Diagnostics\IQueryLogger::class); |
|
612 | + |
|
613 | + $this->registerService(TempManager::class, function (Server $c) { |
|
614 | + return new TempManager( |
|
615 | + $c->getLogger(), |
|
616 | + $c->getConfig() |
|
617 | + ); |
|
618 | + }); |
|
619 | + $this->registerAlias('TempManager', TempManager::class); |
|
620 | + $this->registerAlias(ITempManager::class, TempManager::class); |
|
621 | + |
|
622 | + $this->registerService(AppManager::class, function (Server $c) { |
|
623 | + return new \OC\App\AppManager( |
|
624 | + $c->getUserSession(), |
|
625 | + $c->getAppConfig(), |
|
626 | + $c->getGroupManager(), |
|
627 | + $c->getMemCacheFactory(), |
|
628 | + $c->getEventDispatcher() |
|
629 | + ); |
|
630 | + }); |
|
631 | + $this->registerAlias('AppManager', AppManager::class); |
|
632 | + $this->registerAlias(IAppManager::class, AppManager::class); |
|
633 | + |
|
634 | + $this->registerService(\OCP\IDateTimeZone::class, function (Server $c) { |
|
635 | + return new DateTimeZone( |
|
636 | + $c->getConfig(), |
|
637 | + $c->getSession() |
|
638 | + ); |
|
639 | + }); |
|
640 | + $this->registerAlias('DateTimeZone', \OCP\IDateTimeZone::class); |
|
641 | + |
|
642 | + $this->registerService(\OCP\IDateTimeFormatter::class, function (Server $c) { |
|
643 | + $language = $c->getConfig()->getUserValue($c->getSession()->get('user_id'), 'core', 'lang', null); |
|
644 | + |
|
645 | + return new DateTimeFormatter( |
|
646 | + $c->getDateTimeZone()->getTimeZone(), |
|
647 | + $c->getL10N('lib', $language) |
|
648 | + ); |
|
649 | + }); |
|
650 | + $this->registerAlias('DateTimeFormatter', \OCP\IDateTimeFormatter::class); |
|
651 | + |
|
652 | + $this->registerService(\OCP\Files\Config\IUserMountCache::class, function (Server $c) { |
|
653 | + $mountCache = new UserMountCache($c->getDatabaseConnection(), $c->getUserManager(), $c->getLogger()); |
|
654 | + $listener = new UserMountCacheListener($mountCache); |
|
655 | + $listener->listen($c->getUserManager()); |
|
656 | + return $mountCache; |
|
657 | + }); |
|
658 | + $this->registerAlias('UserMountCache', \OCP\Files\Config\IUserMountCache::class); |
|
659 | + |
|
660 | + $this->registerService(\OCP\Files\Config\IMountProviderCollection::class, function (Server $c) { |
|
661 | + $loader = \OC\Files\Filesystem::getLoader(); |
|
662 | + $mountCache = $c->query('UserMountCache'); |
|
663 | + $manager = new \OC\Files\Config\MountProviderCollection($loader, $mountCache); |
|
664 | + |
|
665 | + // builtin providers |
|
666 | + |
|
667 | + $config = $c->getConfig(); |
|
668 | + $manager->registerProvider(new CacheMountProvider($config)); |
|
669 | + $manager->registerHomeProvider(new LocalHomeMountProvider()); |
|
670 | + $manager->registerHomeProvider(new ObjectHomeMountProvider($config)); |
|
671 | + |
|
672 | + return $manager; |
|
673 | + }); |
|
674 | + $this->registerAlias('MountConfigManager', \OCP\Files\Config\IMountProviderCollection::class); |
|
675 | + |
|
676 | + $this->registerService('IniWrapper', function ($c) { |
|
677 | + return new IniGetWrapper(); |
|
678 | + }); |
|
679 | + $this->registerService('AsyncCommandBus', function (Server $c) { |
|
680 | + $jobList = $c->getJobList(); |
|
681 | + return new AsyncBus($jobList); |
|
682 | + }); |
|
683 | + $this->registerService('TrustedDomainHelper', function ($c) { |
|
684 | + return new TrustedDomainHelper($this->getConfig()); |
|
685 | + }); |
|
686 | + $this->registerService('Throttler', function(Server $c) { |
|
687 | + return new Throttler( |
|
688 | + $c->getDatabaseConnection(), |
|
689 | + new TimeFactory(), |
|
690 | + $c->getLogger(), |
|
691 | + $c->getConfig() |
|
692 | + ); |
|
693 | + }); |
|
694 | + $this->registerService('IntegrityCodeChecker', function (Server $c) { |
|
695 | + // IConfig and IAppManager requires a working database. This code |
|
696 | + // might however be called when ownCloud is not yet setup. |
|
697 | + if(\OC::$server->getSystemConfig()->getValue('installed', false)) { |
|
698 | + $config = $c->getConfig(); |
|
699 | + $appManager = $c->getAppManager(); |
|
700 | + } else { |
|
701 | + $config = null; |
|
702 | + $appManager = null; |
|
703 | + } |
|
704 | + |
|
705 | + return new Checker( |
|
706 | + new EnvironmentHelper(), |
|
707 | + new FileAccessHelper(), |
|
708 | + new AppLocator(), |
|
709 | + $config, |
|
710 | + $c->getMemCacheFactory(), |
|
711 | + $appManager, |
|
712 | + $c->getTempManager() |
|
713 | + ); |
|
714 | + }); |
|
715 | + $this->registerService(\OCP\IRequest::class, function ($c) { |
|
716 | + if (isset($this['urlParams'])) { |
|
717 | + $urlParams = $this['urlParams']; |
|
718 | + } else { |
|
719 | + $urlParams = []; |
|
720 | + } |
|
721 | + |
|
722 | + if (defined('PHPUNIT_RUN') && PHPUNIT_RUN |
|
723 | + && in_array('fakeinput', stream_get_wrappers()) |
|
724 | + ) { |
|
725 | + $stream = 'fakeinput://data'; |
|
726 | + } else { |
|
727 | + $stream = 'php://input'; |
|
728 | + } |
|
729 | + |
|
730 | + return new Request( |
|
731 | + [ |
|
732 | + 'get' => $_GET, |
|
733 | + 'post' => $_POST, |
|
734 | + 'files' => $_FILES, |
|
735 | + 'server' => $_SERVER, |
|
736 | + 'env' => $_ENV, |
|
737 | + 'cookies' => $_COOKIE, |
|
738 | + 'method' => (isset($_SERVER) && isset($_SERVER['REQUEST_METHOD'])) |
|
739 | + ? $_SERVER['REQUEST_METHOD'] |
|
740 | + : null, |
|
741 | + 'urlParams' => $urlParams, |
|
742 | + ], |
|
743 | + $this->getSecureRandom(), |
|
744 | + $this->getConfig(), |
|
745 | + $this->getCsrfTokenManager(), |
|
746 | + $stream |
|
747 | + ); |
|
748 | + }); |
|
749 | + $this->registerAlias('Request', \OCP\IRequest::class); |
|
750 | + |
|
751 | + $this->registerService(\OCP\Mail\IMailer::class, function (Server $c) { |
|
752 | + return new Mailer( |
|
753 | + $c->getConfig(), |
|
754 | + $c->getLogger(), |
|
755 | + $c->query(Defaults::class), |
|
756 | + $c->getURLGenerator(), |
|
757 | + $c->getL10N('lib') |
|
758 | + ); |
|
759 | + }); |
|
760 | + $this->registerAlias('Mailer', \OCP\Mail\IMailer::class); |
|
761 | + |
|
762 | + $this->registerService('LDAPProvider', function(Server $c) { |
|
763 | + $config = $c->getConfig(); |
|
764 | + $factoryClass = $config->getSystemValue('ldapProviderFactory', null); |
|
765 | + if(is_null($factoryClass)) { |
|
766 | + throw new \Exception('ldapProviderFactory not set'); |
|
767 | + } |
|
768 | + /** @var \OCP\LDAP\ILDAPProviderFactory $factory */ |
|
769 | + $factory = new $factoryClass($this); |
|
770 | + return $factory->getLDAPProvider(); |
|
771 | + }); |
|
772 | + $this->registerService('LockingProvider', function (Server $c) { |
|
773 | + $ini = $c->getIniWrapper(); |
|
774 | + $config = $c->getConfig(); |
|
775 | + $ttl = $config->getSystemValue('filelocking.ttl', max(3600, $ini->getNumeric('max_execution_time'))); |
|
776 | + if ($config->getSystemValue('filelocking.enabled', true) or (defined('PHPUNIT_RUN') && PHPUNIT_RUN)) { |
|
777 | + /** @var \OC\Memcache\Factory $memcacheFactory */ |
|
778 | + $memcacheFactory = $c->getMemCacheFactory(); |
|
779 | + $memcache = $memcacheFactory->createLocking('lock'); |
|
780 | + if (!($memcache instanceof \OC\Memcache\NullCache)) { |
|
781 | + return new MemcacheLockingProvider($memcache, $ttl); |
|
782 | + } |
|
783 | + return new DBLockingProvider($c->getDatabaseConnection(), $c->getLogger(), new TimeFactory(), $ttl); |
|
784 | + } |
|
785 | + return new NoopLockingProvider(); |
|
786 | + }); |
|
787 | + |
|
788 | + $this->registerService(\OCP\Files\Mount\IMountManager::class, function () { |
|
789 | + return new \OC\Files\Mount\Manager(); |
|
790 | + }); |
|
791 | + $this->registerAlias('MountManager', \OCP\Files\Mount\IMountManager::class); |
|
792 | + |
|
793 | + $this->registerService(\OCP\Files\IMimeTypeDetector::class, function (Server $c) { |
|
794 | + return new \OC\Files\Type\Detection( |
|
795 | + $c->getURLGenerator(), |
|
796 | + \OC::$configDir, |
|
797 | + \OC::$SERVERROOT . '/resources/config/' |
|
798 | + ); |
|
799 | + }); |
|
800 | + $this->registerAlias('MimeTypeDetector', \OCP\Files\IMimeTypeDetector::class); |
|
801 | + |
|
802 | + $this->registerService(\OCP\Files\IMimeTypeLoader::class, function (Server $c) { |
|
803 | + return new \OC\Files\Type\Loader( |
|
804 | + $c->getDatabaseConnection() |
|
805 | + ); |
|
806 | + }); |
|
807 | + $this->registerAlias('MimeTypeLoader', \OCP\Files\IMimeTypeLoader::class); |
|
808 | + $this->registerService(BundleFetcher::class, function () { |
|
809 | + return new BundleFetcher($this->getL10N('lib')); |
|
810 | + }); |
|
811 | + $this->registerService(\OCP\Notification\IManager::class, function (Server $c) { |
|
812 | + return new Manager( |
|
813 | + $c->query(IValidator::class) |
|
814 | + ); |
|
815 | + }); |
|
816 | + $this->registerAlias('NotificationManager', \OCP\Notification\IManager::class); |
|
817 | + |
|
818 | + $this->registerService(\OC\CapabilitiesManager::class, function (Server $c) { |
|
819 | + $manager = new \OC\CapabilitiesManager($c->getLogger()); |
|
820 | + $manager->registerCapability(function () use ($c) { |
|
821 | + return new \OC\OCS\CoreCapabilities($c->getConfig()); |
|
822 | + }); |
|
823 | + return $manager; |
|
824 | + }); |
|
825 | + $this->registerAlias('CapabilitiesManager', \OC\CapabilitiesManager::class); |
|
826 | + |
|
827 | + $this->registerService(\OCP\Comments\ICommentsManager::class, function(Server $c) { |
|
828 | + $config = $c->getConfig(); |
|
829 | + $factoryClass = $config->getSystemValue('comments.managerFactory', '\OC\Comments\ManagerFactory'); |
|
830 | + /** @var \OCP\Comments\ICommentsManagerFactory $factory */ |
|
831 | + $factory = new $factoryClass($this); |
|
832 | + return $factory->getManager(); |
|
833 | + }); |
|
834 | + $this->registerAlias('CommentsManager', \OCP\Comments\ICommentsManager::class); |
|
835 | + |
|
836 | + $this->registerService('ThemingDefaults', function(Server $c) { |
|
837 | + /* |
|
838 | 838 | * Dark magic for autoloader. |
839 | 839 | * If we do a class_exists it will try to load the class which will |
840 | 840 | * make composer cache the result. Resulting in errors when enabling |
841 | 841 | * the theming app. |
842 | 842 | */ |
843 | - $prefixes = \OC::$composerAutoloader->getPrefixesPsr4(); |
|
844 | - if (isset($prefixes['OCA\\Theming\\'])) { |
|
845 | - $classExists = true; |
|
846 | - } else { |
|
847 | - $classExists = false; |
|
848 | - } |
|
849 | - |
|
850 | - if ($classExists && $c->getConfig()->getSystemValue('installed', false) && $c->getAppManager()->isInstalled('theming')) { |
|
851 | - return new ThemingDefaults( |
|
852 | - $c->getConfig(), |
|
853 | - $c->getL10N('theming'), |
|
854 | - $c->getURLGenerator(), |
|
855 | - $c->getAppDataDir('theming'), |
|
856 | - $c->getMemCacheFactory(), |
|
857 | - new Util($c->getConfig(), $this->getRootFolder(), $this->getAppManager()) |
|
858 | - ); |
|
859 | - } |
|
860 | - return new \OC_Defaults(); |
|
861 | - }); |
|
862 | - $this->registerService(SCSSCacher::class, function(Server $c) { |
|
863 | - /** @var Factory $cacheFactory */ |
|
864 | - $cacheFactory = $c->query(Factory::class); |
|
865 | - return new SCSSCacher( |
|
866 | - $c->getLogger(), |
|
867 | - $c->query(\OC\Files\AppData\Factory::class), |
|
868 | - $c->getURLGenerator(), |
|
869 | - $c->getConfig(), |
|
870 | - $c->getThemingDefaults(), |
|
871 | - \OC::$SERVERROOT, |
|
872 | - $cacheFactory->create('SCSS') |
|
873 | - ); |
|
874 | - }); |
|
875 | - $this->registerService(EventDispatcher::class, function () { |
|
876 | - return new EventDispatcher(); |
|
877 | - }); |
|
878 | - $this->registerAlias('EventDispatcher', EventDispatcher::class); |
|
879 | - $this->registerAlias(EventDispatcherInterface::class, EventDispatcher::class); |
|
880 | - |
|
881 | - $this->registerService('CryptoWrapper', function (Server $c) { |
|
882 | - // FIXME: Instantiiated here due to cyclic dependency |
|
883 | - $request = new Request( |
|
884 | - [ |
|
885 | - 'get' => $_GET, |
|
886 | - 'post' => $_POST, |
|
887 | - 'files' => $_FILES, |
|
888 | - 'server' => $_SERVER, |
|
889 | - 'env' => $_ENV, |
|
890 | - 'cookies' => $_COOKIE, |
|
891 | - 'method' => (isset($_SERVER) && isset($_SERVER['REQUEST_METHOD'])) |
|
892 | - ? $_SERVER['REQUEST_METHOD'] |
|
893 | - : null, |
|
894 | - ], |
|
895 | - $c->getSecureRandom(), |
|
896 | - $c->getConfig() |
|
897 | - ); |
|
898 | - |
|
899 | - return new CryptoWrapper( |
|
900 | - $c->getConfig(), |
|
901 | - $c->getCrypto(), |
|
902 | - $c->getSecureRandom(), |
|
903 | - $request |
|
904 | - ); |
|
905 | - }); |
|
906 | - $this->registerService('CsrfTokenManager', function (Server $c) { |
|
907 | - $tokenGenerator = new CsrfTokenGenerator($c->getSecureRandom()); |
|
908 | - |
|
909 | - return new CsrfTokenManager( |
|
910 | - $tokenGenerator, |
|
911 | - $c->query(SessionStorage::class) |
|
912 | - ); |
|
913 | - }); |
|
914 | - $this->registerService(SessionStorage::class, function (Server $c) { |
|
915 | - return new SessionStorage($c->getSession()); |
|
916 | - }); |
|
917 | - $this->registerService(\OCP\Security\IContentSecurityPolicyManager::class, function (Server $c) { |
|
918 | - return new ContentSecurityPolicyManager(); |
|
919 | - }); |
|
920 | - $this->registerAlias('ContentSecurityPolicyManager', \OCP\Security\IContentSecurityPolicyManager::class); |
|
921 | - |
|
922 | - $this->registerService('ContentSecurityPolicyNonceManager', function(Server $c) { |
|
923 | - return new ContentSecurityPolicyNonceManager( |
|
924 | - $c->getCsrfTokenManager(), |
|
925 | - $c->getRequest() |
|
926 | - ); |
|
927 | - }); |
|
928 | - |
|
929 | - $this->registerService(\OCP\Share\IManager::class, function(Server $c) { |
|
930 | - $config = $c->getConfig(); |
|
931 | - $factoryClass = $config->getSystemValue('sharing.managerFactory', '\OC\Share20\ProviderFactory'); |
|
932 | - /** @var \OCP\Share\IProviderFactory $factory */ |
|
933 | - $factory = new $factoryClass($this); |
|
934 | - |
|
935 | - $manager = new \OC\Share20\Manager( |
|
936 | - $c->getLogger(), |
|
937 | - $c->getConfig(), |
|
938 | - $c->getSecureRandom(), |
|
939 | - $c->getHasher(), |
|
940 | - $c->getMountManager(), |
|
941 | - $c->getGroupManager(), |
|
942 | - $c->getL10N('core'), |
|
943 | - $factory, |
|
944 | - $c->getUserManager(), |
|
945 | - $c->getLazyRootFolder(), |
|
946 | - $c->getEventDispatcher() |
|
947 | - ); |
|
948 | - |
|
949 | - return $manager; |
|
950 | - }); |
|
951 | - $this->registerAlias('ShareManager', \OCP\Share\IManager::class); |
|
952 | - |
|
953 | - $this->registerService('SettingsManager', function(Server $c) { |
|
954 | - $manager = new \OC\Settings\Manager( |
|
955 | - $c->getLogger(), |
|
956 | - $c->getDatabaseConnection(), |
|
957 | - $c->getL10N('lib'), |
|
958 | - $c->getConfig(), |
|
959 | - $c->getEncryptionManager(), |
|
960 | - $c->getUserManager(), |
|
961 | - $c->getLockingProvider(), |
|
962 | - $c->getRequest(), |
|
963 | - new \OC\Settings\Mapper($c->getDatabaseConnection()), |
|
964 | - $c->getURLGenerator(), |
|
965 | - $c->query(AccountManager::class), |
|
966 | - $c->getGroupManager(), |
|
967 | - $c->getL10NFactory() |
|
968 | - ); |
|
969 | - return $manager; |
|
970 | - }); |
|
971 | - $this->registerService(\OC\Files\AppData\Factory::class, function (Server $c) { |
|
972 | - return new \OC\Files\AppData\Factory( |
|
973 | - $c->getRootFolder(), |
|
974 | - $c->getSystemConfig() |
|
975 | - ); |
|
976 | - }); |
|
977 | - |
|
978 | - $this->registerService('LockdownManager', function (Server $c) { |
|
979 | - return new LockdownManager(function() use ($c) { |
|
980 | - return $c->getSession(); |
|
981 | - }); |
|
982 | - }); |
|
983 | - |
|
984 | - $this->registerService(\OCP\OCS\IDiscoveryService::class, function (Server $c) { |
|
985 | - return new DiscoveryService($c->getMemCacheFactory(), $c->getHTTPClientService()); |
|
986 | - }); |
|
987 | - |
|
988 | - $this->registerService(ICloudIdManager::class, function (Server $c) { |
|
989 | - return new CloudIdManager(); |
|
990 | - }); |
|
991 | - |
|
992 | - /* To trick DI since we don't extend the DIContainer here */ |
|
993 | - $this->registerService(CleanPreviewsBackgroundJob::class, function (Server $c) { |
|
994 | - return new CleanPreviewsBackgroundJob( |
|
995 | - $c->getRootFolder(), |
|
996 | - $c->getLogger(), |
|
997 | - $c->getJobList(), |
|
998 | - new TimeFactory() |
|
999 | - ); |
|
1000 | - }); |
|
1001 | - |
|
1002 | - $this->registerAlias(\OCP\AppFramework\Utility\IControllerMethodReflector::class, \OC\AppFramework\Utility\ControllerMethodReflector::class); |
|
1003 | - $this->registerAlias('ControllerMethodReflector', \OCP\AppFramework\Utility\IControllerMethodReflector::class); |
|
1004 | - |
|
1005 | - $this->registerAlias(\OCP\AppFramework\Utility\ITimeFactory::class, \OC\AppFramework\Utility\TimeFactory::class); |
|
1006 | - $this->registerAlias('TimeFactory', \OCP\AppFramework\Utility\ITimeFactory::class); |
|
1007 | - |
|
1008 | - $this->registerService(Defaults::class, function (Server $c) { |
|
1009 | - return new Defaults( |
|
1010 | - $c->getThemingDefaults() |
|
1011 | - ); |
|
1012 | - }); |
|
1013 | - $this->registerAlias('Defaults', \OCP\Defaults::class); |
|
1014 | - |
|
1015 | - $this->registerService(\OCP\ISession::class, function(SimpleContainer $c) { |
|
1016 | - return $c->query(\OCP\IUserSession::class)->getSession(); |
|
1017 | - }); |
|
1018 | - |
|
1019 | - $this->registerService(IShareHelper::class, function(Server $c) { |
|
1020 | - return new ShareHelper( |
|
1021 | - $c->query(\OCP\Share\IManager::class) |
|
1022 | - ); |
|
1023 | - }); |
|
1024 | - } |
|
1025 | - |
|
1026 | - /** |
|
1027 | - * @return \OCP\Contacts\IManager |
|
1028 | - */ |
|
1029 | - public function getContactsManager() { |
|
1030 | - return $this->query('ContactsManager'); |
|
1031 | - } |
|
1032 | - |
|
1033 | - /** |
|
1034 | - * @return \OC\Encryption\Manager |
|
1035 | - */ |
|
1036 | - public function getEncryptionManager() { |
|
1037 | - return $this->query('EncryptionManager'); |
|
1038 | - } |
|
1039 | - |
|
1040 | - /** |
|
1041 | - * @return \OC\Encryption\File |
|
1042 | - */ |
|
1043 | - public function getEncryptionFilesHelper() { |
|
1044 | - return $this->query('EncryptionFileHelper'); |
|
1045 | - } |
|
1046 | - |
|
1047 | - /** |
|
1048 | - * @return \OCP\Encryption\Keys\IStorage |
|
1049 | - */ |
|
1050 | - public function getEncryptionKeyStorage() { |
|
1051 | - return $this->query('EncryptionKeyStorage'); |
|
1052 | - } |
|
1053 | - |
|
1054 | - /** |
|
1055 | - * The current request object holding all information about the request |
|
1056 | - * currently being processed is returned from this method. |
|
1057 | - * In case the current execution was not initiated by a web request null is returned |
|
1058 | - * |
|
1059 | - * @return \OCP\IRequest |
|
1060 | - */ |
|
1061 | - public function getRequest() { |
|
1062 | - return $this->query('Request'); |
|
1063 | - } |
|
1064 | - |
|
1065 | - /** |
|
1066 | - * Returns the preview manager which can create preview images for a given file |
|
1067 | - * |
|
1068 | - * @return \OCP\IPreview |
|
1069 | - */ |
|
1070 | - public function getPreviewManager() { |
|
1071 | - return $this->query('PreviewManager'); |
|
1072 | - } |
|
1073 | - |
|
1074 | - /** |
|
1075 | - * Returns the tag manager which can get and set tags for different object types |
|
1076 | - * |
|
1077 | - * @see \OCP\ITagManager::load() |
|
1078 | - * @return \OCP\ITagManager |
|
1079 | - */ |
|
1080 | - public function getTagManager() { |
|
1081 | - return $this->query('TagManager'); |
|
1082 | - } |
|
1083 | - |
|
1084 | - /** |
|
1085 | - * Returns the system-tag manager |
|
1086 | - * |
|
1087 | - * @return \OCP\SystemTag\ISystemTagManager |
|
1088 | - * |
|
1089 | - * @since 9.0.0 |
|
1090 | - */ |
|
1091 | - public function getSystemTagManager() { |
|
1092 | - return $this->query('SystemTagManager'); |
|
1093 | - } |
|
1094 | - |
|
1095 | - /** |
|
1096 | - * Returns the system-tag object mapper |
|
1097 | - * |
|
1098 | - * @return \OCP\SystemTag\ISystemTagObjectMapper |
|
1099 | - * |
|
1100 | - * @since 9.0.0 |
|
1101 | - */ |
|
1102 | - public function getSystemTagObjectMapper() { |
|
1103 | - return $this->query('SystemTagObjectMapper'); |
|
1104 | - } |
|
1105 | - |
|
1106 | - /** |
|
1107 | - * Returns the avatar manager, used for avatar functionality |
|
1108 | - * |
|
1109 | - * @return \OCP\IAvatarManager |
|
1110 | - */ |
|
1111 | - public function getAvatarManager() { |
|
1112 | - return $this->query('AvatarManager'); |
|
1113 | - } |
|
1114 | - |
|
1115 | - /** |
|
1116 | - * Returns the root folder of ownCloud's data directory |
|
1117 | - * |
|
1118 | - * @return \OCP\Files\IRootFolder |
|
1119 | - */ |
|
1120 | - public function getRootFolder() { |
|
1121 | - return $this->query('LazyRootFolder'); |
|
1122 | - } |
|
1123 | - |
|
1124 | - /** |
|
1125 | - * Returns the root folder of ownCloud's data directory |
|
1126 | - * This is the lazy variant so this gets only initialized once it |
|
1127 | - * is actually used. |
|
1128 | - * |
|
1129 | - * @return \OCP\Files\IRootFolder |
|
1130 | - */ |
|
1131 | - public function getLazyRootFolder() { |
|
1132 | - return $this->query('LazyRootFolder'); |
|
1133 | - } |
|
1134 | - |
|
1135 | - /** |
|
1136 | - * Returns a view to ownCloud's files folder |
|
1137 | - * |
|
1138 | - * @param string $userId user ID |
|
1139 | - * @return \OCP\Files\Folder|null |
|
1140 | - */ |
|
1141 | - public function getUserFolder($userId = null) { |
|
1142 | - if ($userId === null) { |
|
1143 | - $user = $this->getUserSession()->getUser(); |
|
1144 | - if (!$user) { |
|
1145 | - return null; |
|
1146 | - } |
|
1147 | - $userId = $user->getUID(); |
|
1148 | - } |
|
1149 | - $root = $this->getRootFolder(); |
|
1150 | - return $root->getUserFolder($userId); |
|
1151 | - } |
|
1152 | - |
|
1153 | - /** |
|
1154 | - * Returns an app-specific view in ownClouds data directory |
|
1155 | - * |
|
1156 | - * @return \OCP\Files\Folder |
|
1157 | - * @deprecated since 9.2.0 use IAppData |
|
1158 | - */ |
|
1159 | - public function getAppFolder() { |
|
1160 | - $dir = '/' . \OC_App::getCurrentApp(); |
|
1161 | - $root = $this->getRootFolder(); |
|
1162 | - if (!$root->nodeExists($dir)) { |
|
1163 | - $folder = $root->newFolder($dir); |
|
1164 | - } else { |
|
1165 | - $folder = $root->get($dir); |
|
1166 | - } |
|
1167 | - return $folder; |
|
1168 | - } |
|
1169 | - |
|
1170 | - /** |
|
1171 | - * @return \OC\User\Manager |
|
1172 | - */ |
|
1173 | - public function getUserManager() { |
|
1174 | - return $this->query('UserManager'); |
|
1175 | - } |
|
1176 | - |
|
1177 | - /** |
|
1178 | - * @return \OC\Group\Manager |
|
1179 | - */ |
|
1180 | - public function getGroupManager() { |
|
1181 | - return $this->query('GroupManager'); |
|
1182 | - } |
|
1183 | - |
|
1184 | - /** |
|
1185 | - * @return \OC\User\Session |
|
1186 | - */ |
|
1187 | - public function getUserSession() { |
|
1188 | - return $this->query('UserSession'); |
|
1189 | - } |
|
1190 | - |
|
1191 | - /** |
|
1192 | - * @return \OCP\ISession |
|
1193 | - */ |
|
1194 | - public function getSession() { |
|
1195 | - return $this->query('UserSession')->getSession(); |
|
1196 | - } |
|
1197 | - |
|
1198 | - /** |
|
1199 | - * @param \OCP\ISession $session |
|
1200 | - */ |
|
1201 | - public function setSession(\OCP\ISession $session) { |
|
1202 | - $this->query(SessionStorage::class)->setSession($session); |
|
1203 | - $this->query('UserSession')->setSession($session); |
|
1204 | - $this->query(Store::class)->setSession($session); |
|
1205 | - } |
|
1206 | - |
|
1207 | - /** |
|
1208 | - * @return \OC\Authentication\TwoFactorAuth\Manager |
|
1209 | - */ |
|
1210 | - public function getTwoFactorAuthManager() { |
|
1211 | - return $this->query('\OC\Authentication\TwoFactorAuth\Manager'); |
|
1212 | - } |
|
1213 | - |
|
1214 | - /** |
|
1215 | - * @return \OC\NavigationManager |
|
1216 | - */ |
|
1217 | - public function getNavigationManager() { |
|
1218 | - return $this->query('NavigationManager'); |
|
1219 | - } |
|
1220 | - |
|
1221 | - /** |
|
1222 | - * @return \OCP\IConfig |
|
1223 | - */ |
|
1224 | - public function getConfig() { |
|
1225 | - return $this->query('AllConfig'); |
|
1226 | - } |
|
1227 | - |
|
1228 | - /** |
|
1229 | - * @internal For internal use only |
|
1230 | - * @return \OC\SystemConfig |
|
1231 | - */ |
|
1232 | - public function getSystemConfig() { |
|
1233 | - return $this->query('SystemConfig'); |
|
1234 | - } |
|
1235 | - |
|
1236 | - /** |
|
1237 | - * Returns the app config manager |
|
1238 | - * |
|
1239 | - * @return \OCP\IAppConfig |
|
1240 | - */ |
|
1241 | - public function getAppConfig() { |
|
1242 | - return $this->query('AppConfig'); |
|
1243 | - } |
|
1244 | - |
|
1245 | - /** |
|
1246 | - * @return \OCP\L10N\IFactory |
|
1247 | - */ |
|
1248 | - public function getL10NFactory() { |
|
1249 | - return $this->query('L10NFactory'); |
|
1250 | - } |
|
1251 | - |
|
1252 | - /** |
|
1253 | - * get an L10N instance |
|
1254 | - * |
|
1255 | - * @param string $app appid |
|
1256 | - * @param string $lang |
|
1257 | - * @return IL10N |
|
1258 | - */ |
|
1259 | - public function getL10N($app, $lang = null) { |
|
1260 | - return $this->getL10NFactory()->get($app, $lang); |
|
1261 | - } |
|
1262 | - |
|
1263 | - /** |
|
1264 | - * @return \OCP\IURLGenerator |
|
1265 | - */ |
|
1266 | - public function getURLGenerator() { |
|
1267 | - return $this->query('URLGenerator'); |
|
1268 | - } |
|
1269 | - |
|
1270 | - /** |
|
1271 | - * @return \OCP\IHelper |
|
1272 | - */ |
|
1273 | - public function getHelper() { |
|
1274 | - return $this->query('AppHelper'); |
|
1275 | - } |
|
1276 | - |
|
1277 | - /** |
|
1278 | - * @return AppFetcher |
|
1279 | - */ |
|
1280 | - public function getAppFetcher() { |
|
1281 | - return $this->query(AppFetcher::class); |
|
1282 | - } |
|
1283 | - |
|
1284 | - /** |
|
1285 | - * Returns an ICache instance. Since 8.1.0 it returns a fake cache. Use |
|
1286 | - * getMemCacheFactory() instead. |
|
1287 | - * |
|
1288 | - * @return \OCP\ICache |
|
1289 | - * @deprecated 8.1.0 use getMemCacheFactory to obtain a proper cache |
|
1290 | - */ |
|
1291 | - public function getCache() { |
|
1292 | - return $this->query('UserCache'); |
|
1293 | - } |
|
1294 | - |
|
1295 | - /** |
|
1296 | - * Returns an \OCP\CacheFactory instance |
|
1297 | - * |
|
1298 | - * @return \OCP\ICacheFactory |
|
1299 | - */ |
|
1300 | - public function getMemCacheFactory() { |
|
1301 | - return $this->query('MemCacheFactory'); |
|
1302 | - } |
|
1303 | - |
|
1304 | - /** |
|
1305 | - * Returns an \OC\RedisFactory instance |
|
1306 | - * |
|
1307 | - * @return \OC\RedisFactory |
|
1308 | - */ |
|
1309 | - public function getGetRedisFactory() { |
|
1310 | - return $this->query('RedisFactory'); |
|
1311 | - } |
|
1312 | - |
|
1313 | - |
|
1314 | - /** |
|
1315 | - * Returns the current session |
|
1316 | - * |
|
1317 | - * @return \OCP\IDBConnection |
|
1318 | - */ |
|
1319 | - public function getDatabaseConnection() { |
|
1320 | - return $this->query('DatabaseConnection'); |
|
1321 | - } |
|
1322 | - |
|
1323 | - /** |
|
1324 | - * Returns the activity manager |
|
1325 | - * |
|
1326 | - * @return \OCP\Activity\IManager |
|
1327 | - */ |
|
1328 | - public function getActivityManager() { |
|
1329 | - return $this->query('ActivityManager'); |
|
1330 | - } |
|
1331 | - |
|
1332 | - /** |
|
1333 | - * Returns an job list for controlling background jobs |
|
1334 | - * |
|
1335 | - * @return \OCP\BackgroundJob\IJobList |
|
1336 | - */ |
|
1337 | - public function getJobList() { |
|
1338 | - return $this->query('JobList'); |
|
1339 | - } |
|
1340 | - |
|
1341 | - /** |
|
1342 | - * Returns a logger instance |
|
1343 | - * |
|
1344 | - * @return \OCP\ILogger |
|
1345 | - */ |
|
1346 | - public function getLogger() { |
|
1347 | - return $this->query('Logger'); |
|
1348 | - } |
|
1349 | - |
|
1350 | - /** |
|
1351 | - * Returns a router for generating and matching urls |
|
1352 | - * |
|
1353 | - * @return \OCP\Route\IRouter |
|
1354 | - */ |
|
1355 | - public function getRouter() { |
|
1356 | - return $this->query('Router'); |
|
1357 | - } |
|
1358 | - |
|
1359 | - /** |
|
1360 | - * Returns a search instance |
|
1361 | - * |
|
1362 | - * @return \OCP\ISearch |
|
1363 | - */ |
|
1364 | - public function getSearch() { |
|
1365 | - return $this->query('Search'); |
|
1366 | - } |
|
1367 | - |
|
1368 | - /** |
|
1369 | - * Returns a SecureRandom instance |
|
1370 | - * |
|
1371 | - * @return \OCP\Security\ISecureRandom |
|
1372 | - */ |
|
1373 | - public function getSecureRandom() { |
|
1374 | - return $this->query('SecureRandom'); |
|
1375 | - } |
|
1376 | - |
|
1377 | - /** |
|
1378 | - * Returns a Crypto instance |
|
1379 | - * |
|
1380 | - * @return \OCP\Security\ICrypto |
|
1381 | - */ |
|
1382 | - public function getCrypto() { |
|
1383 | - return $this->query('Crypto'); |
|
1384 | - } |
|
1385 | - |
|
1386 | - /** |
|
1387 | - * Returns a Hasher instance |
|
1388 | - * |
|
1389 | - * @return \OCP\Security\IHasher |
|
1390 | - */ |
|
1391 | - public function getHasher() { |
|
1392 | - return $this->query('Hasher'); |
|
1393 | - } |
|
1394 | - |
|
1395 | - /** |
|
1396 | - * Returns a CredentialsManager instance |
|
1397 | - * |
|
1398 | - * @return \OCP\Security\ICredentialsManager |
|
1399 | - */ |
|
1400 | - public function getCredentialsManager() { |
|
1401 | - return $this->query('CredentialsManager'); |
|
1402 | - } |
|
1403 | - |
|
1404 | - /** |
|
1405 | - * Returns an instance of the HTTP helper class |
|
1406 | - * |
|
1407 | - * @deprecated Use getHTTPClientService() |
|
1408 | - * @return \OC\HTTPHelper |
|
1409 | - */ |
|
1410 | - public function getHTTPHelper() { |
|
1411 | - return $this->query('HTTPHelper'); |
|
1412 | - } |
|
1413 | - |
|
1414 | - /** |
|
1415 | - * Get the certificate manager for the user |
|
1416 | - * |
|
1417 | - * @param string $userId (optional) if not specified the current loggedin user is used, use null to get the system certificate manager |
|
1418 | - * @return \OCP\ICertificateManager | null if $uid is null and no user is logged in |
|
1419 | - */ |
|
1420 | - public function getCertificateManager($userId = '') { |
|
1421 | - if ($userId === '') { |
|
1422 | - $userSession = $this->getUserSession(); |
|
1423 | - $user = $userSession->getUser(); |
|
1424 | - if (is_null($user)) { |
|
1425 | - return null; |
|
1426 | - } |
|
1427 | - $userId = $user->getUID(); |
|
1428 | - } |
|
1429 | - return new CertificateManager($userId, new View(), $this->getConfig(), $this->getLogger()); |
|
1430 | - } |
|
1431 | - |
|
1432 | - /** |
|
1433 | - * Returns an instance of the HTTP client service |
|
1434 | - * |
|
1435 | - * @return \OCP\Http\Client\IClientService |
|
1436 | - */ |
|
1437 | - public function getHTTPClientService() { |
|
1438 | - return $this->query('HttpClientService'); |
|
1439 | - } |
|
1440 | - |
|
1441 | - /** |
|
1442 | - * Create a new event source |
|
1443 | - * |
|
1444 | - * @return \OCP\IEventSource |
|
1445 | - */ |
|
1446 | - public function createEventSource() { |
|
1447 | - return new \OC_EventSource(); |
|
1448 | - } |
|
1449 | - |
|
1450 | - /** |
|
1451 | - * Get the active event logger |
|
1452 | - * |
|
1453 | - * The returned logger only logs data when debug mode is enabled |
|
1454 | - * |
|
1455 | - * @return \OCP\Diagnostics\IEventLogger |
|
1456 | - */ |
|
1457 | - public function getEventLogger() { |
|
1458 | - return $this->query('EventLogger'); |
|
1459 | - } |
|
1460 | - |
|
1461 | - /** |
|
1462 | - * Get the active query logger |
|
1463 | - * |
|
1464 | - * The returned logger only logs data when debug mode is enabled |
|
1465 | - * |
|
1466 | - * @return \OCP\Diagnostics\IQueryLogger |
|
1467 | - */ |
|
1468 | - public function getQueryLogger() { |
|
1469 | - return $this->query('QueryLogger'); |
|
1470 | - } |
|
1471 | - |
|
1472 | - /** |
|
1473 | - * Get the manager for temporary files and folders |
|
1474 | - * |
|
1475 | - * @return \OCP\ITempManager |
|
1476 | - */ |
|
1477 | - public function getTempManager() { |
|
1478 | - return $this->query('TempManager'); |
|
1479 | - } |
|
1480 | - |
|
1481 | - /** |
|
1482 | - * Get the app manager |
|
1483 | - * |
|
1484 | - * @return \OCP\App\IAppManager |
|
1485 | - */ |
|
1486 | - public function getAppManager() { |
|
1487 | - return $this->query('AppManager'); |
|
1488 | - } |
|
1489 | - |
|
1490 | - /** |
|
1491 | - * Creates a new mailer |
|
1492 | - * |
|
1493 | - * @return \OCP\Mail\IMailer |
|
1494 | - */ |
|
1495 | - public function getMailer() { |
|
1496 | - return $this->query('Mailer'); |
|
1497 | - } |
|
1498 | - |
|
1499 | - /** |
|
1500 | - * Get the webroot |
|
1501 | - * |
|
1502 | - * @return string |
|
1503 | - */ |
|
1504 | - public function getWebRoot() { |
|
1505 | - return $this->webRoot; |
|
1506 | - } |
|
1507 | - |
|
1508 | - /** |
|
1509 | - * @return \OC\OCSClient |
|
1510 | - */ |
|
1511 | - public function getOcsClient() { |
|
1512 | - return $this->query('OcsClient'); |
|
1513 | - } |
|
1514 | - |
|
1515 | - /** |
|
1516 | - * @return \OCP\IDateTimeZone |
|
1517 | - */ |
|
1518 | - public function getDateTimeZone() { |
|
1519 | - return $this->query('DateTimeZone'); |
|
1520 | - } |
|
1521 | - |
|
1522 | - /** |
|
1523 | - * @return \OCP\IDateTimeFormatter |
|
1524 | - */ |
|
1525 | - public function getDateTimeFormatter() { |
|
1526 | - return $this->query('DateTimeFormatter'); |
|
1527 | - } |
|
1528 | - |
|
1529 | - /** |
|
1530 | - * @return \OCP\Files\Config\IMountProviderCollection |
|
1531 | - */ |
|
1532 | - public function getMountProviderCollection() { |
|
1533 | - return $this->query('MountConfigManager'); |
|
1534 | - } |
|
1535 | - |
|
1536 | - /** |
|
1537 | - * Get the IniWrapper |
|
1538 | - * |
|
1539 | - * @return IniGetWrapper |
|
1540 | - */ |
|
1541 | - public function getIniWrapper() { |
|
1542 | - return $this->query('IniWrapper'); |
|
1543 | - } |
|
1544 | - |
|
1545 | - /** |
|
1546 | - * @return \OCP\Command\IBus |
|
1547 | - */ |
|
1548 | - public function getCommandBus() { |
|
1549 | - return $this->query('AsyncCommandBus'); |
|
1550 | - } |
|
1551 | - |
|
1552 | - /** |
|
1553 | - * Get the trusted domain helper |
|
1554 | - * |
|
1555 | - * @return TrustedDomainHelper |
|
1556 | - */ |
|
1557 | - public function getTrustedDomainHelper() { |
|
1558 | - return $this->query('TrustedDomainHelper'); |
|
1559 | - } |
|
1560 | - |
|
1561 | - /** |
|
1562 | - * Get the locking provider |
|
1563 | - * |
|
1564 | - * @return \OCP\Lock\ILockingProvider |
|
1565 | - * @since 8.1.0 |
|
1566 | - */ |
|
1567 | - public function getLockingProvider() { |
|
1568 | - return $this->query('LockingProvider'); |
|
1569 | - } |
|
1570 | - |
|
1571 | - /** |
|
1572 | - * @return \OCP\Files\Mount\IMountManager |
|
1573 | - **/ |
|
1574 | - function getMountManager() { |
|
1575 | - return $this->query('MountManager'); |
|
1576 | - } |
|
1577 | - |
|
1578 | - /** @return \OCP\Files\Config\IUserMountCache */ |
|
1579 | - function getUserMountCache() { |
|
1580 | - return $this->query('UserMountCache'); |
|
1581 | - } |
|
1582 | - |
|
1583 | - /** |
|
1584 | - * Get the MimeTypeDetector |
|
1585 | - * |
|
1586 | - * @return \OCP\Files\IMimeTypeDetector |
|
1587 | - */ |
|
1588 | - public function getMimeTypeDetector() { |
|
1589 | - return $this->query('MimeTypeDetector'); |
|
1590 | - } |
|
1591 | - |
|
1592 | - /** |
|
1593 | - * Get the MimeTypeLoader |
|
1594 | - * |
|
1595 | - * @return \OCP\Files\IMimeTypeLoader |
|
1596 | - */ |
|
1597 | - public function getMimeTypeLoader() { |
|
1598 | - return $this->query('MimeTypeLoader'); |
|
1599 | - } |
|
1600 | - |
|
1601 | - /** |
|
1602 | - * Get the manager of all the capabilities |
|
1603 | - * |
|
1604 | - * @return \OC\CapabilitiesManager |
|
1605 | - */ |
|
1606 | - public function getCapabilitiesManager() { |
|
1607 | - return $this->query('CapabilitiesManager'); |
|
1608 | - } |
|
1609 | - |
|
1610 | - /** |
|
1611 | - * Get the EventDispatcher |
|
1612 | - * |
|
1613 | - * @return EventDispatcherInterface |
|
1614 | - * @since 8.2.0 |
|
1615 | - */ |
|
1616 | - public function getEventDispatcher() { |
|
1617 | - return $this->query('EventDispatcher'); |
|
1618 | - } |
|
1619 | - |
|
1620 | - /** |
|
1621 | - * Get the Notification Manager |
|
1622 | - * |
|
1623 | - * @return \OCP\Notification\IManager |
|
1624 | - * @since 8.2.0 |
|
1625 | - */ |
|
1626 | - public function getNotificationManager() { |
|
1627 | - return $this->query('NotificationManager'); |
|
1628 | - } |
|
1629 | - |
|
1630 | - /** |
|
1631 | - * @return \OCP\Comments\ICommentsManager |
|
1632 | - */ |
|
1633 | - public function getCommentsManager() { |
|
1634 | - return $this->query('CommentsManager'); |
|
1635 | - } |
|
1636 | - |
|
1637 | - /** |
|
1638 | - * @return \OCA\Theming\ThemingDefaults |
|
1639 | - */ |
|
1640 | - public function getThemingDefaults() { |
|
1641 | - return $this->query('ThemingDefaults'); |
|
1642 | - } |
|
1643 | - |
|
1644 | - /** |
|
1645 | - * @return \OC\IntegrityCheck\Checker |
|
1646 | - */ |
|
1647 | - public function getIntegrityCodeChecker() { |
|
1648 | - return $this->query('IntegrityCodeChecker'); |
|
1649 | - } |
|
1650 | - |
|
1651 | - /** |
|
1652 | - * @return \OC\Session\CryptoWrapper |
|
1653 | - */ |
|
1654 | - public function getSessionCryptoWrapper() { |
|
1655 | - return $this->query('CryptoWrapper'); |
|
1656 | - } |
|
1657 | - |
|
1658 | - /** |
|
1659 | - * @return CsrfTokenManager |
|
1660 | - */ |
|
1661 | - public function getCsrfTokenManager() { |
|
1662 | - return $this->query('CsrfTokenManager'); |
|
1663 | - } |
|
1664 | - |
|
1665 | - /** |
|
1666 | - * @return Throttler |
|
1667 | - */ |
|
1668 | - public function getBruteForceThrottler() { |
|
1669 | - return $this->query('Throttler'); |
|
1670 | - } |
|
1671 | - |
|
1672 | - /** |
|
1673 | - * @return IContentSecurityPolicyManager |
|
1674 | - */ |
|
1675 | - public function getContentSecurityPolicyManager() { |
|
1676 | - return $this->query('ContentSecurityPolicyManager'); |
|
1677 | - } |
|
1678 | - |
|
1679 | - /** |
|
1680 | - * @return ContentSecurityPolicyNonceManager |
|
1681 | - */ |
|
1682 | - public function getContentSecurityPolicyNonceManager() { |
|
1683 | - return $this->query('ContentSecurityPolicyNonceManager'); |
|
1684 | - } |
|
1685 | - |
|
1686 | - /** |
|
1687 | - * Not a public API as of 8.2, wait for 9.0 |
|
1688 | - * |
|
1689 | - * @return \OCA\Files_External\Service\BackendService |
|
1690 | - */ |
|
1691 | - public function getStoragesBackendService() { |
|
1692 | - return $this->query('OCA\\Files_External\\Service\\BackendService'); |
|
1693 | - } |
|
1694 | - |
|
1695 | - /** |
|
1696 | - * Not a public API as of 8.2, wait for 9.0 |
|
1697 | - * |
|
1698 | - * @return \OCA\Files_External\Service\GlobalStoragesService |
|
1699 | - */ |
|
1700 | - public function getGlobalStoragesService() { |
|
1701 | - return $this->query('OCA\\Files_External\\Service\\GlobalStoragesService'); |
|
1702 | - } |
|
1703 | - |
|
1704 | - /** |
|
1705 | - * Not a public API as of 8.2, wait for 9.0 |
|
1706 | - * |
|
1707 | - * @return \OCA\Files_External\Service\UserGlobalStoragesService |
|
1708 | - */ |
|
1709 | - public function getUserGlobalStoragesService() { |
|
1710 | - return $this->query('OCA\\Files_External\\Service\\UserGlobalStoragesService'); |
|
1711 | - } |
|
1712 | - |
|
1713 | - /** |
|
1714 | - * Not a public API as of 8.2, wait for 9.0 |
|
1715 | - * |
|
1716 | - * @return \OCA\Files_External\Service\UserStoragesService |
|
1717 | - */ |
|
1718 | - public function getUserStoragesService() { |
|
1719 | - return $this->query('OCA\\Files_External\\Service\\UserStoragesService'); |
|
1720 | - } |
|
1721 | - |
|
1722 | - /** |
|
1723 | - * @return \OCP\Share\IManager |
|
1724 | - */ |
|
1725 | - public function getShareManager() { |
|
1726 | - return $this->query('ShareManager'); |
|
1727 | - } |
|
1728 | - |
|
1729 | - /** |
|
1730 | - * Returns the LDAP Provider |
|
1731 | - * |
|
1732 | - * @return \OCP\LDAP\ILDAPProvider |
|
1733 | - */ |
|
1734 | - public function getLDAPProvider() { |
|
1735 | - return $this->query('LDAPProvider'); |
|
1736 | - } |
|
1737 | - |
|
1738 | - /** |
|
1739 | - * @return \OCP\Settings\IManager |
|
1740 | - */ |
|
1741 | - public function getSettingsManager() { |
|
1742 | - return $this->query('SettingsManager'); |
|
1743 | - } |
|
1744 | - |
|
1745 | - /** |
|
1746 | - * @return \OCP\Files\IAppData |
|
1747 | - */ |
|
1748 | - public function getAppDataDir($app) { |
|
1749 | - /** @var \OC\Files\AppData\Factory $factory */ |
|
1750 | - $factory = $this->query(\OC\Files\AppData\Factory::class); |
|
1751 | - return $factory->get($app); |
|
1752 | - } |
|
1753 | - |
|
1754 | - /** |
|
1755 | - * @return \OCP\Lockdown\ILockdownManager |
|
1756 | - */ |
|
1757 | - public function getLockdownManager() { |
|
1758 | - return $this->query('LockdownManager'); |
|
1759 | - } |
|
1760 | - |
|
1761 | - /** |
|
1762 | - * @return \OCP\Federation\ICloudIdManager |
|
1763 | - */ |
|
1764 | - public function getCloudIdManager() { |
|
1765 | - return $this->query(ICloudIdManager::class); |
|
1766 | - } |
|
843 | + $prefixes = \OC::$composerAutoloader->getPrefixesPsr4(); |
|
844 | + if (isset($prefixes['OCA\\Theming\\'])) { |
|
845 | + $classExists = true; |
|
846 | + } else { |
|
847 | + $classExists = false; |
|
848 | + } |
|
849 | + |
|
850 | + if ($classExists && $c->getConfig()->getSystemValue('installed', false) && $c->getAppManager()->isInstalled('theming')) { |
|
851 | + return new ThemingDefaults( |
|
852 | + $c->getConfig(), |
|
853 | + $c->getL10N('theming'), |
|
854 | + $c->getURLGenerator(), |
|
855 | + $c->getAppDataDir('theming'), |
|
856 | + $c->getMemCacheFactory(), |
|
857 | + new Util($c->getConfig(), $this->getRootFolder(), $this->getAppManager()) |
|
858 | + ); |
|
859 | + } |
|
860 | + return new \OC_Defaults(); |
|
861 | + }); |
|
862 | + $this->registerService(SCSSCacher::class, function(Server $c) { |
|
863 | + /** @var Factory $cacheFactory */ |
|
864 | + $cacheFactory = $c->query(Factory::class); |
|
865 | + return new SCSSCacher( |
|
866 | + $c->getLogger(), |
|
867 | + $c->query(\OC\Files\AppData\Factory::class), |
|
868 | + $c->getURLGenerator(), |
|
869 | + $c->getConfig(), |
|
870 | + $c->getThemingDefaults(), |
|
871 | + \OC::$SERVERROOT, |
|
872 | + $cacheFactory->create('SCSS') |
|
873 | + ); |
|
874 | + }); |
|
875 | + $this->registerService(EventDispatcher::class, function () { |
|
876 | + return new EventDispatcher(); |
|
877 | + }); |
|
878 | + $this->registerAlias('EventDispatcher', EventDispatcher::class); |
|
879 | + $this->registerAlias(EventDispatcherInterface::class, EventDispatcher::class); |
|
880 | + |
|
881 | + $this->registerService('CryptoWrapper', function (Server $c) { |
|
882 | + // FIXME: Instantiiated here due to cyclic dependency |
|
883 | + $request = new Request( |
|
884 | + [ |
|
885 | + 'get' => $_GET, |
|
886 | + 'post' => $_POST, |
|
887 | + 'files' => $_FILES, |
|
888 | + 'server' => $_SERVER, |
|
889 | + 'env' => $_ENV, |
|
890 | + 'cookies' => $_COOKIE, |
|
891 | + 'method' => (isset($_SERVER) && isset($_SERVER['REQUEST_METHOD'])) |
|
892 | + ? $_SERVER['REQUEST_METHOD'] |
|
893 | + : null, |
|
894 | + ], |
|
895 | + $c->getSecureRandom(), |
|
896 | + $c->getConfig() |
|
897 | + ); |
|
898 | + |
|
899 | + return new CryptoWrapper( |
|
900 | + $c->getConfig(), |
|
901 | + $c->getCrypto(), |
|
902 | + $c->getSecureRandom(), |
|
903 | + $request |
|
904 | + ); |
|
905 | + }); |
|
906 | + $this->registerService('CsrfTokenManager', function (Server $c) { |
|
907 | + $tokenGenerator = new CsrfTokenGenerator($c->getSecureRandom()); |
|
908 | + |
|
909 | + return new CsrfTokenManager( |
|
910 | + $tokenGenerator, |
|
911 | + $c->query(SessionStorage::class) |
|
912 | + ); |
|
913 | + }); |
|
914 | + $this->registerService(SessionStorage::class, function (Server $c) { |
|
915 | + return new SessionStorage($c->getSession()); |
|
916 | + }); |
|
917 | + $this->registerService(\OCP\Security\IContentSecurityPolicyManager::class, function (Server $c) { |
|
918 | + return new ContentSecurityPolicyManager(); |
|
919 | + }); |
|
920 | + $this->registerAlias('ContentSecurityPolicyManager', \OCP\Security\IContentSecurityPolicyManager::class); |
|
921 | + |
|
922 | + $this->registerService('ContentSecurityPolicyNonceManager', function(Server $c) { |
|
923 | + return new ContentSecurityPolicyNonceManager( |
|
924 | + $c->getCsrfTokenManager(), |
|
925 | + $c->getRequest() |
|
926 | + ); |
|
927 | + }); |
|
928 | + |
|
929 | + $this->registerService(\OCP\Share\IManager::class, function(Server $c) { |
|
930 | + $config = $c->getConfig(); |
|
931 | + $factoryClass = $config->getSystemValue('sharing.managerFactory', '\OC\Share20\ProviderFactory'); |
|
932 | + /** @var \OCP\Share\IProviderFactory $factory */ |
|
933 | + $factory = new $factoryClass($this); |
|
934 | + |
|
935 | + $manager = new \OC\Share20\Manager( |
|
936 | + $c->getLogger(), |
|
937 | + $c->getConfig(), |
|
938 | + $c->getSecureRandom(), |
|
939 | + $c->getHasher(), |
|
940 | + $c->getMountManager(), |
|
941 | + $c->getGroupManager(), |
|
942 | + $c->getL10N('core'), |
|
943 | + $factory, |
|
944 | + $c->getUserManager(), |
|
945 | + $c->getLazyRootFolder(), |
|
946 | + $c->getEventDispatcher() |
|
947 | + ); |
|
948 | + |
|
949 | + return $manager; |
|
950 | + }); |
|
951 | + $this->registerAlias('ShareManager', \OCP\Share\IManager::class); |
|
952 | + |
|
953 | + $this->registerService('SettingsManager', function(Server $c) { |
|
954 | + $manager = new \OC\Settings\Manager( |
|
955 | + $c->getLogger(), |
|
956 | + $c->getDatabaseConnection(), |
|
957 | + $c->getL10N('lib'), |
|
958 | + $c->getConfig(), |
|
959 | + $c->getEncryptionManager(), |
|
960 | + $c->getUserManager(), |
|
961 | + $c->getLockingProvider(), |
|
962 | + $c->getRequest(), |
|
963 | + new \OC\Settings\Mapper($c->getDatabaseConnection()), |
|
964 | + $c->getURLGenerator(), |
|
965 | + $c->query(AccountManager::class), |
|
966 | + $c->getGroupManager(), |
|
967 | + $c->getL10NFactory() |
|
968 | + ); |
|
969 | + return $manager; |
|
970 | + }); |
|
971 | + $this->registerService(\OC\Files\AppData\Factory::class, function (Server $c) { |
|
972 | + return new \OC\Files\AppData\Factory( |
|
973 | + $c->getRootFolder(), |
|
974 | + $c->getSystemConfig() |
|
975 | + ); |
|
976 | + }); |
|
977 | + |
|
978 | + $this->registerService('LockdownManager', function (Server $c) { |
|
979 | + return new LockdownManager(function() use ($c) { |
|
980 | + return $c->getSession(); |
|
981 | + }); |
|
982 | + }); |
|
983 | + |
|
984 | + $this->registerService(\OCP\OCS\IDiscoveryService::class, function (Server $c) { |
|
985 | + return new DiscoveryService($c->getMemCacheFactory(), $c->getHTTPClientService()); |
|
986 | + }); |
|
987 | + |
|
988 | + $this->registerService(ICloudIdManager::class, function (Server $c) { |
|
989 | + return new CloudIdManager(); |
|
990 | + }); |
|
991 | + |
|
992 | + /* To trick DI since we don't extend the DIContainer here */ |
|
993 | + $this->registerService(CleanPreviewsBackgroundJob::class, function (Server $c) { |
|
994 | + return new CleanPreviewsBackgroundJob( |
|
995 | + $c->getRootFolder(), |
|
996 | + $c->getLogger(), |
|
997 | + $c->getJobList(), |
|
998 | + new TimeFactory() |
|
999 | + ); |
|
1000 | + }); |
|
1001 | + |
|
1002 | + $this->registerAlias(\OCP\AppFramework\Utility\IControllerMethodReflector::class, \OC\AppFramework\Utility\ControllerMethodReflector::class); |
|
1003 | + $this->registerAlias('ControllerMethodReflector', \OCP\AppFramework\Utility\IControllerMethodReflector::class); |
|
1004 | + |
|
1005 | + $this->registerAlias(\OCP\AppFramework\Utility\ITimeFactory::class, \OC\AppFramework\Utility\TimeFactory::class); |
|
1006 | + $this->registerAlias('TimeFactory', \OCP\AppFramework\Utility\ITimeFactory::class); |
|
1007 | + |
|
1008 | + $this->registerService(Defaults::class, function (Server $c) { |
|
1009 | + return new Defaults( |
|
1010 | + $c->getThemingDefaults() |
|
1011 | + ); |
|
1012 | + }); |
|
1013 | + $this->registerAlias('Defaults', \OCP\Defaults::class); |
|
1014 | + |
|
1015 | + $this->registerService(\OCP\ISession::class, function(SimpleContainer $c) { |
|
1016 | + return $c->query(\OCP\IUserSession::class)->getSession(); |
|
1017 | + }); |
|
1018 | + |
|
1019 | + $this->registerService(IShareHelper::class, function(Server $c) { |
|
1020 | + return new ShareHelper( |
|
1021 | + $c->query(\OCP\Share\IManager::class) |
|
1022 | + ); |
|
1023 | + }); |
|
1024 | + } |
|
1025 | + |
|
1026 | + /** |
|
1027 | + * @return \OCP\Contacts\IManager |
|
1028 | + */ |
|
1029 | + public function getContactsManager() { |
|
1030 | + return $this->query('ContactsManager'); |
|
1031 | + } |
|
1032 | + |
|
1033 | + /** |
|
1034 | + * @return \OC\Encryption\Manager |
|
1035 | + */ |
|
1036 | + public function getEncryptionManager() { |
|
1037 | + return $this->query('EncryptionManager'); |
|
1038 | + } |
|
1039 | + |
|
1040 | + /** |
|
1041 | + * @return \OC\Encryption\File |
|
1042 | + */ |
|
1043 | + public function getEncryptionFilesHelper() { |
|
1044 | + return $this->query('EncryptionFileHelper'); |
|
1045 | + } |
|
1046 | + |
|
1047 | + /** |
|
1048 | + * @return \OCP\Encryption\Keys\IStorage |
|
1049 | + */ |
|
1050 | + public function getEncryptionKeyStorage() { |
|
1051 | + return $this->query('EncryptionKeyStorage'); |
|
1052 | + } |
|
1053 | + |
|
1054 | + /** |
|
1055 | + * The current request object holding all information about the request |
|
1056 | + * currently being processed is returned from this method. |
|
1057 | + * In case the current execution was not initiated by a web request null is returned |
|
1058 | + * |
|
1059 | + * @return \OCP\IRequest |
|
1060 | + */ |
|
1061 | + public function getRequest() { |
|
1062 | + return $this->query('Request'); |
|
1063 | + } |
|
1064 | + |
|
1065 | + /** |
|
1066 | + * Returns the preview manager which can create preview images for a given file |
|
1067 | + * |
|
1068 | + * @return \OCP\IPreview |
|
1069 | + */ |
|
1070 | + public function getPreviewManager() { |
|
1071 | + return $this->query('PreviewManager'); |
|
1072 | + } |
|
1073 | + |
|
1074 | + /** |
|
1075 | + * Returns the tag manager which can get and set tags for different object types |
|
1076 | + * |
|
1077 | + * @see \OCP\ITagManager::load() |
|
1078 | + * @return \OCP\ITagManager |
|
1079 | + */ |
|
1080 | + public function getTagManager() { |
|
1081 | + return $this->query('TagManager'); |
|
1082 | + } |
|
1083 | + |
|
1084 | + /** |
|
1085 | + * Returns the system-tag manager |
|
1086 | + * |
|
1087 | + * @return \OCP\SystemTag\ISystemTagManager |
|
1088 | + * |
|
1089 | + * @since 9.0.0 |
|
1090 | + */ |
|
1091 | + public function getSystemTagManager() { |
|
1092 | + return $this->query('SystemTagManager'); |
|
1093 | + } |
|
1094 | + |
|
1095 | + /** |
|
1096 | + * Returns the system-tag object mapper |
|
1097 | + * |
|
1098 | + * @return \OCP\SystemTag\ISystemTagObjectMapper |
|
1099 | + * |
|
1100 | + * @since 9.0.0 |
|
1101 | + */ |
|
1102 | + public function getSystemTagObjectMapper() { |
|
1103 | + return $this->query('SystemTagObjectMapper'); |
|
1104 | + } |
|
1105 | + |
|
1106 | + /** |
|
1107 | + * Returns the avatar manager, used for avatar functionality |
|
1108 | + * |
|
1109 | + * @return \OCP\IAvatarManager |
|
1110 | + */ |
|
1111 | + public function getAvatarManager() { |
|
1112 | + return $this->query('AvatarManager'); |
|
1113 | + } |
|
1114 | + |
|
1115 | + /** |
|
1116 | + * Returns the root folder of ownCloud's data directory |
|
1117 | + * |
|
1118 | + * @return \OCP\Files\IRootFolder |
|
1119 | + */ |
|
1120 | + public function getRootFolder() { |
|
1121 | + return $this->query('LazyRootFolder'); |
|
1122 | + } |
|
1123 | + |
|
1124 | + /** |
|
1125 | + * Returns the root folder of ownCloud's data directory |
|
1126 | + * This is the lazy variant so this gets only initialized once it |
|
1127 | + * is actually used. |
|
1128 | + * |
|
1129 | + * @return \OCP\Files\IRootFolder |
|
1130 | + */ |
|
1131 | + public function getLazyRootFolder() { |
|
1132 | + return $this->query('LazyRootFolder'); |
|
1133 | + } |
|
1134 | + |
|
1135 | + /** |
|
1136 | + * Returns a view to ownCloud's files folder |
|
1137 | + * |
|
1138 | + * @param string $userId user ID |
|
1139 | + * @return \OCP\Files\Folder|null |
|
1140 | + */ |
|
1141 | + public function getUserFolder($userId = null) { |
|
1142 | + if ($userId === null) { |
|
1143 | + $user = $this->getUserSession()->getUser(); |
|
1144 | + if (!$user) { |
|
1145 | + return null; |
|
1146 | + } |
|
1147 | + $userId = $user->getUID(); |
|
1148 | + } |
|
1149 | + $root = $this->getRootFolder(); |
|
1150 | + return $root->getUserFolder($userId); |
|
1151 | + } |
|
1152 | + |
|
1153 | + /** |
|
1154 | + * Returns an app-specific view in ownClouds data directory |
|
1155 | + * |
|
1156 | + * @return \OCP\Files\Folder |
|
1157 | + * @deprecated since 9.2.0 use IAppData |
|
1158 | + */ |
|
1159 | + public function getAppFolder() { |
|
1160 | + $dir = '/' . \OC_App::getCurrentApp(); |
|
1161 | + $root = $this->getRootFolder(); |
|
1162 | + if (!$root->nodeExists($dir)) { |
|
1163 | + $folder = $root->newFolder($dir); |
|
1164 | + } else { |
|
1165 | + $folder = $root->get($dir); |
|
1166 | + } |
|
1167 | + return $folder; |
|
1168 | + } |
|
1169 | + |
|
1170 | + /** |
|
1171 | + * @return \OC\User\Manager |
|
1172 | + */ |
|
1173 | + public function getUserManager() { |
|
1174 | + return $this->query('UserManager'); |
|
1175 | + } |
|
1176 | + |
|
1177 | + /** |
|
1178 | + * @return \OC\Group\Manager |
|
1179 | + */ |
|
1180 | + public function getGroupManager() { |
|
1181 | + return $this->query('GroupManager'); |
|
1182 | + } |
|
1183 | + |
|
1184 | + /** |
|
1185 | + * @return \OC\User\Session |
|
1186 | + */ |
|
1187 | + public function getUserSession() { |
|
1188 | + return $this->query('UserSession'); |
|
1189 | + } |
|
1190 | + |
|
1191 | + /** |
|
1192 | + * @return \OCP\ISession |
|
1193 | + */ |
|
1194 | + public function getSession() { |
|
1195 | + return $this->query('UserSession')->getSession(); |
|
1196 | + } |
|
1197 | + |
|
1198 | + /** |
|
1199 | + * @param \OCP\ISession $session |
|
1200 | + */ |
|
1201 | + public function setSession(\OCP\ISession $session) { |
|
1202 | + $this->query(SessionStorage::class)->setSession($session); |
|
1203 | + $this->query('UserSession')->setSession($session); |
|
1204 | + $this->query(Store::class)->setSession($session); |
|
1205 | + } |
|
1206 | + |
|
1207 | + /** |
|
1208 | + * @return \OC\Authentication\TwoFactorAuth\Manager |
|
1209 | + */ |
|
1210 | + public function getTwoFactorAuthManager() { |
|
1211 | + return $this->query('\OC\Authentication\TwoFactorAuth\Manager'); |
|
1212 | + } |
|
1213 | + |
|
1214 | + /** |
|
1215 | + * @return \OC\NavigationManager |
|
1216 | + */ |
|
1217 | + public function getNavigationManager() { |
|
1218 | + return $this->query('NavigationManager'); |
|
1219 | + } |
|
1220 | + |
|
1221 | + /** |
|
1222 | + * @return \OCP\IConfig |
|
1223 | + */ |
|
1224 | + public function getConfig() { |
|
1225 | + return $this->query('AllConfig'); |
|
1226 | + } |
|
1227 | + |
|
1228 | + /** |
|
1229 | + * @internal For internal use only |
|
1230 | + * @return \OC\SystemConfig |
|
1231 | + */ |
|
1232 | + public function getSystemConfig() { |
|
1233 | + return $this->query('SystemConfig'); |
|
1234 | + } |
|
1235 | + |
|
1236 | + /** |
|
1237 | + * Returns the app config manager |
|
1238 | + * |
|
1239 | + * @return \OCP\IAppConfig |
|
1240 | + */ |
|
1241 | + public function getAppConfig() { |
|
1242 | + return $this->query('AppConfig'); |
|
1243 | + } |
|
1244 | + |
|
1245 | + /** |
|
1246 | + * @return \OCP\L10N\IFactory |
|
1247 | + */ |
|
1248 | + public function getL10NFactory() { |
|
1249 | + return $this->query('L10NFactory'); |
|
1250 | + } |
|
1251 | + |
|
1252 | + /** |
|
1253 | + * get an L10N instance |
|
1254 | + * |
|
1255 | + * @param string $app appid |
|
1256 | + * @param string $lang |
|
1257 | + * @return IL10N |
|
1258 | + */ |
|
1259 | + public function getL10N($app, $lang = null) { |
|
1260 | + return $this->getL10NFactory()->get($app, $lang); |
|
1261 | + } |
|
1262 | + |
|
1263 | + /** |
|
1264 | + * @return \OCP\IURLGenerator |
|
1265 | + */ |
|
1266 | + public function getURLGenerator() { |
|
1267 | + return $this->query('URLGenerator'); |
|
1268 | + } |
|
1269 | + |
|
1270 | + /** |
|
1271 | + * @return \OCP\IHelper |
|
1272 | + */ |
|
1273 | + public function getHelper() { |
|
1274 | + return $this->query('AppHelper'); |
|
1275 | + } |
|
1276 | + |
|
1277 | + /** |
|
1278 | + * @return AppFetcher |
|
1279 | + */ |
|
1280 | + public function getAppFetcher() { |
|
1281 | + return $this->query(AppFetcher::class); |
|
1282 | + } |
|
1283 | + |
|
1284 | + /** |
|
1285 | + * Returns an ICache instance. Since 8.1.0 it returns a fake cache. Use |
|
1286 | + * getMemCacheFactory() instead. |
|
1287 | + * |
|
1288 | + * @return \OCP\ICache |
|
1289 | + * @deprecated 8.1.0 use getMemCacheFactory to obtain a proper cache |
|
1290 | + */ |
|
1291 | + public function getCache() { |
|
1292 | + return $this->query('UserCache'); |
|
1293 | + } |
|
1294 | + |
|
1295 | + /** |
|
1296 | + * Returns an \OCP\CacheFactory instance |
|
1297 | + * |
|
1298 | + * @return \OCP\ICacheFactory |
|
1299 | + */ |
|
1300 | + public function getMemCacheFactory() { |
|
1301 | + return $this->query('MemCacheFactory'); |
|
1302 | + } |
|
1303 | + |
|
1304 | + /** |
|
1305 | + * Returns an \OC\RedisFactory instance |
|
1306 | + * |
|
1307 | + * @return \OC\RedisFactory |
|
1308 | + */ |
|
1309 | + public function getGetRedisFactory() { |
|
1310 | + return $this->query('RedisFactory'); |
|
1311 | + } |
|
1312 | + |
|
1313 | + |
|
1314 | + /** |
|
1315 | + * Returns the current session |
|
1316 | + * |
|
1317 | + * @return \OCP\IDBConnection |
|
1318 | + */ |
|
1319 | + public function getDatabaseConnection() { |
|
1320 | + return $this->query('DatabaseConnection'); |
|
1321 | + } |
|
1322 | + |
|
1323 | + /** |
|
1324 | + * Returns the activity manager |
|
1325 | + * |
|
1326 | + * @return \OCP\Activity\IManager |
|
1327 | + */ |
|
1328 | + public function getActivityManager() { |
|
1329 | + return $this->query('ActivityManager'); |
|
1330 | + } |
|
1331 | + |
|
1332 | + /** |
|
1333 | + * Returns an job list for controlling background jobs |
|
1334 | + * |
|
1335 | + * @return \OCP\BackgroundJob\IJobList |
|
1336 | + */ |
|
1337 | + public function getJobList() { |
|
1338 | + return $this->query('JobList'); |
|
1339 | + } |
|
1340 | + |
|
1341 | + /** |
|
1342 | + * Returns a logger instance |
|
1343 | + * |
|
1344 | + * @return \OCP\ILogger |
|
1345 | + */ |
|
1346 | + public function getLogger() { |
|
1347 | + return $this->query('Logger'); |
|
1348 | + } |
|
1349 | + |
|
1350 | + /** |
|
1351 | + * Returns a router for generating and matching urls |
|
1352 | + * |
|
1353 | + * @return \OCP\Route\IRouter |
|
1354 | + */ |
|
1355 | + public function getRouter() { |
|
1356 | + return $this->query('Router'); |
|
1357 | + } |
|
1358 | + |
|
1359 | + /** |
|
1360 | + * Returns a search instance |
|
1361 | + * |
|
1362 | + * @return \OCP\ISearch |
|
1363 | + */ |
|
1364 | + public function getSearch() { |
|
1365 | + return $this->query('Search'); |
|
1366 | + } |
|
1367 | + |
|
1368 | + /** |
|
1369 | + * Returns a SecureRandom instance |
|
1370 | + * |
|
1371 | + * @return \OCP\Security\ISecureRandom |
|
1372 | + */ |
|
1373 | + public function getSecureRandom() { |
|
1374 | + return $this->query('SecureRandom'); |
|
1375 | + } |
|
1376 | + |
|
1377 | + /** |
|
1378 | + * Returns a Crypto instance |
|
1379 | + * |
|
1380 | + * @return \OCP\Security\ICrypto |
|
1381 | + */ |
|
1382 | + public function getCrypto() { |
|
1383 | + return $this->query('Crypto'); |
|
1384 | + } |
|
1385 | + |
|
1386 | + /** |
|
1387 | + * Returns a Hasher instance |
|
1388 | + * |
|
1389 | + * @return \OCP\Security\IHasher |
|
1390 | + */ |
|
1391 | + public function getHasher() { |
|
1392 | + return $this->query('Hasher'); |
|
1393 | + } |
|
1394 | + |
|
1395 | + /** |
|
1396 | + * Returns a CredentialsManager instance |
|
1397 | + * |
|
1398 | + * @return \OCP\Security\ICredentialsManager |
|
1399 | + */ |
|
1400 | + public function getCredentialsManager() { |
|
1401 | + return $this->query('CredentialsManager'); |
|
1402 | + } |
|
1403 | + |
|
1404 | + /** |
|
1405 | + * Returns an instance of the HTTP helper class |
|
1406 | + * |
|
1407 | + * @deprecated Use getHTTPClientService() |
|
1408 | + * @return \OC\HTTPHelper |
|
1409 | + */ |
|
1410 | + public function getHTTPHelper() { |
|
1411 | + return $this->query('HTTPHelper'); |
|
1412 | + } |
|
1413 | + |
|
1414 | + /** |
|
1415 | + * Get the certificate manager for the user |
|
1416 | + * |
|
1417 | + * @param string $userId (optional) if not specified the current loggedin user is used, use null to get the system certificate manager |
|
1418 | + * @return \OCP\ICertificateManager | null if $uid is null and no user is logged in |
|
1419 | + */ |
|
1420 | + public function getCertificateManager($userId = '') { |
|
1421 | + if ($userId === '') { |
|
1422 | + $userSession = $this->getUserSession(); |
|
1423 | + $user = $userSession->getUser(); |
|
1424 | + if (is_null($user)) { |
|
1425 | + return null; |
|
1426 | + } |
|
1427 | + $userId = $user->getUID(); |
|
1428 | + } |
|
1429 | + return new CertificateManager($userId, new View(), $this->getConfig(), $this->getLogger()); |
|
1430 | + } |
|
1431 | + |
|
1432 | + /** |
|
1433 | + * Returns an instance of the HTTP client service |
|
1434 | + * |
|
1435 | + * @return \OCP\Http\Client\IClientService |
|
1436 | + */ |
|
1437 | + public function getHTTPClientService() { |
|
1438 | + return $this->query('HttpClientService'); |
|
1439 | + } |
|
1440 | + |
|
1441 | + /** |
|
1442 | + * Create a new event source |
|
1443 | + * |
|
1444 | + * @return \OCP\IEventSource |
|
1445 | + */ |
|
1446 | + public function createEventSource() { |
|
1447 | + return new \OC_EventSource(); |
|
1448 | + } |
|
1449 | + |
|
1450 | + /** |
|
1451 | + * Get the active event logger |
|
1452 | + * |
|
1453 | + * The returned logger only logs data when debug mode is enabled |
|
1454 | + * |
|
1455 | + * @return \OCP\Diagnostics\IEventLogger |
|
1456 | + */ |
|
1457 | + public function getEventLogger() { |
|
1458 | + return $this->query('EventLogger'); |
|
1459 | + } |
|
1460 | + |
|
1461 | + /** |
|
1462 | + * Get the active query logger |
|
1463 | + * |
|
1464 | + * The returned logger only logs data when debug mode is enabled |
|
1465 | + * |
|
1466 | + * @return \OCP\Diagnostics\IQueryLogger |
|
1467 | + */ |
|
1468 | + public function getQueryLogger() { |
|
1469 | + return $this->query('QueryLogger'); |
|
1470 | + } |
|
1471 | + |
|
1472 | + /** |
|
1473 | + * Get the manager for temporary files and folders |
|
1474 | + * |
|
1475 | + * @return \OCP\ITempManager |
|
1476 | + */ |
|
1477 | + public function getTempManager() { |
|
1478 | + return $this->query('TempManager'); |
|
1479 | + } |
|
1480 | + |
|
1481 | + /** |
|
1482 | + * Get the app manager |
|
1483 | + * |
|
1484 | + * @return \OCP\App\IAppManager |
|
1485 | + */ |
|
1486 | + public function getAppManager() { |
|
1487 | + return $this->query('AppManager'); |
|
1488 | + } |
|
1489 | + |
|
1490 | + /** |
|
1491 | + * Creates a new mailer |
|
1492 | + * |
|
1493 | + * @return \OCP\Mail\IMailer |
|
1494 | + */ |
|
1495 | + public function getMailer() { |
|
1496 | + return $this->query('Mailer'); |
|
1497 | + } |
|
1498 | + |
|
1499 | + /** |
|
1500 | + * Get the webroot |
|
1501 | + * |
|
1502 | + * @return string |
|
1503 | + */ |
|
1504 | + public function getWebRoot() { |
|
1505 | + return $this->webRoot; |
|
1506 | + } |
|
1507 | + |
|
1508 | + /** |
|
1509 | + * @return \OC\OCSClient |
|
1510 | + */ |
|
1511 | + public function getOcsClient() { |
|
1512 | + return $this->query('OcsClient'); |
|
1513 | + } |
|
1514 | + |
|
1515 | + /** |
|
1516 | + * @return \OCP\IDateTimeZone |
|
1517 | + */ |
|
1518 | + public function getDateTimeZone() { |
|
1519 | + return $this->query('DateTimeZone'); |
|
1520 | + } |
|
1521 | + |
|
1522 | + /** |
|
1523 | + * @return \OCP\IDateTimeFormatter |
|
1524 | + */ |
|
1525 | + public function getDateTimeFormatter() { |
|
1526 | + return $this->query('DateTimeFormatter'); |
|
1527 | + } |
|
1528 | + |
|
1529 | + /** |
|
1530 | + * @return \OCP\Files\Config\IMountProviderCollection |
|
1531 | + */ |
|
1532 | + public function getMountProviderCollection() { |
|
1533 | + return $this->query('MountConfigManager'); |
|
1534 | + } |
|
1535 | + |
|
1536 | + /** |
|
1537 | + * Get the IniWrapper |
|
1538 | + * |
|
1539 | + * @return IniGetWrapper |
|
1540 | + */ |
|
1541 | + public function getIniWrapper() { |
|
1542 | + return $this->query('IniWrapper'); |
|
1543 | + } |
|
1544 | + |
|
1545 | + /** |
|
1546 | + * @return \OCP\Command\IBus |
|
1547 | + */ |
|
1548 | + public function getCommandBus() { |
|
1549 | + return $this->query('AsyncCommandBus'); |
|
1550 | + } |
|
1551 | + |
|
1552 | + /** |
|
1553 | + * Get the trusted domain helper |
|
1554 | + * |
|
1555 | + * @return TrustedDomainHelper |
|
1556 | + */ |
|
1557 | + public function getTrustedDomainHelper() { |
|
1558 | + return $this->query('TrustedDomainHelper'); |
|
1559 | + } |
|
1560 | + |
|
1561 | + /** |
|
1562 | + * Get the locking provider |
|
1563 | + * |
|
1564 | + * @return \OCP\Lock\ILockingProvider |
|
1565 | + * @since 8.1.0 |
|
1566 | + */ |
|
1567 | + public function getLockingProvider() { |
|
1568 | + return $this->query('LockingProvider'); |
|
1569 | + } |
|
1570 | + |
|
1571 | + /** |
|
1572 | + * @return \OCP\Files\Mount\IMountManager |
|
1573 | + **/ |
|
1574 | + function getMountManager() { |
|
1575 | + return $this->query('MountManager'); |
|
1576 | + } |
|
1577 | + |
|
1578 | + /** @return \OCP\Files\Config\IUserMountCache */ |
|
1579 | + function getUserMountCache() { |
|
1580 | + return $this->query('UserMountCache'); |
|
1581 | + } |
|
1582 | + |
|
1583 | + /** |
|
1584 | + * Get the MimeTypeDetector |
|
1585 | + * |
|
1586 | + * @return \OCP\Files\IMimeTypeDetector |
|
1587 | + */ |
|
1588 | + public function getMimeTypeDetector() { |
|
1589 | + return $this->query('MimeTypeDetector'); |
|
1590 | + } |
|
1591 | + |
|
1592 | + /** |
|
1593 | + * Get the MimeTypeLoader |
|
1594 | + * |
|
1595 | + * @return \OCP\Files\IMimeTypeLoader |
|
1596 | + */ |
|
1597 | + public function getMimeTypeLoader() { |
|
1598 | + return $this->query('MimeTypeLoader'); |
|
1599 | + } |
|
1600 | + |
|
1601 | + /** |
|
1602 | + * Get the manager of all the capabilities |
|
1603 | + * |
|
1604 | + * @return \OC\CapabilitiesManager |
|
1605 | + */ |
|
1606 | + public function getCapabilitiesManager() { |
|
1607 | + return $this->query('CapabilitiesManager'); |
|
1608 | + } |
|
1609 | + |
|
1610 | + /** |
|
1611 | + * Get the EventDispatcher |
|
1612 | + * |
|
1613 | + * @return EventDispatcherInterface |
|
1614 | + * @since 8.2.0 |
|
1615 | + */ |
|
1616 | + public function getEventDispatcher() { |
|
1617 | + return $this->query('EventDispatcher'); |
|
1618 | + } |
|
1619 | + |
|
1620 | + /** |
|
1621 | + * Get the Notification Manager |
|
1622 | + * |
|
1623 | + * @return \OCP\Notification\IManager |
|
1624 | + * @since 8.2.0 |
|
1625 | + */ |
|
1626 | + public function getNotificationManager() { |
|
1627 | + return $this->query('NotificationManager'); |
|
1628 | + } |
|
1629 | + |
|
1630 | + /** |
|
1631 | + * @return \OCP\Comments\ICommentsManager |
|
1632 | + */ |
|
1633 | + public function getCommentsManager() { |
|
1634 | + return $this->query('CommentsManager'); |
|
1635 | + } |
|
1636 | + |
|
1637 | + /** |
|
1638 | + * @return \OCA\Theming\ThemingDefaults |
|
1639 | + */ |
|
1640 | + public function getThemingDefaults() { |
|
1641 | + return $this->query('ThemingDefaults'); |
|
1642 | + } |
|
1643 | + |
|
1644 | + /** |
|
1645 | + * @return \OC\IntegrityCheck\Checker |
|
1646 | + */ |
|
1647 | + public function getIntegrityCodeChecker() { |
|
1648 | + return $this->query('IntegrityCodeChecker'); |
|
1649 | + } |
|
1650 | + |
|
1651 | + /** |
|
1652 | + * @return \OC\Session\CryptoWrapper |
|
1653 | + */ |
|
1654 | + public function getSessionCryptoWrapper() { |
|
1655 | + return $this->query('CryptoWrapper'); |
|
1656 | + } |
|
1657 | + |
|
1658 | + /** |
|
1659 | + * @return CsrfTokenManager |
|
1660 | + */ |
|
1661 | + public function getCsrfTokenManager() { |
|
1662 | + return $this->query('CsrfTokenManager'); |
|
1663 | + } |
|
1664 | + |
|
1665 | + /** |
|
1666 | + * @return Throttler |
|
1667 | + */ |
|
1668 | + public function getBruteForceThrottler() { |
|
1669 | + return $this->query('Throttler'); |
|
1670 | + } |
|
1671 | + |
|
1672 | + /** |
|
1673 | + * @return IContentSecurityPolicyManager |
|
1674 | + */ |
|
1675 | + public function getContentSecurityPolicyManager() { |
|
1676 | + return $this->query('ContentSecurityPolicyManager'); |
|
1677 | + } |
|
1678 | + |
|
1679 | + /** |
|
1680 | + * @return ContentSecurityPolicyNonceManager |
|
1681 | + */ |
|
1682 | + public function getContentSecurityPolicyNonceManager() { |
|
1683 | + return $this->query('ContentSecurityPolicyNonceManager'); |
|
1684 | + } |
|
1685 | + |
|
1686 | + /** |
|
1687 | + * Not a public API as of 8.2, wait for 9.0 |
|
1688 | + * |
|
1689 | + * @return \OCA\Files_External\Service\BackendService |
|
1690 | + */ |
|
1691 | + public function getStoragesBackendService() { |
|
1692 | + return $this->query('OCA\\Files_External\\Service\\BackendService'); |
|
1693 | + } |
|
1694 | + |
|
1695 | + /** |
|
1696 | + * Not a public API as of 8.2, wait for 9.0 |
|
1697 | + * |
|
1698 | + * @return \OCA\Files_External\Service\GlobalStoragesService |
|
1699 | + */ |
|
1700 | + public function getGlobalStoragesService() { |
|
1701 | + return $this->query('OCA\\Files_External\\Service\\GlobalStoragesService'); |
|
1702 | + } |
|
1703 | + |
|
1704 | + /** |
|
1705 | + * Not a public API as of 8.2, wait for 9.0 |
|
1706 | + * |
|
1707 | + * @return \OCA\Files_External\Service\UserGlobalStoragesService |
|
1708 | + */ |
|
1709 | + public function getUserGlobalStoragesService() { |
|
1710 | + return $this->query('OCA\\Files_External\\Service\\UserGlobalStoragesService'); |
|
1711 | + } |
|
1712 | + |
|
1713 | + /** |
|
1714 | + * Not a public API as of 8.2, wait for 9.0 |
|
1715 | + * |
|
1716 | + * @return \OCA\Files_External\Service\UserStoragesService |
|
1717 | + */ |
|
1718 | + public function getUserStoragesService() { |
|
1719 | + return $this->query('OCA\\Files_External\\Service\\UserStoragesService'); |
|
1720 | + } |
|
1721 | + |
|
1722 | + /** |
|
1723 | + * @return \OCP\Share\IManager |
|
1724 | + */ |
|
1725 | + public function getShareManager() { |
|
1726 | + return $this->query('ShareManager'); |
|
1727 | + } |
|
1728 | + |
|
1729 | + /** |
|
1730 | + * Returns the LDAP Provider |
|
1731 | + * |
|
1732 | + * @return \OCP\LDAP\ILDAPProvider |
|
1733 | + */ |
|
1734 | + public function getLDAPProvider() { |
|
1735 | + return $this->query('LDAPProvider'); |
|
1736 | + } |
|
1737 | + |
|
1738 | + /** |
|
1739 | + * @return \OCP\Settings\IManager |
|
1740 | + */ |
|
1741 | + public function getSettingsManager() { |
|
1742 | + return $this->query('SettingsManager'); |
|
1743 | + } |
|
1744 | + |
|
1745 | + /** |
|
1746 | + * @return \OCP\Files\IAppData |
|
1747 | + */ |
|
1748 | + public function getAppDataDir($app) { |
|
1749 | + /** @var \OC\Files\AppData\Factory $factory */ |
|
1750 | + $factory = $this->query(\OC\Files\AppData\Factory::class); |
|
1751 | + return $factory->get($app); |
|
1752 | + } |
|
1753 | + |
|
1754 | + /** |
|
1755 | + * @return \OCP\Lockdown\ILockdownManager |
|
1756 | + */ |
|
1757 | + public function getLockdownManager() { |
|
1758 | + return $this->query('LockdownManager'); |
|
1759 | + } |
|
1760 | + |
|
1761 | + /** |
|
1762 | + * @return \OCP\Federation\ICloudIdManager |
|
1763 | + */ |
|
1764 | + public function getCloudIdManager() { |
|
1765 | + return $this->query(ICloudIdManager::class); |
|
1766 | + } |
|
1767 | 1767 | } |
@@ -41,241 +41,241 @@ |
||
41 | 41 | */ |
42 | 42 | |
43 | 43 | class NavigationManager implements INavigationManager { |
44 | - protected $entries = []; |
|
45 | - protected $closureEntries = []; |
|
46 | - protected $activeEntry; |
|
47 | - /** @var bool */ |
|
48 | - protected $init = false; |
|
49 | - /** @var IAppManager|AppManager */ |
|
50 | - protected $appManager; |
|
51 | - /** @var IURLGenerator */ |
|
52 | - private $urlGenerator; |
|
53 | - /** @var IFactory */ |
|
54 | - private $l10nFac; |
|
55 | - /** @var IUserSession */ |
|
56 | - private $userSession; |
|
57 | - /** @var IGroupManager|Manager */ |
|
58 | - private $groupManager; |
|
59 | - /** @var IConfig */ |
|
60 | - private $config; |
|
44 | + protected $entries = []; |
|
45 | + protected $closureEntries = []; |
|
46 | + protected $activeEntry; |
|
47 | + /** @var bool */ |
|
48 | + protected $init = false; |
|
49 | + /** @var IAppManager|AppManager */ |
|
50 | + protected $appManager; |
|
51 | + /** @var IURLGenerator */ |
|
52 | + private $urlGenerator; |
|
53 | + /** @var IFactory */ |
|
54 | + private $l10nFac; |
|
55 | + /** @var IUserSession */ |
|
56 | + private $userSession; |
|
57 | + /** @var IGroupManager|Manager */ |
|
58 | + private $groupManager; |
|
59 | + /** @var IConfig */ |
|
60 | + private $config; |
|
61 | 61 | |
62 | - public function __construct(IAppManager $appManager, |
|
63 | - IURLGenerator $urlGenerator, |
|
64 | - IFactory $l10nFac, |
|
65 | - IUserSession $userSession, |
|
66 | - IGroupManager $groupManager, |
|
67 | - IConfig $config) { |
|
68 | - $this->appManager = $appManager; |
|
69 | - $this->urlGenerator = $urlGenerator; |
|
70 | - $this->l10nFac = $l10nFac; |
|
71 | - $this->userSession = $userSession; |
|
72 | - $this->groupManager = $groupManager; |
|
73 | - $this->config = $config; |
|
74 | - } |
|
62 | + public function __construct(IAppManager $appManager, |
|
63 | + IURLGenerator $urlGenerator, |
|
64 | + IFactory $l10nFac, |
|
65 | + IUserSession $userSession, |
|
66 | + IGroupManager $groupManager, |
|
67 | + IConfig $config) { |
|
68 | + $this->appManager = $appManager; |
|
69 | + $this->urlGenerator = $urlGenerator; |
|
70 | + $this->l10nFac = $l10nFac; |
|
71 | + $this->userSession = $userSession; |
|
72 | + $this->groupManager = $groupManager; |
|
73 | + $this->config = $config; |
|
74 | + } |
|
75 | 75 | |
76 | - /** |
|
77 | - * Creates a new navigation entry |
|
78 | - * |
|
79 | - * @param array|\Closure $entry Array containing: id, name, order, icon and href key |
|
80 | - * The use of a closure is preferred, because it will avoid |
|
81 | - * loading the routing of your app, unless required. |
|
82 | - * @return void |
|
83 | - */ |
|
84 | - public function add($entry) { |
|
85 | - if ($entry instanceof \Closure) { |
|
86 | - $this->closureEntries[] = $entry; |
|
87 | - return; |
|
88 | - } |
|
76 | + /** |
|
77 | + * Creates a new navigation entry |
|
78 | + * |
|
79 | + * @param array|\Closure $entry Array containing: id, name, order, icon and href key |
|
80 | + * The use of a closure is preferred, because it will avoid |
|
81 | + * loading the routing of your app, unless required. |
|
82 | + * @return void |
|
83 | + */ |
|
84 | + public function add($entry) { |
|
85 | + if ($entry instanceof \Closure) { |
|
86 | + $this->closureEntries[] = $entry; |
|
87 | + return; |
|
88 | + } |
|
89 | 89 | |
90 | - $entry['active'] = false; |
|
91 | - if(!isset($entry['icon'])) { |
|
92 | - $entry['icon'] = ''; |
|
93 | - } |
|
94 | - if(!isset($entry['type'])) { |
|
95 | - $entry['type'] = 'link'; |
|
96 | - } |
|
97 | - $this->entries[] = $entry; |
|
98 | - } |
|
90 | + $entry['active'] = false; |
|
91 | + if(!isset($entry['icon'])) { |
|
92 | + $entry['icon'] = ''; |
|
93 | + } |
|
94 | + if(!isset($entry['type'])) { |
|
95 | + $entry['type'] = 'link'; |
|
96 | + } |
|
97 | + $this->entries[] = $entry; |
|
98 | + } |
|
99 | 99 | |
100 | - /** |
|
101 | - * returns all the added Menu entries |
|
102 | - * @param string $type |
|
103 | - * @return array an array of the added entries |
|
104 | - */ |
|
105 | - public function getAll($type = 'link') { |
|
106 | - $this->init(); |
|
107 | - foreach ($this->closureEntries as $c) { |
|
108 | - $this->add($c()); |
|
109 | - } |
|
110 | - $this->closureEntries = array(); |
|
100 | + /** |
|
101 | + * returns all the added Menu entries |
|
102 | + * @param string $type |
|
103 | + * @return array an array of the added entries |
|
104 | + */ |
|
105 | + public function getAll($type = 'link') { |
|
106 | + $this->init(); |
|
107 | + foreach ($this->closureEntries as $c) { |
|
108 | + $this->add($c()); |
|
109 | + } |
|
110 | + $this->closureEntries = array(); |
|
111 | 111 | |
112 | - if ($type === 'all') { |
|
113 | - return $this->entries; |
|
114 | - } |
|
112 | + if ($type === 'all') { |
|
113 | + return $this->entries; |
|
114 | + } |
|
115 | 115 | |
116 | - return array_filter($this->entries, function($entry) use ($type) { |
|
117 | - return $entry['type'] === $type; |
|
118 | - }); |
|
119 | - } |
|
116 | + return array_filter($this->entries, function($entry) use ($type) { |
|
117 | + return $entry['type'] === $type; |
|
118 | + }); |
|
119 | + } |
|
120 | 120 | |
121 | - /** |
|
122 | - * removes all the entries |
|
123 | - */ |
|
124 | - public function clear($loadDefaultLinks = true) { |
|
125 | - $this->entries = []; |
|
126 | - $this->closureEntries = []; |
|
127 | - $this->init = !$loadDefaultLinks; |
|
128 | - } |
|
121 | + /** |
|
122 | + * removes all the entries |
|
123 | + */ |
|
124 | + public function clear($loadDefaultLinks = true) { |
|
125 | + $this->entries = []; |
|
126 | + $this->closureEntries = []; |
|
127 | + $this->init = !$loadDefaultLinks; |
|
128 | + } |
|
129 | 129 | |
130 | - /** |
|
131 | - * Sets the current navigation entry of the currently running app |
|
132 | - * @param string $id of the app entry to activate (from added $entry) |
|
133 | - */ |
|
134 | - public function setActiveEntry($id) { |
|
135 | - $this->activeEntry = $id; |
|
136 | - } |
|
130 | + /** |
|
131 | + * Sets the current navigation entry of the currently running app |
|
132 | + * @param string $id of the app entry to activate (from added $entry) |
|
133 | + */ |
|
134 | + public function setActiveEntry($id) { |
|
135 | + $this->activeEntry = $id; |
|
136 | + } |
|
137 | 137 | |
138 | - /** |
|
139 | - * gets the active Menu entry |
|
140 | - * @return string id or empty string |
|
141 | - * |
|
142 | - * This function returns the id of the active navigation entry (set by |
|
143 | - * setActiveEntry |
|
144 | - */ |
|
145 | - public function getActiveEntry() { |
|
146 | - return $this->activeEntry; |
|
147 | - } |
|
138 | + /** |
|
139 | + * gets the active Menu entry |
|
140 | + * @return string id or empty string |
|
141 | + * |
|
142 | + * This function returns the id of the active navigation entry (set by |
|
143 | + * setActiveEntry |
|
144 | + */ |
|
145 | + public function getActiveEntry() { |
|
146 | + return $this->activeEntry; |
|
147 | + } |
|
148 | 148 | |
149 | - private function init() { |
|
150 | - if ($this->init) { |
|
151 | - return; |
|
152 | - } |
|
153 | - $this->init = true; |
|
149 | + private function init() { |
|
150 | + if ($this->init) { |
|
151 | + return; |
|
152 | + } |
|
153 | + $this->init = true; |
|
154 | 154 | |
155 | - $l = $this->l10nFac->get('lib'); |
|
156 | - if ($this->config->getSystemValue('knowledgebaseenabled', true)) { |
|
157 | - $this->add([ |
|
158 | - 'type' => 'settings', |
|
159 | - 'id' => 'help', |
|
160 | - 'order' => 5, |
|
161 | - 'href' => $this->urlGenerator->linkToRoute('settings_help'), |
|
162 | - 'name' => $l->t('Help'), |
|
163 | - 'icon' => $this->urlGenerator->imagePath('settings', 'help.svg'), |
|
164 | - ]); |
|
165 | - } |
|
155 | + $l = $this->l10nFac->get('lib'); |
|
156 | + if ($this->config->getSystemValue('knowledgebaseenabled', true)) { |
|
157 | + $this->add([ |
|
158 | + 'type' => 'settings', |
|
159 | + 'id' => 'help', |
|
160 | + 'order' => 5, |
|
161 | + 'href' => $this->urlGenerator->linkToRoute('settings_help'), |
|
162 | + 'name' => $l->t('Help'), |
|
163 | + 'icon' => $this->urlGenerator->imagePath('settings', 'help.svg'), |
|
164 | + ]); |
|
165 | + } |
|
166 | 166 | |
167 | - if ($this->userSession->isLoggedIn()) { |
|
168 | - if ($this->isAdmin()) { |
|
169 | - // App management |
|
170 | - $this->add([ |
|
171 | - 'type' => 'settings', |
|
172 | - 'id' => 'core_apps', |
|
173 | - 'order' => 3, |
|
174 | - 'href' => $this->urlGenerator->linkToRoute('settings.AppSettings.viewApps'), |
|
175 | - 'icon' => $this->urlGenerator->imagePath('settings', 'apps.svg'), |
|
176 | - 'name' => $l->t('Apps'), |
|
177 | - ]); |
|
178 | - } |
|
167 | + if ($this->userSession->isLoggedIn()) { |
|
168 | + if ($this->isAdmin()) { |
|
169 | + // App management |
|
170 | + $this->add([ |
|
171 | + 'type' => 'settings', |
|
172 | + 'id' => 'core_apps', |
|
173 | + 'order' => 3, |
|
174 | + 'href' => $this->urlGenerator->linkToRoute('settings.AppSettings.viewApps'), |
|
175 | + 'icon' => $this->urlGenerator->imagePath('settings', 'apps.svg'), |
|
176 | + 'name' => $l->t('Apps'), |
|
177 | + ]); |
|
178 | + } |
|
179 | 179 | |
180 | - // Personal and (if applicable) admin settings |
|
181 | - $this->add([ |
|
182 | - 'type' => 'settings', |
|
183 | - 'id' => 'settings', |
|
184 | - 'order' => 1, |
|
185 | - 'href' => $this->urlGenerator->linkToRoute('settings_personal'), |
|
186 | - 'name' => $l->t('Settings'), |
|
187 | - 'icon' => $this->urlGenerator->imagePath('settings', 'admin.svg'), |
|
188 | - ]); |
|
180 | + // Personal and (if applicable) admin settings |
|
181 | + $this->add([ |
|
182 | + 'type' => 'settings', |
|
183 | + 'id' => 'settings', |
|
184 | + 'order' => 1, |
|
185 | + 'href' => $this->urlGenerator->linkToRoute('settings_personal'), |
|
186 | + 'name' => $l->t('Settings'), |
|
187 | + 'icon' => $this->urlGenerator->imagePath('settings', 'admin.svg'), |
|
188 | + ]); |
|
189 | 189 | |
190 | - // Logout |
|
191 | - $this->add([ |
|
192 | - 'type' => 'settings', |
|
193 | - 'id' => 'logout', |
|
194 | - 'order' => 99999, |
|
195 | - 'href' => $this->urlGenerator->linkToRouteAbsolute( |
|
196 | - 'core.login.logout', |
|
197 | - ['requesttoken' => \OCP\Util::callRegister()] |
|
198 | - ), |
|
199 | - 'name' => $l->t('Log out'), |
|
200 | - 'icon' => $this->urlGenerator->imagePath('core', 'actions/logout.svg'), |
|
201 | - ]); |
|
190 | + // Logout |
|
191 | + $this->add([ |
|
192 | + 'type' => 'settings', |
|
193 | + 'id' => 'logout', |
|
194 | + 'order' => 99999, |
|
195 | + 'href' => $this->urlGenerator->linkToRouteAbsolute( |
|
196 | + 'core.login.logout', |
|
197 | + ['requesttoken' => \OCP\Util::callRegister()] |
|
198 | + ), |
|
199 | + 'name' => $l->t('Log out'), |
|
200 | + 'icon' => $this->urlGenerator->imagePath('core', 'actions/logout.svg'), |
|
201 | + ]); |
|
202 | 202 | |
203 | - if ($this->isSubadmin()) { |
|
204 | - // User management |
|
205 | - $this->add([ |
|
206 | - 'type' => 'settings', |
|
207 | - 'id' => 'core_users', |
|
208 | - 'order' => 4, |
|
209 | - 'href' => $this->urlGenerator->linkToRoute('settings_users'), |
|
210 | - 'name' => $l->t('Users'), |
|
211 | - 'icon' => $this->urlGenerator->imagePath('settings', 'users.svg'), |
|
212 | - ]); |
|
213 | - } |
|
214 | - } |
|
203 | + if ($this->isSubadmin()) { |
|
204 | + // User management |
|
205 | + $this->add([ |
|
206 | + 'type' => 'settings', |
|
207 | + 'id' => 'core_users', |
|
208 | + 'order' => 4, |
|
209 | + 'href' => $this->urlGenerator->linkToRoute('settings_users'), |
|
210 | + 'name' => $l->t('Users'), |
|
211 | + 'icon' => $this->urlGenerator->imagePath('settings', 'users.svg'), |
|
212 | + ]); |
|
213 | + } |
|
214 | + } |
|
215 | 215 | |
216 | - if ($this->appManager === 'null') { |
|
217 | - return; |
|
218 | - } |
|
219 | - foreach ($this->appManager->getInstalledApps() as $app) { |
|
220 | - // load plugins and collections from info.xml |
|
221 | - $info = $this->appManager->getAppInfo($app); |
|
222 | - if (empty($info['navigations'])) { |
|
223 | - continue; |
|
224 | - } |
|
225 | - foreach ($info['navigations'] as $nav) { |
|
226 | - if (!isset($nav['name'])) { |
|
227 | - continue; |
|
228 | - } |
|
229 | - if (!isset($nav['route'])) { |
|
230 | - continue; |
|
231 | - } |
|
232 | - $role = isset($nav['@attributes']['role']) ? $nav['@attributes']['role'] : 'all'; |
|
233 | - if ($role === 'admin' && !$this->isAdmin()) { |
|
234 | - continue; |
|
235 | - } |
|
236 | - $l = $this->l10nFac->get($app); |
|
237 | - $id = isset($nav['id']) ? $nav['id'] : $app; |
|
238 | - $order = isset($nav['order']) ? $nav['order'] : 100; |
|
239 | - $type = isset($nav['type']) ? $nav['type'] : 'link'; |
|
240 | - $route = $this->urlGenerator->linkToRoute($nav['route']); |
|
241 | - $icon = isset($nav['icon']) ? $nav['icon'] : 'app.svg'; |
|
242 | - foreach ([$icon, "$app.svg"] as $i) { |
|
243 | - try { |
|
244 | - $icon = $this->urlGenerator->imagePath($app, $i); |
|
245 | - break; |
|
246 | - } catch (\RuntimeException $ex) { |
|
247 | - // no icon? - ignore it then |
|
248 | - } |
|
249 | - } |
|
250 | - if ($icon === null) { |
|
251 | - $icon = $this->urlGenerator->imagePath('core', 'default-app-icon'); |
|
252 | - } |
|
216 | + if ($this->appManager === 'null') { |
|
217 | + return; |
|
218 | + } |
|
219 | + foreach ($this->appManager->getInstalledApps() as $app) { |
|
220 | + // load plugins and collections from info.xml |
|
221 | + $info = $this->appManager->getAppInfo($app); |
|
222 | + if (empty($info['navigations'])) { |
|
223 | + continue; |
|
224 | + } |
|
225 | + foreach ($info['navigations'] as $nav) { |
|
226 | + if (!isset($nav['name'])) { |
|
227 | + continue; |
|
228 | + } |
|
229 | + if (!isset($nav['route'])) { |
|
230 | + continue; |
|
231 | + } |
|
232 | + $role = isset($nav['@attributes']['role']) ? $nav['@attributes']['role'] : 'all'; |
|
233 | + if ($role === 'admin' && !$this->isAdmin()) { |
|
234 | + continue; |
|
235 | + } |
|
236 | + $l = $this->l10nFac->get($app); |
|
237 | + $id = isset($nav['id']) ? $nav['id'] : $app; |
|
238 | + $order = isset($nav['order']) ? $nav['order'] : 100; |
|
239 | + $type = isset($nav['type']) ? $nav['type'] : 'link'; |
|
240 | + $route = $this->urlGenerator->linkToRoute($nav['route']); |
|
241 | + $icon = isset($nav['icon']) ? $nav['icon'] : 'app.svg'; |
|
242 | + foreach ([$icon, "$app.svg"] as $i) { |
|
243 | + try { |
|
244 | + $icon = $this->urlGenerator->imagePath($app, $i); |
|
245 | + break; |
|
246 | + } catch (\RuntimeException $ex) { |
|
247 | + // no icon? - ignore it then |
|
248 | + } |
|
249 | + } |
|
250 | + if ($icon === null) { |
|
251 | + $icon = $this->urlGenerator->imagePath('core', 'default-app-icon'); |
|
252 | + } |
|
253 | 253 | |
254 | - $this->add([ |
|
255 | - 'id' => $id, |
|
256 | - 'order' => $order, |
|
257 | - 'href' => $route, |
|
258 | - 'icon' => $icon, |
|
259 | - 'type' => $type, |
|
260 | - 'name' => $l->t($nav['name']), |
|
261 | - ]); |
|
262 | - } |
|
263 | - } |
|
264 | - } |
|
254 | + $this->add([ |
|
255 | + 'id' => $id, |
|
256 | + 'order' => $order, |
|
257 | + 'href' => $route, |
|
258 | + 'icon' => $icon, |
|
259 | + 'type' => $type, |
|
260 | + 'name' => $l->t($nav['name']), |
|
261 | + ]); |
|
262 | + } |
|
263 | + } |
|
264 | + } |
|
265 | 265 | |
266 | - private function isAdmin() { |
|
267 | - $user = $this->userSession->getUser(); |
|
268 | - if ($user !== null) { |
|
269 | - return $this->groupManager->isAdmin($user->getUID()); |
|
270 | - } |
|
271 | - return false; |
|
272 | - } |
|
266 | + private function isAdmin() { |
|
267 | + $user = $this->userSession->getUser(); |
|
268 | + if ($user !== null) { |
|
269 | + return $this->groupManager->isAdmin($user->getUID()); |
|
270 | + } |
|
271 | + return false; |
|
272 | + } |
|
273 | 273 | |
274 | - private function isSubadmin() { |
|
275 | - $user = $this->userSession->getUser(); |
|
276 | - if ($user !== null) { |
|
277 | - return $this->groupManager->getSubAdmin()->isSubAdmin($user); |
|
278 | - } |
|
279 | - return false; |
|
280 | - } |
|
274 | + private function isSubadmin() { |
|
275 | + $user = $this->userSession->getUser(); |
|
276 | + if ($user !== null) { |
|
277 | + return $this->groupManager->getSubAdmin()->isSubAdmin($user); |
|
278 | + } |
|
279 | + return false; |
|
280 | + } |
|
281 | 281 | } |
@@ -27,89 +27,89 @@ |
||
27 | 27 | * @since 9.1 |
28 | 28 | */ |
29 | 29 | interface IManager { |
30 | - /** |
|
31 | - * @since 9.1.0 |
|
32 | - */ |
|
33 | - const KEY_ADMIN_SETTINGS = 'admin'; |
|
30 | + /** |
|
31 | + * @since 9.1.0 |
|
32 | + */ |
|
33 | + const KEY_ADMIN_SETTINGS = 'admin'; |
|
34 | 34 | |
35 | - /** |
|
36 | - * @since 9.1.0 |
|
37 | - */ |
|
38 | - const KEY_ADMIN_SECTION = 'admin-section'; |
|
35 | + /** |
|
36 | + * @since 9.1.0 |
|
37 | + */ |
|
38 | + const KEY_ADMIN_SECTION = 'admin-section'; |
|
39 | 39 | |
40 | - /** |
|
41 | - * sets up settings according to data specified by an apps info.xml, within |
|
42 | - * the <settings> element. |
|
43 | - * |
|
44 | - * @param array $settings an associative array, allowed keys are as specified |
|
45 | - * by the KEY_ constant of this interface. The value |
|
46 | - * must always be a class name, implement either |
|
47 | - * IAdmin or ISection. I.e. only one section and admin |
|
48 | - * setting can be configured per app. |
|
49 | - * @since 9.1.0 |
|
50 | - */ |
|
51 | - public function setupSettings(array $settings); |
|
40 | + /** |
|
41 | + * sets up settings according to data specified by an apps info.xml, within |
|
42 | + * the <settings> element. |
|
43 | + * |
|
44 | + * @param array $settings an associative array, allowed keys are as specified |
|
45 | + * by the KEY_ constant of this interface. The value |
|
46 | + * must always be a class name, implement either |
|
47 | + * IAdmin or ISection. I.e. only one section and admin |
|
48 | + * setting can be configured per app. |
|
49 | + * @since 9.1.0 |
|
50 | + */ |
|
51 | + public function setupSettings(array $settings); |
|
52 | 52 | |
53 | - /** |
|
54 | - * attempts to remove an apps section and/or settings entry. A listener is |
|
55 | - * added centrally making sure that this method is called ones an app was |
|
56 | - * disabled. |
|
57 | - * |
|
58 | - * What this does not help with is when applications change their settings |
|
59 | - * or section classes during their life time. New entries will be added, |
|
60 | - * but inactive ones will still reside in the database. |
|
61 | - * |
|
62 | - * @param string $appId |
|
63 | - * @since 9.1.0 |
|
64 | - */ |
|
65 | - public function onAppDisabled($appId); |
|
53 | + /** |
|
54 | + * attempts to remove an apps section and/or settings entry. A listener is |
|
55 | + * added centrally making sure that this method is called ones an app was |
|
56 | + * disabled. |
|
57 | + * |
|
58 | + * What this does not help with is when applications change their settings |
|
59 | + * or section classes during their life time. New entries will be added, |
|
60 | + * but inactive ones will still reside in the database. |
|
61 | + * |
|
62 | + * @param string $appId |
|
63 | + * @since 9.1.0 |
|
64 | + */ |
|
65 | + public function onAppDisabled($appId); |
|
66 | 66 | |
67 | - /** |
|
68 | - * The method should check all registered classes whether they are still |
|
69 | - * instantiable and remove them, if not. This method is called by a |
|
70 | - * background job once, after one or more apps were updated. |
|
71 | - * |
|
72 | - * An app`s info.xml can change during an update and make it unknown whether |
|
73 | - * a registered class name was changed or not. An old one would just stay |
|
74 | - * registered. Another case is if an admin takes a radical approach and |
|
75 | - * simply removes an app from the app folder. These unregular checks will |
|
76 | - * take care of such situations. |
|
77 | - * |
|
78 | - * @since 9.1.0 |
|
79 | - */ |
|
80 | - public function checkForOrphanedClassNames(); |
|
67 | + /** |
|
68 | + * The method should check all registered classes whether they are still |
|
69 | + * instantiable and remove them, if not. This method is called by a |
|
70 | + * background job once, after one or more apps were updated. |
|
71 | + * |
|
72 | + * An app`s info.xml can change during an update and make it unknown whether |
|
73 | + * a registered class name was changed or not. An old one would just stay |
|
74 | + * registered. Another case is if an admin takes a radical approach and |
|
75 | + * simply removes an app from the app folder. These unregular checks will |
|
76 | + * take care of such situations. |
|
77 | + * |
|
78 | + * @since 9.1.0 |
|
79 | + */ |
|
80 | + public function checkForOrphanedClassNames(); |
|
81 | 81 | |
82 | - /** |
|
83 | - * returns a list of the admin sections |
|
84 | - * |
|
85 | - * @return array array of ISection[] where key is the priority |
|
86 | - * @since 9.1.0 |
|
87 | - */ |
|
88 | - public function getAdminSections(); |
|
82 | + /** |
|
83 | + * returns a list of the admin sections |
|
84 | + * |
|
85 | + * @return array array of ISection[] where key is the priority |
|
86 | + * @since 9.1.0 |
|
87 | + */ |
|
88 | + public function getAdminSections(); |
|
89 | 89 | |
90 | - /** |
|
91 | - * returns a list of the personal sections |
|
92 | - * |
|
93 | - * @return array array of ISection[] where key is the priority |
|
94 | - * @since 12.0.0 |
|
95 | - */ |
|
96 | - public function getPersonalSections(); |
|
90 | + /** |
|
91 | + * returns a list of the personal sections |
|
92 | + * |
|
93 | + * @return array array of ISection[] where key is the priority |
|
94 | + * @since 12.0.0 |
|
95 | + */ |
|
96 | + public function getPersonalSections(); |
|
97 | 97 | |
98 | - /** |
|
99 | - * returns a list of the admin settings |
|
100 | - * |
|
101 | - * @param string $section the section id for which to load the settings |
|
102 | - * @return array array of IAdmin[] where key is the priority |
|
103 | - * @since 9.1.0 |
|
104 | - */ |
|
105 | - public function getAdminSettings($section); |
|
98 | + /** |
|
99 | + * returns a list of the admin settings |
|
100 | + * |
|
101 | + * @param string $section the section id for which to load the settings |
|
102 | + * @return array array of IAdmin[] where key is the priority |
|
103 | + * @since 9.1.0 |
|
104 | + */ |
|
105 | + public function getAdminSettings($section); |
|
106 | 106 | |
107 | - /** |
|
108 | - * returns a list of the personal settings |
|
109 | - * |
|
110 | - * @param string $section the section id for which to load the settings |
|
111 | - * @return array array of IPersonal[] where key is the priority |
|
112 | - * @since 12.0.0 |
|
113 | - */ |
|
114 | - public function getPersonalSettings($section); |
|
107 | + /** |
|
108 | + * returns a list of the personal settings |
|
109 | + * |
|
110 | + * @param string $section the section id for which to load the settings |
|
111 | + * @return array array of IPersonal[] where key is the priority |
|
112 | + * @since 12.0.0 |
|
113 | + */ |
|
114 | + public function getPersonalSettings($section); |
|
115 | 115 | } |
@@ -35,84 +35,84 @@ |
||
35 | 35 | * @package OC\Settings\Controller |
36 | 36 | */ |
37 | 37 | class AdminSettingsController extends Controller { |
38 | - use CommonSettingsTrait; |
|
38 | + use CommonSettingsTrait; |
|
39 | 39 | |
40 | - /** @var INavigationManager */ |
|
41 | - private $navigationManager; |
|
42 | - /** @var ISettingsManager */ |
|
43 | - private $settingsManager; |
|
40 | + /** @var INavigationManager */ |
|
41 | + private $navigationManager; |
|
42 | + /** @var ISettingsManager */ |
|
43 | + private $settingsManager; |
|
44 | 44 | |
45 | - /** |
|
46 | - * @param string $appName |
|
47 | - * @param IRequest $request |
|
48 | - * @param INavigationManager $navigationManager |
|
49 | - * @param ISettingsManager $settingsManager |
|
50 | - */ |
|
51 | - public function __construct( |
|
52 | - $appName, |
|
53 | - IRequest $request, |
|
54 | - INavigationManager $navigationManager, |
|
55 | - ISettingsManager $settingsManager |
|
56 | - ) { |
|
57 | - parent::__construct($appName, $request); |
|
58 | - $this->navigationManager = $navigationManager; |
|
59 | - $this->settingsManager = $settingsManager; |
|
60 | - } |
|
45 | + /** |
|
46 | + * @param string $appName |
|
47 | + * @param IRequest $request |
|
48 | + * @param INavigationManager $navigationManager |
|
49 | + * @param ISettingsManager $settingsManager |
|
50 | + */ |
|
51 | + public function __construct( |
|
52 | + $appName, |
|
53 | + IRequest $request, |
|
54 | + INavigationManager $navigationManager, |
|
55 | + ISettingsManager $settingsManager |
|
56 | + ) { |
|
57 | + parent::__construct($appName, $request); |
|
58 | + $this->navigationManager = $navigationManager; |
|
59 | + $this->settingsManager = $settingsManager; |
|
60 | + } |
|
61 | 61 | |
62 | - /** |
|
63 | - * @param string $section |
|
64 | - * @return TemplateResponse |
|
65 | - * |
|
66 | - * @NoCSRFRequired |
|
67 | - */ |
|
68 | - public function index($section) { |
|
69 | - $this->navigationManager->setActiveEntry('admin'); |
|
70 | - return $this->getIndexResponse($section); |
|
71 | - } |
|
62 | + /** |
|
63 | + * @param string $section |
|
64 | + * @return TemplateResponse |
|
65 | + * |
|
66 | + * @NoCSRFRequired |
|
67 | + */ |
|
68 | + public function index($section) { |
|
69 | + $this->navigationManager->setActiveEntry('admin'); |
|
70 | + return $this->getIndexResponse($section); |
|
71 | + } |
|
72 | 72 | |
73 | - /** |
|
74 | - * @param string $section |
|
75 | - * @return array |
|
76 | - */ |
|
77 | - private function getSettings($section) { |
|
78 | - // PhpStorm shows this as unused, but is required by CommonSettingsTrait |
|
79 | - $settings = $this->settingsManager->getAdminSettings($section); |
|
80 | - $formatted = $this->formatSettings($settings); |
|
81 | - if($section === 'additional') { |
|
82 | - $formatted['content'] .= $this->getLegacyForms(); |
|
83 | - } |
|
84 | - return $formatted; |
|
85 | - } |
|
73 | + /** |
|
74 | + * @param string $section |
|
75 | + * @return array |
|
76 | + */ |
|
77 | + private function getSettings($section) { |
|
78 | + // PhpStorm shows this as unused, but is required by CommonSettingsTrait |
|
79 | + $settings = $this->settingsManager->getAdminSettings($section); |
|
80 | + $formatted = $this->formatSettings($settings); |
|
81 | + if($section === 'additional') { |
|
82 | + $formatted['content'] .= $this->getLegacyForms(); |
|
83 | + } |
|
84 | + return $formatted; |
|
85 | + } |
|
86 | 86 | |
87 | - /** |
|
88 | - * @return bool|string |
|
89 | - */ |
|
90 | - private function getLegacyForms() { |
|
91 | - $forms = \OC_App::getForms('admin'); |
|
87 | + /** |
|
88 | + * @return bool|string |
|
89 | + */ |
|
90 | + private function getLegacyForms() { |
|
91 | + $forms = \OC_App::getForms('admin'); |
|
92 | 92 | |
93 | - $forms = array_map(function ($form) { |
|
94 | - if (preg_match('%(<h2(?P<class>[^>]*)>.*?</h2>)%i', $form, $regs)) { |
|
95 | - $sectionName = str_replace('<h2' . $regs['class'] . '>', '', $regs[0]); |
|
96 | - $sectionName = str_replace('</h2>', '', $sectionName); |
|
97 | - $anchor = strtolower($sectionName); |
|
98 | - $anchor = str_replace(' ', '-', $anchor); |
|
93 | + $forms = array_map(function ($form) { |
|
94 | + if (preg_match('%(<h2(?P<class>[^>]*)>.*?</h2>)%i', $form, $regs)) { |
|
95 | + $sectionName = str_replace('<h2' . $regs['class'] . '>', '', $regs[0]); |
|
96 | + $sectionName = str_replace('</h2>', '', $sectionName); |
|
97 | + $anchor = strtolower($sectionName); |
|
98 | + $anchor = str_replace(' ', '-', $anchor); |
|
99 | 99 | |
100 | - return array( |
|
101 | - 'anchor' => $anchor, |
|
102 | - 'section-name' => $sectionName, |
|
103 | - 'form' => $form |
|
104 | - ); |
|
105 | - } |
|
106 | - return array( |
|
107 | - 'form' => $form |
|
108 | - ); |
|
109 | - }, $forms); |
|
100 | + return array( |
|
101 | + 'anchor' => $anchor, |
|
102 | + 'section-name' => $sectionName, |
|
103 | + 'form' => $form |
|
104 | + ); |
|
105 | + } |
|
106 | + return array( |
|
107 | + 'form' => $form |
|
108 | + ); |
|
109 | + }, $forms); |
|
110 | 110 | |
111 | - $out = new Template('settings', 'admin/additional'); |
|
112 | - $out->assign('forms', $forms); |
|
111 | + $out = new Template('settings', 'admin/additional'); |
|
112 | + $out->assign('forms', $forms); |
|
113 | 113 | |
114 | - return $out->fetchPage(); |
|
115 | - } |
|
114 | + return $out->fetchPage(); |
|
115 | + } |
|
116 | 116 | |
117 | 117 | |
118 | 118 | } |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | // PhpStorm shows this as unused, but is required by CommonSettingsTrait |
79 | 79 | $settings = $this->settingsManager->getAdminSettings($section); |
80 | 80 | $formatted = $this->formatSettings($settings); |
81 | - if($section === 'additional') { |
|
81 | + if ($section === 'additional') { |
|
82 | 82 | $formatted['content'] .= $this->getLegacyForms(); |
83 | 83 | } |
84 | 84 | return $formatted; |
@@ -90,9 +90,9 @@ discard block |
||
90 | 90 | private function getLegacyForms() { |
91 | 91 | $forms = \OC_App::getForms('admin'); |
92 | 92 | |
93 | - $forms = array_map(function ($form) { |
|
93 | + $forms = array_map(function($form) { |
|
94 | 94 | if (preg_match('%(<h2(?P<class>[^>]*)>.*?</h2>)%i', $form, $regs)) { |
95 | - $sectionName = str_replace('<h2' . $regs['class'] . '>', '', $regs[0]); |
|
95 | + $sectionName = str_replace('<h2'.$regs['class'].'>', '', $regs[0]); |
|
96 | 96 | $sectionName = str_replace('</h2>', '', $sectionName); |
97 | 97 | $anchor = strtolower($sectionName); |
98 | 98 | $anchor = str_replace(' ', '-', $anchor); |
@@ -30,44 +30,44 @@ |
||
30 | 30 | use OCP\Settings\IManager as ISettingsManager; |
31 | 31 | |
32 | 32 | class PersonalSettingsController extends Controller { |
33 | - use CommonSettingsTrait { |
|
34 | - getSettings as private; |
|
35 | - } |
|
33 | + use CommonSettingsTrait { |
|
34 | + getSettings as private; |
|
35 | + } |
|
36 | 36 | |
37 | - /** @var INavigationManager */ |
|
38 | - private $navigationManager; |
|
37 | + /** @var INavigationManager */ |
|
38 | + private $navigationManager; |
|
39 | 39 | |
40 | - public function __construct( |
|
41 | - $appName, |
|
42 | - IRequest $request, |
|
43 | - INavigationManager $navigationManager, |
|
44 | - ISettingsManager $settingsManager |
|
45 | - ) { |
|
46 | - parent::__construct($appName, $request); |
|
47 | - $this->navigationManager = $navigationManager; |
|
48 | - $this->settingsManager = $settingsManager; |
|
49 | - } |
|
40 | + public function __construct( |
|
41 | + $appName, |
|
42 | + IRequest $request, |
|
43 | + INavigationManager $navigationManager, |
|
44 | + ISettingsManager $settingsManager |
|
45 | + ) { |
|
46 | + parent::__construct($appName, $request); |
|
47 | + $this->navigationManager = $navigationManager; |
|
48 | + $this->settingsManager = $settingsManager; |
|
49 | + } |
|
50 | 50 | |
51 | - /** |
|
52 | - * @param string $section |
|
53 | - * @return TemplateResponse |
|
54 | - * |
|
55 | - * @NoCSRFRequired |
|
56 | - * @NoAdminRequired |
|
57 | - * @NoSubadminRequired |
|
58 | - */ |
|
59 | - public function index($section) { |
|
60 | - $this->navigationManager->setActiveEntry('personal'); |
|
61 | - return $this->getIndexResponse($section); |
|
62 | - } |
|
51 | + /** |
|
52 | + * @param string $section |
|
53 | + * @return TemplateResponse |
|
54 | + * |
|
55 | + * @NoCSRFRequired |
|
56 | + * @NoAdminRequired |
|
57 | + * @NoSubadminRequired |
|
58 | + */ |
|
59 | + public function index($section) { |
|
60 | + $this->navigationManager->setActiveEntry('personal'); |
|
61 | + return $this->getIndexResponse($section); |
|
62 | + } |
|
63 | 63 | |
64 | - /** |
|
65 | - * @param string $section |
|
66 | - * @return array |
|
67 | - */ |
|
68 | - private function getSettings($section) { |
|
69 | - // PhpStorm shows this as unused, but is required by CommonSettingsTrait |
|
70 | - $settings = $this->settingsManager->getPersonalSettings($section); |
|
71 | - return $this->formatSettings($settings); |
|
72 | - } |
|
64 | + /** |
|
65 | + * @param string $section |
|
66 | + * @return array |
|
67 | + */ |
|
68 | + private function getSettings($section) { |
|
69 | + // PhpStorm shows this as unused, but is required by CommonSettingsTrait |
|
70 | + $settings = $this->settingsManager->getPersonalSettings($section); |
|
71 | + return $this->formatSettings($settings); |
|
72 | + } |
|
73 | 73 | } |
@@ -36,77 +36,77 @@ |
||
36 | 36 | |
37 | 37 | $application = new Application(); |
38 | 38 | $application->registerRoutes($this, [ |
39 | - 'resources' => [ |
|
40 | - 'users' => ['url' => '/settings/users/users'], |
|
41 | - 'AuthSettings' => ['url' => '/settings/personal/authtokens'], |
|
42 | - ], |
|
43 | - 'routes' => [ |
|
44 | - ['name' => 'MailSettings#setMailSettings', 'url' => '/settings/admin/mailsettings', 'verb' => 'POST'], |
|
45 | - ['name' => 'MailSettings#storeCredentials', 'url' => '/settings/admin/mailsettings/credentials', 'verb' => 'POST'], |
|
46 | - ['name' => 'MailSettings#sendTestMail', 'url' => '/settings/admin/mailtest', 'verb' => 'POST'], |
|
47 | - ['name' => 'Encryption#startMigration', 'url' => '/settings/admin/startmigration', 'verb' => 'POST'], |
|
48 | - ['name' => 'AppSettings#listCategories', 'url' => '/settings/apps/categories', 'verb' => 'GET'], |
|
49 | - ['name' => 'AppSettings#viewApps', 'url' => '/settings/apps', 'verb' => 'GET'], |
|
50 | - ['name' => 'AppSettings#listApps', 'url' => '/settings/apps/list', 'verb' => 'GET'], |
|
51 | - ['name' => 'SecuritySettings#trustedDomains', 'url' => '/settings/admin/security/trustedDomains', 'verb' => 'POST'], |
|
52 | - ['name' => 'Users#setDisplayName', 'url' => '/settings/users/{username}/displayName', 'verb' => 'POST'], |
|
53 | - ['name' => 'Users#setEMailAddress', 'url' => '/settings/users/{id}/mailAddress', 'verb' => 'PUT'], |
|
54 | - ['name' => 'Users#setUserSettings', 'url' => '/settings/users/{username}/settings', 'verb' => 'PUT'], |
|
55 | - ['name' => 'Users#getVerificationCode', 'url' => '/settings/users/{account}/verify', 'verb' => 'GET'], |
|
56 | - ['name' => 'Users#setEnabled', 'url' => '/settings/users/{id}/setEnabled', 'verb' => 'POST'], |
|
57 | - ['name' => 'Users#stats', 'url' => '/settings/users/stats', 'verb' => 'GET'], |
|
58 | - ['name' => 'LogSettings#setLogLevel', 'url' => '/settings/admin/log/level', 'verb' => 'POST'], |
|
59 | - ['name' => 'LogSettings#getEntries', 'url' => '/settings/admin/log/entries', 'verb' => 'GET'], |
|
60 | - ['name' => 'LogSettings#download', 'url' => '/settings/admin/log/download', 'verb' => 'GET'], |
|
61 | - ['name' => 'CheckSetup#check', 'url' => '/settings/ajax/checksetup', 'verb' => 'GET'], |
|
62 | - ['name' => 'CheckSetup#getFailedIntegrityCheckFiles', 'url' => '/settings/integrity/failed', 'verb' => 'GET'], |
|
63 | - ['name' => 'CheckSetup#rescanFailedIntegrityCheck', 'url' => '/settings/integrity/rescan', 'verb' => 'GET'], |
|
64 | - ['name' => 'Certificate#addPersonalRootCertificate', 'url' => '/settings/personal/certificate', 'verb' => 'POST'], |
|
65 | - ['name' => 'Certificate#removePersonalRootCertificate', 'url' => '/settings/personal/certificate/{certificateIdentifier}', 'verb' => 'DELETE'], |
|
66 | - ['name' => 'Certificate#addSystemRootCertificate', 'url' => '/settings/admin/certificate', 'verb' => 'POST'], |
|
67 | - ['name' => 'Certificate#removeSystemRootCertificate', 'url' => '/settings/admin/certificate/{certificateIdentifier}', 'verb' => 'DELETE'], |
|
68 | - ['name' => 'PersonalSettings#index', 'url' => '/settings/personal/{section}', 'verb' => 'GET', 'defaults' => ['section' => 'personal-info']], |
|
69 | - ['name' => 'AdminSettings#index', 'url' => '/settings/admin/{section}', 'verb' => 'GET', 'defaults' => ['section' => 'server']], |
|
70 | - ['name' => 'AdminSettings#form', 'url' => '/settings/admin/{section}', 'verb' => 'GET'], |
|
71 | - ['name' => 'ChangePassword#changePersonalPassword', 'url' => '/settings/personal/changepassword', 'verb' => 'POST'], |
|
72 | - ['name' => 'ChangePassword#changeUserPassword', 'url' => '/settings/users/changepassword', 'verb' => 'POST'], |
|
73 | - ['name' => 'Personal#setLanguage', 'url' => '/settings/ajax/setlanguage.php', 'verb' => 'POST'], |
|
74 | - ['name' => 'Groups#index', 'url' => '/settings/users/groups', 'verb' => 'GET'], |
|
75 | - ['name' => 'Groups#show', 'url' => '/settings/users/groups/{id}', 'requirements' => ['id' => '[^?]*'], 'verb' => 'GET'], |
|
76 | - ['name' => 'Groups#create', 'url' => '/settings/users/groups', 'verb' => 'POST'], |
|
77 | - ['name' => 'Groups#update', 'url' => '/settings/users/groups/{id}', 'requirements' => ['id' => '[^?]*'], 'verb' => 'PUT'], |
|
78 | - ['name' => 'Groups#destroy', 'url' => '/settings/users/groups/{id}', 'requirements' => ['id' => '[^?]*'], 'verb' => 'DELETE'], |
|
79 | - ] |
|
39 | + 'resources' => [ |
|
40 | + 'users' => ['url' => '/settings/users/users'], |
|
41 | + 'AuthSettings' => ['url' => '/settings/personal/authtokens'], |
|
42 | + ], |
|
43 | + 'routes' => [ |
|
44 | + ['name' => 'MailSettings#setMailSettings', 'url' => '/settings/admin/mailsettings', 'verb' => 'POST'], |
|
45 | + ['name' => 'MailSettings#storeCredentials', 'url' => '/settings/admin/mailsettings/credentials', 'verb' => 'POST'], |
|
46 | + ['name' => 'MailSettings#sendTestMail', 'url' => '/settings/admin/mailtest', 'verb' => 'POST'], |
|
47 | + ['name' => 'Encryption#startMigration', 'url' => '/settings/admin/startmigration', 'verb' => 'POST'], |
|
48 | + ['name' => 'AppSettings#listCategories', 'url' => '/settings/apps/categories', 'verb' => 'GET'], |
|
49 | + ['name' => 'AppSettings#viewApps', 'url' => '/settings/apps', 'verb' => 'GET'], |
|
50 | + ['name' => 'AppSettings#listApps', 'url' => '/settings/apps/list', 'verb' => 'GET'], |
|
51 | + ['name' => 'SecuritySettings#trustedDomains', 'url' => '/settings/admin/security/trustedDomains', 'verb' => 'POST'], |
|
52 | + ['name' => 'Users#setDisplayName', 'url' => '/settings/users/{username}/displayName', 'verb' => 'POST'], |
|
53 | + ['name' => 'Users#setEMailAddress', 'url' => '/settings/users/{id}/mailAddress', 'verb' => 'PUT'], |
|
54 | + ['name' => 'Users#setUserSettings', 'url' => '/settings/users/{username}/settings', 'verb' => 'PUT'], |
|
55 | + ['name' => 'Users#getVerificationCode', 'url' => '/settings/users/{account}/verify', 'verb' => 'GET'], |
|
56 | + ['name' => 'Users#setEnabled', 'url' => '/settings/users/{id}/setEnabled', 'verb' => 'POST'], |
|
57 | + ['name' => 'Users#stats', 'url' => '/settings/users/stats', 'verb' => 'GET'], |
|
58 | + ['name' => 'LogSettings#setLogLevel', 'url' => '/settings/admin/log/level', 'verb' => 'POST'], |
|
59 | + ['name' => 'LogSettings#getEntries', 'url' => '/settings/admin/log/entries', 'verb' => 'GET'], |
|
60 | + ['name' => 'LogSettings#download', 'url' => '/settings/admin/log/download', 'verb' => 'GET'], |
|
61 | + ['name' => 'CheckSetup#check', 'url' => '/settings/ajax/checksetup', 'verb' => 'GET'], |
|
62 | + ['name' => 'CheckSetup#getFailedIntegrityCheckFiles', 'url' => '/settings/integrity/failed', 'verb' => 'GET'], |
|
63 | + ['name' => 'CheckSetup#rescanFailedIntegrityCheck', 'url' => '/settings/integrity/rescan', 'verb' => 'GET'], |
|
64 | + ['name' => 'Certificate#addPersonalRootCertificate', 'url' => '/settings/personal/certificate', 'verb' => 'POST'], |
|
65 | + ['name' => 'Certificate#removePersonalRootCertificate', 'url' => '/settings/personal/certificate/{certificateIdentifier}', 'verb' => 'DELETE'], |
|
66 | + ['name' => 'Certificate#addSystemRootCertificate', 'url' => '/settings/admin/certificate', 'verb' => 'POST'], |
|
67 | + ['name' => 'Certificate#removeSystemRootCertificate', 'url' => '/settings/admin/certificate/{certificateIdentifier}', 'verb' => 'DELETE'], |
|
68 | + ['name' => 'PersonalSettings#index', 'url' => '/settings/personal/{section}', 'verb' => 'GET', 'defaults' => ['section' => 'personal-info']], |
|
69 | + ['name' => 'AdminSettings#index', 'url' => '/settings/admin/{section}', 'verb' => 'GET', 'defaults' => ['section' => 'server']], |
|
70 | + ['name' => 'AdminSettings#form', 'url' => '/settings/admin/{section}', 'verb' => 'GET'], |
|
71 | + ['name' => 'ChangePassword#changePersonalPassword', 'url' => '/settings/personal/changepassword', 'verb' => 'POST'], |
|
72 | + ['name' => 'ChangePassword#changeUserPassword', 'url' => '/settings/users/changepassword', 'verb' => 'POST'], |
|
73 | + ['name' => 'Personal#setLanguage', 'url' => '/settings/ajax/setlanguage.php', 'verb' => 'POST'], |
|
74 | + ['name' => 'Groups#index', 'url' => '/settings/users/groups', 'verb' => 'GET'], |
|
75 | + ['name' => 'Groups#show', 'url' => '/settings/users/groups/{id}', 'requirements' => ['id' => '[^?]*'], 'verb' => 'GET'], |
|
76 | + ['name' => 'Groups#create', 'url' => '/settings/users/groups', 'verb' => 'POST'], |
|
77 | + ['name' => 'Groups#update', 'url' => '/settings/users/groups/{id}', 'requirements' => ['id' => '[^?]*'], 'verb' => 'PUT'], |
|
78 | + ['name' => 'Groups#destroy', 'url' => '/settings/users/groups/{id}', 'requirements' => ['id' => '[^?]*'], 'verb' => 'DELETE'], |
|
79 | + ] |
|
80 | 80 | ]); |
81 | 81 | |
82 | 82 | /** @var $this \OCP\Route\IRouter */ |
83 | 83 | |
84 | 84 | // Settings pages |
85 | 85 | $this->create('settings_help', '/settings/help') |
86 | - ->actionInclude('settings/help.php'); |
|
86 | + ->actionInclude('settings/help.php'); |
|
87 | 87 | $this->create('settings_users', '/settings/users') |
88 | - ->actionInclude('settings/users.php'); |
|
88 | + ->actionInclude('settings/users.php'); |
|
89 | 89 | // Settings ajax actions |
90 | 90 | // users |
91 | 91 | $this->create('settings_ajax_setquota', '/settings/ajax/setquota.php') |
92 | - ->actionInclude('settings/ajax/setquota.php'); |
|
92 | + ->actionInclude('settings/ajax/setquota.php'); |
|
93 | 93 | $this->create('settings_ajax_togglegroups', '/settings/ajax/togglegroups.php') |
94 | - ->actionInclude('settings/ajax/togglegroups.php'); |
|
94 | + ->actionInclude('settings/ajax/togglegroups.php'); |
|
95 | 95 | $this->create('settings_ajax_togglesubadmins', '/settings/ajax/togglesubadmins.php') |
96 | - ->actionInclude('settings/ajax/togglesubadmins.php'); |
|
96 | + ->actionInclude('settings/ajax/togglesubadmins.php'); |
|
97 | 97 | $this->create('settings_ajax_changegorupname', '/settings/ajax/changegroupname.php') |
98 | - ->actionInclude('settings/ajax/changegroupname.php'); |
|
98 | + ->actionInclude('settings/ajax/changegroupname.php'); |
|
99 | 99 | // apps |
100 | 100 | $this->create('settings_ajax_enableapp', '/settings/ajax/enableapp.php') |
101 | - ->actionInclude('settings/ajax/enableapp.php'); |
|
101 | + ->actionInclude('settings/ajax/enableapp.php'); |
|
102 | 102 | $this->create('settings_ajax_disableapp', '/settings/ajax/disableapp.php') |
103 | - ->actionInclude('settings/ajax/disableapp.php'); |
|
103 | + ->actionInclude('settings/ajax/disableapp.php'); |
|
104 | 104 | $this->create('settings_ajax_updateapp', '/settings/ajax/updateapp.php') |
105 | - ->actionInclude('settings/ajax/updateapp.php'); |
|
105 | + ->actionInclude('settings/ajax/updateapp.php'); |
|
106 | 106 | $this->create('settings_ajax_uninstallapp', '/settings/ajax/uninstallapp.php') |
107 | - ->actionInclude('settings/ajax/uninstallapp.php'); |
|
107 | + ->actionInclude('settings/ajax/uninstallapp.php'); |
|
108 | 108 | $this->create('settings_ajax_navigationdetect', '/settings/ajax/navigationdetect.php') |
109 | - ->actionInclude('settings/ajax/navigationdetect.php'); |
|
109 | + ->actionInclude('settings/ajax/navigationdetect.php'); |
|
110 | 110 | // admin |
111 | 111 | $this->create('settings_ajax_excludegroups', '/settings/ajax/excludegroups.php') |
112 | - ->actionInclude('settings/ajax/excludegroups.php'); |
|
112 | + ->actionInclude('settings/ajax/excludegroups.php'); |