@@ -39,246 +39,246 @@ |
||
| 39 | 39 | use OCP\Settings\ISettings; |
| 40 | 40 | |
| 41 | 41 | class PersonalInfo implements ISettings { |
| 42 | - /** @var IConfig */ |
|
| 43 | - private $config; |
|
| 44 | - /** @var IUserManager */ |
|
| 45 | - private $userManager; |
|
| 46 | - /** @var AccountManager */ |
|
| 47 | - private $accountManager; |
|
| 48 | - /** @var IGroupManager */ |
|
| 49 | - private $groupManager; |
|
| 50 | - /** @var IAppManager */ |
|
| 51 | - private $appManager; |
|
| 52 | - /** @var IFactory */ |
|
| 53 | - private $l10nFactory; |
|
| 42 | + /** @var IConfig */ |
|
| 43 | + private $config; |
|
| 44 | + /** @var IUserManager */ |
|
| 45 | + private $userManager; |
|
| 46 | + /** @var AccountManager */ |
|
| 47 | + private $accountManager; |
|
| 48 | + /** @var IGroupManager */ |
|
| 49 | + private $groupManager; |
|
| 50 | + /** @var IAppManager */ |
|
| 51 | + private $appManager; |
|
| 52 | + /** @var IFactory */ |
|
| 53 | + private $l10nFactory; |
|
| 54 | 54 | |
| 55 | - const COMMON_LANGUAGE_CODES = [ |
|
| 56 | - 'en', 'es', 'fr', 'de', 'de_DE', 'ja', 'ar', 'ru', 'nl', 'it', |
|
| 57 | - 'pt_BR', 'pt_PT', 'da', 'fi_FI', 'nb_NO', 'sv', 'tr', 'zh_CN', 'ko' |
|
| 58 | - ]; |
|
| 55 | + const COMMON_LANGUAGE_CODES = [ |
|
| 56 | + 'en', 'es', 'fr', 'de', 'de_DE', 'ja', 'ar', 'ru', 'nl', 'it', |
|
| 57 | + 'pt_BR', 'pt_PT', 'da', 'fi_FI', 'nb_NO', 'sv', 'tr', 'zh_CN', 'ko' |
|
| 58 | + ]; |
|
| 59 | 59 | |
| 60 | - /** @var IL10N */ |
|
| 61 | - private $l; |
|
| 60 | + /** @var IL10N */ |
|
| 61 | + private $l; |
|
| 62 | 62 | |
| 63 | - /** |
|
| 64 | - * @param IConfig $config |
|
| 65 | - * @param IUserManager $userManager |
|
| 66 | - * @param IGroupManager $groupManager |
|
| 67 | - * @param AccountManager $accountManager |
|
| 68 | - * @param IFactory $l10nFactory |
|
| 69 | - * @param IL10N $l |
|
| 70 | - */ |
|
| 71 | - public function __construct( |
|
| 72 | - IConfig $config, |
|
| 73 | - IUserManager $userManager, |
|
| 74 | - IGroupManager $groupManager, |
|
| 75 | - AccountManager $accountManager, |
|
| 76 | - IAppManager $appManager, |
|
| 77 | - IFactory $l10nFactory, |
|
| 78 | - IL10N $l |
|
| 79 | - ) { |
|
| 80 | - $this->config = $config; |
|
| 81 | - $this->userManager = $userManager; |
|
| 82 | - $this->accountManager = $accountManager; |
|
| 83 | - $this->groupManager = $groupManager; |
|
| 84 | - $this->appManager = $appManager; |
|
| 85 | - $this->l10nFactory = $l10nFactory; |
|
| 86 | - $this->l = $l; |
|
| 87 | - } |
|
| 63 | + /** |
|
| 64 | + * @param IConfig $config |
|
| 65 | + * @param IUserManager $userManager |
|
| 66 | + * @param IGroupManager $groupManager |
|
| 67 | + * @param AccountManager $accountManager |
|
| 68 | + * @param IFactory $l10nFactory |
|
| 69 | + * @param IL10N $l |
|
| 70 | + */ |
|
| 71 | + public function __construct( |
|
| 72 | + IConfig $config, |
|
| 73 | + IUserManager $userManager, |
|
| 74 | + IGroupManager $groupManager, |
|
| 75 | + AccountManager $accountManager, |
|
| 76 | + IAppManager $appManager, |
|
| 77 | + IFactory $l10nFactory, |
|
| 78 | + IL10N $l |
|
| 79 | + ) { |
|
| 80 | + $this->config = $config; |
|
| 81 | + $this->userManager = $userManager; |
|
| 82 | + $this->accountManager = $accountManager; |
|
| 83 | + $this->groupManager = $groupManager; |
|
| 84 | + $this->appManager = $appManager; |
|
| 85 | + $this->l10nFactory = $l10nFactory; |
|
| 86 | + $this->l = $l; |
|
| 87 | + } |
|
| 88 | 88 | |
| 89 | - /** |
|
| 90 | - * @return TemplateResponse returns the instance with all parameters set, ready to be rendered |
|
| 91 | - * @since 9.1 |
|
| 92 | - */ |
|
| 93 | - public function getForm() { |
|
| 94 | - $federatedFileSharingEnabled = $this->appManager->isEnabledForUser('federatedfilesharing'); |
|
| 95 | - $lookupServerUploadEnabled = false; |
|
| 96 | - if($federatedFileSharingEnabled) { |
|
| 97 | - $federatedFileSharing = new Application(); |
|
| 98 | - $shareProvider = $federatedFileSharing->getFederatedShareProvider(); |
|
| 99 | - $lookupServerUploadEnabled = $shareProvider->isLookupServerUploadEnabled(); |
|
| 100 | - } |
|
| 89 | + /** |
|
| 90 | + * @return TemplateResponse returns the instance with all parameters set, ready to be rendered |
|
| 91 | + * @since 9.1 |
|
| 92 | + */ |
|
| 93 | + public function getForm() { |
|
| 94 | + $federatedFileSharingEnabled = $this->appManager->isEnabledForUser('federatedfilesharing'); |
|
| 95 | + $lookupServerUploadEnabled = false; |
|
| 96 | + if($federatedFileSharingEnabled) { |
|
| 97 | + $federatedFileSharing = new Application(); |
|
| 98 | + $shareProvider = $federatedFileSharing->getFederatedShareProvider(); |
|
| 99 | + $lookupServerUploadEnabled = $shareProvider->isLookupServerUploadEnabled(); |
|
| 100 | + } |
|
| 101 | 101 | |
| 102 | - $uid = \OC_User::getUser(); |
|
| 103 | - $user = $this->userManager->get($uid); |
|
| 104 | - $userData = $this->accountManager->getUser($user); |
|
| 102 | + $uid = \OC_User::getUser(); |
|
| 103 | + $user = $this->userManager->get($uid); |
|
| 104 | + $userData = $this->accountManager->getUser($user); |
|
| 105 | 105 | |
| 106 | - $storageInfo = \OC_Helper::getStorageInfo('/'); |
|
| 107 | - if ($storageInfo['quota'] === FileInfo::SPACE_UNLIMITED) { |
|
| 108 | - $totalSpace = $this->l->t('Unlimited'); |
|
| 109 | - } else { |
|
| 110 | - $totalSpace = \OC_Helper::humanFileSize($storageInfo['total']); |
|
| 111 | - } |
|
| 106 | + $storageInfo = \OC_Helper::getStorageInfo('/'); |
|
| 107 | + if ($storageInfo['quota'] === FileInfo::SPACE_UNLIMITED) { |
|
| 108 | + $totalSpace = $this->l->t('Unlimited'); |
|
| 109 | + } else { |
|
| 110 | + $totalSpace = \OC_Helper::humanFileSize($storageInfo['total']); |
|
| 111 | + } |
|
| 112 | 112 | |
| 113 | - $languageParameters = $this->getLanguages($user); |
|
| 114 | - $messageParameters = $this->getMessageParameters($userData); |
|
| 113 | + $languageParameters = $this->getLanguages($user); |
|
| 114 | + $messageParameters = $this->getMessageParameters($userData); |
|
| 115 | 115 | |
| 116 | - $parameters = [ |
|
| 117 | - 'total_space' => $totalSpace, |
|
| 118 | - 'usage' => \OC_Helper::humanFileSize($storageInfo['used']), |
|
| 119 | - 'usage_relative' => round($storageInfo['relative']), |
|
| 120 | - 'quota' => $storageInfo['quota'], |
|
| 121 | - 'avatarChangeSupported' => $user->canChangeAvatar(), |
|
| 122 | - 'lookupServerUploadEnabled' => $lookupServerUploadEnabled, |
|
| 123 | - 'avatarScope' => $userData[AccountManager::PROPERTY_AVATAR]['scope'], |
|
| 124 | - 'displayNameChangeSupported' => $user->canChangeDisplayName(), |
|
| 125 | - 'displayName' => $userData[AccountManager::PROPERTY_DISPLAYNAME]['value'], |
|
| 126 | - 'displayNameScope' => $userData[AccountManager::PROPERTY_DISPLAYNAME]['scope'], |
|
| 127 | - 'email' => $userData[AccountManager::PROPERTY_EMAIL]['value'], |
|
| 128 | - 'emailScope' => $userData[AccountManager::PROPERTY_EMAIL]['scope'], |
|
| 129 | - 'emailVerification' => $userData[AccountManager::PROPERTY_EMAIL]['verified'], |
|
| 130 | - 'phone' => $userData[AccountManager::PROPERTY_PHONE]['value'], |
|
| 131 | - 'phoneScope' => $userData[AccountManager::PROPERTY_PHONE]['scope'], |
|
| 132 | - 'address' => $userData[AccountManager::PROPERTY_ADDRESS]['value'], |
|
| 133 | - 'addressScope' => $userData[AccountManager::PROPERTY_ADDRESS]['scope'], |
|
| 134 | - 'website' => $userData[AccountManager::PROPERTY_WEBSITE]['value'], |
|
| 135 | - 'websiteScope' => $userData[AccountManager::PROPERTY_WEBSITE]['scope'], |
|
| 136 | - 'websiteVerification' => $userData[AccountManager::PROPERTY_WEBSITE]['verified'], |
|
| 137 | - 'twitter' => $userData[AccountManager::PROPERTY_TWITTER]['value'], |
|
| 138 | - 'twitterScope' => $userData[AccountManager::PROPERTY_TWITTER]['scope'], |
|
| 139 | - 'twitterVerification' => $userData[AccountManager::PROPERTY_TWITTER]['verified'], |
|
| 140 | - 'groups' => $this->getGroups($user), |
|
| 141 | - 'passwordChangeSupported' => $user->canChangePassword(), |
|
| 142 | - ] + $messageParameters + $languageParameters; |
|
| 116 | + $parameters = [ |
|
| 117 | + 'total_space' => $totalSpace, |
|
| 118 | + 'usage' => \OC_Helper::humanFileSize($storageInfo['used']), |
|
| 119 | + 'usage_relative' => round($storageInfo['relative']), |
|
| 120 | + 'quota' => $storageInfo['quota'], |
|
| 121 | + 'avatarChangeSupported' => $user->canChangeAvatar(), |
|
| 122 | + 'lookupServerUploadEnabled' => $lookupServerUploadEnabled, |
|
| 123 | + 'avatarScope' => $userData[AccountManager::PROPERTY_AVATAR]['scope'], |
|
| 124 | + 'displayNameChangeSupported' => $user->canChangeDisplayName(), |
|
| 125 | + 'displayName' => $userData[AccountManager::PROPERTY_DISPLAYNAME]['value'], |
|
| 126 | + 'displayNameScope' => $userData[AccountManager::PROPERTY_DISPLAYNAME]['scope'], |
|
| 127 | + 'email' => $userData[AccountManager::PROPERTY_EMAIL]['value'], |
|
| 128 | + 'emailScope' => $userData[AccountManager::PROPERTY_EMAIL]['scope'], |
|
| 129 | + 'emailVerification' => $userData[AccountManager::PROPERTY_EMAIL]['verified'], |
|
| 130 | + 'phone' => $userData[AccountManager::PROPERTY_PHONE]['value'], |
|
| 131 | + 'phoneScope' => $userData[AccountManager::PROPERTY_PHONE]['scope'], |
|
| 132 | + 'address' => $userData[AccountManager::PROPERTY_ADDRESS]['value'], |
|
| 133 | + 'addressScope' => $userData[AccountManager::PROPERTY_ADDRESS]['scope'], |
|
| 134 | + 'website' => $userData[AccountManager::PROPERTY_WEBSITE]['value'], |
|
| 135 | + 'websiteScope' => $userData[AccountManager::PROPERTY_WEBSITE]['scope'], |
|
| 136 | + 'websiteVerification' => $userData[AccountManager::PROPERTY_WEBSITE]['verified'], |
|
| 137 | + 'twitter' => $userData[AccountManager::PROPERTY_TWITTER]['value'], |
|
| 138 | + 'twitterScope' => $userData[AccountManager::PROPERTY_TWITTER]['scope'], |
|
| 139 | + 'twitterVerification' => $userData[AccountManager::PROPERTY_TWITTER]['verified'], |
|
| 140 | + 'groups' => $this->getGroups($user), |
|
| 141 | + 'passwordChangeSupported' => $user->canChangePassword(), |
|
| 142 | + ] + $messageParameters + $languageParameters; |
|
| 143 | 143 | |
| 144 | 144 | |
| 145 | - return new TemplateResponse('settings', 'settings/personal/personal.info', $parameters, ''); |
|
| 146 | - } |
|
| 145 | + return new TemplateResponse('settings', 'settings/personal/personal.info', $parameters, ''); |
|
| 146 | + } |
|
| 147 | 147 | |
| 148 | - /** |
|
| 149 | - * @return string the section ID, e.g. 'sharing' |
|
| 150 | - * @since 9.1 |
|
| 151 | - */ |
|
| 152 | - public function getSection() { |
|
| 153 | - return 'personal-info'; |
|
| 154 | - } |
|
| 148 | + /** |
|
| 149 | + * @return string the section ID, e.g. 'sharing' |
|
| 150 | + * @since 9.1 |
|
| 151 | + */ |
|
| 152 | + public function getSection() { |
|
| 153 | + return 'personal-info'; |
|
| 154 | + } |
|
| 155 | 155 | |
| 156 | - /** |
|
| 157 | - * @return int whether the form should be rather on the top or bottom of |
|
| 158 | - * the admin section. The forms are arranged in ascending order of the |
|
| 159 | - * priority values. It is required to return a value between 0 and 100. |
|
| 160 | - * |
|
| 161 | - * E.g.: 70 |
|
| 162 | - * @since 9.1 |
|
| 163 | - */ |
|
| 164 | - public function getPriority() { |
|
| 165 | - return 10; |
|
| 166 | - } |
|
| 156 | + /** |
|
| 157 | + * @return int whether the form should be rather on the top or bottom of |
|
| 158 | + * the admin section. The forms are arranged in ascending order of the |
|
| 159 | + * priority values. It is required to return a value between 0 and 100. |
|
| 160 | + * |
|
| 161 | + * E.g.: 70 |
|
| 162 | + * @since 9.1 |
|
| 163 | + */ |
|
| 164 | + public function getPriority() { |
|
| 165 | + return 10; |
|
| 166 | + } |
|
| 167 | 167 | |
| 168 | - /** |
|
| 169 | - * returns a sorted list of the user's group GIDs |
|
| 170 | - * |
|
| 171 | - * @param IUser $user |
|
| 172 | - * @return array |
|
| 173 | - */ |
|
| 174 | - private function getGroups(IUser $user) { |
|
| 175 | - $groups = array_map( |
|
| 176 | - function(IGroup $group) { |
|
| 177 | - return $group->getGID(); |
|
| 178 | - }, |
|
| 179 | - $this->groupManager->getUserGroups($user) |
|
| 180 | - ); |
|
| 181 | - sort($groups); |
|
| 168 | + /** |
|
| 169 | + * returns a sorted list of the user's group GIDs |
|
| 170 | + * |
|
| 171 | + * @param IUser $user |
|
| 172 | + * @return array |
|
| 173 | + */ |
|
| 174 | + private function getGroups(IUser $user) { |
|
| 175 | + $groups = array_map( |
|
| 176 | + function(IGroup $group) { |
|
| 177 | + return $group->getGID(); |
|
| 178 | + }, |
|
| 179 | + $this->groupManager->getUserGroups($user) |
|
| 180 | + ); |
|
| 181 | + sort($groups); |
|
| 182 | 182 | |
| 183 | - return $groups; |
|
| 184 | - } |
|
| 183 | + return $groups; |
|
| 184 | + } |
|
| 185 | 185 | |
| 186 | - /** |
|
| 187 | - * returns the user language, common language and other languages in an |
|
| 188 | - * associative array |
|
| 189 | - * |
|
| 190 | - * @param IUser $user |
|
| 191 | - * @return array |
|
| 192 | - */ |
|
| 193 | - private function getLanguages(IUser $user) { |
|
| 194 | - $forceLanguage = $this->config->getSystemValue('force_language', false); |
|
| 195 | - if($forceLanguage !== false) { |
|
| 196 | - return []; |
|
| 197 | - } |
|
| 186 | + /** |
|
| 187 | + * returns the user language, common language and other languages in an |
|
| 188 | + * associative array |
|
| 189 | + * |
|
| 190 | + * @param IUser $user |
|
| 191 | + * @return array |
|
| 192 | + */ |
|
| 193 | + private function getLanguages(IUser $user) { |
|
| 194 | + $forceLanguage = $this->config->getSystemValue('force_language', false); |
|
| 195 | + if($forceLanguage !== false) { |
|
| 196 | + return []; |
|
| 197 | + } |
|
| 198 | 198 | |
| 199 | - $uid = $user->getUID(); |
|
| 199 | + $uid = $user->getUID(); |
|
| 200 | 200 | |
| 201 | - $userLang = $this->config->getUserValue($uid, 'core', 'lang', $this->l10nFactory->findLanguage()); |
|
| 202 | - $languageCodes = $this->l10nFactory->findAvailableLanguages(); |
|
| 201 | + $userLang = $this->config->getUserValue($uid, 'core', 'lang', $this->l10nFactory->findLanguage()); |
|
| 202 | + $languageCodes = $this->l10nFactory->findAvailableLanguages(); |
|
| 203 | 203 | |
| 204 | - $commonLanguages = []; |
|
| 205 | - $languages = []; |
|
| 204 | + $commonLanguages = []; |
|
| 205 | + $languages = []; |
|
| 206 | 206 | |
| 207 | - foreach($languageCodes as $lang) { |
|
| 208 | - $l = \OC::$server->getL10N('lib', $lang); |
|
| 209 | - // TRANSLATORS this is the language name for the language switcher in the personal settings and should be the localized version |
|
| 210 | - $potentialName = (string) $l->t('__language_name__'); |
|
| 211 | - if($l->getLanguageCode() === $lang && $potentialName[0] !== '_') {//first check if the language name is in the translation file |
|
| 212 | - $ln = array('code' => $lang, 'name' => $potentialName); |
|
| 213 | - } elseif ($lang === 'en') { |
|
| 214 | - $ln = ['code' => $lang, 'name' => 'English (US)']; |
|
| 215 | - }else{//fallback to language code |
|
| 216 | - $ln=array('code'=>$lang, 'name'=>$lang); |
|
| 217 | - } |
|
| 207 | + foreach($languageCodes as $lang) { |
|
| 208 | + $l = \OC::$server->getL10N('lib', $lang); |
|
| 209 | + // TRANSLATORS this is the language name for the language switcher in the personal settings and should be the localized version |
|
| 210 | + $potentialName = (string) $l->t('__language_name__'); |
|
| 211 | + if($l->getLanguageCode() === $lang && $potentialName[0] !== '_') {//first check if the language name is in the translation file |
|
| 212 | + $ln = array('code' => $lang, 'name' => $potentialName); |
|
| 213 | + } elseif ($lang === 'en') { |
|
| 214 | + $ln = ['code' => $lang, 'name' => 'English (US)']; |
|
| 215 | + }else{//fallback to language code |
|
| 216 | + $ln=array('code'=>$lang, 'name'=>$lang); |
|
| 217 | + } |
|
| 218 | 218 | |
| 219 | - // put appropriate languages into appropriate arrays, to print them sorted |
|
| 220 | - // used language -> common languages -> divider -> other languages |
|
| 221 | - if ($lang === $userLang) { |
|
| 222 | - $userLang = $ln; |
|
| 223 | - } elseif (in_array($lang, self::COMMON_LANGUAGE_CODES)) { |
|
| 224 | - $commonLanguages[array_search($lang, self::COMMON_LANGUAGE_CODES)]=$ln; |
|
| 225 | - } else { |
|
| 226 | - $languages[]=$ln; |
|
| 227 | - } |
|
| 228 | - } |
|
| 219 | + // put appropriate languages into appropriate arrays, to print them sorted |
|
| 220 | + // used language -> common languages -> divider -> other languages |
|
| 221 | + if ($lang === $userLang) { |
|
| 222 | + $userLang = $ln; |
|
| 223 | + } elseif (in_array($lang, self::COMMON_LANGUAGE_CODES)) { |
|
| 224 | + $commonLanguages[array_search($lang, self::COMMON_LANGUAGE_CODES)]=$ln; |
|
| 225 | + } else { |
|
| 226 | + $languages[]=$ln; |
|
| 227 | + } |
|
| 228 | + } |
|
| 229 | 229 | |
| 230 | - // if user language is not available but set somehow: show the actual code as name |
|
| 231 | - if (!is_array($userLang)) { |
|
| 232 | - $userLang = [ |
|
| 233 | - 'code' => $userLang, |
|
| 234 | - 'name' => $userLang, |
|
| 235 | - ]; |
|
| 236 | - } |
|
| 230 | + // if user language is not available but set somehow: show the actual code as name |
|
| 231 | + if (!is_array($userLang)) { |
|
| 232 | + $userLang = [ |
|
| 233 | + 'code' => $userLang, |
|
| 234 | + 'name' => $userLang, |
|
| 235 | + ]; |
|
| 236 | + } |
|
| 237 | 237 | |
| 238 | - ksort($commonLanguages); |
|
| 238 | + ksort($commonLanguages); |
|
| 239 | 239 | |
| 240 | - // sort now by displayed language not the iso-code |
|
| 241 | - usort( $languages, function ($a, $b) { |
|
| 242 | - if ($a['code'] === $a['name'] && $b['code'] !== $b['name']) { |
|
| 243 | - // If a doesn't have a name, but b does, list b before a |
|
| 244 | - return 1; |
|
| 245 | - } |
|
| 246 | - if ($a['code'] !== $a['name'] && $b['code'] === $b['name']) { |
|
| 247 | - // If a does have a name, but b doesn't, list a before b |
|
| 248 | - return -1; |
|
| 249 | - } |
|
| 250 | - // Otherwise compare the names |
|
| 251 | - return strcmp($a['name'], $b['name']); |
|
| 252 | - }); |
|
| 240 | + // sort now by displayed language not the iso-code |
|
| 241 | + usort( $languages, function ($a, $b) { |
|
| 242 | + if ($a['code'] === $a['name'] && $b['code'] !== $b['name']) { |
|
| 243 | + // If a doesn't have a name, but b does, list b before a |
|
| 244 | + return 1; |
|
| 245 | + } |
|
| 246 | + if ($a['code'] !== $a['name'] && $b['code'] === $b['name']) { |
|
| 247 | + // If a does have a name, but b doesn't, list a before b |
|
| 248 | + return -1; |
|
| 249 | + } |
|
| 250 | + // Otherwise compare the names |
|
| 251 | + return strcmp($a['name'], $b['name']); |
|
| 252 | + }); |
|
| 253 | 253 | |
| 254 | - return [ |
|
| 255 | - 'activelanguage' => $userLang, |
|
| 256 | - 'commonlanguages' => $commonLanguages, |
|
| 257 | - 'languages' => $languages |
|
| 258 | - ]; |
|
| 259 | - } |
|
| 254 | + return [ |
|
| 255 | + 'activelanguage' => $userLang, |
|
| 256 | + 'commonlanguages' => $commonLanguages, |
|
| 257 | + 'languages' => $languages |
|
| 258 | + ]; |
|
| 259 | + } |
|
| 260 | 260 | |
| 261 | - /** |
|
| 262 | - * @param array $userData |
|
| 263 | - * @return array |
|
| 264 | - */ |
|
| 265 | - private function getMessageParameters(array $userData) { |
|
| 266 | - $needVerifyMessage = [AccountManager::PROPERTY_EMAIL, AccountManager::PROPERTY_WEBSITE, AccountManager::PROPERTY_TWITTER]; |
|
| 267 | - $messageParameters = []; |
|
| 268 | - foreach ($needVerifyMessage as $property) { |
|
| 269 | - switch ($userData[$property]['verified']) { |
|
| 270 | - case AccountManager::VERIFIED: |
|
| 271 | - $message = $this->l->t('Verifying'); |
|
| 272 | - break; |
|
| 273 | - case AccountManager::VERIFICATION_IN_PROGRESS: |
|
| 274 | - $message = $this->l->t('Verifying …'); |
|
| 275 | - break; |
|
| 276 | - default: |
|
| 277 | - $message = $this->l->t('Verify'); |
|
| 278 | - } |
|
| 279 | - $messageParameters[$property . 'Message'] = $message; |
|
| 280 | - } |
|
| 281 | - return $messageParameters; |
|
| 282 | - } |
|
| 261 | + /** |
|
| 262 | + * @param array $userData |
|
| 263 | + * @return array |
|
| 264 | + */ |
|
| 265 | + private function getMessageParameters(array $userData) { |
|
| 266 | + $needVerifyMessage = [AccountManager::PROPERTY_EMAIL, AccountManager::PROPERTY_WEBSITE, AccountManager::PROPERTY_TWITTER]; |
|
| 267 | + $messageParameters = []; |
|
| 268 | + foreach ($needVerifyMessage as $property) { |
|
| 269 | + switch ($userData[$property]['verified']) { |
|
| 270 | + case AccountManager::VERIFIED: |
|
| 271 | + $message = $this->l->t('Verifying'); |
|
| 272 | + break; |
|
| 273 | + case AccountManager::VERIFICATION_IN_PROGRESS: |
|
| 274 | + $message = $this->l->t('Verifying …'); |
|
| 275 | + break; |
|
| 276 | + default: |
|
| 277 | + $message = $this->l->t('Verify'); |
|
| 278 | + } |
|
| 279 | + $messageParameters[$property . 'Message'] = $message; |
|
| 280 | + } |
|
| 281 | + return $messageParameters; |
|
| 282 | + } |
|
| 283 | 283 | |
| 284 | 284 | } |
@@ -93,7 +93,7 @@ discard block |
||
| 93 | 93 | public function getForm() { |
| 94 | 94 | $federatedFileSharingEnabled = $this->appManager->isEnabledForUser('federatedfilesharing'); |
| 95 | 95 | $lookupServerUploadEnabled = false; |
| 96 | - if($federatedFileSharingEnabled) { |
|
| 96 | + if ($federatedFileSharingEnabled) { |
|
| 97 | 97 | $federatedFileSharing = new Application(); |
| 98 | 98 | $shareProvider = $federatedFileSharing->getFederatedShareProvider(); |
| 99 | 99 | $lookupServerUploadEnabled = $shareProvider->isLookupServerUploadEnabled(); |
@@ -192,7 +192,7 @@ discard block |
||
| 192 | 192 | */ |
| 193 | 193 | private function getLanguages(IUser $user) { |
| 194 | 194 | $forceLanguage = $this->config->getSystemValue('force_language', false); |
| 195 | - if($forceLanguage !== false) { |
|
| 195 | + if ($forceLanguage !== false) { |
|
| 196 | 196 | return []; |
| 197 | 197 | } |
| 198 | 198 | |
@@ -204,16 +204,16 @@ discard block |
||
| 204 | 204 | $commonLanguages = []; |
| 205 | 205 | $languages = []; |
| 206 | 206 | |
| 207 | - foreach($languageCodes as $lang) { |
|
| 207 | + foreach ($languageCodes as $lang) { |
|
| 208 | 208 | $l = \OC::$server->getL10N('lib', $lang); |
| 209 | 209 | // TRANSLATORS this is the language name for the language switcher in the personal settings and should be the localized version |
| 210 | 210 | $potentialName = (string) $l->t('__language_name__'); |
| 211 | - if($l->getLanguageCode() === $lang && $potentialName[0] !== '_') {//first check if the language name is in the translation file |
|
| 211 | + if ($l->getLanguageCode() === $lang && $potentialName[0] !== '_') {//first check if the language name is in the translation file |
|
| 212 | 212 | $ln = array('code' => $lang, 'name' => $potentialName); |
| 213 | 213 | } elseif ($lang === 'en') { |
| 214 | 214 | $ln = ['code' => $lang, 'name' => 'English (US)']; |
| 215 | - }else{//fallback to language code |
|
| 216 | - $ln=array('code'=>$lang, 'name'=>$lang); |
|
| 215 | + } else {//fallback to language code |
|
| 216 | + $ln = array('code'=>$lang, 'name'=>$lang); |
|
| 217 | 217 | } |
| 218 | 218 | |
| 219 | 219 | // put appropriate languages into appropriate arrays, to print them sorted |
@@ -221,9 +221,9 @@ discard block |
||
| 221 | 221 | if ($lang === $userLang) { |
| 222 | 222 | $userLang = $ln; |
| 223 | 223 | } elseif (in_array($lang, self::COMMON_LANGUAGE_CODES)) { |
| 224 | - $commonLanguages[array_search($lang, self::COMMON_LANGUAGE_CODES)]=$ln; |
|
| 224 | + $commonLanguages[array_search($lang, self::COMMON_LANGUAGE_CODES)] = $ln; |
|
| 225 | 225 | } else { |
| 226 | - $languages[]=$ln; |
|
| 226 | + $languages[] = $ln; |
|
| 227 | 227 | } |
| 228 | 228 | } |
| 229 | 229 | |
@@ -238,7 +238,7 @@ discard block |
||
| 238 | 238 | ksort($commonLanguages); |
| 239 | 239 | |
| 240 | 240 | // sort now by displayed language not the iso-code |
| 241 | - usort( $languages, function ($a, $b) { |
|
| 241 | + usort($languages, function($a, $b) { |
|
| 242 | 242 | if ($a['code'] === $a['name'] && $b['code'] !== $b['name']) { |
| 243 | 243 | // If a doesn't have a name, but b does, list b before a |
| 244 | 244 | return 1; |
@@ -276,7 +276,7 @@ discard block |
||
| 276 | 276 | default: |
| 277 | 277 | $message = $this->l->t('Verify'); |
| 278 | 278 | } |
| 279 | - $messageParameters[$property . 'Message'] = $message; |
|
| 279 | + $messageParameters[$property.'Message'] = $message; |
|
| 280 | 280 | } |
| 281 | 281 | return $messageParameters; |
| 282 | 282 | } |