Changeset 1409
- Timestamp:
- 07/26/09 12:25:29 (3 years ago)
- Location:
- trunk/wifidog-auth
- Files:
-
- 8 modified
-
CHANGELOG (modified) (1 diff)
-
wifidog/classes/AbstractGeocoder.php (modified) (2 diffs)
-
wifidog/classes/Network.php (modified) (2 diffs)
-
wifidog/classes/Node.php (modified) (2 diffs)
-
wifidog/classes/User.php (modified) (4 diffs)
-
wifidog/geocoder.php (modified) (1 diff)
-
wifidog/js/hotspots_status_map.js (modified) (9 diffs)
-
wifidog/templates/sites/hotspots_map.tpl (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/wifidog-auth/CHANGELOG
r1403 r1409 1 1 # $Id$ 2 3 2009-07-26 Robin Jones 4 * Addded New Geocoders Yahoo and Google. 5 * Geocoder now defaults to google if no country specific Geocoder is found (in future, this will be made selectable by network) 6 * Fixed Postcode search on Find Hotspot Map #436 7 * Added search for user by email closes #417 8 * Added validation to networkID to stop database errors, closes #458 9 2 10 3 11 2009-07-10 Benoit Grégoire <benoitg@coeus.ca> -
trunk/wifidog-auth/wifidog/classes/AbstractGeocoder.php
r1013 r1409 68 68 // Implementation attributes 69 69 private $endpoint_url; 70 private $APIKey; 70 71 // This value is only used to prevent from running to same query twice 71 72 private $execute_query = true; 72 73 73 74 // Factory method hash map 74 private static $implementations_map = array ("Canada" => "GeocoderCanada", "USA" => "GeocoderUsa" );75 private static $implementations_map = array ("Canada" => "GeocoderCanada", "USA" => "GeocoderUsa", "UK" => "GeocoderYahooGlobal", "Earth" => "GeocoderGoogleGlobal"); 75 76 76 77 /** Returns a list of countries for which we provide a geocoder implementation … … 205 206 $this->execute_query = false; 206 207 } 208 209 protected function setAPIKey($APIKey) 210 { 211 $this->APIKey = $APIKey; 212 } 213 214 public function getAPIKey() 215 { 216 return $this->APIKey; 217 } 218 207 219 208 220 abstract public function validateAddress(); -
trunk/wifidog-auth/wifidog/classes/Network.php
r1401 r1409 329 329 $name = "new_network_id"; 330 330 $html .= "<input type='text' size='10' name='{$name}'>\n"; 331 332 331 return $html; 333 332 } … … 352 351 if (!empty($_REQUEST[$name])) { 353 352 $network_id = $_REQUEST[$name]; 353 354 if (!preg_match('/^[0-9a-zA-Z_-]+$/', $network_id)) { 355 throw new Exception(_("The Network ID entered was not valid. It must only contain Alphanumerical Characters, Hyphens and Underscores e.g. My_Network-6")); 356 return; 357 } 354 358 355 359 if ($network_id) { -
trunk/wifidog-auth/wifidog/classes/Node.php
r1393 r1409 1477 1477 if (!empty ($_REQUEST['geocode_only'])) 1478 1478 { 1479 $geocoder = AbstractGeocoder :: getGeocoder($this->getCountry()); 1479 if ($geocoder = AbstractGeocoder :: getGeocoder($this->getCountry()) != null) 1480 $geocoder = AbstractGeocoder :: getGeocoder($this->getCountry()); 1481 else 1482 $geocoder = AbstractGeocoder :: getGeocoder('Earth'); 1483 1480 1484 if ($geocoder != null) 1481 1485 { … … 1485 1489 $geocoder->setProvince($this->getProvince()); 1486 1490 $geocoder->setPostalCode($this->getPostalCode()); 1487 if ($geocoder->validateAddress() == =true)1491 if ($geocoder->validateAddress() == true) 1488 1492 { 1489 1493 if (($point = $geocoder->getGisLocation()) !== null) -
trunk/wifidog-auth/wifidog/classes/User.php
r1406 r1409 173 173 174 174 /** Instantiate a user object 175 * @param $usernameOrEmail The username or the email address of the user 176 * @param &$errMsg An error message will be appended to this if the username is not empty, but the user doesn't exist. 177 * @return a User object, or null if there was an error 178 */ 179 public static function getUserByUsernameOrEmail($usernameOrEmail, &$errMsg = null) { 180 $db = AbstractDb::getObject(); 181 $object = null; 182 183 $usernameOrEmail_str = $db->escapeString($usernameOrEmail); 184 $db->execSqlUniqueRes("SELECT user_id FROM users WHERE username ILike '$usernameOrEmail_str' OR email ILike '$usernameOrEmail_str'", $user_info, false); 185 186 if ($user_info != null) { 187 $object = self::getObject($user_info['user_id']); 188 } 189 else if (!empty($usernameOrEmail)) { 190 $errMsg .= sprintf(_("There is no user with username or email %s"),$usernameOrEmail); 191 } 192 return $object; 193 } 194 195 196 /** Instantiate a user object 175 197 * @param $url The OpenId url 176 198 * @return a User object, or null if none matched … … 813 835 $userSelector .= InterfaceElements :: generateInputSubmit($add_button_name, $add_button_value); 814 836 } else { 815 $userSelector = _(" Username") . ": " . InterfaceElements :: generateInputText("select_user_" . $user_prefix . "_username");816 } 817 $html = "<div class='user_select_user_ui_container'>".$networkSelector . $userSelector . "</div>\n";837 $userSelector = _("Search for Username or Email Address") . ": " . InterfaceElements :: generateInputText("select_user_" . $user_prefix . "_username"); 838 } 839 $html = "<div class='user_select_user_ui_container'>".$networkSelector . "<br>" . $userSelector . "</div>\n"; 818 840 return $html; 819 841 } … … 831 853 if (!empty ($_REQUEST[$name])) { 832 854 $username = $_REQUEST[$name]; 833 return self :: getUserByUsername AndOrigin($username, $network, $errMsg);855 return self :: getUserByUsernameOrEmail($username, $errMsg); 834 856 } else 835 857 return null; … … 865 887 $name = "user_" . $this->getId() . "_username"; 866 888 $content = "<input type='text' name='$name' value='" . htmlentities($this->getUsername()) . "' size=30><br/>\n"; 867 $content .= _("Be careful lwhen changing this: it's the username you use to log in!");889 $content .= _("Be careful when changing this: it's the username you use to log in!"); 868 890 $userPreferencesItems[] = InterfaceElements::genSectionItem($content, $title); 891 892 893 /* Email */ 894 $title = _("Email"); 895 $name = "email_" . $this->getId() . "_email"; 896 $content = "<input type='text' name='$name' disabled='disabled' value='" . htmlentities($this->getEmail()) . "' size=30><br/>\n"; 897 $content .= _("If you wish to change this address, please Email Support!"); 898 $userPreferencesItems[] = InterfaceElements::genSectionItem($content, $title); 899 900 869 901 870 902 /* Change password */ -
trunk/wifidog-auth/wifidog/geocoder.php
r916 r1409 55 55 if(!empty($_REQUEST["postal_code"])) 56 56 { 57 $geocoder = AbstractGeocoder::getGeocoder(" Canada");57 $geocoder = AbstractGeocoder::getGeocoder("Earth"); 58 58 $geocoder->setPostalCode($_REQUEST["postal_code"]); 59 59 $long = $geocoder->getLongitude(); -
trunk/wifidog-auth/wifidog/js/hotspots_status_map.js
r1066 r1409 42 42 */ 43 43 44 // Create a Global array that will contain refs to markers 45 var markers = new Array(); 46 44 47 // Translations 45 48 function HotspotsMapTranslations(browser_support, homepage, show_on_map, loading) … … 64 67 65 68 // Create the array that will contain refs to markers 66 this.markers = Array();69 //markers = Array(); 67 70 68 71 // Init source url … … 85 88 var self = this; 86 89 GDownloadUrl("geocoder.php?postal_code=" + postal_code, function(data, responseCode) { 87 var root_node = GXml.parse(data).documentElement 90 // To ensure against HTTP errors that result in null or bad data, 91 // always check status code is equal to 200 before processing the data 92 if(responseCode == 200) { 93 var root_node = GXml.parse(data).documentElement 88 94 self.findClosestHotspotByCoords(new GLatLng(GXml.value(root_node.getElementsByTagName("lat")[0]), GXml.value(root_node.getElementsByTagName("long")[0]))); 95 }else if(responseCode == -1) { 96 alert("Data request timed out. Please try later."); 97 } else { 98 alert("Request resulted in error. Check XML file is retrievable."); 99 } 100 89 101 }); 90 102 } 91 103 104 92 105 HotspotsMap.prototype.findClosestHotspotByPostalCode = function(postal_code) 93 106 { 94 if (postal_code != undefined && this.markers.length > 0) {107 if (postal_code != undefined && markers.length > 0) { 95 108 this.getGPointFromPostalCode(postal_code); 96 109 } … … 99 112 HotspotsMap.prototype.findClosestHotspotByCoords = function(coord) 100 113 { 101 if (coord != null && this.markers.length > 0) {114 if (coord != null && markers.length > 0) { 102 115 // Init values 103 116 var dist = null; … … 105 118 106 119 // For each registered markers 107 for(i in this.markers) {108 if( this.markers[i] && this.markers[i].getPoint) {120 for(i in markers) { 121 if(markers[i] && markers[i].getPoint) { 109 122 // Compute the distance in meters between the two points 110 tmp = coord.distanceFrom( this.markers[i].getPoint()); 111 123 tmp = coord.distanceFrom( markers[i].getPoint()); 112 124 if(dist == null || tmp < dist) { 113 125 dist = tmp … … 261 273 { 262 274 // Trigger click ( NB. markers is a global var ) 263 GEvent.trigger( this.markers[bubbleId], "click");275 GEvent.trigger(markers[bubbleId], "click"); 264 276 } 265 277 … … 335 347 // Prepare fragment that will go in the sidebar 336 348 var html = this.buildHtmlFromHotspot(hotspots[i], markerIcon); 337 html_list += html + "<br /><br /><a href=\"javascript:" + this.external_object_name +".openInfoBubble('" + GXml.value(hotspotId[0])+ "');\">" + this.translations.show_on_map + "</a><hr width='95%'/>";349 html_list += html + "<br /><br /><a href=\"javascript:" + this.external_object_name +".openInfoBubble('" + markers.length + "');\">" + this.translations.show_on_map + "</a><hr width='95%'/>"; 338 350 339 351 // Create, save as ID and add the marker … … 341 353 342 354 // markers is a global var 343 this.markers[GXml.value(hotspotId[0])] = marker; 355 //markers[GXml.value(hotspotId[0])] = marker; 356 markers[markers.length] = marker; 344 357 this.map.addOverlay(marker); 345 358 } … … 352 365 HotspotsMap.prototype.redraw = function() 353 366 { 354 for (i = 0;i < this.markers.length;i++) {355 this.map.removeOverlay( this.markers[i]);367 for (i = 0;i < markers.length;i++) { 368 this.map.removeOverlay(markers[i]); 356 369 } 357 370 -
trunk/wifidog-auth/wifidog/templates/sites/hotspots_map.tpl
r1249 r1409 62 62 {"Enter your postal code"|_}:<br/> 63 63 <input type="text" id="postal_code" size="10"><p/> 64 <input type="button" value="{"Show"|_}" onclick="toggleOverlay('map_postalcode_overlay'); p = document.getElementById('postal_code'); hotspots_map.findClosestHotspotByPostalCode(p.value);">64 <input type="button" value="{"Show"|_}" onclick="toggleOverlay('map_postalcode_overlay'); p = document.getElementById('postal_code'); HotspotsMap.prototype.findClosestHotspotByPostalCode(p.value);"> 65 65 </div> 66 66
