geo_calendar.rb 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. # Copyright (C) 2012-2022 Zammad Foundation, https://zammad-foundation.org/
  2. module Service
  3. class GeoCalendar
  4. include ApplicationLib
  5. =begin
  6. lookup calendar based on ip or hostname
  7. result = Service::GeoCalendar.location( '99.99.99.99' )
  8. lookup calendar based on own system ip
  9. result = Service::GeoCalendar.location
  10. returns
  11. result = {
  12. "name" => 'Country Name',
  13. "timezone" => 'time zone of ip',
  14. "business_hours" => {
  15. "mon" => {
  16. "active" => true,
  17. "timeframes" => [["09:00","17:00"]]
  18. },
  19. "tue" => {
  20. "active" => true,
  21. "timeframes" => [["09:00","17:00"]]
  22. },
  23. "wed":{
  24. "active" => true,
  25. "timeframes" => [["09:00","17:00"]]
  26. },
  27. "thu":{
  28. "active" => true,
  29. "timeframes" => [["09:00","17:00"]]
  30. },
  31. "fri":{
  32. "active" => true,
  33. "timeframes" => [["09:00","17:00"]]
  34. },
  35. "sat":{
  36. "active" => false,
  37. "timeframes" => [["09:00","17:00"]]
  38. },
  39. "sun":{
  40. "active" => false,
  41. "timeframes" => [["09:00","17:00"]]
  42. }
  43. },
  44. "ical_url" => "",
  45. }
  46. =end
  47. def self.location(address = nil)
  48. # load backend
  49. backend = load_adapter_by_setting('geo_calendar_backend')
  50. return if !backend
  51. # db lookup
  52. backend.location(address)
  53. end
  54. end
  55. end