Skip to content

Commit

Permalink
Item14343: Modify Wiki Groups for easier upgrades
Browse files Browse the repository at this point in the history
Move templates into the System web.
Change group create code to look for the topic template in Usersweb,
then System.
Move "active" components of WikiGroups into System.WikiGroupsComponents

Also fixed a minor error, group_upgrade dialog was no longer functional.
  • Loading branch information
gac410 committed Mar 17, 2017
1 parent 847e815 commit 0d20ce7
Show file tree
Hide file tree
Showing 8 changed files with 121 additions and 94 deletions.
8 changes: 0 additions & 8 deletions TopicUserMappingContrib/data/Main/GroupTemplate.txt

This file was deleted.

13 changes: 13 additions & 0 deletions TopicUserMappingContrib/data/System/GroupTemplate.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
%META:TOPICINFO{author="ProjectContributor" date="1489712653" format="1.1" version="1"}%
%META:TOPICPARENT{name="WikiGroups"}%
%STARTSECTION{type="templateonly"}%
To modify this template, first copy it to %USERSWEB%.%TOPIC% web, and edit that
copy. If %USERSWEB%.%TOPIC% exists, it will automatically be used when
creating new groups.
%ENDSECTION{type="templateonly"}%

%MAKETEXT{"Edit this topic to add a description to the [_1]" args="!%URLPARAM{"topic"}%"}%

%META:PREFERENCE{name="GROUP" title="GROUP" value=""}%
%META:PREFERENCE{name="VIEW_TEMPLATE" title="VIEW_TEMPLATE" value="GroupView"}%
%META:PREFERENCE{name="ALLOWTOPICCHANGE" title="ALLOWTOPICCHANGE" type="Set" value="%URLPARAM{"topic"}%"}%
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
data/System/TopicUserMappingContrib.txt 0644 Documentation
lib/Foswiki/Contrib/TopicUserMappingContrib.pm 0444
lib/Foswiki/Users/TopicUserMapping.pm 0444
data/Main/GroupTemplate.txt 0644
data/Main/NobodyGroup.txt 0644
data/Main/RegistrationAgent.txt 0644
data/Main/UserHomepageHeader.txt 0644
Expand All @@ -19,6 +18,7 @@ data/System/ChangeEmailAddress.txt 0644
data/System/ChangePassword.txt 0644
data/System/DefaultUserRegistration.txt 0644
data/System/FAQRebuildingWikiUsersTopic.txt 0644
data/System/GroupTemplate.txt 0644
data/System/ManagingUsers.txt 0644
data/System/NewUserTemplate.txt 0644
data/System/ResetPassword.txt 0644
Expand Down
13 changes: 11 additions & 2 deletions TopicUserMappingContrib/lib/Foswiki/Users/TopicUserMapping.pm
Original file line number Diff line number Diff line change
Expand Up @@ -946,8 +946,17 @@ sub addUserToGroup {
)
);

$groupTopicObject =
Foswiki::Meta->load( $this->{session}, $groupWeb, 'GroupTemplate' );
if ( Foswiki::Func::topicExists( $groupWeb, 'GroupTemplate' ) ) {
$groupTopicObject =
Foswiki::Meta->load( $this->{session}, $groupWeb,
'GroupTemplate' );
}
else {
$groupTopicObject =
Foswiki::Meta->load( $this->{session},
$Foswiki::cfg{SystemWebName},
'GroupTemplate' );
}

# expand the GroupTemplate as best we can.
$this->{session}->{request}
Expand Down
74 changes: 2 additions & 72 deletions core/data/Main/WikiGroups.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
%META:TOPICINFO{author="ProjectContributor" date="1489206078" format="1.1" version="1"}%
%META:TOPICINFO{author="ProjectContributor" date="1489712653" format="1.1" version="1"}%
%META:TOPICPARENT{name="WebHome"}%
---+ Wiki groups dashboard
Showing all known groups that can be used to define [[%SYSTEMWEB%.AccessControl][access controls]] in <nop>%WIKITOOLNAME%.
Expand All @@ -13,74 +13,4 @@ page can be significantly improved by enabling the following Set statement.
With this enabled, adding and removing members and also topic upgrades for each group are omitted from this page. Maintenance can be done from the individual group topics.
-->

%TWISTY{
link="<img src='%ICONURLPATH{"persons"}%' /> %MAKETEXT{"Create a new group"}%"
mode="div"
%IF{"$expand='1'" then='start="show"'}%
}%

