This commit is contained in:
Maxime Corteel 2016-04-17 01:00:54 +02:00
Родитель 34e8f66e6f
Коммит d2f7bae5c6
18 изменённых файлов: 1143 добавлений и 1023 удалений

Просмотреть файл

@ -21,7 +21,7 @@ $application = new Application();
$application->registerRoutes($this, array('routes' => array(
array('name' => 'page#index', 'url' => '/', 'verb' => 'GET'),
array('name' => 'page#goto_poll', 'url' => '/goto/{hash}', 'verb' => 'GET'),
array('name' => 'page#goto_poll', 'url' => '/poll/{hash}', 'verb' => 'GET'),
array('name' => 'page#edit_poll', 'url' => '/edit/{hash}', 'verb' => 'GET'),
array('name' => 'page#create_poll', 'url' => '/create', 'verb' => 'GET'),
array('name' => 'page#delete_poll', 'url' => '/delete', 'verb' => 'POST'),

Просмотреть файл

@ -36,6 +36,7 @@ use \OCP\IURLGenerator;
use OCP\Security\ISecureRandom;
use \OCP\AppFramework\Http\TemplateResponse;
use \OCP\AppFramework\Http\RedirectResponse;
use \OCP\AppFramework\Http\JSONResponse;
use \OCP\AppFramework\Controller;
$userMgr = \OC::$server->getUserManager();
@ -162,8 +163,9 @@ class PageController extends Controller {
} catch(\OCP\AppFramework\Db\DoesNotExistException $e) {
$notification = null;
}
if($this->hasUserAccess($poll)) return new TemplateResponse('polls', 'goto.tmpl', ['poll' => $poll, 'dates' => $dates, 'comments' => $comments, 'votes' => $votes, 'notification' => $notification, 'userId' => $this->userId, 'userMgr' => $this->manager, 'urlGenerator' => $this->urlGenerator, 'avatarManager' => $this->avatarManager]);
else {
if($this->hasUserAccess($poll)) {
return new TemplateResponse('polls', 'goto.tmpl', ['poll' => $poll, 'dates' => $dates, 'comments' => $comments, 'votes' => $votes, 'notification' => $notification, 'userId' => $this->userId, 'userMgr' => $this->manager, 'urlGenerator' => $this->urlGenerator, 'avatarManager' => $this->avatarManager]);
} else {
\OCP\User::checkLoggedIn();
return new TemplateResponse('polls', 'no.acc.tmpl', []);
}
@ -361,7 +363,7 @@ class PageController extends Controller {
}
}
} else {
$userId = $userId . ' (extern)';
$userId = $userId;
}
$poll = $this->eventMapper->find($pollId);
if($changed === 'true') {
@ -408,7 +410,7 @@ class PageController extends Controller {
$this->sendNotifications($pollId, $userId);
$hash = $this->eventMapper->find($pollId)->getHash();
$url = $this->urlGenerator->linkToRoute('polls.page.goto_poll', ['hash' => $hash]);
return new RedirectResponse($url);
return new JSONResponse(array('comment' => $commentBox, 'date' => date('Y-m-d H:i:s'), 'userName' => $this->manager->get($userId)->getDisplayName()));
}
public function getPollsForUser() {
@ -435,8 +437,7 @@ class PageController extends Controller {
foreach ($user_groups as $user_group) {
if ($user_group === $grp) return true;
}
}
else if (strpos($item, 'user_') === 0) {
} else if (strpos($item, 'user_') === 0) {
$usr = substr($item, 5);
if ($usr === \OCP\User::getUser()) return true;
}

86
css/create.css Normal file
Просмотреть файл

@ -0,0 +1,86 @@
#access_rights {
display :none;
border: 1px solid #DDD;
margin: 15px;
padding: 5px;
border-radius: 3px;
max-height: 150px;
overflow-y: auto;
}
#access_rights h3 {
margin: 0 0 5px;
}
.cl_access_item {
padding: 5px;
background-color: white;
color: #333;
cursor: pointer;
}
.cl_access_item:hover {
background-color: #EEE;
}
.cl_access_item.selected {
background-color: #409AE7;
color: #FFF;
}
.cl_access_item.selected:hover {
background-color: #337AB7;
color: #FFF;
}
textarea {
min-height: 66px;
}
.choices {
margin-top: 10px;
}
.choices td {
min-width: 30px;
}
table td {
text-align: center;
}
.text-row, .date-row {
font-weight: bold;
padding: 2px 5px;
background-color: #337AB7;
color: #FFF;
text-align: left;
}
.text-row:hover, .date-row:hover {
background-color: #D9534F;
text-decoration: line-through;
}
#selected-dates-table tr:first-child td {
font-weight: bold;
padding: 2px 5px;
background-color: #337AB7;
color: #FFF;
}
table .icon-close {
cursor: pointer;
background-color: #D9534F;
padding: 0 5px;
}
table .icon-checkmark {
cursor: pointer;
background-color: #5CB85C;
padding: 0 5px;
}
#expiration {
max-width: 200px;
}

24
css/list.css Normal file
Просмотреть файл

@ -0,0 +1,24 @@
table {
width: 100%;
}
table thead th {
font-weight: bold;
text-align: left;
padding: 3px 5px;
background-color: #337AB7;
color: #FFF;
}
table tbody td {
text-align: left;
padding: 3px 5px;
}
tbody tr:nth-child(even) {
background-color: #D4F7FF;
}
tbody tr:nth-child(even):hover {
background-color: #CDF5FF;
}

Просмотреть файл

