Skip to content

Commit

Permalink
Item1484: port WebPermissionsPlugin - i'll start...
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.foswiki.org/trunk/WebPermissionsPlugin@3602 0b4bb1d4-4e5a-0410-9cc4-b2b747904278
  • Loading branch information
SvenDowideit authored and SvenDowideit committed Apr 21, 2009
1 parent 67357f0 commit 98b325d
Show file tree
Hide file tree
Showing 7 changed files with 46 additions and 48 deletions.
36 changes: 17 additions & 19 deletions data/System/WebPermissionsPlugin.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,19 @@
* Set Y = <input checked="checked" type="checkbox" />
* Set N = <input type="checkbox" />
-->
This plugin provides a centralised interface to TWiki permissions.
This plugin provides a centralised interface to Foswiki permissions.

Web permissions are presented as a matrix that has columns of webs and rows of users. For each web, you can control which users can view or change that web. All user webs, every registered user (except admin users), and every group (except admin groups) are shown in the matrix.

To interactivly edit topic permissions, it adds an "Edit topic ACLs" option to the "More Actions" page.

---++++ Web Permissions
This interface allows you to control
<table class="twikiTable">
<table class="foswikiTable">
<tr><th width="50%"> Viewing </th><th width="50%"> Editing </th></tr>
<tr><td>
VIEW = %V% CHANGE = %C%
<table class="twikiTable">
<table class="foswikiTable">
<tr><th></th><th>Albums</th><th>Singles</th><th>Reviews</th><th>Statistics</th></tr>
<tr><th>AnnieLennox<td>%V%%C%</td><td>%V%%C%</td><td>%V%%C%</td><td>%V%</td></tr>
<tr><th>BillyBragg </th><td>%V%<td>%V%</td><td>%V%</td><td></td></tr>
Expand All @@ -31,7 +31,7 @@ VIEW = %V% CHANGE = %C%
<button>Edit</button>
</td><td>
VIEW = %V% CHANGE = %C%
<table class="twikiTable" border="1">
<table class="foswikiTable" border="1">
<tr><th></th><th>Albums</th><th>Singles</th><th>Reviews</th><th>Statistics</th></tr>
<tr><th> AnnieLennox </th><td>%V%%Y% %C%%Y%</td><td>%V%%Y%%C%%Y%</td><td>%V%%Y%%C%%Y%</td><td>%V%%Y%%C%%N%</td></tr>
<tr><th> BillyBragg </th><td>%V%%Y%%C%%N%<td>%V%%Y%%C%%N%</td><td>%V%%Y%%C%%N%</td><td>%V%%N%%C%%N%</td></tr>
Expand Down Expand Up @@ -63,8 +63,8 @@ The plugin tries very hard to keep the permissions specification you started wit
<optgroup label="Groups"></optgroup>
<optgroup label="Users"><option>ProjectContributor</option><option>WikiGuest</option></optgroup></select>
</td><td align="center" width="100">
<button type="button" style="width: 100%;" class="twikiSubmit" name="action_save" id="save">%LEFT% Remove</button>
<button type="button" style="width: 100%;" class="twikiSubmit" name="action_cancel" id="cancel">Add %RIGHT%</button></td>
<button type="button" style="width: 100%;" class="foswikiSubmit" name="action_save" id="save">%LEFT% Remove</button>
<button type="button" style="width: 100%;" class="foswikiSubmit" name="action_cancel" id="cancel">Add %RIGHT%</button></td>
<td width="40%">
<h4><a name="Editors"></a> Editors </h4>
<select size="5" name="topiceditors" multiple="multiple" style="width: 100%;">
Expand All @@ -77,13 +77,13 @@ The plugin tries very hard to keep the permissions specification you started wit
</tr>
<tr><td></td>
<td align="center" valign="center">
<button type="button" style="height: 20px; width: 30%;" class="twikiSubmit" name="action_save" id="save">%DOWN%</button>
<button type="button" style="height: 20px; width: 30%;" class="twikiSubmit" name="action_cancel" id="cancel">%UP%</button>
<button type="button" style="height: 20px; width: 30%;" class="foswikiSubmit" name="action_save" id="save">%DOWN%</button>
<button type="button" style="height: 20px; width: 30%;" class="foswikiSubmit" name="action_cancel" id="cancel">%UP%</button>
</td>
</tr>
<tr><td align="center">
<button type="button" style="width: 100%;"class="twikiSubmit" name="action_save" id="save">%LEFT% Remove</button>
<button type="button" style="width: 100%;" class="twikiSubmit" name="action_cancel" id="cancel">Add %RIGHT%</button></td>
<button type="button" style="width: 100%;"class="foswikiSubmit" name="action_save" id="save">%LEFT% Remove</button>
<button type="button" style="width: 100%;" class="foswikiSubmit" name="action_cancel" id="cancel">Add %RIGHT%</button></td>
<td><h4><a name="Viewers"></a> Viewers </h4>
<select size="5" name="topicviewers" multiple="multiple" style="width: 100%;">
<optgroup label="Groups">
Expand All @@ -94,16 +94,14 @@ The plugin tries very hard to keep the permissions specification you started wit
</tr><tr height="10">
</tr><tr>
<td colspan="3" align="right">
<input class="twikiSubmit" name="topic_permissions_action" id="save" value="Save" >
<input class="twikiSubmit" name="topic_permissions_action" id="cancel" value="Cancel"> &nbsp; &nbsp; &nbsp; &nbsp;
<input class="foswikiSubmit" name="topic_permissions_action" id="save" value="Save" >
<input class="foswikiSubmit" name="topic_permissions_action" id="cancel" value="Cancel"> &nbsp; &nbsp; &nbsp; &nbsp;
</td>
</tr>
</tbody></table>
</form>
<hr />

