Skip to content
This repository was archived by the owner on Mar 30, 2024. It is now read-only.

Commit d4444b1

Browse files
committed
fix #32
1 parent ff37068 commit d4444b1

File tree

12 files changed

+251
-51
lines changed

12 files changed

+251
-51
lines changed

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
latest
2-
1.1.6
2+
1.1.7
33
1.1
44
1

core/Poll.php

Lines changed: 71 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ public function saveSendData( $template ){
7171
//parse name and mail
7272
$name = Utilities::validateInput($_POST['name'], self::PREG_NAME, self::MAXL_NAME);
7373
$mail = empty( $_POST['email'] ) ? '[email protected]' : Utilities::validateInput($_POST['email'], self::PREG_MAIL, self::MAXL_MAIL);
74+
$showuser = !empty( $_POST['showuser'] ) && $_POST['showuser'] == 'show';
7475

7576
if( $this->pollsub === false ){
7677
$this->pollsub = new JSONReader( 'pollsub_' . $this->id, true); //directly exclusive
@@ -110,14 +111,40 @@ public function saveSendData( $template ){
110111
return false;
111112
}
112113

114+
//parse additionals
115+
$additionals = array();
116+
if( $this->polldata->isValue(['additionals']) ){
117+
foreach( $this->polldata->getValue(['additionals']) as $key => $add ){
118+
if( !empty( $_POST['additional_' . $key] ) ){
119+
$addhere = ($add['type'] === 'text' ? Utilities::validateInput($_POST['additional_' . $key], PollCreator::PREG_TEXTINPUT, PollCreator::MAXL_TEXTINPUT) : true);
120+
if( !empty($addhere) ){
121+
$additionals[] = $addhere;
122+
}
123+
else{
124+
$this->error = LanguageManager::getTranslation('FillAdditionals');
125+
return false;
126+
}
127+
}
128+
else if ( empty( $_POST['additional_' . $key] ) && $add['require'] ){
129+
$this->error = LanguageManager::getTranslation('FillAdditionals');
130+
return false;
131+
}
132+
else{
133+
$additionals[] = ($add['type'] === 'text' ? '' : false);
134+
}
135+
}
136+
}
137+
113138
//save
114139
$editcode = sha1($name . $mail) . Utilities::randomCode(10,Utilities::POLL_ID);
115140
$addedids = array();
116141
$userar = array(
117142
"name" => $name,
118143
"mail" => $mail,
144+
"showuser" => $showuser,
119145
"time" => time(),
120-
"editcode" => $editcode
146+
"editcode" => $editcode,
147+
"additionals" => $additionals
121148
);
122149
foreach( $termine as $id ){
123150
if( $this->pollsub->isValue( [$id] ) ){
@@ -191,33 +218,38 @@ public function showPollForm( $template ){
191218
$template->setContent( 'POLLDESCRIPT', Utilities::optimizeOutputString($this->polldata->getValue( ['description'] )) );
192219
$template->setContent( 'POLLID', $this->id );
193220
$template->setContent( 'DELSUBAPI', URL::generateAPILink( 'delsubmission', array( 'poll' => $this->id ) ) );
194-
195221

196-
197222
$type = $this->polldata->getValue( ['formtype'] );
223+
224+
if( $type === 'meeting' ){ // meetings will always list the names!
225+
$template->setContent( 'ATTRSHOWNAME', 'checked="checked" disabled="disabled"');
226+
}
227+
198228
$termine = array();
199229
foreach( $this->polldata->getValue( ['termine'] ) as $id => $values){
230+
$schon = $this->pollsub->isValue( [$id] ) ? count( $this->pollsub->getValue( [$id] ) ) : 0;
231+
200232
if( $type === 'person' ){
201-
$schon = $this->pollsub->isValue( [$id] ) ? count( $this->pollsub->getValue( [$id] ) ) : 0;
202233
$anzval = $schon . '/' . $values["anz"];
203-
204234
$disable = $schon >= $values["anz"] ? ' disabled="disabled"' : '';
205235
}
206236
else{
207-
if( $this->pollsub->isValue( [$id] ) ){
208-
$names = array();
209-
foreach( $this->pollsub->getValue( [$id] ) as $user){
237+
$disable = '';
238+
$anzval = $schon;
239+
}
240+
if( $schon > 0 ){
241+
$names = array();
242+
foreach( $this->pollsub->getValue( [$id] ) as $user){
243+
if( $type === 'meeting' || ( !empty($user['showuser']) && $user['showuser'] ) ){
210244
$names[] = Utilities::optimizeOutputString( $user['name'] );
211245
}
246+
}
247+
if( !empty($names) ){
212248
$anzval = Utilities::getCollapseHtml(
213-
LanguageManager::getTranslation("Teilnehm"),
249+
LanguageManager::getTranslation("Teilnehm") . ' – ' . $anzval,
214250
'<ul class="list-group"><li class="list-group-item">' . implode( '</li><li class="list-group-item">', $names ). '</li></ul>'
215251
);
216252
}
217-
else{
218-
$anzval = '';
219-
}
220-
$disable = '';
221253
}
222254
$termine[] = array(
223255
"NAME" => Utilities::optimizeOutputString( $values["bez"] ),
@@ -244,6 +276,32 @@ public function showPollForm( $template ){
244276
)
245277
);
246278
}
279+
280+
//additional inputs
281+
if( $this->polldata->isValue(['additionals']) ){
282+
$texts = array();
283+
$checks = array();
284+
foreach( $this->polldata->getValue(['additionals']) as $key => $add ){
285+
if( $add['type'] === 'text' ){
286+
$texts[] = array(
287+
"ADDNAME" => "additional_" . $key,
288+
"ADDPLACEHOLDER" => $add['text'] . ( $add['require'] ? '' : ' (optional)' )
289+
);
290+
}
291+
else {
292+
$checks[] = array(
293+
"ADDNAME" => "additional_" . $key,
294+
"ADDTEXT" => $add['text'] . ( $add['require'] ? '' : ' (optional)' )
295+
);
296+
}
297+
}
298+
if( !empty($texts) ){
299+
$template->setMultipleContent('AdditionalsText', $texts);
300+
}
301+
if( !empty($checks) ){
302+
$template->setMultipleContent('AdditionalsCheck', $checks);
303+
}
304+
}
247305
}
248306

249307
/**

core/Utilities.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class Utilities{
1616
/**
1717
* The system's Version
1818
*/
19-
const SYS_VERSION = 'v1.1.6';
19+
const SYS_VERSION = 'v1.1.7';
2020

2121
/**
2222
* Possible chars for:

core/api/Export.php

Lines changed: 58 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,15 +59,45 @@ private function csv(){
5959

6060
$data = array();
6161
$data[] = array( $this->polldata->getValue(['pollname']) );
62-
62+
63+
$addsHeader = array();
64+
if( $this->polldata->isValue(['additionals']) ){
65+
foreach( $this->polldata->getValue(['additionals']) as $key => $add ){
66+
$addsHeader[] = $add['text'];
67+
}
68+
}
69+
6370
foreach( $this->polldata->getValue( ['termine'] ) as $id => $values){
6471
$data[] = array();
65-
$data[] = array( $values['bez'] );
72+
$data[] = array_merge(
73+
array( $values['bez'] , '', '', '', '' ),
74+
$addsHeader
75+
);
6676

6777
if( $this->pollsub->isValue( [$id] ) ){
6878
$i = 1;
6979
foreach( $this->pollsub->getValue( [$id] ) as $sub){
70-
$data[] = array( '', $i++, $sub['name'], $sub['mail'], date( 'H:i:s d.m.Y', $sub['time'] ) );
80+
$addsCells = array();
81+
if( $this->polldata->isValue(['additionals']) ){
82+
foreach( $this->polldata->getValue(['additionals']) as $key => $add ){
83+
if( isset($sub['additionals'][$key]) ){
84+
if( $add['type'] === 'checkbox' ){
85+
$addsCells[] = ($sub['additionals'][$key] ? 'yes' : 'no');
86+
}
87+
else {
88+
$addsCells[] = $sub['additionals'][$key];
89+
}
90+
}
91+
else {
92+
$addsCells[] = '';
93+
}
94+
}
95+
}
96+
97+
$data[] = array_merge(
98+
array( '', $i++, $sub['name'], $sub['mail'], date( 'H:i:s d.m.Y', $sub['time'] ) ),
99+
$addsCells
100+
);
71101
}
72102
}
73103
if( $values['anz'] !== false ){
@@ -98,15 +128,38 @@ private function printview(){
98128
$h.= '<h2>' . Utilities::optimizeOutputString( $this->polldata->getValue(['pollname']) ) . '</h2>';
99129
$h .= '<div>' . $mdp->text($this->polldata->getValue( ['description'] )) . '</div>';
100130

131+
$addsHeader = '';
132+
if( $this->polldata->isValue(['additionals']) ){
133+
foreach( $this->polldata->getValue(['additionals']) as $key => $add ){
134+
$addsHeader .= '<th>'. Utilities::optimizeOutputString( $add['text'] ) .'</th>';
135+
}
136+
}
137+
101138
$termine = array();
102139
foreach( $this->polldata->getValue( ['termine'] ) as $id => $values){
103140
$h .= '<hr /><h3>'. Utilities::optimizeOutputString( $values['bez'] ) .'</h3>';
104141
$h .= empty( $values['des'] ) ? '' : '<div>'. $mdp->text($values['des']) .'</div>';
105-
$h .= '<table style="width: 100%;"><tr><th>ID</th><th>Name</th><th>E-Mail</th><th style="width:30%;">Time</th></tr>';
142+
$h .= '<table style="width: 100%;"><tr><th>ID</th><th>Name</th><th>E-Mail</th><th>Time</th>'. $addsHeader .'</tr>';
106143
if( $this->pollsub->isValue( [$id] ) ){
107144
$i = 1;
108145
foreach( $this->pollsub->getValue( [$id] ) as $sub){
109-
$h .= '<tr><td>'. $i++ .'</td><td>'. Utilities::optimizeOutputString( $sub['name'] ) .'</td><td>'. Utilities::optimizeOutputString( $sub['mail'] ) .'</td><td>'. date( 'H:i:s d.m.Y', $sub['time'] ) .'</td></tr>';
146+
$addsCells = '';
147+
if( $this->polldata->isValue(['additionals']) ){
148+
foreach( $this->polldata->getValue(['additionals']) as $key => $add ){
149+
if( isset($sub['additionals'][$key]) ){
150+
if( $add['type'] === 'checkbox' ){
151+
$addsCells .= '<td>'. ($sub['additionals'][$key] ? '&check;' : '&cross;' ) .'</td>';
152+
}
153+
else {
154+
$addsCells .= '<td>'. Utilities::optimizeOutputString( $sub['additionals'][$key] ) .'</td>';
155+
}
156+
}
157+
else {
158+
$addsCells .= '<td></td>';
159+
}
160+
}
161+
}
162+
$h .= '<tr><td>'. $i++ .'</td><td>'. Utilities::optimizeOutputString( $sub['name'] ) .'</td><td>'. Utilities::optimizeOutputString( $sub['mail'] ) .'</td><td>'. date( 'H:i:s d.m.Y', $sub['time'] ) .'</td>'. $addsCells .'</tr>';
110163
}
111164
}
112165
$h .= '</table>';

core/templates/poll.json

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,23 @@
66
"%%TEXTSEINWILL%%" : "",
77
"%%INNERCONTAINER%%" : "",
88
"%%POLLID%%" : "poll",
9+
"%%ATTRSHOWNAME%%" : "",
910
"multiples" : {
1011
"Termin" : {
1112
"%%NAME%%" : "Name",
1213
"%%ANZAHL%%" : "0/10",
1314
"%%HINWEISE%%" : "**bla**",
1415
"%%TERMINID%%" : "termin_a",
1516
"%%DISABLE%%" : ""
16-
}
17+
},
18+
"AdditionalsText" : {
19+
"%%ADDNAME%%" : "",
20+
"%%ADDPLACEHOLDER%%" : ""
21+
},
22+
"AdditionalsCheck" : {
23+
"%%ADDNAME%%" : "",
24+
"%%ADDTEXT%%" : ""
25+
}
1726
},
1827
"%%DELSUBAPI%%": ""
1928
}

core/templates/poll_de.html

Lines changed: 28 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -53,23 +53,42 @@ <h3>Termine</h3>
5353
%%TEXTSEINWILL%%
5454
%%CAPTCHA%%
5555
<div class="alert alert-primary" role="alert">
56-
<div class="row">
56+
<div class="row form-group">
5757
<div class="col-sm">
58-
<div class="form-group">
59-
<input type="text" name="name" placeholder="Name" class="username form-control"
58+
<input type="text" name="name" placeholder="Name" class="username form-control"
6059
title="Name der Person, die den Termin wahrnimmt. &ndash; Pflichtfeld">
61-
</div>
6260
</div>
6361
<div class="col-sm">
64-
<div class="form-group">
65-
<input type="email" name="email" placeholder="E-Mail-Adresse" class="usermail form-control"
62+
<input type="email" name="email" placeholder="E-Mail-Adresse (optional)" class="usermail form-control"
6663
title="E-Mail Adresse der Person für Nachfragen. &ndash; optional und nur für Admins sichtbar">
67-
</div>
6864
</div>
6965
</div>
70-
<div class="row">
66+
<!--MULTIPLE-AdditionalsText-BEGIN-->
67+
<div class="row form-group">
68+
<div class="col-sm">
69+
<input type="text" name="%%ADDNAME%%" placeholder="%%ADDPLACEHOLDER%%" class="form-control othersave">
70+
</div>
71+
</div>
72+
<!--MULTIPLE-AdditionalsText-END-->
73+
<!--MULTIPLE-AdditionalsCheck-BEGIN-->
74+
<div class="row form-group">
75+
<div class="col-sm form-check">
76+
<label class="form-check-label">
77+
<input type="checkbox" name="%%ADDNAME%%" value="yes" class="form-check-input othersave">
78+
%%ADDTEXT%%
79+
</label>
80+
</div>
81+
</div>
82+
<!--MULTIPLE-AdditionalsCheck-END-->
83+
<div class="row form-group">
84+
<div class="col-sm form-check">
85+
<label class="form-check-label">
86+
<input type="checkbox" name="showuser" value="show" class="showuser form-check-input othersave" %%ATTRSHOWNAME%%>
87+
Zeige den oben angegebenen Namen öffentlich auf dieser Seite an.
88+
</label>
89+
</div>
7190
<div class="col-sm">
72-
<input type="submit" class="btn btn-primary" value="Umfrage absenden">
91+
<input type="submit" class="btn btn-primary form-control" value="Umfrage absenden">
7392
</div>
7493
</div>
7594
</div>

core/templates/poll_en.html

Lines changed: 29 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -56,20 +56,39 @@ <h3>Options</h3>
5656
%%CAPTCHA%%
5757
<div class="alert alert-primary" role="alert">
5858
<div class="row">
59-
<div class="col-sm">
60-
<div class="form-group">
61-
<input type="text" name="name" placeholder="Name" class="username form-control"
62-
title="Name of the participant. &ndash; required">
63-
</div>
59+
<div class="col-sm form-group">
60+
<input type="text" name="name" placeholder="Name" class="username form-control"
61+
title="Name of the participant. &ndash; required">
6462
</div>
63+
<div class="col-sm form-group">
64+
<input type="email" name="email" placeholder="E-Mail-Address (optional)" class="usermail form-control"
65+
title="E-Mail-Address corresponding to the participant. &ndash; optional, only visible for admins">
66+
</div>
67+
</div>
68+
<!--MULTIPLE-AdditionalsText-BEGIN-->
69+
<div class="row form-group">
6570
<div class="col-sm">
66-
<div class="form-group">
67-
<input type="email" name="email" placeholder="E-Mail-Address" class="usermail form-control"
68-
title="E-Mail-Address corresponding to the participant. &ndash; optional, only visible for admins">
69-
</div>
71+
<input type="text" name="%%ADDNAME%%" placeholder="%%ADDPLACEHOLDER%%" class="form-control othersave">
7072
</div>
7173
</div>
72-
<div class="row">
74+
<!--MULTIPLE-AdditionalsText-END-->
75+
<!--MULTIPLE-AdditionalsCheck-BEGIN-->
76+
<div class="row form-group">
77+
<div class="col-sm form-check">
78+
<label class="form-check-label">
79+
<input type="checkbox" name="%%ADDNAME%%" value="yes" class="form-check-input othersave">
80+
%%ADDTEXT%%
81+
</label>
82+
</div>
83+
</div>
84+
<!--MULTIPLE-AdditionalsCheck-END-->
85+
<div class="row form-group">
86+
<div class="col-sm form-check">
87+
<label class="form-check-label">
88+
<input type="checkbox" name="showuser" value="show" class="showuser form-check-input othersave" %%ATTRSHOWNAME%%>
89+
Publish my name provided above on this site.
90+
</label>
91+
</div>
7392
<div class="col-sm">
7493
<input type="submit" class="btn btn-primary" value="Submit poll">
7594
</div>

core/templates/pollsaved_de.html

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ <h4 class="alert-heading">Erfolgreich eingetragen!</h4>
2424
</div>
2525

2626
<script>
27-
localStorage.removeItem("pollPollDateData");
28-
var on_site_loaded = () => poll_submissions_delete_code( '%%POLLID%%', %%VALUES%%, '%%CODE%%' );
27+
var on_site_loaded = () => {
28+
poll_submissions_delete_code( '%%POLLID%%', %%VALUES%%, '%%CODE%%' );
29+
delete_wahl_for_poll( '%%POLLID%%' );
30+
}
2931
</script>

core/templates/pollsaved_en.html

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ <h4 class="alert-heading">Successful submitted!</h4>
2424
</div>
2525

2626
<script>
27-
localStorage.removeItem("pollPollDateData");
28-
var on_site_loaded = () => poll_submissions_delete_code( '%%POLLID%%', %%VALUES%%, '%%CODE%%' );
27+
var on_site_loaded = () => {
28+
poll_submissions_delete_code( '%%POLLID%%', %%VALUES%%, '%%CODE%%' );
29+
delete_wahl_for_poll( '%%POLLID%%' );
30+
}
2931
</script>

data/translation_de.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,6 @@
2222
"TermFin": "Termin finden",
2323
"Teilnehm": "Teilnehmende",
2424
"mailAdminNotif": "Neue Teilnahme",
25-
"mailNewPollNotif": "Neue Umfrage erstellt"
25+
"mailNewPollNotif": "Neue Umfrage erstellt",
26+
"FillAdditionals": "Bitte alle Felder füllen, nicht als optional gekennzeichnete Felder sind Pflichtfelder."
2627
}

0 commit comments

Comments
 (0)