@ -1,14 +1,6 @@
#content-wrapper {
position: relative;
}
body {
margin: 10px;
}
h1 {
font-size: 2em;
margin-bottom: 15px;
font-size: 1.8em;
margin-bottom: 5px;
}
h2 {
@ -16,45 +8,80 @@ h2 {
margin: 10px 0 5px 0;
}
footer {
text-align: center;
color: #777;
a {
color: #35537a;
}
th, tr, td {
padding: 4px;
text-align: center;
a:not(.button):hover {
text-decoration: underline;
}
th {
font-weight: bold;
#app header {
padding-top: 15px;
}
tr:nth-child(even), tr:nth-child(even):hover, tr:nth-child(even) a {
background: #35537a;
color: #eee;
.row:after {
content: ".";
display:block;
height:0;
clear:both;
visibility:hidden;
}
tr:nth-child(odd) {
.col-100 {
width: 100%;
padding: 0px 15px;
}
.col-70 {
width: 65%;
float: left;
padding: 0px 15px;
}
.col-50 {
width: 50%;
float: left;
padding: 0px 15px;
}
.col-30 {
width: 35%;
float: left;
padding: 0px 15px;
}
@media(max-width: 1000px) {
.col-70, .col-30, .col-50 {
float: none;
width: 100%;
}
}
input[type="text"] {
display: block;
width: 100%;
}
textarea {
min-width: 100%;
max-width: 100%;
}
table {
border: 1px solid #aaa;
border: 1px solid #DDD;
border-radius: 3px;
}
.form-actions {
padding: 15px;
}
.goto_poll {
width: 100%;
}
input.input_field {
width: 20%;
}
.label_h1 {
display:block;
}
div.new_poll {
width: 100%;
}
@ -70,11 +97,11 @@ div.partic_all {
}
div.partic_yes {
background-color: #6fff70; /*green*/
background-color: #5CB85C; /*green*/
}
div.partic_no {
background-color: #ff6f6f; /*red*/
background-color: #D9534F; /*red*/
}
input.table_button {
@ -97,6 +124,14 @@ div.scroll_div_dialog {
overflow-y: auto;
}
.bordered {
border-left: 1px solid #FFF;
}
tbody th {
text-align: left;
}
td.td_shown {
visibility: visible;
}
@ -145,26 +180,16 @@ td.td_shown {
}
.input_title{
display: block;
font-size: 1.2em;
margin-top: 5px;
}
.padded td {
padding: 10px;
}
.cl_create_form {
min-width: 60%;
margin-bottom: 10px;
}
.vote_table {
margin-top: 10px;
}
.cl_create_form td {
padding: 3px;
text-align: left;
vertical-align: center;
text-align: center;
.vote_table thead th {
min-width: 40px;
}
.time-slot-cell {
@ -172,12 +197,14 @@ td.td_shown {
}
.toggle-all {
width: 20px;
min-width: 40px;
cursor: pointer;
}
.user-cell {
padding-left: 20px;
padding-right: 20px;
text-align: left;
min-width: 100px;
height: 40px;
}
.userNameImg {
@ -212,7 +239,7 @@ td.td_shown {
background-color: #82de82;
}
.cl_poll_access, .cl_poll_url, .cl_click, .cl_delete, .cl_date_time_header {
.cl_poll_url, .cl_click, .cl_delete, .cl_date_time_header {
cursor: pointer;
}
@ -237,12 +264,6 @@ td.td_shown {
.cl_maybe:before, .cl_maybe:after{
content: "?";
}
.cl_total_y {
background-color: #6fff70; /*green*/
}
.cl_total_n {
background-color: #ff6f6f; /*red*/
}
.win_row {
color: #5ef56c;
@ -276,11 +297,6 @@ td.td_shown {
margin-left: 5px;
}
.date {
font-size: 0.8em;
color: #555;
}
#id_tab_total {
height: 2em;
width: 100%;
@ -301,138 +317,79 @@ td.td_shown {
padding-left: 2px;
}
/* users, groups... */
#dialog-overlay {
/* set it to fill the whil screen */
width:100%;
height:100%;
/* transparency for different browsers */
filter:alpha(opacity=50);
-moz-opacity:0.5;
-khtml-opacity: 0.5;
opacity: 0.5;
background:#000;
/* make sure it appear behind the dialog box but above everything else */
position:absolute;
top:0; left:0;
z-index:3000;
/* hide it by default */
display:none;
}
#text-title, #id_expire_date {
margin-left: 5px;
}
#dialog-box {
padding: 10px;
/* css3 drop shadow */
-webkit-box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.5);
-moz-box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.5);
box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.5);
/* css3 border radius */
-moz-border-radius: 5px;
-webkit-border-radius: 5px;
border-radius: 5px;
background:#eee;
/* styling of the dialog box, i have a fixed dimension for this demo */
width:400px;
/* make sure it has the highest z-index */
position:absolute;
z-index:5000;
/* hide it by default */
display:none;
}
div#dialog-message {
padding: 0 0 20px 0;
}
#table_groups, #table_users {
width: 100%;
padding: 20px 5px 10px 5px;
table-layout: fixed;
overflow-y: auto;
}
#table_users {
padding-left: 10px;
}
.cl_group_item, .cl_user_item {
background-color: white;
color: #000000;
}
.cl_group_item_selected, .cl_user_item_selected {
background-color: #1d2d44;
color: #8e96a1;
}
/* STUFF FROM mypolls */
ul {
padding: 5px;
padding-left: 12px;
}
#app-content {
padding: 5px;
}
#polls {
.input-group {
position: relative;
display: table;
border-collapse: separate;
width: 100%;
}
#poll-table {
width: 100%;
.input-group>input, .input-group-addon, .input-group-btn {
display: table-cell;
}
#poll-desc, #comments-container, #poll-dates {
margin-bottom: 15px;
.input-group-addon {
padding: 6px 12px;
font-size: 14px;
line-height: 1;
color: #555;
text-align: center;
background-color: #eee;
border: 1px solid #ccc;
border-radius: 4px;
white-space: nowrap;
vertical-align: middle;
width: 1%;
}
.input-group-addon input[type="checkbox"] {
margin: 0;
}
#comment-text {
.input-group-btn {
vertical-align: top;
}
.input-group-btn .btn {
height: 31.25px;
border: 1px solid #DDD;
margin: 0;
border-radius: 3px;
vertical-align: middle;
display: block;
width: 100%;
}
#datepicker {
.input-group>input {
position: relative;
z-index: 2;
float: left;
padding-right: 15px;
width: 100%;
margin: 0;
}
#new-poll-form-warn {
color: red;
.input-group input:first-child, .input-group .input-group-btn:first-child .btn, .input-group-addon:first-child {
border-top-right-radius: 0;
border-bottom-right-radius: 0;
}
.input-group input:last-child, .input-group .input-group-btn:last-child .btn, .input-group-addon:last-child {
border-top-left-radius: 0;
border-bottom-left-radius: 0;
}
.input-group .input-group-btn:first-child .btn, .input-group-addon:first-child {
border-right: none;
}
.input-group .input-group-btn:last-child .btn, .input-group-addon:last-child {
border-left: none;
}
#poll-dates table {
min-width: 50%;
}
#check_notif {
margin-bottom: 10px;
}
.poll-cell-not, .poll-cell-is, .poll-cell-maybe, .poll-cell-un, .poll-cell-active-not, .poll-cell-active-is, .poll-cell-active-maybe, .poll-cell-active-un {
}
.poll-cell-un, .poll-cell-active-un {
background-color: #fff;
}
.poll-cell-is, .poll-cell-active-is, .date-text-selected, .selected-all {
background-color: #6fff70; /*green*/
}
.poll-cell-maybe, .poll-cell-active-maybe, .selected-maybe {
background-color: #fcff6f; /*yellow*/
}
.poll-cell-not, .poll-cell-active-not, .date-text-not-selected, .selected-none {
background-color: #ff6f6f; /*red*/
}
.date-row:hover, .date-col:hover, .text-row:hover {
background-color: red;
color: black;
.alert-info {
margin-left: 50%;
transform:translateX(-50%);
width: auto;
padding: 5px 15px;
text-align: center;
border: 1px solid #1D2D44;
border-top: 0;
border-radius: 0 0 3px 3px;
}

172
css/vote.css Normal file
Просмотреть файл

@ -0,0 +1,172 @@
.vote_table {
width: 100%;
}
.vote_table thead tr:nth-child(even) th, .vote_table tfoot tr:nth-child(even) th, .vote_table tfoot tr:nth-child(even) td {
background-color: #337AB7;
color: #FFF;
}
.vote_table thead tr:nth-child(odd) th, .vote_table tfoot tr:nth-child(odd) th, .vote_table tfoot tr:nth-child(odd) td {
background: #35537a;
color: #FFF;
}
tbody.votes tr:nth-child(even) {
background-color: #D4F7FF;
}
tbody.votes tr:nth-child(even):hover {
background-color: #CDF5FF;
}
tbody.total th {
text-align: right;
}
th, tr, td {
padding: 4px;
text-align: center;
}
th {
font-weight: bold;
}
#polls {
width: 100%;
}
#poll-table {
width: 100%;
}
#poll-desc, #comments-container, #poll-dates {
margin-bottom: 15px;
}
#datepicker {
float: left;
padding-right: 15px;
}
#new-poll-form-warn {
color: red;
}
#poll-dates table {
min-width: 50%;
}
#check_notif {
margin-bottom: 10px;
}
tr.current-user th {
background-color: #337AB7;
color: #FFF
}
tr.current-user td, tr.current-user th {
border-top: 3px solid #337AB7;
border-bottom: 3px solid #337AB7;
}
th.external {
padding-left: 40px;
font-style: italic;
}
th.external input{
min-width: 100px;
}
.poll-cell-un, .poll-cell-active-un {
background-color: #FFF3CD;
}
.poll-cell-is, .poll-cell-active-is, .date-text-selected, .selected-all {
background-color: #6AD56A; /*green*/
background-image: url('../img/yes.svg');
background-repeat: no-repeat;
background-position: center;
transition: background-color 0.2s;
}
.poll-cell-not, .poll-cell-active-not, .date-text-not-selected, .selected-none {
background-image: url('../img/no.svg');
background-repeat: no-repeat;
background-position: center;
transition: background-color 0.2s;
}
.share {
margin: 10px 0;
}
.share .input-group-addon{
background-image: url('../img/share.svg');
background-repeat: no-repeat;
background-position: 10px center;
padding-left: 35px;
}
.comment {
border: 1px solid #DDD;
border-radius: 3px;
margin-bottom: 10px;
}
.comment .comment-header {
background-color: #EEE;
border-bottom: 1px solid #DDD;
border-radius: 3px 3px 0 0;
padding: 2px 5px;
}
.comment .comment-date {
float: right;
font-size: 0.9em;
color: #555;
}
.comment .comment-content {
padding: 5px;
}
.new-comment .icon-loading-small {
float: left;
margin-top: 10px;
display: none;
}
.new-comment .comment-content textarea {
display: block;
min-width: 100%;
max-width: 100%;
min-height: 66px;
}
td.total {
padding: 2px 0 1px;
color: #FFF;
font-weight: bold;
}
.color_yes, .poll-cell-is, .poll-cell-active-is {
background-color: #6AD56A; /*green*/
}
.color_no, .poll-cell-not, .poll-cell-active-not {
background-color: #D9534F; /*red*/
}
.color_maybe, .poll-cell-maybe, .poll-cell-active-maybe, .poll-cell-un, .poll-cell-active-un {
background-color: #FFF0C3; /*yellow*/
}
.home-link {
background-image: url('../img/home.svg');
background-repeat: no-repeat;
background-position: 5px center;
padding-left: 26px;
float: right;
}

Просмотреть файл

