return $area->getId();
}
- function delete_city($name) {
- if (! check_admin(1, "delete a city")) return;
-
- $city = get_city_by_name($name);
- if (! $city) return false;
-
- try {
- $city->delete();
- }
- catch (Exception $e) {
- echo "<p>Error deleting $name!</p>\n";
- /* XXX: Why? Check for addresses in use... */
- return false;
- }
-
- return true;
- }
-
function show_area_delivery_days_form($days) {
global $week;
echo "Delivery days:";
return true;
}
+ function confirm_delete_area($name, $id = null, &$city_id = null) {
+ if (! check_admin(1, "delete an area")) return;
+
+ if (isset($id)) $area = get_area_by_id($id);
+ else $area = get_area_by_name($name);
+ if (! $area) return false;
+
+ echo "<h3>Confirm deletion</h3>\n";
+ echo "<p>You must confirm deletion of area " . $area->getName() . ": " . $area->getDeleteLink(true) . "</p>\n";
+ }
+
function delete_area($name, $id = null, &$city_id = null) {
- if (! check_admin(1, "delete a area")) return;
+ if (! check_admin(1, "delete an area")) return;
if (isset($id)) $area = get_area_by_id($id);
else $area = get_area_by_name($name);
if (count($args)) {
switch ($args[0]) {
case "delete":
+ confirm_delete_area($name, $id, $city_id);
+ break;
+
+ case "confirmdelete":
delete_area($name, $id, $city_id);
break;
}
return $city->getId();
}
+ function confirm_delete_city($name, $id = null) {
+ if (! check_admin(1, "delete a city")) return;
+
+ if (isset($id)) $city = get_city_by_id($id);
+ else $city = get_city_by_name($name);
+ if (! $city) return false;
+
+ echo "<h3>Confirm deletion</h3>\n";
+ echo "<p>You must confirm deletion of city " . $city->getName() . ": " . $city->getDeleteLink(true) . "</p>\n";
+ }
+
function delete_city($name, $id = null) {
if (! check_admin(1, "delete a city")) return;
if (count($args)) {
switch ($args[0]) {
case "delete":
+ confirm_delete_city($name, $id);
+ break;
+
+ case "confirmdelete":
delete_city($name, $id);
break;
return $contact->getId();
}
+ function confirm_delete_contact($name, $id = null, &$city_id = null) {
+ if (! check_admin(1, "delete a contact")) return;
+
+ if (isset($id)) $contact = get_contact_by_id($id);
+ else $contact = get_contact_by_name($name);
+ if (! $contact) return false;
+
+ echo "<h3>Confirm deletion</h3>\n";
+ echo "<p>You must confirm deletion of contact " . $contact->getDisplayname() . ": " . $contact->getDeleteLink(true) . "</p>\n";
+ }
+
function delete_contact($name, $id = null, &$city_id = null) {
if (! check_admin(1, "delete a contact")) return;
if (count($args)) {
switch ($args[0]) {
case "delete":
+ confirm_delete_contact($name, $id);
+ break;
+
+ case "confirmdelete":
delete_contact($name, $id);
break;
}
return $donation->getId();
}
+ function confirm_delete_donation($id = null) {
+ if (! check_admin(1, "delete a donation")) return;
+
+ if (isset($id)) $donation = get_donation_by_id($id);
+ if (! $donation) return false;
+
+ echo "<h3>Confirm deletion</h3>\n";
+ echo "<p>You must confirm deletion of donation $id: " . $donation->getDeleteLink(true) . "</p>\n";
+ }
+
function delete_donation($id = null) {
if (! check_admin(1, "delete a donation")) return;
if (count($args)) {
switch ($args[0]) {
case "delete":
+ confirm_delete_donation($id);
+ break;
+
+ case "confirmdelete":
delete_donation($id);
break;
}
return $hub->getId();
}
+ function confirm_delete_hub($name, $id = null) {
+ if (! check_admin(1, "delete a hub")) return;
+
+ if (isset($id)) $hub = get_hub_by_id($id);
+ else $hub = get_hub_by_name($name);
+ if (! $hub) return false;
+
+ echo "<h3>Confirm deletion</h3>\n";
+ echo "<p>You must confirm deletion of hub " . $hub->getDisplayname() . ": " . $hub->getDeleteLink(true) . "</p>\n";
+ }
+
function delete_hub($name, $id = null, &$city_id = null) {
if (! check_admin(1, "delete a hub")) return;
if (count($args)) {
switch ($args[0]) {
case "delete":
+ confirm_delete_hub($name, $id);
+ break;
+
+ case "confirmdelete":
delete_hub($name, $id);
break;
}
return $order->getId();
}
+ function confirm_delete_order($id = null) {
+ if (! check_admin(1, "delete an order")) return;
+
+ if (isset($id)) $order = get_order_by_id($id);
+ if (! $order) return false;
+
+ echo "<h3>Confirm deletion</h3>\n";
+ echo "<p>You must confirm deletion of order $id: " . $order->getDeleteLink(true) . "</p>\n";
+ }
+
function delete_order($id = null) {
if (! check_admin(1, "delete an order")) return;
if (count($args)) {
switch ($args[0]) {
case "delete":
+ confirm_delete_order($id);
+ break;
+
+ case "confirmdelete":
delete_order($id);
break;
}
return $this->getLink($blurb, sprintf("%s/%s", $this->getURL(), urlencode($action)), array_unique(array_merge($classes, array("small"))));
}
- function getDeleteLink() {
- return $this->getActionLink("delete", "Delete", array("delete", "noprint"));
+ function getDeleteLink($confirm = false) {
+ $link = ($confirm) ? "confirmdelete" : "delete";
+ return $this->getActionLink($link, "Delete", array("delete", "noprint"));
}
}