Project

General

Profile

Actions

Feature #29048

open

Wiki page permission level

Added by filippo mandelli over 5 years ago. Updated over 5 years ago.

Status:
New
Priority:
Normal
Assignee:
-
Category:
Wiki
Target version:
-
Start date:
Due date:
% Done:

0%

Estimated time:
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.


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
Actions #1

Updated by filippo mandelli over 5 years ago

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

Actions #2

Updated by Gregor Schmidt over 5 years ago

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

Actions #3

Updated by filippo mandelli over 5 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"

Actions #4

Updated by Bernhard Rohloff over 5 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.

Actions #5

Updated by filippo mandelli over 5 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

Actions #6

Updated by filippo mandelli over 5 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 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?

Actions #7

Updated by Bernhard Rohloff over 5 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.

Actions #8

Updated by filippo mandelli over 5 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

Actions #9

Updated by Bernhard Rohloff over 5 years ago

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

Actions #10

Updated by filippo mandelli over 5 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

Actions #11

Updated by Bernhard Rohloff over 5 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...

Actions #12

Updated by filippo mandelli over 5 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

Actions #13

Updated by filippo mandelli over 5 years ago

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

!imageExample.png!

it is not visible

Actions #14

Updated by Bernhard Rohloff over 5 years ago

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

Actions #15

Updated by filippo mandelli over 5 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

Actions #16

Updated by Bernhard Rohloff over 5 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.

Actions #17

Updated by filippo mandelli over 5 years ago

Ohh yes , thanks again :-)

Actions

Also available in: Atom PDF