@ -65,7 +65,7 @@ class CommentMapper extends Mapper {
* @return Comment[]
*/
public function findByPoll($pollId, $limit=null, $offset=null) {
$sql = 'SELECT * FROM `*PREFIX*polls_comments` WHERE poll_id=?';
$sql = 'SELECT * FROM `*PREFIX*polls_comments` WHERE poll_id=? ORDER BY Dt DESC';
return $this->findEntities($sql, [$pollId], $limit, $offset);
}

5
img/home.svg Normal file
Просмотреть файл

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns="http://www.w3.org/2000/svg" height="16" width="16" version="1.0" xmlns:cc="http://creativecommons.org/ns#" xmlns:dc="http://purl.org/dc/elements/1.1/">
<rect style="color:#000000" fill-opacity="0" height="97.986" width="163.31" y="-32.993" x="-62.897"/>
<path opacity=".5" d="m8 1.0306-8 7.9694h3v6.0001h10v-6h3l-3-3.0306v-3.9695h-3v1.0812l-2-2.0505z" fill-rule="evenodd"/>
</svg>

После

Ширина:  |  Высота:  |  Размер: 506 B

77
img/no.svg Normal file
Просмотреть файл

@ -0,0 +1,77 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
height="16"
width="16"
version="1.1"
id="svg2"
inkscape:version="0.91 r13725"
sodipodi:docname="no.svg">
<metadata
id="metadata15">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
</cc:Work>
</rdf:RDF>
</metadata>
<sodipodi:namedview
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1"
objecttolerance="10"
gridtolerance="10"
guidetolerance="10"
inkscape:pageopacity="0"
inkscape:pageshadow="2"
inkscape:window-width="1600"
inkscape:window-height="825"
id="namedview13"
showgrid="true"
inkscape:zoom="14.75"
inkscape:cx="-4"
inkscape:cy="8"
inkscape:window-x="0"
inkscape:window-y="0"
inkscape:window-maximized="1"
inkscape:current-layer="svg2">
<inkscape:grid
type="xygrid"
id="grid3343" />
</sodipodi:namedview>
<defs
id="defs4">
<filter
id="a"
style="color-interpolation-filters:sRGB"
height="1"
width="1"
y="-2.8582539e-09"
x="-2.8637974e-09">
<feGaussianBlur
stdDeviation="1.1812806e-08"
id="feGaussianBlur7" />
</filter>
</defs>
<path
filter="url(#a)"
stroke="#fff"
stroke-width="2"
d="m12.95 11.536-1.414 1.414-3.536-3.5358-3.5355 3.5358-1.4142-1.414 3.5355-3.536-3.5355-3.5356 1.4142-1.4142 3.5355 3.5356 3.516-3.5547 1.434 1.4333-3.5357 3.5356z"
fill="#fff"
id="path9"
style="stroke-linejoin:round;" />
<path
d="m12.95 11.536-1.414 1.414-3.536-3.5358-3.5355 3.5358-1.4142-1.414 3.5355-3.536-3.5355-3.5356 1.4142-1.4142 3.5355 3.5356 3.516-3.5547 1.434 1.4333-3.5357 3.5356z"
id="path11"
style="fill:#ffffff;stroke:#ffffff;stroke-width:1;stroke-miterlimit:0.4;stroke-dasharray:none;stroke-linejoin:round" />
</svg>

После

Ширина:  |  Высота:  |  Размер: 2.3 KiB

6
img/share.svg Normal file
Просмотреть файл

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns="http://www.w3.org/2000/svg" height="16" width="16" version="1.1" xmlns:cc="http://creativecommons.org/ns#" xmlns:dc="http://purl.org/dc/elements/1.1/">
<g transform="translate(0 -1036.4)">
<path d="m12.228 1037.4c-1.3565 0-2.4592 1.0977-2.4592 2.4542 0 0.075 0.0084 0.1504 0.0149 0.2236l-4.7346 2.4145c-0.4291-0.3667-0.98611-0.5863-1.5947-0.5863-1.3565 0-2.4542 1.0977-2.4542 2.4543 0 1.3565 1.0977 2.4542 2.4542 2.4542 0.54607 0 1.0528-0.1755 1.4606-0.477l4.8637 2.4741c-0.0024 0.044-0.0099 0.089-0.0099 0.1342 0 1.3565 1.1027 2.4542 2.4592 2.4542s2.4542-1.0977 2.4542-2.4542-1.0977-2.4592-2.4542-2.4592c-0.63653 0-1.218 0.2437-1.6544 0.6409l-4.6953-2.4c0.01892-0.1228 0.03478-0.2494 0.03478-0.3775 0-0.072-0.0089-0.1437-0.0149-0.2137l4.7395-2.4145c0.42802 0.3627 0.98488 0.5813 1.5898 0.5813 1.3565 0 2.4542-1.1027 2.4542-2.4592s-1.0977-2.4542-2.4542-2.4542z"/>
</g>
</svg>

После

Ширина:  |  Высота:  |  Размер: 1003 B

4
img/yes.svg Normal file
Просмотреть файл

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns="http://www.w3.org/2000/svg" xml:space="preserve" height="16px" viewBox="-0.5 -0.5 16 16" width="16px" version="1.1" y="0px" x="0px" xmlns:cc="http://creativecommons.org/ns#" enable-background="new -0.5 -0.5 16 16" overflow="visible" xmlns:dc="http://purl.org/dc/elements/1.1/">
<path fill="#fff" transform="translate(-.5 -.5)" d="m12.438 3.6875c-0.363 0-0.726 0.1314-1 0.4063l-4.5005 4.5-1.9687-2c-0.5498-0.5484-1.4489-0.5498-2 0l-0.5 0.5c-0.5512 0.5496-0.5512 1.4502 0 2l2.9687 2.9682c0.0063 0.007-0.0065 0.025 0 0.032l0.5 0.5c0.5497 0.55 1.4503 0.55 2 0l0.5-0.5 0.1875-0.219 5.313-5.2812c0.549-0.5498 0.549-1.4503 0-2l-0.5-0.5c-0.275-0.2749-0.638-0.4063-1-0.4063z"/>
</svg>

После

Ширина:  |  Высота:  |  Размер: 799 B

Просмотреть файл

@ -2,8 +2,6 @@ var g_chosen_datetimes = [];
var g_chosen_texts = [];
var g_chosen_groups = [];
var g_chosen_users = [];
var g_tmp_groups = [];
var g_tmp_users = [];
var chosen_type = 'event';
var access_type = '';
@ -11,21 +9,15 @@ $(document).ready(function () {
// enable / disable date picker
$('#id_expire_set').click(function(){
$('#id_expire_date').prop("disabled", !this.checked);
// TODO: this would be nice, for some reason it doesn't work
//if (this.checked) {
// $("id_expire_date").focus();
//}
if (this.checked) {
$("#id_expire_date").focus();
}
});
var privateRadio = document.getElementById('private');
var hiddenRadio = document.getElementById('hidden');
var publicRadio = document.getElementById('public');
var selectRadio = document.getElementById('select');
privateRadio.onclick = hideSelectTable;
hiddenRadio.onclick = hideSelectTable;
publicRadio.onclick = hideSelectTable;
selectRadio.onclick = showSelectTable;
if(privateRadio.checked) access_type = 'registered';
if(hiddenRadio.checked) access_type = 'hidden';
if(publicRadio.checked) access_type = 'public';
@ -176,40 +168,24 @@ $(document).ready(function () {
text.value = '';
});
$(document).on('click', '#button_cancel_access', function(e) {
g_tmp_groups = [];
g_tmp_users = [];
closeAccessDialog();
});
$(document).on('click', '#button_ok_access', function(e) {
g_chosen_groups = g_tmp_groups;
g_chosen_users = g_tmp_users;
g_tmp_groups = [];
g_tmp_users = [];
closeAccessDialog();
});
$(document).on('click', '.cl_user_item', function(e) {
$(this).switchClass('cl_user_item', 'cl_user_item_selected');
g_tmp_users.push(this.id);
});
$(document).on('click', '.cl_user_item_selected', function(e) {
$(this).switchClass('cl_user_item_selected', 'cl_user_item');
var index = g_tmp_users.indexOf(this.id);
if(index > -1) g_tmp_users.splice(index, 1);
if($(this).hasClass('selected')) {
var index = g_chosen_users.indexOf(this.id);
if(index > -1) g_chosen_users.splice(index, 1);
} else {
g_chosen_users.push(this.id);
}
$(this).toggleClass('selected');
});
$(document).on('click', '.cl_group_item', function(e) {
$(this).switchClass('cl_group_item', 'cl_group_item_selected');
g_tmp_groups.push(this.id);
});
$(document).on('click', '.cl_group_item_selected', function(e) {
$(this).switchClass('cl_group_item_selected', 'cl_group_item');
var index = g_tmp_groups.indexOf(this.id);
if(index > -1) g_tmp_groups.splice(index, 1);
if($(this).hasClass('selected')) {
var index = g_chosen_groups.indexOf(this.id);
if(index > -1) g_chosen_groups.splice(index, 1);
} else {
g_chosen_groups.push(this.id);
}
$(this).toggleClass('selected');
});
$('.toggleable-row').hover(
@ -254,9 +230,9 @@ $(document).ready(function () {
$('input[type=radio][name=accessType]').change(function() {
access_type = this.value;
if(access_type == 'select') {
showAccessDialog();
$("#access_rights").show();
} else {
closeAccessDialog();
$("#access_rights").hide();
}
});
@ -434,72 +410,3 @@ function addColToList(ts, text, dateTs) {
td.id = ts;
}
}
//Popup dialog
function showAccessDialog() {
var message = t('polls', 'Please choose the groups or users you want to add to your poll.');
// get the screen height and width
var maskHeight = $(document).height();
var maskWidth = $(window).width();
// calculate the values for center alignment
//var dialogTop = (maskHeight / 3) - ($('#dialog-box').height());
// todo: height doesn't work
var dialogTop = 100;
var dialogLeft = (maskWidth / 2) - ($('#dialog-box').width() / 2);
// assign values to the overlay and dialog box
$('#dialog-overlay').css({height: maskHeight, width: maskWidth}).show();
$('#dialog-box').css({top: dialogTop, left: dialogLeft}).show();
// display the message
$('#dialog-message').html(message);
var unselectedGrps = [].slice.call(document.getElementsByClassName('cl_group_item'));
var selectedGrps = [].slice.call(document.getElementsByClassName('cl_group_item_selected'));
var unselectedUsers = [].slice.call(document.getElementsByClassName('cl_user_item'));
var selectedUsers = [].slice.call(document.getElementsByClassName('cl_user_item_selected'));
cells_grp = unselectedGrps.concat(selectedGrps);
cells_usr = unselectedUsers.concat(selectedUsers);
var tmpGroups = g_chosen_groups.slice();
for(var i=0; i<cells_grp.length; i++) {
var curr = cells_grp[i];
curr.className = 'cl_group_item';
for(var j=0; j<tmpGroups.length; j++) {
if(tmpGroups[j] == curr.id) {
curr.className = 'cl_group_item_selected';
tmpGroups.splice(j, 1);
break;
}
}
}
var tmpUsers = g_chosen_users.slice();
for(var i=0; i<cells_usr.length; i++) {
var curr = cells_usr[i];
curr.className = 'cl_user_item';
for(var j=0; j<tmpUsers.length; j++) {
if(tmpUsers[j] == curr.id) {
curr.className = 'cl_user_item_selected';
tmpUsers.splice(j, 1);
break;
}
}
}
g_tmp_groups = g_chosen_groups.slice();
g_tmp_users = g_chosen_users.slice();
}
function closeAccessDialog() {
$('#dialog-box').hide();
return false;
}
function showSelectTable() {
document.getElementById("table_access").style.display = "table";
}
function hideSelectTable() {
document.getElementById("table_access").style.display = "none";
}

Просмотреть файл

@ -1,39 +1,9 @@
var edit_access_id = null; // set if called from the summary page
$(document).ready(function () {
edit_access_id = null;
// users, groups
var elem = document.getElementById('select');
if (elem) elem.onclick = showAccessDialog;
elem = document.getElementById('button_close_access');
if (elem) elem.onclick = closeAccessDialog;
$('.cl_delete').click(deletePoll);
cells = document.getElementsByClassName('cl_group_item');
for (var i = 0; i < cells.length; i++) {
cells[i].onclick = groupItemClicked;
}
cells = document.getElementsByClassName('cl_user_item');
for (var i = 0; i < cells.length; i++) {
cells[i].onclick = userItemClicked;
}
var cells = document.getElementsByClassName('cl_delete');
for (var i = 0; i < cells.length; i++) {
var cell = cells[i];
cells[i].onclick = deletePoll;
}
// set "show poll url" handler
cells = document.getElementsByClassName('cl_poll_url');
for (var i = 0; i < cells.length; i++) {
var cell = cells[i];
cells[i].onclick = function(e) {
// td has inner 'input'; value is poll url
var cell = e.target;
var url = cell.getElementsByTagName('input')[0].value;
window.prompt(t('polls','Copy to clipboard: Ctrl+C, Enter'), url);
}
}
$('.cl_link').click(function() {
window.prompt(t('polls','Copy to clipboard: Ctrl+C, Enter'), $(this).data('url'));
});
});
function deletePoll(e) {

Просмотреть файл

@ -4,27 +4,13 @@ var newUserTypes = [];
var max_votes = 0;
var values_changed = false;
$(document).ready(function () {
var cells = [];
cells = document.getElementsByClassName('cl_click');
// loop over 'user' cells
for (var i = 0; i < cells.length; i++){
// fill arrays (if this is edit)
if (cells[i].className.indexOf('poll-cell-active-not') >= 0){
newUserTypes.push(0);
newUserDates.push(cells[i].id);
} else if (cells[i].className.indexOf('poll-cell-active-is') >= 0){
newUserTypes.push(1);
newUserDates.push(cells[i].id);
} else if(cells[i].className.indexOf('poll-cell-active-maybe') >= 0){
newUserTypes.push(2);
newUserDates.push(cells[i].id);
} else {
newUserTypes.push(-1);
newUserDates.push(cells[i].id);
}
}
$.fn.switchClass = function(a, b) {
this.removeClass(a);
this.addClass(b);
return this;
}
$(document).ready(function () {
$('#submit_finish_vote').click(function() {
var form = document.finish_vote;
var ac = document.getElementById('user_name');
@ -37,6 +23,19 @@ $(document).ready(function () {
}
}
check_notif = document.getElementById('check_notif');
var newUserDates = [], newUserTypes = [];
$(".cl_click").each(function() {
if($(this).hasClass('poll-cell-active-not')) {
newUserTypes.push(0);
} else if ($(this).hasClass('poll-cell-active-is')){
newUserTypes.push(1);
} else if($(this).hasClass('poll-cell-active-maybe')){
newUserTypes.push(2);
} else {
newUserTypes.push(-1);
}
newUserDates.push(parseInt($(this).attr('id')));
});
form.elements['dates'].value = JSON.stringify(newUserDates);
form.elements['types'].value = JSON.stringify(newUserTypes);
form.elements['notif'].value = (check_notif && check_notif.checked) ? 'true' : 'false';
@ -44,179 +43,75 @@ $(document).ready(function () {
form.submit();
});
$('#submit_send_comment').click(function() {
$('#submit_send_comment').click(function(e) {
e.preventDefault();
var form = document.send_comment;
var comm = document.getElementById('commentBox');
if(comm.value.length <= 0) {
if(comm.value.trim().length <= 0) {
alert(t('polls', 'Please add some text to your comment before submitting it.'));
return;
}
form.submit();
var data = {
pollId: form.elements['pollId'].value,
userId: form.elements['userId'].value,
commentBox: comm.value.trim()
};
$('.new-comment .icon-loading-small').show();
$.post(form.action, data, function(data) {
$('.comments .comment:first').after('<div class="comment"><div class="comment-header"><span class="comment-date">' + data.date + '</span>' + data.userName + '</div><div class="wordwrap comment-content">' + data.comment + '</div></div>');
$('.new-comment textarea').val('').focus();
$('.new-comment .icon-loading-small').hide();
}).error(function() {
alert(t('polls', 'An error occurred, your comment was not posted...'));
$('.new-comment .icon-loading-small').hide();
});
});
$(".share input").click(function() {
$(this).select();
});
});
$(document).on('click', '.toggle-all', function(e) {
if($(this).attr('class').indexOf('selected-all') > -1) {
var selected = $(this).parent().children('.poll-cell-active-is');
var maybes = $(this).parent().children('.poll-cell-active-maybe');
for(var i=0; i<selected.length; i++) {
var curr = $(selected[i]);
curr.switchClass('poll-cell-active-is', 'poll-cell-active-not');
deselectItem(curr);
}
for(var i=0; i<maybes.length; i++) {
var curr = $(maybes[i]);
curr.switchClass('poll-cell-active-maybe', 'poll-cell-active-not');
deselectItem(curr);
}
$(this).removeClass('selected-all');
$(this).addClass('selected-none');
} else if($(this).attr('class').indexOf('selected-none') > -1) {
var selected = $(this).parent().children('.poll-cell-active-is');
var unselected = $(this).parent().children('.poll-cell-active-not');
for(var i=0; i<selected.length; i++) {
var curr = $(selected[i]);
curr.switchClass('poll-cell-active-is', 'poll-cell-active-maybe');
maybeItem(curr);
}
for(var i=0; i<unselected.length; i++) {
var curr = $(unselected[i]);
curr.switchClass('poll-cell-active-not', 'poll-cell-active-maybe');
maybeItem(curr);
}
$(this).removeClass('selected-none');
$(this).addClass('selected-maybe');
$(document).on('click', '.toggle-all, .cl_click', function(e) {
values_changed = true;
var cl = "";
if($(this).hasClass('poll-cell-active-is')) {
cl = "not";
} else if($(this).hasClass('poll-cell-active-not')) {
cl = "maybe";
} else if($(this).hasClass('poll-cell-active-maybe')) {
cl = "is";
} else {
var maybes = $(this).parent().children('.poll-cell-active-maybe');
var unselected = $(this).parent().children('.poll-cell-active-not');
var notselected = $(this).parent().children('.poll-cell-active-un');
for(var i=0; i<maybes.length; i++) {
var curr = $(maybes[i]);
curr.switchClass('poll-cell-active-maybe', 'poll-cell-active-is');
selectItem(curr);
cl = "is";
}
for(var i=0; i<unselected.length; i++) {
var curr = $(unselected[i]);
curr.switchClass('poll-cell-active-not', 'poll-cell-active-is');
selectItem(curr, 'poll-cell-active-not');
}
for(var i=0; i<notselected.length; i++) {
var curr = $(notselected[i]);
curr.switchClass('poll-cell-active-un', 'poll-cell-active-is');
selectItem(curr);
}
$(this).removeClass('selected-maybe');
$(this).addClass('selected-all');
if($(this).hasClass('toggle-all')) {
$(".cl_click").attr('class', 'cl_click poll-cell-active-' + cl);
$(this).attr('class', 'toggle-all poll-cell-active-' + cl);
} else {
$(this).attr('class', 'cl_click poll-cell-active-' + cl);
}
$('.cl_click').each(function() {
var yes_c = $('#id_y_' + $(this).attr('id'));
var no_c = $('#id_n_' + $(this).attr('id'));
$(yes_c).text(parseInt($(yes_c).attr('data-value')) + ($(this).hasClass('poll-cell-active-is') ? 1 : 0));
$(no_c).text(parseInt($(no_c).attr('data-value')) + ($(this).hasClass('poll-cell-active-not') ? 1 : 0));
});
updateCounts();
});
$(document).on('click', '.poll-cell-active-un', function(e) {
maybeItem($(this));
});
$(document).on('click', '.poll-cell-active-not', function(e) {
maybeItem($(this));
});
$(document).on('click', '.poll-cell-active-maybe', function(e) {
selectItem($(this));
});
$(document).on('click', '.poll-cell-active-is', function(e) {
deselectItem($(this));
});
function selectItem(cell, cl) {
if(typeof cl === 'undefined') cl = '';
values_changed = true;
var ts = cell.attr('id');
var index = newUserDates.indexOf(ts);
if(index > -1) {
newUserDates.splice(index, 1);
newUserTypes.splice(index, 1);
}
newUserDates.push(ts);
newUserTypes.push(1);
if(cl.indexOf('poll-cell-active-not') > -1) {
var total_no = document.getElementById('id_n_' + ts);
var intNo = parseInt(total_no.innerHTML);
if(intNo >= 1) total_no.innerHTML = intNo - 1;
else total_no.innerHTML = '0';
}
var total_yes = document.getElementById('id_y_' + ts);
total_yes.innerHTML = parseInt(total_yes.innerHTML) + 1;
cell.switchClass('poll-cell-active-maybe', 'poll-cell-active-is');
findNewMaxCount();
updateStrongCounts();
}
function deselectItem(cell) {
values_changed = true;
var ts = cell.attr('id');
var index = newUserDates.indexOf(ts);
if(index > -1) {
newUserDates.splice(index, 1);
newUserTypes.splice(index, 1);
}
newUserDates.push(ts);
newUserTypes.push(0);
var total_yes = document.getElementById('id_y_' + ts);
var total_no = document.getElementById('id_n_' + ts);
var intYes = parseInt(total_yes.innerHTML);
if(intYes >= 1) total_yes.innerHTML = intYes - 1;
else total_yes.innerHTML = '0';
total_no.innerHTML = parseInt(total_no.innerHTML) + 1;
cell.switchClass('poll-cell-active-is', 'poll-cell-active-not');
findNewMaxCount();
updateStrongCounts();
}
function maybeItem(cell) {
values_changed = true;
var ts = cell.attr('id');
var index = newUserDates.indexOf(ts);
if(index > -1) {
newUserDates.splice(index, 1);
newUserTypes.splice(index, 1);
}
newUserDates.push(ts);
newUserTypes.push(2);
var total_no = document.getElementById('id_n_' + ts);
var intNo = parseInt(total_no.innerHTML);
if(intNo >= 1) total_no.innerHTML = intNo - 1;
else total_no.innerHTML = '0';
cell.switchClass('poll-cell-active-not', 'poll-cell-active-maybe');
cell.switchClass('poll-cell-active-un', 'poll-cell-active-maybe');
findNewMaxCount();
updateStrongCounts();
}
function findNewMaxCount(){
var cell_tot_y = document.getElementsByClassName('cl_total_y');
var cell_tot_n = document.getElementsByClassName('cl_total_n');
function updateCounts(){
max_votes = 0;
for(var i=0; i<cell_tot_y.length; i++) {
var currYes = parseInt(cell_tot_y[i].innerHTML);
var currNo = parseInt(cell_tot_n[i].innerHTML);
var curr = currYes - currNo;
if(curr > max_votes) max_votes = curr;
}
}
function updateStrongCounts(){
var cell_tot_y = document.getElementsByClassName('cl_total_y');
var cell_tot_n = document.getElementsByClassName('cl_total_n');
for(var i=0; i<cell_tot_y.length; i++) {
var cell_win = document.getElementById('id_total_' + i);
var curr = parseInt(cell_tot_y[i].innerHTML) - parseInt(cell_tot_n[i].innerHTML);
if(curr < max_votes) {
cell_win.className = 'win_row';
cell_tot_y[i].style.fontWeight = 'normal';
}
else {
cell_tot_y[i].style.fontWeight = 'bold';
cell_win.className = 'win_row icon-checkmark';
}
$('td.total').each(function() {
var yes = parseInt($(this).find('.color_yes').text());
var no = parseInt($(this).find('.color_no').text());
if(yes - no > max_votes) {
max_votes = yes - no;
}
});
var i = 0;
$('td.total').each(function() {
var yes = parseInt($(this).find('.color_yes').text());
var no = parseInt($(this).find('.color_no').text());
$('#id_total_' + i++).toggleClass('icon-checkmark', yes - no == max_votes);
});
}

Просмотреть файл

@ -1,5 +1,6 @@
<?php
\OCP\Util::addStyle('polls', 'main');
\OCP\Util::addStyle('polls', 'create');
\OCP\Util::addStyle('polls', 'jquery.datetimepicker');
\OCP\Util::addScript('polls', 'create_edit');
\OCP\Util::addScript('polls', 'jquery.datetimepicker.full.min');
@ -30,6 +31,9 @@
}
?>
<div id="app">
<div id="app-content">
<div id="app-content-wrapper">
<?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()); ?>" />
@ -40,18 +44,25 @@
<input type="hidden" name="expireTs" id="expireTs" value="<?php if(isset($expireTs)) p($expireTs); ?>" />
<input type="hidden" name="userId" id="userId" value="<?php p($userId); ?>" />
<div class="new_poll">
<header class="row">
<div class="col-100">
<?php if($isUpdate): ?>
<h1><?php p($l->t('Edit poll') . ' ' . $poll->getTitle()); ?></h1>
<?php else: ?>
<h1><?php p($l->t('Create new poll')); ?></h1>
<?php endif; ?>
<label for="text_title" class="label_h1 input_title"><?php p($l->t('Title')); ?></label>
<input type="text" class="input_field" id="pollTitle" name="pollTitle" value="<?php if(isset($title)) p($title); ?>" />
<label for="pollDesc" class="label_h1 input_title"><?php p($l->t('Description')); ?></label>
<textarea cols="50" rows="5" style="width: auto;" class="input_field" id="pollDesc" name="pollDesc"><?php if(isset($desc)) p($desc); ?></textarea>
</div>
</header>
<div class="input_title"><?php p($l->t('Access')); ?></div>
<div class="new_poll row">
<div class="col-50">
<h2><?php p($l->t('Basic information')); ?></h2>
<label for="pollTitle" class="input_title"><?php p($l->t('Title')); ?></label>
<input type="text" class="input_field" id="pollTitle" name="pollTitle" value="<?php if(isset($title)) p($title); ?>" />
<label for="pollDesc" class="input_title"><?php p($l->t('Description')); ?></label>
<textarea class="input_field" id="pollDesc" name="pollDesc"><?php if(isset($desc)) p($desc); ?></textarea>
<label class="input_title"><?php p($l->t('Access')); ?></label>
<input type="radio" name="accessType" id="private" value="registered" <?php if(!$isUpdate || $access === 'registered') print_unescaped('checked'); ?> />
<label for="private"><?php p($l->t('Registered users only')); ?></label>
@ -66,9 +77,34 @@
<label for="select"><?php p($l->t('Select')); ?></label>
<span id="id_label_select">...</span>
<div id="access_rights" class="row">
<div class="col-50">
<h3><?php p($l->t('Groups')); ?></h3>
<ul>
<?php $groups = OC_Group::getUserGroups($userId); ?>
<?php foreach($groups as $gid) : ?>
<li class="cl_group_item cl_access_item" id="group_<?php p($gid); ?>">
<?php p($gid); ?>
</li>
<?php endforeach; ?>
</ul>
</div>
<div class="col-50">
<h3><?php p($l->t('Users')); ?></h3>
<ul>
<?php $users = $userMgr->search(''); ?>
<?php foreach ($users as $user) : ?>
<li class="cl_user_item cl_access_item" id="user_<?php p($user->getUID()); ?>" >
<?php p($user->getDisplayName()); ?>
</li>
<?php endforeach; ?>
</ul>
</div>
</div>
<input type="hidden" name="accessValues" id="accessValues" value="<?php if($isUpdate && $access === 'select') p($accessTypes) ?>" />
<div class="input_title"><?php p($l->t('Type')); ?></div>
<label class="input_title"><?php p($l->t('Type')); ?></label>
<input type="radio" name="pollType" id="event" value="event" <?php if(!$isUpdate || $poll->getType() === '0') print_unescaped('checked'); ?> />
<label for="event"><?php p($l->t('Event schedule')); ?></label>
@ -77,87 +113,44 @@
<input type="radio" name="pollType" id="text" value="text" <?php if($isUpdate && $poll->getType() === '1') print_unescaped('checked'); ?>>
<label for="text"><?php p($l->t('Text based')); ?></label>
<br/>
<label for="id_expire_set" class="input_title"><?php p($l->t('Expires')); ?></label>
<div class="input-group" id="expiration">
<div class="input-group-addon">
<input id="id_expire_set" name="check_expire" type="checkbox" <?php ($isUpdate && $poll->getExpire() !== null) ? print_unescaped('value="true" checked') : print_unescaped('value="false"'); ?> />
<label for="id_expire_set"><?php p($l->t('Expires')); ?>:</label>
</div>
<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" />
<br/>
</div>
</div>
<div class="col-50">
<h2><?php p($l->t('Choices')); ?></h2>
<div id="date-select-container" <?php if($isUpdate && $poll->getType() === '1') print_unescaped('style="display:none;"'); ?> >
<label for="datetimepicker"><?php p($l->t('Dates')); ?>:</label>
<br/>
<label for="datetimepicker" class="input_title"><?php p($l->t('Dates')); ?></label>
<input id="datetimepicker" type="text" />
<table id="selected-dates-table">
<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;"'); ?> >
<label for="text-title"><?php p($l->t('Text item')); ?>:</label>
<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...'); ?>" />
<br/>
<input type="button" id="text-submit" value="<?php p($l->t('Add')); ?>"/>
<table id="selected-texts-table">
<div class="input-group-btn">
<input type="button" id="text-submit" value="<?php p($l->t('Add')); ?>" class="btn"/>
</div>
</div>
<table id="selected-texts-table" class="choices">
</table>
</div>
<br/>
<a href="<?php p($urlGenerator->linkToRoute('polls.page.index')); ?>"><input type="button" id="submit_cancel_poll" value="<?php p($l->t('Cancel')); ?>" /></a>
<input type="submit" id="submit_finish_poll" value="<?php p($l->t('Next')); ?>" />
</div>
</div>
<div class="form-actions">
<?php if($isUpdate): ?>
<input type="submit" id="submit_finish_poll" value="<?php p($l->t('Update poll')); ?>" />
<?php else: ?>
<input type="submit" id="submit_finish_poll" value="<?php p($l->t('Create poll')); ?>" />
<?php endif; ?>
<a href="<?php p($urlGenerator->linkToRoute('polls.page.index')); ?>" id="submit_cancel_poll" class="button"><?php p($l->t('Cancel')); ?></a>
</div>
</form>
<div id="dialog-box">
<div id="dialog-message"></div>
<?php if (isset($url)) : ?>
<input type="radio" name="radio_pub" id="private" value="registered"/>
<label for="private"><?php p($l->t('Registered users only')); ?></label>
<br/>
<input type="radio" name="radio_pub" id="hidden" value="hidden" />
<label for="hidden"><?php p($l->t('hidden')); ?></label>
<br/>
<input type="radio" name="radio_pub" id="public" value="public" />
<label for="public"><?php p($l->t('Public access')); ?></label>
<br/>
<input type="radio" name="radio_pub" id="select" value="select" checked />
<label for="select"><?php p($l->t('Select')); ?></label>
<br/>
<?php endif; ?>
<table id="table_access">
<tr>
<td>
<div class="scroll_div_dialog">
<table id="table_groups">
<tr>
<th><?php p($l->t('Groups')); ?></th>
</tr>
<?php $groups = OC_Group::getUserGroups($userId); ?>
<?php foreach($groups as $gid) : ?>
<tr>
<td class="cl_group_item" id="group_<?php p($gid); ?>"><?php p($gid); ?></td>
</tr>
<?php endforeach; ?>
</table>
</div>
</td>
<td>
<div class="scroll_div_dialog">
<table id="table_users">
<tr>
<th><?php p($l->t('Users')); ?></th>
</tr>
<?php $users = $userMgr->search(''); ?>
<?php foreach ($users as $user) : ?>
<tr>
<td class="cl_user_item" id="user_<?php p($user->getUID()); ?>" >
<?php p($user->getDisplayName()); ?>
</td>
</tr>
<?php endforeach; ?>
</table>
</div>
</td>
</tr>
</table>
<input type="button" id="button_cancel_access" value="<?php p($l->t('Cancel')); ?>" />
<input type="button" id="button_ok_access" value="<?php p($l->t('Ok')); ?>" />
</div>
</div>
</div>

Просмотреть файл

@ -1,21 +1,25 @@
<?php
use \OCP\User;
\OCP\Util::addStyle('polls', 'main');
\OCP\Util::addStyle('polls', 'vote');
\OCP\Util::addScript('polls', 'vote');
$userId = $_['userId'];
$userMgr = $_['userMgr'];
$urlGenerator = $_['urlGenerator'];
$avaMgr = $_['avatarManager'];
use \OCP\User;
$poll = $_['poll'];
$dates = $_['dates'];
$votes = $_['votes'];
$comments = $_['comments'];
$notification = $_['notification'];
$poll_type = $poll->getType();
if ($poll->getExpire() === null) $expired = false;
else {
if ($poll->getExpire() === null) {
$expired = false;
} else {
$expired = time() > strtotime($poll->getExpire());
}
@ -24,10 +28,8 @@ if ($poll->getType() === '0') {
$arr_dates = null; // will be like: [21.02] => 3
$arr_years = null; // [1992] => 6
foreach($dates as $d) {
$date = date('d.m.Y', strtotime($d->getDt()));
$arr = explode('.', $date);
$day_month = $arr[0] . '.' . $arr[1] . '.'; // 21.02
$year = $arr[2]; // 1992
$day_month = date('d.m', strtotime($d->getDt()));
$year = date('Y', strtotime($d->getDt()));
if (isset($arr_dates[$day_month])) {
$arr_dates[$day_month] += 1;
@ -35,109 +37,100 @@ if ($poll->getType() === '0') {
$arr_dates[$day_month] = 1;
}
// -----
if (isset($arr_years[$year])) {
$arr_years[$year] += 1;
} else {
$arr_years[$year] = 1;
}
}
$for_string_dates = '';
foreach (array_keys($arr_dates) as $dt) { // date (13.09)
$for_string_dates .= '<th colspan="' . $arr_dates[$dt] . '">' . $dt . '</th>';
foreach (array_keys($arr_dates) as $dt) {
$for_string_dates .= '<th colspan="' . $arr_dates[$dt] . '" class="bordered">' . $dt . '</th>';
}
$for_string_years = '';
foreach (array_keys($arr_years) as $year) { // year (1992)
$for_string_years .= '<th colspan="' . $arr_years[$year] . '">' . $year . '</th>';
foreach (array_keys($arr_years) as $year) {
$for_string_years .= '<th colspan="' . $arr_years[$year] . '" class="bordered">' . $year . '</th>';
}
}
if($poll->getDescription() !== null && $poll->getDescription() !== '') $line = str_replace("\n", '<br/>', $poll->getDescription());
else $line = $l->t('No description provided.');
if ($poll->getDescription() !== null && $poll->getDescription() !== '') {
$line = str_replace("\n", '<br/>', $poll->getDescription());
} else {
$line = $l->t('No description provided.');
}
// ----------- title / descr --------
// init array for counting 'yes'-votes for each date
$total_y = array();
$total_n = array();
for ($i = 0 ; $i < count($dates) ; $i++) {
$total_y[$i] = 0;
$total_n[$i] = 0;
}
$user_voted = array();
$pollUrl = OCP\Util::linkToAbsolute('', $urlGenerator->linkToRoute('polls.page.goto_poll', ['hash' => $poll->getHash()]));
?>
<!-- TODO reimplement?
<?php if(!User::isLoggedIn()) : ?>
<p>
<header>
<div id="header">
<a href="<?php print_unescaped(link_to('', 'index.php')); ?>"
title="" id="owncloud">
<div class="logo-wide svg"></div>
</a>
<div id="logo-claim" style="display:none;"><?php p($theme->getLogoClaim()); ?></div>
<div class="header-right">
<?php p($l->t('Already have an account?')); ?>
<?php $url = OCP\Util::linkToAbsolute( '', 'index.php' ).'?redirect_url='.$urlGenerator->linkToRoute('polls_goto', array('poll_id' => $poll_id)); ?>
<a href="<?php p($url); ?>"><?php p($l->t('Login')); ?></a>
<div id="app">
<div id="app-content">
<div id="app-content-wrapper">
<?php if(!User::isLoggedIn()) : ?>
<div class="row">
<div class="col-100">
<div class="alert-info">
<?php
p($l->t('Already have an account?'));
$loginUrl = OCP\Util::linkToAbsolute('', 'index.php' ) . '?redirect_url=' . $urlGenerator->linkToRoute('polls.page.goto_poll', ['hash' => $poll->getHash()]);
?>
<a href="<?php p($loginUrl); ?>"><?php p($l->t('Login')); ?></a>
</div>
</div>
</div>
<?php endif; ?>
<header class="row">
<div class="col-100">
<h1><?php p($poll->getTitle()); ?></h1>
<div class="wordwrap desc"><?php p($line); ?></div>
</div>
</header>
</p>
<p>&nbsp;</p><p>&nbsp;</p> <?php // for some reason the header covers the title otherwise ?>
<?php endif; ?>
-->
<h1><?php p($poll->getTitle()); ?></h1>
<div class="wordwrap desc"><?php p($line); ?></div>
<?
// -------------- url ---------------
?>
<h2><?php p($l->t('Poll URL')); ?></h2>
<p class="url">
<?php
$url = $urlGenerator->linkToRoute('polls.page.goto_poll', ['hash' => $poll->getHash()]);
?>
<a href="<?php p($url);?>"><?php p($url); ?></a>
</p>
<div class="scroll_div">
<table class="vote_table" id="id_table_1"> <?php //from above title ?>
<div class="row">
<div class="col-70">
<h2><?php p($l->t('Poll')); ?></h2>
<div class="scroll_div">
<table class="vote_table" id="id_table_1">
<thead>
<tr>
<th></th>
<th></th>
<?php
if ($poll_type === '0') {
if ($poll->getType() === '0') {
print_unescaped('<th rowspan=3></th>');
print_unescaped($for_string_years);
}
else {
print_unescaped('<th class="bordered" rowspan=3>' . $l->t('All') . '</th>');
} else {
print_unescaped('<th></th>');
foreach ($dates as $el) {
print_unescaped('<th title="' . $el->getText(). '">' . $el->getText() . '</th>');
print_unescaped('<th title="' . $el->getText(). '" class="bordered">' . $el->getText() . '</th>');
}
print_unescaped('<th class="bordered">' . $l->t('All') . '</th>');
}
?>
</tr>
<?php
if ($poll_type === '0'){
print_unescaped('<tr><th></th><td></td>' . $for_string_dates . '</tr>');
print_unescaped('<tr><th></th><td></td>');
if ($poll->getType() === '0'){
print_unescaped('<tr>' . $for_string_dates . '</tr><tr>');
$prev = "";
for ($i = 0; $i < count($dates); $i++) {
$c = ($prev != date('Y-m-d', strtotime($dates[$i]->getDt())) ? ' bordered' : '');
$prev = date('Y-m-d', strtotime($dates[$i]->getDt()));
$ch_obj = date('H:i', strtotime($dates[$i]->getDt()));
print_unescaped('<th class="time-slot-cell">' . $ch_obj . '</th>');
print_unescaped('<th class="time-slot-cell' . $c . '">' . $ch_obj . '</th>');
}
print_unescaped('</tr>');
}
// init array for counting 'yes'-votes for each dt
$total_y = array();
$total_n = array();
for ($i = 0; $i < count($dates); $i++){
$total_y[$i] = 0;
$total_n[$i] = 0;
}
$user_voted = array();
// -------------- other users ---------------
// loop over users
?>
</thead>
<tbody class="votes">
<?php
if ($votes !== null) {
//group by user
@ -158,31 +151,26 @@ else $line = $l->t('No description provided.');
}
}
print_unescaped('<tr>');
print_unescaped('<th class="user-cell">');
if($userMgr->get($usr) != null) {
print_unescaped('<th class="user-cell">');
$avatar = $avaMgr->getAvatar($usr)->get(32);
if($avatar !== false) {
$avatarImg = '<img class="userNameImg" src="data:' . $avatar->mimeType() . ';base64,' . $avatar . '" />';
print_unescaped('<img class="userNameImg" src="data:' . $avatar->mimeType() . ';base64,' . $avatar . '" />');
} else {
$avatarImg = '<div class="userNameImg noAvatar" style="background-color:' . getHsl($usr) . ';">' . strtoupper($usr[0]) . '</div>';
print_unescaped('<div class="userNameImg noAvatar" style="background-color:' . getHsl($usr) . ';">' . strtoupper($usr[0]) . '</div>');
}
print_unescaped($avatarImg);
p($userMgr->get($usr)->getDisplayName());
} else {
print_unescaped('<th class="user-cell external"> '. $usr);
}
else p($usr);
print_unescaped('</th>');
print_unescaped('<td></td>'); //empty cell for toggle vote (only current user)
$i_tot = -1;
// loop over dts
$i_tot = 0;
foreach($dates as $dt) {
$i_tot++;
$date_id = '';
if ($poll_type === '0') {
if ($poll->getType() === '0') {
$date_id = strtotime($dt->getDt());
}
else {
} else {
$date_id = $dt->getText();
}
// look what user voted for this dts
@ -192,8 +180,7 @@ else $line = $l->t('No description provided.');
if ($vote->getType() === '1') {
$cl = 'poll-cell-is';
$total_y[$i_tot]++;
}
else if ($vote->getType() === '0') {
} else if ($vote->getType() === '0') {
$cl = 'poll-cell-not';
$total_n[$i_tot]++;
} else {
@ -207,35 +194,32 @@ else $line = $l->t('No description provided.');
$cl = 'poll-cell-un';
}
print_unescaped('<td class="' . $cl . '"></td>');
$i_tot++;
}
print_unescaped('<td></td>');
print_unescaped('</tr>');
}
}
// -------------- current user --------------
?>
<tr>
<?php
$total_y_others = array_merge(array(), $total_y);
$total_n_others = array_merge(array(), $total_n);
if (!$expired) {
print_unescaped('<tr class="current-user">');
if (User::isLoggedIn()) {
print_unescaped('<th class="user-cell">');
$avatar = $avaMgr->getAvatar($userId)->get(32);
if($avatar !== false) {
$avatarImg = '<img class="userNameImg" src="data:' . $avatar->mimeType() . ';base64,' . $avatar . '" />';
print_unescaped('<img class="userNameImg" src="data:' . $avatar->mimeType() . ';base64,' . $avatar . '" />');
} else {
$avatarImg = '<div class="userNameImg noAvatar" style="background-color:' . getHsl($userId) . ';">' . strtoupper($userId[0]) . '</div>';
print_unescaped('<div class="userNameImg noAvatar" style="background-color:' . getHsl($userId) . ';">' . strtoupper($userId[0]) . '</div>');
}
print_unescaped($avatarImg);
p($userMgr->get($userId)->getDisplayName());
print_unescaped('</th>');
} else {
print_unescaped('<th id="id_ac_detected" ><input type="text" name="user_name" id="user_name" /></th>');
print_unescaped('<th id="id_ac_detected" class="external current-user"><input type="text" name="user_name" id="user_name" placeholder="' . $l->t('Your name here') . '" /></th>');
}
print_unescaped('<td class="toggle-all selected-maybe"></td>');
$i_tot = -1;
$date_id = '';
$i_tot = 0;
foreach ($dates as $dt) {
$i_tot++;
if ($poll_type === '0') {
if ($poll->getType() === '0') {
$date_id = strtotime($dt->getDt());
} else {
$date_id = $dt->getText();
@ -245,8 +229,11 @@ else $line = $l->t('No description provided.');
if (isset($user_voted)) {
foreach ($user_voted as $obj) {
$voteVal = null;
if($poll_type === '0') $voteVal = strtotime($obj->getDt());
else $voteVal = $obj->getText();
if($poll->getType() === '0') {
$voteVal = strtotime($obj->getDt());
} else {
$voteVal = $obj->getText();
}
if ($voteVal === $date_id) {
if ($obj->getType() === '1') {
$cl = 'poll-cell-active-is';
@ -255,7 +242,6 @@ else $line = $l->t('No description provided.');
$cl = 'poll-cell-active-not';
$total_n[$i_tot]++;
} else if($obj->getType() === '2'){
//$total_m[$i_tot]++;
$cl = 'poll-cell-active-maybe';
}
break;
@ -263,105 +249,101 @@ else $line = $l->t('No description provided.');
}
}
print_unescaped('<td class="cl_click ' . $cl . '" id="' . $date_id . '"></td>');
$i_tot++;
}
print_unescaped('<td class="toggle-all selected-maybe"></td></tr>');
}
?>
</tr>
<?php // --------------- total -------------------- ?>
</tbody>
<tbody class="total">
<?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>
<th><?php p($l->t('Total')); ?>:</th>
<td></td>
<?php for ($i = 0; $i < count($dates); $i++) : ?>
<td>
<table id="id_tab_total">
<tr>
<?php if($poll_type === '0'): ?>
<?php $classSuffix = strtotime($dates[$i]->getDt()); ?>
<?php else : ?>
<?php $classSuffix = str_replace(' ', '_', $dates[$i]->getText()); ?>
<?php endif; ?>
<td id="id_y_<?php p($classSuffix); ?>"
<?php if(isset($total_y[$i])) : ?>
<?php if( $total_y[$i] - $total_n[$i] === $max_votes) : ?>
<th><?php p($l->t('Total')); ?></th>
<?php for ($i = 0 ; $i < count($dates) ; $i++) : ?>
<td class="total">
<?php
$class = 'cl_total_y cl_win';
$classSuffix = $poll->getType() === '0' ? strtotime($dates[$i]->getDt()) : str_replace(' ', '_', $dates[$i]->getText());
if (isset($total_y[$i])) {
$val = $total_y[$i];
} else {
$val = 0;
}
?>
<?php else : ?>
<?php $class='cl_total_y'; ?>
<?php endif; ?>
<?php $val = $total_y[$i]; ?>
<?php else : ?>
<?php $val = 0; ?>
<?php endif; ?>
class="<?php p($class); ?>"><?php p($val); ?>
</td>
</tr>
<tr>
<td id="id_n_<?php p($classSuffix); ?>" class="cl_total_n"><?php p(isset($total_n[$i]) ? $total_n[$i] : '0'); ?></td>
</tr>
</table>
<div id="id_y_<?php p($classSuffix); ?>" class="color_yes" data-value=<?php p(isset($total_y_others[$i]) ? $total_y_others[$i] : '0'); ?>>
<?php p($val); ?>
</div>
<div id="id_n_<?php p($classSuffix); ?>" class="color_no" data-value=<?php p(isset($total_n_others[$i]) ? $total_n_others[$i] : '0'); ?>>
<?php p(isset($total_n[$i]) ? $total_n[$i] : '0'); ?>
</div>
</td>
<?php endfor; ?>
</tr>
<?php // ------------ winner ----------------------- ?>
<tr>
<th><?php p($l->t('Win:')); ?></th>
<td></td>
<?php for ($i = 0; $i < count($dates); $i++) :
</tr>
<tr>
<th><?php p($l->t('Best option')); ?></th>
<?php
for ($i = 0; $i < count($dates); $i++) {
$check = '';
if ($total_y[$i] - $total_n[$i] === $max_votes){
$check = 'icon-checkmark';
}
print_unescaped('<td class="win_row ' . $check . '" id="id_total_' . $i . '"></td>');
endfor;
?>
</tr>
<?php
if ($poll_type === '0'){
print_unescaped('<tr><td></td><td></td>');
for ($i = 0; $i < count($dates); $i++) {
$ch_obj = date('H:i', strtotime($dates[$i]->getDt()));
print_unescaped('<th>' . $ch_obj . '</th>');
}
print_unescaped('</tr>');
print_unescaped('<tr><td></td><td></td>' . $for_string_dates . '</tr>');
?>
<td class="bordered"></td>
</tr>
</tbody>
<tfoot>
<?php
if ($poll->getType() === '0') {
print_unescaped('<tr><th rowspan=3></th>');
$prev = "";
for ($i = 0; $i < count($dates); $i++) {
$c = ($prev != date('Y-m-d', strtotime($dates[$i]->getDt())) ? ' bordered' : '');
$prev = date('Y-m-d', strtotime($dates[$i]->getDt()));
$ch_obj = date('H:i', strtotime($dates[$i]->getDt()));
print_unescaped('<th class="time-slot-cell' . $c . '">' . $ch_obj . '</th>');
}
print_unescaped('<th rowspan=3 class="bordered">' . $l->t('All') . '</th></tr>');
print_unescaped('<tr>' . $for_string_dates . '</tr>');
}
?>
<tr>
<th></th>
<th></th>
<?php
if ($poll_type === '0') {
if ($poll->getType() === '0') {
print_unescaped($for_string_years);
}
else {
} else {
print_unescaped('<th></th>');
foreach ($dates as $el) {
print_unescaped('<th title="' . $el->getText() . '">' . $el->getText() . '</th>');
print_unescaped('<th title="' . $el->getText() . '" class="bordered">' . $el->getText() . '</th>');
}
print_unescaped('<th class="bordered"></th>');
}
?>
</tr>
</tfoot>
</table>
</div>
<?php if(User::isLoggedIn()) : ?>
</div>
<div class="input-group share">
<div class="input-group-addon">
<span class="icon-share"></span> Link
</div>
<input type="text" value="<?php p($pollUrl);?>" readonly="readonly">
</div>
<?php if(User::isLoggedIn()) : ?>
<p>
<input type="checkbox" id="check_notif" <?php if($notification !== null) print_unescaped(' checked'); ?> />
<label for="check_notif"><?php p($l->t('Receive notification email on activity')); ?></label>
<br/>
<?php endif; ?>
</p>
<?php endif; ?>
<a href="<?php p($urlGenerator->linkToRoute('polls.page.index')); ?>" style="float:left;padding-right: 5px;"><input type="button" class="icon-home" /></a>
<form name="finish_vote" action="<?php p($urlGenerator->linkToRoute('polls.page.insert_vote')); ?>" method="POST">
<form name="finish_vote" action="<?php p($urlGenerator->linkToRoute('polls.page.insert_vote')); ?>" method="POST">
<input type="hidden" name="pollId" value="<?php p($poll->getId()); ?>" />
<input type="hidden" name="userId" value="<?php p($userId); ?>" />
<input type="hidden" name="dates" value="<?php p($poll->getId()); ?>" />
@ -369,29 +351,56 @@ else $line = $l->t('No description provided.');
<input type="hidden" name="notif" />
<input type="hidden" name="changed" />
<input type="button" id="submit_finish_vote" value="<?php p($l->t('Vote!')); ?>" />
</form>
<?php if(User::isLoggedIn()) : ?>
<a href="<?php p($urlGenerator->linkToRoute('polls.page.index')); ?>" class="button home-link"><?php p($l->t('Polls summary')); ?></a>
<?php endif; ?>
</form>
<?php if($expired) : ?>
<div id="expired_info">
<?php if($expired) : ?>
<div id="expired_info">
<h2><?php p($l->t('Poll expired')); ?></h2>
<p>
<?php p($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()))))); ?>
</p>
</div>
<?php endif; ?>
<?php // -------- comments ---------- ?>
<h2><?php p($l->t('Comments')); ?></h2>
<div class="cl_user_comments">
</div>
<?php endif; ?>
</div>
<div class="col-30">
<h2><?php p($l->t('Comments')); ?></h2>
<div class="comments">
<div class="comment new-comment">
<?php if(!User::isLoggedIn()) : ?>
<div class="comment-content">
<?php
p($l->t('You must be logged in to post a comment.'));
?>
<a href="<?php p($loginUrl); ?>"><?php p($l->t('Login')); ?></a>
</div>
<?php else: ?>
<form name="send_comment" action="<?php p($urlGenerator->linkToRoute('polls.page.insert_comment')); ?>" method="POST">
<input type="hidden" name="pollId" value="<?php p($poll->getId()); ?>" />
<input type="hidden" name="userId" value="<?php p($userId); ?>" />
<div class="comment-content">
<textarea id="commentBox" name="commentBox"></textarea>
<p>
<input type="button" id="submit_send_comment" value="<?php p($l->t('Send!')); ?>" />
<span class="icon-loading-small" style="float:right;"></span>
</p>
</div>
</form>
<?php endif; ?>
</div>
<?php if($comments !== null) : ?>
<?php foreach ($comments as $comment) : ?>
<div class="user_comment">
<div class="comment">
<div class="comment-header">
<?php
print_unescaped('<span class="comment-date">' . date('d.m.Y H:i:s', strtotime($comment->getDt())) . '</span>');
p($userMgr->get($comment->getUserId())->getDisplayName());
print_unescaped(' <i class="date">' . date('d.m.Y H:i', strtotime($comment->getDt())) . '</i>');
?>
<div class="wordwrap user_comment_text">
</div>
<div class="wordwrap comment-content">
<?php p($comment->getComment()); ?>
</div>
</div>
@ -399,22 +408,16 @@ else $line = $l->t('No description provided.');
<?php else : ?>
<?php p($l->t('No comments yet. Be the first.')); ?>
<?php endif; ?>
<div class="cl_comment">
<form name="send_comment" action="<?php p($urlGenerator->linkToRoute('polls.page.insert_comment')); ?>" method="POST">
<input type="hidden" name="pollId" value="<?php p($poll->getId()); ?>" />
<input type="hidden" name="userId" value="<?php p($userId); ?>" />
<?php // -------- leave comment ---------- ?>
<h3><?php p($l->t('Write new Comment')); ?></h3>
<textarea style="width: 300px;" cols="50" rows="3" id="commentBox" name="commentBox"></textarea>
<br/>
<input type="button" id="submit_send_comment" value="<?php p($l->t('Send!')); ?>" />
</form>
</div>
</div>
</div>
</div>
</div>
</div>
<?php
//adapted from jsxc.chat
function getHsl($str) {
//adapted from jsxc.chat
function getHsl($str) {
$hash = 0;
for($i=0; $i<strlen($str); $i++) {
$utf16_char = mb_convert_encoding($str[$i], "utf-16", "utf-8");
@ -426,5 +429,5 @@ else $line = $l->t('No description provided.');
$saturation = 90;
$lightness = 65;
return 'hsl(' . $hue . ', ' . $saturation . '%, ' . $lightness . '%)';
}
}
?>

Просмотреть файл

@ -1,21 +1,26 @@
<?php
\OCP\Util::addStyle('polls', 'main');
\OCP\Util::addStyle('polls', 'list');
\OCP\Util::addScript('polls', 'start');
use OCP\User;
$userId = $_['userId'];
$userMgr = $_['userMgr'];
$urlGenerator = $_['urlGenerator'];
?>
<h1><?php p($l->t('Summary')); ?></h1>
<div class="goto_poll">
<?php
$url = $urlGenerator->linkToRoute('polls.page.index');
?>
<div id="app">
<div id="app-content">
<div id="app-content-wrapper">
<header class="row">
<div class="col-100">
<h1><?php p($l->t('Summary')); ?></h1>
</div>
</header>
<div class="goto_poll col-100">
<?php if(count($_['polls']) === 0) : ?>
<?php p($l->t('No existing polls.')); ?>
<?php else : ?>
<table class="cl_create_form">
<thead>
<tr>
<th><?php p($l->t('Title')); ?></th>
<th id="id_th_descr"><?php p($l->t('Description')); ?></th>
@ -26,11 +31,13 @@
<th id="id_th_descr"><?php p($l->t('Access')); ?></th>
<th><?php p($l->t('Options')); ?></th>
</tr>
</thead>
<tbody>
<?php foreach ($_['polls'] as $poll) : ?>
<?php
if (!userHasAccess($poll, $userId)) continue;
// direct url to poll
$pollUrl = $url . 'goto/' . $poll->getHash();
$pollUrl = $urlGenerator->linkToRoute('polls.page.goto_poll', array('hash' => $poll->getHash()));
?>
<tr>
<td title="<?php p($l->t('Go to')); ?>">
@ -44,7 +51,7 @@
}
?>
<td><?php p($desc_str); ?></td>
<td class="cl_poll_url" title="<?php p($l->t('Click to get link')); ?>"><input type="hidden" value="<?php p($pollUrl); ?>" /><?php p(date('d.m.Y H:i', strtotime($poll->getCreated()))); ?></td>
<td><?php p(date('d.m.Y H:i', strtotime($poll->getCreated()))); ?></td>
<td>
<?php
if($poll->getOwner() === $userId) p($l->t('Yourself'));
@ -92,7 +99,7 @@
<div class="partic_all <?php p($partic_class); ?>">
</div>
</td>
<td <?php if ($poll->getOwner() === $userId) print_unescaped('class="cl_poll_access" id="cl_poll_access_' . $poll->getId() . '" title="'.$l->t('Edit access').'"'); ?> >
<td>
<?php p($l->t($poll->getAccess())); ?>
</td>
<td>
@ -100,15 +107,20 @@
<input type="button" id="id_del_<?php p($poll->getId()); ?>" class="table_button cl_delete icon-delete"></input>
<a href="<?php p($urlGenerator->linkToRoute('polls.page.edit_poll', ['hash' => $poll->getHash()])); ?>"><input type="button" id="id_edit_<?php p($poll->getId()); ?>" class="table_button cl_edit icon-rename"></input></a>
<?php endif; ?>
<input type="button" class="table_button cl_link icon-public" data-url="<?php p(OCP\Util::linkToAbsolute('', $pollUrl)); ?>" title="<?php p($l->t('Click to get link')); ?>"></input>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<form id="form_delete_poll" name="form_delete_poll" action="<?php p($urlGenerator->linkToRoute('polls.page.delete_poll')); ?>" method="POST">
</form>
<?php endif; ?>
<a href="<?php p($urlGenerator->linkToRoute('polls.page.create_poll')); ?>"><input type="button" id="submit_new_poll" class="icon-add" /></a>
</div>
</div>
</div>
</div>
<a href="<?php p($urlGenerator->linkToRoute('polls.page.create_poll')); ?>"><input type="button" id="submit_new_poll" class="icon-add" /></a>
<?php
// ---- helper functions ----

Просмотреть файл

@ -1,13 +1,21 @@
<?php
\OCP\Util::addStyle('polls', 'main');
\OCP\Util::addStyle('polls', 'main');
?>
<h1>
<center>
<?php p($l->t('Error')); ?>
</center>
</h1>
<h2>
<center>
<div id="app">
<div id="app-content">
<div id="app-content-wrapper">
<header>
<div class="row">
<div class="col-100">
<h1>
<?php p($l->t('Access denied')); ?>
</h1>
<h2>
<?php p($l->t('You are not allowed to view this poll or the poll does not exist.')); ?>
</center>
</h2>
</h2>
</div>
</div>
</header>
</div>
</div>
</div>