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--appinfo/routes.php4
-rw-r--r--css/list.scss240
-rw-r--r--js/start.js66
-rw-r--r--lib/Controller/PageController.php27
-rw-r--r--templates/main.tmpl.php286
5 files changed, 4 insertions, 619 deletions
diff --git a/appinfo/routes.php b/appinfo/routes.php
index 13fecaa5..83655694 100644
--- a/appinfo/routes.php
+++ b/appinfo/routes.php
@@ -24,7 +24,6 @@
return [
'routes' => [
['name' => 'page#index', 'url' => '/', 'verb' => 'GET'],
- ['name' => 'page#index_old', 'url' => '/list', 'verb' => 'GET'],
['name' => 'page#goto_poll', 'url' => '/poll/{hash}', 'verb' => 'GET'],
['name' => 'page#create_poll', 'url' => '/new', 'verb' => 'GET'],
@@ -32,8 +31,6 @@ return [
['name' => 'page#clone_poll', 'url' => '/clone/{hash}', 'verb' => 'GET'],
['name' => 'page#delete_poll', 'url' => '/delete', 'verb' => 'POST'],
- ['name' => 'page#update_poll', 'url' => '/update', 'verb' => 'POST'],
- ['name' => 'page#insert_poll', 'url' => '/insert', 'verb' => 'POST'],
['name' => 'page#insert_vote', 'url' => '/insert/vote', 'verb' => 'POST'],
['name' => 'page#insert_comment', 'url' => '/insert/comment', 'verb' => 'POST'],
['name' => 'page#search', 'url' => '/search', 'verb' => 'POST'],
@@ -48,6 +45,7 @@ return [
['name' => 'api#get_event', 'url' => '/get/event/{pollId}', 'verb' => 'GET'],
['name' => 'api#remove_poll', 'url' => '/remove/poll', 'verb' => 'POST'],
['name' => 'api#get_polls', 'url' => '/get/polls', 'verb' => 'GET'],
+
['name' => 'system#get_site_users_and_groups', 'url' => '/get/siteusers', 'verb' => 'POST'],
['name' => 'system#get_system', 'url' => '/get/system', 'verb' => 'GET']
]
diff --git a/css/list.scss b/css/list.scss
deleted file mode 100644
index 6d87c18d..00000000
--- a/css/list.scss
+++ /dev/null
@@ -1,240 +0,0 @@
-@import 'colors.scss';
-
-$row-padding: 15px;
-$table-padding: 4px;
-
-$date-width: 120px;
-$participants-width: 95px;
-$group-2-2-width: max($date-width, $participants-width);
-
-$owner-width: 140px;
-$access-width: 140px;
-$group-2-1-width: max($access-width, $date-width);
-$group-2-width: $owner-width + $group-2-1-width + $group-2-2-width;
-
-$action-width: 44px;
-$thumbnail-width: 44px;
-$thumbnail-icon-width: 32px;
-$name-width: 150px;
-$description-width: 150px;
-$group-1-1-width: max($name-width, $description-width);
-$group-1-width: $thumbnail-width + $group-1-1-width + $action-width;
-
-$group-master-width: max($group-1-width, $group-2-width);
-
-$mediabreak-1: ($group-1-width + $owner-width + $access-width + $date-width + $date-width + $participants-width + $row-padding * 2);
-$mediabreak-2: ($group-1-width + $group-2-width + $row-padding * 2);
-$mediabreak-3: $group-1-width + $owner-width + max($group-2-1-width, $group-2-2-width) + $row-padding *2 ;
-
-.table {
- width: 100%;
-}
-
-#emptycontent {
- .icon-polls {
- background-color: black;
- -webkit-mask: url('../img/app.svg') no-repeat 50% 50%;
- mask: url('../img/app.svg') no-repeat 50% 50%;
- }
-}
-
-.table-row {
- display: flex;
- width: 100%;
- padding-left: $row-padding;
- padding-right: $row-padding;
-
- line-height: 2em;
- transition: background-color 0.3s ease;
- background-color: var(--color-main-background);
- min-height: 4em;
- border-bottom: 1px solid var(--color-border);
-
- &.table-header {
- .name, .description {
- padding-left: ($thumbnail-width + $table-padding *2);
- }
- .owner {
- padding-left: 6px;
- }
- }
-
- &.table-body {
- &:hover, &:focus, &:active, &.mouseOver {
- transition: background-color 0.3s ease;
- background-color: var(--color-background-dark);
- }
- .flex-column.owner {
- display: flex;
- .avatardiv {
- margin-right: 4px;
- }
- }
- .icon-more {
- right: 14px;
- opacity: 0.3;
- cursor: pointer;
- height: 44px;
- width: 44px;
- }
-
- .symbol {
- padding: 2px;
- }
-
- }
-
- &.table-header {
- opacity: 0.5;
- }
-}
-
-.wrapper {
- display: flex;
- align-items: center;
- position: relative;
- div {
- }
-}
-
-
-.flex-column {
- padding: 0 $table-padding;
- overflow: hidden;
- white-space: nowrap;
- text-overflow: ellipsis;
- align-items: center;
- min-height: 16px;
-}
-
-.name {
- width: $name-width;
-}
-
-.description {
- width: $description-width;
- color: var(--color-text-maxcontrast);
- }
-
-.owner {
- width: $owner-width;
-}
-
-.access {
- width: $access-width;
-}
-
-.created {
- width: $date-width;
-}
-
-.expiry {
- width: $date-width;
- &.expired {
- color: red;
- }
-}
-
-.participants{
- width: $participants-width;
- div {
- &.partic_voted {
- &.icon-partic_yes {
- background-image: var(--icon-yes);
- }
- &.icon-partic_no {
- background-image: var(--icon-no);
- }
- }
-
- &.partic_commented {
- &.icon-commented_yes {
- background-image: var(--icon-comment-yes);
- }
- &.icon-commented_no {
- background-image: var(--icon-comment-no);
- }
- }
- }
-
-}
-
-.actions {
- width: $action-width;
- position: relative;
- overflow: initial;
-}
-
-.thumbnail {
- background-size: $thumbnail-icon-width;
- width: $thumbnail-width;
- height: $thumbnail-width;
- padding-right: $table-padding;
- background-repeat: no-repeat;
- background-position: center;
- &.progress, &.endless {
- &.partic_yes {
- background-image: url('../img/open-voted-vote.svg');
- }
- &.partic_no {
- background-image: url('../img/open-unvoted-vote.svg');
- }
- }
- &.expired {
- &.partic_yes {
- background-image: url('../img/expired-voted-vote.svg');
- }
- &.partic_no {
- background-image: url('../img/expired-unvoted-vote.svg');
- }
- }
-}
-
-.options, .participants {
- display: flex;
- flex-direction: row;
-}
-
-.group-1, .group-1-1, .group-master {
- flex-grow: 1;
-}
-
-.group-1-1 {
- flex-direction: column;
- width: $group-1-1-width;
- > div {
- width: 100%;
- }
-}
-
-@media all and (max-width: ($mediabreak-1) ) {
- .group-1 {
- width: $group-1-width;
- }
- .group-2-1, .group-2-2 {
- flex-direction: column;
- }
-
- .access, .created {
- width: $group-2-1-width;;
- }
- .expiry, .participants {
- width: $group-2-2-width;;
- }
-}
-
-@media all and (max-width: ($mediabreak-2) ) {
- .table-row {
- padding: 0;
- }
-
- .group-2-1 {
- display: none;
- }
-}
-
-@media all and (max-width: ($mediabreak-3) ) {
- .group-2 {
- display: none;
- }
-}
diff --git a/js/start.js b/js/start.js
deleted file mode 100644
index c13594b7..00000000
--- a/js/start.js
+++ /dev/null
@@ -1,66 +0,0 @@
-/* global Clipboard, navigator, deletePoll */
-$(document).ready(function () {
- var clipboard = new Clipboard('.copy-link');
- clipboard.on('success', function (e) {
- var $input = $(e.trigger);
- $input.tooltip('hide')
- .attr('data-original-title', t('core', 'Copied!'))
- .tooltip('fixTitle')
- .tooltip({placement: 'bottom', trigger: 'manual'})
- .tooltip('show');
- _.delay(function () {
- $input.tooltip('hide');
- if (OC.Share.Social.Collection.size() === 0) {
- $input.attr('data-original-title', t('core', 'Copy'))
- .tooltip('fixTitle');
- } else {
- $input.tooltip('destroy');
- }
- }, 3000);
- });
-
- clipboard.on('error', function (e) {
- var $input = $(e.trigger);
- var actionMsg = '';
- if (/iPhone|iPad/i.test(navigator.userAgent)) {
- actionMsg = t('core', 'Not supported!');
- } else if (/Mac/i.test(navigator.userAgent)) {
- actionMsg = t('core', 'Press ?-C to copy.');
- } else {
- actionMsg = t('core', 'Press Ctrl-C to copy.');
- }
-
- $input.tooltip('hide')
- .attr('data-original-title', actionMsg)
- .tooltip('fixTitle')
- .tooltip({placement: 'bottom', trigger: 'manual'})
- .tooltip('show');
- _.delay(function () {
- $input.tooltip('hide');
- if (OC.Share.Social.Collection.size() === 0) {
- $input.attr('data-original-title', t('core', 'Copy'))
- .tooltip('fixTitle');
- } else {
- $input.tooltip("destroy");
- }
- }, 3000);
- });
-
- $('.alt-tooltip').tooltip();
-
- $('.delete-poll').click(function () {
- deletePoll(this);
- });
-
- $('.table-body .avatardiv').each(function (i, obj) {
- $(obj).avatar(obj.title, 32);
- });
-
- $('.popupmenu').each(function () {
- OC.registerMenu($('#expand_' + $(this).attr('value')), $('#expanddiv_' + $(this).attr('value')) );
- });
-
- $('.copy_link').click(function () {
- window.prompt(t('polls','Copy to clipboard: Ctrl+C, Enter'), $(this).data('url'));
- });
-});
diff --git a/lib/Controller/PageController.php b/lib/Controller/PageController.php
index 457ca668..32eb2c2b 100644
--- a/lib/Controller/PageController.php
+++ b/lib/Controller/PageController.php
@@ -131,31 +131,10 @@ class PageController extends Controller {
}
/**
- * @NoAdminRequired
- * @NoCSRFRequired
- */
- public function indexOld() {
- $polls = $this->eventMapper->findAllForUserWithInfo($this->userId);
- $comments = $this->commentMapper->findDistinctByUser($this->userId);
- $votes = $this->voteMapper->findDistinctByUser($this->userId);
- $response = new TemplateResponse('polls', 'main.tmpl', [
- 'polls' => $polls,
- 'comments' => $comments,
- 'votes' => $votes,
- 'userId' => $this->userId,
- 'userMgr' => $this->userMgr,
- 'urlGenerator' => $this->urlGenerator
- ]);
- $csp = new ContentSecurityPolicy();
- $response->setContentSecurityPolicy($csp);
- return $response;
- }
-
- /**
* @NoAdminRequired
* @NoCSRFRequired
*/
- public function createPoll() {
+ public function index() {
return new TemplateResponse('polls', 'polls.tmpl',
['urlGenerator' => $this->urlGenerator]);
}
@@ -164,7 +143,7 @@ class PageController extends Controller {
* @NoAdminRequired
* @NoCSRFRequired
*/
- public function clonePoll() {
+ public function createPoll() {
return new TemplateResponse('polls', 'polls.tmpl',
['urlGenerator' => $this->urlGenerator]);
}
@@ -173,7 +152,7 @@ class PageController extends Controller {
* @NoAdminRequired
* @NoCSRFRequired
*/
- public function index() {
+ public function clonePoll() {
return new TemplateResponse('polls', 'polls.tmpl',
['urlGenerator' => $this->urlGenerator]);
}
diff --git a/templates/main.tmpl.php b/templates/main.tmpl.php
deleted file mode 100644
index a0dd594f..00000000
--- a/templates/main.tmpl.php
+++ /dev/null
@@ -1,286 +0,0 @@
-<?php
- /**
- * @copyright Copyright (c) 2017 Vinzenz Rosenkranz <vinzenz.rosenkranz@gmail.com>
- *
- * @author Vinzenz Rosenkranz <vinzenz.rosenkranz@gmail.com>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
- use OCP\User; //To do: replace according to API
- use OCP\Util;
- use OCP\Template;
- use OCP\IGroupManager;
-
-
- Util::addStyle('polls', 'list');
- Util::addScript('polls', 'app');
- Util::addScript('polls', 'start');
-
- $userId = $_['userId'];
- /** @var \OCP\IUserManager $userMgr */
- $userMgr = $_['userMgr'];
- /** @var \OCP\IURLGenerator $urlGenerator */
- $urlGenerator = $_['urlGenerator'];
- /** @var \OCA\Polls\Db\Event[] $polls */
- $polls = $_['polls'];
- $adminMode = (\OC::$server->getGroupManager()->isAdmin($userId))
-?>
-
- <div id="app-content">
- <div id="controls">
- <div class="breadcrumb">
- <div class="crumb svg crumbhome">
- <a class="icon-home" href="<?php p($urlGenerator->linkToRoute('polls.page.index')); ?>"> Home </a>
- </div>
- </div>
- <div class="actions creatable" style="">
- <a href="<?php p($urlGenerator->linkToRoute('polls.page.create_poll')); ?>" class="button new">
- <span class="symbol icon-add"></span><span class="hidden-visually">Neu</span>
- </a>
- <input class="stop icon-close" style="display:none" value="" type="button">
- </div>
- </div>
-
- <?php if (count($_['polls']) === 0) : ?>
- <div id="emptycontent" class="">
- <div class="icon-polls"></div>
- <h2><?php p($l->t('No existing polls.')); ?></h2>
- <a href="<?php p($urlGenerator->linkToRoute('polls.page.create_poll')); ?>" class="button new">
- <span><?php p($l->t('Click here to add a poll')); ?></span>
- </a>
- </div>
- <?php else : ?>
-
- <div class="table main-container has-controls">
- <div class ="table-row table-header">
- <div class="wrapper group-master">
- <div class="wrapper group-1">
- <div class="wrapper group-1-1">
- <div class="flex-column name"> <?php p($l->t('Title')); ?></div>
- </div>
- <div class="wrapper group-1-2">
- <div class="flex-column actions"></div>
- </div>
- </div>
- <div class="wrapper group-2">
- <div class="flex-column owner"> <?php p($l->t('By')); ?></div>
- <div class="wrapper group-2-1">
- <div class="flex-column access"> <?php p($l->t('Access')); ?></div>
- <div class="flex-column created"> <?php p($l->t('Created')); ?></div>
- </div>
- <div class="wrapper group-2-2">
- <div class="flex-column expiry"> <?php p($l->t('Expires')); ?></div>
- <div class="flex-column participants"> <?php p($l->t('participated')); ?></div>
- </div>
- </div>
- </div>
- </div>
-
- <?php foreach ($polls as $poll) : ?>
-
- <?php
- if (!userHasAccess($poll, $userId)) {
- continue;
- }
- // direct url to poll
- $pollUrl = $urlGenerator->linkToRouteAbsolute('polls.page.goto_poll', array('hash' => $poll->getHash()));
- $owner = $poll->getOwner();
-
- $expiry_style = '';
- $participated = $_['votes'];
- $participated_class = 'no';
- $participated_title = 'You did not vote';
- $participated_count = count($participated);
-
- $comments = $_['comments'];
- $commented_class = 'no';
- $commented_title = 'You did not comment';
- $commented_count = count($comments);
-
- $owner = \OC_User::getDisplayName($owner);
-
-
- $timestamp_style = '';
- $expiry_style = ' endless';
- $expiry_date = $l->t('Never');
-
- if ($poll->getExpire() !== null) {
- $expiry_date = Template::relative_modified_date(strtotime($poll->getExpire())); // does not work, because relative_modified_date seems not to recognise future time diffs
- $expiry_style = ' progress';
- $timestamp_style = ' live-relative-timestamp';
- if (date('U') > strtotime($poll->getExpire())) {
- $expiry_date = Template::relative_modified_date(strtotime($poll->getExpire()));
- $expiry_style = ' expired';
- }
- }
-
- for ($i = 0; $i < count($participated); $i++) {
- if ($poll->getId() === $participated[$i]->getPollId()) {
- $participated_class = 'yes';
- $participated_title = 'You voted in this poll';
- array_splice($participated, $i, 1);
- break;
- }
- }
-
- for ($i = 0; $i < count($comments); $i++) {
- if ($poll->getId() === $comments[$i]->getPollId()) {
- $commented_class = 'yes';
- $commented_title = 'You commented this poll';
- array_splice($comments, $i, 1);
- break;
- }
- }
- ?>
- <div class="table-row table-body">
- <div class="wrapper group-master">
- <div class="wrapper group-1">
- <div class="thumbnail <?php p($expiry_style . ' commented_' . $commented_class . ' partic_' . $participated_class); ?>"></div><!-- Image to display the status or type of poll -->
- <a href="<?php p($pollUrl); ?>" class="wrapper group-1-1">
- <div class="flex-column name"> <?php p($poll->getTitle()); ?></div>
- <div class="flex-column description"> <?php p($poll->getDescription()); ?></div>
- </a>
- <div class="flex-column actions">
- <div class="icon-more popupmenu" value="<?php p($poll->getId()); ?>" id="expand_<?php p($poll->getId()); ?>"></div>
- <div class="popovermenu bubble menu hidden" id="expanddiv_<?php p($poll->getId()); ?>">
- <ul>
- <li>
- <a class="menuitem alt-tooltip copy-link has-tooltip action permanent" data-toggle="tooltip" data-clipboard-text="<?php p($pollUrl); ?>" title="<?php p($l->t('Click to get link')); ?>" href="#">
- <span class="icon-clippy"></span>
- <span>
- <?php p($l->t('Copy Link')); ?>
- </span>
- </a>
- </li>
- <?php if (($poll->getOwner() === $userId) || $adminMode) : ?>
- <li>
- <a id="id_del_<?php p($poll->getId()); ?>" class="menuitem alt-tooltip delete-poll action permanent" data-value="<?php p($poll->getTitle()); ?>" href="#">
- <span class="icon-delete"></span>
- <span>
- <?php p($l->t('Delete poll'));
- if (($poll->getOwner() !== $userId) && $adminMode) {
- p(' (') & p($l->t('as admin')) & p(')');
- }
- ?>
- </span>
- </a>
- </li>
- <li>
- <a id="id_edit_<?php p($poll->getId()); ?>" class="menuitem action permanent" href="<?php p($urlGenerator->linkToRoute('polls.page.edit_poll', ['hash' => $poll->getHash()])); ?>">
- <span class="icon-rename"></span>
- <span>
- <?php p($l->t('Edit poll'));
- if (($poll->getOwner() !== $userId) && $adminMode) {
- p(' (') & p($l->t('as admin')) & p(')');
- }
- ?>
- </span>
- </a>
- </li>
- <?php endif; ?>
- </ul>
-
- </div>
- </div>
- </div>
- <div class="wrapper group-2">
- <div class="flex-column owner">
- <div class="avatardiv" title="<?php p($poll->getOwner()); ?>" style="height: 32px; width: 32px;"></div>
- <div class="name-cell"><?php p(\OC_User::getDisplayName($owner)); ?></div>
- </div>
- <div class="wrapper group-2-1">
- <div class="flex-column access"><?php p($l->t($poll->getAccess())); ?></div>
- <div class="flex-column created has-tooltip live-relative-timestamp" data-timestamp="<?php p(strtotime($poll->getCreated()) * 1000); ?>" data-value="<?php p($poll->getCreated()); ?>"><?php p(Template::relative_modified_date(strtotime($poll->getCreated()))); ?></div>
- </div>
- <div class="wrapper group-2-2">
- <div class="flex-column has-tooltip expiry<?php p($expiry_style . $timestamp_style); ?>" data-timestamp="<?php p(strtotime($poll->getExpire()) * 1000); ?>" data-value="<?php p($poll->getExpire()); ?>"> <?php p($expiry_date); ?></div>
- <div class="flex-column participants">
- <div class="symbol alt-tooltip partic_voted icon-<?php p($participated_class); ?>" title="<?php p($participated_title); ?>"></div>
- <div class="symbol alt-tooltip partic_commented icon-comment-<?php p($commented_class); ?>" title="<?php p($commented_title); ?>"></div>
- </div>
- </div>
- </div>
- </div>
- </div>
- <?php endforeach; ?>
- </div>
- </div>
- <form id="form_delete_poll" name="form_delete_poll" action="<?php p($urlGenerator->linkToRoute('polls.page.delete_poll')); ?>" method="POST"></form>
-<?php endif; ?>
-
-
-<?php
-// ---- helper functions ----
-// from spreed.me
-/**
- * @param string $userId
- * @return \OCP\IGroup[]
- */
-function getGroups($userId) {
- if (class_exists('\OC_Group')) {
- // Nextcloud <= 11, ownCloud
- return \OC_Group::getUserGroups($userId);
- }
- // Nextcloud >= 12
- $groups = \OC::$server->getGroupManager()->getUserGroups(\OC::$server->getUserSession()->getUser());
- return array_map(function($group) {
- return $group->getGID();
- }, $groups);
-}
-
-/**
- * @param OCA\Polls\Db\Event $poll
- * @param string $userId
- * @return boolean
- */
-function userHasAccess(OCA\Polls\Db\Event $poll, $userId) {
- if ($poll === null) {
- return false;
- }
- $access = $poll->getAccess();
- if (!User::isLoggedIn()) {
- return false;
- }
- if ($access === 'public' || $access === 'hidden' || $access === 'registered') {
- return true;
- }
- if ($poll->getOwner() === $userId) {
- return true;
- }
-
- $user_groups = getGroups($userId);
- $arr = explode(';', $access);
-
- foreach ($arr as $item) {
- if (strpos($item, 'group_') === 0) {
- $grp = substr($item, 6);
- foreach ($user_groups as $user_group) {
- if ($user_group === $grp) {
- return true;
- }
- }
- } else if (strpos($item, 'user_') === 0) {
- $usr = substr($item, 5);
- if ($usr === $userId) {
- return true;
- }
- }
- }
- return false;
-}
-?>