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:
authorRené Gieling <github@dartcafe.de>2017-11-10 15:21:53 +0300
committerGitHub <noreply@github.com>2017-11-10 15:21:53 +0300
commitddeaba716daa905861ff79dcec1010e25f79df75 (patch)
tree77f99db90a751fe51d1c753878ecf38f14d62c69 /templates
parent77a192800165d714fd54e4fd29bfdf7918aa4f2b (diff)
parentb8c6b4d84069c2e80aa93d6c6b6f22cca2394db2 (diff)
Merge branch 'develop' into css-fixes
Diffstat (limited to 'templates')
-rw-r--r--templates/create.tmpl.php43
-rw-r--r--templates/goto.tmpl.php110
-rw-r--r--templates/main.tmpl.php76
3 files changed, 121 insertions, 108 deletions
diff --git a/templates/create.tmpl.php b/templates/create.tmpl.php
index 77e9b195..fa022046 100644
--- a/templates/create.tmpl.php
+++ b/templates/create.tmpl.php
@@ -28,20 +28,24 @@
\OCP\Util::addScript('polls', 'vendor/jquery.datetimepicker.full.min');
$userId = $_['userId'];
+ /** @var \OCP\IUserManager $userMgr */
$userMgr = $_['userMgr'];
+ /** @var \OCP\IURLGenerator $urlGenerator */
$urlGenerator = $_['urlGenerator'];
- $isUpdate = isset($_['poll']) && $_['poll'] != null;
+ $isUpdate = isset($_['poll']) && $_['poll'] !== null;
$isAnonymous = false;
$hideNames = false;
if ($isUpdate) {
+ /** @var OCA\Polls\Db\Event $poll */
$poll = $_['poll'];
$isAnonymous = $poll->getIsAnonymous();
$hideNames = $isAnonymous && $poll->getFullAnonymous();
+ /** @var OCA\Polls\Db\Date[]|OCA\Polls\Db\Text[] $dates */
$dates = $_['dates'];
$chosen = '[';
foreach ($dates as $d) {
- if ($poll->getType() == '0') {
+ if ($poll->getType() === 0) {
$chosen .= strtotime($d->getDt());
} else {
$chosen .= '"' . $d->getText() . '"';
@@ -52,14 +56,15 @@
$chosen .= ']';
$title = $poll->getTitle();
$desc = $poll->getDescription();
- if ($poll->getExpire() != null) {
+ if ($poll->getExpire() !== null) {
$expireTs = strtotime($poll->getExpire()) - 60*60*24; //remove one day, which has been added to expire at the end of a day
$expireStr = date('d.m.Y', $expireTs);
}
$access = $poll->getAccess();
$accessTypes = $access;
- if ( $access != 'registered'
- && $access != 'hidden' && $access != 'public'
+ if (
+ $access !== 'registered'
+ && $access !== 'hidden' && $access !== 'public'
) {
$access = 'select';
}
@@ -73,7 +78,7 @@
<div id="breadcrump">
<div class="crumb svg" data-dir="/">
<a href="<?php p($urlGenerator->linkToRoute('polls.page.index')); ?>">
- <img class="svg" src="<?php print_unescaped(OCP\image_path("core", "places/home.svg")); ?>" alt="Home">
+ <img class="svg" src="<?php print_unescaped(\OCP\Template::image_path('core', 'places/home.svg')); ?>" alt="Home">
</a>
</div>
<div class="crumb svg last">
@@ -87,7 +92,7 @@
</div>
</div>
</div>
-
+
<?php if ($isUpdate): ?>
<form name="finish_poll" action="<?php p($urlGenerator->linkToRoute('polls.page.update_poll')); ?>" method="POST">
<input type="hidden" name="pollId" value="<?php p($poll->getId()); ?>" />
@@ -100,7 +105,7 @@
<header class="row">
</header>
-
+
<div class="new_poll row">
<div class="col-50">
<label for="pollTitle" class="input_title"><?php p($l->t('Title')); ?></label>
@@ -110,16 +115,16 @@
<label class="input_title"><?php p($l->t('Access')); ?></label>
- <input type="radio" name="accessType" id="private" value="registered" class="radio" <?php if (!$isUpdate || $access == 'registered') print_unescaped('checked'); ?> />
+ <input type="radio" name="accessType" id="private" value="registered" class="radio" <?php if (!$isUpdate || $access === 'registered') print_unescaped('checked'); ?> />
<label for="private"><?php p($l->t('Registered users only')); ?></label>
- <input type="radio" name="accessType" id="hidden" value="hidden" class="radio" <?php if ($isUpdate && $access == 'hidden') print_unescaped('checked'); ?> />
+ <input type="radio" name="accessType" id="hidden" value="hidden" class="radio" <?php if ($isUpdate && $access === 'hidden') print_unescaped('checked'); ?> />
<label for="hidden"><?php p($l->t('hidden')); ?></label>
- <input type="radio" name="accessType" id="public" value="public" class="radio" <?php if ($isUpdate && $access == 'public') print_unescaped('checked'); ?> />
+ <input type="radio" name="accessType" id="public" value="public" class="radio" <?php if ($isUpdate && $access === 'public') print_unescaped('checked'); ?> />
<label for="public"><?php p($l->t('Public access')); ?></label>
- <input type="radio" name="accessType" id="select" value="select" class="radio" <?php if ($isUpdate && $access == 'select') print_unescaped('checked'); ?>>
+ <input type="radio" name="accessType" id="select" value="select" class="radio" <?php if ($isUpdate && $access === 'select') print_unescaped('checked'); ?>>
<label for="select"><?php p($l->t('Select')); ?></label>
<span id="id_label_select">...</span>
@@ -135,7 +140,7 @@
</div>
</div>
- <input type="hidden" name="accessValues" id="accessValues" value="<?php if ($isUpdate && $access == 'select') p($accessTypes) ?>" />
+ <input type="hidden" name="accessValues" id="accessValues" value="<?php if ($isUpdate && $access === 'select') p($accessTypes) ?>" />
<input id="isAnonymous" name="isAnonymous" type="checkbox" class="checkbox" <?php $isAnonymous ? print_unescaped('value="true" checked') : print_unescaped('value="false"'); ?> />
<label for="isAnonymous" class="input_title"><?php p($l->t('Anonymous')) ?></label>
@@ -145,28 +150,28 @@
<label for="hideNames" class="input_title"><?php p($l->t('Hide user names for admin')) ?></label>
</div>
- <input id="id_expire_set" name="check_expire" type="checkbox" class="checkbox" <?php ($isUpdate && $poll->getExpire() != null) ? print_unescaped('value="true" checked') : print_unescaped('value="false"'); ?> />
+ <input id="id_expire_set" name="check_expire" type="checkbox" class="checkbox" <?php ($isUpdate && $poll->getExpire() !== null) ? print_unescaped('value="true" checked') : print_unescaped('value="false"'); ?> />
<label for="id_expire_set" class="input_title"><?php p($l->t('Expires')); ?></label>
<div class="input-group" id="expiration">
- <input id="id_expire_date" type="text" required="" <?php (!$isUpdate || $poll->getExpire() == null) ? print_unescaped('disabled="true"') : print_unescaped('value="' . $expireStr . '"'); ?> name="expire_date_input" />
+ <input id="id_expire_date" type="text" required="" <?php (!$isUpdate || $poll->getExpire() === null) ? print_unescaped('disabled="true"') : print_unescaped('value="' . $expireStr . '"'); ?> name="expire_date_input" />
</div>
</div>
<div class="col-50">
- <input type="radio" name="pollType" id="event" value="event" class="radio" <?php if (!$isUpdate || $poll->getType() == '0') print_unescaped('checked'); ?> />
+ <input type="radio" name="pollType" id="event" value="event" class="radio" <?php if (!$isUpdate || $poll->getType() === 0) print_unescaped('checked'); ?> />
<label for="event"><?php p($l->t('Event schedule')); ?></label>
<!-- TODO texts to db -->
- <input type="radio" name="pollType" id="text" value="text" class="radio" <?php if ($isUpdate && $poll->getType() == '1') print_unescaped('checked'); ?>>
+ <input type="radio" name="pollType" id="text" value="text" class="radio" <?php if ($isUpdate && $poll->getType() === 1) print_unescaped('checked'); ?>>
<label for="text"><?php p($l->t('Text based')); ?></label>
- <div id="date-select-container" <?php if ($isUpdate && $poll->getType() == '1') print_unescaped('style="display:none;"'); ?> >
+ <div id="date-select-container" <?php if ($isUpdate && $poll->getType() === 1) print_unescaped('style="display:none;"'); ?> >
<label for="datetimepicker" class="input_title"><?php p($l->t('Dates')); ?></label>
<input id="datetimepicker" type="text" />
<table id="selected-dates-table" class="choices">
</table>
</div>
- <div id="text-select-container" <?php if(!$isUpdate || $poll->getType() == '0') print_unescaped('style="display:none;"'); ?> >
+ <div id="text-select-container" <?php if(!$isUpdate || $poll->getType() === 0) print_unescaped('style="display:none;"'); ?> >
<label for="text-title" class="input_title"><?php p($l->t('Text item')); ?></label>
<div class="input-group">
<input type="text" id="text-title" placeholder="<?php print_unescaped('Insert text...'); ?>" />
diff --git a/templates/goto.tmpl.php b/templates/goto.tmpl.php
index 4b741b83..5bdb6428 100644
--- a/templates/goto.tmpl.php
+++ b/templates/goto.tmpl.php
@@ -32,18 +32,25 @@
\OCP\Util::addStyle('polls', 'app-navigation-simulation');
\OCP\Util::addScript('polls', 'app');
\OCP\Util::addScript('polls', 'vote');
-
+
$userId = $_['userId'];
+ /** @var \OCP\IUserManager $userMgr */
$userMgr = $_['userMgr'];
+ /** @var \OCP\IURLGenerator $urlGenerator */
$urlGenerator = $_['urlGenerator'];
+ /** @var \OCP\IAvatarManager $avaMgr */
$avaMgr = $_['avatarManager'];
-
+ /** @var \OCA\Polls\Db\Event $poll */
$poll = $_['poll'];
+ /** @var OCA\Polls\Db\Date[]|OCA\Polls\Db\Text[] $dates */
$dates = $_['dates'];
+ /** @var OCA\Polls\Db\Participation[]|OCA\Polls\Db\ParticipationText[] $votes */
$votes = $_['votes'];
+ /** @var \OCA\Polls\Db\Comment[] $comments */
$comments = $_['comments'];
- $isAnonymous = $poll->getIsAnonymous() && $userId != $poll->getOwner();
+ $isAnonymous = $poll->getIsAnonymous() && $userId !== $poll->getOwner();
$hideNames = $poll->getIsAnonymous() && $poll->getFullAnonymous();
+ /** @var \OCA\Polls\Db\Notification $notification */
$notification = $_['notification'];
if ($poll->getExpire() === null) {
@@ -51,27 +58,28 @@
} else {
$expired = time() > strtotime($poll->getExpire());
}
-
+
if ($expired) {
- $statusClass = "expired-vote";
+ $statusClass = 'expired-vote';
} else {
- $statusClass = "open-vote";
+ $statusClass = 'open-vote';
if (time() < strtotime($poll->getExpire())) {
- $statusClass = $statusClass . ' endless';
+ $statusClass .= ' endless';
}
}
- if ($poll->getType() == '0') {
+ if ($poll->getType() === 0) {
$pollType = 'date-poll';
$pollTypeClass = 'date-poll';
- } else if ($poll->getType() == '1') {
+ } else if ($poll->getType() === 1) {
$pollType = 'option-poll';
$pollTypeClass = 'option-poll';
}
- if ( $poll->getDescription() != null
- && $poll->getDescription() != ''
+ if (
+ $poll->getDescription() !== null &&
+ $poll->getDescription() !== ''
) {
$description = nl2br($poll->getDescription());
} else {
@@ -80,7 +88,7 @@
// init array for counting 'yes'-votes for each date
$total = array();
- for ($i = 0 ; $i < count($dates) ; $i++) {
+ for ($i = 0; $i < count($dates); $i++) {
$total['yes'][$i] = 0;
$total['no'][$i] = 0;
}
@@ -95,7 +103,7 @@
<?php if (User::isLoggedIn()) : ?>
<div class="crumb svg" data-dir="/">
<a href="<?php p($urlGenerator->linkToRoute('polls.page.index')); ?>">
- <img class="svg" src="<?php print_unescaped(OCP\image_path("core", "places/home.svg")); ?>"" alt="Home">
+ <img class="svg" src="<?php print_unescaped(\OCP\Template::image_path('core', 'places/home.svg')); ?>" alt="Home">
</a>
</div>
<?php endif; ?>
@@ -104,8 +112,8 @@
</div>
</div>
-
-
+
+
<a id="switchDetails" class="button details" title="Details" href="#">
<span class="symbol icon-settings"></span>
<?php if (count($comments)) : ?>
@@ -113,12 +121,12 @@
<?php else: ?>
<div id="comment-counter" class="badge no-comments"><?php p(count($comments)) ?></div>
<?php endif; ?>
- </a>
+ </a>
</div>
-
+
<div id="votings" class="main-container">
<div class="wordwrap description"><span><?php p($description); ?></span>
- <?php
+ <?php
if ($expired) {
print_unescaped('<span class="' . $statusClass . '">' . $l->t('The poll expired on %s. Voting is disabled, but you can still comment.', array(date('d.m.Y H:i', strtotime($poll->getExpire())))) . '</span>');
}?>
@@ -127,10 +135,10 @@
<ul class="row header" >
<?php
foreach ($dates as $el) {
- if ($poll->getType() == '0') {
+ if ($poll->getType() === 0) {
$timestamp = strtotime($el->getDt());
print_unescaped('<li id="slot_' . $el->getId() . '" title="' . $el->getDt() . ' ' . date_default_timezone_get() . '" class="column vote time" data-timestamp="' . $timestamp . '"data-value-utc="' . $el->getDt() . '">');
-
+
print_unescaped(' <div class="date-box column">');
print_unescaped(' <div class="month">' . $l->t(date('M', $timestamp)) . '</div>');
print_unescaped(' <div class="day">' . date('j', $timestamp) . '</div>');
@@ -157,7 +165,7 @@
</ul>
<ul class="column table-body">
<?php
- if ($votes != null) {
+ if ($votes !== null) {
//group by user
$others = array();
$displayName = '';
@@ -167,12 +175,12 @@
if (!isset($others[$vote->getUserId()])) {
$others[$vote->getUserId()] = array();
}
- array_push($others[$vote->getUserId()], $vote);
+ $others[$vote->getUserId()][]= $vote;
}
$userCnt = 0;
foreach (array_keys($others) as $usr) {
$userCnt++;
- if ($usr == $userId) {
+ if ($usr === $userId) {
// if poll expired, just put current user among the others;
// otherwise skip here to add current user as last row (to vote)
if (!$expired) {
@@ -180,8 +188,10 @@
continue;
}
}
- if ( $userMgr->get($usr) != null
- && !$isAnonymous && !$hideNames
+ if (
+ $userMgr->get($usr) !== null &&
+ !$isAnonymous &&
+ !$hideNames
) {
$displayName = $userMgr->get($usr)->getDisplayName();
$avatarName = $usr;
@@ -208,32 +218,32 @@
<?php
// loop over dts
$i_tot = 0;
-
+
foreach ($dates as $dt) {
- if ($poll->getType() == '0') {
+ if ($poll->getType() === 0) {
$dateId = strtotime($dt->getDt());
- $pollId = "voteid_" . $dt->getId();
+ $pollId = 'voteid_' . $dt->getId();
} else {
$dateId = $dt->getText();
- $pollId = "voteid_" . $dt->getId();
+ $pollId = 'voteid_' . $dt->getId();
}
// look what user voted for this dts
$class = 'column poll-cell no';
foreach ($others[$usr] as $vote) {
$voteVal = null;
- if ($poll->getType() == '0') {
+ if ($poll->getType() === 0) {
$voteVal = strtotime($vote->getDt());
} else {
$voteVal = $vote->getText();
}
- if ($dateId == $voteVal) {
- if ($vote->getType() == '1') {
+ if ($dateId === $voteVal) {
+ if ($vote->getType() === 1) {
$class = 'column poll-cell yes';
$total['yes'][$i_tot]++;
- } else if ($vote->getType() == '0') {
+ } else if ($vote->getType() === 0) {
$class = 'column poll-cell no';
$total['no'][$i_tot]++;
- } else if ($vote->getType() == '2') {
+ } else if ($vote->getType() === 2) {
$class = 'column poll-cell maybe';
}
break;
@@ -242,7 +252,7 @@
print_unescaped('<li id="'. $pollId . '" class="' . $class . '"></li>');
$i_tot++;
}
-
+
print_unescaped('</ul>');
print_unescaped('</li>');
}
@@ -275,12 +285,12 @@
$i_tot = 0;
foreach ($dates as $dt) {
- if ($poll->getType() == '0') {
+ if ($poll->getType() === 0) {
$dateId = strtotime($dt->getDt());
- $pollId = "voteid_" . $dt->getId();
+ $pollId = 'voteid_' . $dt->getId();
} else {
$dateId = $dt->getText();
- $pollId = "voteid_" . $dt->getId();
+ $pollId = 'voteid_' . $dt->getId();
}
// see if user already has data for this event
$class = 'no';
@@ -288,19 +298,19 @@
if (isset($userVoted)) {
foreach ($userVoted as $obj) {
$voteVal = null;
- if($poll->getType() == '0') {
+ if($poll->getType() === 0) {
$voteVal = strtotime($obj->getDt());
} else {
$voteVal = $obj->getText();
}
- if ($voteVal == $dateId) {
- if ($obj->getType() == '1') {
+ if ($voteVal === $dateId) {
+ if ($obj->getType() === 1) {
$class = 'column poll-cell yes';
$total['yes'][$i_tot]++;
- } else if ($obj->getType() == '0') {
+ } else if ($obj->getType() === 0) {
$class = 'column poll-cell no';
$total['no'][$i_tot]++;
- } else if($obj->getType() == '2') {
+ } else if($obj->getType() === 2) {
$class = 'column poll-cell maybe';
}
break;
@@ -331,17 +341,14 @@
</div>
<?php if (User::isLoggedIn()) : ?>
<div class="notification">
- <input type="checkbox" id="check_notif" class="checkbox" <?php if ($notification != null) print_unescaped(' checked'); ?> />
+ <input type="checkbox" id="check_notif" class="checkbox" <?php if ($notification !== null) print_unescaped(' checked'); ?> />
<label for="check_notif"><?php p($l->t('Receive notification email on activity')); ?></label>
</div>
<?php endif; ?>
</div>
</div>
-
<div id="app-sidebar" class="detailsView scroll-container disappear">
<a id="closeDetails" class="close icon-close" href="#" alt="<?php $l->t('Close');?>"></a>
-
-
<div class="table">
<div class="row">
<div id="app-navigation-simulation">
@@ -351,8 +358,8 @@
<?php p($l->t('Copy Link')); ?>
</a>
</li>
-
- <?php if ($poll->getOwner() == $userId) : ?>
+
+ <?php if ($poll->getOwner() === $userId) : ?>
<li class="">
<a id="id_del_<?php p($poll->getId()); ?>" class="icon-delete svg delete-poll" data-value="<?php p($poll->getTitle()); ?>" href="#">
<?php p($l->t('Delete poll')); ?>
@@ -369,7 +376,6 @@
</div>
</div>
-
<?php if ($expired) : ?>
<div id="expired_info">
<h2><?php p($l->t('Poll expired')); ?></h2>
@@ -400,7 +406,7 @@
</div>
</form>
</div>
- <?php if ($comments != null) : ?>
+ <?php if ($comments !== null) : ?>
<?php foreach ($comments as $comment) : ?>
<div class="comment">
<div class="comment-header">
@@ -409,7 +415,7 @@
if ($isAnonymous || $hideNames) {
p('Anonymous');
} else {
- if ($userMgr->get($comment->getUserId()) != null) {
+ if ($userMgr->get($comment->getUserId()) !== null) {
p($userMgr->get($comment->getUserId())->getDisplayName());
} else {
print_unescaped('<i>');
diff --git a/templates/main.tmpl.php b/templates/main.tmpl.php
index 938debec..653d15f0 100644
--- a/templates/main.tmpl.php
+++ b/templates/main.tmpl.php
@@ -29,8 +29,12 @@
\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'];
?>
<div id="app">
@@ -40,7 +44,7 @@
<div id="breadcrump">
<div class ="crumb svg last" data-dir="/">
<a href="<?php p($urlGenerator->linkToRoute('polls.page.index')); ?>">
- <img class="svg" src="<?php print_unescaped(OCP\image_path("core", "places/home.svg")); ?>" alt="Home">
+ <img class="svg" src="<?php print_unescaped(\OCP\Template::image_path('core', 'places/home.svg')); ?>" alt="Home">
</a>
</div>
<div class="creatable" style="">
@@ -51,7 +55,7 @@
</div>
</div>
</div>
- <?php if (count($_['polls']) == 0) : ?>
+ <?php if (count($_['polls']) === 0) : ?>
<div id="emptycontent" class="">
<div class="icon-polls"></div>
<h2><?php p($l->t('No existing polls.')); ?></h2>
@@ -84,15 +88,17 @@
</div>
</div>
- <?php foreach ($_['polls'] as $poll) : ?>
+ <?php foreach ($polls as $poll) : ?>
<?php
- if (!userHasAccess($poll, $userId)) continue;
+ 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 = '';
- if ($poll->getType() == '0') {
+ if ($poll->getType() === 0) {
$participated = $_['participations'];
} else {
$participated = $_['participations_text'];
@@ -106,16 +112,16 @@
$commented_title = 'You did not comment';
$commented_count = count($comments);
- if ($owner == $userId) {
+ if ($owner === $userId) {
$owner = $l->t('Yourself');
}
- if ($poll->getExpire() != null) {
+ if ($poll->getExpire() !== null) {
// $expiry_date = date('d.m.Y', strtotime($poll->getExpire()));
- $expiry_date = OCP\relative_modified_date(strtotime($poll->getExpire())); // does not work, because relative_modified_date seems not to recognise future time diffs
+ $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';
if (date('U') > strtotime($poll->getExpire())) {
- $expiry_date = OCP\relative_modified_date(strtotime($poll->getExpire()));
+ $expiry_date = \OCP\Template::relative_modified_date(strtotime($poll->getExpire()));
$expiry_style = ' expired';
}
} else {
@@ -124,7 +130,7 @@
}
for ($i = 0; $i < count($participated); $i++) {
- if ($poll->getId() == intval($participated[$i]->getPollId())) {
+ if ($poll->getId() === $participated[$i]->getPollId()) {
$participated_class = 'partic_yes';
$participated_title = 'You voted';
array_splice($participated, $i, 1);
@@ -133,7 +139,7 @@
}
for ($i = 0; $i < count($comments); $i++) {
- if ($poll->getId() == intval($comments[$i]->getPollId())) {
+ if ($poll->getId() === $comments[$i]->getPollId()) {
$commented_class = 'commented_yes';
$commented_title = 'You commented';
array_splice($comments, $i, 1);
@@ -142,11 +148,10 @@
}
?>
-
<div class="row table-body">
<div class="wrapper group-master">
<div class="wrapper group-1">
- <div class="thumbnail <?php p($expiry_style . " " . $commented_class. " " . $participated_class); ?>"></div> <!-- Image to display status or type of poll */ -->
+ <div class="thumbnail <?php p($expiry_style . ' ' . $commented_class. ' ' . $participated_class); ?>"></div><!-- Image to display the status or type of poll -->
<a href="<?php p($pollUrl); ?>" class="wrapper group-1-1">
<div class="column name"> <?php p($poll->getTitle()); ?></div>
<div class="column description"> <?php p($poll->getDescription()); ?></div>
@@ -161,7 +166,7 @@
<span>Copy Link</span>
</a>
</li>
- <?php if ($poll->getOwner() == $userId) : ?>
+ <?php if ($poll->getOwner() === $userId) : ?>
<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>
@@ -188,7 +193,7 @@
</div>
<div class="wrapper group-2-1">
<div class="column access"><?php p($l->t($poll->getAccess())); ?></div>
- <div class="column created" data-timestamp="<?php p(strtotime($poll->getCreated())); ?>" data-value="<?php p($poll->getCreated()); ?>"><?php p(OCP\relative_modified_date(strtotime($poll->getCreated()))); ?></div>
+ <div class="column created" data-timestamp="<?php p(strtotime($poll->getCreated())); ?>" data-value="<?php p($poll->getCreated()); ?>"><?php p(\OCP\Template::relative_modified_date(strtotime($poll->getCreated()))); ?></div>
</div>
<div class="wrapper group-2-2">
<div class="column expiry<?php p($expiry_style); ?>" data-value="<?php p($poll->getExpire()); ?>"> <?php p($expiry_date); ?></div>
@@ -213,12 +218,11 @@
// ---- helper functions ----
// from spreed.me
/**
- * @param $userId
- * @return array with groups
+ * @param string $userId
+ * @return \OCP\IGroup[]
*/
function getGroups($userId) {
- // $this->requireLogin();
- if (class_exists('\OC_Group', true)) {
+ if (class_exists('\OC_Group')) {
// Nextcloud <= 11, ownCloud
return \OC_Group::getUserGroups($userId);
}
@@ -230,12 +234,12 @@ function getGroups($userId) {
}
/**
- * @param $poll
- * @param $userId
- * @return boolean
+ * @param OCA\Polls\Db\Event $poll
+ * @param string $userId
+ * @return boolean
*/
-function userHasAccess($poll, $userId) {
- if ($poll == null) {
+function userHasAccess(OCA\Polls\Db\Event $poll, $userId) {
+ if ($poll === null) {
return false;
}
$access = $poll->getAccess();
@@ -243,32 +247,30 @@ function userHasAccess($poll, $userId) {
if (!User::isLoggedIn()) {
return false;
}
- if ($access == 'public') {
+ if ($access === 'public' || $access === 'hidden' || $access === 'registered') {
return true;
}
- if ($access == 'hidden') {
+ if ($owner === $userId) {
return true;
}
- if ($access == 'registered') {
- return true;
- }
- if ($owner == $userId) {
- return true;
- }
- $user_groups = getGroups($userId);
+ $user_groups = getGroups($userId);
$arr = explode(';', $access);
foreach ($arr as $item) {
- if (strpos($item, 'group_') == 0) {
+ if (strpos($item, 'group_') === 0) {
$grp = substr($item, 6);
foreach ($user_groups as $user_group) {
- if ($user_group == $grp) return true;
+ if ($user_group === $grp) {
+ return true;
+ }
}
}
- else if (strpos($item, 'user_') == 0) {
+ else if (strpos($item, 'user_') === 0) {
$usr = substr($item, 5);
- if ($usr == $userId) return true;
+ if ($usr === $userId) {
+ return true;
+ }
}
}
return false;