Skip to content

Commit

Permalink
Item2172: can now create a new group using the same manage API, inclu…
Browse files Browse the repository at this point in the history
…ding specifying an initial set of users

git-svn-id: http://svn.foswiki.org/trunk@5170 0b4bb1d4-4e5a-0410-9cc4-b2b747904278
  • Loading branch information
SvenDowideit authored and SvenDowideit committed Sep 29, 2009
1 parent 63f418f commit 54de07e
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 9 deletions.
Expand Up @@ -719,10 +719,10 @@ sub addUserToGroup {
my $groupTopicObject =
Foswiki::Meta->load( $this->{session}, $Foswiki::cfg{UsersWebName},
$groupName );

return 0
if ( !$groupTopicObject->haveAccess( 'CHANGE', $user ) )
; #can't change topic.

my $membersString =
$groupTopicObject->getPreference('GROUP') . ', '
. $usersObj->getWikiName($cuid);
Expand Down
13 changes: 7 additions & 6 deletions core/data/Main/WikiGroups.txt
Expand Up @@ -11,18 +11,19 @@ These groups can be used to define fine grained [[%SYSTEMWEB%.AccessControl][Acc
separator="$n"
}%

<form action="%SCRIPTURLPATH{"edit"}%/%WEB%/" method="get">
<form action="%SCRIPTURLPATH{"manage"}%/%WEB%/%TOPIC%" method="POST">

<div class="foswikiFormSteps">
<div class="foswikiFormStep foswikiLast">
%TABLE{databg="" cellborder="0" tableborder="0"}%
| New Group: |<input type="text" name="topic" value="NameGroup" size="40" class="foswikiInputField" />&nbsp;<input class="foswikiSubmit" type="submit" value="Add"/> |
| New Group: | <input type="text" name="groupname" size="20" class="foswikiInputField"/> |
| Users in Group: (Comma separated) | <input type="text" name="username" value="" size="60" class="foswikiInputField" /> |
| | <input class="foswikiSubmit" type="submit" value="Add"/> |
| |%ICON{"warning"}% *Note:* A group topic name must be a [[%SYSTEMWEB%.WikiWord][WikiWord]] and *must* end in =...Group=. New topics are based on [[GroupTemplate]] |

<input type="hidden" name="templatetopic" value="GroupTemplate"/>
<input type="hidden" name="topicparent" value="%TOPIC%"/>
<input type="hidden" name="onlywikiname" value="on" />
<input type="hidden" name="onlynewtopic" value="on" />
<input type="hidden" name="action" value="addUserToGroup"/>
<input type="hidden" name="create" value="1"/>

</div>
</div>
</form>
Expand Down
1 change: 1 addition & 0 deletions core/data/System/CommandAndCGIScripts.txt
Expand Up @@ -164,6 +164,7 @@ add a user / list of users to a group
| *Parameter* | *Description* | *Default* |
| =username= | *list* of usernames/wikinames to add to group | none - error if not set |
| =groupname= |groupname to change | none - error if not set |
| =create= | create the group if it doesn't exist | false |

---++++ =action=removeUserFromGroup=
remove a user / list of users to a group
Expand Down
5 changes: 3 additions & 2 deletions core/lib/Foswiki/UI/Register.pm
Expand Up @@ -566,6 +566,8 @@ sub addUserToGroup {
my $user = $session->{user};

my @userNames = $query->param('username');
my $groupName = $query->param('groupname');
my $create = Foswiki::isTrue( $query->param('create'), 0);
if (
(length(@userNames) <= 0) or
($userNames[0] eq '')){
Expand All @@ -574,14 +576,13 @@ sub addUserToGroup {
if (length(@userNames) == 1) {
@userNames = split(/,\s+/, $userNames[0]);
}
my $groupName = $query->param('groupname');
if (!$groupName or $groupName eq '') {
throw Foswiki::OopsException( 'attention', def => 'no_group_specified_for_add_to_group' );
}
my @failed;
foreach my $u (@userNames) {
try {
if (!Foswiki::Func::addUserToGroup($u, $groupName)) {
if (!Foswiki::Func::addUserToGroup($u, $groupName, $create)) {
push(@failed, $u);
# Log the error
$session->logger->log( 'warning',
Expand Down
3 changes: 3 additions & 0 deletions core/templates/messages.tmpl
Expand Up @@ -450,6 +450,9 @@

%MAKETEXT{"Please check to ensure you have permssion to modify the group."}%

%MAKETEXT{"See %MAINWEB%.WikiGroups to see the result."}%%TMPL:END%


%TMPL:END%

%TMPL:DEF{"added_users_to_group"}%
Expand Down

0 comments on commit 54de07e

Please sign in to comment.