Skip to content

Commit

Permalink
Item8802: use english to select UI type for add users to groups on re…
Browse files Browse the repository at this point in the history
…gistration - none, automatic, one and multiple

git-svn-id: http://svn.foswiki.org/trunk@7088 0b4bb1d4-4e5a-0410-9cc4-b2b747904278
  • Loading branch information
SvenDowideit authored and SvenDowideit committed Apr 5, 2010
1 parent 0da1c62 commit c28d817
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 17 deletions.
24 changes: 18 additions & 6 deletions TopicUserMappingContrib/data/System/DefaultUserRegistration.txt
Expand Up @@ -40,7 +40,7 @@ Other sections define the fields and extra info text.
%IF{'context passwords_modifyable' then='%INCLUDE{"%TOPIC%" section="requiredField_password"}%' else='<!-- -->'}%
<!-- START OPTIONAL FIELDS -->
<!-- remove EXCLUDED_ from section names to show fields -->
%IF{'$REGISTRATIONGROUPTYPE !="disabled"' then='%INCLUDE{"%TOPIC%" section="extraField_groups" warn="off"}%' else='<!-- -->'}%
%IF{'$REGISTRATIONGROUPTYPE !="none"' then='%INCLUDE{"%TOPIC%" section="extraField_groups" warn="off"}%' else='<!-- -->'}%
%INCLUDE{"%TOPIC%" section="EXCLUDED_extraField_organisationName" warn="off"}%
%INCLUDE{"%TOPIC%" section="EXCLUDED_extraField_organisationUrl" warn="off"}%
%INCLUDE{"%TOPIC%" section="EXCLUDED_extraField_country" warn="off"}%
Expand Down Expand Up @@ -187,14 +187,18 @@ TODO: should redo this topic to look different between a guest registering thems
TODO: it might make sense to separate this into several sections, dependent on the REGISTRATIONGROUPTYPE setting.
TODO: it would be nice to have a red warning if the rego agent is in the admin group telling the admin that this feature is disabled unless they remove the rego user from that group (die to security issues)
(and confirming to them that this is due to an upgrade)


Instead of choosing between "disabled", "hidden", "checkbox" and "radio" - which is html/form lingo, we can provide more meaningful choices like "none", "automatic", "multiple" and "one"

%STARTSECTION{"extraField_groups"}%%GROUPINFO{
header="$percntINCLUDE{$quot%WEB%.%TOPIC%$quot section=$quotrendergroupheader$quot}$percnt"
header="$percntINCLUDE{$quot%WEB%.%TOPIC%$quot section=$quot%IF{"'%REGISTRATIONGROUPTYPE%' = 'automatic'" then="hidden"}%rendergroupheader$quot multiple=$quot%IF{"'%REGISTRATIONGROUPTYPE%' = 'multiple'" then="Groups" else="Group"}%$quot}$percnt"
footer="$percntINCLUDE{$quot%WEB%.%TOPIC%$quot section=$quotrendergroupfooter$quot}$percnt"
format="$percntINCLUDE{$quot%WEB%.%TOPIC%$quot
section=$quotrendergroup$quot
groupname=$quot$name$quot
allowschange=$quot$allowschange%IF{"$ WIKINAME='WikiGuest'" then="(RegistrationAgent)"}%$quot
inputtype=$quot%IF{"'%REGISTRATIONGROUPTYPE%' = 'automatic'" then="hidden"}%%IF{"'%REGISTRATIONGROUPTYPE%' = 'one'" then="radio"}%%IF{"'%REGISTRATIONGROUPTYPE%' = 'multiple'" then="checkbox"}%$quot
}$percnt"
separator=" "
}%%ENDSECTION{"extraField_groups"}%
Expand All @@ -206,10 +210,13 @@ Section nochange


Section rendergroup
parameters: groupname, allowschange
parameters: groupname, allowschange, inputtype

%STARTSECTION{"rendergroup"}%%IF{"%allowschange% = 1" then="$percntINCLUDE{$quot%WEB%.%TOPIC%$quot
section=$quotchangegroup$quot groupname=$quot%groupname%$quot inputtype=$quot%REGISTRATIONGROUPTYPE%$quot}$percnt"}%%ENDSECTION{"rendergroup"}%
%STARTSECTION{"rendergroup"}%%IF{
"%allowschange% = 1"
then="$percntINCLUDE{$quot%WEB%.%TOPIC%$quot
section=$quotchangegroup$quot groupname=$quot%groupname%$quot inputtype=$quot%inputtype%$quot}$percnt"
}%%ENDSECTION{"rendergroup"}%


Section changegroup
Expand All @@ -222,7 +229,7 @@ Section changegroup
Section rendergroupheader
parameters:

