Tags:
create new tag
, view all tags

Feature Proposals » Add Context IsAdmin to IF Statements

Summary

Current State: Developer: Reason: Date: Concerns By: Bug Tracking: Proposed For:
UnderInvestigation   None        

Edit Form

TopicSummary:
CurrentState:
CommittedDeveloper:
ReasonForDecision:
DateOfCommitment:   Format: YYYY-MM-DD
ConcernRaisedBy:
BugTracking:
OutstandingIssues:
RelatedTopics:
InterestedParties:
ProposedFor:
TWikiContributors:
 

Motivation

A context makes for a much simpler and shorter IF statement.

(Foswiki has this feature.)

Description and Documentation

I find it to be very useful to mark sections of topics for admin eyes only. A context would make re,e,bering this syntax (and creating variables with it) much easier.

Examples

%IF{"context isadmin" then="..." else="..."}%

vs

%IF{"'%USERNAME%' ingroup 'TWikiAdminGroup'" then="..." }

Impact


WhatDoesItAffect: Plugins

Implementation

-- Contributors: Vicki Brown - 2017-03-19

Discussion


TWiki has already context in the IF{} variable.

Agreed that adding isadmin to context is a useful small enhancement.

If you are committed to implementing this set the date and name in the form. Please review TWikiReleaseManagementProcess.

-- Peter Thoeny - 2017-03-19

One thing to note is that TWikiAdminGroup does not necessarily determine whether a user is an admin or not. By default, that's the case since TWiki::Users::TWikiUserMapping::isAdmin() behaves that way. A while back, I introduced TWiki::Users::isAdmin(), which calls the isAdmin() of the currently effective user mapping.

So now it's easier than before to introduce the isadmin context. It's only a matter of calling TWiki::Users::isAdmin().

-- Hideyo Imazu - 2017-03-21

Also, for now you could simple define a site-wide ISADMIN variable that returns 0 or 1 based on an IF with ingroup.

-- Peter Thoeny - 2017-03-21

Feature discussed at KampalaReleaseMeeting2017x04x06:

  • No commit date and developer, wait until committed developer
  • Can also be done with a setting:
    • Set ISADMIN = %IF{"'%USERNAME%' ingroup 'TWikiAdminGroup'" then="1" else="0" }%
    • Set ISADMIN = 0
    • Results in: 0

-- Peter Thoeny - 2017-04-09

Edit | Attach | Watch | Print version | History: r5 < r4 < r3 < r2 < r1 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r5 - 2017-04-09 - PeterThoeny
 
  • 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-2017 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.