Browse files

Updated code that generates parking URLs so that if no URL is defined…

… in the config settings, then no URL is generated at all. I believe this was intended behaviour (as there is one location where the code checks whether the URL is blank and only adds an option if it isn't) but in all cases the config value had a query string appended, and therefore it would never be blank.

As well as ensuring that the contact's getReserveParkingSpaceUrl() function works properly, I have updated the code on the list_contacts view so that it only outputs the 'reserve parking space' option when a URL is available.  This was the only other place where the function is currently used.
  • Loading branch information...
1 parent fbd062f commit 05e8c8d05d457ffc0eebe7498ddc33d0173bf588 @MarkMaldaba MarkMaldaba committed Nov 13, 2012
View
6 application/models/contacts/Contact.class.php
@@ -607,7 +607,11 @@ function getToggleFavoriteUrl($redirect_to = null) {
* @return null
*/
function getReserveParkingSpaceUrl() {
- return config_option('parking space reservation url', '').'?license_plate='.$this->getLicensePlate();
+ $url = trim(config_option('parking space reservation url', ''));
+ if ($url != '') {
+ $url .= '?license_plate=' . $this->getLicensePlate();
+ }
+ return $url;
} // getReserveParkingSpaceUrl
/**
View
5 application/views/administration/list_contacts.php
@@ -26,7 +26,10 @@
<?php
$options = array();
if (logged_user()->isMemberOfOwnerCompany()) {
- $options[] = '<a href="' . $contact->getReserveParkingSpaceUrl() . '">' . lang('reserve parking space') . '</a>';
+ $parkingurl = trim($contact->getReserveParkingSpaceUrl());
+ if ($parkingurl != '') {
+ $options[] = '<a href="' . $parkingurl . '">' . lang('reserve parking space') . '</a>';
+ }
$options[] = '<a href="' . $contact->getShowMapUrl() . '">' . lang('show map') . '</a>';
$options[] = '<a href="' . logged_user()->getContact()->getShowRouteUrl($contact) . '">' . lang('show route') . '</a>';
}

0 comments on commit 05e8c8d

Please sign in to comment.