summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorArthur Schiwon <blizzz@arthur-schiwon.de>2017-05-17 11:51:22 +0200
committerArthur Schiwon <blizzz@arthur-schiwon.de>2017-06-23 12:36:38 +0200
commit9e924d74c96f9d6545ab0d204719c8486c5c8cb7 (patch)
tree813381ea602222246e898e00644e4ac3db6f9772 /lib
parent045f652ef2844e3917b4ae7f3bbb5abb3422d02b (diff)
downloadnextcloud-server-9e924d74c96f9d6545ab0d204719c8486c5c8cb7.tar.gz
nextcloud-server-9e924d74c96f9d6545ab0d204719c8486c5c8cb7.zip
fix displaying groups in personal info
Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
Diffstat (limited to 'lib')
-rw-r--r--lib/private/Settings/Personal/PersonalInfo.php54
1 files changed, 44 insertions, 10 deletions
diff --git a/lib/private/Settings/Personal/PersonalInfo.php b/lib/private/Settings/Personal/PersonalInfo.php
index c1b2e8acc70..605d0c4df60 100644
--- a/lib/private/Settings/Personal/PersonalInfo.php
+++ b/lib/private/Settings/Personal/PersonalInfo.php
@@ -27,6 +27,7 @@ namespace OC\Settings\Personal;
use OC\Accounts\AccountManager;
use OCP\AppFramework\Http\TemplateResponse;
use OCP\IConfig;
+use OCP\IGroup;
use OCP\IGroupManager;
use OCP\IUser;
use OCP\IUserManager;
@@ -58,6 +59,7 @@ class PersonalInfo implements ISettings {
* @param IGroupManager $groupManager
* @param AccountManager $accountManager
* @param IFactory $l10nFactory
+ * @param \OC_Defaults $defaults
*/
public function __construct(
IConfig $config,
@@ -85,16 +87,9 @@ class PersonalInfo implements ISettings {
$uid = \OC_User::getUser();
$user = $this->userManager->get($uid);
-
$userData = $this->accountManager->getUser($user);
- list($activeLanguage, $commonLanguages, $languages) = $this->getLanguages($user);
- //links to clients
- $clients = [
- 'desktop' => $this->config->getSystemValue('customclient_desktop', $this->defaults->getSyncClientUrl()),
- 'android' => $this->config->getSystemValue('customclient_android', $this->defaults->getAndroidClientUrl()),
- 'ios' => $this->config->getSystemValue('customclient_ios', $this->defaults->getiOSClientUrl())
- ];
+ list($activeLanguage, $commonLanguages, $languages) = $this->getLanguages($user);
$parameters = [
'avatarChangeSupported' => \OC_User::canUserChangeAvatar($uid),
@@ -116,12 +111,12 @@ class PersonalInfo implements ISettings {
'twitter' => $userData[AccountManager::PROPERTY_TWITTER]['value'],
'twitterScope' => $userData[AccountManager::PROPERTY_TWITTER]['scope'],
'twitterVerification' => $userData[AccountManager::PROPERTY_TWITTER]['verified'],
- 'groups' => $this->groupManager->getUserGroups($user),
+ 'groups' => $this->getGroups($user),
'passwordChangeSupported' => \OC_User::canUserChangePassword($uid),
'activelanguage' => $activeLanguage,
'commonlanguages' => $commonLanguages,
'languages' => $languages,
- 'clients' => $clients,
+ 'clients' => $this->getClientLinks(),
];
@@ -148,6 +143,31 @@ class PersonalInfo implements ISettings {
return 10;
}
+ /**
+ * returns a sorted list of the user's group GIDs
+ *
+ * @param IUser $user
+ * @return array
+ */
+ private function getGroups(IUser $user) {
+ $groups = array_map(
+ function(IGroup $group) {
+ return $group->getGID();
+ },
+ $this->groupManager->getUserGroups($user)
+ );
+ sort($groups);
+
+ return $groups;
+ }
+
+ /**
+ * returns the user language, common language and other languages in an
+ * associative array
+ *
+ * @param IUser $user
+ * @return array
+ */
private function getLanguages(IUser $user) {
$uid = $user->getUID();
@@ -203,4 +223,18 @@ class PersonalInfo implements ISettings {
return [$userLang, $commonLanguages, $languages];
}
+
+ /**
+ * returns an array containing links to the various clients
+ *
+ * @return array
+ */
+ private function getClientLinks() {
+ $clients = [
+ 'desktop' => $this->config->getSystemValue('customclient_desktop', $this->defaults->getSyncClientUrl()),
+ 'android' => $this->config->getSystemValue('customclient_android', $this->defaults->getAndroidClientUrl()),
+ 'ios' => $this->config->getSystemValue('customclient_ios', $this->defaults->getiOSClientUrl())
+ ];
+ return $clients;
+ }
}