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:
authorsplitt3r <splitt3r@users.noreply.github.com>2017-11-07 21:21:37 +0300
committersplitt3r <splitt3r@users.noreply.github.com>2017-11-07 21:21:37 +0300
commit7905d95e08ae4c177d6d0e9af930fc740177aaa8 (patch)
tree8c8495a195e05246aa85449772d7839df0aef733 /templates
parent6e11d77656cbc9387f275d0b71de73fbafda16fa (diff)
First try to clean up a bit
Diffstat (limited to 'templates')
-rw-r--r--templates/create.tmpl.php43
-rw-r--r--templates/goto.tmpl.php84
-rw-r--r--templates/main.tmpl.php66
3 files changed, 103 insertions, 90 deletions
diff --git a/templates/create.tmpl.php b/templates/create.tmpl.php
index 1b7c178e..0df522a7 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 12a74ffb..cfb2ae19 100644
--- a/templates/goto.tmpl.php
+++ b/templates/goto.tmpl.php
@@ -26,36 +26,43 @@
\OCP\Util::addStyle('polls', 'main');
\OCP\Util::addStyle('polls', 'vote');
\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) {
+ if ($poll->getExpire() === null) {
$expired = false;
} else {
$expired = time() > strtotime($poll->getExpire());
}
?>
-<?php if($poll->getType() == '0') : ?>
+<?php if($poll->getType() === 0) : ?>
<?php foreach($dates as $d) : ?>
<input class="hidden-dates" type="hidden" value="<?php print_unescaped($d->getDt()); ?>" />
<?php endforeach ?>
<?php endif ?>
<?php
-if ( $poll->getDescription() != null
- && $poll->getDescription() != ''
+if ( $poll->getDescription() !== null
+ && $poll->getDescription() !== ''
) {
$description = nl2br($poll->getDescription());
} else {
@@ -65,7 +72,7 @@ if ( $poll->getDescription() != null
// init array for counting 'yes'-votes for each date
$total_y = array();
$total_n = array();
-for ($i = 0 ; $i < count($dates) ; $i++) {
+for ($i = 0; $i < count($dates); $i++) {
$total_y[$i] = 0;
$total_n[$i] = 0;
}
@@ -82,7 +89,7 @@ $pollUrl = $urlGenerator->linkToRouteAbsolute('polls.page.goto_poll', ['hash' =>
<?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>
<div class="crumb svg last">
@@ -106,7 +113,7 @@ $pollUrl = $urlGenerator->linkToRouteAbsolute('polls.page.goto_poll', ['hash' =>
<table class="vote_table">
<thead>
<?php
- if ($poll->getType() == '0') {
+ if ($poll->getType() === 0) {
print_unescaped('<tr id="time-slots-header"><th class="first_header_cell" colspan="3"></th>');
} else {
print_unescaped('<tr id="vote-options-header"><th class="first_header_cell" colspan="3"></th>');
@@ -119,7 +126,7 @@ $pollUrl = $urlGenerator->linkToRouteAbsolute('polls.page.goto_poll', ['hash' =>
</thead>
<tbody class="votes">
<?php
- if ($votes != null) {
+ if ($votes !== null) {
//group by user
$others = array();
foreach ($votes as $vote) {
@@ -131,7 +138,7 @@ $pollUrl = $urlGenerator->linkToRouteAbsolute('polls.page.goto_poll', ['hash' =>
$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) {
@@ -141,7 +148,8 @@ $pollUrl = $urlGenerator->linkToRouteAbsolute('polls.page.goto_poll', ['hash' =>
}
print_unescaped('<tr>');
print_unescaped('<td class="avatar-cell">');
- if ( $userMgr->get($usr) != null
+ if (
+ $userMgr->get($usr) !== null
&& !$isAnonymous && !$hideNames
) {
print_unescaped('<div class="poll avatardiv" title="'.($usr).'"></div>');
@@ -165,33 +173,32 @@ $pollUrl = $urlGenerator->linkToRouteAbsolute('polls.page.goto_poll', ['hash' =>
// loop over dts
$i_tot = 0;
foreach ($dates as $dt) {
- if ($poll->getType() == '0') {
+ if ($poll->getType() === 0) {
$date_id = strtotime($dt->getDt());
- $poll_id = "pollid_" . $dt->getId();
+ $poll_id = 'pollid_' . $dt->getId();
} else {
$date_id = $dt->getText();
- $poll_id = "pollid_" . $dt->getId();
+ $poll_id = 'pollid_' . $dt->getId();
}
// look what user voted for this dts
$found = false;
foreach ($others[$usr] as $vote) {
$voteVal = null;
- if ($poll->getType() == '0') {
+ if ($poll->getType() === 0) {
$voteVal = strtotime($vote->getDt());
} else {
$voteVal = $vote->getText();
}
- if ($date_id == $voteVal) {
- if ($vote->getType() == '1') {
+ if ($date_id === $voteVal) {
+ $cl = 'poll-cell unvoted';
+ if ($vote->getType() === 1) {
$cl = 'poll-cell yes';
$total_y[$i_tot]++;
- } else if ($vote->getType() == '0') {
+ } else if ($vote->getType() === 0) {
$cl = 'poll-cell no';
$total_n[$i_tot]++;
- } else if ($vote->getType() == '2') {
+ } else if ($vote->getType() === 2) {
$cl = 'poll-cell maybe';
- } else {
- $cl = 'poll-cell unvoted';
}
$found = true;
break;
@@ -228,31 +235,31 @@ $pollUrl = $urlGenerator->linkToRouteAbsolute('polls.page.goto_poll', ['hash' =>
// print_unescaped('</td><td class="toggle-cell"><div id="toggle" class="toggle-all toggle maybe"></div><img class="svg" src="../../../../core/img/actions/play-next.svg" "="" alt=""></td>');
$i_tot = 0;
foreach ($dates as $dt) {
- if ($poll->getType() == '0') {
+ if ($poll->getType() === 0) {
$date_id = strtotime($dt->getDt());
- $poll_id = "pollid_" . $dt->getId();
+ $poll_id = 'pollid_' . $dt->getId();
} else {
$date_id = $dt->getText();
- $poll_id = "pollid_" . $dt->getId();
+ $poll_id = 'pollid_' . $dt->getId();
}
// see if user already has data for this event
$cl = 'poll-cell active unvoted ';
if (isset($user_voted)) {
foreach ($user_voted as $obj) {
$voteVal = null;
- if($poll->getType() == '0') {
+ if($poll->getType() === 0) {
$voteVal = strtotime($obj->getDt());
} else {
$voteVal = $obj->getText();
}
- if ($voteVal == $date_id) {
- if ($obj->getType() == '1') {
+ if ($voteVal === $date_id) {
+ if ($obj->getType() === 1) {
$cl = 'poll-cell active yes';
$total_y[$i_tot]++;
- } else if ($obj->getType() == '0') {
+ } else if ($obj->getType() === 0) {
$cl = 'poll-cell active no';
$total_n[$i_tot]++;
- } else if($obj->getType() == '2') {
+ } else if($obj->getType() === 2) {
$cl = 'poll-cell active maybe';
}
break;
@@ -272,21 +279,20 @@ $pollUrl = $urlGenerator->linkToRouteAbsolute('polls.page.goto_poll', ['hash' =>
<tbody class="summary">
<?php
$diff_array = $total_y;
- for($i = 0 ; $i < count($diff_array) ; $i++) {
+ for ($i = 0; $i < count($diff_array); $i++) {
$diff_array[$i] = ($total_y[$i] - $total_n[$i]);
}
$max_votes = max($diff_array);
?>
<tr class="total">
<th colspan="3"><?php p($l->t('Total')); ?></th>
- <?php for ($i = 0 ; $i < count($dates) ; $i++) : ?>
+ <?php for ($i = 0; $i < count($dates); $i++) : ?>
<td class="total">
<?php
$classSuffix = "pollid_" . $dates[$i]->getId();
+ $val = 0;
if (isset($total_y[$i])) {
$val = $total_y[$i];
- } else {
- $val = 0;
}
?>
<div id="id_y_<?php p($classSuffix); ?>" class="result-cell yes" data-value=<?php p(isset($total_y_others[$i]) ? $total_y_others[$i] : '0'); ?>>
@@ -303,7 +309,7 @@ $pollUrl = $urlGenerator->linkToRouteAbsolute('polls.page.goto_poll', ['hash' =>
<?php
for ($i = 0; $i < count($dates); $i++) {
$check = '';
- if ($total_y[$i] - $total_n[$i] == $max_votes) {
+ if ($total_y[$i] - $total_n[$i] === $max_votes) {
$check = 'icon-checkmark';
}
print_unescaped('<td class="win_row ' . $check . '" id="id_total_' . $i . '"></td>');
@@ -323,7 +329,7 @@ $pollUrl = $urlGenerator->linkToRouteAbsolute('polls.page.goto_poll', ['hash' =>
</form>
<?php if (User::isLoggedIn()) : ?>
<span 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>
</span>
<?php endif; ?>
@@ -366,7 +372,7 @@ $pollUrl = $urlGenerator->linkToRouteAbsolute('polls.page.goto_poll', ['hash' =>
</div>
</form>
</div>
- <?php if ($comments != null) : ?>
+ <?php if ($comments !== null) : ?>
<?php foreach ($comments as $comment) : ?>
<div class="comment">
<div class="comment-header">
@@ -375,7 +381,7 @@ $pollUrl = $urlGenerator->linkToRouteAbsolute('polls.page.goto_poll', ['hash' =>
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 a9c19373..19d38b04 100644
--- a/templates/main.tmpl.php
+++ b/templates/main.tmpl.php
@@ -28,8 +28,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-content">
<div id="app-content-wrapper">
@@ -37,7 +41,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>
@@ -48,7 +52,7 @@
<input class="stop icon-close" style="display:none" value="" type="button">
</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>
@@ -81,7 +85,7 @@
</div>
</div>
- <?php foreach ($_['polls'] as $poll) : ?>
+ <?php foreach ($polls as $poll) : ?>
<?php
if (!userHasAccess($poll, $userId)) continue;
// direct url to poll
@@ -89,7 +93,7 @@
$owner = $poll->getOwner();
$expiry_style = '';
- if ($poll->getType() == '0') {
+ if ($poll->getType() === 0) {
$participated = $_['participations'];
} else {
$participated = $_['participations_text'];
@@ -103,16 +107,16 @@
$commented_title = $l->t('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 {
@@ -121,7 +125,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 = $l->t('You voted');
array_splice($participated, $i, 1);
@@ -130,7 +134,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 = $l->t('You commented');
array_splice($comments, $i, 1);
@@ -143,7 +147,7 @@
<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 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>
@@ -158,7 +162,7 @@
<span>Copy Link</span>
</button>
</li>
- <?php if ($poll->getOwner() == $userId) : ?>
+ <?php if ($poll->getOwner() === $userId) : ?>
<li>
<button class="menuitem delete_poll action permanent" id="id_del_<?php p($poll->getId()); ?>" data-value="<?php p($poll->getTitle()); ?>">
<span class="cl_delete icon-delete"></span>
@@ -185,7 +189,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>
@@ -209,12 +213,12 @@
// ---- helper functions ----
// from spreed.me
/**
- * @param $userId
+ * @param string $userId
* @return array with groups
*/
function getGroups($userId) {
// $this->requireLogin();
- if (class_exists('\OC_Group', true)) {
+ if (class_exists('\OC_Group')) {
// Nextcloud <= 11, ownCloud
return \OC_Group::getUserGroups($userId);
}
@@ -226,12 +230,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) {
+ if ($poll === null) {
return false;
}
$access = $poll->getAccess();
@@ -239,32 +243,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;