*THIS PLUGIN REQUIRES TWiki-4.0.0 or later*

---++ Syntax Rules

The web permissions matrix can be viewed (and edited) by entering =%<nop>WEBPERMISSIONS%= anywhere in a topic.
Expand All @@ -114,7 +112,7 @@ You have to have write permissions to that topic to view/edit the UI.


---+++ =WEBPERMISSIONS=
The =WEBPERMISSIONS= TWiki variable accepts the following parameters:
The =WEBPERMISSIONS= TML variable accepts the following parameters:
* =repeatheads= - if set to a number, headings will be repeated every this number of rows. This is very useful when you have a lot of users and groups.
* =webs= - a comma-separated list of webs to show. Default is to show all webs.
* =users= - a comma-separated list of users (and groups) to show. Default is to show all users and groups.
Expand Down Expand Up @@ -152,7 +150,7 @@ To add an "Edit ACLS" option to the "More topic actions" screen add =webpermis
-->
By default, the plugin only supports VIEW and CHANGE permissions on webs. You can change the set of access modes handled by the plugin by defining a configuration variable (in !LocalSite.cfg) to be a comma-separated list of access modes. For example,
<verbatim>
$TWiki::cfg{Plugins}{WebPermissionsPlugin}{modes} = 'VIEW,CHANGE,RENAME';
$Foswiki::cfg{Plugins}{WebPermissionsPlugin}{modes} = 'VIEW,CHANGE,RENAME';
</verbatim>
See %SYSTEMWEB%.AccessControl for more information on what access modes can be used to control.

Expand All @@ -166,25 +164,25 @@ e.g. =Set SKIN=webpermissions,pattern=)

---++ Plugin Info

Another great TWiki extension from the <a style="text-decoration:none" href="http://wikiring.com"><img src="%ATTACHURLPATH%/wikiringlogo20x20.png" alt="" /> *WikiRing* </a> - working together to improve your wiki experience!
Another great Foswiki extension from the <a style="text-decoration:none" href="http://wikiring.com"><img src="%ATTACHURLPATH%/wikiringlogo20x20.png" alt="" /> *WikiRing* </a> - working together to improve your wiki experience!

