* * @author Vinzenz Rosenkranz * * @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 . * */ use OCP\User; //To do: replace according to API \OCP\Util::addStyle('polls', 'main'); \OCP\Util::addStyle('polls', 'list'); \OCP\Util::addScript('polls', 'app'); \OCP\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']; ?>

t('No existing polls.')); ?>

t('Title')); ?>
t('By')); ?>
t('Access')); ?>
t('Created')); ?>
t('Expires')); ?>
t('participated')); ?>
linkToRouteAbsolute('polls.page.goto_poll', array('hash' => $poll->getHash())); $owner = $poll->getOwner(); $expiry_style = ''; $participated = $_['votes']; $participated_class = 'partic_no'; $participated_title = 'You did not vote'; $participated_count = count($participated); $comments = $_['comments']; $commented_class = 'commented_no'; $commented_title = 'You did not comment'; $commented_count = count($comments); if ($owner === $userId) { $owner = $l->t('Yourself'); } $timestamp_style = ''; $expiry_style = ' endless'; $expiry_date = $l->t('Never'); if ($poll->getExpire() !== null) { $expiry_date = \OCP\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 = \OCP\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 = 'partic_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 = 'commented_yes'; $commented_title = 'You commented this poll'; array_splice($comments, $i, 1); break; } } ?>
t($poll->getAccess())); ?>
getCreated()))); ?>
= 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(); $owner = $poll->getOwner(); if (!User::isLoggedIn()) { return false; } if ($access === 'public' || $access === 'hidden' || $access === 'registered') { return true; } if ($owner === $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; } ?>