Tags:
create new tag
view all tags

Question

Hide Edit link if not in group

I believe it would be useful to have a plugin that can detect if a user is a member of a certain user group. This functionality would allow parts of the page to be printed only if the user is in a certain group. For example, if your TWIki site is not completely public, you may not want readers of topics to even see the "Edit" buttons unless they are members of an appropriate group. Example usage might be:

%IFINUSERGROUP{"%WIKINAME%" group="TWikiAdminGroup, DeveloperGroup" then="In the right group." else="Not in the right group."}%

The default argument is the username to check, the "group" argument specifies a list of groups. If the user is in any of the groups then the "then" argument is displayed, otherwise the "else" argument is displayed.

Alternatively, the "IF" macro that already exists could be modified to include this functionality.

-- KevinCraft - 30 Mar 2006

Answer

You don't need a plugin to get the effect you want:

Create a file RenderEditButton that looks something like this


%STARTINCLUDE%
<a href="%SCRIPTURL{"edit"}%/%BASEWEB%/%BASETOPIC%?t=%GMTIME{"$year$mo$day$hours$minutes$seconds"}%">
Edit</a>
%STOPINCLUDE%

   * Set ALLOWTOPICVIEW = DeveloperGroup

Add then the edit button by using a

%INCLUDE{"RenderEditButton" warn="off"}%

in some other topic.

-- MichaelDaum - 30 Mar 2006

Nice one Michael. Good candidate to package as a TWikiApplication component (in the Plugins web)

-- PeterThoeny - 30 Mar 2006

This is a good solution. I still think that it will be simpler to have a macro that does the same thing. If I have 10 different things that I only want developers to see, I don't want to create 10 different files. This is especially true if what I am trying to print is something trivial like "You are a Developer!".

-- KevinCraft - 30 Mar 2006

One topic will be enough if you use STARTSECTION / ENDSECTION together with %INCLUDE{section="mysection"}%. Then all UI items for developers go into the DevelopersInterface topic.

-- ArthurClemens - 06 Dec 2006

The solution I found for this involved modifying the template definitions for viewtopicactionbuttons and toolbarbuttons

I used the following statement to search whether the current viewer was in the group I wanted:

%CALC{$IF($EXACT("%SEARCH{ search="%WIKIUSERNAME%" web="Main" topic="MainWebAdminGroup" format="found" nonoise="on" zeroresults="off" }%","found"), Replace this text with buttons you only want displayed for MainWebAdminGroup ,)}%

-- DougCampbell - 06 Dec 2006

Edit | Attach | Watch | Print version | History: r7 < r6 < r5 < r4 < r3 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r7 - 2006-12-06 - DougCampbell
 
  • Learn about TWiki  
  • Download TWiki
This site is powered by the TWiki collaboration platform Powered by Perl Hosted by OICcam.com Ideas, requests, problems regarding TWiki? Send feedback. Ask community in the support forum.
Copyright © 1999-2026 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.