Feature #29048
openWiki page permission level
Added by filippo mandelli over 6 years ago. Updated over 6 years ago.
0%
Description
I would like to set different permission level in a wiki page.
i.e:
Level | Description |
1 | developers |
2 | service |
3 | marketing |
4 | customer |
And I would like to set permission in the Roles setting.
Files
restrict_access_macro.rb (827 Bytes) restrict_access_macro.rb | Bernhard Rohloff, 2018-06-21 13:00 | ||
restrict_access_macro_v2.rb (981 Bytes) restrict_access_macro_v2.rb | Bernhard Rohloff, 2018-06-22 13:45 |
Updated by filippo mandelli over 6 years ago
User with lover level will see pages of high level and not vice versa
Updated by Gregor Schmidt over 6 years ago
Did you consider using multiple projects and cross-project wiki links?
Updated by filippo mandelli over 6 years ago
Gregor Schmidt wrote:
Did you consider using multiple projects and cross-project wiki links?
It can be a solution but I have lot of project active and in some cases I have only few pages to lock, then I will have so many project to manage only for wiki page access.
In my solution I think it is just a field to add in wiki table and then manage the view. I think it can be done by a plug-in like "Manage Page Permission Plugin"
Updated by Bernhard Rohloff over 6 years ago
Or maybe you can make it work with custom macros where the text is only shown for a specific role in your project.
Updated by filippo mandelli over 6 years ago
Bernhard Rohloff wrote:
Or maybe you can make it work with custom macros where the text is only shown for a specific role in your project.
This should be a very simple solution, but I have questions (I'm not expert in ruby):
1 How can I check role
2 How can I hide the text
thanks
Updated by filippo mandelli over 6 years ago
filippo mandelli wrote:
Bernhard Rohloff wrote:
Or maybe you can make it work with custom macros where the text is only shown for a specific role in your project.
This should be a very simple solution, but I have questions (I'm not expert in ruby):
1 How can I check role
2 How can I hide the textthanks
I would like to write something to hide page in function of user role:
Redmine::WikiFormatting::Macros.register do desc "Hide page !{{hide(roleToHide)}}" macro :hide do |obj, args| ....... end end
Is it possible?
Updated by Bernhard Rohloff over 6 years ago
Yes, something like this should be possible. If you need some help, I'll try to come up with a solution until tomorrow.
Updated by filippo mandelli over 6 years ago
Bernhard Rohloff wrote:
Yes, something like this should be possible. If you need some help, I'll try to come up with a solution until tomorrow.
yes, thank you
Updated by Bernhard Rohloff over 6 years ago
- File restrict_access_macro.rb restrict_access_macro.rb added
As I promised yesterday, here is my macro based attempt.
Filippo Bernante mandelli
Currently it does exact the opposite of your required behavior as it shows content to a specific role rather then hiding it.
But I think you can easily modify it to do so by swapping the outputs in the if else block.
The error messages are only for demonstration and testing. If you don't need them, just delete the content of the string so that you get:
out = h("")
Updated by filippo mandelli over 6 years ago
Grat thanks for your help, I'm testing a wiki page like this:
{{restrict_access(1,2,4)}}
Documentation
bla bla
macro
pictures
And I would like to hide all lines after the macro {{restrict_access(1,2,4)}} but seems it is not working, maibe I make some error?
Can you help me?
Thanks again
Updated by Bernhard Rohloff over 6 years ago
You have to put the text which should be hidden inside the curly brackets.
So for example:
This part should be visible for everybody. ... {{restrict_access(1,2,4) But this is only visisble for Managers, Developers and Helpdesk... }} ... Here comes normal text again...
Updated by filippo mandelli over 6 years ago
Ok, I understand
I found two small problem:
1 In case of membership is nill , I fix it in this way
if membership.nil? out = h("Access reserved - no roles") else project_roles = membership.roles.to_a project_roles.map!{ |e| e.id } matching_roles = project_roles & permitted_roles if matching_roles.any? out = h(textilizable(text)) else out = h("Access reserved - no member") end end
2 In case I have wiki page that contains macro childpages I have this error, but it is not a problem for my purpose
Error executing the child_pages macro (With no argument, this macro can be called from wiki pages only.)
Thanks for help
Updated by filippo mandelli over 6 years ago
I add another problem that is critical for me, if wiki page contain image
!imageExample.png!
it is not visible
Updated by Bernhard Rohloff over 6 years ago
This is a slightly modified version, which should fix your problems.
Updated by filippo mandelli over 6 years ago
Bernhard Rohloff wrote:
This is a slightly modified version, which should fix your problems.
Hello Bernhard, the problem of images is still present in my installation
And I see another small problem: in case I want to hide just a link to an issues inside a line
{{restrict_access(1,2,4) (#356) }}
It doesn't run, but I can workaround in this way
{{restrict_access2(1,2,4) (#356) }}
Thanks for your help
Updated by Bernhard Rohloff over 6 years ago
filippo mandelli wrote:
Hello Bernhard, the problem of images is still present in my installation
Hey filippo,
you are logged in with an admin account, aren't you?
I've forgotten to apply my changes also for this case. The line 22 should of course be the same as line 17. Then all should work fine.
And I see another small problem: in case I want to hide just a link to an issues inside a line
[...]It doesn't run, but I can workaround in this way
[...]
This seems to be expected behavior according to RedmineMacros in the wiki.