BMLT Root Server
search_results_csv.php
Go to the documentation of this file.
1 <?php
2 /***********************************************************************/
3 /** \file search_results_csv.php
4 
5  \brief This file represents a View layer of the BMLT MVC pattern. It
6  will do a meeting search, and return the results as comma-separated
7  values (CSV). It is not an object-oriented file, and is quite simple
8  to use. For many people, the procedural View Layer files may be all
9  they need to see. The object-oriented stuff is encapsulated within.
10 
11  The way you use this file is to call DisplaySearchResultsCSV with an
12  array that contains values that specify the search.
13 
14  This file is part of the Basic Meeting List Toolbox (BMLT).
15 
16  Find out more at: https://bmlt.app
17 
18  BMLT is free software: you can redistribute it and/or modify
19  it under the terms of the MIT License.
20 
21  BMLT is distributed in the hope that it will be useful,
22  but WITHOUT ANY WARRANTY; without even the implied warranty of
23  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24  MIT License for more details.
25 
26  You should have received a copy of the MIT License along with this code.
27  If not, see <https://opensource.org/licenses/MIT>.
28 */
29 
30 defined('BMLT_EXEC') or die('Cannot Execute Directly'); // Makes sure that this file is in the correct context.
31 
32 require_once(dirname(__FILE__).'/common_search.inc.php');
33 require(dirname(__FILE__).'/../../server/config/get-config.php'); // Just to make sure we have an early copy.
34 
35 global $g_format_dictionary; ///< This is a dictionary used to translate formats to NAWS format. It uses the format shared IDs in the server's language.
36 
38 
39 /// If you wish to override this, simply set this up in your /get-config.php file. That will supersede this.
40 /// Actually... this block of code never, ever gets hit because the above call to bmlt_populate_format_dictionary
41 /// will always set $g_format_dictionary. We should... probably remove it?
42 if (!isset($g_format_dictionary) || !is_array($g_format_dictionary) || !count($g_format_dictionary)) {
43  /// This is the default set.
44  /// The right side is the BMLT side, and the left side is the NAWS code. The left side should not be changed.
45  $g_format_dictionary = array (
46  'CPT' => null,
47  'MED' => null,
48  'QA' => null,
49  'RA' => null,
50  'BEG' => array(1),
51  'BT' => array(3),
52  'OPEN' => array(4),
53  'CAN' => array(6),
54  'CH' => array(5),
55  'CW' => array(7),
56  'DISC' => array(8),
57  'GL' => array(10),
58  'GP' => array(52),
59  'IP' => array(12),
60  'IW' => array(13),
61  'JFT' => array(14),
62  'LIT' => array(36),
63  'M' => array(15),
64  'CLOSED' => array(17),
65  'NC' => array(16),
66  'NS' => array(37),
67  'SMOK' => array(25),
68  'SPK' => array(22),
69  'STEP' => array(27),
70  'SWG' => array(23),
71  'TOP' => array(29),
72  'TRAD' => array(30),
73  'VAR' => array(19),
74  'W' => array(32),
75  'WCHR' => array(33),
76  'Y' => array(34)
77  );
78 }
79 
80 /*******************************************************************/
81 /** \brief This reads in the server format codes, and populates the
82  format dictionary with the NAWS IDs.
83 */
85 {
86  global $g_format_dictionary; ///< This is a dictionary used to translate formats to NAWS format. It uses the format shared IDs in the server's language.
87 
88  // first accumulate a local array of formats in $dict
89  $dict = [];
91  $localized_strings = c_comdef_server::GetLocalStrings();
92  $formats_array = c_comdef_server::GetServer()->GetFormatsObj()->GetFormatsArray();
93 
94  foreach ($formats_array['en'] as $format) {
95  if ($format instanceof c_comdef_format) {
96  $world_id = $format->GetWorldID();
97  $shared_id = $format->GetSharedID();
98  if ($world_id && $shared_id) {
99  if (array_key_exists($world_id, $dict)) {
100  array_push($dict[$world_id], $shared_id);
101  } else {
102  $dict[$world_id] = array( $shared_id );
103  }
104  }
105  }
106  }
107  // add all the formats in $dict to $g_format_dictionary, putting the preferred formats first (in the same
108  // order as in naws_export_formats_at_front)
109  $g_format_dictionary = [];
111  $preferred = $local_strings['naws_export_formats_at_front'];
112  foreach ($preferred as $id) {
113  if (array_key_exists($id, $dict)) {
114  $g_format_dictionary[$id] = $dict[$id];
115  }
116  }
117  foreach ($dict as $id => $val) {
118  if (!in_array($id, $preferred)) {
119  $g_format_dictionary[$id] = $dict[$id];
120  }
121  }
122 }
123 
124 /*******************************************************************/
125 /** \brief This function does a search, then builds a CSV result,
126  with each row being a meeting. The first row is a row of keys.
127 
128  \returns a string, containing CSV data, with the first row a key header.
129 */
131  $in_http_vars,
132  // The various HTTP GET and POST parameters.
133  // If this is defined and set to 'yes', then that means the client supports AJAX.
134  // - 'supports_ajax'
135  // We serve non-JavaScript content to clients that don't support AJAX, even if they support JavaScript.
136  //
137  // The values that are important to the list paging are:
138  // - 'page_num'
139  // This is a positive integer, specifying which page of results to display.
140  //
141  // - 'page_size'
142  // This is the number of meetings to list on one "page" of results.
143  // The search results are paged, so that a large search is broken
144  // into multiple pages of page_display_size results.
145  //
146  // - 'sort_key'
147  // This is the key to use for sorting. There are three possible values:
148  // - 'town'
149  // This is sorted by town, borough and neighborhood first, weekday and time second.
150  // - 'weekday'
151  // This is sorted by weekday first, town, borough and neighborhood second, then time
152  // - 'time'
153  // This is sorted by weekday first, time, second, then town, borough and neighborhood.
154  //
155  // - 'sort_dir'
156  // This is the direction of the sort. It can be one of the following:
157  // - 'asc'
158  // Ascending, from least to greatest.
159  // - 'desc'
160  // Descending, from greatest to least.
161  //
162  // These are used to specify a search:
163  //
164  // - 'services'
165  // This is an array of positive integers.
166  // This is interpreted as an array of integers. Each integer represents the ID of a Service Body.
167  // A positive integer means that the search will look specifically for meetings that contain that
168  // Service Body ID.
169  // If the integer is negative (preceded by a minus sign -), then the criteria will be to look
170  // for meetings that don't contain that ID.
171  // If no 'services' values are given, then the search will not use the Service Body field as a
172  // search criteria.
173  //
174  // - 'weekdays'
175  // This is an array of positive integers ( 1-7).
176  // This is interpreted as an array of integers. Each integer represents a weekday (1 -> Sunday, 7 -> Saturday).
177  // A positive integer means that the search will look specifically for meetings that occur on that weekday.
178  // If the integer is negative (preceded by a minus sign -), then the criteria will be to look
179  // for meetings that don't occur on that weekday.
180  // If no 'weekdays' values are given, then the search will not use the weekday field as a
181  // search criteria.
182  //
183  // - 'formats'
184  // This is an array of positive integers.
185  // This is interpreted as an array of integers. Each integer represents a format shared ID.
186  // A format ID means that the search will look specifically for meetings that have that format.
187  // If the format is negative (preceded by a minus sign -), then the criteria will be to look
188  // for meetings that don't have that format.
189  // If no 'formats' values are given, then the search will not use the formats field as a
190  // search criteria.
191  //
192  // - 'langs'
193  // This is an array of 2-character strings.
194  // This is interpreted as an array of strings. Each string represents a language code, and is a 2-character string.
195  // A language string means that the search will look specifically for meetings that are in that language.
196  // If the language is preceded by a minus sign -, then the criteria will be to look
197  // for meetings that are not in that language.
198  // If no 'langs' values are given, then the search will not use the lang_enum field as a
199  // search criteria.
200  //
201  // - 'bmlt_search_type'
202  // This is set to 'advanced' if the search is an advanced one (we need to take more criteria into consideration).
203  //
204  // - 'advanced_formats'
205  // This is the formats array, but is only counted if the bmlt_search_type is set to 'advanced'.
206  //
207  // - 'advanced_service_bodies'
208  // This is the same, but for Service Bodies.
209  //
210  // - 'advanced_weekdays'
211  // ...and weekdays.
212  //
213  // - 'advanced_radius'
214  // ...and radius (in degrees)
215  //
216  // - advanced_mapmode
217  // If this is true (1), then the Advanced form is using its map.
218  //
219  // The following values specify a start time "window." The meeting must start on, or after StartsAfterH/M, and
220  // can start no later than StartsBeforeH/M
221  //
222  // - 'StartsAfterH'
223  // A positive integer between 0 and 23. The hour of the minimal start time for meetings, in military time.
224  // - 'StartsAfterM'
225  // A positive integer between 0 and 59. The minute of the minimal start time for meetings, in military time.
226  // - 'StartsBeforeH'
227  // A positive integer between 0 and 23. The hour of the maximal start time for meetings, in military time.
228  // - 'StartsBeforeM'
229  // A positive integer between 0 and 59. The minute of the maximal start time for meetings, in military time.
230  //
231  // The following values specify a time duration "window." The meeting can last no longer than MaxDurationH/M,
232  // and no less than MinDurationH/M.
233  //
234  // - 'MinDurationH'
235  // A positive integer. This is the number of hours in the minimal duration.
236  // - 'MinDurationM'
237  // A positive integer. This is the number of minutes in the minimal duration.
238  // - 'MaxDurationH'
239  // A positive integer. This is the number of hours in the maximal duration.
240  // - 'MaxDurationM'
241  // A positive integer. This is the number of minutes in the maximal duration.
242  //
243  // This is how meetings are located. We don't use address lookups. Instead, we geolocate the meetings via the
244  // longitude and latitude fields in each record. If you don't specify a geolocation, then the entire database
245  // is searched. If you do specify one, then only the portion within the radius is searched.
246  //
247  // - 'geo_width'
248  // A floating point number. This is the radius (not diameter) of the search, in MILES (not Kilometers).
249  // If this is negative, then it should be an integer, and that indicates an auto-radius is requested to
250  // find the number of meetings in the integer.
251  //
252  // - 'geo_width_km'
253  // A floating point number. This is the radius (not diameter) of the search, in KILOMETERS (not Miles).
254  // If this is negative, then it should be an integer, and that indicates an auto-radius is requested to
255  // find the number of meetings in the integer.
256  //
257  // - 'long_val'
258  // If one of the three radius specifiers is zero or undefined, this is ignored.
259  // This is a floating point number that specifies the longitude, in degrees, of the center of the search radius.
260  //
261  // - 'lat_val'
262  // If one of the three radius specifiers is zero or undefined, this is ignored.
263  // This is a floating point number that specifies the latitude, in degrees, of the center of the search radius.
264  //
265  // - 'SearchString'
266  // A string. If this is specified, then all the string fields of the meetings specified by the above criteria
267  // will be searched for the string. By default, if the language supports metaphone (sound like search), then
268  // that is used.
269  //
270  // - 'StringSearchIsAnAddress'
271  // A boolean. Nonzero means that the given string should not be checked against any of the fields in the meeting
272  // data. Instead, it is to be considered a submission to the Google Maps geocode, and will be used to determine
273  // a cernter point in a local search.
274  //
275  // - 'SearchStringAll'
276  // If nonzero, then all of the words in the search string will have to be matched for a meetings to qualify.
277  //
278  // - 'SearchStringExact'
279  // If nonzero, metaphone will not be used, and the spelling must be exact.
280  //
281  // - 'meeting_ids'
282  // An array of positive integers. Each integer is an ID of an individual meeting. If this is set, all other
283  // search criteria are ignored.
284  //
285  // - 'sort_keys'
286  // This is a comma-separated list of sort keys. The leftmost one will be the top priority, and the rightmost the lowest.
287  // The sort depth will be the number of keys.
288  // The direction will be assumed 'asc', unless 'desc' is one of the keys (it can be anywhere in the list).
289  //
290  // - 'simple_other_fields'
291  // Set this to '1' in order to prevent the server from separating values with the prompt separator.
292  &$return_array = null, ///< If this is supplied, then the result will be saved in this as an array. It must be an empty array, supplied by reference.
293  &$return_geocode = null,
294  // If this is supplied, the response will be an associative array, with the search center and radius.
295  // It will return:
296  // - 'radius' The radius of the search, in Km
297  // - 'longitude' The longitude of the search center
298  // - 'latitude' Th latitude of the search center
299  &$return_results = null, ///< If supplied, should point to an array that will be filled with the actual meeting objects that comprise the result.
300  $in_supress_hidden_concat = false, ///< If true, then hidden fields will not have their prompts encoded
301  $in_editor_only = false ///< If true, then only meetings for which the current logged-in user can edit/observe are returned.
302 ) {
303  $ret = null;
304  require_once(dirname(__FILE__).'/c_comdef_meeting_search_manager.class.php');
305 
306  $search_manager = new c_comdef_meeting_search_manager;
307 
308  if ($search_manager instanceof c_comdef_meeting_search_manager) {
309  $localized_strings = c_comdef_server::GetLocalStrings();
310 
311  $lang_enum = c_comdef_server::GetServer()->GetLocalLang();
312 
313  // This can be changed in the auto config.
314  include(dirname(__FILE__).'/../../server/config/get-config.php');
315 
316  if (isset($in_http_vars['lang_enum']) && $in_http_vars['lang_enum']) {
317  $lang_enum = $in_http_vars['lang_enum'];
318  }
319 
320  if (!isset($in_http_vars['results_per_page'])) {
321  $in_http_vars['results_per_page'] = 0;
322  }
323 
324  if (isset($default_sort_key) && !isset($in_http_vars['sort_key']) && !isset($in_http_vars['sort_keys'])) {
325  $in_http_vars['sort_key'] = $default_sort_key;
326  }
327 
328  if ((!isset($in_http_vars['sort_dir']) || ( ($in_http_vars['sort_dir'] != 'desc') && ($in_http_vars['sort_dir'] != 'asc') ) ) && !isset($in_http_vars['sort_keys'])) {
329  $in_http_vars['sort_dir'] = 'asc';
330  }
331 
332  SetUpSearch($search_manager, $in_http_vars);
333 
334  if (isset($in_http_vars['page_size'])) {
335  $search_manager->SetResultsPerPage($in_http_vars['page_size']);
336  }
337 
338  if (isset($in_http_vars['sort_dir'])) {
339  $sort_dir_desc = ($in_http_vars['sort_dir'] == "desc") ? true : false;
340 
341  if (isset($localized_strings['default_sorts']) && isset($in_http_vars['sort_key']) && isset($sort_dir_desc) && !isset($in_http_vars['sort_keys'])) {
342  $search_manager->SetSort($localized_strings['default_sorts'][$in_http_vars['sort_key']], $sort_dir_desc, 0);
343  }
344  }
345 
346  $search_manager->DoSearch();
347 
348  $long = null;
349  $lat = null;
350 
351  if (isset($in_http_vars['long_val'])) {
352  $long = $in_http_vars['long_val'];
353  }
354 
355  if (isset($in_http_vars['lat_val'])) {
356  $lat = $in_http_vars['lat_val'];
357  }
358 
359  if (isset($in_http_vars['geo_width'])) {
360  $my_radius = $in_http_vars['geo_width'];
361  } elseif (isset($in_http_vars['geo_width_km'])) {
362  $my_radius = $in_http_vars['geo_width_km'];
363  }
364 
365  if (isset($my_radius) && ($my_radius < 0)) {
366  $my_radius = $search_manager->GetRadius($localized_strings['dist_units'] == 'mi');
367  }
368 
369  if (isset($return_geocode)) {
370  $return_geocode = nil;
371 
372  if ($search_manager->GetRadius(false)) {
373  $return_geocode['radius'] = $search_manager->GetRadius(false);
374  $return_geocode['longitude'] = $search_manager->GetLongitude();
375  $return_geocode['latitude'] = $search_manager->GetLatitude();
376  }
377  }
378 
379  $num_pages = $search_manager->GetNumberOfPages();
380  $num_results = $search_manager->GetNumberOfResults();
381 
382  $page_no = 1;
383 
384  if (isset($in_http_vars['page_num']) && (0 < intval($in_http_vars['page_num']))) {
385  $page_no = intval($in_http_vars['page_num']);
386  }
387 
388  if (1 > intval($page_no)) {
389  $page_no = 1;
390  }
391 
392  if ($page_no > $num_pages) {
393  $page_no = $num_pages;
394  }
395 
396  $page_data = $search_manager->GetPageOfResults($page_no);
397 
398  if ($page_data instanceof c_comdef_meeting_search_manager) {
400  // This is a required one for data export.
401  if (!in_array('meeting_name', $keys)) {
402  $keys[] = 'meeting_name';
403  }
404 
405  $keys[] = 'root_server_uri';
406  $keys[] = 'format_shared_id_list';
407 
408  $ret = '"'.join('","', $keys).'"';
409 
410  $formats = c_comdef_server::GetServer()->GetFormatsObj();
411  $formats_keys = array();
412  $formats_keys_header = array();
413 
414  $ret .= "\n";
415 
416  $in_ar = $page_data->GetSearchResultsAsArray();
417 
418  if (isset($return_results) && is_array($return_results)) {
419  $return_results = $in_ar;
420  }
421 
422  foreach ($in_ar as &$mtg_obj) {
423  $line = array();
424  $formats_ar = $formats_keys;
425 
426  if ($mtg_obj instanceof c_comdef_meeting) {
427  if (!$in_editor_only || $mtg_obj->UserCanObserve()) {
428  $format_shared_id_list = array();
429  $first = true;
430  foreach ($keys as $key) {
431  if (trim($key)) {
432  $val = $mtg_obj->GetMeetingDataValue($key);
433 
434  if (($key == 'meeting_name') && !$val) { // No meeting name results in a generic "NA Meeting" as the name.
435  $val = $localized_strings['comdef_server_admin_strings']['Value_Prompts']['generic'];
436  }
437 
438  if ($key == 'lang_enum' && isset($in_http_vars['lang_enum']) && $in_http_vars['lang_enum']) {
439  // Override the native lang_enum for the meeting with the requested language if present in http_vars
440  // (Does this ever matter??)
441  $val = $in_http_vars['lang_enum'];
442  }
443 
444  if (isset($val)) {
445  if (($key == 'formats')) {
446  if (is_array($val) && count($val)) {
447  $v_ar = array();
448  foreach ($val as $format) {
449  if ($format instanceof c_comdef_format) {
450  // $format will be one of the meeting's formats in the native server language. If it's already
451  // in the correct language, just add its key to $v_ar and its id to $format_shared_id_list.
452  // Otherwise see if there is a version of the format in the other language (stored in $lang_enum). If there is,
453  // push the key for the format in the other language onto $v_ar instead. Note that the key might be different
454  // in different languages. If there isn't a version of the format in the other language, just skip it.
455  $id = $format->GetSharedID();
456  if ($format->GetLocalLang() == $lang_enum) {
457  array_push($v_ar, $format->GetKey());
458  array_push($format_shared_id_list, $id);
459  } else {
460  $fs = $formats->GetFormatsBySharedIDCode($id);
461  if (array_key_exists($lang_enum, $fs)) {
462  $localized_format = $fs[$lang_enum];
463  array_push($v_ar, $localized_format->GetKey());
464  array_push($format_shared_id_list, $id);
465  }
466  }
467  }
468  }
469  $val = join(',', $v_ar);
470  $val = preg_replace('|"|', '\\"', preg_replace('|[\r\n\t]+|', ' ', $val));
471  } elseif (is_string($val)) {
472  $val = preg_replace('|"|', '\\"', preg_replace('|[\r\n\t]+|', ' ', $val));
473  }
474  }
475 
476  if (($key == 'formats') && $val) {
477  $f_list = explode(',', $val);
478 
479  if (is_array($f_list) && count($f_list)) {
480  foreach ($f_list as $format) {
481  $formats_ar[$format] = 1;
482  }
483  }
484  }
485 
486  if ($val) {
487  if ($mtg_obj->IsItemHidden($key)) {
488  if ($mtg_obj->UserCanObserve()) {
489  if (!$in_supress_hidden_concat && !isset($in_http_vars['simple_other_fields'])) {
490  $val = preg_replace('|.*?\#\@\-\@\#|', '', $mtg_obj->GetMeetingDataValue($key)); // Strip out any old accidentally introduced separators.
491  $val = 'observer_only#@-@#'.$mtg_obj->GetMeetingDataPrompt($key).'#@-@#'.$val;
492  }
493  } else {
494  $val = '';
495  }
496  } else {
497  switch ($key) {
498  // We don't do anything for the standard fields.
499  case 'distance_in_miles':
500  case 'distance_in_km':
501  case 'id_bigint':
502  case 'worldid_mixed':
503  case 'shared_group_id_bigint':
504  case 'service_body_bigint':
505  case 'weekday_tinyint':
506  case 'start_time':
507  case 'duration_time':
508  case 'time_zone':
509  case 'formats':
510  case 'lang_enum':
511  case 'longitude':
512  case 'latitude':
513  case 'published':
514  case 'email_contact':
515  case 'meeting_name':
516  case 'location_text':
517  case 'location_info':
518  case 'location_street':
519  case 'location_city_subsection':
520  case 'location_neighborhood':
521  case 'location_municipality':
522  case 'location_sub_province':
523  case 'location_province':
524  case 'location_postal_code_1':
525  case 'location_nation':
526  case 'comments':
527  case 'virtual_meeting_link':
528  case 'virtual_meeting_additional_info':
529  case 'phone_meeting_number':
530  break;
531 
532  // The rest get the prompt/value treatment, unless otherwise requested.
533  default:
534  if ($val && !isset($in_http_vars['simple_other_fields'])) {
535  $val = preg_replace('|.*?\#\@\-\@\#|', '', $val); // Strip out any old accidentally introduced separators.
536  $val = $mtg_obj->GetMeetingDataPrompt($key).'#@-@#'.$val;
537  }
538  break;
539  }
540  }
541  }
542  } else {
543  $val = '';
544  }
545 
546  $val = trim(preg_replace("|[\n\r]+|", "; ", $val));
547 
548  $line[$key] = $val;
549  }
550  }
551 
552  if (!isset($line['duration_time']) || !$line['duration_time'] || ($line['duration_time'] == '00:00:00')) {
553  $line['duration_time'] = $localized_strings['default_duration_time'];
554  }
555 
556  if (isset($format_shared_id_list) && is_array($format_shared_id_list) && count($format_shared_id_list)) {
557  sort($format_shared_id_list);
558  $line['format_shared_id_list'] = implode(',', $format_shared_id_list);
559  }
560 
561  $line['root_server_uri'] = dirname(dirname(GetURLToMainServerDirectory(true)));
562 
563  if (is_array($line) && count($line)) {
564  if (is_array($return_array)) {
565  array_push($return_array, $line);
566  }
567 
568  $ret .= '"'.join('","', $line).'"';
569 
570  $ret .= "\n";
571  }
572  }
573  }
574  }
575  }
576  }
577 
578  return $ret;
579 }
580 
581 /********************************************************************/
582 /* NAWS LIST GENERATION */
583 /* The following functions are used to generate a CSV file that is */
584 /* in a format suitable for NA World Services (NAWS). Because they */
585 /* often change their format, it needs to be extremely flexible. */
586 /* The heart is a "translator dictionary," that matches fields in a */
587 /* standard meeting object to the fields expected by NAWS. If the */
588 /* content of a dictionary entry is a function, then a translation */
589 /* is done by calling a function. Otherwise, if the content is a */
590 /* field name, the contents of that field are simply transferred */
591 /* without interpretation. */
592 /********************************************************************/
593 
594 /*******************************************************************/
595 /**
596  \brief Returns the CSV file in NAWS format
597 
598  \returns A string, consisting of a CSV file, in the format required by NAWS.
599 */
601  $in_http_vars, ///< The HTTP GET and POST parameters.
602  &$server ///< A reference to an instance of c_comdef_server
603 ) {
604  // This is a dictionary that is used to translate the meeting data from the BMLT format to the NAWS format.
605  $transfer_dictionary = array( 'Committee' => 'BMLT_FuncNAWSReturnMeetingNAWSID',
606  'CommitteeName' => 'meeting_name',
607  'AddDate' => null,
608  'AreaRegion' => 'BMLT_FuncNAWSReturnMeetingServiceBodyNAWSID',
609  'ParentName' => 'BMLT_FuncNAWSReturnMeetingServiceBodyName',
610  'ComemID' => null,
611  'ContactID' => null,
612  'ContactName' => null,
613  'CompanyName' => null,
614  'ContactAddrID' => null,
615  'ContactAddress1' => null,
616  'ContactAddress2' => null,
617  'ContactCity' => null,
618  'ContactState' => null,
619  'ContactZip' => null,
620  'ContactCountry' => null,
621  'ContactPhone' => null,
622  'MeetingID' => null,
623  'Room' => 'BMLT_FuncNAWSReturnNonNawsFormats',
624  'Closed' => 'BMLT_FuncNAWSReturnOpenOrClosed',
625  'WheelChr' => 'BMLT_FuncNAWSReturnWheelchair',
626  'Day' => 'BMLT_FuncNAWSReturnWeekday',
627  'Time' => 'BMLT_FuncNAWSReturnTime',
628  'Language1' => 'BMLT_FuncNAWSReturnLanguage1',
629  'Language2' => null,
630  'Language3' => null,
631  'LocationId' => null,
632  'Place' => 'location_text',
633  'Address' => 'location_street',
634  'City' => 'BMLT_FuncNAWSReturnMeetingTown',
635  'LocBorough' => 'location_neighborhood',
636  'State' => 'location_province',
637  'Zip' => 'location_postal_code_1',
638  'Country' => 'location_nation',
639  'Directions' => 'BMLT_FuncNAWSReturnDirections',
640  'Institutional' => 'BMLT_FuncNAWSReturnInst',
641  'Format1' => 'BMLT_FuncNAWSReturnFormat1',
642  'Format2' => 'BMLT_FuncNAWSReturnFormat2',
643  'Format3' => 'BMLT_FuncNAWSReturnFormat3',
644  'Format4' => 'BMLT_FuncNAWSReturnFormat4',
645  'Format5' => 'BMLT_FuncNAWSReturnFormat5',
646  'Delete' => null,
647  'LastChanged' => 'BMLT_FuncNAWSReturnLastMeetingChangeTime',
648  'Longitude' => 'longitude',
649  'Latitude' => 'latitude',
650  'ContactGP' => null,
651  'PhoneMeetingNumber' => 'phone_meeting_number',
652  'VirtualMeetingLink' => 'virtual_meeting_link',
653  'VirtualMeetingInfo' => 'virtual_meeting_additional_info',
654  'TimeZone' => 'time_zone',
655  'bmlt_id' => 'id_bigint',
656  'unpublished' => 'BMLT_FuncNAWSReturnPublishedStatus'
657  );
658 
659  $ret = null;
660 
661  if (!( isset($in_http_vars['geo_width']) && $in_http_vars['geo_width'] ) && isset($in_http_vars['bmlt_search_type']) && ($in_http_vars['bmlt_search_type'] == 'advanced') && isset($in_http_vars['advanced_radius']) && isset($in_http_vars['advanced_mapmode']) && $in_http_vars['advanced_mapmode'] && ( floatval($in_http_vars['advanced_radius'] != 0.0) ) && isset($in_http_vars['lat_val']) && isset($in_http_vars['long_val']) && ( (floatval($in_http_vars['lat_val']) != 0.0) || (floatval($in_http_vars['long_val']) != 0.0) )) {
662  $in_http_vars['geo_width'] = $in_http_vars['advanced_radius'];
663  } elseif (!( isset($in_http_vars['geo_width']) && $in_http_vars['geo_width'] ) && isset($in_http_vars['bmlt_search_type']) && ($in_http_vars['bmlt_search_type'] == 'advanced')) {
664  $in_http_vars['lat_val'] = null;
665  $in_http_vars['long_val'] = null;
666  } elseif (!isset($in_http_vars['geo_loc']) || $in_http_vars['geo_loc'] != 'yes') {
667  if (!isset($in_http_vars['geo_width'])) {
668  $in_http_vars['geo_width'] = 0;
669  }
670  }
671  $ret_array = array (); // If we supply an array as a second parameter, we will get the dump returned in a two-dimensional array.
672  DisplaySearchResultsCSV($in_http_vars, $ret_array); // Start off by getting the CSV dump in the same manner as the normal CSV dump.
673 
674  if (is_array($ret_array) && count($ret_array)) {
675  $ret = '"'.join('","', array_keys($transfer_dictionary)).'"'; // This is the header line.
676  foreach ($ret_array as $one_meeting) {
677  if (is_array($one_meeting) && count($one_meeting)) {
678  $line = array();
679  foreach ($transfer_dictionary as $key => $value) {
680  // See if this is a function.
681  if (function_exists($value) && is_callable($value) && preg_match('|^BMLT_FuncNAWSReturn|', $value)) {
682  $value = $value($one_meeting['id_bigint'], $server);
683  } elseif (isset($one_meeting[$value])) { // See if we just transfer the value with no change.
684  $value = $one_meeting[$value];
685  }
686  array_push($line, $value);
687  }
688 
689  if (is_array($line) && count($line)) {
690  $ret .= "\n".'"'.join('","', $line).'"';
691  }
692  }
693  }
694  }
695 
696  $del_meetings = ReturnNAWSDeletedMeetings($server, $transfer_dictionary, $in_http_vars['services']); // We append deleted meetings to the end.
697 
698  if (is_array($del_meetings) && count($del_meetings)) {
699  foreach ($del_meetings as $one_meeting) {
700  if (is_array($one_meeting) && count($one_meeting)) {
701  $ret .= "\n".'"'.join('","', $one_meeting).'"';
702  }
703  }
704  }
705 
706  return $ret;
707 }
708 
709 /*******************************************************************/
710 /**
711  \brief Returns deleted meetings with NAWS IDs.
712 
713  \description This queries every deleted meeting. The meetings returned are
714  not restricted to the search parameters, and may repeat from previous dumps.
715  Only meetings that had World IDs are returned.
716 
717  \returns An array of World IDs and change dates. These each represent deleted meetings.
718 */
720  &$server, ///< A reference to an instance of c_comdef_server
721  $in_transfer_dictionary, ///< The transfer dictionary
722  $in_services ///< Any Service body IDs
723 ) {
724  $ret = null;
725 
726  // We start by getting all the meetings that have been deleted (Could be quite a few).
727  $changes = $server->GetChangesFromOTypeAndCType('c_comdef_meeting', 'comdef_change_type_delete');
728 
729  if ($changes instanceof c_comdef_changes) {
730  $ret = array();
731  $c_array = $changes->GetChangesObjects();
732 
733  if (is_array($c_array) && count($c_array)) {
734  foreach ($c_array as &$change) {
735  $b_obj = $change->GetBeforeObject();
736  if ($b_obj instanceof c_comdef_meeting) {
737  $line = null;
738  if (!$server->GetOneMeeting($b_obj->GetID())) { // Must be currently deleted.
739  if (is_array($in_services) && count($in_services)) {
740  $found = false;
741  reset($in_services);
742  foreach ($in_services as $sb_id) {
743  if (!$found) {
744  if (intval($b_obj->GetServiceBodyID()) == intval($sb_id)) {
745  $found = true;
746  }
747  }
748  }
749  }
750 
751  $value = intval(preg_replace('|\D*?|', '', $b_obj->GetMeetingDataValue('worldid_mixed')));
752 
753  if ($value && $found) {
754  foreach ($in_transfer_dictionary as $key => $value2) {
755  if (($key != 'Delete')) {
756  $value1 = null;
757  // See if this is a function.
758  if (function_exists($value2) && is_callable($value2) && preg_match('|^BMLT_FuncNAWSReturn|', $value2)) {
759  if ($value2 == 'BMLT_FuncNAWSReturnLastMeetingChangeTime') {
760  $value1 = date('n/j/y', $change->GetChangeDate());
761  } else {
762  $value1 = $value2($b_obj, $server);
763  }
764  } else // See if we just transfer the value with no change.
765  {
766  $value1 = $b_obj->GetMeetingDataValue($value2);
767  }
768  } else {
769  $value1 = 'D';
770  }
771 
772  $line[$key] = $value1;
773  }
774  }
775  }
776 
777  array_push($ret, $line);
778  }
779  }
780  }
781  }
782  return $ret;
783 }
784 
785 /*******************************************************************/
786 /**
787  \brief Returns '' or '1', if the meeting is unpublished or not (used for the NAWS format)
788 
789  \returns A string, '' or '1'.
790 */
792  $in_meeting_id, ///< The ID of the meeting (internal DB ID). This can also be a meeting object.
793  &$server ///< A reference to an instance of c_comdef_server
794 ) {
795  $ret = '';
796 
797  if ($in_meeting_id instanceof c_comdef_meeting) {
798  $the_meeting = $in_meeting_id;
799  } else {
800  $the_meeting = $server->GetOneMeeting($in_meeting_id);
801  }
802 
803  if ($the_meeting instanceof c_comdef_meeting) {
804  $ret = $the_meeting->IsPublished() ? '' : '1';
805  }
806 
807  return $ret;
808 }
809 
810 /*******************************************************************/
811 /**
812  \brief Returns 'OPEN' or 'CLOSED', if the meeting is open or closed (used for the NAWS format)
813 
814  \returns A string, 'OPEN' or 'CLOSED'.
815 */
817  $in_meeting_id, ///< The ID of the meeting (internal DB ID). This can also be a meeting object.
818  &$server ///< A reference to an instance of c_comdef_server
819 ) {
820  global $g_format_dictionary;
821 
822  $localized_strings = c_comdef_server::GetLocalStrings();
823 
824  $ret = $localized_strings['default_closed_status'] ? 'CLOSED' : 'OPEN'; // This is the default closed/open status.
825  $opposite = $localized_strings['default_closed_status'] ? 'OPEN' : 'CLOSED';
826 
827  if ($in_meeting_id instanceof c_comdef_meeting) {
828  $the_meeting = $in_meeting_id;
829  } else {
830  $the_meeting = $server->GetOneMeeting($in_meeting_id);
831  }
832 
833  $ids = $g_format_dictionary[$opposite];
834 
835  if ($the_meeting instanceof c_comdef_meeting) {
836  $formats = $the_meeting->GetMeetingDataValue('formats');
837 
838  if (is_array($formats) && count($formats) && is_array($ids)) {
839  foreach ($ids as $id) {
840  if (isset($formats[$id])) {
841  $ret = $opposite;
842  break;
843  }
844  }
845  }
846  }
847 
848  return $ret;
849 }
850 
851 /*******************************************************************/
852 /**
853  \brief Returns 'TRUE' or 'FALSE', if the meeting is or is not wheelchair-accessible (used for the NAWS format)
854 
855  \returns A string, 'TRUE' or 'FALSE'.
856 */
858  $in_meeting_id, ///< The ID of the meeting (internal DB ID) This can also be a meeting object.
859  &$server ///< A reference to an instance of c_comdef_server
860 ) {
861  global $g_format_dictionary;
862 
863  $ret = 'FALSE';
864 
865  if ($in_meeting_id instanceof c_comdef_meeting) {
866  $the_meeting = $in_meeting_id;
867  } else {
868  $the_meeting = $server->GetOneMeeting($in_meeting_id);
869  }
870 
871  $ids = $g_format_dictionary['WCHR'];
872 
873  if ($the_meeting instanceof c_comdef_meeting) {
874  $formats = $the_meeting->GetMeetingDataValue('formats');
875 
876  if (is_array($formats) && count($formats) && is_array($ids)) {
877  foreach ($ids as $id) {
878  if (isset($formats[$id])) {
879  $ret = 'TRUE';
880  break;
881  }
882  }
883  }
884  }
885 
886  return $ret;
887 }
888 
889 /*******************************************************************/
890 /**
891  \brief Returns 'TRUE' or 'FALSE', if the meeting is or is not an institution meeting (used for the NAWS format)
892 
893  \returns A string, 'TRUE' or 'FALSE' (It will always be FALSE).
894 */
896  $in_meeting_id, ///< The ID of the meeting (internal DB ID) This can also be a meeting object.
897  &$server ///< A reference to an instance of c_comdef_server
898 ) {
899  $ret = 'FALSE';
900 
901  return $ret;
902 }
903 
904 /*******************************************************************/
905 /**
906  \brief Returns the string for the weekday the meeting gathers (used for the NAWS format)
907 
908  \returns A string ('Monday' - 'Friday').
909 */
911  $in_meeting_id, ///< The ID of the meeting (internal DB ID) This can also be a meeting object.
912  &$server ///< A reference to an instance of c_comdef_server
913 ) {
914  $ret = null;
915 
916  $weekdays = array ( null, 'Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday' );
917 
918  if ($in_meeting_id instanceof c_comdef_meeting) {
919  $the_meeting = $in_meeting_id;
920  } else {
921  $the_meeting = $server->GetOneMeeting($in_meeting_id);
922  }
923 
924  if ($the_meeting instanceof c_comdef_meeting) {
925  $ret = $weekdays[$the_meeting->GetMeetingDataValue('weekday_tinyint')];
926  }
927 
928  return $ret;
929 }
930 
931 /*******************************************************************/
932 /**
933  \brief Returns the string for the weekday the meeting gathers (used for the NAWS format)
934 
935  \returns A string (the time, in pure military time - no seconds).
936 */
938  $in_meeting_id, ///< The ID of the meeting (internal DB ID) This can also be a meeting object.
939  &$server ///< A reference to an instance of c_comdef_server
940 ) {
941  $ret = null;
942 
943  if ($in_meeting_id instanceof c_comdef_meeting) {
944  $the_meeting = $in_meeting_id;
945  } else {
946  $the_meeting = $server->GetOneMeeting($in_meeting_id);
947  }
948 
949  if ($the_meeting instanceof c_comdef_meeting) {
950  $ret = explode(':', $the_meeting->GetMeetingDataValue('start_time'));
951  if (is_array($ret) && count($ret) > 1) {
952  $ret = $ret[0].$ret[1];
953  }
954  }
955 
956  return $ret;
957 }
958 
959 /*******************************************************************/
960 /**
961  \brief Returns the string for the first alternative language (if any)
962 
963  \returns A string.
964 */
966  $in_meeting_id, ///< The ID of the meeting (internal DB ID) This can also be a meeting object.
967  &$server ///< A reference to an instance of c_comdef_server
968 ) {
969  $ret = '';
970 
971  if ($in_meeting_id instanceof c_comdef_meeting) {
972  $the_meeting = $in_meeting_id;
973  } else {
974  $the_meeting = $server->GetOneMeeting($in_meeting_id);
975  }
976 
977  if ($the_meeting instanceof c_comdef_meeting) {
978  $formats = $the_meeting->GetMeetingDataValue('formats');
979  $lang = $server->GetLocalLang();
980 
981  if (is_array($formats) && count($formats)) {
982  foreach ($formats as $format) {
983  if ($format instanceof c_comdef_format) {
984  if ('LANG' == $format->GetWorldID()) {
985  $ret = strtoupper(trim($format->GetKey()));
986  break;
987  }
988  }
989  }
990  }
991  }
992 
993  return $ret;
994 }
995 
996 /*******************************************************************/
997 /**
998  \brief Returns the string for the NAWS ID for the meeting (used for the NAWS format)
999 
1000  \returns A string The meeting ID, in NAWS form (G0000000).
1001 */
1003  $in_meeting_id, ///< The ID of the meeting (internal DB ID) This can also be a meeting object.
1004  &$server ///< A reference to an instance of c_comdef_server
1005 ) {
1006  $ret = null;
1007  if ($in_meeting_id instanceof c_comdef_meeting) {
1008  $the_meeting = $in_meeting_id;
1009  } else {
1010  $the_meeting = $server->GetOneMeeting($in_meeting_id);
1011  }
1012 
1013  if ($the_meeting instanceof c_comdef_meeting) {
1014  $ret = trim($the_meeting->GetMeetingDataValue('worldid_mixed'));
1015  }
1016 
1017  return $ret;
1018 }
1019 
1020 /*******************************************************************/
1021 /**
1022  \brief Returns the string for the town field the meeting (used for the NAWS format). This may use the borough name, instead.
1023 
1024  \returns A string The meeting town.
1025 */
1027  $in_meeting_id, ///< The ID of the meeting (internal DB ID) This can also be a meeting object.
1028  &$server ///< A reference to an instance of c_comdef_server
1029 ) {
1030  $ret = null;
1031  if ($in_meeting_id instanceof c_comdef_meeting) {
1032  $the_meeting = $in_meeting_id;
1033  } else {
1034  $the_meeting = $server->GetOneMeeting($in_meeting_id);
1035  }
1036 
1037  if ($the_meeting instanceof c_comdef_meeting) {
1038  // Our first choice is the borough/ku.
1039  $ret = trim($the_meeting->GetMeetingDataValue('location_city_subsection'));
1040 
1041  if (!$ret) {
1042  $ret = trim($the_meeting->GetMeetingDataValue('location_municipality'));
1043  }
1044 
1045  // If all else fails, we use the neighborhood.
1046  if (!$ret) {
1047  $ret = trim($the_meeting->GetMeetingDataValue('location_neighborhood'));
1048  }
1049  }
1050 
1051  return $ret;
1052 }
1053 
1054 /*******************************************************************/
1055 /**
1056  \brief Returns the latest changed date for the given meeting.
1057 
1058  \returns a date in ISO form ('2013-01-31').
1059 */
1061  $in_meeting_id, ///< The ID of the meeting (internal DB ID) This can also be a meeting object.
1062  &$server ///< A reference to an instance of c_comdef_server
1063 ) {
1064  $ret = null;
1065 
1066  $changes_obj = $server->GetChangesFromIDAndType('c_comdef_meeting', $in_meeting_id);
1067 
1068  if ($changes_obj instanceof c_comdef_changes) {
1069  $changes_objects = $changes_obj->GetChangesObjects();
1070 
1071  if (is_array($changes_objects) && count($changes_objects)) {
1072  $last_date = 0;
1073  foreach ($changes_objects as $change) {
1074  $last_date = max($last_date, $change->GetChangeDate());
1075  }
1076 
1077  if ($last_date) {
1078  $ret = date('n/j/y', $last_date);
1079  }
1080  }
1081  }
1082 
1083  return $ret;
1084 }
1085 
1086 /*******************************************************************/
1087 /**
1088  \brief Returns the string for the NAWS ID for the meeting's Service Body (used for the NAWS format)
1089 
1090  \returns A string The Service Body ID, in NAWS form (RG/AR0000000).
1091 */
1093  $in_meeting_id, ///< The ID of the meeting (internal DB ID) This can also be a meeting object.
1094  &$server ///< A reference to an instance of c_comdef_server
1095 ) {
1096  $ret = null;
1097 
1098  if ($in_meeting_id instanceof c_comdef_meeting) {
1099  $the_meeting = $in_meeting_id;
1100  } else {
1101  $the_meeting = $server->GetOneMeeting($in_meeting_id);
1102  }
1103 
1104  if ($the_meeting instanceof c_comdef_meeting) {
1105  $service_body = $the_meeting->GetServiceBodyObj();
1106 
1107  $ret2 = intval(preg_replace('|\D*?|', '', trim($service_body->GetWorldID())));
1108 
1109  if ($service_body instanceof c_comdef_service_body) {
1110  if ($service_body->GetSBType() == c_comdef_service_body__ASC__) {
1111  if ($ret2) {
1112  $ret = sprintf('AR%05d', $ret2);
1113  }
1114  } elseif ($service_body->GetSBType() == c_comdef_service_body__RSC__) {
1115  if ($ret2) {
1116  $ret = sprintf('RG%03d', $ret2);
1117  }
1118  }
1119  }
1120  }
1121 
1122  return $ret;
1123 }
1124 
1125 /*******************************************************************/
1126 /**
1127 \brief Returns a string of all formats that don't map to NAWS codes.
1128 
1129 \returns A string The format codes name_string.
1130  */
1132  $in_meeting_id, ///< The ID of the meeting (internal DB ID) This can also be a meeting object.
1133  &$server ///< A reference to an instance of c_comdef_server
1134 ) {
1135 
1136  $ret = "";
1137 
1138  if ($in_meeting_id instanceof c_comdef_meeting) {
1139  $the_meeting = $in_meeting_id;
1140  } else {
1141  $the_meeting = $server->GetOneMeeting($in_meeting_id);
1142  }
1143 
1144  if ($the_meeting instanceof c_comdef_meeting) {
1145  $formats = $the_meeting->GetMeetingDataValue('formats');
1146 
1147  if (is_array($formats) && count($formats)) {
1148  foreach ($formats as $format) {
1149  if ($format != null && !$format->GetWorldID()) {
1150  $ret .= $format->GetLocalName();
1151  $ret .= ',';
1152  }
1153  }
1154 
1155  $ret = rtrim($ret, ',');
1156  }
1157  }
1158 
1159  return $ret;
1160 }
1161 
1162 /*******************************************************************/
1163 /**
1164 \brief Returns a string of location_info and comments fields.
1165 
1166 \returns A string The location_info and comments fields.
1167  */
1169  $in_meeting_id, ///< The ID of the meeting (internal DB ID) This can also be a meeting object.
1170  &$server ///< A reference to an instance of c_comdef_server
1171 ) {
1172 
1173  $ret = "";
1174 
1175  if ($in_meeting_id instanceof c_comdef_meeting) {
1176  $the_meeting = $in_meeting_id;
1177  } else {
1178  $the_meeting = $server->GetOneMeeting($in_meeting_id);
1179  }
1180 
1181  if ($the_meeting instanceof c_comdef_meeting) {
1182  $ret = trim($the_meeting->GetMeetingDataValue('location_info'));
1183 
1184  if ($the_meeting->GetMeetingDataValue('comments')) {
1185  if ($ret) {
1186  $ret .= ", ";
1187  }
1188  $ret .= trim($the_meeting->GetMeetingDataValue('comments'));
1189  }
1190  }
1191 
1192  return $ret;
1193 }
1194 
1195 /*******************************************************************/
1196 /**
1197  \brief Returns the string for the first format (used for the NAWS format)
1198 
1199  \returns A string The format code, in NAWS form.
1200 */
1202  $in_meeting_id, ///< The ID of the meeting (internal DB ID) This can also be a meeting object.
1203  &$server ///< A reference to an instance of c_comdef_server
1204 ) {
1205  return BMLT_FuncNAWSReturnFormat(1, $in_meeting_id, $server);
1206 }
1207 
1208 /*******************************************************************/
1209 /**
1210  \brief Returns the string for the second format (used for the NAWS format)
1211 
1212  \returns A string The format code, in NAWS form.
1213 */
1215  $in_meeting_id, ///< The ID of the meeting (internal DB ID) This can also be a meeting object.
1216  &$server ///< A reference to an instance of c_comdef_server
1217 ) {
1218  return BMLT_FuncNAWSReturnFormat(2, $in_meeting_id, $server);
1219 }
1220 
1221 /*******************************************************************/
1222 /**
1223  \brief Returns the string for the third format (used for the NAWS format)
1224 
1225  \returns A string The format code, in NAWS form.
1226 */
1228  $in_meeting_id, ///< The ID of the meeting (internal DB ID) This can also be a meeting object.
1229  &$server ///< A reference to an instance of c_comdef_server
1230 ) {
1231  return BMLT_FuncNAWSReturnFormat(3, $in_meeting_id, $server);
1232 }
1233 
1234 /*******************************************************************/
1235 /**
1236  \brief Returns the string for the fourth format (used for the NAWS format)
1237 
1238  \returns A string The format code, in NAWS form.
1239 */
1241  $in_meeting_id, ///< The ID of the meeting (internal DB ID) This can also be a meeting object.
1242  &$server ///< A reference to an instance of c_comdef_server
1243 ) {
1244  return BMLT_FuncNAWSReturnFormat(4, $in_meeting_id, $server);
1245 }
1246 
1247 /*******************************************************************/
1248 /**
1249  \brief Returns the string for the fifth format (used for the NAWS format)
1250 
1251  \returns A string The format code, in NAWS form.
1252 */
1254  $in_meeting_id, ///< The ID of the meeting (internal DB ID) This can also be a meeting object.
1255  &$server ///< A reference to an instance of c_comdef_server
1256 ) {
1257  return BMLT_FuncNAWSReturnFormat(5, $in_meeting_id, $server);
1258 }
1259 
1260 /*******************************************************************/
1261 /**
1262  \brief Returns the string for the n-th format (used for the NAWS format)
1263 
1264  \returns A string The format code, in NAWS form.
1265  */
1267  $n, ///< which format
1268  $in_meeting_id, ///< The ID of the meeting (internal DB ID) This can also be a meeting object.
1269  &$server ///< A reference to an instance of c_comdef_server
1270 ) {
1271  global $g_format_dictionary;
1272  if ($in_meeting_id instanceof c_comdef_meeting) {
1273  $the_meeting = $in_meeting_id;
1274  } else {
1275  $the_meeting = $server->GetOneMeeting($in_meeting_id);
1276  }
1277  if ($the_meeting instanceof c_comdef_meeting) {
1278  // $formats is an array of the formats for this meeting as they are stored in the BMLT database.
1279  // $naws_formats is an array of the NAWS versions of these formats - note that not everything in $formats
1280  // will have a corresponding NAWS versions. Also there can also be several BMLT formats that map
1281  // to the same NAWS format -- in this case, only include one NAWS format.
1282  // This function is a bit stupid, since it gets called up to 5 times for the 5 possible NAWS formats --
1283  // more aesthetic (and slightly more efficient) would be to just call it once. However, efficiency is not
1284  // terribly important here since this just gets called when producing an export spreadsheet.
1285  $formats = $the_meeting->GetMeetingDataValue('formats');
1286  $naws_formats = [];
1287  if (is_array($formats) && count($formats)) {
1288  foreach ($g_format_dictionary as $n_format => $b_formats) {
1289  if (($n_format != 'OPEN') && ($n_format != 'CLOSED') && ($n_format != 'WCHR')) {
1290  foreach ($b_formats as $b_format) {
1291  if (isset($formats[$b_format]) && !in_array($n_format, $naws_formats)) {
1292  array_push($naws_formats, $n_format);
1293  }
1294  }
1295  }
1296  }
1297  }
1298  if ($n > count($naws_formats)) {
1299  return null;
1300  } else {
1301  return $naws_formats[$n-1];
1302  }
1303  }
1304 }
1305 
1306 /*******************************************************************/
1307 /**
1308  \brief Returns the string for the name for the meeting's Service Body (used for the NAWS format)
1309 
1310  \returns A string The Service Body name.
1311 */
1313  $in_meeting_id, ///< The ID of the meeting (internal DB ID) This can also be a meeting object.
1314  &$server ///< A reference to an instance of c_comdef_server
1315 ) {
1316  $ret = null;
1317 
1318  if ($in_meeting_id instanceof c_comdef_meeting) {
1319  $the_meeting = $in_meeting_id;
1320  } else {
1321  $the_meeting = $server->GetOneMeeting($in_meeting_id);
1322  }
1323 
1324  if ($the_meeting instanceof c_comdef_meeting) {
1325  $service_body = $the_meeting->GetServiceBodyObj();
1326 
1327  while (!$ret && ($service_body instanceof c_comdef_service_body)) {
1328  if (($service_body->GetSBType() == c_comdef_service_body__ASC__) || ($service_body->GetSBType() == c_comdef_service_body__RSC__)) {
1329  $ret = $service_body->GetLocalName();
1330  } else {
1331  $service_body = $service_body->GetOwnerIDObject();
1332  }
1333  }
1334  }
1335 
1336  return $ret;
1337 }
static GetLocalStrings($in_lang_enum=null)
This gets the appropriate language files, and puts all the the strings into an associative array...
BMLT_FuncNAWSReturnWeekday($in_meeting_id, &$server)
Returns the string for the weekday the meeting gathers (used for the NAWS format) ...
SetUpSearch(&$in_search_manager, &$in_http_vars)
This function sets up the search manager to do the specified search. It does not actually do the sear...
A Class for Service Body Objects.
BMLT_FuncNAWSReturnInst($in_meeting_id, &$server)
Returns &#39;TRUE&#39; or &#39;FALSE&#39;, if the meeting is or is not an institution meeting (used for the NAWS form...
A class to hold a single meeting object.
if($handler instanceof c_comdef_admin_ajax_handler)
$local_strings
Definition: index.php:6
BMLT_FuncNAWSReturnMeetingNAWSID($in_meeting_id, &$server)
Returns the string for the NAWS ID for the meeting (used for the NAWS format)
global $g_format_dictionary
This is a dictionary used to translate formats to NAWS format. It uses the format shared IDs in the s...
BMLT_FuncNAWSReturnFormat5($in_meeting_id, &$server)
Returns the string for the fifth format (used for the NAWS format)
static GetAllMeetingKeys()
Returns an array of strings, containing the keys (table columns) used for all meetings (specified in ...
$ret
Definition: contact.php:226
function sprintf()
Definition: installer.js:873
BMLT_FuncNAWSReturnMeetingTown($in_meeting_id, &$server)
Returns the string for the town field the meeting (used for the NAWS format). This may use the boroug...
BMLT_FuncNAWSReturnPublishedStatus($in_meeting_id, &$server)
Returns &#39;&#39; or &#39;1&#39;, if the meeting is unpublished or not (used for the NAWS format) ...
ReturnNAWSFormatCSV($in_http_vars, &$server)
Returns the CSV file in NAWS format.
BMLT_FuncNAWSReturnLanguage1($in_meeting_id, &$server)
Returns the string for the first alternative language (if any)
if(!isset($g_format_dictionary)||!is_array($g_format_dictionary)||!count($g_format_dictionary)) bmlt_populate_format_dictionary()
This reads in the server format codes, and populates the format dictionary with the NAWS IDs...
A Class for Format Codes.
const c_comdef_service_body__RSC__
BMLT_FuncNAWSReturnLastMeetingChangeTime($in_meeting_id, &$server)
Returns the latest changed date for the given meeting.
$lang_enum
Definition: index.php:23
BMLT_FuncNAWSReturnFormat4($in_meeting_id, &$server)
Returns the string for the fourth format (used for the NAWS format)
BMLT_FuncNAWSReturnOpenOrClosed($in_meeting_id, &$server)
Returns &#39;OPEN&#39; or &#39;CLOSED&#39;, if the meeting is open or closed (used for the NAWS format) ...
const c_comdef_service_body__ASC__
BMLT_FuncNAWSReturnFormat3($in_meeting_id, &$server)
Returns the string for the third format (used for the NAWS format)
BMLT_FuncNAWSReturnDirections($in_meeting_id, &$server)
Returns a string of location_info and comments fields.
BMLT_FuncNAWSReturnFormat2($in_meeting_id, &$server)
Returns the string for the second format (used for the NAWS format)
BMLT_FuncNAWSReturnFormat1($in_meeting_id, &$server)
Returns the string for the first format (used for the NAWS format)
BMLT_FuncNAWSReturnNonNawsFormats($in_meeting_id, &$server)
Returns a string of all formats that don&#39;t map to NAWS codes.
$server
Definition: GetLangs.php:25
A class to hold a collection of c_comdef_change objects.
GetURLToMainServerDirectory($inAllowHTTPS=true)
Returns a URL (HTTP) to the main_server directory (or renamed).
DisplaySearchResultsCSV($in_http_vars, &$return_array=null, &$return_geocode=null, &$return_results=null, $in_supress_hidden_concat=false, $in_editor_only=false)
This function does a search, then builds a CSV result, with each row being a meeting. The first row is a row of keys.
static MakeServer()
This is the factory for the server instantiation. It makes sure that only one instance exists...
BMLT_FuncNAWSReturnTime($in_meeting_id, &$server)
Returns the string for the weekday the meeting gathers (used for the NAWS format) ...
defined('BMLT_EXEC') or define('BMLT_EXEC'
Definition: index.php:3
BMLT_FuncNAWSReturnFormat($n, $in_meeting_id, &$server)
Returns the string for the n-th format (used for the NAWS format)
ReturnNAWSDeletedMeetings(&$server, $in_transfer_dictionary, $in_services)
Returns deleted meetings with NAWS IDs.
BMLT_FuncNAWSReturnMeetingServiceBodyNAWSID($in_meeting_id, &$server)
Returns the string for the NAWS ID for the meeting&#39;s Service Body (used for the NAWS format) ...
A class to control the basic common functionality of all meeting searches.
BMLT_FuncNAWSReturnMeetingServiceBodyName($in_meeting_id, &$server)
Returns the string for the name for the meeting&#39;s Service Body (used for the NAWS format) ...
BMLT_FuncNAWSReturnWheelchair($in_meeting_id, &$server)
Returns &#39;TRUE&#39; or &#39;FALSE&#39;, if the meeting is or is not wheelchair-accessible (used for the NAWS forma...