Convention.php

Go to the documentation of this file.
00001 <?php
00002 /************************************************************************
00003                         Convention.php - Copyright arklinux
00004 
00005 Here you can write a license for your code, some comments or any other
00006 information you want to have in your generated code. To to this simply
00007 configure the "headings" directory in uml to point to a directory
00008 where you have your heading files.
00009 
00010 or you can just replace the contents of this file with your own.
00011 If you want to do this, this file is located at
00012 
00013 /usr/share/apps/umbrello/headings/heading.php
00014 
00015 -->Code Generators searches for heading files based on the file extension
00016    i.e. it will look for a file name ending in ".h" to include in C++ header
00017    files, and for a file name ending in ".java" to include in all generated
00018    java code.
00019    If you name the file "heading.<extension>", Code Generator will always
00020    choose this file even if there are other files with the same extension in the
00021    directory. If you name the file something else, it must be the only one with that
00022    extension in the directory to guarantee that Code Generator will choose it.
00023 
00024 you can use variables in your heading files which are replaced at generation
00025 time. possible variables are : author, date, time, filename and filepath.
00026 just write %variable_name%
00027 
00028 This file was generated on %date% at %time%
00029 The original location of this file is /home/arklinux/public_html/confuzled/setup/modules/convention/code/Convention.php
00030 **************************************************************************/
00031 
00032 
00033 
00037 class Convention extends lockableClass
00038 {
00039         var $membershipTypes;              
00040         var $optionalChoices;              
00041         var $hotels;
00042         var $members;
00043         var $events;                       
00044         var $adminConfirmation;            
00045         
00046         var $title;
00047         var $description;
00048         var $requestTShirtSize;            
00049         var $emailFooter;
00050         var $startDate;
00051         var $endDate;
00052         var $owner;
00053         var $registrationEnabled;           
00054         var $eventLapse;                    
00055         var $averagePerRoom;                
00056         
00057         var $emailSubjects;                 
00058         var $emailBodies;                   
00059         
00060         var $nextID = -1;                   
00061         var $nextMemberID = -1;             
00062         
00063         var $currentAvailable;
00064         var $id;
00065         var $conventionBasedir;
00066         
00073         function Convention( $conventionID = 0 )
00074         {
00075                 global $conventionSettings;
00076                 
00077                 if( $conventionID == 0 )
00078                         $this->id = $conventionSettings->nextConventionID();
00079                 else
00080                         $this->id = $conventionID;
00081                 
00082                 $this->conventionBasedir = $conventionSettings->conventionDir . "/" . $this->id;
00083                 $this->lockfile = $this->conventionBasedir . "/locked";
00084                 
00085                 if( $conventionID != 0 )
00086                 {
00087                         if( $this->lock() )
00088                         {
00089                                 $this->load();
00090                                 $this->unlock();
00091                         }
00092                         else
00093                                 die( "Timeout error. Please go back and try again." );
00094                 }
00095                 else
00096                 {
00097                         $this->emailSubjects = $this->emailBodies = $this->hotels = $this->events = $this->members = $this->membershipTypes = $this->optionalChoices = array();
00098                         $this->emailSubjects["initial"] = "";
00099                         $this->emailBodies["initial"] = "";
00100                         $this->emailSubjects["initial2"] = "";
00101                         $this->emailBodies["initial2"] = "";
00102                         $this->emailSubjects["confirmed"] = "";
00103                         $this->emailBodies["confirmed"] = "";
00104                 }
00105         }
00106         
00107         function load()
00108         {
00109                 if( file_exists( $this->conventionBasedir . "/convention.php" ) )
00110                 {
00111                         include( $this->conventionBasedir . "/convention.php" );
00112                         
00113                         $totalAvailable = 0;
00114                         foreach( $settings as $key => $value )
00115                         {
00116                                 switch( $key )
00117                                 {
00118                                 case "membershipTypes":
00119                                         foreach( $value as $key2 => $value2 )
00120                                         {
00121                                                 $this->membershipTypes[$value2] = new MembershipType(&$this, $value2);
00122                                                 $totalAvailable += $this->membershipTypes[$key2]->maxCount;
00123                                         }
00124                                         break;
00125                                 case "optionalChoices":
00126                                         foreach( $value as $key2 => $value2 )
00127                                                 $this->optionalChoices[$key2] = new OptionalChoice(&$this, $value2);
00128                                         break;
00129                                 case "members":
00130                                         foreach( $value as $key2 => $value2 )
00131                                                 $this->members[$value2] = new Member(&$this, $value2);
00132                                         break;
00133                                 case "hotels":
00134                                         foreach( $value as $key2 => $value2 )
00135                                                 $this->hotels[$key2] = new Hotel(&$this, $value2);
00136                                         break;
00137                                 case "events":
00138                                         foreach( $value as $key2 => $value2 )
00139                                                 $this->events[$key2] = new Event(&$this, $value2);
00140                                         break;
00141                                 default:
00142                                         $this->$key = $value;
00143                                 }
00144                         }
00145                 }
00146                 
00147                 if( $this->emailSubjects["initial"] == "" )
00148                         $this->emailSubjects["initial"] = "##convention## registration - confirmation information";
00149                 if( $this->emailBodies["initial"] == "" )
00150                         $this->emailBodies["initial"] = "You have successfully registered for ##convention##, but your membership needs to be confirmed by the staff. Should you later change your email address, this will happen again.";
00151                 
00152                 if( $this->emailSubjects["initial2"] == "" )
00153                         $this->emailSubjects["initial2"] = "##convention## registration - confirmation information";
00154                 if( $this->emailBodies["initial2"] == "" )
00155                 {
00156                         $this->emailBodies["initial2"] .= "You have successfully registered for ##convention##, but you still need to confirm your registration. Doing this can be done simply by clicking on the link below:";
00157                         $this->emailBodies["initial2"] .= "\n\n" . globalIDtoURL( "convention/confirm/##conventionid##/##confirmationcode##" );
00158                         $this->emailBodies["initial2"] .= "\n\n" . i18n( "If the above URL does not work, please go to ##0## and fill out the information. Your ID is ##regid##, your username is ##username## and your confirmation code is ##confirmationcode##.", array( globalIDtoURL( "convention/confirm" ) ) );
00159                 }
00160                 
00161                 if( $this->emailSubjects["confirmed"] == "" )
00162                         $this->emailSubjects["confirmed"] = "##convention## registration - confirmed";
00163                 if( $this->emailBodies["confirmed"] == "" )
00164                 {
00165                         $this->emailBodies["confirmed"] = "Thank you for registering for ##convention##. This is confirmation that your registration has been accepted. Please see the website for details on payment options.";
00166                         $this->emailBodies["confirmed"] .= "\n\n" . "Registration ID: ##regid##";
00167                         $this->emailBodies["confirmed"] .= "\n" . "Username: ##username##";
00168                         $this->emailBodies["confirmed"] .= "\n" . "Password: ##password##";
00169                 }
00170                 
00171                 if( $this->emailSubjects["confirmed2"] == "" )
00172                         $this->emailSubjects["confirmed2"] = "##convention## registration - confirmed";
00173                 if( $this->emailBodies["confirmed2"] == "" )
00174                 {
00175                         $this->emailBodies["confirmed2"] = "You have successfully confirmed your registration for ##convention##. Your login information can be found below. Please retain this information for future reference! See the website for details on payment options.";
00176                         $this->emailBodies["confirmed2"] .= "\n\n" . "Registration ID: ##regid##";
00177                         $this->emailBodies["confirmed2"] .= "\n" . "Username: ##username##";
00178                         $this->emailBodies["confirmed2"] .= "\n" . "Password: ##password##";
00179                 }
00180                 
00181                 if( !is_array( $this->membershipTypes ) )
00182                         $this->membershipTypes = array();
00183                 if( !is_array( $this->optionalChoices ) )
00184                         $this->optionalChoices = array();
00185                 if( !is_array( $this->members ) )
00186                         $this->members = array();
00187                 if( !is_array( $this->hotels ) )
00188                         $this->hotels = array();
00189                 if( !is_array( $this->events ) )
00190                         $this->events = array();
00191                 if( !is_array( $this->emailSubjects ) )
00192                         $this->emailSubjects = array();
00193                 if( !is_array( $this->emailBodies ) )
00194                         $this->emailBodies = array();
00195                 
00196                 ksort($this->members);
00197                 $this->currentAvailable = $totalAvailable - count($this->members);
00198         }
00199         
00200         function save()
00201         {
00202                 $settings["title"] = $this->title;
00203                 $settings["description"] = $this->description;
00204                 $settings["requestTShirtSize"] = $this->requestTShirtSize;
00205                 $settings["registrationEnabled"] = $this->registrationEnabled;
00206                 $settings["eventLapse"] = $this->eventLapse;
00207                 $settings["startDate"] = $this->startDate;
00208                 $settings["endDate"] = $this->endDate;
00209                 $settings["owner"] = $this->owner;
00210                 $settings["nextID"] = $this->nextID;
00211                 $settings["nextMemberID"] = $this->nextMemberID;
00212                 $settings["adminConfirmation"] = $this->adminConfirmation;
00213                 $settings["emailFooter"] = $this->emailFooter;
00214                 $settings["emailSubjects"] = $this->emailSubjects;
00215                 $settings["emailBodies"] = $this->emailBodies;
00216                 $settings["averagePerRoom"] = $this->averagePerRoom;
00217                 
00218                 foreach( $this->hotels as $key => $value )
00219                         $settings["hotels"][$key] = $value->id;
00220                         
00221                 foreach( $this->events as $key => $value )
00222                         $settings["events"][$key] = $value->id;
00223                 
00224                 foreach( $this->members as $key => $value )
00225                 {
00226                         $settings["members"][$key] = $value->id;
00227                         $counts[$value->membershipType]++;
00228                 }
00229                 
00230                 foreach( $this->membershipTypes as $key => $value )
00231                 {
00232                         $settings["membershipTypes"][$key] = $value->id;
00233                         if( $value->maxCount > 0 && $value->maxCount == $counts[$value->id] )
00234                         {
00235                                 $this->membershipTypes[$key]->available = false;
00236                                 $this->membershipTypes[$key]->save();
00237                         }
00238                 }
00239                 
00240                 foreach( $this->optionalChoices as $key => $value )
00241                         $settings["optionalChoices"][$key] = $value->id;
00242                 
00243                 if( !is_dir( $this->conventionBasedir ) )
00244                         mkdir( $this->conventionBasedir );
00245                 
00246                 if( file_exists( $this->conventionBasedir . "/convention.php" ) )
00247                         unlink( $this->conventionBasedir . "/convention.php" );
00248                 
00249                 file_put_contents( $this->conventionBasedir . "/convention.php", array_export( $settings, "settings" ) );
00250         }
00251         
00252         function getNextID()
00253         {
00254                 $this->nextID++;
00255                 $this->save();
00256                 return $this->nextID;
00257         }
00258         
00259         function getNextMemberID()
00260         {
00261                 $this->nextMemberID++;
00262                 $this->save();
00263                 return $this->nextMemberID;
00264         }
00265         
00272         function getEmailSubject( $whatMessage, $user )
00273         {
00274                 return $this->getMessage( "emailSubjects", $whatMessage, &$user );
00275         }
00276         
00283         function getEmailBody( $whatMessage, $user )
00284         {
00285                 return $this->getMessage( "emailBodies", $whatMessage, &$user );
00286         }
00287         
00295         function getMessage( $whatType, $whatMessage, $user )
00296         {
00297                 $replace[] = "##nickname##";
00298                 $replace[] = "##username##";
00299                 $replace[] = "##regid##";
00300                 $replace[] = "##password##";
00301                 $replace[] = "##confirmationcode##";
00302                 $replace[] = "##membershiptype##";
00303                 $replace[] = "##convention##";
00304                 
00305                 $with[] = getUserInfo( $user->username, "name" );
00306                 $with[] = $user->username;
00307                 $with[] = $user->id;
00308                 $with[] = $user->password;
00309                 $with[] = $user->confirmationCode;
00310                 $with[] = $this->membershipTypes[$user->membershipType]->title;
00311                 $with[] = $this->title;
00312                 
00313                 // Right, you can't do $this->$whatType[$whatMessage], for some reason that doesn't work. So, here you go, power of references to the rescue :P
00314                 $what = &$this->$whatType;
00315                 
00316                 return str_replace( $replace, $with, $what[$whatMessage] );
00317         }
00318         
00319         function calculateAverage()
00320         {
00321                 $counts = array();
00322                 foreach( $this->hotels as $hotelKey => $hotel )
00323                 {
00324                         foreach( $this->hotels[$hotelKey]->floors as $key => $value )
00325                         {
00326                                 foreach( $this->hotels[$hotelKey]->floors[$key]["rooms"] as $key2 => $value2 )
00327                                 {
00328                                         // No reason to count event rooms for this - they are not available for accomodation anyway
00329                                         if( $value2["eventspace"] == 0 )
00330                                         {
00331                                                 $count = 0;
00332                                                 foreach( $this->hotels[$hotelKey]->floors[$key]["rooms"][$key2]["beds"] as $key3 => $value3 )
00333                                                         $count += $value3["capacity"];
00334                                                 $counts[$count]++;
00335                                         }
00336                                 }
00337                         }
00338                 }
00339                 
00340                 // Do something clever to figure out which is the average number of people in a room...
00341                 arsort($counts);
00342                 reset($counts);
00343                 if( $this->lock() )
00344                 {
00345                         $this->averagePerRoom = key($counts);
00346                         $this->save();
00347                         $this->unlock();
00348                 }
00349         }
00350         
00357         function getSpareIDs()
00358         {
00359                 $spareIDs = array();
00360                 for( $i = 1; $i < endKey( $this->members ) ; $i++ )
00361                         if( ! array_key_exists( $i, $this->members ) )
00362                                 $spareIDs[$i] = $i;
00363                 return $spareIDs;
00364         }
00365         
00366         function handleRegistration( $username = null, $admin = false, $theFinalID )
00367         {
00368                 global $conventionSettings, $globalID, $usermanager;
00369                 // Registration form below
00370                 $panel = new optionsPanel( "conreg" );
00371                 $panel->showHeader = false;
00372                 $panel->saveTitle = i18n("Register new member");
00373                 $panel->revertTitle = i18n("Reset choices");
00374                 
00375                 // Nickname - check for uniqueness!
00376                 $panel->addHeader( i18n("Personal details"), "details" );
00377                 if( $admin == true )
00378                 {
00379                         $panel->addOption( i18n("Nickname"), i18n("The name you wish to go by at the convention. This will appear on your badge and also be used for generation of a username."), "", "nick", "text" );
00380                         $panel->addOption( i18n("OR user"), i18n("OR select a user already in the system. To do this, do NOT enter anything in the box above"), "", "username", "select", allUsersArray(true, true) );
00381                 }
00382                 else if( $username == null )
00383                         $panel->addOption( i18n("Nickname"), i18n("The name you wish to go by at the convention. This will appear on your badge and also be used for generation of a username."), "", "nick", "text" );
00384                 else
00385                         $panel->addOption( i18n("Username"), "", $username, "username", "label" );
00386                 $panel->addOption( i18n("Name"), i18n("Your legal name, required for identification reasons. Use the name written in your passport. This will appear on your badge. If you require a different name for genuine reasons, please contact us after registration."), "", "name", "text" );
00387                 $panel->addOption( i18n("Date of birth"), i18n("Your legal date of birth, required for identification reasons. Use the date of birth written in your passport."), mktime(0, 0, 0, 0, 0, date("Y") - 23), "dateOfBirth", "date", array( date("Y") - 120, date("Y") - 17 ) );
00388                 $panel->addOption( i18n("Gender"), i18n("Your legal gender, required for identification reasons. Use the gender written in your passport."), "m", "gender", "select", array( "m" => i18n("Male"), "f" => i18n("Female") ) );
00389                 if( $this->requestTShirtSize )
00390                         $panel->addOption( i18n("T-Shirt size"), i18n("What size T-Shirt would fit you? (We need this information to see approximately how many T-Shirts to get)"), "m", "tShirtSize", "select", array( "xs" => "Extra small", "s" => "Small", "m" => "Medium", "l" => "Large", "xl" => "Extra large", "xxl" => "Extra extra large", "xxxl" => "Tripple-extra large" ) );
00391                 
00392                 $panel->addHeader( i18n("Address"), "address" );
00393                 $panel->addOption( i18n("Street address"), "", "", "addressStreet", "text" );
00394                 $panel->addOption( i18n("Address line 2 (optional)"), "", "", "addressStreet2", "text" );
00395                 $panel->addOption( i18n("City"), "", "", "addressCity", "text" );
00396                 $panel->addOption( i18n("Postal code/ ZIP"), "", "", "addressZip", "text" );
00397                 $panel->addOption( i18n("County/ State (optional)"), "", "", "addressState", "text" );
00398                 $panel->addOption( i18n("Country"), "", "GB", "addressCountry", "select", getCountryArray() );
00399                 $panel->addOption( i18n("Phone number"), "", "", "addressPhone", "text" );
00400                 if( $username == null )
00401                         $panel->addOption( i18n("Email address"), i18n("Required for sending out information regarding the convention, and will require confirmation before we can accept your registration!"), "", "email", "text" );
00402                 
00403                 // Membership type
00404                 $panel->addHeader( i18n("Membership type"), "membershiptype" );
00405                 foreach( $this->membershipTypes as $key => $value )
00406                         if( $this->membershipTypes[$key]->isAvailable() )
00407                                 $membershipTypes[$value->id] = array("title" => $value->title . " (" . $conventionSettings->currency . $value->price . ")", "description" => $value->description);
00408                 if( count( $membershipTypes ) > 0 )
00409                         $panel->addOption( i18n("Membership type"), i18n("What type of membership do you want for this convention?"), firstKey($membershipTypes), "membershipType", "radio", $membershipTypes);
00410                 
00411                 // Optional choice
00412                 $freeOptions = array();
00413                 $payOptions = array();
00414                 foreach( $this->optionalChoices as $key => $value )
00415                 {
00416                         if( $value->isAvailable() )
00417                         {
00418                                 if( $value->price == 0 || $value->price == "" )
00419                                         $freeOptions[$key] = $value;
00420                                 else
00421                                         $payOptions[$key] = $value;
00422                         }
00423                 }
00424                 
00425                 if( count( $payOptions ) > 0 )
00426                 {
00427                         $panel->addHeader( i18n("Optional choices - non-free"), "optionalchoicespay" );
00428                         foreach( $payOptions as $key => $value )
00429                                 $panel->addOption( $value->title . " (" . $conventionSettings->currency . $value->price . ")", $value->description, 0, "optionalchoices(" . $value->id . ")", "checkbox" );
00430                 }
00431                 if( count( $freeOptions ) > 0 )
00432                 {
00433                         $panel->addHeader( i18n("Optional choices - free"), "optionalchoicesfree" );
00434                         foreach( $freeOptions as $key => $value )
00435                                 $panel->addOption( $value->title, $value->description, 0, "optionalchoices(" . $value->id . ")", "checkbox" );
00436                 }
00437                 
00438                 if( $panel->submitted )
00439                 {
00440                         // Reload, just to be entirely on the safe side...
00441                         if( $this->lock() )
00442                         {
00443                                 $this->load();
00444                                 
00445                                 // Bellow we break the coding standard, but that is only because the coding standard would produce very obscurely unreadable code
00446                                 // (when something is a list, let is be a list!)
00447                                 $errorExists = false;
00448                                 if( array_key_exists( "nick", $panel->options ) && $panel->options["nick"]["current"] != "" )
00449                                 {
00450                                         if( $panel->options["nick"]["current"] == "" )
00451                                                 { $panel->options["nick"]["error"] = i18n("You must enter a username!"); $errorExists = true; }
00452                                         else if( $usermanager->userExists( Member::generateUsername( $panel->options["nick"]["current"] ) ) )
00453                                                 { $panel->options["nick"]["error"] = i18n("A user with this nickname already exists. Please choose another."); $errurExists = true; }
00454                                         if( $panel->options["name"]["current"] == "" || strpos( $panel->options["name"]["current"], " " ) === false )
00455                                                 { $panel->options["name"]["error"] = i18n("You must enter your full, legal name!"); $errorExists = true; }
00456                                 }
00457                                 
00458                                 if( $panel->options["addressStreet"]["current"] == "" )
00459                                         { $panel->options["addressStreet"]["error"] = i18n("You must enter a full address!"); $errorExists = true; }
00460                                 if( $panel->options["addressCity"]["current"] == "" )
00461                                         { $panel->options["addressCity"]["error"] = i18n("You must enter a full address!"); $errorExists = true; }
00462                                 if( $panel->options["addressZip"]["current"] == "" )
00463                                         { $panel->options["addressZip"]["error"] = i18n("You must enter a full address!"); $errorExists = true; }
00464                                 if( $panel->options["addressPhone"]["current"] == "" )
00465                                         { $panel->options["addressPhone"]["error"] = i18n("You must enter a phone number!"); $errorExists = true; }
00466                                 
00467                                 if( $username == null )
00468                                 {
00469                                         if( $panel->options["email"]["current"] == "" )
00470                                                 { $panel->options["email"]["error"] = i18n("You must enter an email address!"); $errorExists = true; }
00471                                         else if( !validateEmail( $panel->options["email"]["current"] ) )
00472                                                 { $panel->options["email"]["error"] = i18n("You must enter a VALID email address!"); $errorExists = true; }
00473                                 }
00474                                 
00475                                 if( !$errorExists )
00476                                 {
00477                                         if( $username == null )
00478                                         {
00479                                                 if( $panel->options["nick"]["current"] != "" )
00480                                                 {
00481                                                         $usersPassword = makeRandomPassword();
00482                                                         $usersUsername = Member::generateUsername($panel->options["nick"]["current"]);
00483                                                         $usermanager->changeadd($usersUsername, $usersPassword);
00484                                                         saveUserInfo($usersUsername, "email", $panel->options["email"]["current"]);
00485                                                         saveUserInfo($usersUsername, "name", $panel->options["nick"]["current"] );
00486                                                 }
00487                                                 else
00488                                                 {
00489                                                         $usersPassword = i18n("unknown (you can request a new password through the login form)");
00490                                                         $usersUsername = $panel->options["username"]["current"];
00491                                                         saveUserInfo($usersUsername, "email", $panel->options["email"]["current"]);
00492                                                 }
00493                                         }
00494                                         else
00495                                         {
00496                                                 $usersUsername = $username;
00497                                                 $usersPassword = i18n("unknown (you can request a new password through the login form)");
00498                                         }
00499                                         
00500                                         // Create new member and fill stuff out...
00501                                         $newMember = new Member( &$this );
00502                                         $newMember->username = $usersUsername;
00503                                         $newMember->password = $usersPassword;
00504                                         $newMember->realname = $panel->options["name"]["current"];
00505                                         $newMember->gender = $panel->options["gender"]["current"];
00506                                         if( $this->requestTShirtSize )
00507                                                 $newMember->tShirtSize = $panel->options["tShirtSize"]["current"];
00508                                         $newMember->dateOfBirth = $panel->options["dateOfBirth"]["current"];
00509                                         
00510                                         $newMember->addressStreet = $panel->options["addressStreet"]["current"];
00511                                         $newMember->addressStreet2 = $panel->options["addressStreet2"]["current"];
00512                                         $newMember->addressCity = $panel->options["addressCity"]["current"];
00513                                         $newMember->addressZip = $panel->options["addressZip"]["current"];
00514                                         $newMember->addressState = $panel->options["addressState"]["current"];
00515                                         $newMember->addressCountry = $panel->options["addressCountry"]["current"];
00516                                         $newMember->addressPhone = $panel->options["addressPhone"]["current"];
00517                                         
00518                                         $newMember->membershipType = $panel->options["membershipType"]["current"];
00519                                         foreach( $panel->options as $key => $value )
00520                                                 if( substr( $value["name"], 0, 15 ) == "optionalchoices" && $value["current"] == 1 )
00521                                                         $newMember->optionalChoices[] = extractBetweenDelimeters( $value["name"], "(", ")" );
00522                                         
00523                                         $newMember->id = endKey($this->members) + 1;
00524                                         $newMember->newConfirmationCode(); // This also saves, thus we don't need to do that manually
00525                                         $this->members[$newMember->id] = $newMember;
00526                                         $this->save();
00527                                         
00528                                         // Redirect...
00529                                         header("Location: " . globalIDtoURL( str_replace( "##0##", $newMember->id, $theFinalID ) ) );
00530                                 }
00531                                 $this->unlock();
00532                         }
00533                         else
00534                                 die( "Timeout error. Please go back and try again (too many people are attempting to register at the same time)." );
00535                 }
00536                 return $panel->render();
00537         }
00538         
00539         function renderEvents($thisGlobalID)
00540         {
00541                 // List all the events by order of hotel -> event room -> event slot
00542                 $table = new Table("convention-events", "convention-events-row", "convention-events-cell");
00543                 $table->addColumn( "convention-events-column-time" );
00544                 
00545                 $thetimes = array();
00546                 $roomcount = 0;
00547                 foreach( $this->events as $key => $event )
00548                 {
00549                         $therooms[$event->hotelID][$event->floorID][$event->roomID] = $roomcount;
00550                         $roomcount++;
00551                         
00552                         $i = date( "l", $event->startTime );
00553                         if( $event->startTime > 0 && ( !array_key_exists( $i, $thetimes ) || !array_key_exists( "startTime", $thetimes[$i] ) || $thetimes[$i]["startTime"] > $event->startTime ) )
00554                                 $thetimes[$i]["startTime"] = $event->startTime;
00555                         if( !array_key_exists( $i, $thetimes ) || !array_key_exists( "endTime", $thetimes[$i] ) || $thetimes[$i]["endTime"] < $event->startTime + ( $event->duration * 60 ) )
00556                                 $thetimes[$i]["endTime"] = $event->startTime + ( $event->duration * 60 );
00557                 }
00558                 sort( $thetimes );
00559                 
00560                 foreach( $therooms as $hotelID => $value )
00561                         foreach( $value as $floorID => $roomID )
00562                                 foreach( $roomID as $roomIDnum => $roomcountnum )
00563                                         $table->addColumn();
00564                 
00565                 $rows = 0;
00566                 foreach( $thetimes as $key => $value )
00567                 {
00568                         $table->addRow( "convention-events-row-day", true );
00569                         $table->setColSpan( $rows, 0, $roomcount );
00570                         $table->setContent( $rows, 0, date( "l", $value["startTime"] ) );
00571                         $rows++;
00572                         
00573                         $table->addRow( "convention-events-row-rooms", true );
00574                         $columns = 1;
00575                         foreach( $therooms as $hotelID => $value2 )
00576                         {
00577                                 foreach( $value2 as $floorID => $roomID )
00578                                 {
00579                                         foreach( $roomID as $roomIDnum => $roomcountnum )
00580                                         {
00581                                                 $table->setContent( $rows, $columns, $this->hotels[$hotelID]->floors[$floorID]["rooms"][$roomIDnum]["name"] );
00582                                                 $roomColumns[$hotelID][$floorID][$roomIDnum] = $columns;
00583                                                 $columns++;
00584                                         }
00585                                 }
00586                         }
00587                         $rows++;
00588                         
00589                         
00590                         for( $i = $value["startTime"] ; $i <= $value["endTime"] ; $i += $this->eventLapse * 60 )
00591                         {
00592                                 $table->addRow();
00593                                 $table->setContent( $rows, 0, date( "H:i", $i ) );
00594                                 $timeRows[$i] = $rows;
00595                                 $rows++;
00596                         }
00597                 }
00598                 
00599                 foreach( $this->events as $key => $value )
00600                 {
00601                         $row = $timeRows[$value->startTime];
00602                         $column = $roomColumns[$value->hotelID][$value->floorID][$value->roomID];
00603                         $span = ( $value->duration / $this->eventLapse );
00604                         $table->setContent( $row, $column, $value->renderLink( "$thisGlobalID/events" ) );
00605                         $table->setRowSpan( $row, $column, $span );
00606                         if( $value->customClass != "" )
00607                                 $table->setStyleClass( $row, $column, "convention-events-cell " . $value->customClass );
00608                 }
00609                 
00610                 return $table->render();
00611         }
00612         
00613         function renderEditor()
00614         {
00615                 global $conventionSettings, $globalID, $usermanager;
00616                 
00617                 $splitID = explode( "/", $globalID );
00618                 
00619                 if( $splitID[3] == "cons" )
00620                 {
00621                         $thisGlobalID = "setup/modulesetup/convention/cons/" . $this->id;
00622                         $editorSection = $splitID[5];
00623                         $editorSubsection = $splitID[6];
00624                         $editorSubsubsection = $splitID[7];
00625                         $editorSubsubsub = $splitID[8];
00626                 }
00627                 else
00628                 {
00629                         $thisGlobalID = "setup/modulesetup/convention";
00630                         $editorSection = $splitID[3];
00631                         $editorSubsection = $splitID[4];
00632                         $editorSubsubsection = $splitID[5];
00633                         $editorSubsubsub = $splitID[6];
00634                 }
00635                 
00636                 $conEditor = new TabWidget();
00637                 $conEditor->tabbar->addTab( i18n("Registered Members"), globalIDtoURL($thisGlobalID) );
00638                 $conEditor->tabbar->addTab( i18n("Convention Details"), globalIDtoURL("$thisGlobalID/details") );
00639                 $conEditor->tabbar->addTab( i18n("Emails"), globalIDtoURL("$thisGlobalID/emails") );
00640                 $conEditor->tabbar->addTab( i18n("Membership Types"), globalIDtoURL("$thisGlobalID/membershiptypes") );
00641                 $conEditor->tabbar->addTab( i18n("Optional Choices"), globalIDtoURL("$thisGlobalID/optionalchoices") );
00642                 $conEditor->tabbar->addTab( i18n("Accomodation"), globalIDtoURL("$thisGlobalID/hotels") );
00643                 $conEditor->tabbar->addTab( i18n("Events"), globalIDtoURL("$thisGlobalID/events") );
00644                 $conEditor->tabbar->addTab( i18n("Summaries"), globalIDtoURL("$thisGlobalID/summaries") );
00645                 
00646                 switch( $editorSection )
00647                 {
00648                 case "summaries":
00649                         $conEditor->tabbar->setCurrent(i18n("Summaries"));
00650                         // Summaries
00651                         
00652                         $table = new Table();
00653                         
00654                         //   Member lists, sorted by:
00655                         switch( $editorSubsection )
00656                         {
00657                         case "payment":
00658                         //   - Payment remaining amount
00659                                 foreach( $this->members as $memberID => $member )
00660                                 {
00661                                         $totalPayable = (float)$this->membershipTypes[$member->membershipType]->price;
00662                                         if( is_array( $member->optionalChoices ) )
00663                                                 foreach( $member->optionalChoices as $key => $value )
00664                                                         foreach( $this->optionalChoices as $key2 => $value2 )
00665                                                                 if( $value == $value2->id )
00666                                                                         (float)$totalPayable += $value2->price;
00667                                         
00668                                         $remainingPayable = $totalPayable - $member->paidAmount;
00669                                         
00670                                         $members[$memberID] = array( "username" => $member->username, "realname" => $member->realname, "id" => $member->id, "paidAmount" => $member->paidAmount, "remainingPayable" => $remainingPayable, "totalPayable" => $totalPayable);
00671                                 }
00672                                 
00673                                 usort( $members, "convention_compare_remainingPayablerev" );
00674                                 
00675                                 $table->newRow(null, true);
00676                                 $table->newCell(i18n("Member"));
00677                                 $table->newCell(i18n("Total payable"));
00678                                 $table->newCell(i18n("Paid amount"));
00679                                 $table->newCell(i18n("Remaining"));
00680                                 
00681                                 foreach( $members as $memberID => $member )
00682                                 {
00683                                         $table->newRow();
00684                                         $table->newCell( drawCommand( $member["id"], i18n( "Show the membership details for member ID ##0##", array($member["id"]) ), globalIDtoURL( "$thisGlobalID/member/details/" . $member["id"] ) ) . " " . $member["realname"] . " (" . $member["username"] . ")" );
00685                                         $table->newCell($member["totalPayable"]);
00686                                         $table->newCell($member["paidAmount"]);
00687                                         $table->newCell($member["remainingPayable"]);
00688                                 }
00689                                 
00690                                 $conEditor->contents .= $table->render();
00691                                 break;
00692                         case "country":
00693                         //   - Country
00694                                 foreach( $this->members as $memberID => $member )
00695                                         $members[$memberID] = array( "username" => $member->username, "realname" => $member->realname, "id" => $member->id, "country" => $member->addressCountry );
00696                                 
00697                                 usort( $members, "convention_compare_country" );
00698                                 
00699                                 $table->newRow(null, true);
00700                                 $table->newCell(i18n("Member"));
00701                                 $table->newCell(i18n("Country"));
00702                                 $countries = getCountryArray();
00703                                 
00704                                 foreach( $members as $memberID => $member )
00705                                 {
00706                                         $table->newRow();
00707                                         $table->newCell( drawCommand( $member["id"], i18n( "Show the membership details for member ID ##0##", array($member["id"]) ), globalIDtoURL( "$thisGlobalID/member/details/" . $member["id"] ) ) . " " . $member["realname"] . " (" . $member["username"] . ")" );
00708                                         $table->newCell( $countries[$member["country"]] );
00709                                 }
00710                                 
00711                                 $conEditor->contents .= $table->render();
00712                                 break;
00713                         case "regid":
00714                         //   - Registration ID
00715                         //   - Membership type
00716                         //   - Optional choices
00717                                 $table->newRow(null, true);
00718                                 $table->newCell(i18n("Member"));
00719                                 $table->newCell(i18n("Membership type"));
00720                                 $table->newCell(i18n("Optional choices"));
00721                                 
00722                                 $showMemberships = $showChoices = array();
00723                                 $filterApplied = array_key_exists( "applyFilter", $_POST );
00724                                 
00725                                 $inclusiveChecked = " checked";
00726                                 if( $filterApplied )
00727                                 {
00728                                         $inclusiveChecked = $_POST["inclusivefilter"] ? " checked" : "";
00729                                         $filterExclusive = true;
00730                                 }
00731                                 
00732                                 foreach( $this->optionalChoices as $key => $choice )
00733                                 {
00734                                         $checked = " checked";
00735                                         $backwards[$choice->id] = $choice;
00736                                         if( $filterApplied )
00737                                         {
00738                                                 $checked = $_POST["optionalchoice(" . $key . ")"] ? " checked" : "";
00739                                                 if( $checked != "" )
00740                                                         $showChoices[] = $choice->id;
00741                                         }
00742                                         $renderedChoiceDescriptions .= "<label><input type=\"checkbox\" name=\"optionalchoice($key)\"$checked><strong>" . $choice->title . ":</strong> " . $choice->description . "</label><br />";
00743                                 }
00744                                 foreach( $this->membershipTypes as $key => $membershipType )
00745                                 {
00746                                         $checked = " checked";
00747                                         if( $filterApplied )
00748                                         {
00749                                                 $checked = $_POST["membershiptype(" . $key . ")"] ? " checked" : "";
00750                                                 if( $checked != "" )
00751                                                         $showMemberships[] = $key;
00752                                         }
00753                                         $renderedMembershipDescriptions .= "<label><input type=\"checkbox\" name=\"membershiptype($key)\"$checked><strong>" . $membershipType->title . ":</strong> " . $membershipType->description . "</label><br />";
00754                                 }
00755                                 
00756                                 foreach( $this->members as $memberID => $member )
00757                                 {
00758                                         $showThisMember = false;
00759                                         $renderedChoices = "";
00760                                         $firstChoice = "";
00761                                         foreach( $member->optionalChoices as $key => $choiceID )
00762                                         {
00763                                                 $renderedChoices .= $firstChoice . $backwards[$choiceID]->title;
00764                                                 $firstChoice = ", ";
00765                                                 if( in_array( $choiceID, $showChoices ) )
00766                                                         $showThisMember = true;
00767                                         }
00768                                         
00769                                         if( $filterExclusive )
00770                                         {
00771                                                 $showThisMember = true;
00772                                                 if( !in_array( $member->membershipType, $showMemberships ) )
00773                                                         $showThisMember = false;
00774                                                 
00775                                                 if( $showThisMember )
00776                                                 {
00777                                                         foreach( $showChoices as $key => $choiceID )
00778                                                         {
00779                                                                 if( !in_array( $choiceID, $member->optionalChoices ) )
00780                                                                         $showThisMember = false;
00781                                                                 if( !$showThisMember )
00782                                                                         break;
00783                                                         }
00784                                                 }
00785                                         }
00786                                         else
00787                                         {
00788                                                 if( in_array( $member->membershipType, $showMemberships ) )
00789                                                         $showThisMember = true;
00790                                         }
00791                                         
00792                                         if( !$filterApplied || ( $filterApplied && $showThisMember ) )
00793                                         {
00794                                                 $table->newRow();
00795                                                 $table->newCell( drawCommand( $member->id, i18n( "Show the membership details for member ID ##0##", array($member->id) ), globalIDtoURL( "$thisGlobalID/member/details/" . $member->id ) ) . " " . $member->realname . " (" . $member->username . ")" );
00796                                                 $table->newCell( $this->membershipTypes[$member->membershipType]->title );
00797                                                 $table->newCell( $renderedChoices );
00798                                         }
00799                                 }
00800                                 
00801                                 $conEditor->contents .= $table->render();
00802                                 
00803                                 $conEditor->contents .= "<form action=\"" . thisPageURL() . "\" method=\"POST\">" .
00804                                         parse_page_data("---") . $renderedMembershipDescriptions .
00805                                         parse_page_data("---") . $renderedChoiceDescriptions .
00806                                         "<input type=\"submit\" name=\"applyFilter\" value=\"" . i18n("Apply filter") . "\" />
00807                                         <label><input name=\"inclusivefilter\" type=\"checkbox\"$inclusiveChecked>Match any (uncheck to match all)</label></form>";
00808                                 break;
00809                         case "sharing":
00810                         //   - Sharing with (and confirmation status)
00811                                 $table->newRow(null, true);
00812                                 $table->newCell(i18n("Member"));
00813                                 $table->newCell(i18n("Confirmed sharing"));
00814                                 $hasUnconfirmed = false;
00815                                 
00816                                 foreach( $this->members as $memberID => $member )
00817                                         $backwards[$member->username] = $member->id;
00818                                 
00819                                 foreach( $this->members as $memberID => $member )
00820                                 {
00821                                         $table->newRow();
00822                                         $table->newCell( drawCommand( $member->id, i18n( "Show the membership details for member ID ##0##", array($member->id) ), globalIDtoURL( "$thisGlobalID/member/details/" . $member->id ) ) . " " . $member->realname . " (" . $member->username . ")" );
00823                                         
00824                                         $member->checkRoomies();
00825                                         
00826                                         $renderedConfirmed = "";
00827                                         $renderedUnconfirmed = "";
00828                                         foreach( $member->sharingWith as $username => $confirmed )
00829                                         {
00830                                                 if( $confirmed )
00831                                                         $renderedConfirmed .= "<div>" . drawCommand( $backwards[$username], i18n( "Show the membership details for member ID ##0##", array($backwards[$username]) ), globalIDtoURL( "$thisGlobalID/member/details/" . $backwards[$username] ) ) . " " . $this->members[$backwards[$username]]->realname . " (" . $username . ")</div>";
00832                                                 else
00833                                                         $renderedUnconfirmed .= "<div>" . drawCommand( $backwards[$username], i18n( "Show the membership details for member ID ##0##", array($backwards[$username]) ), globalIDtoURL( "$thisGlobalID/member/details/" . $backwards[$username] ) ) . " " . $this->members[$backwards[$username]]->realname . " (" . $username . ")</div>";
00834                                         }
00835                                         $table->newCell( $renderedConfirmed );
00836                                         
00837                                         if( $renderedUnconfirmed != "" )
00838                                         {
00839                                                 $table->newCell( $renderedUnconfirmed );
00840                                                 $hasUnconfirmed = true;
00841                                         }
00842                                 }
00843                                 
00844                                 if( $hasUnconfirmed )
00845                                         $table->setContent( 0, 2, i18n("Unconfirmed sharing") );
00846                                 
00847                                 $conEditor->contents .= $table->render();
00848                                 break;
00849                         default:
00850                                 $table->newRow();
00851                                 $table->newCell( i18n("Show memberships sorted by remaining payment") );
00852                                 $table->newCell( drawCommand( i18n("Show ##0##", array("&raquo;") ), i18n("Show memberships sorted by remaining payment"), globalIDtoURL("$thisGlobalID/summaries/payment") ) );
00853                                 
00854                                 $table->newRow();
00855                                 $table->newCell( i18n("Show memberships sorted by country of origin") );
00856                                 $table->newCell( drawCommand( i18n("Show ##0##", array("&raquo;") ), i18n("Show memberships sorted by country of origin"), globalIDtoURL("$thisGlobalID/summaries/country") ) );
00857                                 
00858                                 $table->newRow();
00859                                 $table->newCell( i18n("Show memberships with membership type and optional choices") );
00860                                 $table->newCell( drawCommand( i18n("Show ##0##", array("&raquo;") ), i18n("Show memberships with membership type and optional choices"), globalIDtoURL("$thisGlobalID/summaries/regid") ) );
00861                                 
00862                                 $table->newRow();
00863                                 $table->newCell( i18n("Show memberships with room sharing information") );
00864                                 $table->newCell( drawCommand( i18n("Show ##0##", array("&raquo;") ), i18n("Show memberships with room sharing information"), globalIDtoURL("$thisGlobalID/summaries/sharing") ) );
00865                                 
00866                                 $table->columns[1] = array( "styleClass" => "setup wikirightalign" );
00867                                 $conEditor->contents .= $table->render();
00868                         }
00869                         
00870                         if( $editorSubsection != "" )
00871                                 $conEditor->addCommand( i18n("##0## Back", array("&laquo;") ), i18n("Return to selection screen"), globalIDtoURL("$thisGlobalID/summaries") );
00872                         break;
00873                 case "events":
00874                         $conEditor->tabbar->setCurrent(i18n("Events"));
00875                         
00876                         // Get all event rooms available: $eventrooms[hotelID][floorID] = reference to room
00877                         foreach( $this->hotels as $hotelID => $hotel )
00878                                 foreach( $this->hotels[$hotelID]->floors as $floorID => $floor )
00879                                         foreach( $this->hotels[$hotelID]->floors[$floorID]["rooms"] as $roomID => $room )
00880                                                 if( $room["eventspace"] > 0 )
00881                                                         $eventrooms[] = array( "hotelID" => $hotelID, "floorID" => $floorID, "roomID" => $roomID, "room" => &$this->hotels[$hotelID]->floors[$floorID]["rooms"][$roomID] );
00882                         
00883                         foreach( $this->events as $eventID => $event )
00884                                 $sortedEvents[$hotelID][] = &$this->events[$eventID];
00885                         
00886                         switch( $editorSubsection )
00887                         {
00888                         case "new":
00889                                 $conEditor->addCommand( i18n( "##0## Back", array("&laquo;") ), i18n("Return to event management"), globalIDtoURL("$thisGlobalID/events") );
00890                                 
00891                                 for( $i = $this->eventLapse ; $i <= 1440 ; $i = $i + $this->eventLapse )
00892                                 {
00893                                         if( $i < 60 )
00894                                                 $eventLapses[$i] = i18n( "##0## minutes", array($i) );
00895                                         else
00896                                         {
00897                                                 $hours = floor( $i / 60 );
00898                                                 $minutes = $i % 60;
00899                                                 if( $minutes < 1 )
00900                                                         $eventLapses[$i] = i18n( "##0## hours", array( $hours ) );
00901                                                 else
00902                                                         $eventLapses[$i] = i18n( "##0##:##1## hours", array( $hours, $minutes ) );
00903                                         }
00904                                 }
00905                                 
00906                                 foreach( $eventrooms as $key => $value )
00907                                         $rooms[$key] = $value["room"]["name"];
00908                                 
00909                                 $panel = new optionsPanel("newevent");
00910                                 $panel->showHeader = false;
00911                                 $panel->saveTitle = i18n("Create event");
00912                                 $panel->revertTitle = i18n("Revert to defaults");
00913                                 
00914                                 $panel->addOption( i18n("Name"), i18n("The title text which will be shown in the table view"), "", "name", "text" );
00915                                 $panel->addOption( i18n("Blurb"), i18n("A text which will be used for both a link tooltip and the first, bolded paragraph of the full description"), "", "blurb", "textbox" );
00916                                 $panel->addOption( i18n("Event room"), i18n("In which room will this event take place?"), "", "room", "select", $rooms );
00917                                 $panel->addOption( i18n("Owner"), i18n("The person responsible for this event"), currentUser(), "owner", "select", allUsersArray( true, true ) );
00918                                 $panel->addOption( i18n("Custom CSS class"), i18n("An optional extra CSS class to set for the cell containing this event in the overview table"), $this->customClass, "customClass", "text" );
00919                                 $panel->addOption( i18n("Start time"), i18n("When the event starts"), $this->startDate, "startTime", "datetime" );
00920                                 $panel->addOption( i18n("Duration"), i18n("How long the event goes on for"), $this->eventLapse, "duration", "select", $eventLapses );
00921                                 $panel->addOption( i18n("Long description"), "", "", "description", "pagedata" );
00922                                 
00923                                 if( $panel->submitted )
00924                                 {
00925                                         $event = new Event(&$this);
00926                                         $event->name = $panel->options["name"]["current"];
00927                                         $event->blurb = $panel->options["blurb"]["current"];
00928                                         $event->description = $panel->options["description"]["current"];
00929                                         $event->hotelID = $eventrooms[$panel->options["room"]["current"]]["hotelID"];
00930                                         $event->floorID = $eventrooms[$panel->options["room"]["current"]]["floorID"];
00931                                         $event->roomID = $eventrooms[$panel->options["room"]["current"]]["roomID"];
00932                                         $event->owner = $panel->options["owner"]["current"];
00933                                         $event->startTime = $panel->options["startTime"]["current"];
00934                                         $event->duration = $panel->options["duration"]["current"];
00935                                         $event->customClass = $panel->options["customClass"]["current"];
00936                                         if( $this->lock() )
00937                                         {
00938                                                 $this->load();
00939                                                 $event->id = $this->getNextID();
00940                                                 $this->events[$event->id] = $event;
00941                                                 $event->save();
00942                                                 $this->save();
00943                                                 $this->unlock();
00944                                                 header( "Location: " . globalIDtoURL("$thisGlobalID/events") );
00945                                         }
00946                                         else
00947                                                 die( i18n("Unable to lock convention - too many users attempting access!") );
00948                                 }
00949                                 
00950                                 $conEditor->contents .= "<form action=\"" . thisPageURL() . "\" method=\"POST\">" . renderInformationBox( i18n("Create new event"), $panel->render(), false ) . "</form>";
00951                                 
00952                                 break;
00953                         default:
00954                                 if( is_numeric( $editorSubsection ) )
00955                                 {
00956                                         $conEditor->addCommand( i18n( "##0## Back", array("&laquo;") ), i18n("Return to event management"), globalIDtoURL("$thisGlobalID/events") );
00957                                         if( $editorSubsubsection == "delete" )
00958                                         {
00959                                                 $panel = new optionsPanel("eventdelete");
00960                                                 $panel->showHeader = false;
00961                                                 $panel->saveTitle = i18n("Confirm selection");
00962                                                 $panel->resetTitle = i18n("Reset choices");
00963                                                 
00964                                                 $panel->addOption( i18n("The event in question"), "", $this->events[$editorSubsection]->name . "<br />" . $this->events[$editorSubsection]->blurb , "eventdesc", "label" );
00965                                                 $panel->addOption( i18n("Check to delete"), i18n("Just leave unchecked and click Confirm selection to abort the deletion process"), 0, "confirmDelete", "checkbox" );
00966                                                 
00967                                                 if( $panel->submitted )
00968                                                 {
00969                                                         if( $panel->options["confirmDelete"]["current"] == true )
00970                                                         {
00971                                                                 if( $this->lock() )
00972                                                                 {
00973                                                                         $this->load();
00974                                                                         $errorHandler = new errorHandler(globalIDtoURL("$thisGlobalID/events/$editorSubsection/delete"));
00975                                                                         $errorHandler->handle( i18n("Deleting event data from disk"), unlink( $this->conventionBasedir . "/events/$editorSubsection.php" ) );
00976                                                                         unset( $this->events[$editorSubsection] );
00977                                                                         $this->save();
00978                                                                         $this->unlock();
00979                                                                         
00980                                                                         if( $errorHandler->handled == true )
00981                                                                                 $conEditor->contents .= $errorHandler->render();
00982                                                                         else
00983                                                                                 header( "Location: " . globalIDtoURL( "$thisGlobalID/events" ) );
00984                                                                 }
00985                                                         }
00986                                                         else
00987                                                                 header( "Location: " . globalIDtoURL( "$thisGlobalID/events" ) );
00988                                                 }
00989                                                 
00990                                                 $conEditor->contents .= renderInformationBox( i18n( "Delete ##0##?", array( $this->events[$editorSubsection]->name ) ), "<form action=\"" . globalIDtoURL("$thisGlobalID/events/$editorSubsection/delete") . "\" method=\"POST\">" . $panel->render() . "</form>", false );
00991                                         }
00992                                         else
00993                                                 $conEditor->contents .= "<form action=\"" . thisPageURL() . "\" method=\"POST\">" . $this->events[$editorSubsection]->render($thisGlobalID) . "</form>";
00994                                 }
00995                                 else
00996                                 {
00997                                         $conEditor->addCommand( i18n("New event"), i18n("Create a new event"), globalIDtoURL("$thisGlobalID/events/new") );
00998                                         
00999                                         if( count( $this->events ) < 1 )
01000                                                 $conEditor->contents .= renderInformationBox( i18n("No events"), i18n("No events have been created yet. ##0##", array( drawCommand( i18n("Please click here to create one."), i18n("Click here to create an event"), globalIDtoURL("$thisGlobalID/events/new") ) ) ) );
01001                                         else
01002                                         {
01003                                                 $conEditor->contents .= $this->renderEvents($thisGlobalID);
01004                                         }
01005                                 }
01006                                 break;
01007                         }
01008                         break;
01009                 case "hotels":
01010                         $conEditor->tabbar->setCurrent(i18n("Accomodation"));
01011                         $conEditor->addCommand( i18n("Add Hotel"), i18n("Add a new hotel to this convention"), globalIDtoURL("$thisGlobalID/hotels/new") );
01012                         
01013                         if( is_numeric( $editorSubsection ) )
01014                                 $conEditor->contents .= $this->hotels[$editorSubsection]->render(true);
01015                         else
01016                         {
01017                                 switch( $editorSubsection )
01018                                 {
01019                                 case "new":
01020                                         $panel = new optionsPanel("hotel");
01021                                         $panel->showHeader = false;
01022                                         $panel->saveTitle = i18n("Create hotel");
01023                                         $panel->revertTitle = i18n("Revert to defaults");
01024                                         
01025                                         $panel->addOption( i18n("Name"), i18n("The name of this hotel"), "", "name", "text" );
01026                                         $panel->addOption( i18n("Description"), i18n("A shortish description of the hotel"), "", "description", "textbox" );
01027                                         $panel->addOption( i18n("Long description"), "", "", "longDescription", "pagedata" );
01028                                         
01029                                         if( $panel->submitted )
01030                                         {
01031                                                 $hotel = new Hotel(&$this);
01032                                                 $hotel->name = $panel->options["name"]["current"];
01033                                                 $hotel->description = $panel->options["description"]["current"];
01034                                                 $hotel->longDescription = $panel->options["longDescription"]["current"];
01035                                                 if( $this->lock() )
01036                                                 {
01037                                                         $this->load();
01038                                                         $hotel->id = $this->getNextID();
01039                                                         $this->hotels[$hotel->id] = $hotel;
01040                                                         $hotel->save();
01041                                                         $this->save();
01042                                                         $this->unlock();
01043                                                         header( "Location: " . globalIDtoURL("$thisGlobalID/hotels") );
01044                                                 }
01045                                                 else
01046                                                         die( i18n("Unable to lock convention - too many users attempting access!") );
01047                                         }
01048                                         
01049                                         $conEditor->contents .= "<form action=\"" . thisPageURL() . "\" method=\"POST\">" . $panel->render() . "</form>";
01050                                         break;
01051                                 case "delete":
01052                                         if( ! is_numeric( $editorSubsubsection ) )
01053                                                 header( "Location: " . globalIDtoURL( $thisGlobalID ) );
01054                                         $panel = new optionsPanel("hoteldelete");
01055                                         $panel->showHeader = false;
01056                                         $panel->saveTitle = i18n("Confirm selection");
01057                                         $panel->resetTitle = i18n("Reset choices");
01058                                         
01059                                         $panel->addOption( i18n("The hotel in question"), "", $this->hotels[$editorSubsubsection]->name , "hoteldesc", "label" );
01060                                         $panel->addOption( i18n("Check to delete"), i18n("Just leave unchecked and click Confirm selection to abort the deletion process"), 0, "confirmDelete", "checkbox" );
01061                                         
01062                                         if( $panel->submitted )
01063                                         {
01064                                                 if( $panel->options["confirmDelete"]["current"] == true )
01065                                                 {
01066                                                         if( $this->lock() )
01067                                                         {
01068                                                                 $this->load();
01069                                                                 $errorHandler = new errorHandler(globalIDtoURL("$thisGlobalID/hotels/delete/$editorSubsubsection"));
01070                                                                 $errorHandler->handle( i18n("Deleting hotel data from disk"), unlink( $this->conventionBasedir . "/hotels/$editorSubsubsection.php" ) );
01071                                                                 unset( $this->hotels[$editorSubsubsection] );
01072                                                                 $this->save();
01073                                                                 $this->unlock();
01074                                                                 
01075                                                                 if( $errorHandler->handled == true )
01076                                                                         $conEditor->contents .= $errorHandler->render();
01077                                                                 else
01078                                                                         header( "Location: " . globalIDtoURL( "$thisGlobalID/hotels" ) );
01079                                                         }
01080                                                 }
01081                                                 else
01082                                                         header( "Location: " . globalIDtoURL( "$thisGlobalID/hotels" ) );
01083                                         }
01084                                         
01085                                         $conEditor->contents .= renderInformationBox( i18n( "Delete ##0##?", array( $this->hotels[$editorSubsubsection]->name ) ), "<form action=\"" . globalIDtoURL("$thisGlobalID/hotels/delete/$editorSubsubsection") . "\" method=\"POST\">" . $panel->render() . "</form>", false );
01086                                         
01087                                         break;
01088                                 default:
01089                                         if( count( $this->hotels ) < 1 )
01090                                         {
01091                                                 $conEditor->contents .= renderInformationBox( i18n("No hotels"), i18n("There are no hotels defined yet for this convention. Please create one to begin.") );
01092                                         }
01093                                         else
01094                                         {
01095                                                 $conEditor->contents .= "<table class=\"setup\">";
01096                                                 
01097                                                 foreach( $this->hotels as $key => $value )
01098                                                         $conEditor->contents .= $this->hotels[$key]->render();
01099                                                 
01100                                                 $conEditor->contents .= "</table>";
01101                                         }
01102                                 }
01103                         }
01104                         
01105                         break;
01106                 case "optionalchoices":
01107                         $conEditor->tabbar->setCurrent(i18n("Optional Choices"));
01108                         $conEditor->addCommand( i18n("Add Optional Choice"), i18n("Add a new optional choice to this convention"), globalIDtoURL("$thisGlobalID/optionalchoices/new") );
01109                         
01110                         // Optional choices
01111                         if( is_numeric( $editorSubsection ) )
01112                         {
01113                                 $theOC = &$this->optionalChoices[$editorSubsection];
01114                                 
01115                                 $panel = new optionsPanel("oc");
01116                                 $panel->showHeader = false;
01117                                 $panel->saveTitle = i18n("Save optional choice");
01118                                 $panel->revertTitle = i18n("Revert");
01119                                 
01120                                 $panel->addOption( i18n("Category"), i18n("A short title describing what category the optional choice is in. You can leave this empty if you have no need for categories."), $theOC->category, "category", "text" );
01121                                 $panel->addOption( i18n("Title"), i18n("The title of the optional choice"), $theOC->title, "title", "text" );
01122                                 $panel->addOption( i18n("Price"), i18n("The price of the optional choice. If this is not set, it is a free option"), $theOC->price, "price", "text" );
01123                                 $panel->addOption( i18n("Administrator only"), i18n("If this is set, only admin is allowed to assign and unasign this optional choice"), $theOC->adminOnly, "adminOnly", "checkbox" );
01124                                 $panel->addOption( i18n("Description"), i18n("The description of the membership type"), $theOC->description, "description", "pagedata" );
01125                                 
01126                                 if( $panel->submitted )
01127                                 {
01128                                         $this->lock();
01129                                         $this->load();
01130                                         $theOC->category = $panel->options["category"]["current"];
01131                                         $theOC->title = $panel->options["title"]["current"];
01132                                         $theOC->description = $panel->options["description"]["current"];
01133                                         $theOC->price = $panel->options["price"]["current"];
01134                                         $theOC->adminOnly = $panel->options["adminOnly"]["current"];
01135                                         $theOC->save();
01136                                         $this->unlock();
01137                                         header("Location: " . globalIDtoURL("$thisGlobalID/optionalchoices") );
01138                                 }
01139                                 
01140                                 $conEditor->contents .= "<form action=\"" . thisPageURL() . "\" method=\"POST\">" . $panel->render() . "</form>";
01141                         }
01142                         else if( $editorSubsection == "new" )
01143                         {
01144                                 // Create new, disabled by default, show editor
01145                                 $newOC = new OptionalChoice(&$this);
01146                                 $newOC->id = $this->getNextID();
01147                                 $newOC->save();
01148                                 
01149                                 $this->lock();
01150                                 $this->load();
01151                                 $this->optionalChoices[] = &$newOC;
01152                                 $this->save();
01153                                 $this->unlock();
01154                                 
01155                                 header("Location: " . globalIDtoURL( "$thisGlobalID/optionalchoices/" . endkey($this->optionalChoices) ) );
01156                         }
01157                         else if( $editorSubsection == "delete" && is_numeric($editorSubsubsection) )
01158                         {
01159                                 if( $editorSubsubsub == "confirm" )
01160                                 {
01161                                         $this->lock();
01162                                         $this->load();
01163                                         unlink( $this->conventionBasedir . "/optionalchoices/" . $this->optionalChoices[$editorSubsubsection]->id . ".php" );
01164                                         unset( $this->optionalChoices[$editorSubsubsection] );
01165                                         $this->save();
01166                                         $this->unlock();
01167                                         header("Location: " . globalIDtoURL("$thisGlobalID/optionalchoices") );
01168                                 }
01169                                 else
01170                                 {
01171                                         $conEditor->contents .= renderInformationBox(
01172                                                 i18n("Delete?"),
01173                                                 i18n("Are you sure you wish to delete the ##0## optional choice?##1##",
01174                                                         array(
01175                                                                 $this->optionalChoices[$editorSubsubsection]->title,
01176                                                                 "<div class=\"wikicenteralign\">" .
01177                                                                         drawCommand( i18n("Confirm delete"), i18n("Confirm deletion of this optoinal choice"), globalIDtoURL( "$thisGlobalID/optionalchoices/delete/$editorSubsubsection/confirm" ) ) . " " .
01178                                                                         drawCommand( i18n("Abort delete"), i18n("Abort the deletion process"), globalIDtoURL("$thisGlobalID/optionalchoices") ) .
01179                                                                 "</div>"
01180                                                                 ),
01181                                                 false ) );
01182                                 }
01183                         }
01184                         else if( $editorSubsection == "toggleavailable" && is_numeric($editorSubsubsection) )
01185                         {
01186                                 $this->optionalChoices[$editorSubsubsection]->available = ! $this->optionalChoices[$editorSubsubsection]->available;
01187                                 $this->optionalChoices[$editorSubsubsection]->save();
01188                                 header( "Location: " . globalIDtoURL("$thisGlobalID/optionalchoices") );
01189                         }
01190                         else
01191                         {
01192                                 if( count( $this->optionalChoices ) == 0 )
01193                                         $conEditor->contents .= renderInformationBox( i18n("No optional choices"), i18n("There are no optional choices defined yet - please add one by clicking on the Add Optional Choice command link above.") );
01194                                 else
01195                                 {
01196                                         $conEditor->contents .= "
01197                                         <table class=\"setup\">";
01198                                         foreach( $this->optionalChoices as $key => $value )
01199                                         {
01200                                                 $availableTitle = $value->available ? i18n("Make unavailable") : i18n("Make available");
01201                                                 $adminOnlyTitle = $value->adminOnly ? i18n("(administrator only)"): "";
01202                                                 $conEditor->contents .= "
01203                                                 <tr class=\"setup\">
01204                                                         <td class=\"setup\">" . $value->title . "</td>
01205                                                         <td class=\"setup wikirightalign\">$adminOnlyTitle
01206                                                         " . drawCommand( $availableTitle, i18n("Toggle the availability of this optional choice"), globalIDtoURL( "$thisGlobalID/optionalchoices/toggleavailable/$key" ) ) . "
01207                                                         " . drawCommand( i18n("Delete"), i18n("Delete the membership type"), globalIDtoURL( "$thisGlobalID/optionalchoices/delete/$key" ) ) . "
01208                                                         " . drawCommand( i18n("Edit"), i18n("Edit this optional choice"), globalIDtoURL( "$thisGlobalID/optionalchoices/$key" ) ) . "
01209                                                         </td>
01210                                                 </tr>";
01211                                         }
01212                                         $conEditor->contents .= "
01213                                         </table>";
01214                                 }
01215                         }
01216                         
01217                         break;
01218                 case "membershiptypes":
01219                         $conEditor->tabbar->setCurrent(i18n("Membership Types"));
01220                         $conEditor->addCommand( i18n("Add Membership Type"), i18n("Add a new membership type to this convention"), globalIDtoURL("$thisGlobalID/membershiptypes/new") );
01221                         
01222                         // Membership types
01223                         if( is_numeric( $editorSubsection ) && array_key_exists( $editorSubsection, $this->membershipTypes ) )
01224                         {
01225                                 $theMT = &$this->membershipTypes[$editorSubsection];
01226                                 
01227                                 $panel = new optionsPanel("mt");
01228                                 $panel->showHeader = false;
01229                                 $panel->saveTitle = i18n("Save membership type");
01230                                 $panel->revertTitle = i18n("Revert to saved");
01231                                 
01232                                 $panel->addOption( i18n("Title"), i18n("The title of the membership type"), $theMT->title, "title", "text" );
01233                                 $panel->addOption( i18n("Price"), i18n("The price of the membership type"), $theMT->price, "price", "text" );
01234                                 $panel->addOption( i18n("Administrator only"), i18n("If this is set, only admin is allowed to assign this membership type"), $theMT->adminOnly, "adminOnly", "checkbox" );
01235                                 $panel->addOption( i18n("Available amount"), i18n("The amount of places available of this membership type. When this number is reached, the membership type will automatically be made unavailable"), $theMT->maxCount, "maxCount", "text" );
01236                                 $panel->addOption( i18n("Description"), i18n("The description of the membership type"), $theMT->description, "description", "pagedata" );
01237                                 
01238                                 if( $panel->submitted )
01239                                 {
01240                                         $theMT->title = $panel->options["title"]["current"];
01241                                         $theMT->description = $panel->options["description"]["current"];
01242                                         $theMT->price = $panel->options["price"]["current"];
01243                                         $theMT->adminOnly = $panel->options["adminOnly"]["current"];
01244                                         $theMT->maxCount = $panel->options["maxCount"]["current"];
01245                                         $theMT->save();
01246                                         header("Location: " . globalIDtoURL("$thisGlobalID/membershiptypes") );
01247                                 }
01248                                 $conEditor->contents .= "<form action=\"" . globalIDtoURL( "$thisGlobalID/membershiptypes/$editorSubsection" ) . "\" method=\"POST\">" . $panel->render() . "</form>";
01249                         }
01250                         else if( $editorSubsection == "new" )
01251                         {
01252                                 // Create new, disabled by default, show editor
01253                                 $newMT = new MembershipType(&$this);
01254                                 $newMT->id = $this->getNextID();
01255                                 $newMT->save();
01256                                 
01257                                 $this->lock();
01258                                 $this->load();
01259                                 $this->membershipTypes[] = &$newMT;
01260                                 $this->save();
01261                                 $this->unlock();
01262                                 
01263                                 header("Location: " . globalIDtoURL( "$thisGlobalID/membershiptypes/" . endkey($this->membershipTypes) ) );
01264                         }
01265                         else if( $editorSubsection == "available" && is_numeric($editorSubsubsection) )
01266                         {
01267                                 $this->membershipTypes[$editorSubsubsection]->available = ($this->membershipTypes[$editorSubsubsection]->available == 1) ? 0 : 1;
01268                                 $this->membershipTypes[$editorSubsubsection]->save();
01269                                 header("Location: " . globalIDtoURL("$thisGlobalID/membershiptypes") );
01270                         }
01271                         else if( $editorSubsection == "delete" && is_numeric($editorSubsubsection) )
01272                         {
01273                                 if( $editorSubsubsub == "confirm" )
01274                                 {
01275                                         unlink( $this->conventionBasedir . "/membershiptypes/" . $this->membershipTypes[$editorSubsubsection]->id . ".php" );
01276                                         unset( $this->membershipTypes[$editorSubsubsection] );
01277                                         $this->save();
01278                                         header("Location: " . globalIDtoURL("$thisGlobalID/membershiptypes") );
01279                                 }
01280                                 else
01281                                 {
01282                                         $conEditor->contents .= renderInformationBox(
01283                                                 i18n("Delete?"),
01284                                                 i18n("Are you sure you wish to delete the ##0## membership type? Please note that any member who has chosen this membership type already will NO LONGER HAVE A MEMBERSHIP TYPE!##1##",
01285                                                         array(
01286                                                                 $this->membershipTypes[$editorSubsubsection]->title,
01287                                                                 "<div class=\"wikicenteralign\">" .
01288                                                                         drawCommand( i18n("Confirm delete"), i18n("Confirm deletion of this membership type"), globalIDtoURL( "$thisGlobalID/membershiptypes/delete/$editorSubsubsection/confirm" ) ) . " " .
01289                                                                         drawCommand( i18n("Abort delete"), i18n("Abort the deletion process"), globalIDtoURL("$thisGlobalID/membershiptypes") ) .
01290                                                                 "</div>"
01291                                                                 ),
01292                                                 false ) );
01293                                 }
01294                         }
01295                         else
01296                         {
01297                                 if( count( $this->membershipTypes ) == 0 )
01298                                         $conEditor->contents .= renderInformationBox( i18n("No membership types"), i18n("There are no membership types defined yet - please add one by clicking on the Add Membership Type command link above.") );
01299                                 else
01300                                 {
01301                                         $conEditor->contents .= "
01302                                         <table class=\"setup\">";
01303                                         foreach( $this->membershipTypes as $key => $value )
01304                                         {
01305                                                 $availableTitle = ($value->available == 1) ? i18n("Make unavailable") : i18n("Make available");
01306                                                 $adminOnlyTitle = $value->adminOnly ? i18n("(administrator only)"): "";
01307                                                 
01308                                                 $conEditor->contents .= "
01309                                                 <tr class=\"setup\">
01310                                                         <td class=\"setup\">" . $value->title . " (" . $value->maxCount . ")</td>
01311                                                         <td class=\"setup wikirightalign\">$adminOnlyTitle
01312                                                         " . drawCommand( $availableTitle, i18n("Toggle the availability of this membership type"), globalIDtoURL( "$thisGlobalID/membershiptypes/available/$key" ) ) . "
01313                                                         " . drawCommand( i18n("Delete"), i18n("Delete the membership type"), globalIDtoURL( "$thisGlobalID/membershiptypes/delete/$key" ) ) . "
01314                                                         " . drawCommand( i18n("Edit"), i18n("Edit this membership type"), globalIDtoURL( "$thisGlobalID/membershiptypes/$key" ) ) . "
01315                                                         </td>
01316                                                 </tr>";
01317                                         }
01318                                         $conEditor->contents .= "
01319                                         </table>";
01320                                 }
01321                         }
01322                         break;
01323                 case "calculateAverage":
01324                         $this->calculateAverage();
01325                         header( "Location: " . globalIDtoURL("$thisGlobalID/details") );
01326                         break;
01327                 case "emails":
01328                         $conEditor->tabbar->setCurrent(i18n("Emails"));
01329                         
01330                         $panel = new optionsPanel("con");
01331                         $panel->showHeader = false;
01332                         $panel->saveTitle = i18n("Save Emails");
01333                         $panel->revertTitle = i18n("Revert to saved");
01334                         
01335                         $helpText = i18n("You can use several placeholders in the fields below, all pertaining to the member the email is sent out to:") . "\n";
01336                         $helpText .= i18n("* ##nickname## is replaced with the member's nickname") . "\n";
01337                         $helpText .= i18n("* ##username## is replaced with the member's username") . "\n";
01338                         $helpText .= i18n("* ##regid## is replaced with the member's registration id") . "\n";
01339                         $helpText .= i18n("* ##password## is replaced with the member's password") . "\n";
01340                         $helpText .= i18n("* ##confirmationcode## is replaced with the member's confirmation code") . "\n";
01341                         $helpText .= i18n("* ##membershiptype## is replaced with the name of the member's membership type") . "\n";
01342                         $helpText .= i18n("* ##convention## is replaced with the convention's name") . "\n";
01343                         $helpText .= i18n("* ##conventionid## is replaced with the convention's id") . "\n";
01344                         
01345                         $panel->addHeader( i18n("Initial registration email - administrator confirmation"), "initial-header" );
01346                         $panel->addOption( i18n("Subject"), "", $this->emailSubjects["initial"], "initial-subject", "text" );
01347                         $panel->addOption( i18n("Body"), i18n("Send out to new members who have completed registration and are awaiting an administrator's confirmation"), $this->emailBodies["initial"], "initial-body", "textbox" );
01348                         
01349                         $panel->addHeader( i18n("Initial registration email - self-confirmation"), "initial2-header" );
01350                         $panel->addOption( i18n("Subject"), "", $this->emailSubjects["initial2"], "initial2-subject", "text" );
01351                         $panel->addOption( i18n("Body"), i18n("Sent out to members who have completed registration, but who can confirm the registration themselves"), $this->emailBodies["initial2"], "initial2-body", "textbox" );
01352                         
01353                         $panel->addHeader( i18n("Registration confirmed email - administrator confirmation"), "confirmed-header" );
01354                         $panel->addOption( i18n("Subject"), "", $this->emailSubjects["confirmed"], "confirmed-subject", "text" );
01355                         $panel->addOption( i18n("Body"), i18n("Sent out to members when membership is confirmed by an administrator"), $this->emailBodies["confirmed"], "confirmed-body", "textbox" );
01356                         
01357                         $panel->addHeader( i18n("Registration confirmed email - self-confirmation"), "confirmed2-header" );
01358                         $panel->addOption( i18n("Subject"), "", $this->emailSubjects["confirmed2"], "confirmed2-subject", "text" );
01359                         $panel->addOption( i18n("Body"), i18n("Sent out to members when membership is confirmed by themselves"), $this->emailBodies["confirmed2"], "confirmed2-body", "textbox" );
01360                         
01361                         $panel->addOption( i18n("Help"), "", parse_page_data($helpText), "input-help", "label" );
01362                         
01363                         
01364                         if( $panel->submitted )
01365                         {
01366                                 if( $this->lock() )
01367                                 {
01368                                         $this->emailSubjects["initial"] = $panel->getValue("initial-subject");
01369                                         $this->emailBodies["initial"] = $panel->getValue("initial-body");
01370                                         $this->emailSubjects["initial2"] = $panel->getValue("initial2-subject");
01371                                         $this->emailBodies["initial2"] = $panel->getValue("initial2-body");
01372                                         $this->emailSubjects["confirmed"] = $panel->getValue("confirmed-subject");
01373                                         $this->emailBodies["confirmed"] = $panel->getValue("confirmed-body");
01374                                         $this->emailSubjects["confirmed2"] = $panel->getValue("confirmed2-subject");
01375                                         $this->emailBodies["confirmed2"] = $panel->getValue("confirmed2-body");
01376                                         
01377                                         $this->save();
01378                                         $this->unlock();
01379                                 }
01380                         }
01381                         $conEditor->contents .= "<form action=\"" . thisPageURL() . "\" method=\"POST\">" . $panel->render() . "</form>";
01382                         break;
01383                 case "details":
01384                         // Convention details
01385                         $conEditor->tabbar->setCurrent(i18n("Convention Details"));
01386                         
01387                         $panel = new optionsPanel("con");
01388                         $panel->showHeader = false;
01389                         $panel->saveTitle = i18n("Save Convention");
01390                         $panel->revertTitle = i18n("Revert to saved");
01391                         
01392                         $panel->addOption( i18n("Title"), i18n("What is the convention called?"), $this->title, "title", "text" );
01393                         $panel->addOption( i18n("Start date"), i18n("When does the convention start?"), $this->startDate, "startDate", "datetime" );
01394                         $panel->addOption( i18n("End date"), i18n("When does the convention end?"), $this->endDate, "endDate", "datetime" );
01395                         $panel->addOption( i18n("Owner"), i18n("Who is the convention's main administrator. This person will receive an email notification of all new registrations"), $this->owner, "owner", "select", allUsersArray(true, true));
01396                         $panel->addOption( i18n("Average room size"), i18n("The convention's most common room size. Used for the room sharing system. ##0##", array( drawCommand( i18n("Calculate average room size"), i18n("Calculate the average room size of all hotels"), globalIDtoURL("$thisGlobalID/calculateAverage") ) ) ), $this->averagePerRoom, "averagePerRoom", "text" );
01397                         $panel->addOption( i18n("Registration enabled"), i18n("Tick this to enable user self registration"), $this->registrationEnabled, "registrationEnabled", "checkbox" );
01398                         $panel->addOption( i18n("Administrator confirmation"), i18n("Registrations require administrator confirmation"), $this->adminConfirmation, "adminConfirmation", "checkbox" );
01399                         $panel->addOption( i18n("Request T-Shirt Size"),i18n("Do you wish registrations to include T-Shirt size?"), $this->requestTShirtSize, "requestTShirtSize", "checkbox" );
01400                         $panel->addOption( i18n("Event duration lapse"), i18n("How long is the multiple of minutes available to events (for example 10 or 30)"), $this->eventLapse, "eventLapse", "text" );
01401                         $panel->addOption( i18n("Email footer"), i18n("You can here enter a message which will be put at the end of each email sent out by the system"), $this->emailFooter, "emailFooter", "textbox" );
01402                         $panel->addOption( i18n("Description"), i18n("How do you describe the convention?"), $this->description, "description", "pagedata" );
01403                         
01404                         if( $panel->submitted )
01405                         {
01406                                 $this->title = $panel->options["title"]["current"];
01407                                 $this->description = $panel->options["description"]["current"];
01408                                 $this->requestTShirtSize = $panel->options["requestTShirtSize"]["current"];
01409                                 $this->registrationEnabled = $panel->options["registrationEnabled"]["current"];
01410                                 $this->eventLapse = $panel->options["eventLapse"]["current"];
01411                                 $this->startDate = $panel->options["startDate"]["current"];
01412                                 $this->endDate = $panel->options["endDate"]["current"];
01413                                 $this->owner = $panel->options["owner"]["current"];
01414                                 $this->averagePerRoom = $panel->options["averagePerRoom"]["current"];
01415                                 $this->adminConfirmation = $panel->options["adminConfirmation"]["current"];
01416                                 $this->emailFooter = $panel->options["emailFooter"]["current"];
01417                                 $this->save();
01418                         }
01419                         $conEditor->contents .= "<form action=\"" . thisPageURL() . "\" method=\"POST\">" . $panel->render() . "</form>";
01420                         break;
01421                 case "member":
01422                 default:
01423                         $conEditor->tabbar->setCurrent(i18n("Registered Members"));
01424                         $conEditor->addCommand( i18n("New member"), i18n("Add a member to this convention"), globalIDtoURL( "$thisGlobalID/member/new" ) );
01425                         // Members
01426                         if( count( $this->members ) == 0 && $editorSubsection != "new" )
01427                                 $conEditor->contents = renderInformationBox( i18n("No members"), i18n("There are not currently any members registered for this convention") );
01428                         //   Registered members
01429                         else
01430                         {
01431                                 switch( $editorSubsection )
01432                                 {
01433                                 case "new":
01434                                         $conEditor->contents .= renderInformationBox( i18n( "Register new user for ##0##", array( $this->title ) ), "<form action=\"" . globalIDtoURL("$thisGlobalID/member/new") . "\" method=\"POST\">" . $this->handleRegistration( null, true, $thisGlobalID ) . "</form>", false );
01435                                         break;
01436                                 //   - Payment details
01437                                 //   - User details
01438                                 case "details":
01439                                         if( ! is_numeric( $editorSubsubsection ) )
01440                                                 header( "Location: " . globalIDtoURL( $thisGlobalID ) );
01441                                         
01442                                         $conEditor->contents .= $this->members[$editorSubsubsection]->renderEditor(true);
01443                                         break;
01444                                 //   Send messages
01445                                 case "sendmessage":
01446                                         $subject = stripslashes($_POST["messageSubject"]);
01447                                         $message = stripslashes($_POST["messageBody"]) . "\n" . $this->emailFooter;
01448                                         
01449                                         if( array_key_exists("selectedMembers", $_POST) && is_array($_POST["selectedMembers"]) )
01450                                                 foreach( $_POST["selectedMembers"] as $key => $value )
01451                                                         sendMessage($this->members[$key]->username, $subject, $message, $this->owner, "email");
01452                                         
01453                                         header( "Location: " . globalIDtoURL( $thisGlobalID ) );
01454                                         break;
01455                                 // Toggle confirmation status
01456                                 case "toggleconfirmed":
01457                                         if( ! is_numeric( $editorSubsubsection ) )
01458                                                 header( "Location: " . globalIDtoURL( $thisGlobalID ) );
01459                                         
01460                                         if( $this->members[$editorSubsubsection]->confirmed )
01461                                                 $this->members[$editorSubsubsection]->confirmed = false;
01462                                         else
01463                                                 $this->members[$editorSubsubsection]->setConfirmed();
01464                                         
01465                                         $this->members[$editorSubsubsection]->save();
01466                                         header( "Location: " . globalIDtoURL( $thisGlobalID ) );
01467                                         break;
01468                                 //   Delete a registration
01469                                 case "delete":
01470                                         if( ! is_numeric( $editorSubsubsection ) )
01471                                                 header( "Location: " . globalIDtoURL( $thisGlobalID ) );
01472                                         $panel = new optionsPanel("regdelete");
01473                                         $panel->showHeader = false;
01474                                         $panel->saveTitle = i18n("Confirm selection");
01475                                         $panel->resetTitle = i18n("Reset choices");
01476                                         
01477                                         $panel->addOption( i18n("The member in question"), "", $this->members[$editorSubsubsection]->realname , "regdesc", "label" );
01478                                         $panel->addOption( i18n("Check to delete"), i18n("Just leave unchecked and click Confirm selection to abort the deletion process"), 0, "confirmDelete", "checkbox" );
01479                                         
01480                                         if( $panel->submitted )
01481                                         {
01482                                                 if( $panel->options["confirmDelete"]["current"] == true )
01483                                                 {
01484                                                         $this->lock();
01485                                                         $this->load();
01486                                                         $errorHandler = new errorHandler(globalIDtoURL("$thisGlobalID/member/delete/$editorSubsubsection"));
01487                                                         if( file_exists( $this->conventionBasedir . "/members/$editorSubsubsection.php" ) )
01488                                                                 $errorHandler->handle( i18n("Deleting registration data from disk"), unlink( $this->conventionBasedir . "/members/$editorSubsubsection.php" ) );
01489                                                         unset( $this->members[$editorSubsubsection] );
01490                                                         $this->save();
01491                                                         $this->unlock();
01492                                                         
01493                                                         if( $errorHandler->handled == true )
01494                                                                 $conEditor->contents .= $errorHandler->render();
01495                                                         else
01496                                                                 header( "Location: " . globalIDtoURL( $thisGlobalID ) );
01497                                                 }
01498                                                 else
01499                                                         header( "Location: " . globalIDtoURL( $thisGlobalID ) );
01500                                         }
01501                                         
01502                                         $conEditor->contents .= renderInformationBox( i18n( "Delete ##0##?", array( $this->members[$editorSubsubsection]->realname ) ), "<form action=\"" . globalIDtoURL("$thisGlobalID/member/delete/$editorSubsubsection") . "\" method=\"POST\">" . $panel->render() . "</form>", false );
01503                                         
01504                                         break;
01505                                 default:
01506                                         $conEditor->contents .= "<form name=\"convention-members\" action=\"" . globalIDtoURL("$thisGlobalID/member/sendmessage") . "\" method=\"post\"><table class=\"setup convention-setup-members\">
01507                                         <tr class=\"setup\">
01508                                                 <th class=\"setup\">" . i18n("ID") . "</th>
01509                                                 <th class=\"setup\">" . i18n("Member") . "</th>
01510                                                 <th class=\"setup wikirightalign\">" . i18n("Remaining payment") . "</th>
01511                                                 <th class=\"setup wikirightalign\">" . i18n("Commands") . "</th>
01512                                         </tr>";
01513                                         
01514                                         foreach( $this->members as $key => $value )
01515                                                 $conEditor->contents .= $value->renderBlock($thisGlobalID);
01516                                                 
01517                                         $conEditor->contents .= "
01518                                         <tr class=\"option\">
01519                                                 <th colspan=\"4\" class=\"option\">
01520                                                         " . i18n("The message to be sent to the selected users") . "
01521                                                 </th>
01522                                         </tr>
01523                                         <tr class=\"option\">
01524                                                 <td colspan=\"4\" class=\"option\"><input type=\"text\" style=\"width: 100%;\" class=\"options_text\" name=\"messageSubject\" value=\"\" /><textarea rows=\"4\" style=\"width: 100%;\" class=\"option_textbox\" name=\"messageBody\"></textarea></td>
01525                                         </tr>
01526                                         <tr class=\"options\">
01527                                                 <td width=\"50%\" class=\"options-bottomleft\" colspan=\"2\"><input type=\"submit\" class=\"options_save\" name=\"saveOptions\" value=\"" . i18n("Send message") . "\" /></td>
01528                                                 <td width=\"50%\" class=\"options-bottomright\" colspan=\"2\"><input type=\"reset\" class=\"options_reset\" value=\"" . i18n("Reset") . "\" /></td>
01529                                         </tr>
01530                                         </table></form>";
01531                                         break;
01532                                 }
01533                         }
01534                         break;
01535                 }
01536                 
01537                 $renderedContent = "<h2 class=\"convention-title\">" . $this->title . "</h2><div class=\"convention-description\">" . parse_page_data($this->description) . "</div>";
01538                 
01539                 $renderedContent .= $conEditor->renderTabWidget();
01540                 
01541                 return $renderedContent;
01542         }
01543         
01547         function render()
01548         {
01549                 global $globalID, $conventionSettings, $usermanager;
01550                 $splitID = explode( "/", $globalID );
01551                 
01552                 switch( $splitID[1] )
01553                 {
01554                 // Events listing
01555                 case "events":
01556                         if( is_numeric( $splitID[2] ) )
01557                                 $renderedContent .= $this->events[$splitID[2]]->render();
01558                         else
01559                                 $renderedContent .= $this->renderEvents("convention");
01560                         break;
01561                 // Registered members area
01562                 case "member":
01563                         if( $_REQUEST["logout"] == "true" || !isAuth() )
01564                                 header("Location: " . globalIDtoURL("convention"));
01565                         
01566                         $currUser = currentUser();
01567                         $userID = false;
01568                         foreach( $this->members as $key => $value )
01569                         {
01570                                 if( $currUser == $value->username )
01571                                 {
01572                                         if( $value->confirmed == true )
01573                                                 $userID = $key;
01574                                         else if( !$this->adminConfirmation )
01575                                                 header( "Location: " . globalIDtoURL("convention/confirm") );
01576                                         
01577                                 }
01578                         }
01579                         
01580                         // If the user ID is boolean false, then the user isn't registered for /this/ con,
01581                         // but does have a username (they can't get to here if they're not actually logged in...
01582                         // If so, we need to let them sign up without generating a new username for them...
01583                         if( $userID !== false )
01584                         {
01585                                 if( $this->members[$userID]->confirmed )
01586                                         $renderedContent .= $this->members[$userID]->render();
01587                                 else
01588                                         $renderedContent .= renderInformationBox( i18n("Not yet confirmed"), i18n("You are not yet confirmed for this convention. Please refer to the email sent to you and the documentation found elsewhere on this website for further information on when this confirmation will happen.") );
01589                         }
01590                         else
01591                         {
01592                                 if( $this->registrationEnabled )
01593                                 {
01594                                         // Registration form below
01595                                         $renderedContent .= "<div
01596                                                 class=\"convention-registration\"><span
01597                                                 class=\"convention-registration-title\">" . i18n("You have not yet registered for this convention. You can do so using this form") . "</span><form action=\"" . globalIDtoURL("convention/member") . "\" method=\"post\">" . $this->handleRegistration( currentUser(), false, "convention/registered/##0##" ) . "</form></div>";
01598                                 }
01599                                 else
01600                                 {
01601                                         $renderedContent .= renderInformationBox( i18n("Registration disabled"), i18n("Sorry, registration is disabled for the convention right now.") );
01602                                 }
01603                                 
01604                         }
01605                         
01606                         break;
01607                 // Confirm email
01608                 case "confirm":
01609                         
01610                         // Check user with ID splitID[2] to see if convirmation code in splitID[3] is correct
01611                         if( array_key_exists( 2, $splitID ) && is_numeric($splitID[2]) && array_key_exists( 3, $splitID ) && $this->members[$splitID[2]]->confirmationCode == $splitID[3] )
01612                         {
01613                                 $this->members[$splitID[2]]->setConfirmed();
01614                                 
01615                                 $renderedContent .= renderInformationBox( i18n("Confirmation completed!"), i18n("You have successfully confirmed your registration, and you should shortly recieve an email with your password. You can now log in and continue on to see your membership status and change your information simply by going to the ##0##Registration page##1## and using the login box.", array("<a href=\"" . globalIDtoURL("convention") . "\">", "</a>") ) );
01616                         }
01617                         // If not, then there's something odd going on, or the user simply wants to enter the details manually...
01618                         else
01619                         {
01620                                 $panel = new optionsPanel("confirm");
01621                                 $panel->showHeader = false;
01622                                 $panel->saveTitle = i18n("Complete confirmation");
01623                                 $panel->revertTitle = i18n("Revert changes");
01624                                 
01625                                 $panel->addOption( i18n("User ID"), i18n("The ID you were assigned, it should be in the email you received"), "", "userid", "text" );
01626                                 $panel->addOption( i18n("Username"), i18n("The username you were assigned, it should be in the email you received"), "", "username", "text" );
01627                                 $panel->addOption( i18n("Confirmation code"), i18n("The 25 letter confirmation code which was emailed to you"), "", "confirmationCode", "text" );
01628                                 
01629                                 if( $panel->submitted )
01630                                 {
01631                                         if( $this->members[$panel->options["userid"]["current"]]->username != $panel->options["username"]["current"] )
01632                                                 $panel->options["username"]["error"] = i18n("The entered username does not match the entered User ID!");
01633                                         else if( $this->members[$panel->options["userid"]["current"]]->confirmationCode != $panel->options["confirmationCode"]["current"] )
01634                                                 $panel->options["confirmationCode"]["error"] = i18n("The entered confirmation code is incorrect!");
01635                                         else
01636                                         {
01637                                                 $this->members[$panel->options["userid"]["current"]]->setConfirmed();
01638                                                 
01639                                                 $renderedContent .= renderInformationBox( i18n("Confirmation completed!"), i18n("You have successfully confirmed your registration. You can now log in and continue on to see your membership status and change your information simply by going to the ##0##Registration page##1## and using the login box.", array("<a href=\"" . globalIDtoURL("convention") . "\">", "</a>") ) );
01640                                         }
01641                                 }
01642                                 
01643                                 $renderedContent .= "<form action=\"" . globalIDtoURL("convention/confirm") . "\" method=\"post\">" . renderInformationBox( i18n("Enter confirmation details below"), $panel->render(), false ) . "</form>";
01644                         }
01645                         break;
01646                 case "registered":
01647                         if( $this->adminConfirmation )
01648                                 $renderedContent .= renderInformationBox( i18n("Congratulations!"), i18n("Thank you for registering for ##0##!\nYou have been given a provisional registration number of: ##1##\nWe'll confirm your registration as soon as possible, which could be up to 48 hours.\nWe have sent you an email with these details.", array( $this->title, $splitID[2] ) ) );
01649                         else
01650                         {
01651                                 $renderedContent .= renderInformationBox( i18n("Congratulations!"), i18n("You have registered for ##0## and has been assigned the membership number ##1##. The next step you must take to complete your registration is to confirm the registration. You will shortly recieve an email containing a link to the confirmation address.", array( $this->title, $splitID[2] ) ) );
01652                                 sendMessage($this->owner, i18n("New registration ID ##0## for ##1##", array( $splitID[2], $this->title ) ), i18n("A new user has been registered. ##0##", array( globalIDtoURL( "setup/modulesetup/convention/cons/" . $this->id . "/member/details/" . $splitID[2] ) ) ), getUserInfo($this->owner, "email"), "email");
01653                         }
01654                         break;
01655                 // Login and registration form
01656                 default:
01657                         $renderedContent .= "<div class=\"convention-description\">" . parse_page_data( $this->description ) . "</div>";
01658                         
01659                         // Horizontal login box at the very top
01660                         if( isAuth() && isAllowed("global_admin") )
01661                         {
01662                                 $renderedContent .= "<div
01663                                 class=\"convention-loginform\"><span
01664                                 class=\"convention-loginform-title\">" . i18n("You have logged in") . "</span><span
01665                                 class=\"convention-loginform-loggedin\">" .
01666                                         i18n("The reason you are seeing this text is that you have administration rights. This means that you are allowed to register new users. If you simply wish to view your own membership, please go to ##0##", array( drawCommand( i18n("Your member page"), i18n("Go to your own member page"), globalIDtoURL("convention/member") ) ) ) .
01667                                 "</span></div>";
01668                         }
01669                         else
01670                         {
01671                                 $renderedContent .= "<form action=\"" . globalIDtoURL("convention/member") . "\" method=\"post\"><input type=\"hidden\" name=\"logout\" value=\"false\" /><div
01672                                 class=\"convention-loginform\"><span
01673                                 class=\"convention-loginform-title\">" . i18n("Existing Users - Login Here:") . "</span><span
01674                                 class=\"convention-loginform-username\"><span
01675                                         class=\"convention-loginform-username-label\">" . i18n("Username:") . "</span><input
01676                                         class=\"convention-loginform-username-input\" type=\"text\" name=\"username\"
01677                                 /></span><span
01678                                 class=\"convention-loginform-password\"><span
01679                                         class=\"convention-loginform-password-label\">" . i18n("Password:") . "</span><input
01680                                         class=\"convention-loginform-password-input\" type=\"password\" name=\"password\"
01681                                 /></span><span
01682                                 class=\"convention-loginform-controls\"><input
01683                                         class=\"convention-loginform-submit\" type=\"submit\" value=\"" . i18n("Login") . "\" name=\"convention-submit\" /><a
01684                                         class=\"convention-loginform-requestpassword\" href=\"" . globalIDtoURL("setup/requestpassword") . "\">" . i18n("Request new password") . "</a></span></div></form>";
01685                         }
01686                         
01687                         // Registration form below
01688                         if( $this->registrationEnabled )
01689                         {
01690                                 $available = false;
01691                                 foreach( $this->membershipTypes as $key => $value )
01692                                         if( $this->membershipTypes[$key]->isAvailable() )
01693                                                 $available = true;
01694                                 
01695                                 if( $available )
01696                                         $renderedContent .= "<div
01697                                         class=\"convention-registration\"><span
01698                                         class=\"convention-registration-title\">" . i18n("New Users - Register Below") . "</span><form action=\"" . globalIDtoURL("convention") . "\" method=\"post\">" . $this->handleRegistration( null, false, "convention/registered/##0##" ) . "</form></div>";
01699                                 else
01700                                         $renderedContent .= renderInformationBox( i18n("Registration closed"), i18n("Registration for ##0## has been closed on account of there being no more space available. Sorry!", array( $this->title ) ) );
01701                         }
01702                         else if( isAuth() && isAllowed("global_admin") )
01703                                 $renderedContent .= renderInformationBox( i18n("Registration disabled"), i18n("If you wish to enable the outside user registration for this convention, please go to the ##0##convention setup##1## to do so. This text is only visible to administrators.", array( "<a href=\"" . globalIDtoURL("setup/modulesetup/convention/details") . "\">", "</a>" ) ) );
01704                         
01705                         break;
01706                 }
01707                 
01708                 return $renderedContent;
01709         }
01710         
01711 } // end of Convention
01712 function extractBetweenDelimeters($inputstr,$delimeterLeft,$delimeterRight) {
01713     $posLeft  = stripos($inputstr,$delimeterLeft)+strlen($delimeterLeft);
01714     $posRight = stripos($inputstr,$delimeterRight,$posLeft+1);
01715     return  substr($inputstr,$posLeft,$posRight-$posLeft);
01716  }
01717 function convention_compare_remainingPayablerev($x, $y) { return arrayColumnCompare($x, $y, "remainingPayable", true); }
01718 function convention_compare_country($x, $y) { return arrayColumnCompare($x, $y, "country"); }
01719 ?>

Generated on Sun Oct 26 20:33:12 2008 for The Travelsized Content Management System by  doxygen 1.5.5