Feature #29048

Wiki page permission level

Added by filippo mandelli 8 months ago. Updated 8 months ago.

Status:NewStart date:
Priority:NormalDue date:
Assignee:-% Done:

0%

Category:Wiki
Target version:-
Resolution:

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.

restrict_access_macro.rb Magnifier (827 Bytes) Bernhard Rohloff, 2018-06-21 13:00

restrict_access_macro_v2.rb Magnifier (981 Bytes) Bernhard Rohloff, 2018-06-22 13:45

History

#1 Updated by filippo mandelli 8 months ago

User with lover level will see pages of high level and not vice versa

#2 Updated by Gregor Schmidt 8 months ago

Did you consider using multiple projects and cross-project wiki links?

#3 Updated by filippo mandelli 8 months 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"

#4 Updated by Bernhard Rohloff 8 months ago

Or maybe you can make it work with custom macros where the text is only shown for a specific role in your project.

#5 Updated by filippo mandelli 8 months 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

#6 Updated by filippo mandelli 8 months 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 text

thanks

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?

#7 Updated by Bernhard Rohloff 8 months ago

Yes, something like this should be possible. If you need some help, I'll try to come up with a solution until tomorrow.

#8 Updated by filippo mandelli 8 months 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

#9 Updated by Bernhard Rohloff 8 months ago

As I promised yesterday, here is my macro based attempt.

@filippo 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("")

#10 Updated by filippo mandelli 8 months 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

#11 Updated by Bernhard Rohloff 8 months 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...

#12 Updated by filippo mandelli 8 months 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

#13 Updated by filippo mandelli 8 months ago

I add another problem that is critical for me, if wiki page contain image

!imageExample.png!

it is not visible

#14 Updated by Bernhard Rohloff 8 months ago

This is a slightly modified version, which should fix your problems.

#15 Updated by filippo mandelli 8 months 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

#16 Updated by Bernhard Rohloff 8 months 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.

#17 Updated by filippo mandelli 8 months ago

Ohh yes , thanks again :-)

Also available in: Atom PDF