liquid_feedback_frontend

view app/main/index/index.lua @ 1595:ec0d69b4bb20

Return 404 for invalid areas
author bsw
date Sun Jan 31 20:34:37 2021 +0100 (2021-01-31)
parents 2a0d86117d54
children 6b203b43bef3
line source
1 if not app.session:has_access("anonymous") then
2 slot.put("<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Closed user group, please login.<br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br />")
3 return
4 end
6 local unit_id = request.get_param{ name = "unit" }
7 local area_id = request.get_param{ name = "area" }
9 if unit_id == "all" then
10 unit_id = nil
11 end
13 if area_id == "all" then
14 area_id = nil
15 end
17 local unit
18 local area
20 if unit_id then
21 unit = Unit:by_id(unit_id)
22 if not unit or unit.attr.hidden then
23 execute.view { module = "index", view = "404" }
24 request.set_status("404 Not Found")
25 return
26 end
27 end
29 if area_id then
30 area = Area:by_id(area_id)
31 if not area or area.unit_id ~= unit.id then
32 execute.view { module = "index", view = "404" }
33 request.set_status("404 Not Found")
34 return
35 end
36 end
38 ui.grid{ content = function()
39 ui.cell_main{ content = function()
41 execute.view{ module = "index", view = "_sidebar_motd_public" }
43 execute.view{ module = "issue", view = "_list" }
44 end }
46 ui.cell_sidebar{ content = function()
47 execute.view{ module = "index", view = "_sidebar_motd" }
48 if app.session.member then
49 execute.view{ module = "index", view = "_sidebar_notifications" }
50 end
51 if config.firstlife then
52 ui.container{ attr = { class = "map mdl-special-card mdl-shadow--2dp pos-before-main" }, content = function()
53 ui.tag{ tag = "iframe", attr = { src = config.firstlife.areaviewer_url .. "?" .. config.firstlife.coordinates .. "&domain=" .. request.get_absolute_baseurl(), class = "map" }, content = "" }
54 end }
55 end
56 if config.map then
57 local initiatives = Initiative:new_selector():exec()
58 local geo_objects = {}
59 for i, initiative in ipairs(initiatives) do
60 if initiative.location and initiative.location.coordinates then
61 local geo_object = {
62 lon = initiative.location.coordinates[1],
63 lat = initiative.location.coordinates[2],
64 label = "i" .. initiative.id,
65 description = slot.use_temporary(function()
66 ui.link{ module = "initiative", view = "show", id = initiative.id, text = initiative.display_name }
67 end),
68 type = "initiative"
69 }
70 table.insert(geo_objects, geo_object)
71 end
72 end
73 if ontomap_get_instances then
74 local instances = ontomap_get_instances()
75 for i, instance in ipairs(instances) do
76 table.insert(geo_objects, instance)
77 end
78 end
79 ui.container{ attr = { class = "map mdl-special-card mdl-shadow--2dp pos-before-main" }, content = function()
80 ui.map(geo_objects)
81 end }
82 end
83 if config.logo then
84 config.logo()
85 end
86 if area then
87 execute.view{ module = "area", view = "_sidebar_whatcanido", params = { area = area } }
88 elseif unit then
89 execute.view{ module = "unit", view = "_sidebar_whatcanido", params = { unit = unit } }
90 else
91 execute.view{ module = "index", view = "_sidebar_whatcanido" }
92 end
94 execute.view { module = "index", view = "_sidebar_members" }
96 end }
97 end }

Impressum / About Us