@@ -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)) { |
@@ -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 | |
@@ -34,173 +34,173 @@ |
||
| 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 | - const COMMON_LANGUAGE_CODES = [ |
|
| 49 | - 'en', 'es', 'fr', 'de', 'de_DE', 'ja', 'ar', 'ru', 'nl', 'it', |
|
| 50 | - 'pt_BR', 'pt_PT', 'da', 'fi_FI', 'nb_NO', 'sv', 'tr', 'zh_CN', 'ko' |
|
| 51 | - ]; |
|
| 52 | - /** @var \OC_Defaults */ |
|
| 53 | - private $defaults; |
|
| 54 | - |
|
| 55 | - /** |
|
| 56 | - * @param IConfig $config |
|
| 57 | - * @param IUserManager $userManager |
|
| 58 | - * @param IGroupManager $groupManager |
|
| 59 | - * @param AccountManager $accountManager |
|
| 60 | - * @param IFactory $l10nFactory |
|
| 61 | - */ |
|
| 62 | - public function __construct( |
|
| 63 | - IConfig $config, |
|
| 64 | - IUserManager $userManager, |
|
| 65 | - IGroupManager $groupManager, |
|
| 66 | - AccountManager $accountManager, |
|
| 67 | - IFactory $l10nFactory, |
|
| 68 | - \OC_Defaults $defaults |
|
| 69 | - ) { |
|
| 70 | - $this->config = $config; |
|
| 71 | - $this->userManager = $userManager; |
|
| 72 | - $this->accountManager = $accountManager; |
|
| 73 | - $this->groupManager = $groupManager; |
|
| 74 | - $this->l10nFactory = $l10nFactory; |
|
| 75 | - $this->defaults = $defaults; |
|
| 76 | - } |
|
| 77 | - |
|
| 78 | - /** |
|
| 79 | - * @return TemplateResponse returns the instance with all parameters set, ready to be rendered |
|
| 80 | - * @since 9.1 |
|
| 81 | - */ |
|
| 82 | - public function getForm() { |
|
| 83 | - $lookupServerUploadEnabled = $this->config->getAppValue('files_sharing', 'lookupServerUploadEnabled', 'yes'); |
|
| 84 | - $lookupServerUploadEnabled = $lookupServerUploadEnabled === 'yes'; |
|
| 85 | - |
|
| 86 | - $uid = \OC_User::getUser(); |
|
| 87 | - $user = $this->userManager->get($uid); |
|
| 88 | - |
|
| 89 | - $userData = $this->accountManager->getUser($user); |
|
| 90 | - list($activeLanguage, $commonLanguages, $languages) = $this->getLanguages($user); |
|
| 91 | - |
|
| 92 | - //links to clients |
|
| 93 | - $clients = [ |
|
| 94 | - 'desktop' => $this->config->getSystemValue('customclient_desktop', $this->defaults->getSyncClientUrl()), |
|
| 95 | - 'android' => $this->config->getSystemValue('customclient_android', $this->defaults->getAndroidClientUrl()), |
|
| 96 | - 'ios' => $this->config->getSystemValue('customclient_ios', $this->defaults->getiOSClientUrl()) |
|
| 97 | - ]; |
|
| 98 | - |
|
| 99 | - $parameters = [ |
|
| 100 | - 'avatarChangeSupported' => \OC_User::canUserChangeAvatar($uid), |
|
| 101 | - 'lookupServerUploadEnabled' => $lookupServerUploadEnabled, |
|
| 102 | - 'avatar_scope' => $userData[AccountManager::PROPERTY_AVATAR]['scope'], |
|
| 103 | - 'displayNameChangeSupported' => \OC_User::canUserChangeDisplayName($uid), |
|
| 104 | - 'displayName' => $userData[AccountManager::PROPERTY_DISPLAYNAME]['value'], |
|
| 105 | - 'email' => $userData[AccountManager::PROPERTY_EMAIL]['value'], |
|
| 106 | - 'emailScope' => $userData[AccountManager::PROPERTY_EMAIL]['scope'], |
|
| 107 | - 'emailMesage' => '', |
|
| 108 | - 'emailVerification' => $userData[AccountManager::PROPERTY_EMAIL]['verified'], |
|
| 109 | - 'phone' => $userData[AccountManager::PROPERTY_PHONE]['value'], |
|
| 110 | - 'phoneScope' => $userData[AccountManager::PROPERTY_PHONE]['scope'], |
|
| 111 | - 'address', $userData[AccountManager::PROPERTY_ADDRESS]['value'], |
|
| 112 | - 'addressScope', $userData[AccountManager::PROPERTY_ADDRESS]['scope'], |
|
| 113 | - 'website' => $userData[AccountManager::PROPERTY_WEBSITE]['value'], |
|
| 114 | - 'websiteScope' => $userData[AccountManager::PROPERTY_WEBSITE]['scope'], |
|
| 115 | - 'websiteVerification' => $userData[AccountManager::PROPERTY_WEBSITE]['verified'], |
|
| 116 | - 'twitter' => $userData[AccountManager::PROPERTY_TWITTER]['value'], |
|
| 117 | - 'twitterScope' => $userData[AccountManager::PROPERTY_TWITTER]['scope'], |
|
| 118 | - 'twitterVerification' => $userData[AccountManager::PROPERTY_TWITTER]['verified'], |
|
| 119 | - 'groups' => $this->groupManager->getUserGroups($user), |
|
| 120 | - 'passwordChangeSupported' => \OC_User::canUserChangePassword($uid), |
|
| 121 | - 'activelanguage' => $activeLanguage, |
|
| 122 | - 'commonlanguages' => $commonLanguages, |
|
| 123 | - 'languages' => $languages, |
|
| 124 | - 'clients' => $clients, |
|
| 125 | - ]; |
|
| 126 | - |
|
| 127 | - |
|
| 128 | - return new TemplateResponse('settings', 'settings/personal/personal.info', $parameters, ''); |
|
| 129 | - } |
|
| 130 | - |
|
| 131 | - /** |
|
| 132 | - * @return string the section ID, e.g. 'sharing' |
|
| 133 | - * @since 9.1 |
|
| 134 | - */ |
|
| 135 | - public function getSection() { |
|
| 136 | - return 'personal-info'; |
|
| 137 | - } |
|
| 138 | - |
|
| 139 | - /** |
|
| 140 | - * @return int whether the form should be rather on the top or bottom of |
|
| 141 | - * the admin section. The forms are arranged in ascending order of the |
|
| 142 | - * priority values. It is required to return a value between 0 and 100. |
|
| 143 | - * |
|
| 144 | - * E.g.: 70 |
|
| 145 | - * @since 9.1 |
|
| 146 | - */ |
|
| 147 | - public function getPriority() { |
|
| 148 | - return 10; |
|
| 149 | - } |
|
| 150 | - |
|
| 151 | - private function getLanguages(IUser $user) { |
|
| 152 | - $uid = $user->getUID(); |
|
| 153 | - |
|
| 154 | - $commonLanguages = []; |
|
| 155 | - $userLang = $this->config->getUserValue($uid, 'core', 'lang', $this->l10nFactory->findLanguage()); |
|
| 156 | - $languageCodes = $this->l10nFactory->findAvailableLanguages(); |
|
| 157 | - foreach($languageCodes as $lang) { |
|
| 158 | - $l = \OC::$server->getL10N('settings', $lang); |
|
| 159 | - // TRANSLATORS this is the language name for the language switcher in the personal settings and should be the localized version |
|
| 160 | - $potentialName = (string) $l->t('__language_name__'); |
|
| 161 | - if($l->getLanguageCode() === $lang && substr($potentialName, 0, 1) !== '_') {//first check if the language name is in the translation file |
|
| 162 | - $ln = array('code' => $lang, 'name' => $potentialName); |
|
| 163 | - } elseif ($lang === 'en') { |
|
| 164 | - $ln = ['code' => $lang, 'name' => 'English (US)']; |
|
| 165 | - }else{//fallback to language code |
|
| 166 | - $ln=array('code'=>$lang, 'name'=>$lang); |
|
| 167 | - } |
|
| 168 | - |
|
| 169 | - // put appropriate languages into appropriate arrays, to print them sorted |
|
| 170 | - // used language -> common languages -> divider -> other languages |
|
| 171 | - if ($lang === $userLang) { |
|
| 172 | - $userLang = $ln; |
|
| 173 | - } elseif (in_array($lang, self::COMMON_LANGUAGE_CODES)) { |
|
| 174 | - $commonLanguages[array_search($lang, self::COMMON_LANGUAGE_CODES)]=$ln; |
|
| 175 | - } else { |
|
| 176 | - $languages[]=$ln; |
|
| 177 | - } |
|
| 178 | - } |
|
| 179 | - |
|
| 180 | - // if user language is not available but set somehow: show the actual code as name |
|
| 181 | - if (!is_array($userLang)) { |
|
| 182 | - $userLang = [ |
|
| 183 | - 'code' => $userLang, |
|
| 184 | - 'name' => $userLang, |
|
| 185 | - ]; |
|
| 186 | - } |
|
| 187 | - |
|
| 188 | - ksort($commonLanguages); |
|
| 189 | - |
|
| 190 | - // sort now by displayed language not the iso-code |
|
| 191 | - usort( $languages, function ($a, $b) { |
|
| 192 | - if ($a['code'] === $a['name'] && $b['code'] !== $b['name']) { |
|
| 193 | - // If a doesn't have a name, but b does, list b before a |
|
| 194 | - return 1; |
|
| 195 | - } |
|
| 196 | - if ($a['code'] !== $a['name'] && $b['code'] === $b['name']) { |
|
| 197 | - // If a does have a name, but b doesn't, list a before b |
|
| 198 | - return -1; |
|
| 199 | - } |
|
| 200 | - // Otherwise compare the names |
|
| 201 | - return strcmp($a['name'], $b['name']); |
|
| 202 | - }); |
|
| 203 | - |
|
| 204 | - return [$userLang, $commonLanguages, $languages]; |
|
| 205 | - } |
|
| 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 | + const COMMON_LANGUAGE_CODES = [ |
|
| 49 | + 'en', 'es', 'fr', 'de', 'de_DE', 'ja', 'ar', 'ru', 'nl', 'it', |
|
| 50 | + 'pt_BR', 'pt_PT', 'da', 'fi_FI', 'nb_NO', 'sv', 'tr', 'zh_CN', 'ko' |
|
| 51 | + ]; |
|
| 52 | + /** @var \OC_Defaults */ |
|
| 53 | + private $defaults; |
|
| 54 | + |
|
| 55 | + /** |
|
| 56 | + * @param IConfig $config |
|
| 57 | + * @param IUserManager $userManager |
|
| 58 | + * @param IGroupManager $groupManager |
|
| 59 | + * @param AccountManager $accountManager |
|
| 60 | + * @param IFactory $l10nFactory |
|
| 61 | + */ |
|
| 62 | + public function __construct( |
|
| 63 | + IConfig $config, |
|
| 64 | + IUserManager $userManager, |
|
| 65 | + IGroupManager $groupManager, |
|
| 66 | + AccountManager $accountManager, |
|
| 67 | + IFactory $l10nFactory, |
|
| 68 | + \OC_Defaults $defaults |
|
| 69 | + ) { |
|
| 70 | + $this->config = $config; |
|
| 71 | + $this->userManager = $userManager; |
|
| 72 | + $this->accountManager = $accountManager; |
|
| 73 | + $this->groupManager = $groupManager; |
|
| 74 | + $this->l10nFactory = $l10nFactory; |
|
| 75 | + $this->defaults = $defaults; |
|
| 76 | + } |
|
| 77 | + |
|
| 78 | + /** |
|
| 79 | + * @return TemplateResponse returns the instance with all parameters set, ready to be rendered |
|
| 80 | + * @since 9.1 |
|
| 81 | + */ |
|
| 82 | + public function getForm() { |
|
| 83 | + $lookupServerUploadEnabled = $this->config->getAppValue('files_sharing', 'lookupServerUploadEnabled', 'yes'); |
|
| 84 | + $lookupServerUploadEnabled = $lookupServerUploadEnabled === 'yes'; |
|
| 85 | + |
|
| 86 | + $uid = \OC_User::getUser(); |
|
| 87 | + $user = $this->userManager->get($uid); |
|
| 88 | + |
|
| 89 | + $userData = $this->accountManager->getUser($user); |
|
| 90 | + list($activeLanguage, $commonLanguages, $languages) = $this->getLanguages($user); |
|
| 91 | + |
|
| 92 | + //links to clients |
|
| 93 | + $clients = [ |
|
| 94 | + 'desktop' => $this->config->getSystemValue('customclient_desktop', $this->defaults->getSyncClientUrl()), |
|
| 95 | + 'android' => $this->config->getSystemValue('customclient_android', $this->defaults->getAndroidClientUrl()), |
|
| 96 | + 'ios' => $this->config->getSystemValue('customclient_ios', $this->defaults->getiOSClientUrl()) |
|
| 97 | + ]; |
|
| 98 | + |
|
| 99 | + $parameters = [ |
|
| 100 | + 'avatarChangeSupported' => \OC_User::canUserChangeAvatar($uid), |
|
| 101 | + 'lookupServerUploadEnabled' => $lookupServerUploadEnabled, |
|
| 102 | + 'avatar_scope' => $userData[AccountManager::PROPERTY_AVATAR]['scope'], |
|
| 103 | + 'displayNameChangeSupported' => \OC_User::canUserChangeDisplayName($uid), |
|
| 104 | + 'displayName' => $userData[AccountManager::PROPERTY_DISPLAYNAME]['value'], |
|
| 105 | + 'email' => $userData[AccountManager::PROPERTY_EMAIL]['value'], |
|
| 106 | + 'emailScope' => $userData[AccountManager::PROPERTY_EMAIL]['scope'], |
|
| 107 | + 'emailMesage' => '', |
|
| 108 | + 'emailVerification' => $userData[AccountManager::PROPERTY_EMAIL]['verified'], |
|
| 109 | + 'phone' => $userData[AccountManager::PROPERTY_PHONE]['value'], |
|
| 110 | + 'phoneScope' => $userData[AccountManager::PROPERTY_PHONE]['scope'], |
|
| 111 | + 'address', $userData[AccountManager::PROPERTY_ADDRESS]['value'], |
|
| 112 | + 'addressScope', $userData[AccountManager::PROPERTY_ADDRESS]['scope'], |
|
| 113 | + 'website' => $userData[AccountManager::PROPERTY_WEBSITE]['value'], |
|
| 114 | + 'websiteScope' => $userData[AccountManager::PROPERTY_WEBSITE]['scope'], |
|
| 115 | + 'websiteVerification' => $userData[AccountManager::PROPERTY_WEBSITE]['verified'], |
|
| 116 | + 'twitter' => $userData[AccountManager::PROPERTY_TWITTER]['value'], |
|
| 117 | + 'twitterScope' => $userData[AccountManager::PROPERTY_TWITTER]['scope'], |
|
| 118 | + 'twitterVerification' => $userData[AccountManager::PROPERTY_TWITTER]['verified'], |
|
| 119 | + 'groups' => $this->groupManager->getUserGroups($user), |
|
| 120 | + 'passwordChangeSupported' => \OC_User::canUserChangePassword($uid), |
|
| 121 | + 'activelanguage' => $activeLanguage, |
|
| 122 | + 'commonlanguages' => $commonLanguages, |
|
| 123 | + 'languages' => $languages, |
|
| 124 | + 'clients' => $clients, |
|
| 125 | + ]; |
|
| 126 | + |
|
| 127 | + |
|
| 128 | + return new TemplateResponse('settings', 'settings/personal/personal.info', $parameters, ''); |
|
| 129 | + } |
|
| 130 | + |
|
| 131 | + /** |
|
| 132 | + * @return string the section ID, e.g. 'sharing' |
|
| 133 | + * @since 9.1 |
|
| 134 | + */ |
|
| 135 | + public function getSection() { |
|
| 136 | + return 'personal-info'; |
|
| 137 | + } |
|
| 138 | + |
|
| 139 | + /** |
|
| 140 | + * @return int whether the form should be rather on the top or bottom of |
|
| 141 | + * the admin section. The forms are arranged in ascending order of the |
|
| 142 | + * priority values. It is required to return a value between 0 and 100. |
|
| 143 | + * |
|
| 144 | + * E.g.: 70 |
|
| 145 | + * @since 9.1 |
|
| 146 | + */ |
|
| 147 | + public function getPriority() { |
|
| 148 | + return 10; |
|
| 149 | + } |
|
| 150 | + |
|
| 151 | + private function getLanguages(IUser $user) { |
|
| 152 | + $uid = $user->getUID(); |
|
| 153 | + |
|
| 154 | + $commonLanguages = []; |
|
| 155 | + $userLang = $this->config->getUserValue($uid, 'core', 'lang', $this->l10nFactory->findLanguage()); |
|
| 156 | + $languageCodes = $this->l10nFactory->findAvailableLanguages(); |
|
| 157 | + foreach($languageCodes as $lang) { |
|
| 158 | + $l = \OC::$server->getL10N('settings', $lang); |
|
| 159 | + // TRANSLATORS this is the language name for the language switcher in the personal settings and should be the localized version |
|
| 160 | + $potentialName = (string) $l->t('__language_name__'); |
|
| 161 | + if($l->getLanguageCode() === $lang && substr($potentialName, 0, 1) !== '_') {//first check if the language name is in the translation file |
|
| 162 | + $ln = array('code' => $lang, 'name' => $potentialName); |
|
| 163 | + } elseif ($lang === 'en') { |
|
| 164 | + $ln = ['code' => $lang, 'name' => 'English (US)']; |
|
| 165 | + }else{//fallback to language code |
|
| 166 | + $ln=array('code'=>$lang, 'name'=>$lang); |
|
| 167 | + } |
|
| 168 | + |
|
| 169 | + // put appropriate languages into appropriate arrays, to print them sorted |
|
| 170 | + // used language -> common languages -> divider -> other languages |
|
| 171 | + if ($lang === $userLang) { |
|
| 172 | + $userLang = $ln; |
|
| 173 | + } elseif (in_array($lang, self::COMMON_LANGUAGE_CODES)) { |
|
| 174 | + $commonLanguages[array_search($lang, self::COMMON_LANGUAGE_CODES)]=$ln; |
|
| 175 | + } else { |
|
| 176 | + $languages[]=$ln; |
|
| 177 | + } |
|
| 178 | + } |
|
| 179 | + |
|
| 180 | + // if user language is not available but set somehow: show the actual code as name |
|
| 181 | + if (!is_array($userLang)) { |
|
| 182 | + $userLang = [ |
|
| 183 | + 'code' => $userLang, |
|
| 184 | + 'name' => $userLang, |
|
| 185 | + ]; |
|
| 186 | + } |
|
| 187 | + |
|
| 188 | + ksort($commonLanguages); |
|
| 189 | + |
|
| 190 | + // sort now by displayed language not the iso-code |
|
| 191 | + usort( $languages, function ($a, $b) { |
|
| 192 | + if ($a['code'] === $a['name'] && $b['code'] !== $b['name']) { |
|
| 193 | + // If a doesn't have a name, but b does, list b before a |
|
| 194 | + return 1; |
|
| 195 | + } |
|
| 196 | + if ($a['code'] !== $a['name'] && $b['code'] === $b['name']) { |
|
| 197 | + // If a does have a name, but b doesn't, list a before b |
|
| 198 | + return -1; |
|
| 199 | + } |
|
| 200 | + // Otherwise compare the names |
|
| 201 | + return strcmp($a['name'], $b['name']); |
|
| 202 | + }); |
|
| 203 | + |
|
| 204 | + return [$userLang, $commonLanguages, $languages]; |
|
| 205 | + } |
|
| 206 | 206 | } |
@@ -154,16 +154,16 @@ discard block |
||
| 154 | 154 | $commonLanguages = []; |
| 155 | 155 | $userLang = $this->config->getUserValue($uid, 'core', 'lang', $this->l10nFactory->findLanguage()); |
| 156 | 156 | $languageCodes = $this->l10nFactory->findAvailableLanguages(); |
| 157 | - foreach($languageCodes as $lang) { |
|
| 157 | + foreach ($languageCodes as $lang) { |
|
| 158 | 158 | $l = \OC::$server->getL10N('settings', $lang); |
| 159 | 159 | // TRANSLATORS this is the language name for the language switcher in the personal settings and should be the localized version |
| 160 | 160 | $potentialName = (string) $l->t('__language_name__'); |
| 161 | - if($l->getLanguageCode() === $lang && substr($potentialName, 0, 1) !== '_') {//first check if the language name is in the translation file |
|
| 161 | + if ($l->getLanguageCode() === $lang && substr($potentialName, 0, 1) !== '_') {//first check if the language name is in the translation file |
|
| 162 | 162 | $ln = array('code' => $lang, 'name' => $potentialName); |
| 163 | 163 | } elseif ($lang === 'en') { |
| 164 | 164 | $ln = ['code' => $lang, 'name' => 'English (US)']; |
| 165 | - }else{//fallback to language code |
|
| 166 | - $ln=array('code'=>$lang, 'name'=>$lang); |
|
| 165 | + } else {//fallback to language code |
|
| 166 | + $ln = array('code'=>$lang, 'name'=>$lang); |
|
| 167 | 167 | } |
| 168 | 168 | |
| 169 | 169 | // put appropriate languages into appropriate arrays, to print them sorted |
@@ -171,9 +171,9 @@ discard block |
||
| 171 | 171 | if ($lang === $userLang) { |
| 172 | 172 | $userLang = $ln; |
| 173 | 173 | } elseif (in_array($lang, self::COMMON_LANGUAGE_CODES)) { |
| 174 | - $commonLanguages[array_search($lang, self::COMMON_LANGUAGE_CODES)]=$ln; |
|
| 174 | + $commonLanguages[array_search($lang, self::COMMON_LANGUAGE_CODES)] = $ln; |
|
| 175 | 175 | } else { |
| 176 | - $languages[]=$ln; |
|
| 176 | + $languages[] = $ln; |
|
| 177 | 177 | } |
| 178 | 178 | } |
| 179 | 179 | |
@@ -188,7 +188,7 @@ discard block |
||
| 188 | 188 | ksort($commonLanguages); |
| 189 | 189 | |
| 190 | 190 | // sort now by displayed language not the iso-code |
| 191 | - usort( $languages, function ($a, $b) { |
|
| 191 | + usort($languages, function($a, $b) { |
|
| 192 | 192 | if ($a['code'] === $a['name'] && $b['code'] !== $b['name']) { |
| 193 | 193 | // If a doesn't have a name, but b does, list b before a |
| 194 | 194 | return 1; |
@@ -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 | } |
@@ -54,7 +54,7 @@ discard block |
||
| 54 | 54 | </div> |
| 55 | 55 | </div> |
| 56 | 56 | <span class="icon-checkmark hidden"/> |
| 57 | - <?php if($_['lookupServerUploadEnabled']) { ?> |
|
| 57 | + <?php if ($_['lookupServerUploadEnabled']) { ?> |
|
| 58 | 58 | <input type="hidden" id="avatarscope" value="<?php p($_['avatarScope']) ?>"> |
| 59 | 59 | <?php } ?> |
| 60 | 60 | </form> |
@@ -68,14 +68,14 @@ discard block |
||
| 68 | 68 | <span class="icon-password"/> |
| 69 | 69 | </h2> |
| 70 | 70 | <input type="text" id="displayname" name="displayname" |
| 71 | - <?php if(!$_['displayNameChangeSupported']) { print_unescaped('class="hidden"'); } ?> |
|
| 71 | + <?php if (!$_['displayNameChangeSupported']) { print_unescaped('class="hidden"'); } ?> |
|
| 72 | 72 | value="<?php p($_['displayName']) ?>" |
| 73 | 73 | autocomplete="on" autocapitalize="none" autocorrect="off" /> |
| 74 | - <?php if(!$_['displayNameChangeSupported']) { ?> |
|
| 75 | - <span><?php if(isset($_['displayName']) && !empty($_['displayName'])) { p($_['displayName']); } else { p($l->t('No display name set')); } ?></span> |
|
| 74 | + <?php if (!$_['displayNameChangeSupported']) { ?> |
|
| 75 | + <span><?php if (isset($_['displayName']) && !empty($_['displayName'])) { p($_['displayName']); } else { p($l->t('No display name set')); } ?></span> |
|
| 76 | 76 | <?php } ?> |
| 77 | 77 | <span class="icon-checkmark hidden"/> |
| 78 | - <?php if($_['lookupServerUploadEnabled']) { ?> |
|
| 78 | + <?php if ($_['lookupServerUploadEnabled']) { ?> |
|
| 79 | 79 | <input type="hidden" id="displaynamescope" value="<?php p($_['displayNameScope']) ?>"> |
| 80 | 80 | <?php } ?> |
| 81 | 81 | </form> |
@@ -86,10 +86,10 @@ discard block |
||
| 86 | 86 | <label for="email"><?php p($l->t('Email')); ?></label> |
| 87 | 87 | <span class="icon-password"/> |
| 88 | 88 | </h2> |
| 89 | - <div class="verify <?php if ($_['email'] === '' || $_['emailScope'] !== 'public') p('hidden'); ?>"> |
|
| 89 | + <div class="verify <?php if ($_['email'] === '' || $_['emailScope'] !== 'public') p('hidden'); ?>"> |
|
| 90 | 90 | <img id="verify-email" title="<?php p($_['emailMessage']); ?>" data-status="<?php p($_['emailVerification']) ?>" src=" |
| 91 | 91 | <?php |
| 92 | - switch($_['emailVerification']) { |
|
| 92 | + switch ($_['emailVerification']) { |
|
| 93 | 93 | case \OC\Accounts\AccountManager::VERIFICATION_IN_PROGRESS: |
| 94 | 94 | p(image_path('core', 'actions/verifying.svg')); |
| 95 | 95 | break; |
@@ -102,23 +102,23 @@ discard block |
||
| 102 | 102 | ?>"> |
| 103 | 103 | </div> |
| 104 | 104 | <input type="email" name="email" id="email" value="<?php p($_['email']); ?>" |
| 105 | - <?php if(!$_['displayNameChangeSupported']) { print_unescaped('class="hidden"'); } ?> |
|
| 105 | + <?php if (!$_['displayNameChangeSupported']) { print_unescaped('class="hidden"'); } ?> |
|
| 106 | 106 | placeholder="<?php p($l->t('Your email address')); ?>" |
| 107 | 107 | autocomplete="on" autocapitalize="none" autocorrect="off" /> |
| 108 | - <?php if(!$_['displayNameChangeSupported']) { ?> |
|
| 109 | - <span><?php if(isset($_['email']) && !empty($_['email'])) { p($_['email']); } else { p($l->t('No email address set')); }?></span> |
|
| 108 | + <?php if (!$_['displayNameChangeSupported']) { ?> |
|
| 109 | + <span><?php if (isset($_['email']) && !empty($_['email'])) { p($_['email']); } else { p($l->t('No email address set')); }?></span> |
|
| 110 | 110 | <?php } ?> |
| 111 | - <?php if($_['displayNameChangeSupported']) { ?> |
|
| 111 | + <?php if ($_['displayNameChangeSupported']) { ?> |
|
| 112 | 112 | <br /> |
| 113 | 113 | <em><?php p($l->t('For password reset and notifications')); ?></em> |
| 114 | 114 | <?php } ?> |
| 115 | 115 | <span class="icon-checkmark hidden"/> |
| 116 | - <?php if($_['lookupServerUploadEnabled']) { ?> |
|
| 116 | + <?php if ($_['lookupServerUploadEnabled']) { ?> |
|
| 117 | 117 | <input type="hidden" id="emailscope" value="<?php p($_['emailScope']) ?>"> |
| 118 | 118 | <?php } ?> |
| 119 | 119 | </form> |
| 120 | 120 | </div> |
| 121 | - <?php if($_['lookupServerUploadEnabled']) { ?> |
|
| 121 | + <?php if ($_['lookupServerUploadEnabled']) { ?> |
|
| 122 | 122 | <div class="personal-settings-setting-box"> |
| 123 | 123 | <form id="phoneform" class="section"> |
| 124 | 124 | <h2> |
@@ -153,10 +153,10 @@ discard block |
||
| 153 | 153 | <label for="website"><?php p($l->t('Website')); ?></label> |
| 154 | 154 | <span class="icon-password"/> |
| 155 | 155 | </h2> |
| 156 | - <div class="verify <?php if ($_['website'] === '' || $_['websiteScope'] !== 'public') p('hidden'); ?>"> |
|
| 156 | + <div class="verify <?php if ($_['website'] === '' || $_['websiteScope'] !== 'public') p('hidden'); ?>"> |
|
| 157 | 157 | <img id="verify-website" title="<?php p($_['websiteMessage']); ?>" data-status="<?php p($_['websiteVerification']) ?>" src=" |
| 158 | 158 | <?php |
| 159 | - switch($_['websiteVerification']) { |
|
| 159 | + switch ($_['websiteVerification']) { |
|
| 160 | 160 | case \OC\Accounts\AccountManager::VERIFICATION_IN_PROGRESS: |
| 161 | 161 | p(image_path('core', 'actions/verifying.svg')); |
| 162 | 162 | break; |
@@ -167,13 +167,13 @@ discard block |
||
| 167 | 167 | p(image_path('core', 'actions/verify.svg')); |
| 168 | 168 | } |
| 169 | 169 | ?>" |
| 170 | - <?php if($_['websiteVerification'] === \OC\Accounts\AccountManager::VERIFICATION_IN_PROGRESS || $_['websiteVerification'] === \OC\Accounts\AccountManager::NOT_VERIFIED) print_unescaped(' class="verify-action"') ?> |
|
| 170 | + <?php if ($_['websiteVerification'] === \OC\Accounts\AccountManager::VERIFICATION_IN_PROGRESS || $_['websiteVerification'] === \OC\Accounts\AccountManager::NOT_VERIFIED) print_unescaped(' class="verify-action"') ?> |
|
| 171 | 171 | > |
| 172 | 172 | <div class="verification-dialog popovermenu bubble menu"> |
| 173 | 173 | <div class="verification-dialog-content"> |
| 174 | 174 | <p class="explainVerification"></p> |
| 175 | 175 | <p class="verificationCode"></p> |
| 176 | - <p><?php p($l->t('It can take up to 24 hours before the account is displayed as verified.'));?></p> |
|
| 176 | + <p><?php p($l->t('It can take up to 24 hours before the account is displayed as verified.')); ?></p> |
|
| 177 | 177 | </div> |
| 178 | 178 | </div> |
| 179 | 179 | </div> |
@@ -190,10 +190,10 @@ discard block |
||
| 190 | 190 | <label for="twitter"><?php p($l->t('Twitter')); ?></label> |
| 191 | 191 | <span class="icon-password"/> |
| 192 | 192 | </h2> |
| 193 | - <div class="verify <?php if ($_['twitter'] === '' || $_['twitterScope'] !== 'public') p('hidden'); ?>"> |
|
| 193 | + <div class="verify <?php if ($_['twitter'] === '' || $_['twitterScope'] !== 'public') p('hidden'); ?>"> |
|
| 194 | 194 | <img id="verify-twitter" title="<?php p($_['twitterMessage']); ?>" data-status="<?php p($_['twitterVerification']) ?>" src=" |
| 195 | 195 | <?php |
| 196 | - switch($_['twitterVerification']) { |
|
| 196 | + switch ($_['twitterVerification']) { |
|
| 197 | 197 | case \OC\Accounts\AccountManager::VERIFICATION_IN_PROGRESS: |
| 198 | 198 | p(image_path('core', 'actions/verifying.svg')); |
| 199 | 199 | break; |
@@ -204,13 +204,13 @@ discard block |
||
| 204 | 204 | p(image_path('core', 'actions/verify.svg')); |
| 205 | 205 | } |
| 206 | 206 | ?>" |
| 207 | - <?php if($_['twitterVerification'] === \OC\Accounts\AccountManager::VERIFICATION_IN_PROGRESS || $_['twitterVerification'] === \OC\Accounts\AccountManager::NOT_VERIFIED) print_unescaped(' class="verify-action"') ?> |
|
| 207 | + <?php if ($_['twitterVerification'] === \OC\Accounts\AccountManager::VERIFICATION_IN_PROGRESS || $_['twitterVerification'] === \OC\Accounts\AccountManager::NOT_VERIFIED) print_unescaped(' class="verify-action"') ?> |
|
| 208 | 208 | > |
| 209 | 209 | <div class="verification-dialog popovermenu bubble menu"> |
| 210 | 210 | <div class="verification-dialog-content"> |
| 211 | 211 | <p class="explainVerification"></p> |
| 212 | 212 | <p class="verificationCode"></p> |
| 213 | - <p><?php p($l->t('It can take up to 24 hours before the account is displayed as verified.'));?></p> |
|
| 213 | + <p><?php p($l->t('It can take up to 24 hours before the account is displayed as verified.')); ?></p> |
|
| 214 | 214 | </div> |
| 215 | 215 | </div> |
| 216 | 216 | </div> |
@@ -235,19 +235,19 @@ discard block |
||
| 235 | 235 | </div> |
| 236 | 236 | |
| 237 | 237 | <?php |
| 238 | -if($_['passwordChangeSupported']) { |
|
| 238 | +if ($_['passwordChangeSupported']) { |
|
| 239 | 239 | script('jquery-showpassword'); |
| 240 | 240 | ?> |
| 241 | 241 | <form id="passwordform" class="section"> |
| 242 | - <h2 class="inlineblock"><?php p($l->t('Password'));?></h2> |
|
| 242 | + <h2 class="inlineblock"><?php p($l->t('Password')); ?></h2> |
|
| 243 | 243 | <div id="password-error-msg" class="msg success inlineblock" style="display: none;">Saved</div> |
| 244 | 244 | <br> |
| 245 | 245 | <label for="pass1" class="hidden-visually"><?php p($l->t('Current password')); ?>: </label> |
| 246 | 246 | <input type="password" id="pass1" name="oldpassword" |
| 247 | - placeholder="<?php p($l->t('Current password'));?>" |
|
| 247 | + placeholder="<?php p($l->t('Current password')); ?>" |
|
| 248 | 248 | autocomplete="off" autocapitalize="none" autocorrect="off" /> |
| 249 | 249 | <div class="personal-show-container"> |
| 250 | - <label for="pass2" class="hidden-visually"><?php p($l->t('New password'));?>: </label> |
|
| 250 | + <label for="pass2" class="hidden-visually"><?php p($l->t('New password')); ?>: </label> |
|
| 251 | 251 | <input type="password" id="pass2" name="newpassword" |
| 252 | 252 | placeholder="<?php p($l->t('New password')); ?>" |
| 253 | 253 | data-typetoggle="#personal-show" |
@@ -263,44 +263,44 @@ discard block |
||
| 263 | 263 | |
| 264 | 264 | <form id="language" class="section"> |
| 265 | 265 | <h2> |
| 266 | - <label for="languageinput"><?php p($l->t('Language'));?></label> |
|
| 266 | + <label for="languageinput"><?php p($l->t('Language')); ?></label> |
|
| 267 | 267 | </h2> |
| 268 | - <select id="languageinput" name="lang" data-placeholder="<?php p($l->t('Language'));?>"> |
|
| 269 | - <option value="<?php p($_['activelanguage']['code']);?>"> |
|
| 270 | - <?php p($_['activelanguage']['name']);?> |
|
| 268 | + <select id="languageinput" name="lang" data-placeholder="<?php p($l->t('Language')); ?>"> |
|
| 269 | + <option value="<?php p($_['activelanguage']['code']); ?>"> |
|
| 270 | + <?php p($_['activelanguage']['name']); ?> |
|
| 271 | 271 | </option> |
| 272 | - <?php foreach($_['commonlanguages'] as $language):?> |
|
| 273 | - <option value="<?php p($language['code']);?>"> |
|
| 274 | - <?php p($language['name']);?> |
|
| 272 | + <?php foreach ($_['commonlanguages'] as $language):?> |
|
| 273 | + <option value="<?php p($language['code']); ?>"> |
|
| 274 | + <?php p($language['name']); ?> |
|
| 275 | 275 | </option> |
| 276 | - <?php endforeach;?> |
|
| 276 | + <?php endforeach; ?> |
|
| 277 | 277 | <optgroup label="––––––––––"></optgroup> |
| 278 | - <?php foreach($_['languages'] as $language):?> |
|
| 279 | - <option value="<?php p($language['code']);?>"> |
|
| 280 | - <?php p($language['name']);?> |
|
| 278 | + <?php foreach ($_['languages'] as $language):?> |
|
| 279 | + <option value="<?php p($language['code']); ?>"> |
|
| 280 | + <?php p($language['name']); ?> |
|
| 281 | 281 | </option> |
| 282 | - <?php endforeach;?> |
|
| 282 | + <?php endforeach; ?> |
|
| 283 | 283 | </select> |
| 284 | 284 | <a href="https://www.transifex.com/nextcloud/nextcloud/" |
| 285 | 285 | target="_blank" rel="noreferrer"> |
| 286 | - <em><?php p($l->t('Help translate'));?></em> |
|
| 286 | + <em><?php p($l->t('Help translate')); ?></em> |
|
| 287 | 287 | </a> |
| 288 | 288 | </form> |
| 289 | 289 | |
| 290 | 290 | |
| 291 | 291 | <div id="clientsbox" class="section clientsbox"> |
| 292 | - <h2><?php p($l->t('Get the apps to sync your files'));?></h2> |
|
| 292 | + <h2><?php p($l->t('Get the apps to sync your files')); ?></h2> |
|
| 293 | 293 | <a href="<?php p($_['clients']['desktop']); ?>" rel="noreferrer" target="_blank"> |
| 294 | 294 | <img src="<?php print_unescaped(image_path('core', 'desktopapp.svg')); ?>" |
| 295 | - alt="<?php p($l->t('Desktop client'));?>" /> |
|
| 295 | + alt="<?php p($l->t('Desktop client')); ?>" /> |
|
| 296 | 296 | </a> |
| 297 | 297 | <a href="<?php p($_['clients']['android']); ?>" rel="noreferrer" target="_blank"> |
| 298 | 298 | <img src="<?php print_unescaped(image_path('core', 'googleplay.png')); ?>" |
| 299 | - alt="<?php p($l->t('Android app'));?>" /> |
|
| 299 | + alt="<?php p($l->t('Android app')); ?>" /> |
|
| 300 | 300 | </a> |
| 301 | 301 | <a href="<?php p($_['clients']['ios']); ?>" rel="noreferrer" target="_blank"> |
| 302 | 302 | <img src="<?php print_unescaped(image_path('core', 'appstore.svg')); ?>" |
| 303 | - alt="<?php p($l->t('iOS app'));?>" /> |
|
| 303 | + alt="<?php p($l->t('iOS app')); ?>" /> |
|
| 304 | 304 | </a> |
| 305 | 305 | |
| 306 | 306 | <p> |
@@ -316,8 +316,8 @@ discard block |
||
| 316 | 316 | $l->t('If you want to support the project {contributeopen}join development{linkclose} or {contributeopen}spread the word{linkclose}!'))); ?> |
| 317 | 317 | </p> |
| 318 | 318 | |
| 319 | - <?php if(OC_APP::isEnabled('firstrunwizard')) {?> |
|
| 320 | - <p><a class="button" href="#" id="showWizard"><?php p($l->t('Show First Run Wizard again'));?></a></p> |
|
| 319 | + <?php if (OC_APP::isEnabled('firstrunwizard')) {?> |
|
| 320 | + <p><a class="button" href="#" id="showWizard"><?php p($l->t('Show First Run Wizard again')); ?></a></p> |
|
| 321 | 321 | <?php }?> |
| 322 | 322 | </div> |
| 323 | 323 | |
@@ -42,8 +42,11 @@ discard block |
||
| 42 | 42 | <div class="hidden button icon-delete svg" id="removeavatar" title="<?php p($l->t('Remove image')); ?>"></div> |
| 43 | 43 | <input type="file" name="files[]" id="uploadavatar" class="hiddenuploadfield"> |
| 44 | 44 | <p><em><?php p($l->t('png or jpg, max. 20 MB')); ?></em></p> |
| 45 | - <?php else: ?> |
|
| 46 | - <?php p($l->t('Picture provided by original account')); ?> |
|
| 45 | + <?php else { |
|
| 46 | + : ?> |
|
| 47 | + <?php p($l->t('Picture provided by original account')); |
|
| 48 | +} |
|
| 49 | +?> |
|
| 47 | 50 | <?php endif; ?> |
| 48 | 51 | </div> |
| 49 | 52 | |
@@ -86,7 +89,10 @@ discard block |
||
| 86 | 89 | <label for="email"><?php p($l->t('Email')); ?></label> |
| 87 | 90 | <span class="icon-password"/> |
| 88 | 91 | </h2> |
| 89 | - <div class="verify <?php if ($_['email'] === '' || $_['emailScope'] !== 'public') p('hidden'); ?>"> |
|
| 92 | + <div class="verify <?php if ($_['email'] === '' || $_['emailScope'] !== 'public') { |
|
| 93 | + p('hidden'); |
|
| 94 | +} |
|
| 95 | +?>"> |
|
| 90 | 96 | <img id="verify-email" title="<?php p($_['emailMessage']); ?>" data-status="<?php p($_['emailVerification']) ?>" src=" |
| 91 | 97 | <?php |
| 92 | 98 | switch($_['emailVerification']) { |
@@ -153,7 +159,10 @@ discard block |
||
| 153 | 159 | <label for="website"><?php p($l->t('Website')); ?></label> |
| 154 | 160 | <span class="icon-password"/> |
| 155 | 161 | </h2> |
| 156 | - <div class="verify <?php if ($_['website'] === '' || $_['websiteScope'] !== 'public') p('hidden'); ?>"> |
|
| 162 | + <div class="verify <?php if ($_['website'] === '' || $_['websiteScope'] !== 'public') { |
|
| 163 | + p('hidden'); |
|
| 164 | +} |
|
| 165 | +?>"> |
|
| 157 | 166 | <img id="verify-website" title="<?php p($_['websiteMessage']); ?>" data-status="<?php p($_['websiteVerification']) ?>" src=" |
| 158 | 167 | <?php |
| 159 | 168 | switch($_['websiteVerification']) { |
@@ -167,13 +176,16 @@ discard block |
||
| 167 | 176 | p(image_path('core', 'actions/verify.svg')); |
| 168 | 177 | } |
| 169 | 178 | ?>" |
| 170 | - <?php if($_['websiteVerification'] === \OC\Accounts\AccountManager::VERIFICATION_IN_PROGRESS || $_['websiteVerification'] === \OC\Accounts\AccountManager::NOT_VERIFIED) print_unescaped(' class="verify-action"') ?> |
|
| 179 | + <?php if($_['websiteVerification'] === \OC\Accounts\AccountManager::VERIFICATION_IN_PROGRESS || $_['websiteVerification'] === \OC\Accounts\AccountManager::NOT_VERIFIED) { |
|
| 180 | + print_unescaped(' class="verify-action"') ?> |
|
| 171 | 181 | > |
| 172 | 182 | <div class="verification-dialog popovermenu bubble menu"> |
| 173 | 183 | <div class="verification-dialog-content"> |
| 174 | 184 | <p class="explainVerification"></p> |
| 175 | 185 | <p class="verificationCode"></p> |
| 176 | - <p><?php p($l->t('It can take up to 24 hours before the account is displayed as verified.'));?></p> |
|
| 186 | + <p><?php p($l->t('It can take up to 24 hours before the account is displayed as verified.')); |
|
| 187 | +} |
|
| 188 | +?></p> |
|
| 177 | 189 | </div> |
| 178 | 190 | </div> |
| 179 | 191 | </div> |
@@ -190,7 +202,10 @@ discard block |
||
| 190 | 202 | <label for="twitter"><?php p($l->t('Twitter')); ?></label> |
| 191 | 203 | <span class="icon-password"/> |
| 192 | 204 | </h2> |
| 193 | - <div class="verify <?php if ($_['twitter'] === '' || $_['twitterScope'] !== 'public') p('hidden'); ?>"> |
|
| 205 | + <div class="verify <?php if ($_['twitter'] === '' || $_['twitterScope'] !== 'public') { |
|
| 206 | + p('hidden'); |
|
| 207 | +} |
|
| 208 | +?>"> |
|
| 194 | 209 | <img id="verify-twitter" title="<?php p($_['twitterMessage']); ?>" data-status="<?php p($_['twitterVerification']) ?>" src=" |
| 195 | 210 | <?php |
| 196 | 211 | switch($_['twitterVerification']) { |
@@ -204,13 +219,16 @@ discard block |
||
| 204 | 219 | p(image_path('core', 'actions/verify.svg')); |
| 205 | 220 | } |
| 206 | 221 | ?>" |
| 207 | - <?php if($_['twitterVerification'] === \OC\Accounts\AccountManager::VERIFICATION_IN_PROGRESS || $_['twitterVerification'] === \OC\Accounts\AccountManager::NOT_VERIFIED) print_unescaped(' class="verify-action"') ?> |
|
| 222 | + <?php if($_['twitterVerification'] === \OC\Accounts\AccountManager::VERIFICATION_IN_PROGRESS || $_['twitterVerification'] === \OC\Accounts\AccountManager::NOT_VERIFIED) { |
|
| 223 | + print_unescaped(' class="verify-action"') ?> |
|
| 208 | 224 | > |
| 209 | 225 | <div class="verification-dialog popovermenu bubble menu"> |
| 210 | 226 | <div class="verification-dialog-content"> |
| 211 | 227 | <p class="explainVerification"></p> |
| 212 | 228 | <p class="verificationCode"></p> |
| 213 | - <p><?php p($l->t('It can take up to 24 hours before the account is displayed as verified.'));?></p> |
|
| 229 | + <p><?php p($l->t('It can take up to 24 hours before the account is displayed as verified.')); |
|
| 230 | +} |
|
| 231 | +?></p> |
|
| 214 | 232 | </div> |
| 215 | 233 | </div> |
| 216 | 234 | </div> |
@@ -25,10 +25,10 @@ discard block |
||
| 25 | 25 | /** @var array $_ */ |
| 26 | 26 | |
| 27 | 27 | script('settings', [ |
| 28 | - 'usersettings', |
|
| 29 | - 'federationsettingsview', |
|
| 30 | - 'federationscopemenu', |
|
| 31 | - 'settings/personalInfo', |
|
| 28 | + 'usersettings', |
|
| 29 | + 'federationsettingsview', |
|
| 30 | + 'federationscopemenu', |
|
| 31 | + 'settings/personalInfo', |
|
| 32 | 32 | ]); |
| 33 | 33 | style('settings', 'settings'); |
| 34 | 34 | vendor_script('strengthify/jquery.strengthify'); |
@@ -105,17 +105,17 @@ discard block |
||
| 105 | 105 | <div class="verify <?php if ($_['email'] === '' || $_['emailScope'] !== 'public') p('hidden'); ?>"> |
| 106 | 106 | <img id="verify-email" title="<?php p($_['emailMessage']); ?>" data-status="<?php p($_['emailVerification']) ?>" src=" |
| 107 | 107 | <?php |
| 108 | - switch($_['emailVerification']) { |
|
| 109 | - case \OC\Accounts\AccountManager::VERIFICATION_IN_PROGRESS: |
|
| 110 | - p(image_path('core', 'actions/verifying.svg')); |
|
| 111 | - break; |
|
| 112 | - case \OC\Accounts\AccountManager::VERIFIED: |
|
| 113 | - p(image_path('core', 'actions/verified.svg')); |
|
| 114 | - break; |
|
| 115 | - default: |
|
| 116 | - p(image_path('core', 'actions/verify.svg')); |
|
| 117 | - } |
|
| 118 | - ?>"> |
|
| 108 | + switch($_['emailVerification']) { |
|
| 109 | + case \OC\Accounts\AccountManager::VERIFICATION_IN_PROGRESS: |
|
| 110 | + p(image_path('core', 'actions/verifying.svg')); |
|
| 111 | + break; |
|
| 112 | + case \OC\Accounts\AccountManager::VERIFIED: |
|
| 113 | + p(image_path('core', 'actions/verified.svg')); |
|
| 114 | + break; |
|
| 115 | + default: |
|
| 116 | + p(image_path('core', 'actions/verify.svg')); |
|
| 117 | + } |
|
| 118 | + ?>"> |
|
| 119 | 119 | </div> |
| 120 | 120 | <input type="email" name="email" id="email" value="<?php p($_['email']); ?>" |
| 121 | 121 | <?php if(!$_['displayNameChangeSupported']) { print_unescaped('class="hidden"'); } ?> |
@@ -172,17 +172,17 @@ discard block |
||
| 172 | 172 | <div class="verify <?php if ($_['website'] === '' || $_['websiteScope'] !== 'public') p('hidden'); ?>"> |
| 173 | 173 | <img id="verify-website" title="<?php p($_['websiteMessage']); ?>" data-status="<?php p($_['websiteVerification']) ?>" src=" |
| 174 | 174 | <?php |
| 175 | - switch($_['websiteVerification']) { |
|
| 176 | - case \OC\Accounts\AccountManager::VERIFICATION_IN_PROGRESS: |
|
| 177 | - p(image_path('core', 'actions/verifying.svg')); |
|
| 178 | - break; |
|
| 179 | - case \OC\Accounts\AccountManager::VERIFIED: |
|
| 180 | - p(image_path('core', 'actions/verified.svg')); |
|
| 181 | - break; |
|
| 182 | - default: |
|
| 183 | - p(image_path('core', 'actions/verify.svg')); |
|
| 184 | - } |
|
| 185 | - ?>" |
|
| 175 | + switch($_['websiteVerification']) { |
|
| 176 | + case \OC\Accounts\AccountManager::VERIFICATION_IN_PROGRESS: |
|
| 177 | + p(image_path('core', 'actions/verifying.svg')); |
|
| 178 | + break; |
|
| 179 | + case \OC\Accounts\AccountManager::VERIFIED: |
|
| 180 | + p(image_path('core', 'actions/verified.svg')); |
|
| 181 | + break; |
|
| 182 | + default: |
|
| 183 | + p(image_path('core', 'actions/verify.svg')); |
|
| 184 | + } |
|
| 185 | + ?>" |
|
| 186 | 186 | <?php if($_['websiteVerification'] === \OC\Accounts\AccountManager::VERIFICATION_IN_PROGRESS || $_['websiteVerification'] === \OC\Accounts\AccountManager::NOT_VERIFIED) print_unescaped(' class="verify-action"') ?> |
| 187 | 187 | > |
| 188 | 188 | <div class="verification-dialog popovermenu bubble menu"> |
@@ -209,17 +209,17 @@ discard block |
||
| 209 | 209 | <div class="verify <?php if ($_['twitter'] === '' || $_['twitterScope'] !== 'public') p('hidden'); ?>"> |
| 210 | 210 | <img id="verify-twitter" title="<?php p($_['twitterMessage']); ?>" data-status="<?php p($_['twitterVerification']) ?>" src=" |
| 211 | 211 | <?php |
| 212 | - switch($_['twitterVerification']) { |
|
| 213 | - case \OC\Accounts\AccountManager::VERIFICATION_IN_PROGRESS: |
|
| 214 | - p(image_path('core', 'actions/verifying.svg')); |
|
| 215 | - break; |
|
| 216 | - case \OC\Accounts\AccountManager::VERIFIED: |
|
| 217 | - p(image_path('core', 'actions/verified.svg')); |
|
| 218 | - break; |
|
| 219 | - default: |
|
| 220 | - p(image_path('core', 'actions/verify.svg')); |
|
| 221 | - } |
|
| 222 | - ?>" |
|
| 212 | + switch($_['twitterVerification']) { |
|
| 213 | + case \OC\Accounts\AccountManager::VERIFICATION_IN_PROGRESS: |
|
| 214 | + p(image_path('core', 'actions/verifying.svg')); |
|
| 215 | + break; |
|
| 216 | + case \OC\Accounts\AccountManager::VERIFIED: |
|
| 217 | + p(image_path('core', 'actions/verified.svg')); |
|
| 218 | + break; |
|
| 219 | + default: |
|
| 220 | + p(image_path('core', 'actions/verify.svg')); |
|
| 221 | + } |
|
| 222 | + ?>" |
|
| 223 | 223 | <?php if($_['twitterVerification'] === \OC\Accounts\AccountManager::VERIFICATION_IN_PROGRESS || $_['twitterVerification'] === \OC\Accounts\AccountManager::NOT_VERIFIED) print_unescaped(' class="verify-action"') ?> |
| 224 | 224 | > |
| 225 | 225 | <div class="verification-dialog popovermenu bubble menu"> |
@@ -252,8 +252,8 @@ discard block |
||
| 252 | 252 | |
| 253 | 253 | <?php |
| 254 | 254 | if($_['passwordChangeSupported']) { |
| 255 | - script('jquery-showpassword'); |
|
| 256 | - ?> |
|
| 255 | + script('jquery-showpassword'); |
|
| 256 | + ?> |
|
| 257 | 257 | <form id="passwordform" class="section"> |
| 258 | 258 | <h2 class="inlineblock"><?php p($l->t('Password'));?></h2> |
| 259 | 259 | <div id="password-error-msg" class="msg success inlineblock" style="display: none;">Saved</div> |
@@ -321,15 +321,15 @@ discard block |
||
| 321 | 321 | |
| 322 | 322 | <p> |
| 323 | 323 | <?php print_unescaped(str_replace( |
| 324 | - [ |
|
| 325 | - '{contributeopen}', |
|
| 326 | - '{linkclose}', |
|
| 327 | - ], |
|
| 328 | - [ |
|
| 329 | - '<a href="https://nextcloud.com/contribute" target="_blank" rel="noreferrer">', |
|
| 330 | - '</a>', |
|
| 331 | - ], |
|
| 332 | - $l->t('If you want to support the project {contributeopen}join development{linkclose} or {contributeopen}spread the word{linkclose}!'))); ?> |
|
| 324 | + [ |
|
| 325 | + '{contributeopen}', |
|
| 326 | + '{linkclose}', |
|
| 327 | + ], |
|
| 328 | + [ |
|
| 329 | + '<a href="https://nextcloud.com/contribute" target="_blank" rel="noreferrer">', |
|
| 330 | + '</a>', |
|
| 331 | + ], |
|
| 332 | + $l->t('If you want to support the project {contributeopen}join development{linkclose} or {contributeopen}spread the word{linkclose}!'))); ?> |
|
| 333 | 333 | </p> |
| 334 | 334 | |
| 335 | 335 | <?php if(OC_APP::isEnabled('firstrunwizard')) {?> |
@@ -32,13 +32,13 @@ discard block |
||
| 32 | 32 | <ul> |
| 33 | 33 | <li class="settings-caption">Personal</li> |
| 34 | 34 | <?php |
| 35 | - foreach($_['forms']['personal'] as $form) { |
|
| 36 | - if (isset($form['anchor'])) { |
|
| 37 | - $anchor = \OC::$server->getURLGenerator()->linkToRoute('settings.PersonalSettings.index', ['section' => $form['anchor']]); |
|
| 38 | - $class = 'nav-icon-' . $form['anchor']; |
|
| 39 | - $sectionName = $form['section-name']; |
|
| 40 | - $active = $form['active'] ? ' class="active"' : ''; |
|
| 41 | - ?> |
|
| 35 | + foreach($_['forms']['personal'] as $form) { |
|
| 36 | + if (isset($form['anchor'])) { |
|
| 37 | + $anchor = \OC::$server->getURLGenerator()->linkToRoute('settings.PersonalSettings.index', ['section' => $form['anchor']]); |
|
| 38 | + $class = 'nav-icon-' . $form['anchor']; |
|
| 39 | + $sectionName = $form['section-name']; |
|
| 40 | + $active = $form['active'] ? ' class="active"' : ''; |
|
| 41 | + ?> |
|
| 42 | 42 | <li <?php print_unescaped($form['active'] ? ' class="active"' : ''); ?>> |
| 43 | 43 | <a href="<?php p($anchor); ?>"> |
| 44 | 44 | <?php if (!empty($form['icon'])) { ?> |
@@ -50,24 +50,24 @@ discard block |
||
| 50 | 50 | </a> |
| 51 | 51 | </li> |
| 52 | 52 | <?php |
| 53 | - } |
|
| 54 | - } |
|
| 55 | - ?> |
|
| 53 | + } |
|
| 54 | + } |
|
| 55 | + ?> |
|
| 56 | 56 | |
| 57 | 57 | <?php |
| 58 | - if(!empty($_['forms']['admin'])) { |
|
| 59 | - ?> |
|
| 58 | + if(!empty($_['forms']['admin'])) { |
|
| 59 | + ?> |
|
| 60 | 60 | <li class="settings-caption">Administration</li> |
| 61 | 61 | <?php |
| 62 | - } |
|
| 63 | - foreach($_['forms']['admin'] as $form) { |
|
| 64 | - if (isset($form['anchor'])) { |
|
| 62 | + } |
|
| 63 | + foreach($_['forms']['admin'] as $form) { |
|
| 64 | + if (isset($form['anchor'])) { |
|
| 65 | 65 | |
| 66 | - $anchor = \OC::$server->getURLGenerator()->linkToRoute('settings.AdminSettings.index', ['section' => $form['anchor']]); |
|
| 67 | - $class = 'nav-icon-' . $form['anchor']; |
|
| 68 | - $sectionName = $form['section-name']; |
|
| 69 | - $active = $form['active'] ? ' class="active"' : ''; |
|
| 70 | - ?> |
|
| 66 | + $anchor = \OC::$server->getURLGenerator()->linkToRoute('settings.AdminSettings.index', ['section' => $form['anchor']]); |
|
| 67 | + $class = 'nav-icon-' . $form['anchor']; |
|
| 68 | + $sectionName = $form['section-name']; |
|
| 69 | + $active = $form['active'] ? ' class="active"' : ''; |
|
| 70 | + ?> |
|
| 71 | 71 | <li <?php print_unescaped($form['active'] ? ' class="active"' : ''); ?>> |
| 72 | 72 | <a href="<?php p($anchor); ?>"> |
| 73 | 73 | <?php if (!empty($form['icon'])) { ?> |
@@ -79,9 +79,9 @@ discard block |
||
| 79 | 79 | </a> |
| 80 | 80 | </li> |
| 81 | 81 | <?php |
| 82 | - } |
|
| 83 | - } |
|
| 84 | - ?> |
|
| 82 | + } |
|
| 83 | + } |
|
| 84 | + ?> |
|
| 85 | 85 | </ul> |
| 86 | 86 | </div> |
| 87 | 87 | |
@@ -22,7 +22,7 @@ discard block |
||
| 22 | 22 | */ |
| 23 | 23 | |
| 24 | 24 | style('settings', 'settings'); |
| 25 | -script('settings', [ 'settings', 'admin', 'log', 'certificates'] ); |
|
| 25 | +script('settings', ['settings', 'admin', 'log', 'certificates']); |
|
| 26 | 26 | script('core', ['multiselect', 'setupchecks']); |
| 27 | 27 | script('files', 'jquery.fileupload'); |
| 28 | 28 | |
@@ -32,10 +32,10 @@ discard block |
||
| 32 | 32 | <ul> |
| 33 | 33 | <li class="settings-caption">Personal</li> |
| 34 | 34 | <?php |
| 35 | - foreach($_['forms']['personal'] as $form) { |
|
| 35 | + foreach ($_['forms']['personal'] as $form) { |
|
| 36 | 36 | if (isset($form['anchor'])) { |
| 37 | 37 | $anchor = \OC::$server->getURLGenerator()->linkToRoute('settings.PersonalSettings.index', ['section' => $form['anchor']]); |
| 38 | - $class = 'nav-icon-' . $form['anchor']; |
|
| 38 | + $class = 'nav-icon-'.$form['anchor']; |
|
| 39 | 39 | $sectionName = $form['section-name']; |
| 40 | 40 | $active = $form['active'] ? ' class="active"' : ''; |
| 41 | 41 | ?> |
@@ -55,16 +55,16 @@ discard block |
||
| 55 | 55 | ?> |
| 56 | 56 | |
| 57 | 57 | <?php |
| 58 | - if(!empty($_['forms']['admin'])) { |
|
| 58 | + if (!empty($_['forms']['admin'])) { |
|
| 59 | 59 | ?> |
| 60 | 60 | <li class="settings-caption">Administration</li> |
| 61 | 61 | <?php |
| 62 | 62 | } |
| 63 | - foreach($_['forms']['admin'] as $form) { |
|
| 63 | + foreach ($_['forms']['admin'] as $form) { |
|
| 64 | 64 | if (isset($form['anchor'])) { |
| 65 | 65 | |
| 66 | 66 | $anchor = \OC::$server->getURLGenerator()->linkToRoute('settings.AdminSettings.index', ['section' => $form['anchor']]); |
| 67 | - $class = 'nav-icon-' . $form['anchor']; |
|
| 67 | + $class = 'nav-icon-'.$form['anchor']; |
|
| 68 | 68 | $sectionName = $form['section-name']; |
| 69 | 69 | $active = $form['active'] ? ' class="active"' : ''; |
| 70 | 70 | ?> |
@@ -41,379 +41,379 @@ |
||
| 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 | - /** @var \OC_Defaults */ |
|
| 74 | - private $defaults; |
|
| 75 | - |
|
| 76 | - /** |
|
| 77 | - * @param ILogger $log |
|
| 78 | - * @param IDBConnection $dbc |
|
| 79 | - * @param IL10N $l |
|
| 80 | - * @param IConfig $config |
|
| 81 | - * @param EncryptionManager $encryptionManager |
|
| 82 | - * @param IUserManager $userManager |
|
| 83 | - * @param ILockingProvider $lockingProvider |
|
| 84 | - * @param IRequest $request |
|
| 85 | - * @param Mapper $mapper |
|
| 86 | - * @param IURLGenerator $url |
|
| 87 | - * @param AccountManager $accountManager |
|
| 88 | - * @param IGroupManager $groupManager |
|
| 89 | - * @param IFactory $l10nFactory |
|
| 90 | - */ |
|
| 91 | - public function __construct( |
|
| 92 | - ILogger $log, |
|
| 93 | - IDBConnection $dbc, |
|
| 94 | - IL10N $l, |
|
| 95 | - IConfig $config, |
|
| 96 | - EncryptionManager $encryptionManager, |
|
| 97 | - IUserManager $userManager, |
|
| 98 | - ILockingProvider $lockingProvider, |
|
| 99 | - IRequest $request, |
|
| 100 | - Mapper $mapper, |
|
| 101 | - IURLGenerator $url, |
|
| 102 | - AccountManager $accountManager, |
|
| 103 | - IGroupManager $groupManager, |
|
| 104 | - IFactory $l10nFactory, |
|
| 105 | - \OC_Defaults $defaults |
|
| 106 | - ) { |
|
| 107 | - $this->log = $log; |
|
| 108 | - $this->dbc = $dbc; |
|
| 109 | - $this->mapper = $mapper; |
|
| 110 | - $this->l = $l; |
|
| 111 | - $this->config = $config; |
|
| 112 | - $this->encryptionManager = $encryptionManager; |
|
| 113 | - $this->userManager = $userManager; |
|
| 114 | - $this->lockingProvider = $lockingProvider; |
|
| 115 | - $this->request = $request; |
|
| 116 | - $this->url = $url; |
|
| 117 | - $this->accountManager = $accountManager; |
|
| 118 | - $this->groupManager = $groupManager; |
|
| 119 | - $this->l10nFactory = $l10nFactory; |
|
| 120 | - $this->defaults = $defaults; |
|
| 121 | - } |
|
| 122 | - |
|
| 123 | - /** |
|
| 124 | - * @inheritdoc |
|
| 125 | - */ |
|
| 126 | - public function setupSettings(array $settings) { |
|
| 127 | - if (isset($settings[IManager::KEY_ADMIN_SECTION])) { |
|
| 128 | - $this->setupAdminSection($settings[IManager::KEY_ADMIN_SECTION]); |
|
| 129 | - } |
|
| 130 | - if (isset($settings[IManager::KEY_ADMIN_SETTINGS])) { |
|
| 131 | - $this->setupAdminSettings($settings[IManager::KEY_ADMIN_SETTINGS]); |
|
| 132 | - } |
|
| 133 | - } |
|
| 134 | - |
|
| 135 | - /** |
|
| 136 | - * attempts to remove an apps section and/or settings entry. A listener is |
|
| 137 | - * added centrally making sure that this method is called ones an app was |
|
| 138 | - * disabled. |
|
| 139 | - * |
|
| 140 | - * @param string $appId |
|
| 141 | - * @since 9.1.0 |
|
| 142 | - */ |
|
| 143 | - public function onAppDisabled($appId) { |
|
| 144 | - $appInfo = \OC_App::getAppInfo($appId); // hello static legacy |
|
| 145 | - |
|
| 146 | - if (isset($appInfo['settings'][IManager::KEY_ADMIN_SECTION])) { |
|
| 147 | - $this->mapper->remove(self::TABLE_ADMIN_SECTIONS, trim($appInfo['settings'][IManager::KEY_ADMIN_SECTION], '\\')); |
|
| 148 | - } |
|
| 149 | - if (isset($appInfo['settings'][IManager::KEY_ADMIN_SETTINGS])) { |
|
| 150 | - $this->mapper->remove(self::TABLE_ADMIN_SETTINGS, trim($appInfo['settings'][IManager::KEY_ADMIN_SETTINGS], '\\')); |
|
| 151 | - } |
|
| 152 | - } |
|
| 153 | - |
|
| 154 | - public function checkForOrphanedClassNames() { |
|
| 155 | - $tables = [self::TABLE_ADMIN_SECTIONS, self::TABLE_ADMIN_SETTINGS]; |
|
| 156 | - foreach ($tables as $table) { |
|
| 157 | - $classes = $this->mapper->getClasses($table); |
|
| 158 | - foreach ($classes as $className) { |
|
| 159 | - try { |
|
| 160 | - \OC::$server->query($className); |
|
| 161 | - } catch (QueryException $e) { |
|
| 162 | - $this->mapper->remove($table, $className); |
|
| 163 | - } |
|
| 164 | - } |
|
| 165 | - } |
|
| 166 | - } |
|
| 167 | - |
|
| 168 | - /** |
|
| 169 | - * @param string $sectionClassName |
|
| 170 | - */ |
|
| 171 | - private function setupAdminSection($sectionClassName) { |
|
| 172 | - if (!class_exists($sectionClassName)) { |
|
| 173 | - $this->log->debug('Could not find admin section class ' . $sectionClassName); |
|
| 174 | - return; |
|
| 175 | - } |
|
| 176 | - try { |
|
| 177 | - $section = $this->query($sectionClassName); |
|
| 178 | - } catch (QueryException $e) { |
|
| 179 | - // cancel |
|
| 180 | - return; |
|
| 181 | - } |
|
| 182 | - |
|
| 183 | - if (!$section instanceof ISection) { |
|
| 184 | - $this->log->error( |
|
| 185 | - 'Admin section instance must implement \OCP\ISection. Invalid class: {class}', |
|
| 186 | - ['class' => $sectionClassName] |
|
| 187 | - ); |
|
| 188 | - return; |
|
| 189 | - } |
|
| 190 | - if (!$this->hasAdminSection(get_class($section))) { |
|
| 191 | - $this->addAdminSection($section); |
|
| 192 | - } else { |
|
| 193 | - $this->updateAdminSection($section); |
|
| 194 | - } |
|
| 195 | - } |
|
| 196 | - |
|
| 197 | - private function addAdminSection(ISection $section) { |
|
| 198 | - $this->mapper->add(self::TABLE_ADMIN_SECTIONS, [ |
|
| 199 | - 'id' => $section->getID(), |
|
| 200 | - 'class' => get_class($section), |
|
| 201 | - 'priority' => $section->getPriority(), |
|
| 202 | - ]); |
|
| 203 | - } |
|
| 204 | - |
|
| 205 | - private function addAdminSettings(ISettings $settings) { |
|
| 206 | - $this->mapper->add(self::TABLE_ADMIN_SETTINGS, [ |
|
| 207 | - 'class' => get_class($settings), |
|
| 208 | - 'section' => $settings->getSection(), |
|
| 209 | - 'priority' => $settings->getPriority(), |
|
| 210 | - ]); |
|
| 211 | - } |
|
| 212 | - |
|
| 213 | - private function updateAdminSettings(ISettings $settings) { |
|
| 214 | - $this->mapper->update( |
|
| 215 | - self::TABLE_ADMIN_SETTINGS, |
|
| 216 | - 'class', |
|
| 217 | - get_class($settings), |
|
| 218 | - [ |
|
| 219 | - 'section' => $settings->getSection(), |
|
| 220 | - 'priority' => $settings->getPriority(), |
|
| 221 | - ] |
|
| 222 | - ); |
|
| 223 | - } |
|
| 224 | - |
|
| 225 | - private function updateAdminSection(ISection $section) { |
|
| 226 | - $this->mapper->update( |
|
| 227 | - self::TABLE_ADMIN_SECTIONS, |
|
| 228 | - 'class', |
|
| 229 | - get_class($section), |
|
| 230 | - [ |
|
| 231 | - 'id' => $section->getID(), |
|
| 232 | - 'priority' => $section->getPriority(), |
|
| 233 | - ] |
|
| 234 | - ); |
|
| 235 | - } |
|
| 236 | - |
|
| 237 | - /** |
|
| 238 | - * @param string $className |
|
| 239 | - * @return bool |
|
| 240 | - */ |
|
| 241 | - private function hasAdminSection($className) { |
|
| 242 | - return $this->mapper->has(self::TABLE_ADMIN_SECTIONS, $className); |
|
| 243 | - } |
|
| 244 | - |
|
| 245 | - /** |
|
| 246 | - * @param string $className |
|
| 247 | - * @return bool |
|
| 248 | - */ |
|
| 249 | - private function hasAdminSettings($className) { |
|
| 250 | - return $this->mapper->has(self::TABLE_ADMIN_SETTINGS, $className); |
|
| 251 | - } |
|
| 252 | - |
|
| 253 | - private function setupAdminSettings($settingsClassName) { |
|
| 254 | - if (!class_exists($settingsClassName)) { |
|
| 255 | - $this->log->debug('Could not find admin section class ' . $settingsClassName); |
|
| 256 | - return; |
|
| 257 | - } |
|
| 258 | - |
|
| 259 | - try { |
|
| 260 | - /** @var ISettings $settings */ |
|
| 261 | - $settings = $this->query($settingsClassName); |
|
| 262 | - } catch (QueryException $e) { |
|
| 263 | - // cancel |
|
| 264 | - return; |
|
| 265 | - } |
|
| 266 | - |
|
| 267 | - if (!$settings instanceof ISettings) { |
|
| 268 | - $this->log->error( |
|
| 269 | - 'Admin section instance must implement \OCP\Settings\ISection. Invalid class: {class}', |
|
| 270 | - ['class' => $settingsClassName] |
|
| 271 | - ); |
|
| 272 | - return; |
|
| 273 | - } |
|
| 274 | - if (!$this->hasAdminSettings(get_class($settings))) { |
|
| 275 | - $this->addAdminSettings($settings); |
|
| 276 | - } else { |
|
| 277 | - $this->updateAdminSettings($settings); |
|
| 278 | - } |
|
| 279 | - } |
|
| 280 | - |
|
| 281 | - private function query($className) { |
|
| 282 | - try { |
|
| 283 | - return \OC::$server->query($className); |
|
| 284 | - } catch (QueryException $e) { |
|
| 285 | - $this->log->logException($e); |
|
| 286 | - throw $e; |
|
| 287 | - } |
|
| 288 | - } |
|
| 289 | - |
|
| 290 | - /** |
|
| 291 | - * @inheritdoc |
|
| 292 | - */ |
|
| 293 | - public function getAdminSections() { |
|
| 294 | - // built-in sections |
|
| 295 | - $sections = [ |
|
| 296 | - 0 => [new Section('server', $this->l->t('Basic settings'), 0, $this->url->imagePath('settings', 'admin.svg'))], |
|
| 297 | - 5 => [new Section('sharing', $this->l->t('Sharing'), 0, $this->url->imagePath('core', 'actions/share.svg'))], |
|
| 298 | - 10 => [new Section('security', $this->l->t('Security'), 0, $this->url->imagePath('core', 'actions/password.svg'))], |
|
| 299 | - 45 => [new Section('encryption', $this->l->t('Encryption'), 0, $this->url->imagePath('core', 'actions/password.svg'))], |
|
| 300 | - 98 => [new Section('additional', $this->l->t('Additional settings'), 0, $this->url->imagePath('core', 'actions/settings-dark.svg'))], |
|
| 301 | - 99 => [new Section('tips-tricks', $this->l->t('Tips & tricks'), 0, $this->url->imagePath('settings', 'help.svg'))], |
|
| 302 | - ]; |
|
| 303 | - |
|
| 304 | - $rows = $this->mapper->getAdminSectionsFromDB(); |
|
| 305 | - |
|
| 306 | - foreach ($rows as $row) { |
|
| 307 | - if (!isset($sections[$row['priority']])) { |
|
| 308 | - $sections[$row['priority']] = []; |
|
| 309 | - } |
|
| 310 | - try { |
|
| 311 | - $sections[$row['priority']][] = $this->query($row['class']); |
|
| 312 | - } catch (QueryException $e) { |
|
| 313 | - // skip |
|
| 314 | - } |
|
| 315 | - } |
|
| 316 | - |
|
| 317 | - ksort($sections); |
|
| 318 | - |
|
| 319 | - return $sections; |
|
| 320 | - } |
|
| 321 | - |
|
| 322 | - /** |
|
| 323 | - * @param string $section |
|
| 324 | - * @return ISection[] |
|
| 325 | - */ |
|
| 326 | - private function getBuiltInAdminSettings($section) { |
|
| 327 | - $forms = []; |
|
| 328 | - try { |
|
| 329 | - if ($section === 'server') { |
|
| 330 | - /** @var ISettings $form */ |
|
| 331 | - $form = new Admin\Server($this->dbc, $this->request, $this->config, $this->lockingProvider, $this->l); |
|
| 332 | - $forms[$form->getPriority()] = [$form]; |
|
| 333 | - $form = new Admin\ServerDevNotice(); |
|
| 334 | - $forms[$form->getPriority()] = [$form]; |
|
| 335 | - } |
|
| 336 | - if ($section === 'encryption') { |
|
| 337 | - /** @var ISettings $form */ |
|
| 338 | - $form = new Admin\Encryption($this->encryptionManager, $this->userManager); |
|
| 339 | - $forms[$form->getPriority()] = [$form]; |
|
| 340 | - } |
|
| 341 | - if ($section === 'sharing') { |
|
| 342 | - /** @var ISettings $form */ |
|
| 343 | - $form = new Admin\Sharing($this->config); |
|
| 344 | - $forms[$form->getPriority()] = [$form]; |
|
| 345 | - } |
|
| 346 | - if ($section === 'additional') { |
|
| 347 | - /** @var ISettings $form */ |
|
| 348 | - $form = new Admin\Additional($this->config); |
|
| 349 | - $forms[$form->getPriority()] = [$form]; |
|
| 350 | - } |
|
| 351 | - if ($section === 'tips-tricks') { |
|
| 352 | - /** @var ISettings $form */ |
|
| 353 | - $form = new Admin\TipsTricks($this->config); |
|
| 354 | - $forms[$form->getPriority()] = [$form]; |
|
| 355 | - } |
|
| 356 | - } catch (QueryException $e) { |
|
| 357 | - // skip |
|
| 358 | - } |
|
| 359 | - return $forms; |
|
| 360 | - } |
|
| 361 | - |
|
| 362 | - /** |
|
| 363 | - * @param string $section |
|
| 364 | - * @return ISection[] |
|
| 365 | - */ |
|
| 366 | - private function getBuiltInPersonalSettings($section) { |
|
| 367 | - $forms = []; |
|
| 368 | - try { |
|
| 369 | - if ($section === 'personal-info') { |
|
| 370 | - /** @var ISettings $form */ |
|
| 371 | - $form = new Personal\PersonalInfo($this->config, $this->userManager, $this->groupManager, $this->accountManager, $this->l10nFactory, $this->defaults); |
|
| 372 | - $forms[$form->getPriority()] = [$form]; |
|
| 373 | - } |
|
| 374 | - } catch (QueryException $e) { |
|
| 375 | - // skip |
|
| 376 | - } |
|
| 377 | - return $forms; |
|
| 378 | - } |
|
| 379 | - |
|
| 380 | - /** |
|
| 381 | - * @inheritdoc |
|
| 382 | - */ |
|
| 383 | - public function getAdminSettings($section) { |
|
| 384 | - $settings = $this->getBuiltInAdminSettings($section); |
|
| 385 | - $dbRows = $this->mapper->getAdminSettingsFromDB($section); |
|
| 386 | - |
|
| 387 | - foreach ($dbRows as $row) { |
|
| 388 | - if (!isset($settings[$row['priority']])) { |
|
| 389 | - $settings[$row['priority']] = []; |
|
| 390 | - } |
|
| 391 | - try { |
|
| 392 | - $settings[$row['priority']][] = $this->query($row['class']); |
|
| 393 | - } catch (QueryException $e) { |
|
| 394 | - // skip |
|
| 395 | - } |
|
| 396 | - } |
|
| 397 | - |
|
| 398 | - ksort($settings); |
|
| 399 | - return $settings; |
|
| 400 | - } |
|
| 401 | - |
|
| 402 | - /** |
|
| 403 | - * @inheritdoc |
|
| 404 | - */ |
|
| 405 | - public function getPersonalSections() { |
|
| 406 | - $sections = [ |
|
| 407 | - 0 => [new Section('personal-info', $this->l->t('Personal info'), 0, $this->url->imagePath('core', 'actions/info.svg'))], |
|
| 408 | - ]; |
|
| 409 | - return $sections; |
|
| 410 | - } |
|
| 411 | - |
|
| 412 | - /** |
|
| 413 | - * @inheritdoc |
|
| 414 | - */ |
|
| 415 | - public function getPersonalSettings($section) { |
|
| 416 | - $settings = $this->getBuiltInPersonalSettings($section); |
|
| 417 | - return $settings; |
|
| 418 | - } |
|
| 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 | + /** @var \OC_Defaults */ |
|
| 74 | + private $defaults; |
|
| 75 | + |
|
| 76 | + /** |
|
| 77 | + * @param ILogger $log |
|
| 78 | + * @param IDBConnection $dbc |
|
| 79 | + * @param IL10N $l |
|
| 80 | + * @param IConfig $config |
|
| 81 | + * @param EncryptionManager $encryptionManager |
|
| 82 | + * @param IUserManager $userManager |
|
| 83 | + * @param ILockingProvider $lockingProvider |
|
| 84 | + * @param IRequest $request |
|
| 85 | + * @param Mapper $mapper |
|
| 86 | + * @param IURLGenerator $url |
|
| 87 | + * @param AccountManager $accountManager |
|
| 88 | + * @param IGroupManager $groupManager |
|
| 89 | + * @param IFactory $l10nFactory |
|
| 90 | + */ |
|
| 91 | + public function __construct( |
|
| 92 | + ILogger $log, |
|
| 93 | + IDBConnection $dbc, |
|
| 94 | + IL10N $l, |
|
| 95 | + IConfig $config, |
|
| 96 | + EncryptionManager $encryptionManager, |
|
| 97 | + IUserManager $userManager, |
|
| 98 | + ILockingProvider $lockingProvider, |
|
| 99 | + IRequest $request, |
|
| 100 | + Mapper $mapper, |
|
| 101 | + IURLGenerator $url, |
|
| 102 | + AccountManager $accountManager, |
|
| 103 | + IGroupManager $groupManager, |
|
| 104 | + IFactory $l10nFactory, |
|
| 105 | + \OC_Defaults $defaults |
|
| 106 | + ) { |
|
| 107 | + $this->log = $log; |
|
| 108 | + $this->dbc = $dbc; |
|
| 109 | + $this->mapper = $mapper; |
|
| 110 | + $this->l = $l; |
|
| 111 | + $this->config = $config; |
|
| 112 | + $this->encryptionManager = $encryptionManager; |
|
| 113 | + $this->userManager = $userManager; |
|
| 114 | + $this->lockingProvider = $lockingProvider; |
|
| 115 | + $this->request = $request; |
|
| 116 | + $this->url = $url; |
|
| 117 | + $this->accountManager = $accountManager; |
|
| 118 | + $this->groupManager = $groupManager; |
|
| 119 | + $this->l10nFactory = $l10nFactory; |
|
| 120 | + $this->defaults = $defaults; |
|
| 121 | + } |
|
| 122 | + |
|
| 123 | + /** |
|
| 124 | + * @inheritdoc |
|
| 125 | + */ |
|
| 126 | + public function setupSettings(array $settings) { |
|
| 127 | + if (isset($settings[IManager::KEY_ADMIN_SECTION])) { |
|
| 128 | + $this->setupAdminSection($settings[IManager::KEY_ADMIN_SECTION]); |
|
| 129 | + } |
|
| 130 | + if (isset($settings[IManager::KEY_ADMIN_SETTINGS])) { |
|
| 131 | + $this->setupAdminSettings($settings[IManager::KEY_ADMIN_SETTINGS]); |
|
| 132 | + } |
|
| 133 | + } |
|
| 134 | + |
|
| 135 | + /** |
|
| 136 | + * attempts to remove an apps section and/or settings entry. A listener is |
|
| 137 | + * added centrally making sure that this method is called ones an app was |
|
| 138 | + * disabled. |
|
| 139 | + * |
|
| 140 | + * @param string $appId |
|
| 141 | + * @since 9.1.0 |
|
| 142 | + */ |
|
| 143 | + public function onAppDisabled($appId) { |
|
| 144 | + $appInfo = \OC_App::getAppInfo($appId); // hello static legacy |
|
| 145 | + |
|
| 146 | + if (isset($appInfo['settings'][IManager::KEY_ADMIN_SECTION])) { |
|
| 147 | + $this->mapper->remove(self::TABLE_ADMIN_SECTIONS, trim($appInfo['settings'][IManager::KEY_ADMIN_SECTION], '\\')); |
|
| 148 | + } |
|
| 149 | + if (isset($appInfo['settings'][IManager::KEY_ADMIN_SETTINGS])) { |
|
| 150 | + $this->mapper->remove(self::TABLE_ADMIN_SETTINGS, trim($appInfo['settings'][IManager::KEY_ADMIN_SETTINGS], '\\')); |
|
| 151 | + } |
|
| 152 | + } |
|
| 153 | + |
|
| 154 | + public function checkForOrphanedClassNames() { |
|
| 155 | + $tables = [self::TABLE_ADMIN_SECTIONS, self::TABLE_ADMIN_SETTINGS]; |
|
| 156 | + foreach ($tables as $table) { |
|
| 157 | + $classes = $this->mapper->getClasses($table); |
|
| 158 | + foreach ($classes as $className) { |
|
| 159 | + try { |
|
| 160 | + \OC::$server->query($className); |
|
| 161 | + } catch (QueryException $e) { |
|
| 162 | + $this->mapper->remove($table, $className); |
|
| 163 | + } |
|
| 164 | + } |
|
| 165 | + } |
|
| 166 | + } |
|
| 167 | + |
|
| 168 | + /** |
|
| 169 | + * @param string $sectionClassName |
|
| 170 | + */ |
|
| 171 | + private function setupAdminSection($sectionClassName) { |
|
| 172 | + if (!class_exists($sectionClassName)) { |
|
| 173 | + $this->log->debug('Could not find admin section class ' . $sectionClassName); |
|
| 174 | + return; |
|
| 175 | + } |
|
| 176 | + try { |
|
| 177 | + $section = $this->query($sectionClassName); |
|
| 178 | + } catch (QueryException $e) { |
|
| 179 | + // cancel |
|
| 180 | + return; |
|
| 181 | + } |
|
| 182 | + |
|
| 183 | + if (!$section instanceof ISection) { |
|
| 184 | + $this->log->error( |
|
| 185 | + 'Admin section instance must implement \OCP\ISection. Invalid class: {class}', |
|
| 186 | + ['class' => $sectionClassName] |
|
| 187 | + ); |
|
| 188 | + return; |
|
| 189 | + } |
|
| 190 | + if (!$this->hasAdminSection(get_class($section))) { |
|
| 191 | + $this->addAdminSection($section); |
|
| 192 | + } else { |
|
| 193 | + $this->updateAdminSection($section); |
|
| 194 | + } |
|
| 195 | + } |
|
| 196 | + |
|
| 197 | + private function addAdminSection(ISection $section) { |
|
| 198 | + $this->mapper->add(self::TABLE_ADMIN_SECTIONS, [ |
|
| 199 | + 'id' => $section->getID(), |
|
| 200 | + 'class' => get_class($section), |
|
| 201 | + 'priority' => $section->getPriority(), |
|
| 202 | + ]); |
|
| 203 | + } |
|
| 204 | + |
|
| 205 | + private function addAdminSettings(ISettings $settings) { |
|
| 206 | + $this->mapper->add(self::TABLE_ADMIN_SETTINGS, [ |
|
| 207 | + 'class' => get_class($settings), |
|
| 208 | + 'section' => $settings->getSection(), |
|
| 209 | + 'priority' => $settings->getPriority(), |
|
| 210 | + ]); |
|
| 211 | + } |
|
| 212 | + |
|
| 213 | + private function updateAdminSettings(ISettings $settings) { |
|
| 214 | + $this->mapper->update( |
|
| 215 | + self::TABLE_ADMIN_SETTINGS, |
|
| 216 | + 'class', |
|
| 217 | + get_class($settings), |
|
| 218 | + [ |
|
| 219 | + 'section' => $settings->getSection(), |
|
| 220 | + 'priority' => $settings->getPriority(), |
|
| 221 | + ] |
|
| 222 | + ); |
|
| 223 | + } |
|
| 224 | + |
|
| 225 | + private function updateAdminSection(ISection $section) { |
|
| 226 | + $this->mapper->update( |
|
| 227 | + self::TABLE_ADMIN_SECTIONS, |
|
| 228 | + 'class', |
|
| 229 | + get_class($section), |
|
| 230 | + [ |
|
| 231 | + 'id' => $section->getID(), |
|
| 232 | + 'priority' => $section->getPriority(), |
|
| 233 | + ] |
|
| 234 | + ); |
|
| 235 | + } |
|
| 236 | + |
|
| 237 | + /** |
|
| 238 | + * @param string $className |
|
| 239 | + * @return bool |
|
| 240 | + */ |
|
| 241 | + private function hasAdminSection($className) { |
|
| 242 | + return $this->mapper->has(self::TABLE_ADMIN_SECTIONS, $className); |
|
| 243 | + } |
|
| 244 | + |
|
| 245 | + /** |
|
| 246 | + * @param string $className |
|
| 247 | + * @return bool |
|
| 248 | + */ |
|
| 249 | + private function hasAdminSettings($className) { |
|
| 250 | + return $this->mapper->has(self::TABLE_ADMIN_SETTINGS, $className); |
|
| 251 | + } |
|
| 252 | + |
|
| 253 | + private function setupAdminSettings($settingsClassName) { |
|
| 254 | + if (!class_exists($settingsClassName)) { |
|
| 255 | + $this->log->debug('Could not find admin section class ' . $settingsClassName); |
|
| 256 | + return; |
|
| 257 | + } |
|
| 258 | + |
|
| 259 | + try { |
|
| 260 | + /** @var ISettings $settings */ |
|
| 261 | + $settings = $this->query($settingsClassName); |
|
| 262 | + } catch (QueryException $e) { |
|
| 263 | + // cancel |
|
| 264 | + return; |
|
| 265 | + } |
|
| 266 | + |
|
| 267 | + if (!$settings instanceof ISettings) { |
|
| 268 | + $this->log->error( |
|
| 269 | + 'Admin section instance must implement \OCP\Settings\ISection. Invalid class: {class}', |
|
| 270 | + ['class' => $settingsClassName] |
|
| 271 | + ); |
|
| 272 | + return; |
|
| 273 | + } |
|
| 274 | + if (!$this->hasAdminSettings(get_class($settings))) { |
|
| 275 | + $this->addAdminSettings($settings); |
|
| 276 | + } else { |
|
| 277 | + $this->updateAdminSettings($settings); |
|
| 278 | + } |
|
| 279 | + } |
|
| 280 | + |
|
| 281 | + private function query($className) { |
|
| 282 | + try { |
|
| 283 | + return \OC::$server->query($className); |
|
| 284 | + } catch (QueryException $e) { |
|
| 285 | + $this->log->logException($e); |
|
| 286 | + throw $e; |
|
| 287 | + } |
|
| 288 | + } |
|
| 289 | + |
|
| 290 | + /** |
|
| 291 | + * @inheritdoc |
|
| 292 | + */ |
|
| 293 | + public function getAdminSections() { |
|
| 294 | + // built-in sections |
|
| 295 | + $sections = [ |
|
| 296 | + 0 => [new Section('server', $this->l->t('Basic settings'), 0, $this->url->imagePath('settings', 'admin.svg'))], |
|
| 297 | + 5 => [new Section('sharing', $this->l->t('Sharing'), 0, $this->url->imagePath('core', 'actions/share.svg'))], |
|
| 298 | + 10 => [new Section('security', $this->l->t('Security'), 0, $this->url->imagePath('core', 'actions/password.svg'))], |
|
| 299 | + 45 => [new Section('encryption', $this->l->t('Encryption'), 0, $this->url->imagePath('core', 'actions/password.svg'))], |
|
| 300 | + 98 => [new Section('additional', $this->l->t('Additional settings'), 0, $this->url->imagePath('core', 'actions/settings-dark.svg'))], |
|
| 301 | + 99 => [new Section('tips-tricks', $this->l->t('Tips & tricks'), 0, $this->url->imagePath('settings', 'help.svg'))], |
|
| 302 | + ]; |
|
| 303 | + |
|
| 304 | + $rows = $this->mapper->getAdminSectionsFromDB(); |
|
| 305 | + |
|
| 306 | + foreach ($rows as $row) { |
|
| 307 | + if (!isset($sections[$row['priority']])) { |
|
| 308 | + $sections[$row['priority']] = []; |
|
| 309 | + } |
|
| 310 | + try { |
|
| 311 | + $sections[$row['priority']][] = $this->query($row['class']); |
|
| 312 | + } catch (QueryException $e) { |
|
| 313 | + // skip |
|
| 314 | + } |
|
| 315 | + } |
|
| 316 | + |
|
| 317 | + ksort($sections); |
|
| 318 | + |
|
| 319 | + return $sections; |
|
| 320 | + } |
|
| 321 | + |
|
| 322 | + /** |
|
| 323 | + * @param string $section |
|
| 324 | + * @return ISection[] |
|
| 325 | + */ |
|
| 326 | + private function getBuiltInAdminSettings($section) { |
|
| 327 | + $forms = []; |
|
| 328 | + try { |
|
| 329 | + if ($section === 'server') { |
|
| 330 | + /** @var ISettings $form */ |
|
| 331 | + $form = new Admin\Server($this->dbc, $this->request, $this->config, $this->lockingProvider, $this->l); |
|
| 332 | + $forms[$form->getPriority()] = [$form]; |
|
| 333 | + $form = new Admin\ServerDevNotice(); |
|
| 334 | + $forms[$form->getPriority()] = [$form]; |
|
| 335 | + } |
|
| 336 | + if ($section === 'encryption') { |
|
| 337 | + /** @var ISettings $form */ |
|
| 338 | + $form = new Admin\Encryption($this->encryptionManager, $this->userManager); |
|
| 339 | + $forms[$form->getPriority()] = [$form]; |
|
| 340 | + } |
|
| 341 | + if ($section === 'sharing') { |
|
| 342 | + /** @var ISettings $form */ |
|
| 343 | + $form = new Admin\Sharing($this->config); |
|
| 344 | + $forms[$form->getPriority()] = [$form]; |
|
| 345 | + } |
|
| 346 | + if ($section === 'additional') { |
|
| 347 | + /** @var ISettings $form */ |
|
| 348 | + $form = new Admin\Additional($this->config); |
|
| 349 | + $forms[$form->getPriority()] = [$form]; |
|
| 350 | + } |
|
| 351 | + if ($section === 'tips-tricks') { |
|
| 352 | + /** @var ISettings $form */ |
|
| 353 | + $form = new Admin\TipsTricks($this->config); |
|
| 354 | + $forms[$form->getPriority()] = [$form]; |
|
| 355 | + } |
|
| 356 | + } catch (QueryException $e) { |
|
| 357 | + // skip |
|
| 358 | + } |
|
| 359 | + return $forms; |
|
| 360 | + } |
|
| 361 | + |
|
| 362 | + /** |
|
| 363 | + * @param string $section |
|
| 364 | + * @return ISection[] |
|
| 365 | + */ |
|
| 366 | + private function getBuiltInPersonalSettings($section) { |
|
| 367 | + $forms = []; |
|
| 368 | + try { |
|
| 369 | + if ($section === 'personal-info') { |
|
| 370 | + /** @var ISettings $form */ |
|
| 371 | + $form = new Personal\PersonalInfo($this->config, $this->userManager, $this->groupManager, $this->accountManager, $this->l10nFactory, $this->defaults); |
|
| 372 | + $forms[$form->getPriority()] = [$form]; |
|
| 373 | + } |
|
| 374 | + } catch (QueryException $e) { |
|
| 375 | + // skip |
|
| 376 | + } |
|
| 377 | + return $forms; |
|
| 378 | + } |
|
| 379 | + |
|
| 380 | + /** |
|
| 381 | + * @inheritdoc |
|
| 382 | + */ |
|
| 383 | + public function getAdminSettings($section) { |
|
| 384 | + $settings = $this->getBuiltInAdminSettings($section); |
|
| 385 | + $dbRows = $this->mapper->getAdminSettingsFromDB($section); |
|
| 386 | + |
|
| 387 | + foreach ($dbRows as $row) { |
|
| 388 | + if (!isset($settings[$row['priority']])) { |
|
| 389 | + $settings[$row['priority']] = []; |
|
| 390 | + } |
|
| 391 | + try { |
|
| 392 | + $settings[$row['priority']][] = $this->query($row['class']); |
|
| 393 | + } catch (QueryException $e) { |
|
| 394 | + // skip |
|
| 395 | + } |
|
| 396 | + } |
|
| 397 | + |
|
| 398 | + ksort($settings); |
|
| 399 | + return $settings; |
|
| 400 | + } |
|
| 401 | + |
|
| 402 | + /** |
|
| 403 | + * @inheritdoc |
|
| 404 | + */ |
|
| 405 | + public function getPersonalSections() { |
|
| 406 | + $sections = [ |
|
| 407 | + 0 => [new Section('personal-info', $this->l->t('Personal info'), 0, $this->url->imagePath('core', 'actions/info.svg'))], |
|
| 408 | + ]; |
|
| 409 | + return $sections; |
|
| 410 | + } |
|
| 411 | + |
|
| 412 | + /** |
|
| 413 | + * @inheritdoc |
|
| 414 | + */ |
|
| 415 | + public function getPersonalSettings($section) { |
|
| 416 | + $settings = $this->getBuiltInPersonalSettings($section); |
|
| 417 | + return $settings; |
|
| 418 | + } |
|
| 419 | 419 | } |