<sticky>
<form action='%SCRIPTURLPATH{"manage" topic="%WEB%.%TOPIC%"}%' method='post'>
<input type="hidden" name="action" value="addUserToGroup"/>
<input type="hidden" name="create" value="1"/>
<div class="foswikiFormSteps">
<div class="foswikiFormStep ">
<h3>%MAKETEXT{"Group name"}%</h3>
<input type="text" name="groupname" size="30" class="foswikiInputField" value="%URLPARAM{"groupname"}%" />
<div class="foswikiFormDescription">
*Note:*
A group name must be a [[%SYSTEMWEB%.WikiWord][WikiWord]] and *must* end in =...Group=.
New topics are based on [[GroupTemplate]]
</div>
</div>
<div class="foswikiFormStep">
<h3>%MAKETEXT{"Members"}%</h3>
<input type="text" name="username" value="%URLPARAM{"username"}%" size="60" class="foswikiInputField" />
<div class="foswikiFormDescription">Comma separated list. You will be added to the group automatically to allow you to continue to manage the new group.</div>
</div>
<div class="foswikiFormStep">
<input class="foswikiSubmit" type="submit" value="%MAKETEXT{"Create group"}%"/>
</div>
<div class="foswikiFormStep foswikiLast">
<div class="foswikiFormDescription foswikiHelp">
*IMPORTANT NOTE:* Think twice before restricting write access to a web or a topic, because an open system where everybody can contribute is the essence of [[%SYSTEMWEB%.WikiCulture][WikiCulture]]. Experience shows that unrestricted write access works very well because:
* There is enough peer pressure to post only appropriate content.
* Content does not get lost because topics are under revision control.
* A topic revision can be undone by a member of the [[%USERSWEB%.AdminGroup][AdminGroup]] if necesssary.

*Related topics:* [[%SYSTEMWEB%.AccessControl][AccessControl]], [[%WEBPREFSTOPIC%]], [[%WIKIUSERSTOPIC%]], [[%SYSTEMWEB%.WikiCulture][WikiCulture]]

<div class="foswikiHelp">%X% If a large number of groups are configured, the rendering performance of this page can be significantly improved by disabling group maintenance from this page. Edit this topic for more information.</div>
</div>
</div>
</div>
</form></sticky> %ENDTWISTY%

