- Update the fair info editor

This commit is contained in:
dave 2009-09-25 22:53:40 +00:00
parent 8c79d88b5a
commit 40abe88ae4
2 changed files with 29 additions and 22 deletions

View File

@ -29,31 +29,39 @@ require_once('fair.inc.php');
$fair_type = array('feeder' => 'Feeder Fair', 'sfiab' => 'SFIAB Upstream', 'ysc' => 'YSC/CWSF Upstream'); $fair_type = array('feeder' => 'Feeder Fair', 'sfiab' => 'SFIAB Upstream', 'ysc' => 'YSC/CWSF Upstream');
if($_SESSION['embed'] == true) { /* Sort out who we're editting */
// user_auth_required('committee','admin'); if($_POST['users_id'])
$u = user_load($_SESSION['embed_edit_id']); $eid = intval($_POST['users_id']); /* From a save form */
} else { else if(array_key_exists('embed_edit_id', $_SESSION))
user_auth_required('fair'); $eid = $_SESSION['embed_edit_id']; /* From the embedded editor */
$u = user_load($_SESSION['users_id']); else
} $eid = $_SESSION['users_id']; /* Regular entry */
if($eid != $_SESSION['users_id']) {
/* Not editing ourself, we had better be
* a committee member */
user_auth_required('committee','admin');
}
$u = user_load($eid);
switch($_GET['action']) { switch($_GET['action']) {
case 'save': case 'save':
$id = intval($_POST['id']); $fairs_id = intval($u['fairs_id']);
if(trim($id) == '') { if($fairs_id == 0) {
$q = mysql_query("INSERT INTO fairs(`id`,`name`) VALUES('','new entry')"); $q = mysql_query("INSERT INTO fairs(`id`,`name`) VALUES('','new entry')");
$id = mysql_insert_id(); $id = mysql_insert_id();
} else { } else {
$id = intval($id); $id = intval($fairs_id);
} }
$name = mysql_escape_string(stripslashes($_POST['name'])); $name = mysql_real_escape_string(stripslashes($_POST['name']));
$abbrv = mysql_escape_string(stripslashes($_POST['abbrv'])); $abbrv = mysql_real_escape_string(stripslashes($_POST['abbrv']));
$url = mysql_escape_string($_POST['url']); $url = mysql_real_escape_string($_POST['url']);
$website = mysql_escape_string($_POST['website']); $website = mysql_real_escape_string($_POST['website']);
$type = array_key_exists($_POST['type'], $fair_type) ? $_POST['type'] : ''; $type = array_key_exists($_POST['type'], $fair_type) ? $_POST['type'] : '';
$username = mysql_escape_string(stripslashes($_POST['username'])); $username = mysql_real_escape_string(stripslashes($_POST['username']));
$password = mysql_escape_string(stripslashes($_POST['password'])); $password = mysql_real_escape_string(stripslashes($_POST['password']));
$enable_stats = ($_POST['enable_stats'] == 'yes') ? 'yes' : 'no'; $enable_stats = ($_POST['enable_stats'] == 'yes') ? 'yes' : 'no';
$enable_awards = ($_POST['enable_awards'] == 'yes') ? 'yes' : 'no'; $enable_awards = ($_POST['enable_awards'] == 'yes') ? 'yes' : 'no';
$enable_winners = ($_POST['enable_winners'] == 'yes') ? 'yes' : 'no'; $enable_winners = ($_POST['enable_winners'] == 'yes') ? 'yes' : 'no';
@ -109,12 +117,11 @@ if($_SESSION['embed'] == true) {
); );
} }
$s = ($_SESSION['embed'] == true) ? $_SESSION['embed_submit_url'].'&' : 'fair_info.php?';
?> ?>
<script type="text/javascript"> <script type="text/javascript">
function fairinfo_save(id) function fairinfo_save()
{ {
$("#debug").load("<?=$s?>sub=1&action=save", $("#fairinfo_form").serializeArray()); $("#debug").load("<?=$config['SFIABDIRECTORY']?>/fair_info.php?action=save", $("#fairinfo_form").serializeArray());
return false; return false;
} }
</script> </script>
@ -129,8 +136,7 @@ function fairinfo_save(id)
} }
echo "<form name=\"fairinfo\" id=\"fairinfo_form\" >\n"; echo "<form name=\"fairinfo\" id=\"fairinfo_form\" >\n";
echo "<input type=\"hidden\" name=\"action\" value=\"save\" />\n"; echo "<input type=\"hidden\" name=\"users_id\" value=\"{$u['id']}\" />\n";
echo "<input type=\"hidden\" name=\"id\" value=\"{$f['id']}\" />\n";
echo "<table class=\"tableedit\">\n"; echo "<table class=\"tableedit\">\n";
echo '<tr><td class="left">'.i18n('Fair Type').':</td><td class="right">'; echo '<tr><td class="left">'.i18n('Fair Type').':</td><td class="right">';
echo "<select name=\"type\" id=\"type\" >"; echo "<select name=\"type\" id=\"type\" >";
@ -188,7 +194,7 @@ function fairinfo_save(id)
their own SFIAB to upload data to this SFIAB.'); echo '</div>'; their own SFIAB to upload data to this SFIAB.'); echo '</div>';
echo "<br />"; echo "<br />";
echo "<input type=\"submit\" onclick=\"fairinfo_save({$f['id']});return false;\" value=\"".i18n("Save Fair Information")."\" />\n"; echo "<input type=\"submit\" onclick=\"fairinfo_save();return false;\" value=\"".i18n("Save Fair Information")."\" />\n";
echo "</form>"; echo "</form>";
echo "<br />"; echo "<br />";

View File

@ -169,6 +169,7 @@ case 'save':
//send the header //send the header
if($_SESSION['embed'] == true) { if($_SESSION['embed'] == true) {
echo "<br/>"; echo "<br/>";
display_messages();
echo "<h3>".i18n("Personal Information")."</h3>"; echo "<h3>".i18n("Personal Information")."</h3>";
echo "<br/>"; echo "<br/>";
} else { } else {