Skip to content

Commit 0422807

Browse files
committedJun 19, 2012
Revert "group() function Survey::ExpressionEngine that returns 1/0 depending on whether the current user is in a group" -- wrong branch.
This reverts commit eaa29c5. Conflicts: docs/changelog/7.x.x.txt

File tree

3 files changed

+1
-38
lines changed

3 files changed

+1
-38
lines changed
 

‎docs/changelog/7.x.x.txt

-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
7.10.25
22
- fixed: if user1 adds user2 as a friend, user2 doesn't see user1 as a friend
33
- fixed: data sync bug in WebGUI::User::friends
4-
- added: group() function for Survey::ExpressionEngine to test group membership
54
- added: give WebGUI::PseudoRequest a hostname method
65
- fixed: don't clobber the request handler if WebGUI::Test was loaded inside of mod_perl
76
- fixed #12365: editing a metadata may cause a fatal error (Arjan Widlak / United Knowledge)

‎lib/WebGUI/Asset/Wobject/Survey/ExpressionEngine.pm

-29
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ my $validate;
3636
my $validTargets;
3737
my $otherInstances;
3838
my $tags;
39-
my $groups;
4039

4140
=head2 value
4241
@@ -353,24 +352,6 @@ sub avg {
353352
return sum(@vals) / @vals;
354353
}
355354

356-
=head2 group ($name)
357-
358-
Utility sub that returns a boolean indicating whether the user taking the survey is a member of a specified group, by name
359-
360-
=head3 $name
361-
362-
The name of the group
363-
364-
=cut
365-
366-
sub group {
367-
my ($name) = @_;
368-
my $value = grep( $_ eq $name, @$groups ) ? 1 : 0;
369-
# warn "group($name) resolves to [$value]; groups = " . join( " ", map ">>$_<<", @$groups ) . " for userId " . $session->user->getId;
370-
$session->log->debug("group($name) resolves to [$value]; groups = @$groups");
371-
return $value;
372-
}
373-
374355
=head2 round
375356
376357
Utility sub shared with Safe compartment to allows expressions to easily round numbers
@@ -461,15 +442,6 @@ sub run {
461442
$validTargets = $opts->{validTargets};
462443
$tags = $opts->{tags} || {};
463444
$otherInstances = {};
464-
$groups = $session->db->buildArrayRef( qq{
465-
select groupName
466-
from groupings
467-
join groups using (groupId)
468-
where groupings.userId = ?
469-
and expireDate > now()
470-
}, [
471-
$session->user->getId,
472-
] );
473445

474446
if ( !$session->config->get('enableSurveyExpressionEngine') ) {
475447
$session->log->debug('enableSurveyExpressionEngine config option disabled, skipping');
@@ -497,7 +469,6 @@ sub run {
497469
$compartment->share('&restart');
498470
$compartment->share('&avg');
499471
$compartment->share('&round');
500-
$compartment->share('&group');
501472

502473
# Give them all of List::Util too
503474
$compartment->share_from( 'List::Util',

‎t/Asset/Wobject/Survey/ExpressionEngine.t

+1-8
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ my $session = WebGUI::Test->session;
2222

2323
#----------------------------------------------------------------------------
2424
# Tests
25-
my $tests = 62;
25+
my $tests = 60;
2626
plan tests => $tests + 1;
2727

2828
#----------------------------------------------------------------------------
@@ -237,13 +237,6 @@ cmp_deeply( $e->run( $session, qq{jump {scoreX('$url', ext_s0) == 200} target},
237237
cmp_deeply( $e->run( $session, qq{jump {taggedX('$url', ext_tag) == 199} target}, {userId => $user->userId} ),
238238
{ jump => 'target', tags => {} }, 'external tag lookups work too' );
239239

240-
# group() utility function
241-
$session->user( { userId => 3 });
242-
cmp_deeply( $e->run( $session, qq{jump { group('Admins') } target}, ),
243-
{ jump => 'target', tags => { }, }, 'group() function recognizes us as Admins' );
244-
cmp_deeply( $e->run( $session, qq{jump { group('Space Aliens') } target}, ),
245-
{ jump => undef, tags => { }, }, 'group() function recognizes that we are not Space Aliens' );
246-
247240
# Test for nasty bugs caused by file-scoped lexicals not being properly initialised in L<ExpressionEngine::run>
248241
{
249242
# Create a second test user

0 commit comments

Comments
 (0)
Please sign in to comment.