Many thanks to the following sponsors for supporting this work:
* This plugin was developed on behalf of <a href="http://www.evolvedmedianetwork.com">Evolved Media Network</a>
* Further work supported by [[http://www.spanlink.com/][Spanlink Communications]]

| Plugin Author: | TWiki:Main.CrawfordCurrie & TWiki:Main.SvenDowideit, http://wikiring.com |
| Plugin Author: | Foswiki:Main.CrawfordCurrie & :Main.SvenDowideit, http://wikiring.com |
| Copyright: | &copy; 2006, Evolved Media Network, Spanlink Communications and WikiRing |
| License: | GPL ([[http://www.gnu.org/copyleft/gpl.html][GNU General Public License]]) |
| Plugin Version: | %$VERSION% |
| Change History: | |
| March 2009 | ported to Foswiki |
| 4 Dec 2007 | TWikibug:Item4901 fixed templates TWikibug:Item5072 added users parameter to select a subset of users/groups in the web permissions interface |
| 8 Sep 2007 | Updated for TWiki-4.2.0 |
| July 2006 | add Topic ACLs user interface via More topic actions - SvenDowideit@WikiRing.com |
| 10216 | TWikibug:Item2291 - Added repeatheads and webs parameters |
| 9048 | TWikibug:Item1766 - corrected problems with passing incorrect parameters to setACLs and not interpreting values from the form correctly. |
| 8877 | TWikibug:Item1701 - first release |
| Dependencies: | %$DEPENDENCIES% |
| Demo Url: | http://demo.wikiring.com/twiki/bin/view/Demo/TopicPermissionsDemo |
| Plugin Home: | http://foswiki.org/Extensions/%TOPIC% |
| Feedback: | http://foswiki.org/Extensions/%TOPIC%Dev |
| Appraisal: | http://foswiki.org/Extensions/%TOPIC%Appraisal |
Expand Down
2 changes: 1 addition & 1 deletion lib/Foswiki/Plugins/WebPermissionsPlugin.pm
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
#
# For licensing info read LICENSE file in the TWiki root.
# For licensing info read LICENSE file in the Foswiki root.
#
# Author: Crawford Currie http://c-dot.co.uk
#
Expand Down
15 changes: 8 additions & 7 deletions lib/Foswiki/Plugins/WebPermissionsPlugin/Core.pm
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
#
# For licensing info read LICENSE file in the TWiki root.
# For licensing info read LICENSE file in the Foswiki root.
#
# Author: Crawford Currie http://c-dot.co.uk
# Author: Sven Dowideit http://fosiki.com
# Author: Eugen Mayer http://impressimpressive-media.de
#
# This plugin helps with permissions management by displaying the web
Expand All @@ -30,7 +31,7 @@ use strict;

# BUGO: because WEBPERMISSIONS is using the same view to change and display,
# updated ACL's do not apply to this view.
# TWiki has already loaded the permissions that it is using, and some
# Foswiki has already loaded the permissions that it is using, and some
# random plugins have already processed things based on the ACLs prior to
# the users change. THIS IS HORRIGIBILE
# IMO it needs to be either rest or save, though i'm going to lean to rest
Expand Down Expand Up @@ -107,7 +108,7 @@ sub WEBPERMISSIONS {
}
}

$tab .= CGI::start_table( { border => 1, class => 'twikiTable' } );
$tab .= CGI::start_table( { border => 1, class => 'foswikiTable' } );

my $repeat_heads = $params->{repeatheads} || 0;
my $repeater = 0;
Expand Down Expand Up @@ -142,10 +143,10 @@ sub WEBPERMISSIONS {
$tab .= CGI::end_table();

if( $editing ) {
$tab .= CGI::submit( -name => 'web_permissions_action', -value => 'Save', -class => 'twikiSubmit');
$tab .= CGI::submit( -name => 'web_permissions_action', -value => 'Cancel', -class => 'twikiSubmit' );
$tab .= CGI::submit( -name => 'web_permissions_action', -value => 'Save', -class => 'foswikiSubmit');
$tab .= CGI::submit( -name => 'web_permissions_action', -value => 'Cancel', -class => 'foswikiSubmit' );
} else {
$tab .= CGI::submit( -name => 'web_permissions_action', -value => 'Edit', -class => 'twikiSubmit' );
$tab .= CGI::submit( -name => 'web_permissions_action', -value => 'Edit', -class => 'foswikiSubmit' );
}
my $page = CGI::start_form(
-method => 'POST',
Expand Down Expand Up @@ -389,7 +390,7 @@ sub _getListOfGroups {
@list = map { $_->wikiName() }
@{$session->{users}->getAllGroups()};
} else {
# This code assumes we are using TWiki topic based Group mapping
# This code assumes we are using Foswiki topic based Group mapping
$session->{search}->searchWeb(
_callback => sub {
my $ref = shift;
Expand Down
1 change: 0 additions & 1 deletion lib/Foswiki/Plugins/WebPermissionsPlugin/DEPENDENCIES
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
TWiki::Plugins,>=1.10,perl,TWiki-4


22 changes: 11 additions & 11 deletions pub/System/WebPermissionsPlugin/WebPermissionsPlugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,20 @@
#
*/

//create the TWiki namespace if needed
if ( typeof( TWiki ) == "undefined" ) {
TWiki = {};
//create the Fowsiki namespace if needed
if ( typeof( ) == "undefined" ) {
= {};
}

/**********************************************************************************/
//create the TWiki.WebPermissionsPlugin namespace if needed
if ( typeof( TWiki.WebPermissionsPlugin ) == "undefined" ) {
TWiki.WebPermissionsPlugin = {};
//create the Foswiki.WebPermissionsPlugin namespace if needed
if ( typeof( Foswiki.WebPermissionsPlugin ) == "undefined" ) {
Foswiki.WebPermissionsPlugin = {};
}


//moveSelectionTo(event, 'topiceditors', 'allusersandgroups')
TWiki.WebPermissionsPlugin.moveSelectionTo = function(event, fromSelectName, toSelectName) {
Foswiki.WebPermissionsPlugin.moveSelectionTo = function(event, fromSelectName, toSelectName) {
var buttonTarget = (event.target) ? event.target : event.srcElement;

var fromSelect = buttonTarget.form.elements.namedItem(fromSelectName);
Expand All @@ -54,20 +54,20 @@ TWiki.WebPermissionsPlugin.moveSelectionTo = function(event, fromSelectName, toS
}
}

//the namespace makes TWiki decide its a web.topic to be rendered as a url
//the namespace makes Foswiki decide its a web.topic to be rendered as a url
prepareForSave = function(event) {
return TWiki.WebPermissionsPlugin.prepareForSave(event);
return Foswiki.WebPermissionsPlugin.prepareForSave(event);
}

//return false cancels the submit
TWiki.WebPermissionsPlugin.prepareForSave = function(event) {
Foswiki.WebPermissionsPlugin.prepareForSave = function(event) {
//, 'topiceditors', 'topicviewers', 'disallowedusers'
var buttonTarget = (event.target) ? event.target : event.srcElement;

var userInEditorsList = false;
var selectObj = buttonTarget.form.elements.namedItem('topiceditors');
for (i=0; i< selectObj.options.length; i++) {
if (selectObj.options[i].value == TWiki.UsersWikiName) {
if (selectObj.options[i].value == Foswiki.UsersWikiName) {
userInEditorsList = true;
}
if (selectObj.options[i].changed == 'changed') {
Expand Down
16 changes: 8 additions & 8 deletions templates/webpermissionsplugin.topichtml.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@
</SELECT>
</td>
<td align="center" width="100px">
<button type="button" style="width:100%;" onclick="TWiki.WebPermissionsPlugin.moveSelectionTo(event, 'topiceditors', 'disallowedusers');" class="twikiSubmit" >
<button type="button" style="width:100%;" onclick="Foswiki.WebPermissionsPlugin.moveSelectionTo(event, 'topiceditors', 'disallowedusers');" class="foswikiSubmit" >
<IMG src="%PUBURL%/%SYSTEMWEB%/%PLUGINNAME%/leftarrow.png" alt="<-"> Remove
</button>
<button type="button" style="width: 100%;" onclick="TWiki.WebPermissionsPlugin.moveSelectionTo(event, 'disallowedusers', 'topiceditors');" class="twikiSubmit" >
<button type="button" style="width: 100%;" onclick="Foswiki.WebPermissionsPlugin.moveSelectionTo(event, 'disallowedusers', 'topiceditors');" class="foswikiSubmit" >
Add <IMG src="%PUBURL%/%SYSTEMWEB%/%PLUGINNAME%/rightarrow.png" alt="->">
</button>
</td>
Expand All @@ -39,20 +39,20 @@
<td>
</td>
<td align="center" valign="center">
<button type="button" style="height: 20px;width:30%;" onclick="TWiki.WebPermissionsPlugin.moveSelectionTo(event, 'topiceditors', 'topicviewers');" class="twikiSubmit" >
<button type="button" style="height: 20px;width:30%;" onclick="Foswiki.WebPermissionsPlugin.moveSelectionTo(event, 'topiceditors', 'topicviewers');" class="foswikiSubmit" >
<IMG src="%PUBURL%/%SYSTEMWEB%/%PLUGINNAME%/downarrow.png" alt="V">
</button>
<button type="button" style="height: 20px;width:30%;" onclick="TWiki.WebPermissionsPlugin.moveSelectionTo(event, 'topicviewers', 'topiceditors');" class="twikiSubmit" >
<button type="button" style="height: 20px;width:30%;" onclick="Foswiki.WebPermissionsPlugin.moveSelectionTo(event, 'topicviewers', 'topiceditors');" class="foswikiSubmit" >
<IMG src="%PUBURL%/%SYSTEMWEB%/%PLUGINNAME%/uparrow.png" alt="^">
</button>
</td>
</tr>
<tr>
<td align="center">
<button type="button" style="width: 100%;" onclick="TWiki.WebPermissionsPlugin.moveSelectionTo(event, 'topicviewers', 'disallowedusers');" class="twikiSubmit" >
<button type="button" style="width: 100%;" onclick="Foswiki.WebPermissionsPlugin.moveSelectionTo(event, 'topicviewers', 'disallowedusers');" class="foswikiSubmit" >
<IMG src="%PUBURL%/%SYSTEMWEB%/%PLUGINNAME%/leftarrow.png" alt="<-"> Remove
</button>
<button type="button" style="width: 100%;" onclick="TWiki.WebPermissionsPlugin.moveSelectionTo(event, 'disallowedusers', 'topicviewers');" class="twikiSubmit" >
<button type="button" style="width: 100%;" onclick="Foswiki.WebPermissionsPlugin.moveSelectionTo(event, 'disallowedusers', 'topicviewers');" class="foswikiSubmit" >
Add <IMG src="%PUBURL%/%SYSTEMWEB%/%PLUGINNAME%/rightarrow.png" alt="->">
</button>
</td>
Expand All @@ -72,8 +72,8 @@
</tr>
<tr>
<td align="right" colspan="3">
<input type="submit" %DISABLESAVE% class="twikiSubmit%DISABLESAVE%" name="topic_permissions_action" id="save" value='Save' onclick="return prepareForSave(event);" />
<input type="submit" class="twikiSubmit" name="topic_permissions_action" id="cancel" value='Cancel' accesskey='c' /> &nbsp; &nbsp; &nbsp; &nbsp;
<input type="submit" %DISABLESAVE% class="foswikiSubmit%DISABLESAVE%" name="topic_permissions_action" id="save" value='Save' onclick="return prepareForSave(event);" />
<input type="submit" class="foswikiSubmit" name="topic_permissions_action" id="cancel" value='Cancel' accesskey='c' /> &nbsp; &nbsp; &nbsp; &nbsp;
</td>
</tr>
</table>
Expand Down
2 changes: 1 addition & 1 deletion templates/webpermissionsplugin.topicjavascript.tmpl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

<script language="JavaScript" type="text/javascript" src="%PLUGINPUBURL%/WebPermissionsPlugin.js"></script>
<script language="JavaScript" type="text/javascript">
TWiki.UsersWikiName = '%USERINFO{format="$wikiname"}%';
Foswiki.UsersWikiName = '%USERINFO{format="$wikiname"}%';
</script>

0 comments on commit 98b325d

Please sign in to comment.