foreach ($_POST as $key => $value) { if (array_search($key, Event::$eventParamsNames)) { $eventParams[$key] = mysql_real_escape_string($value); } } $eventParams['date_time'] = $_POST['year'] . '-' . $_POST['month'] . '-' . $_POST['day'] . " " . $_POST['hour'] . ':' . $_POST['min']; /** * If no existing address is selected, it is assumed that a user creates a new address */ if ($_POST['addressID'] == '') { $addressValues = array(); foreach (Address::$addressParams as $param) { $addressValues[$param] = $_POST[$param]; } if ($_POST['locationID'] == '' && $_POST['location'] != "") { $addressValues['locationID'] = EventDatabaseManager::addLocation($_POST['location']); } $address = new Address($addressValues); EventDatabaseManager::addAddress($address); $eventParams['addressID'] = $address->getID(); } if (!isset($_POST['event_visible'])) { $eventParams['event_visible'] = 0; } $event = new Event($eventParams); if (isset($_GET['eventID'])) { $event->setEventID(mysql_real_escape_string($_GET['eventID'])); $result = EventDatabaseManager::updateEvent($event); } else { $result = EventDatabaseManager::addEvent($event); }
echo TOPIC_ADDED_MESSAGE; } else { echo TOPIC_NOT_ADDED_MESSAGE; } } } } /* * Add, edit or delete topic */ if (isset($_POST['locationName'])) { if (isset($_POST['deleteLocation']) && $_POST['deleteLocation'] == 'yes') { if (is_numeric($_GET['locationID'])) { if (EventDatabaseManager::deleteLocation($_GET['locationID'])) { echo MANDANT_DELETED_MESSAGE; } else { echo MANDANT_NOT_DELETED_MESSAGE; } } } else { if (isset($_GET['locationID']) && is_numeric($_GET['locationID'])) { EventDatabaseManager::updateLocation($_GET['locationID'], mysql_real_escape_string($_POST['name'])); } else { if (!isset($_GET['locationID'])) { if (EventDatabaseManager::addLocation(mysql_real_escape_string($_POST['locationName']))) { echo MANDANT_ADDED_MESSAGE; } } } } }