Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/polls.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/lib/Db
diff options
context:
space:
mode:
authordartcafe <github@dartcafe.de>2020-01-29 18:27:47 +0300
committerdartcafe <github@dartcafe.de>2020-01-29 18:27:47 +0300
commit601c8f197cea95ad8807ed19a72c8051e83d75b0 (patch)
tree5063e024c8a1f61677d62d1ab32ff7816c7cf4c8 /lib/Db
parenta6e66f17078dc111a112ca446037e13ddb83b739 (diff)
Add displayname for LDAP users #715
Diffstat (limited to 'lib/Db')
-rw-r--r--lib/Db/Comment.php13
-rw-r--r--lib/Db/Poll.php13
-rw-r--r--lib/Db/Share.php12
-rw-r--r--lib/Db/Vote.php14
4 files changed, 47 insertions, 5 deletions
diff --git a/lib/Db/Comment.php b/lib/Db/Comment.php
index 0226ffb1..4935c077 100644
--- a/lib/Db/Comment.php
+++ b/lib/Db/Comment.php
@@ -27,6 +27,7 @@ namespace OCA\Polls\Db;
use JsonSerializable;
+use OCP\IUser;
use OCP\AppFramework\Db\Entity;
/**
@@ -76,7 +77,17 @@ class Comment extends Entity implements JsonSerializable {
'userId' => $this->userId,
'dt' => $this->dt,
'timestamp' => intval($timestamp),
- 'comment' => $this->comment
+ 'comment' => $this->comment,
+ 'displayName' => $this->getDisplayName()
];
}
+
+ private function getDisplayName() {
+
+ if (\OC::$server->getUserManager()->get($this->userId) instanceof IUser) {
+ return \OC::$server->getUserManager()->get($this->userId)->getDisplayName();
+ } else {
+ return $this->userId;
+ }
+ }
}
diff --git a/lib/Db/Poll.php b/lib/Db/Poll.php
index ef8ffc28..e98c4124 100644
--- a/lib/Db/Poll.php
+++ b/lib/Db/Poll.php
@@ -27,6 +27,7 @@ namespace OCA\Polls\Db;
use JsonSerializable;
+use OCP\IUser;
use OCP\AppFramework\Db\Entity;
/**
@@ -131,7 +132,17 @@ class Poll extends Entity implements JsonSerializable {
'settings' => $this->settings,
'voteLimit' => intval($this->voteLimit),
'showResults' => $this->showResults,
- 'adminAccess' => intVal($this->adminAccess)
+ 'adminAccess' => intVal($this->adminAccess),
+ 'ownerDisplayName' => $this->getDisplayName()
];
}
+
+ private function getDisplayName() {
+
+ if (\OC::$server->getUserManager()->get($this->owner) instanceof IUser) {
+ return \OC::$server->getUserManager()->get($this->owner)->getDisplayName();
+ } else {
+ return $this->owner;
+ }
+ }
}
diff --git a/lib/Db/Share.php b/lib/Db/Share.php
index d290f2ab..d9e9587c 100644
--- a/lib/Db/Share.php
+++ b/lib/Db/Share.php
@@ -25,6 +25,7 @@ namespace OCA\Polls\Db;
use JsonSerializable;
+use OCP\IUser;
use OCP\AppFramework\Db\Entity;
/**
@@ -66,8 +67,17 @@ class Share extends Entity implements JsonSerializable {
'type' => $this->type,
'pollId' => intval($this->pollId),
'userId' => $this->userId,
- 'userEmail' => $this->userEmail
+ 'userEmail' => $this->userEmail,
+ 'displayName' => $this->getDisplayName()
];
+ }
+
+ private function getDisplayName() {
+ if (\OC::$server->getUserManager()->get($this->userId) instanceof IUser) {
+ return \OC::$server->getUserManager()->get($this->userId)->getDisplayName();
+ } else {
+ return $this->userId;
+ }
}
}
diff --git a/lib/Db/Vote.php b/lib/Db/Vote.php
index b890e55d..b6013467 100644
--- a/lib/Db/Vote.php
+++ b/lib/Db/Vote.php
@@ -26,7 +26,7 @@
namespace OCA\Polls\Db;
use JsonSerializable;
-
+use OCP\IUser;
use OCP\AppFramework\Db\Entity;
/**
@@ -65,7 +65,17 @@ class Vote extends Entity implements JsonSerializable {
'userId' => $this->userId,
'voteOptionId' => intval($this->voteOptionId),
'voteOptionText' => $this->voteOptionText,
- 'voteAnswer' => $this->voteAnswer
+ 'voteAnswer' => $this->voteAnswer,
+ 'displayName' => $this->getDisplayName()
];
}
+
+ private function getDisplayName() {
+
+ if (\OC::$server->getUserManager()->get($this->userId) instanceof IUser) {
+ return \OC::$server->getUserManager()->get($this->userId)->getDisplayName();
+ } else {
+ return $this->userId;
+ }
+ }
}