$r['categories'] = $this->wpdb->get_results($sql, ARRAY_A);
}
- if ( isset( $this->postAmenities ) && $this->postAmenities ) {
+ if ($this->postAmenities) {
+
$sql = "
SELECT EC.event AS event_id, C.id, C.name
FROM ".GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX. "amenities AS C,
}
}
if ($this->postAddLocations) {
+ include_once GLM_MEMBERS_PLUGIN_CLASS_PATH . '/data/dataMemberInfo.php';
+ $memberData = new GlmDataMemberInfo( $this->wpdb, $this->config );
$r['locations'] = array();
if ( $r['use_member_location']['value'] ) {
- include_once GLM_MEMBERS_PLUGIN_CLASS_PATH . '/data/dataMemberInfo.php';
- $memberData = new GlmDataMemberInfo( $this->wpdb, $this->config );
$member = $memberData->getActiveInfoForMember((int)$r['ref_dest_id']);
$r['member'] = $member;
} else if ( $r['other_ref_dest_id'] ) {
// get member id from the name
- include_once GLM_MEMBERS_PLUGIN_CLASS_PATH . '/data/dataMemberInfo.php';
- $memberData = new GlmDataMemberInfo( $this->wpdb, $this->config );
$member = $memberData->getActiveInfoForMember( (int)$r['other_ref_dest_id'] );
$r['member'] = $member;
} else {
return $r;
}
+
+ /**
+ * Get Cities List for Events
+ *
+ * Searches for cities with both member and internal data.
+ * May use option to specify a WHERE clause to limit the events
+ * that the cities are drawn from.
+ *
+ * @param string $where WHERE string to limit initial query of events.
+ *
+ * @return array cities list where key is city ID and value is an array of 'id', 'name'
+ */
+ public function getEventsCities($where = 'true')
+ {
+
+ $savedFields = $this->fields;
+ $savedpostAddTimes = $this->postAddTimes;
+ $savedpostAddLocations = $this->postAddLocations;
+ $savedpostAddRecurrences = $this->postAddRecurrences;
+ $savedpostFirstAndLastTimes = $this->postFirstAndLastTimes;
+ $savedpostCategories = $this->postCategories;
+ $savedpostAmenities = $this->postAmenities;
+
+ $this->postAddTimes = false;
+ $this->postAddLocations = true;
+ $this->postAddRecurrences = false;
+ $this->postFirstAndLastTimes = false;
+ $this->postCategories = false;
+ $this->postAmenities = false;
+
+ $this->fields = array(
+ 'id' => $savedFields['id'],
+ 'name' => $savedFields['name'],
+ 'use_member_location' => $savedFields['use_member_location'],
+ 'ref_dest_id' => $savedFields['ref_dest_id'],
+ 'other_ref_dest_id' => $savedFields['other_ref_dest_id']
+ );
+
+ $events = $this->getList($where);
+
+ $eventCities = array();
+ foreach ($events as $event) {
+
+ if (isset($event['member'])) {
+ $eventCities[$event['member']['city_id']] = array(
+ 'id' => $event['member']['city_id'],
+ 'name' => $event['member']['city']
+ );
+ } elseif (isset($event['locations'])) {
+ $eventCities[$event['locations']['city']['value']] = array(
+ 'id' => $event['locations']['city']['value'],
+ 'name' => $event['locations']['city']['name']
+ );
+ }
+
+ }
+
+ $this->fields = $savedFields;
+ $this->postAddTimes = $savedpostAddTimes;
+ $this->postAddLocations = $savedpostAddLocations;
+ $this->postAddRecurrences = $savedpostAddRecurrences;
+ $this->postFirstAndLastTimes = $savedpostFirstAndLastTimes;
+ $this->postCategories = $savedpostCategories;
+ $this->postAmenities = $savedpostAmenities;
+
+ return $eventCities;
+
+ }
+
+
}