Просмотр исходного кода

Log changes when a location is added

Alan Lam 2 лет назад
Родитель
Сommit
53fe24d6a8
1 измененных файлов с 11 добавлено и 3 удалено
  1. 11 3
      controllers/location_add.php

+ 11 - 3
controllers/location_add.php

@@ -10,7 +10,7 @@ Core::addBreadcrumb("/account/locations", "Locations");
 Core::addBreadcrumb("/account/locations?customer_id=$customer->id", "$customer->name Locations");
 Core::addBreadcrumb("/account/locations/add", $page_title);
 
-$location = new Location;
+$location = new Location();
 $location->customer_id = $customer->id;
 $location->country = DEFAULT_COUNTRY;
 
@@ -84,10 +84,18 @@ if($submit) {
 			$form_exception->addError("Failed to get latitude/longitude from address.");
 		}
 
-		if($form_exception->hasErrors()) throw $form_exception;
+		if($form_exception->hasErrors()) {
+			throw $form_exception;
+		}
+
+		$modified_fields = $location->getModifiedFields();
 
 		$success = $location->commit();
-		if(!$success) throw new Exception("Failed to add location at this time. Please try again later.");
+		if(!$success) {
+			throw new RuntimeException("Failed to add location at this time. Please try again later.");
+		}
+
+		$location->logUpdate((object) [], $modified_fields);
 
 		// Venue types
 		$venue_type_ids = http::value("venue_type_ids", "int");