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
diff options
context:
space:
mode:
-rw-r--r--lib/Db/Comment.php9
-rw-r--r--lib/Db/Share.php8
-rw-r--r--lib/Db/Vote.php8
-rw-r--r--lib/Model/Acl.php77
-rw-r--r--src/js/components/Base/ParticipantsList.vue3
-rw-r--r--src/js/components/Base/UserItem.vue6
-rw-r--r--src/js/components/Comments/Comments.vue2
-rw-r--r--src/js/components/VoteTable/VoteHeaderPublic.vue2
-rw-r--r--src/js/store/modules/poll.js3
-rw-r--r--src/js/store/modules/subModules/acl.js3
-rw-r--r--src/js/store/modules/subModules/votes.js2
11 files changed, 47 insertions, 76 deletions
diff --git a/lib/Db/Comment.php b/lib/Db/Comment.php
index 56514570..4165996f 100644
--- a/lib/Db/Comment.php
+++ b/lib/Db/Comment.php
@@ -78,16 +78,21 @@ class Comment extends Entity implements JsonSerializable {
'dt' => $this->dt,
'timestamp' => intval($timestamp),
'comment' => $this->comment,
- 'displayName' => $this->getDisplayName()
+ 'displayName' => $this->getDisplayName(),
+ 'externalUser' => $this->externalUser()
];
}
private function getDisplayName() {
-
if (\OC::$server->getUserManager()->get($this->userId) instanceof IUser) {
return \OC::$server->getUserManager()->get($this->userId)->getDisplayName();
} else {
return $this->userId;
}
}
+
+ private function externalUser() {
+ return (!\OC::$server->getUserManager()->get($this->userId) instanceof IUser);
+ }
+
}
diff --git a/lib/Db/Share.php b/lib/Db/Share.php
index 04b77733..84ae4ea2 100644
--- a/lib/Db/Share.php
+++ b/lib/Db/Share.php
@@ -73,8 +73,9 @@ class Share extends Entity implements JsonSerializable {
'pollId' => intval($this->pollId),
'userId' => $this->userId,
'userEmail' => $this->userEmail,
+ 'invitationSent' => intval($this->invitationSent),
'displayName' => $this->getDisplayName(),
- 'invitationSent' => intval($this->invitationSent)
+ 'externalUser' => $this->externalUser()
];
}
@@ -86,4 +87,9 @@ class Share extends Entity implements JsonSerializable {
return $this->userId;
}
}
+
+ private function externalUser() {
+ return (!\OC::$server->getUserManager()->get($this->userId) instanceof IUser);
+ }
+
}
diff --git a/lib/Db/Vote.php b/lib/Db/Vote.php
index 839f154a..85b63c09 100644
--- a/lib/Db/Vote.php
+++ b/lib/Db/Vote.php
@@ -66,16 +66,20 @@ class Vote extends Entity implements JsonSerializable {
'voteOptionId' => intval($this->voteOptionId),
'voteOptionText' => $this->voteOptionText,
'voteAnswer' => $this->voteAnswer,
- 'displayName' => $this->getDisplayName()
+ 'displayName' => $this->getDisplayName(),
+ 'externalUser' => $this->externalUser()
];
}
private function getDisplayName() {
-
if (\OC::$server->getUserManager()->get($this->userId) instanceof IUser) {
return \OC::$server->getUserManager()->get($this->userId)->getDisplayName();
} else {
return $this->userId;
}
}
+
+ private function externalUser() {
+ return (!\OC::$server->getUserManager()->get($this->userId) instanceof IUser);
+ }
}
diff --git a/lib/Model/Acl.php b/lib/Model/Acl.php
index 71319436..10760008 100644
--- a/lib/Model/Acl.php
+++ b/lib/Model/Acl.php
@@ -53,9 +53,6 @@ class Acl implements JsonSerializable {
/** @var string */
private $token = '';
- /** @var bool */
- private $foundByToken = false;
-
/** @var string */
private $userId;
@@ -77,7 +74,6 @@ class Acl implements JsonSerializable {
/** @var Poll */
private $poll;
-
/**
* Acl constructor.
* @param string $appName
@@ -129,27 +125,20 @@ class Acl implements JsonSerializable {
}
}
-
/**
* @NoAdminRequired
- * @return bool
+ * @return string
*/
- public function setPollIdOrToken($pollId = 0, $token = '') {
-
- if ($token) {
- $this->setToken($token);
- } elseif ($pollId) {
- $this->setPollId($pollId);
- }
-
- return $this;
+ public function getIsExternalUser() {
+ return !($this->userManager->get($this->userId) instanceof IUser);
}
+
/**
* @NoAdminRequired
* @return bool
*/
- public function checkAuthorize($pollId = 0, $token = '') {
+ public function setPollIdOrToken($pollId = 0, $token = '') {
if ($token) {
$this->setToken($token);
@@ -157,7 +146,7 @@ class Acl implements JsonSerializable {
$this->setPollId($pollId);
}
- return ($this->userId && $this->poll->getId());
+ return $this;
}
/**
@@ -309,17 +298,10 @@ class Acl implements JsonSerializable {
* @return bool
*/
public function getAllowVote(): bool {
- if (
- ($this->getAllowView() || $this->getFoundByToken())
+ return ($this->getAllowView() || $this->getToken())
&& !$this->getExpired()
&& !$this->poll->getDeleted()
- && $this->userId
-
- ) {
- return true;
- } else {
- return false;
- }
+ && $this->userId;
}
/**
@@ -343,15 +325,9 @@ class Acl implements JsonSerializable {
* @return bool
*/
public function getAllowSeeResults(): bool {
- if ($this->poll->getShowResults() === 'always' || $this->getIsOwner()) {
- return true;
- } elseif ($this->poll->getShowResults() === 'never') {
- return false;
- } elseif ($this->poll->getShowResults() === 'expired') {
- return $this->getExpired();
- } else {
- return false;
- }
+ return $this->poll->getShowResults() === 'always'
+ || ($this->poll->getShowResults() === 'expired' && $this->getExpired())
+ || $this->getIsOwner();
}
/**
@@ -359,28 +335,7 @@ class Acl implements JsonSerializable {
* @return bool
*/
public function getAllowSeeUsernames(): bool {
- return !($this->poll->getAnonymous() && !$this->getIsOwner()); ;
- }
-
- /**
- * @NoAdminRequired
- * @return bool
- */
- public function getAllowSeeAllVotes(): bool {
- // TODO: preparation for polls without displaying other votes
- if ($this->pollId) {
- return true;
- } else {
- return false;
- }
- }
-
- /**
- * @NoAdminRequired
- * @return bool
- */
- public function getFoundByToken(): bool {
- return $this->foundByToken;
+ return !$this->poll->getAnonymous() || $this->getIsOwner();
}
/**
@@ -401,7 +356,6 @@ class Acl implements JsonSerializable {
$this->token = $token;
$share = $this->shareMapper->findByToken($token);
- $this->foundByToken = true;
$this->setPollId($share->getPollId());
\OC::$server->getLogger()->debug('Share PollId: ' . $share->getPollId());
@@ -410,7 +364,6 @@ class Acl implements JsonSerializable {
$this->setPollId(0);
$this->setUserId(null);
$this->token = '';
- $this->foundByToken = false;
} else if (($share->getType() === 'group' || $share->getType() === 'public') && \OC::$server->getUserSession()->isLoggedIn()) {
// Use user name of authorized user shareType public and group if user is logged in
$this->setUserId($this->userId);
@@ -423,7 +376,6 @@ class Acl implements JsonSerializable {
$this->setPollId(0);
$this->setUserId(null);
$this->token = '';
- $this->foundByToken = false;
}
return $this;
}
@@ -436,6 +388,7 @@ class Acl implements JsonSerializable {
'userId' => $this->getUserId(),
'displayName' => $this->getDisplayName(),
'loggedIn' => $this->getLoggedIn(),
+ 'externalUser' => $this->getIsExternalUser(),
'pollId' => $this->getPollId(),
'token' => $this->getToken(),
'isOwner' => $this->getIsOwner(),
@@ -446,12 +399,10 @@ class Acl implements JsonSerializable {
'allowEdit' => $this->getAllowEdit(),
'allowSeeResults' => $this->getAllowSeeResults(),
'allowSeeUsernames' => $this->getAllowSeeUsernames(),
- 'allowSeeAllVotes' => $this->getAllowSeeAllVotes(),
'userHasVoted' => $this->getUserHasVoted(),
'groupShare' => $this->getGroupShare(),
'personalShare' => $this->getPersonalShare(),
- 'publicShare' => $this->getPublicShare(),
- 'foundByToken' => $this->getFoundByToken()
+ 'publicShare' => $this->getPublicShare()
];
}
}
diff --git a/src/js/components/Base/ParticipantsList.vue b/src/js/components/Base/ParticipantsList.vue
index dafbadd4..35f8f342 100644
--- a/src/js/components/Base/ParticipantsList.vue
+++ b/src/js/components/Base/ParticipantsList.vue
@@ -29,8 +29,7 @@
{{ t('polls','No Participants until now') }}
</h2>
<div v-if="participantsVoted.length" class="participants-list__list">
- <UserItem v-for="(participant) in participantsVoted"
- :key="participant.userId"
+ <UserItem v-for="(participant) in participantsVoted" :key="participant.userId"
v-bind="participant"
:hide-names="true"
type="user" />
diff --git a/src/js/components/Base/UserItem.vue b/src/js/components/Base/UserItem.vue
index babeadb9..b0889c50 100644
--- a/src/js/components/Base/UserItem.vue
+++ b/src/js/components/Base/UserItem.vue
@@ -26,7 +26,7 @@
class="user-item__avatar"
:menu-position="menuPosition"
:user="userId"
- :is-guest="!Boolean(getCurrentUser())"
+ :is-guest="!Boolean(getCurrentUser()) || externalUser"
:display-name="resolveDisplayName"
:is-no-user="isNoUser" />
@@ -84,6 +84,10 @@ export default {
type: Boolean,
default: false,
},
+ externalUser: {
+ type: Boolean,
+ default: false,
+ },
},
data() {
diff --git a/src/js/components/Comments/Comments.vue b/src/js/components/Comments/Comments.vue
index 18ced5a4..280d9de5 100644
--- a/src/js/components/Comments/Comments.vue
+++ b/src/js/components/Comments/Comments.vue
@@ -27,7 +27,7 @@
tag="ul">
<li v-for="(comment) in sortedList" :key="comment.id">
<div class="comment-item">
- <UserItem :user-id="comment.userId" :display-name="comment.displayName" />
+ <UserItem v-bind="comment" />
<Actions v-if="comment.userId === acl.userId">
<ActionButton icon="icon-delete" @click="deleteComment(comment)">
{{ t('polls', 'Delete comment') }}
diff --git a/src/js/components/VoteTable/VoteHeaderPublic.vue b/src/js/components/VoteTable/VoteHeaderPublic.vue
index 2d2f56f0..e60fc480 100644
--- a/src/js/components/VoteTable/VoteHeaderPublic.vue
+++ b/src/js/components/VoteTable/VoteHeaderPublic.vue
@@ -110,7 +110,7 @@ export default {
},
displayLink() {
- return (this.acl.userId !== '' && this.acl.userId !== null && this.acl.foundByToken)
+ return (this.acl.userId !== '' && this.acl.userId !== null && this.acl.token)
},
isValidUser() {
diff --git a/src/js/store/modules/poll.js b/src/js/store/modules/poll.js
index 653a55c4..ee8cbc18 100644
--- a/src/js/store/modules/poll.js
+++ b/src/js/store/modules/poll.js
@@ -89,6 +89,7 @@ const getters = {
participants.push({
userId: item.userId,
displayName: item.displayName,
+ externalUser: item.externalUser,
voted: true,
})
}
@@ -98,6 +99,7 @@ const getters = {
participants.push({
userId: state.acl.userId,
displayName: state.acl.displayName,
+ externalUser: state.externalUser,
voted: false,
})
}
@@ -113,6 +115,7 @@ const getters = {
participantsVoted.push({
userId: item.userId,
displayName: item.displayName,
+ externalUser: item.externalUser,
})
}
}
diff --git a/src/js/store/modules/subModules/acl.js b/src/js/store/modules/subModules/acl.js
index 5c7be050..1959b071 100644
--- a/src/js/store/modules/subModules/acl.js
+++ b/src/js/store/modules/subModules/acl.js
@@ -26,13 +26,12 @@ const defaultAcl = () => {
accessLevel: '',
allowComment: false,
allowEdit: false,
- allowSeeAllVotes: false,
allowSeeResults: false,
allowSeeUsernames: false,
allowView: false,
allowVote: false,
displayName: '',
- foundByToken: false,
+ externalUser: false,
groupShare: false,
isAdmin: false,
isOwner: false,
diff --git a/src/js/store/modules/subModules/votes.js b/src/js/store/modules/subModules/votes.js
index 012e7d72..8eaa9280 100644
--- a/src/js/store/modules/subModules/votes.js
+++ b/src/js/store/modules/subModules/votes.js
@@ -117,7 +117,7 @@ const actions = {
set(context, payload) {
let endPoint = 'apps/polls/vote/set'
- if (context.rootState.poll.acl.foundByToken) {
+ if (context.rootState.poll.acl.token) {
endPoint = endPoint.concat('/s')
}
return axios.post(generateUrl(endPoint), {