# HG changeset patch # User bsw # Date 1341575900 -7200 # Node ID ea2449916c125baebb0dc69603800a002403ff2f # Parent e12f0348b19176d8859c6b20bc91f48f648f0eb9 Cleaned up public access levels diff -r e12f0348b191 -r ea2449916c12 app/main/_filter/21_auth.lua --- a/app/main/_filter/21_auth.lua Fri Jul 06 13:34:02 2012 +0200 +++ b/app/main/_filter/21_auth.lua Fri Jul 06 13:58:20 2012 +0200 @@ -20,7 +20,7 @@ ) ) -if config.public_access then +if app.session:has_access("anonymous") then if module == "area" and view == "show" @@ -41,7 +41,7 @@ end -if config.public_access == "full" then +if app.session:has_access("all_pseudonymous") then if module == "member_image" and view == "show" or module == "vote" and view == "show_incoming" or module == "interest" and view == "show_incoming" @@ -50,11 +50,17 @@ end end +if app.session:has_access("everything") then + if module == "member" and (view == "show" or view == "history") then + auth_needed = false + end +end + if module == "sitemap" then auth_needed = false end -if config.public_access and not app.session.member_id and auth_needed and module == "index" and view == "index" then +if app.session:has_access("anonymous") and not app.session.member_id and auth_needed and module == "index" and view == "index" then if config.single_unit_id then request.redirect{ module = "unit", view = "show", id = config.single_unit_id } else diff -r e12f0348b191 -r ea2449916c12 app/main/_filter_view/30_navigation.lua --- a/app/main/_filter_view/30_navigation.lua Fri Jul 06 13:34:02 2012 +0200 +++ b/app/main/_filter_view/30_navigation.lua Fri Jul 06 13:58:20 2012 +0200 @@ -9,25 +9,28 @@ module = 'index', view = 'index' } - ui.link{ - content = _"Search", - module = 'index', - view = 'search' - } + + if app.session:has_access("anonymous") then - - - if config.public_access and app.session.member == nil then ui.link{ - text = _"Login", + content = _"Search", module = 'index', - view = 'login', - params = { - redirect_module = request.get_module(), - redirect_view = request.get_view(), - redirect_id = param.get_id() + view = 'search' + } + + if app.session.member == nil then + ui.link{ + text = _"Login", + module = 'index', + view = 'login', + params = { + redirect_module = request.get_module(), + redirect_view = request.get_view(), + redirect_id = param.get_id() + } } - } + end + end if app.session.member == nil then diff -r e12f0348b191 -r ea2449916c12 app/main/event/_list.lua --- a/app/main/event/_list.lua Fri Jul 06 13:34:02 2012 +0200 +++ b/app/main/event/_list.lua Fri Jul 06 13:58:20 2012 +0200 @@ -96,7 +96,7 @@ slot.put(")") end --]] - if (app.session.member_id or config.public_access == "pseudonym") and event.member_id then + if app.session:has_access("authors_pseudonymous") and event.member_id then slot.put("
") slot.put("
") if app.session.member_id then diff -r e12f0348b191 -r ea2449916c12 app/main/index/index.lua --- a/app/main/index/index.lua Fri Jul 06 13:34:02 2012 +0200 +++ b/app/main/index/index.lua Fri Jul 06 13:58:20 2012 +0200 @@ -5,7 +5,7 @@ module = "index", view = "_index_member" } -elseif config.public_access then +elseif app.session:has_access("anonymous") then if config.motd_public then local help_text = config.motd_public ui.container{ diff -r e12f0348b191 -r ea2449916c12 app/main/index/login.lua --- a/app/main/index/login.lua Fri Jul 06 13:34:02 2012 +0200 +++ b/app/main/index/login.lua Fri Jul 06 13:58:20 2012 +0200 @@ -20,7 +20,7 @@ } end -if config.public_access then +if app.session:has_access("anonymous") then ui.tag{ tag = 'p', content = _'You need to be logged in, to use all features of this system.' diff -r e12f0348b191 -r ea2449916c12 app/main/index/search.lua --- a/app/main/index/search.lua Fri Jul 06 13:34:02 2012 +0200 +++ b/app/main/index/search.lua Fri Jul 06 13:58:20 2012 +0200 @@ -15,7 +15,7 @@ attr = { class = "vertical" }, content = function() - if app.session.member_id or config.public_access == "full" then + if app.session:has_access("all_pseudonymous") then ui.field.select{ label = _"Search context", name = "search_for", @@ -38,7 +38,7 @@ if search_string then - if app.session.member_id or config.public_access == "full" then + if app.session:has_access("all_pseudonymous") then if search_for == "global" or search_for == "member" then local members_selector = Member:get_search_selector(search_string) execute.view{ diff -r e12f0348b191 -r ea2449916c12 app/main/initiative/_show.lua --- a/app/main/initiative/_show.lua Fri Jul 06 13:34:02 2012 +0200 +++ b/app/main/initiative/_show.lua Fri Jul 06 13:58:20 2012 +0200 @@ -64,14 +64,14 @@ else ui.container{ attr = { class = "title" }, content = text } end - if app.session.member_id or config.public_access == "pseudonym" or config.public_access == "full" then + if app.session:has_access("authors_pseudonymous") then ui.container{ attr = { class = "content" }, content = function() ui.tag{ attr = { class = "initiator_names" }, content = function() for i, initiator in ipairs(initiators) do slot.put(" ") - if app.session.member_id or config.public_access == "full" then + if app.session:has_access("all_pseudonymous") then ui.link{ content = function () execute.view{ @@ -421,7 +421,7 @@ } - if config.public_access == "full" or app.session.member_id then + if app.session:has_access("all_pseudonymous") then if initiative.issue.ranks_available then local members_selector = initiative.issue:get_reference_selector("direct_voters") :left_join("vote", nil, { "vote.initiative_id = ? AND vote.member_id = member.id", initiative.id }) diff -r e12f0348b191 -r ea2449916c12 app/main/issue/show.lua --- a/app/main/issue/show.lua Fri Jul 06 13:34:02 2012 +0200 +++ b/app/main/issue/show.lua Fri Jul 06 13:58:20 2012 +0200 @@ -17,7 +17,7 @@ execute.view{ module = "issue", view = "_show", params = { issue = issue } } end ) -if app.session.member_id or config.public_access == "full" then +if app.session:has_access("all_pseudonymous") then ui.container{ attr = { class = "heading" }, content = _"Interested members" } diff -r e12f0348b191 -r ea2449916c12 app/main/member/show.lua --- a/app/main/member/show.lua Fri Jul 06 13:34:02 2012 +0200 +++ b/app/main/member/show.lua Fri Jul 06 13:58:20 2012 +0200 @@ -55,7 +55,7 @@ content = _"This member is locked" } end - if not (member.id == app.session.member.id) then + if app.session.member_id and not (member.id == app.session.member.id) then slot.put(" · ") --TODO performance local contact = Contact:by_pk(app.session.member.id, member.id) @@ -93,47 +93,49 @@ } end end - local ignored_member = IgnoredMember:by_pk(app.session.member.id, member.id) - slot.put(" · ") - if ignored_member then - ui.tag{ - attr = { class = "interest" }, - content = _"You have ignored this member" - } + if app.session.member_id then + local ignored_member = IgnoredMember:by_pk(app.session.member.id, member.id) slot.put(" · ") - ui.link{ - text = _"Stop ignoring member", - module = "member", - action = "update_ignore_member", - id = member.id, - params = { delete = true }, - routing = { - default = { - mode = "redirect", - module = request.get_module(), - view = request.get_view(), - id = param.get_id_cgi(), - params = param.get_all_cgi() + if ignored_member then + ui.tag{ + attr = { class = "interest" }, + content = _"You have ignored this member" + } + slot.put(" · ") + ui.link{ + text = _"Stop ignoring member", + module = "member", + action = "update_ignore_member", + id = member.id, + params = { delete = true }, + routing = { + default = { + mode = "redirect", + module = request.get_module(), + view = request.get_view(), + id = param.get_id_cgi(), + params = param.get_all_cgi() + } } } - } - elseif member.activated then - ui.link{ - attr = { class = "interest" }, - text = _"Ignore member", - module = "member", - action = "update_ignore_member", - id = member.id, - routing = { - default = { - mode = "redirect", - module = request.get_module(), - view = request.get_view(), - id = param.get_id_cgi(), - params = param.get_all_cgi() + elseif member.activated then + ui.link{ + attr = { class = "interest" }, + text = _"Ignore member", + module = "member", + action = "update_ignore_member", + id = member.id, + routing = { + default = { + mode = "redirect", + module = request.get_module(), + view = request.get_view(), + id = param.get_id_cgi(), + params = param.get_all_cgi() + } } } - } + end end end } end) diff -r e12f0348b191 -r ea2449916c12 config/example.lua --- a/config/example.lua Fri Jul 06 13:34:02 2012 +0200 +++ b/config/example.lua Fri Jul 06 13:58:20 2012 +0200 @@ -1,15 +1,22 @@ -- ======================================================================== --- MANDATORY (MUST BE SET!) +-- MANDATORY (MUST BE CAREFULLY CHECKED AND PROPERLY SET!) -- ======================================================================== +-- Name of this instance, defaults to name of config file +-- ------------------------------------------------------------------------ +config.instance_name = "Instance name" + + -- Information about service provider (HTML) -- ------------------------------------------------------------------------ config.app_service_provider = "Snake Oil
10000 Berlin
Germany" + -- A rocketwiki formatted text the user has to accept while registering -- ------------------------------------------------------------------------ config.use_terms = "=== Terms of Use ===" + -- Checkbox(es) the user has to accept while registering -- ------------------------------------------------------------------------ config.use_terms_checkboxes = { @@ -24,7 +31,18 @@ -- not_accepted_error = "You have to accept the extra terms of use to be able to register." -- } } + +-- Absolute base url of application +-- ------------------------------------------------------------------------ +config.absolute_base_url = "http://example.com/" + + +-- Connection information for the LiquidFeedback database +-- ------------------------------------------------------------------------ +config.database = { engine='postgresql', dbname='liquid_feedback' } + + -- Location of the rocketwiki binaries -- ------------------------------------------------------------------------ config.formatting_engine_executeables = { @@ -32,17 +50,25 @@ compat = "/opt/rocketwiki-lqfb/rocketwiki-lqfb-compat" } --- Absolute base url of application --- ------------------------------------------------------------------------ -config.absolute_base_url = "http://example.com/" --- Name of this instance, defaults to name of config file +-- Public access level -- ------------------------------------------------------------------------ -config.instance_name = "Instance name" +-- Available options: +-- "none" +-- -> Closed user group, no public access at all +-- (except login/registration/password reset) +-- "anonymous" +-- -> Shows only initiative/suggestions texts and aggregated +-- supporter/voter counts +-- "authors_pseudonymous" +-- -> Like anonymous, but shows screen names of authors +-- "all_pseudonymous" +-- -> Show everything a member can see, except profile pages +-- "everything" +-- -> Show everything a member can see, including profile pages +-- ------------------------------------------------------------------------ +config.public_access = "none" --- Connection information for the LiquidFeedback database --- ------------------------------------------------------------------------ -config.database = { engine='postgresql', dbname='liquid_feedback' } -- ======================================================================== @@ -85,12 +111,6 @@ -- ------------------------------------------------------------------------ -- config.download_use_terms = "=== Download use terms ===\n" --- Set public access level --- Available options: false, "anonymous", "pseudonym", "full" --- Defaults to false (no public access) --- ------------------------------------------------------------------------ --- config.public_access = false - -- Use custom image conversion, defaults to ImageMagick's convert -- ------------------------------------------------------------------------ --config.member_image_content_type = "image/jpeg" diff -r e12f0348b191 -r ea2449916c12 config/init.lua --- a/config/init.lua Fri Jul 06 13:34:02 2012 +0200 +++ b/config/init.lua Fri Jul 06 13:58:20 2012 +0200 @@ -28,10 +28,6 @@ } end -if config.public_access == nil then - config.public_access = false -end - if config.locked_profile_fields == nil then config.locked_profile_fields = {} end diff -r e12f0348b191 -r ea2449916c12 model/member.lua --- a/model/member.lua Fri Jul 06 13:34:02 2012 +0200 +++ b/model/member.lua Fri Jul 06 13:58:20 2012 +0200 @@ -470,7 +470,7 @@ function Member.object:ui_field_text(args) args = args or {} - if app.session.member_id or config.public_access == "pseudonym" or config.public_access == "full" then + if app.session:has_access("authors_pseudonymous") then -- ugly workaround for getting html into a replaced string and to the user ui.container{label = args.label, label_attr={class="ui_field_label"}, content = function() slot.put(string.format('%s', diff -r e12f0348b191 -r ea2449916c12 model/session.lua --- a/model/session.lua Fri Jul 06 13:34:02 2012 +0200 +++ b/model/session.lua Fri Jul 06 13:58:20 2012 +0200 @@ -31,3 +31,44 @@ selector:optional_object_mode() return selector:exec() end + +function Session.object:has_access(level) + if level == "member" then + if app.session.member_id then + return true + else + return false + end + + elseif level == "everything" then + if self:has_access("member") or config.public_access == "everything" then + return true + else + return false + end + + elseif level == "all_pseudonymous" then + if self:has_access("everything") or config.public_access == "all_pseudonymous" then + return true + else + return false + end + + elseif level == "authors_pseudonymous" then + if self:has_access("all_pseudonymous") or config.public_access == "authors_pseudonymous" then + return true + else + return false + end + + elseif level == "anonymous" then + if self:has_access("authors_pseudonymous") or config.public_access == "anonymous" then + return true + else + return false + end + + end + + error("invalid access level") +end