/**
  * Save New Address Info to the Address Cache Module / Table
  * @param $aInfo array of geocode info (lng, lat, status, address)
  */
 function saveAddressCacheInfo($aInfo = array())
 {
     // Bug: $current_user object not properly set for some reason
     if (empty($GLOBALS['current_user']->id) && !empty($_SESSION['authenticated_user_id'])) {
         $GLOBALS['current_user']->id = $_SESSION['authenticated_user_id'];
     }
     if (!empty($this->settings['address_cache_save_enabled'])) {
         // Check for existing address cache data (prevent duplicates)
         $address_cache = $this->getAddressCacheInfo($aInfo);
         if (empty($address_cache)) {
             if (!empty($aInfo['address']) && !($aInfo['lng'] == 0 && $aInfo['lat'] == 0) && $this->is_valid_lng($aInfo['lng']) && $this->is_valid_lat($aInfo['lat'])) {
                 // Note: The modules 'name' field is used for the 'address'
                 // 'status' is not saved in the cache table.
                 $cache = new jjwg_Address_Cache();
                 $cache->update_modified_by = true;
                 $cache->name = $aInfo['address'];
                 $cache->lat = $aInfo['lat'];
                 $cache->lng = $aInfo['lng'];
                 $cache->description = '';
                 $cache->assigned_user_id = $GLOBALS['current_user']->id;
                 $cache->save(false);
                 return true;
             }
         }
     }
     return false;
 }
 public function testis_valid_lat()
 {
     $jjwgAddressCache = new jjwg_Address_Cache();
     //test with invalid values
     $this->assertEquals(false, $jjwgAddressCache->is_valid_lat(''));
     $this->assertEquals(false, $jjwgAddressCache->is_valid_lat(91));
     $this->assertEquals(false, $jjwgAddressCache->is_valid_lat(-91));
     //test with valid values
     $this->assertEquals(true, $jjwgAddressCache->is_valid_lat(90));
     $this->assertEquals(true, $jjwgAddressCache->is_valid_lat(-90));
 }