From e33531303f63183b0bab0e2ece8267523abc155f Mon Sep 17 00:00:00 2001
From: Jonathan Rosenbaum
Date: Thu, 5 Mar 2015 05:09:50 +0000
Subject: [PATCH] Interests now populate the database as defined in the
configurations.
1). Directions are in database_functions.
2). Initial population occurs on first submit.
3). Interests can be changed or deleted
4). It isn't a GUI interface, but it is useful for those without a MySQL understanding.
---
Connections/database_functions.php | 20 +++++++++----
contact_add_edit.php | 47 +++++++++++++++++++++++++++++-
shop_welcome.php | 20 +++++++++++--
3 files changed, 77 insertions(+), 10 deletions(-)
diff --git a/Connections/database_functions.php b/Connections/database_functions.php
index 8a1ce60..cce7255 100644
--- a/Connections/database_functions.php
+++ b/Connections/database_functions.php
@@ -67,27 +67,35 @@ $volunteer_interests = array(
"Publicizing/Outreach", "Graphic Design", "Greeter at the Front Desk",
"Accounting/Record Keeping", "Ordering parts/supplies", "Picking up Donated Bikes/Parts",
"Teaching classes", "League Certified Instructor", "Pricing bikes",
- "Fabricating", "Open Source Programming", "Other/Contact me for general help",
+ "Fabricating", "Open Source Programming", "Other/Contact me for general help"
);
// Provide a comment box - true of false
define("VOLUNTEER_INTEREST_COMMENTS", true);
+// NOTE: The 2 variables ($volunteer_interest_changename & $volunteer_interests_deletename)
+// below allow you to change or delete an interest.
+// Only uncomment one variable at a time, and follow the directions.
+
// Change an interest(s) name:
//
// 1. Associate the name you want to change with a different name to the right as show below.
-// In this example "League Certified Instructor" will become "LCI".
-// 2. Visit contact_add_edit_select.php, reload the page and you are good to go
+// In this example "League Certified Instructor" will become "LCI".
+// 2. Change the interests name in $volunteer_interests above at the same time.
+// 3. Visit your own contact, e.g. contact_add_edit.php?contact_id=1 and click on the Submit button,
+// and the database will be updated.
+// 4. Comment out //$volunteer_interests_changename
//
-//$volunteer_interests_changename = array("League Certified Instructor" => "LCI");
+// $volunteer_interests_changename = array("League Certified Instructor" => "LCI");
// Delete an interest(s) name.
//
// 1. Add the interest(s) you want to delete. Please understand
// that by doing this you will delete the interest and all associated data.
-// 2. Remove the interest from $volunteer_interests at the same time before saving this page,
+// 2. Remove the interest from $volunteer_interests above at the same time before saving this page,
// or it will be recreated.
-// 3. Visit contact_add_edit_select.php, reload the page and you are good to go
+// 3. Visit your own contact, e.g. contact_add_edit.php?contact_id=1 and click on the Submit button,
+// and the database will be updated.
//
//$volunteer_interests_deletename = array("LCI");
diff --git a/contact_add_edit.php b/contact_add_edit.php
index 90b9a42..8730557 100644
--- a/contact_add_edit.php
+++ b/contact_add_edit.php
@@ -15,6 +15,7 @@ if($_GET['shop_id']>0){
$shop_id = current_shop_by_ip();
}
+
switch ($_GET['error']) {
case 'new_error_message': //this is a sample error message. insert error case here
$error_message = '';
@@ -27,6 +28,7 @@ default:
$page_shop_log = PAGE_SHOP_LOG . "?shop_id=$shop_id";
+
if($_GET['contact_id'] == 'new_contact'){
@@ -84,6 +86,10 @@ if($_GET['contact_id'] == 'new_contact'){
$editFormAction = "?contact_id={$contact_id}&shop_id={$shop_id}";
+require_once('php-console/src/PhpConsole/__autoload.php');
+$handler = PhpConsole\Handler::getInstance();
+$handler->start();
+
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
$updateSQL = sprintf("UPDATE contacts SET first_name=%s, middle_initial=%s, last_name=%s, email=%s,
@@ -105,7 +111,45 @@ if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
mysql_select_db($database_YBDB, $YBDB);
$Result1 = mysql_query($updateSQL, $YBDB) or die(mysql_error());
-
+
+ // Are there any interests in the datatbase?
+ $sql = "SELECT option_name FROM options;";
+ $query = mysql_query($sql, $YBDB) or die(mysql_error());
+ while ($result = mysql_fetch_assoc($query)) {
+ $interests[] = $result["option_name"];
+ }
+ $interests = array_combine($interests,$interests);
+
+ if ($volunteer_interest_form && !isset($volunteer_interests_changename)) {
+
+ // populate database with user defined interests if they do not exist
+ $volunteer_interest = array_combine($volunteer_interests,$volunteer_interests);
+
+ foreach ($volunteer_interest as $interest) {
+ // Insert new interest
+ if ( !$interests[$interest] ) {
+ $query = "INSERT INTO options (id, option_name, option_value) VALUES (" .
+ $_POST['contact_id'] . ",'" . $interest . "',0);";
+ $result = mysql_query($query, $YBDB) or die(mysql_error());
+ }
+ }
+
+ } // end volunteer_interest_form populate and/or delete
+
+ // Change or delete an interest(s) name
+ if( isset($volunteer_interests_changename) ) {
+ foreach ($volunteer_interests_changename as $key => $interest) {
+ $sql = "UPDATE options SET option_name='" . $interest .
+ "' WHERE option_name='" . $interests[$key] . "';";
+ $query = mysql_query($sql, $YBDB) or die(mysql_error());
+ }
+ } else if( isset($volunteer_interests_deletename) ) {
+ foreach ($volunteer_interests_deletename as $interest) {
+ $sql = "DELETE FROM options WHERE option_name='" . $interest . "';";
+ $query = mysql_query($sql, $YBDB) or die(mysql_error());
+ }
+ }
+
if ($_POST['contact_id_entry'] == 'new_contact'){
//navigate back to shop that it came from
@@ -223,6 +267,7 @@ $totalRows_Recordset1 = mysql_num_rows($Recordset1);
";
diff --git a/shop_welcome.php b/shop_welcome.php
index 46fa7cd..5f72988 100644
--- a/shop_welcome.php
+++ b/shop_welcome.php
@@ -13,7 +13,9 @@ require_once('Connections/database_functions.php');
- Positive Spin is an all-volunteer non-profit organization
- entirely supported by volunteer time, part donations, and money donations.
+ entirely supported by volunteer time, bike, part and tool donations,
+ the purchase of reused bikes and parts, trade-ups, memberships
+ and financial donations.
- We expect that you volunteer time back to the project
@@ -21,7 +23,7 @@ require_once('Connections/database_functions.php');
- If you are unable to contribute time to the project
- we suggest a $5 donation for personal use of the shop in addition to any donations made for parts.
+ we suggest a $5 donation for personal use of the shop in addition to any other donations.
+ Repairs Policy:
+
+ We are all volunteers, and during shop hours open to repairs
+ we will not repair your bike for you or schedule repairs,
+ but rather we will help you do-it-yourself. At Positive Spin you can find work stations with tools,
+ bicycle repair stands, repair manuals, reasonably priced bicycle parts, and volunteers with varying levels of
+ experience in various areas of bicycle maintenance and repair. Volunteers may help you diagnose, repair and
+ provide instruction about your bicycle. You may discover that at the Spin even highly experienced volunteers learn
+ new skills from others! If you have a physical issue or handicap preventing you from physically
+ repairing your bicycle, we still want you to be part of the process in whatever way you are able,
+ and we will gladly help facilitate the repair of your bicycle.
+