プロジェクト

全般

プロフィール

Vote #79379

未完了

Wiki page permission level

Admin Redmine さんが約4年前に追加. 約4年前に更新.

ステータス:
New
優先度:
通常
担当者:
-
カテゴリ:
Wiki_1
対象バージョン:
-
開始日:
2022/05/09
期日:
進捗率:

0%

予定工数:
category_id:
1
version_id:
0
issue_org_id:
29048
author_id:
320023
assigned_to_id:
0
comments:
17
status_id:
1
tracker_id:
2
plus1:
0
affected_version:
closed_on:
affected_version_id:
ステータス-->[New]

説明

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.


journals

User with lover level will see pages of high level and not vice versa
--------------------------------------------------------------------------------
Did you consider using multiple projects and cross-project wiki links?
--------------------------------------------------------------------------------
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"

--------------------------------------------------------------------------------
Or maybe you can make it work with custom macros where the text is only shown for a specific role in your project.
--------------------------------------------------------------------------------
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

--------------------------------------------------------------------------------
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:

<pre>
Redmine::WikiFormatting::Macros.register do
desc "Hide page !{{hide(roleToHide)}}"
macro :hide do |obj, args|
.......
end
end
</pre>

Is it possible?
--------------------------------------------------------------------------------
Yes, something like this should be possible. If you need some help, I'll try to come up with a solution until tomorrow.
--------------------------------------------------------------------------------
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
--------------------------------------------------------------------------------
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:
<pre>
out = h("")
</pre>

--------------------------------------------------------------------------------
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

--------------------------------------------------------------------------------
You have to put the text which should be hidden inside the curly brackets.
So for example:
<pre>
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...
</pre>
--------------------------------------------------------------------------------
Ok, I understand

I found two small problem:

1 In case of membership is nill , I fix it in this way

<pre>
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
</pre>

2 In case I have wiki page that contains macro childpages I have this error, but it is not a problem for my purpose

<pre>
Error executing the child_pages macro (With no argument, this macro can be called from wiki pages only.)

</pre>

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

<pre>
!imageExample.png!
</pre>

it is not visible
--------------------------------------------------------------------------------
This is a slightly modified version, which should fix your problems.

--------------------------------------------------------------------------------
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
<pre>
{{restrict_access(1,2,4) (#356) }}
</pre>

It doesn't run, but I can workaround in this way

<pre>
{{restrict_access2(1,2,4)
(#356)
}}
</pre>

Thanks for your help

--------------------------------------------------------------------------------
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":https://www.redmine.org/attachments/20938/restrict_access_macro_v2.rb#L22 should of course be the same as "line 17":https://www.redmine.org/attachments/20938/restrict_access_macro_v2.rb#L17. 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#Invoking-macros-in-formatted-text]] in the wiki.

--------------------------------------------------------------------------------
Ohh yes , thanks again :-)
--------------------------------------------------------------------------------

Admin Redmine さんが約4年前に更新

  • カテゴリWiki_1 にセット

他の形式にエクスポート: Atom PDF

いいね!0
いいね!0