Esempio n. 1
0
$message = null;
$error = null;
$srv = new \Pasteque\LocationsService();
if (isset($_POST['id']) && isset($_POST['label'])) {
    // Update location
    $location = \Pasteque\Location::__build($_POST['id'], $_POST['label']);
    if ($srv->update($location)) {
        $message = \i18n("Changes saved");
    } else {
        $error = \i18n("Unable to save changes");
    }
} else {
    if (isset($_POST['label'])) {
        // New location
        $location = new \Pasteque\Location($_POST['label']);
        $id = $srv->create($location);
        if ($id !== false) {
            $message = \i18n("Location saved. <a href=\"%s\">Go to the location page</a>.", PLUGIN_NAME, \Pasteque\get_module_url_action(PLUGIN_NAME, 'location_edit', array('id' => $id)));
        } else {
            $error = \i18n("Unable to save changes");
        }
    }
}
$location = null;
if (isset($_GET['id'])) {
    $location = $srv->get($_GET['id']);
}
?>
<h1><?php 
\pi18n("Edit a location", PLUGIN_NAME);
?>