00001 <?php
00010 $modules_names[] = "Convention";
00011 $modules_versions[] = "0.1";
00012 $modules_descriptions[] = "A convention manager";
00013
00014 $modules_setup[] = "modulesetup_convention";
00015 #$profilemodules[] = "profilemodule_convention";
00016
00017 $modules[] = "parse_convention";
00018
00019 $page_help["\convention(txt1)"] = "Render the convention registration and login form for the convention with ID txt1. If txt1 is omitted, the registration form will work on the current convention.";
00020 $page_help["\conventionevents()"] = "Show the events for the convention - simply causes a redirect to the correct convention page";
00021
00022 include("$module_folder/convention/code/CountryFetcher.php");
00023 include("$module_folder/convention/code/ConventionSettings.php");
00024 include("$module_folder/convention/code/Convention.php");
00025 include("$module_folder/convention/code/Hotel.php");
00026 include("$module_folder/convention/code/Room.php");
00027 include("$module_folder/convention/code/Event.php");
00028 include("$module_folder/convention/code/EventRoom.php");
00029 include("$module_folder/convention/code/Member.php");
00030 include("$module_folder/convention/code/MembershipType.php");
00031 include("$module_folder/convention/code/OptionalChoice.php");
00032 include("$module_folder/convention/code/Residence.php");
00033
00034
00035 $conventionSettings = new ConventionSettings();
00036 $conventionSettings->currentConvention = new Convention( $conventionSettings->currentConvention );
00037
00038 $replacements["##CONVENTION_AVAILABLE##"] = $conventionSettings->currentConvention->currentAvailable;
00039
00040 function parse_convention( $page_data )
00041 {
00042 global $conventionSettings, $replacements, $meta_headers, $module_folder;
00043
00044 $replaced = false;
00045 $loopcontrol = 0;
00046 $moduleCommandName = "convention";
00047 while( $parameters = spotModuleCommand( $page_data, $moduleCommandName, &$loopcontrol ) )
00048 {
00049 if( $parameters == " " )
00050 $parameters = "";
00051
00052 if( $parameters == "" )
00053 $theCon =& $conventionSettings->currentConvention;
00054 else
00055 $theCon = new Convention($parameters);
00056
00057 $replaced = true;
00058
00059 $page_data = str_replace( "\\$moduleCommandName($parameters)", $theCon->render(), $page_data );
00060 }
00061
00062 if( strpos( $page_data, "\\conventionevents()" ) )
00063 header( "Location: " . globalIDtoURL("convention/events") );
00064
00065 if( $replaced )
00066 $meta_headers .= "
00067 <link rel=\"StyleSheet\" type=\"text/css\" href=\"" . siteURL(true) . "$module_folder/convention/convention.css\" />";
00068
00069 return $page_data;
00070 }
00071
00075 function profilemodule_convention()
00076 {
00077 }
00078
00079 function modulesetup_convention()
00080 {
00081 global $pagectl, $meta_headers, $setup_folder, $page_folder, $recent_file, $menu_folder, $module_folder, $theModuleSection, $theModuleSubsection, $theModuleAction, $conventionSettings, $default_language, $permissionlevels_array;
00082
00083 $meta_headers .= "
00084 <link rel=\"StyleSheet\" type=\"text/css\" href=\"" . siteURL(true) . "$module_folder/convention/convention.css\" />";
00085
00086 $conSetup = new TabWidget();
00087 $conSetup->tabbar->addTab(i18n("Current Convention"), globalIDtoURL("setup/modulesetup/convention"));
00088 $conSetup->tabbar->addTab(i18n("Convention Setup"), globalIDtoURL("setup/modulesetup/convention/cons"));
00089 $conSetup->tabbar->addTab(i18n("Options"), globalIDtoURL("setup/modulesetup/convention/options"));
00090
00091 switch( $theModuleSection )
00092 {
00093 case "options":
00094 $conSetup->tabbar->setCurrent(i18n("Options"));
00095 if( $theModuleAction == "create_convention_page" )
00096 {
00097
00098 $edit_page["id"] = $pagectl->getFreePageID($page_folder, $pagectl);
00099 $edit_page["title"] = $conventionSettings->title;
00100 $edit_page["menu"] = $conventionSettingsmenu_id;
00101 $edit_page["language"] = $default_language;
00102 $edit_page["content"] = "\\\\convention()";
00103 $edit_page["author"] = getUserInfo(currentUser(), "name");
00104 $edit_page["email"] = getUserInfo(currentUser(), "email");
00105
00106 unlink_multiple( "$page_folder/{$edit_page['id']}.*" );
00107
00108 if ($pagectl->savePageData($page_folder, $edit_page["id"], $edit_page["language"], $edit_page["author"], $edit_page["email"], $conventionSettings->menu_id, $edit_page["title"], $edit_page["content"])) {
00109 update_getpage_id($page_folder, $setup_folder, $pagectl);
00110 rotate_recent($edit_page["id"], $edit_page["title"], $edit_page["language"], date("j/n/y"), $recent_file);
00111
00112 $conventionSettings->page_id = $edit_page["id"];
00113 $conventionSettings->save();
00114
00115 header("Location: " . globalIDtoURL("setup/modulesetup/convention/options"));
00116 } else {
00117 $error_description = parse_page_data(i18n("The convention page could not be saved!"));
00118 }
00119 }
00120 if( $_POST["saveOptions"] && $_POST["dox"]["page_id"] != 12 && ( $dox_options["page_id"] != $_POST["dox"]["page_id"] || $dox_options["menu_id"] != $_POST["dox"]["menu_id"] || $dox_options["title"] != $_POST["dox"]["title"] ) )
00121 {
00122 $thePage = $pagectl->fetchPageData($_POST["page_id"]);
00123 unlink_multiple( "$page_folder/{$dox_options['page_id']}.*" );
00124 if ($pagectl->savePageData($page_folder, $_POST["dox"]["page_id"], $thePage["language"], $thePage["author"], $thePage["email"], $_POST["dox"]["menu_id"], $_POST["dox"]["title"], "\\\\documents()"))
00125 {
00126 update_getpage_id($page_folder, $setup_folder, $pagectl);
00127 rotate_recent($dox_options["page_id"], $dox_options["title"], $thePage["language"], date("j/n/y"), $recent_file);
00128 }
00129 }
00130 $panel = new optionsPanel("con");
00131 $panel->showHeader = false;
00132
00133 $panel->addHeader( i18n("Convention page"), "thepage" );
00134
00135 $pagelist = $pagectl->fetchPageList($page_folder);
00136 $temp_pagelist[12] = i18n("Please select a page...");
00137 foreach( $pagelist as $key => $value )
00138 {
00139 $temp_pagelist[$key] = $value["title"][0];
00140 }
00141 $panel->addOption(
00142 i18n("Convention page"),
00143 i18n("This is the page that will be used to show the convention on. If you want to create a new page to put the information into, ##0##simply click here##1## and this will be done for you.", array("<a href=\"" . globalIDtoURL("setup/modulesetup/convention/options/na/create_convention_page") . "\">", "</a>")),
00144 $conventionSettings->page_id,
00145 "page_id",
00146 "select",
00147 $temp_pagelist
00148 );
00149
00150 $panel->addOption(
00151 i18n("Title"),
00152 i18n("The title of the convention page"),
00153 $conventionSettings->title,
00154 "title",
00155 "text"
00156 );
00157
00158 $menulist = $pagectl->fetchMenuMenuList($menu_folder);
00159 foreach( $menulist as $key => $value )
00160 {
00161 $temp_menulist[$value["id"]] = $value["title"][0];
00162 }
00163 $panel->addOption(
00164 i18n("Convention menu"),
00165 i18n("This is the menu that will be shown on the convention page"),
00166 $conventionSettings->menu_id,
00167 "menu_id",
00168 "select",
00169 $temp_menulist
00170 );
00171
00172 $panel->addHeader( i18n("General Options"), "general" );
00173
00174 $panel->addOption(
00175 i18n("Currency"),
00176 i18n("What currency do we use at the conventions?"),
00177 $conventionSettings->currency,
00178 "currency",
00179 "text");
00180
00181 $panel->addOption(
00182 i18n("Default duration"),
00183 i18n("How long does a convention normally span. Number of days."),
00184 $conventionSettings->defaultDuration,
00185 "defaultDuration",
00186 "text");
00187
00188 if( count( $conventionSettings->availableConventions ) > 0 )
00189 $panel->addOption(
00190 i18n("Current convention"),
00191 i18n("Which convention is the current one?"),
00192 $conventionSettings->currentConvention->id,
00193 "currentConvention",
00194 "select",
00195 $conventionSettings->availableConventions);
00196
00197 if( $panel->submitted )
00198 {
00199 $conventionSettings->page_id = $panel->options["page_id"]["current"];
00200 $conventionSettings->menu_id = $panel->options["menu_id"]["current"];
00201 $conventionSettings->title = $panel->options["title"]["current"];
00202 $conventionSettings->defaultDuration = $panel->options["defaultDuration"]["current"];
00203 $conventionSettings->currentConvention = new Convention($panel->options["currentConvention"]["current"]);
00204 $conventionSettings->currency = $panel->options["currency"]["current"];
00205
00206 $conventionSettings->save();
00207 }
00208 $conSetup->contents = "<form action=\"" . thisPageURL() . "\" method=\"POST\">" . $panel->render() . "</form>";
00209
00210 break;
00211 case "cons":
00212 $conSetup->tabbar->setCurrent(i18n("Convention Setup"));
00213 $conSetup->addCommand( i18n("New convention"), i18n("Create a new convention"), globalIDtoURL("setup/modulesetup/convention/cons/newconvention") );
00214
00215 if( is_numeric( $theModuleSubsection ) )
00216 {
00217 $theCon = new Convention($theModuleSubsection);
00218 if( $theModuleAction == "delete" )
00219 {
00220 $panel = new optionsPanel("condelete");
00221 $panel->showHeader = false;
00222 $panel->saveTitle = i18n("Confirm selection");
00223 $panel->resetTitle = i18n("Reset choices");
00224
00225 $panel->addOption( i18n("The convention in question"), "", parse_page_data( "**" . $theCon->title . "**\n" . $theCon->description), "condesc", "label" );
00226 $panel->addOption( i18n("Check to delete"), i18n("Just leave unchecked and click Confirm selection to abort the deletion process"), 0, "confirmDelete", "checkbox" );
00227
00228 if( $panel->submitted )
00229 {
00230 if( $panel->options["confirmDelete"]["current"] == 1 )
00231 {
00232 $errorHandler = new errorHandler(globalIDtoURL("setup/modulesetup/convention/cons/$theModuleSubsection/delete"));
00233 $errorHandler->handle( i18n("Deleting convention data from disk"), rmdirr( $theCon->conventionBasedir ) );
00234 unset( $conventionSettings->availableConventions[$theModuleSubsection] );
00235 $errorHandler->handle( i18n("Save convention module settings"), $conventionSettings->save() );
00236
00237 if( $errorHandler->handled == true )
00238 $conSetup->contents .= $errorHandler->render();
00239 else
00240 header( "Location: " . globalIDtoURL( "setup/modulesetup/convention/cons" ) );
00241 }
00242 else
00243 header( "Location: " . globalIDtoURL( "setup/modulesetup/convention/cons" ) );
00244 }
00245
00246 $conSetup->contents .= renderInformationBox( i18n( "Delete ##0##?", array( $theCon->title ) ), "<form action=\"" . globalIDtoURL("setup/modulesetup/convention/cons/$theModuleSubsection/delete") . "\" method=\"POST\">" . $panel->render() . "</form>", false );
00247 }
00248 else
00249 $conSetup->contents .= $theCon->renderEditor();
00250 }
00251 else if( $theModuleSubsection == "newconvention" )
00252 {
00253 if( count( $conventionSettings->availableConventions ) == 0 )
00254 {
00255 $conSetup->contents = renderInformationBox( i18n("No conventions"), i18n("You have not yet set up any conventions. Bellow is a form which will let you create the first convention. Please fill this out and submit it to begin.") );
00256 $makeCurrent = 1;
00257 }
00258 else
00259 $makeCurrent = 0;
00260
00261 $panel = new optionsPanel("newcon");
00262 $panel->showHeader = false;
00263 $panel->saveTitle = i18n("Create Convention");
00264 $panel->revertTitle = i18n("Revert to defaults");
00265
00266 $panel->addOption(
00267 i18n("Title"),
00268 i18n("What is the convention called?"),
00269 i18n("Travelsized Convention"),
00270 "title",
00271 "text");
00272 $panel->addOption(
00273 i18n("Set as current"),
00274 i18n("Set this convention as the new current convention?"),
00275 $makeCurrent,
00276 "makeCurrent",
00277 "checkbox");
00278 $panel->addOption(
00279 i18n("Start date"),
00280 i18n("When does the convention start?"),
00281 time(),
00282 "startDate",
00283 "datetime");
00284 $panel->addOption(
00285 i18n("End date"),
00286 i18n("When does the convention end?"),
00287 time() + ( $conventionSettings->defaultDuration * 86400),
00288 "endDate",
00289 "datetime");
00290 $panel->addOption(
00291 i18n("Description"),
00292 i18n("How do you describe the convention?"),
00293 i18n("An Amazing Convention, brought to you by the Travelsized Convention Squad!"),
00294 "description",
00295 "pagedata");
00296
00297 if( $panel->submitted )
00298 {
00299 $newCon = new Convention();
00300 $newCon->title = $panel->options["title"]["current"];
00301 $newCon->description = $panel->options["description"]["current"];
00302 $newCon->startDate = $panel->options["startDate"]["current"];
00303 $newCon->endDate = $panel->options["endDate"]["current"];
00304 $newCon->save();
00305
00306 if( $panel->options["makeCurrent"]["current"] == 1 )
00307 {
00308 $conventionSettings->currentConvention = $newCon->id;
00309 $conventionSettings->save();
00310 header("Location: " . globalIDtoURL("setup/modulesetup/convention") );
00311 }
00312 else
00313 header("Location: " . globalIDtoURL( "setup/modulesetup/convention/cons/" . $newCon->id ) );
00314 }
00315
00316 $conSetup->contents .= "<form action=\"" . thisPageURL() . "\" method=\"POST\">" . $panel->render() . "</form>";
00317 }
00318 else
00319 {
00320 foreach( $conventionSettings->availableConventions as $key => $value )
00321 {
00322 $conSetup->contents .= "
00323 <div class=\"convention-conventionlist\">
00324 <a style=\"float: right;\" class=\"command\" href=\"" . globalIDtoURL("setup/modulesetup/convention/cons/$key") . "\">[" . i18n("View") . " »]</a>
00325 <a style=\"float: right;\" class=\"command\" href=\"" . globalIDtoURL("setup/modulesetup/convention/cons/$key/delete") . "\">[" . i18n("Delete") . "]</a>
00326 $value</div>";
00327 }
00328 }
00329 break;
00330 default:
00331 $conSetup->tabbar->setCurrent(i18n("Current Convention"));
00332
00333 if( count( $conventionSettings->availableConventions ) == 0 )
00334 header("Location: " . globalIDtoURL("setup/modulesetup/convention/cons/newconvention/1") );
00335 else
00336 $conSetup->contents .= $conventionSettings->currentConvention->renderEditor();
00337
00338 break;
00339 }
00340 return $conSetup->renderTabwidget();
00341 }
00342
00343 $modules_globalID[] = "globalID_convention";
00344 function globalID_convention( $splitID )
00345 {
00346 global $conventionSettings;
00347 $pageID = null;
00348
00349
00350 if( $splitID[0] == "convention" )
00351 {
00352 $pageID = $conventionSettings->page_id;
00353 }
00354
00355 else if( $splitID[0] == "user" && $splitID[2] == "convention" )
00356 {
00357 $_REQUEST["module"] = "profilemodule_convention";
00358 $pageID = "13";
00359 }
00360
00361 return $pageID;
00362 }
00363
00364 ?>