Extension:RegistrationForm

This extension stores its source code on a wiki page. Please be aware that this code may be unreviewed or maliciously altered. They may contain security holes, outdated interfaces that are no longer compatible etc.

Please cut and paste the code found below and place it in $IP/extensions/Registration/Registration.php. Note: $IP stands for the root directory of your MediaWiki installation, the same directory that holds LocalSettings.php.

<?php/** * RegistrationForm.php * Written by David Rauber and David Raison * */if(!defined('MEDIAWIKI'))die('This is a MediaWiki extension, and must be run from within MediaWiki.');define("REGNAME","Registration");$wgExtensionCredits['parserhook'][]=array('path'=>__FILE__,'name'=>REGNAME,'version'=>'0.1.1','author'=>'David Rauber and David Raison','url'=>'http://www.mediawiki.org/wiki/Extension:RegistrationForm','description'=>'Inserts a registration form into a page');$wgAutoloadClasses['Registration']=dirname(__FILE__).'/Registration.body.php';$wgExtensionFunctions[]="wfRegistrationExtension";$wgHooks['BeforePageDisplay'][]='wfAddFormScript';/** * Tag extension * Could also use object directly: * $wgParser->setHook('addscript', array( &$asObj, 'pSet' ) ); * or $wgHooks['ParserAfterTidy'][] = array( $asObj, 'feedScripts' ); * What exactly is the difference between addHook and addFunctionHook? */functionwfRegistrationExtension(){global$wgParser;$wgParser->setHook(REGNAME,"handleRegistration");$wgParser->setHook("seatsleft","showTicketsLeft");returntrue;}functionshowTicketsLeft(){$reg=newRegistration();return($reg->countOpenTickets());}/** * See http://www.mediawiki.org/wiki/Manual:Tag_extensions#Example * <tag arg="$arg1">$input</tag> * $parser --> http://svn.wikimedia.org/doc/classParser.html * */functionhandleRegistration($input,$argv,&$parser){$reg=newRegistration();if($_POST['registered'])$output=$reg->saveRegistration($_POST['emailconfirm'],$_POST['captcha']);elseif($_GET['hash'])$output=$reg->confirmEmail($_GET['hash']);else$output=$reg->renderForm($argv['emailconfirm'],$argv['captcha']);return($output);}/** * BAD!! because not working everywhere! * But using the setHook(), this doesn't seem to work :( */functionwfAddFormScript(){if(strpos($_SERVER['REQUEST_URI'],'Registration')){global$wgOut,$wgScriptPath;$wgOut->addScript('<script type="text/javascript" src="'.$wgScriptPath.'/extensions/Registration/formSetup.js"></script>'."\n");$wgOut->addInlineScript('addOnloadHook(shirts);');}returntrue;}