@@ -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 /**
0 commit comments