require_once GLM_MEMBERS_EVENTS_PLUGIN_CLASS_PATH.'/data/dataRecurrences.php';
require_once GLM_MEMBERS_EVENTS_PLUGIN_CLASS_PATH.'/data/dataManagement.php';
require_once GLM_MEMBERS_PLUGIN_CLASS_PATH.'/data/dataCities.php';
+require_once GLM_MEMBERS_PLUGIN_CLASS_PATH.'/data/dataCounties.php';
/**
* GLmMembersFront_event_fontAdd
foreach ($address as $key => &$part) {
$part = urlencode($part);
}
- $addressString = implode( ',', $address);
- $url = "//maps.googleapis.com/maps/api/geocode/json?address={$addressString}";
- $ch = curl_init($url);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
- $return = json_decode(curl_exec($ch));
- curl_close($ch);
- if (isset($return->results)) {
- $location = $return->results[0]->geometry->location;
-
- return array(
- $location->lat,
- $location->lng
- );;
+ $addressString = $address[0] . ',+' . $address[1] . '+' . $address[2];
+
+ $url = "https://nominatim.openstreetmap.org/search/?format=json&addressdetails=1&q={$addressString}&limit=1";
+ $return = json_decode( wp_remote_retrieve_body( wp_remote_get( $url ) ) );
+ if ( $return[0]->lat && $return[0]->lon ) {
+ return array( $return[0]->lat, $return[0]->lon);
} else {
return false;
}
$eventAmenities = array();
$venues = false;
$startTimeOnly = 0;
- $eventCategories = [];
+ $eventCategories = array();
$cities = array();
+ $counties = array();
if ( isset( $actionData['request']['member_only'] )
&& $memberOnly = filter_var( $actionData['request']['member_only'], FILTER_VALIDATE_BOOLEAN ) ) {
// populate cities dropdown
$cityData = new GlmDataCities( $this->wpdb, $this->config );
$cityVals = $cityData->getList( null, 'name' );
- foreach ( $cityVals as $city ) {
- $cities[$city['id']] = $city['name'];
+ if ( isset( $cityVals ) && is_array( $cityVals ) && !empty( $cityVals ) ) {
+ foreach ( $cityVals as $city ) {
+ $cities[$city['id']] = $city['name'];
+ }
+ }
+ // populate counties dropdown
+ $countyData = new GlmDataCounties( $this->wpdb, $this->config );
+ $countyVals = $countyData->getList( null, 'name' );
+ if ( isset( $countyVals ) && is_array( $countyVals ) && !empty( $countyVals ) ) {
+ foreach ( $countyVals as $county ) {
+ $counties[$county['id']] = $county['name'];
+ }
}
// populate category dropdown
$categories = new GlmDataEventsCategories( $this->wpdb, $this->config );
$place = $this->filterInput( $_REQUEST['place'] );
$address = $this->filterInput( $_REQUEST['address'] );
$city = $this->filterInput( $_REQUEST['city'] );
+ $county = $this->filterInput( $_REQUEST['county'] );
$state = $this->filterInput( $_REQUEST['state'] );
$zip = $this->filterInput( $_REQUEST['zip'] );
$contactEmail = $this->filterInput( $_REQUEST['contact_email'] );
'name' => $place,
'address' => $address,
'city' => $city,
+ 'county' => $county,
'state' => $state,
'zip' => $zip,
'phone' => $contactPhone,
'contact_fname' => $contactFirst,
'contact_lname' => $contactLast,
- 'email' => $contactEmail
+ 'email' => $contactEmail,
);
$locationDataFormat = array(
- '%d',
- '%s',
- '%s',
- '%d',
- '%s',
- '%s',
- '%s',
- '%s',
- '%s',
- '%s'
+ '%d', // eventID
+ '%s', // place
+ '%s', // address
+ '%d', // city
+ '%d', // county
+ '%s', // state
+ '%s', // zip
+ '%s', // contactPhone
+ '%s', // contactFirst
+ '%s', // contactLast
+ '%s', // contactEmail
);
if ( isset( $lat ) && isset( $lon ) && $lat && $lon) {
- $locationData['lat'] = $lat;
- $locationData['lon'] = $lon;
+ $locationData['lat'] = $lat;
+ $locationData['lon'] = $lon;
$locationDataFormat[] = '%s';
$locationDataFormat[] = '%s';
}
'confirmation_page' => $redirect_url,
'mainImgUrl' => GLM_MEMBERS_PLUGIN_MEDIA_URL . '/images/large/',
'cities' => $cities,
+ 'counties' => $counties,
);
//error_reporting(E_ALL ^ E_NOTICE);
</select>
</td>
</tr>
+ {if $settings.enable_counties}
+ <tr>
+ <th>County:</th>
+ <td>
+ <select id="county_{$loc.id}" data-id="{$loc.id}" name="Loc{$loc.id}_county">
+ <option value="0"></option>
+ {foreach from=$loc.county.list item=v}
+ <option value="{$v.value}"{if $v.default} selected="selected"{/if}>
+ {$v.name}
+ </option>
+ {/foreach}
+ </select>
+ </td>
+ </tr>
+ {/if}
<tr>
<th{if $settings.michigan_org_requirements && $lockedToMember} class="glm-required"{/if}>State:</th>
<td>
<input id="zip_{$loc.id}" data-id="{$loc.id}" type="text" name="Loc{$loc.id}_zip" value="{$loc.zip}" class="glm-form-text-input-medium zipcode-input">
</td>
</tr>
- <tr>
- <th>County:</th>
- <td>
- <select id="county_{$loc.id}" data-id="{$loc.id}" name="Loc{$loc.id}_county">
- <option value="0"></option>
- {foreach from=$loc.county.list item=v}
- <option value="{$v.value}"{if $v.default} selected="selected"{/if}>
- {$v.name}
- </option>
- {/foreach}
- </select>
- </td>
- </tr>
<tr>
<th>Country:</th>
<td>
</select>
</td>
</tr>
+ {if $settings.enable_counties}
+ <tr>
+ <th>County:</th>
+ <td>
+ <select id="county_{ newLocID }" data-id="{ newLocID }" name="{ newLocID }_county">
+ <option value="0"></option>
+ {foreach from=$newLocation.fieldData.county.list item=v}
+ <option value="{$v.value}"{if $v.default} selected="selected"{/if}>{$v.name}</option>
+ {/foreach}
+ </select>
+ </td>
+ </tr>
+ {/if}
<tr>
<th{if $settings.michigan_org_requirements && $lockedToMember} class="glm-required"{/if}>State:</th>
<td>
<input id="zip_{ newLocID }" data-id="{ newLocID }" type="text" name="{ newLocID }_zip" value="{$newLocation.fieldData.zip}" class="glm-form-text-input-medium zipcode-input">
</td>
</tr>
- <tr>
- <th>County:</th>
- <td>
- <select id="county_{ newLocID }" data-id="{ newLocID }" name="{ newLocID }_county">
- <option value="0"></option>
- {foreach from=$newLocation.fieldData.county.list item=v}
- <option value="{$v.value}"{if $v.default} selected="selected"{/if}>{$v.name}</option>
- {/foreach}
- </select>
- </td>
- </tr>
<tr>
<th>Country:</th>
<td>
<div class="glm-add-event-form-data">
<select name="city" class="glm-required" required>
<option value="">Choose City</option>
- {foreach $cities as $city_id => $city_name}
- <option value="{$city_id}">{$city_name}</option>
- {/foreach}
+ {foreach $cities as $city_id => $city_name}
+ <option value="{$city_id}">{$city_name}</option>
+ {/foreach}
+ </select>
+ </div>
+ </div>
+ <div class="glm-add-event-form-item">
+ <div class="glm-add-event-form-label">
+ <label>County</label>
+ </div>
+ <div class="glm-add-event-form-data">
+ <select name="county">
+ <option value="">Choose County</option>
+ {foreach $counties as $county_id => $county_name}
+ <option value="{$county_id}">{$county_name}</option>
+ {/foreach}
</select>
</div>
</div>
<select id="state_30" name="state" required>
{foreach $states as $stateAbbr => $stateName}
<option value="{$stateAbbr}"{if $state_def == $stateAbbr} selected{/if}>
- {$stateName}
- </option>
+ {$stateName}
+ </option>
{/foreach}
</select>
</div>