FS-Mod/Erstifahrt/SpecialOE_Anmeldung.php
Einhard Leichtfuß 99bd42e0ee
Fix error in Erstifahrt special pages
The error was previously attempted to be fixed in merge commit
05b36dfd0b.  That did not fix it.

The problem was that the Sanitizer::encodeAttribute() function takes a
string, which an int apparently can be implicitly converted to, unlike
null.

We had a few default form input values configured as null.  Changed to
''.
2024-08-12 00:01:37 +02:00

275 lines
8.9 KiB
PHP

<?php
/**
* Special:OE_Anmeldung, a special page that implements a OE form.
* @file
* @ingroup Extensions
* @author Michel Spils
* @copyright © 2010 Mi
* @license GNU General Public Licence 2.0 or later
* modified 202-:
*/
if( !defined( 'MEDIAWIKI' ) ) {
echo( "not a valid entry point.\n" );
die( 1 );
}
/**
* Provides the OE form
* @ingroup SpecialPage
*/
class Orientierungseinheit extends SpecialPage {
/**
* Constructor
*/
public function __construct() {
parent::__construct( 'Orientierungseinheit' );
}
/**
* Main execution function
*
* @param $par Mixed: Parameters passed to the page
*/
public function execute( $par ) {
$out = $this->getOutput();
$request = $this->getRequest();
//wfLoadExtensionMessages( 'OePage' );
$action = $request->getVal( 'action' );
$f = new OeAnmeldungForm();
// for some reason we nolonger check that all required information is present
if ( 'submit' == $action && $request->wasPosted()) {
$debug = ($request->getVal('debug') ?? "") === "debug";
$data['name'] = $request->getText( 'wpOeName' );
$data['fach'] = $request->getText( 'wpOeFach' );
$data['stud'] = $request->getText( 'wpOeStud' );
$data['mail'] = $request->getText( 'wpOeMail' ) ?? "";
$data['ralley'] = $request->getText( 'wpOeRalley' );
$data['brau'] = "Nein"; // $request->getText( 'wpOeBrau' );
$data['food'] = $request->getText( 'wpOeFood' );
$data['foodOmni'] = $request->getText('wpOeFoodOmni') ? "Ja" : "Nein";
$data['foodVeget'] = $request->getText('wpOeFoodVeget') ? "Ja" : "Nein";
$data['foodVegan'] = $request->getText('wpOeFoodVegan') ? "Ja" : "Nein";;
$out->setPageTitle( 'Orientierungseinheit Anmeldung' );
$titleObj = SpecialPage::getTitleFor( 'Orientierungseinheit' );
$out->addHTML( "<p>Deine Anmeldung wurde erfolgreich übermittelt. Du stehst nun auf der Anmeldeliste und wirst von uns über den weiteren Ablauf informiert.</p>" );
$mailtext = <<<"MAIL"
Name:
{$data['name']}
Studiengang: {$data['fach']} {$data['stud']}
E-Mail: {$data['mail']}
Allergien/Besonderheiten für\x27s Essen:
{$data['food']}
Grillgut:
Omnivor: {$data['foodOmni']}
Vegetarisch: {$data['foodVeget']}
Vegan: {$data['foodVegan']}
Ralley: {$data['ralley']}
Brauerei: {$data['brau']}
Maschinenlesbar:
{$data['name']},{$data['fach']},{$data['stud']},{$data['mail']},{$data['foodOmni']},{$data['foodVeget']},{$data['foodVegan']},{$data['ralley']},{$data['brau']}
MAIL;
$betreff = '[OE] Orientierungseinheit Anmeldung';
$header = 'From: noreply@fs-infmath.uni-kiel.de' . "\r\n" .
'Content-type: text/plain; charset=UTF-8' . "\r\n" .
'X-Mailer: FS-Wiki';
if ($debug) {
mail('ben@fs-infmath.uni-kiel.de' , "Debug: ".$betreff, $mailtext, $header);
} else {
// Funktionsadresse hier rein
mail('oe-orga@fs-infmath.uni-kiel.de', $betreff, $mailtext, $header);
}
} else {
wfDebug( __METHOD__ . ": form\n" );
$f->showForm($out);
}
}
}
/**
* @todo document
* @ingroup SpecialPage
*/
class OeAnmeldungForm {
// These are the default values.
public $name = '';
public $escape = '';
public $ralley = '';
public $stud = '';
public $times = '';
public $mail = '';
public $food = '';
function showForm($out) {
$out->setPageTitle( 'Orientierungseinheit Anmeldung' );
$titleObj = SpecialPage::getTitleFor( 'Orientierungseinheit' );
$action = $titleObj->getLocalURL( 'action=submit' );
$out->addHTML( "<p>Wenn noch Fragen bestehen oder Probleme aufgetreten sind, wende dich bitte an <a href=\"mailto:oe-orga@fs-infmath.uni-kiel.de\">oe-orga@fs-infmath.uni-kiel.de</a>.</p>" );
// prepare form elements
[$lableName, $inputName] = Xml::inputLabelSep("Name*", "wpOeName", "wpOeName", 60, $this->name, array( 'type' => 'text', 'maxlength' => 255, 'required' => 'required' ));
$lableStud = Xml::label( 'Studiengang*', 'wpOeStud' );
$stud1Fach = Xml::radioLabel('1-Fach', 'wpOeFach', '1-Fach', '1Fach', $this->stud == "1-Fach", array('required' => 'required'));
$stud2Fach = Xml::radioLabel('2-Fach', 'wpOeFach', '2-Fach', '2Fach', $this->stud == "2-Fach", array('required' => 'required'));
$studInf = Xml::radioLabel('Informatik' , 'wpOeStud', 'Informatik' , 'Inf' , $this->stud == "Informatik" , array('required' => 'required'));
$studWInf = Xml::radioLabel('Wirtschaftsinformatik', 'wpOeStud', 'Wirtschaftsinformatik', 'WInf', $this->stud == "Wirtschaftsinformatik", array('required' => 'required'));
$studMath = Xml::radioLabel('Mathematik' , 'wpOeStud', 'Mathematik' , 'Math', $this->stud == "Mathematik" , array('required' => 'required'));
[$lableMail, $inputMail] = Xml::inputLabelSep('E-Mail' ,'wpOeMail','wpOeMail', 60, $this->mail, array( 'type' => 'email', 'maxlength' => 255 ) );
[$lableFood, $inputFood] = Xml::inputLabelSep('Allergien/Besonderheiten für\'s Essen' ,'wpOeFood','wpOeFood', 60, $this->food, array( 'type' => 'text', 'maxlength' => 255 ) );
$lableGrill = Xml::label( 'Gewünschtes Grillgut', 'grill' );
$inputOmni = Xml::checkLabel("Omnivor" , "wpOeFoodOmni" , "foodOmni" , false, array('value' => '1'));
$inputVeget = Xml::checkLabel("Vegetarisch", "wpOeFoodVeget", "foodVeget", false, array('value' => '1'));
$inputVegan = Xml::checkLabel("Vegan" , "wpOeFoodVegan", "foodVegan", false, array('value' => '1'));
$lableRalley = Xml::label( 'Teilnahme Rallye*', 'wpOeRalley' );
$ralleyJa = Xml::radioLabel("Ja" , 'wpOeRalley', "Ja" , "ralleyJa" , $this->ralley == "Ja" , array('required' => 'required'));
$ralleyNein = Xml::radioLabel("Nein", 'wpOeRalley', "Nein", "ralleyNein", $this->ralley == "Nein", array('required' => 'required'));
$lableBrau = Xml::label( 'Brauerei', 'wpOeBrau' );
// $brauJa = Xml::radioLabel("Ja" , 'wpOeBrau', "Ja" ,"brauJa" , $this->ralley == "Ja" , array('required' => 'required'));
// $brauNein = Xml::radioLabel("Nein", 'wpOeBrau', "Nein","brauNein", $this->ralley == "Nein" , array('required' => 'required'));
$debug = Xml::element( 'input', array('type' => 'hidden', 'name' => 'debug', 'value' => 'false', 'selected' => 'selected' ));
$inputSubmit = Xml::submitButton( 'Senden', array( 'name' => 'wpOeSend', 'accesskey' => 's' ) );
// add form to output
$out->addHTML(
Xml::openElement( 'form', array( 'method' => 'post', 'action' => $action, 'enctype' => 'multipart/form-data' ) ) .
Xml::openElement( 'fieldset' ) .
Xml::element( 'legend', null, 'Orientierungseinheit Anmeldung' ) .
Xml::openElement( 'table', array( 'id' => 'oeheader' ) ) .
"<tr>
<td class='mw-label'>
$lableName
</td>
<td class='mw-input' id='mw-oe-name' colspan='2'>
$inputName
</td>
</tr>
<tr>
<td class='mw-label'>
$lableStud
</td>
<td class='mw-input' id='mw-oe-stud'>
$stud1Fach<br />
$stud2Fach<br />
</td>
<td class='mw-input' id='mw-oe-stud'>
$studInf<br />
$studWInf<br />
$studMath<br />
</td>
</tr>
<tr>
<td class='mw-label'>
$lableMail
</td>
<td class='mw-input' id='mw-oe-mail' colspan='2'>
$inputMail
</td>
</tr>
<tr>
<td class='mw-label'>
$lableFood
</td>
<td class='mw-input' id='mw-Oepage-food' colspan='2'>
$inputFood
</td>
</tr>
<tr>
<td class='mw-label'>
$lableGrill
</td>
<td class='mw-input' id='mw-Oepage-grillgut' colspan='2'>
$inputOmni<br />
$inputVeget<br />
$inputVegan<br />
</td>
</tr>
<tr>
<td class='mw-label'>
$lableRalley
</td>
<td class='mw-input' id='mw-oe-ralley' colspan='2'>
$ralleyJa<br />
$ralleyNein<br />
</td>
</tr>
<tr>
<td class='mw-label'>
$lableBrau
</td>
<td class='mw-input' id='mw-oe-brau' colspan='2'>
Die Brauerei ist leider ausgebucht.
</td>
</tr>
<tr>
<td></td>
<td class='mw-submit' colspan='2'>
$debug
$inputSubmit <br />
<br />
* Pflichtfeld.<br />
Bitte habt Verständnis, dass unvollständig ausgefüllte Anmeldungen nicht bearbeitet werden können.<br />
Alle mit * markierten Felder sind daher auszufüllen.<br />
<br />
</td>
</tr>
<tr>
<td colspan='2'>
<p><strong>Denkt daran, dass ihr die Uni-Gebäude nur betreten dürft, wenn ihr geimpft, genesen oder getestet seid</strong></p>
</td>
</tr>" .
Xml::closeElement( 'table' ) .
Xml::closeElement( 'fieldset' ) .
Xml::closeElement( 'form' )
);
}
}