%STARTSECTION{"rendergroupheader"}%<li><label for="Twk0AddToGroups">%MAKETEXT{"Wiki Groups to join"}%</label>
%STARTSECTION{"rendergroupheader"}%<li><label for="Twk0AddToGroups">%MAKETEXT{"Select Wiki [_1] to join" args="%multiple%"}%</label>
<div class="joinGroups">%ENDSECTION{"rendergroupheader"}%


Expand All @@ -231,6 +238,11 @@ Section rendergroupfooter

%STARTSECTION{"rendergroupfooter"}%</div></li>%ENDSECTION{"rendergroupfooter"}%

Section hiddenrendergroupheader
parameters:

%STARTSECTION{"hiddenrendergroupheader"}%<li class="foswikiHidden">
<div class="joinGroups">%ENDSECTION{"hiddenrendergroupheader"}%


Optional field organisation name
Expand Down
4 changes: 2 additions & 2 deletions TopicUserMappingContrib/lib/Foswiki/Users/TopicUserMapping.pm
Expand Up @@ -769,7 +769,7 @@ sub addUserToGroup {

my $usersObj = $this->{session}->{users};

#print STDERR "$user, aka(".$usersObj->getWikiName($user).") is TRYING to add $cuid aka(".$usersObj->getWikiName($cuid).") to $groupName\n";
print STDERR "$user, aka(".$usersObj->getWikiName($user).") is TRYING to add $cuid aka(".$usersObj->getWikiName($cuid).") to $groupName\n" if DEBUG;

if (
$usersObj->isGroup($groupName)
Expand All @@ -788,7 +788,7 @@ sub addUserToGroup {

if ( !$groupTopicObject->haveAccess( 'CHANGE', $user ) ) {
#can't change topic.
#print STDERR "eee: $user does not have change access?\n";
print STDERR "eee: $user does not have change access?\n" if DEBUG;
return 0
}

Expand Down
10 changes: 5 additions & 5 deletions core/data/System/DefaultPreferences.txt
Expand Up @@ -170,11 +170,11 @@ Preference settings local to your site should be set in [[%LOCALSITEPREFS%]] (th

---+++ Registration configuration options
* Set REGISTRATIONGROUPS = (not implemented yet..)
* Users can be automatically added to the Groups listed above (by setting the =REGISTRATIONGROUPTYPE= setting to =hidden=), or
Users can select _one_ of the Groups (by setting to =radio=) or
Users can select Multiple Groups to join when they register (by setting to =checkbox=) or
The Add user to Groups feature can be disabled (by setting to =disabled=)
* Set REGISTRATIONGROUPTYPE = disabled
* Users can be automatically added to the Groups listed above (by setting the =REGISTRATIONGROUPTYPE= setting to =automatic=), or
Users can select _one_ of the Groups (by setting to =one=) or
Users can select Multiple Groups to join when they register (by setting to =multiple=) or
The Add user to Groups feature can be disabled (by setting to =none=)
* Set REGISTRATIONGROUPTYPE = none

---+++ HTTP-<nop>EQUIV Settings

Expand Down
9 changes: 5 additions & 4 deletions core/lib/Foswiki/UI/Register.pm
Expand Up @@ -785,6 +785,11 @@ sub _complete {
#combined with this feature, registering users would be able to join the AdminGroup.
#so disable th AddUserToGroupOnRegistration if the rego agent is still admin :(
$enableAddToGroup = !$session->{users}->isAdmin($regoAgent);
if (!$enableAddToGroup) {
#TODO: should really tell the user too?
$session->logger->log( 'warning',
"Registration failed: ERROR: can't add user to groups ($data->{AddToGroups}) because the $Foswiki::cfg{Register}{RegistrationAgentWikiName} is in the $Foswiki::cfg{SuperAdminGroup}");
}
}

if (($enableAddToGroup) and ($data->{AddToGroups})) {
Expand All @@ -797,9 +802,6 @@ sub _complete {
$session->{user} = $safe;
};
}
} else {
#TODO: should really tell the user too?
#print STDERR "ERROR: can't add user to groups ($data->{AddToGroups}) because the $Foswiki::cfg{Register}{RegistrationAgentWikiName} is in the $Foswiki::cfg{SuperAdminGroup}\n";
}
}
catch Error::Simple with {
Expand Down Expand Up @@ -1416,7 +1418,6 @@ sub _getDataFromQuery {

# deal with multivalue fields like checkboxen
my $value = join( ',', @values );
print STDERR "--- $key = $value \n";
# Note: field values are unvalidated (and therefore tainted).
# This is because the registration code does not have enough
# information to validate the data - for example, it cannot
Expand Down

0 comments on commit c28d817

Please sign in to comment.