%GROUPINFO{
header="<table class='foswikiTable wikiGroupsTable'>
<tr>
<th>%MAKETEXT{"Group"}%</th>
<th>%MAKETEXT{"Members"}%</th>
<th>%MAKETEXT{"Actions"}%</th>
</tr>$n"
format="<tr>
<td> $percntIF{\"not istopic '%USERSWEB%.$name'\" then=\"<nop>$name\" else=\"[[%USERSWEB%.$name][$name]]\"}$percnt</td>
<td>
$percntINCLUDE{\"%USERSWEB%.GroupViewTemplate\"
section=\"rendergroup\"
groupname=\"$name\"
allowschange=\"$allowschange\"
}$percnt
</td>
<td class=\"wikiGroupsActions\">
$percntINCLUDE{\"%USERSWEB%.GroupViewTemplate\"
section=\"groupactions\"
groupname=\"$name\"
allowschange=\"$allowschange\"
}$percnt
</td>
</tr>"
footer="</table>"
separator="$n"
}%

%INCLUDE{"%BASEWEB%.WikiGroupsComponents, %SYSTEMWEB%.WikiGroupsComponents"}%
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
%META:TOPICINFO{author="ProjectContributor" date="1458094641" format="1.1" version="1"}%
%META:TOPICINFO{author="ProjectContributor" date="1489712653" format="1.1" version="1"}%
%TMPL:INCLUDE{"view"}%

%TMPL:DEF{"content"}%<div class="foswikiTopicText">
Expand All @@ -11,7 +11,7 @@
AND {AdminUserWikiName} != '%WIKINAME%'"
then="
$percntINCLUDE{
\"%USERSWEB%.GroupViewTemplate\"
\"%SYSTEMWEB%.GroupViewTemplate, %USERSWEB%.GroupViewTemplate\"
section=\"manageself\"
groupname=\"%TOPIC%\"
}$percnt
Expand All @@ -20,12 +20,12 @@
%TEXT%
---++ %MAKETEXT{"Members"}%
%INCLUDE{
"%USERSWEB%.GroupViewTemplate"
"%SYSTEMWEB%.GroupViewTemplate, %USERSWEB%.GroupViewTemplate"
section="rendergroup"
groupname="%TOPIC%"
twisty="on"
}%%INCLUDE{
"%USERSWEB%.GroupViewTemplate"
"%SYSTEMWEB%.GroupViewTemplate, %USERSWEB%.GroupViewTemplate"
section="groupactions"
groupname="%TOPIC%"
twisty="on"
Expand Down Expand Up @@ -179,8 +179,8 @@ then='
parameters: groupname
-->
%STARTSECTION{"group_upgrade"}%
<div id='manageGroup' title="%MAKETEXT{"Upgrade"}% %URLPARAM{"groupname"}%" class="jqUIDialog { modal:true, resizable:false, draggable:false, width:400, autoCenter:true, cache:false}">
<form action="%SCRIPTURLPATH{"manage"}%/%WEB%/%TOPIC%" method="post">
<div id='manageGroup' title='%MAKETEXT{"Upgrade"}% <noautolink>%URLPARAM{"groupname"}%</noautolink>' class="jqUIDialog { modal:true, resizable:false, draggable:false, width:400, autoCenter:true, cache:false}">
<form action="%SCRIPTURLPATH{"manage"}%/%USERSWEB%/%BASETOPIC%" method="post">
<input type="hidden" name="groupname" value="%URLPARAM{"groupname"}%"/>
<input type="hidden" name="action" value="addUserToGroup"/>
<input type="hidden" name="create" value="1"/>
Expand All @@ -201,7 +201,7 @@ then='
-->
%STARTSECTION{"group_add"}%<!-- --><sticky>
<div id='manageGroup' title='%MAKETEXT{"Add Members to [_1]" args="<noautolink>%URLPARAM{"groupname"}%</noautolink>"}%' class='jqUIDialog { modal:true, resizable:false, draggable:false, width:400, autoCenter:true, cache:false}'>
<form id='addUser' action='%SCRIPTURLPATH{"manage"}%/%WEB%/%TOPIC%' method='post'>
<form id='addUser' action='%SCRIPTURLPATH{"manage"}%/%USERSWEB%/%BASETOPIC%' method='post'>
<input type='hidden' name='groupname' value='%URLPARAM{"groupname" default="%groupname%"}%'/>
<input type='hidden' name='action' value='addUserToGroup'/>
<div class='foswikiFormSteps'>
Expand All @@ -226,7 +226,7 @@ then='
%GROUPINFO{
"%URLPARAM{"groupname"}%"
expand="0"
header="<form action=\"%SCRIPTURLPATH{"manage"}%/%WEB%/%TOPIC%\" method=\"post\" >
header="<form action=\"%SCRIPTURLPATH{"manage"}%/%USERSWEB%/%BASETOPIC%\" method=\"post\" >
<input type=\"hidden\" name=\"groupname\" value=\"%URLPARAM{"groupname"}%\" />
<input type=\"hidden\" name=\"action\" value=\"removeUserFromGroup\" />
<div class=\"foswikiFormSteps\">
Expand Down Expand Up @@ -273,8 +273,8 @@ then='
%STARTSECTION{"manageself"}%
%IF{
"'%GROUPINFO{"%groupname%" expand="0"}%'=~'\b%USERNAME%\b'"
then="%INCLUDE{"%USERSWEB%.GroupViewTemplate" section="delme" groupname="%groupname%"}%"
else="%INCLUDE{"%USERSWEB%.GroupViewTemplate" section="addme" groupname="%groupname%"}%"
then="%INCLUDE{"%SYSTEMWEB%.GroupViewTemplate, %USERSWEB%.GroupViewTemplate" section="delme" groupname="%groupname%"}%"
else="%INCLUDE{"%SYSTEMWEB%.GroupViewTemplate, %USERSWEB%.GroupViewTemplate" section="addme" groupname="%groupname%"}%"
}%
%ENDSECTION{"manageself"}%

Expand Down
82 changes: 82 additions & 0 deletions core/data/System/WikiGroupsComponents.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
%META:TOPICINFO{author="ProjectContributor" date="1489712653" format="1.1" version="1"}%
%META:TOPICPARENT{name="WebHome"}%
---+ Wiki groups components.
Contains the active components used by %USERSWEB%.WikiGroups. To modify this
topic, copy it to %USERSWEB%.WikiGroupsComponents and edit the copy. It will
automatically be used.

<verbatim class="tml">
%STARTINCLUDE%
%TWISTY{
link="<img src='%ICONURLPATH{"persons"}%' /> %MAKETEXT{"Create a new group"}%"
mode="div"
%IF{"$expand='1'" then='start="show"'}%
}%

<sticky>
<form action='%SCRIPTURLPATH{"manage" topic="%USERSWEB%.WikiGroups"}%' method='post'>
<input type="hidden" name="action" value="addUserToGroup"/>
<input type="hidden" name="create" value="1"/>
<div class="foswikiFormSteps">
<div class="foswikiFormStep ">
<h3>%MAKETEXT{"Group name"}%</h3>
<input type="text" name="groupname" size="30" class="foswikiInputField" value="%URLPARAM{"groupname"}%" />
<div class="foswikiFormDescription">
*Note:*
A group name must be a [[%SYSTEMWEB%.WikiWord][WikiWord]] and *must* end in =...Group=.
New topics are based on %IF{"istopic %USERSWEB%.GroupTemplate" then="[[%USERSWEB%.GroupTemplate]]" else="[[%SYSTEMWEB%.GroupTemplate]]"}%
</div>
</div>
<div class="foswikiFormStep">
<h3>%MAKETEXT{"Members"}%</h3>
<input type="text" name="username" value="%URLPARAM{"username"}%" size="60" class="foswikiInputField" />
<div class="foswikiFormDescription">Comma separated list. You will be added to the group automatically to allow you to continue to manage the new group.</div>
</div>
<div class="foswikiFormStep">
<input class="foswikiSubmit" type="submit" value="%MAKETEXT{"Create group"}%"/>
</div>
<div class="foswikiFormStep foswikiLast">
<div class="foswikiFormDescription foswikiHelp">
*IMPORTANT NOTE:* Think twice before restricting write access to a web or a topic, because an open system where everybody can contribute is the essence of [[%SYSTEMWEB%.WikiCulture][WikiCulture]]. Experience shows that unrestricted write access works very well because:
* There is enough peer pressure to post only appropriate content.
* Content does not get lost because topics are under revision control.
* A topic revision can be undone by a member of the [[%USERSWEB%.AdminGroup][AdminGroup]] if necesssary.

*Related topics:* [[%SYSTEMWEB%.AccessControl][AccessControl]], [[%WEBPREFSTOPIC%]], [[%WIKIUSERSTOPIC%]], [[%SYSTEMWEB%.WikiCulture][WikiCulture]]

<div class="foswikiHelp">%X% If a large number of groups are configured, the rendering performance of this page can be significantly improved by disabling group maintenance from this page. Edit this topic for more information.</div>
</div>
</div>
</div>
</form></sticky> %ENDTWISTY%

%GROUPINFO{
header="<table class='foswikiTable wikiGroupsTable'>
<tr>
<th>%MAKETEXT{"Group"}%</th>
<th>%MAKETEXT{"Members"}%</th>
<th>%MAKETEXT{"Actions"}%</th>
</tr>$n"
format="<tr>
<td> $percntIF{\"not istopic '%USERSWEB%.$name'\" then=\"<nop>$name\" else=\"[[%USERSWEB%.$name][$name]]\"}$percnt</td>
<td>
$percntINCLUDE{\"%SYSTEMWEB%.GroupViewTemplate, %USERSWEB%.GroupViewTemplate\"
section=\"rendergroup\"
groupname=\"$name\"
allowschange=\"$allowschange\"
}$percnt
</td>
<td class=\"wikiGroupsActions\">
$percntINCLUDE{\"%SYSTEMWEB%.GroupViewTemplate, %USERSWEB%.GroupViewTemplate\"
section=\"groupactions\"
groupname=\"$name\"
allowschange=\"$allowschange\"
}$percnt
</td>
</tr>"
footer="</table>"
separator="$n"
}%

%STOPINCLUDE%
</verbatim>
3 changes: 2 additions & 1 deletion core/lib/Foswiki/Contrib/core/MANIFEST
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ bin/viewfileauth 0555
data/Main/AdminGroup.txt 0644
data/Main/AdminUser.txt 0644
data/Main/AdminUserLeftBar.txt 0644
data/Main/GroupViewTemplate.txt 0644
data/Main/ProjectContributor.txt 0644
data/Main/SitePreferences.txt 0644
data/Main/UnknownUser.txt 0644
Expand Down Expand Up @@ -112,6 +111,7 @@ data/System/FrequentlyAskedQuestions.txt 0644
data/System/GlossaryOfTerms.txt 0644
data/System/GoBox.txt 0644
data/System/GoodStyle.txt 0644
data/System/GroupViewTemplate.txt 0644
data/System/HierarchicalNavigation.txt 0644
data/System/HierarchicalNavigationChildExample.txt 0644
data/System/IfStatements.txt 0644
Expand Down Expand Up @@ -316,6 +316,7 @@ data/System/WebTopicEditTemplate.txt 0644
data/System/WebTopicList.txt 0644
data/System/WelcomeGuest.txt 0644
data/System/WikiCulture.txt 0644
data/System/WikiGroupsComponents.txt 0644
data/System/WikiName.txt 0644
data/System/WikiSyntaxSummary.txt 0644
data/System/WikiWord.txt 0644
Expand Down

0 comments on commit 0d20ce7

Please sign in to comment.