GroupText macro now returns an error message if group cannot be found. includes test

This commit is contained in:
Colin Kuskie 2006-07-13 05:23:49 +00:00
parent 2555a7d5b4
commit 3dd45bad6d
4 changed files with 24 additions and 9 deletions

View file

@ -42,13 +42,17 @@ Text to be shown to someone not in the group.
#-------------------------------------------------------------------
sub process {
my $session = shift;
my @param = @_;
my ($groupId) = $session->dbSlave->quickArray("select groupId from groups where groupName=".$session->db->quote($param[0]));
$groupId = 3 if ($groupId eq "");
if ($session->user->isInGroup($groupId)) {
return $param[1];
} else {
return $param[2];
my ($groupName, $inGroupText, $outGroupText ) = @_;
my ($groupId) = $session->dbSlave->quickArray("select groupId from groups where groupName=?",[$groupName]);
if ($groupId eq "") {
my $i18n = WebGUI::International->new($session, 'Macro_GroupText');
return sprintf $i18n->get('group not found'), $groupName
}
elsif ($session->user->isInGroup($groupId)) {
return $inGroupText;
}
else {
return $outGroupText;
}
}

View file

@ -7,6 +7,12 @@ our $I18N = {
lastUpdated => 1128838520,
},
'group not found' => {
message => q|Group %s was not found|,
lastUpdated => 1112466408,
context => q|Error message when a group is not found during a by-name lookup of groups.|,
},
'group text title' => {
message => q|Group Text Macro|,
lastUpdated => 1112466408,