From 0a0cb09397284df378c00f09e812c9d76ca2a556 Mon Sep 17 00:00:00 2001 From: David Delikat Date: Wed, 22 Feb 2012 17:55:25 +0000 Subject: [PATCH 1/7] changed plan from 53 to 57 --- t/Asset/Wobject/Survey.t | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/t/Asset/Wobject/Survey.t b/t/Asset/Wobject/Survey.t index 0b615412f0..3af842adde 100644 --- a/t/Asset/Wobject/Survey.t +++ b/t/Asset/Wobject/Survey.t @@ -17,7 +17,7 @@ my $session = WebGUI::Test->session; #---------------------------------------------------------------------------- # Tests -plan tests => 53; +plan tests => 57; #---------------------------------------------------------------------------- # put your tests here From 1612067b3a5636e118cc8bb0f9da959b6f048f00 Mon Sep 17 00:00:00 2001 From: David Delikat Date: Thu, 23 Feb 2012 20:42:59 +0000 Subject: [PATCH 2/7] assign default empty array to priv properties --- lib/WebGUI/Middleware/WGAccess.pm | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/WebGUI/Middleware/WGAccess.pm b/lib/WebGUI/Middleware/WGAccess.pm index a51fed001d..686c2a8281 100644 --- a/lib/WebGUI/Middleware/WGAccess.pm +++ b/lib/WebGUI/Middleware/WGAccess.pm @@ -59,6 +59,10 @@ sub call { else { $privs = JSON->new->utf8->decode($contents); } + # in some cases there is nothing but state; default each list to an empty array + $privs->{user} ||= [ ]; + $privs->{groups} ||= [ ]; + $privs->{assets} ||= [ ]; return @$r = (403, [ 'Content-Type' => 'text/plain' ], [ 'Forbidden' ]) if $privs->{state} eq 'trash'; From e6535e4d1897ec86cc7ce21981db826b4ef93ccd Mon Sep 17 00:00:00 2001 From: David Delikat Date: Thu, 23 Feb 2012 22:36:59 +0000 Subject: [PATCH 3/7] removed WebGUI::Utility and WebGUI::Cache because they no longer exist; no other changes as all tests are skipped --- t/Group/ldap_groups.t | 2 -- 1 file changed, 2 deletions(-) diff --git a/t/Group/ldap_groups.t b/t/Group/ldap_groups.t index 998fe4cb8e..a6cbe6987f 100644 --- a/t/Group/ldap_groups.t +++ b/t/Group/ldap_groups.t @@ -14,11 +14,9 @@ use lib "$FindBin::Bin/../lib"; use WebGUI::Test; use WebGUI::Session; -use WebGUI::Utility; use WebGUI::User; use WebGUI::Group; -use WebGUI::Cache; use Test::More skip_all => 'Disabled until the test LDAP server is rejuvenated'; use Test::Deep; From fec47c110d283f2b0c5aff3865d9c692087583bb Mon Sep 17 00:00:00 2001 From: David Delikat Date: Thu, 23 Feb 2012 22:39:56 +0000 Subject: [PATCH 4/7] fixed test for approval --- t/Asset/EMSSubmissionForm.t | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/t/Asset/EMSSubmissionForm.t b/t/Asset/EMSSubmissionForm.t index f81a6b2d26..57df258664 100644 --- a/t/Asset/EMSSubmissionForm.t +++ b/t/Asset/EMSSubmissionForm.t @@ -348,7 +348,7 @@ $sub1 = $sub1->cloneFromDb; diag $sub1->submissionStatus; diag $sub1->ticketId; diag $sub1->getRevisionCount; -is( $sub1->get('submissionStatus'),'created','approval successfull'); +is( $sub1->get('submissionStatus'),'approved','approval successfull'); my $ticket = eval { WebGUI::Asset->newById($session, $sub1->get('ticketId')); }; my $e = Exception::Class->caught(); From 2274bd59ecb5ad5b83717758fe4d4d443ab8d8e2 Mon Sep 17 00:00:00 2001 From: David Delikat Date: Fri, 24 Feb 2012 15:09:28 +0000 Subject: [PATCH 5/7] use correct name to get auth instance --- lib/WebGUI/Operation/Settings.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/WebGUI/Operation/Settings.pm b/lib/WebGUI/Operation/Settings.pm index 856dc5c0d7..9520cbc8da 100644 --- a/lib/WebGUI/Operation/Settings.pm +++ b/lib/WebGUI/Operation/Settings.pm @@ -656,7 +656,7 @@ sub www_editSettings { # Get fieldsets for avaiable auth methods foreach my $authName (@{$session->config->get("authMethods")}) { - my $authInstance = WebGUI::Operation::Auth::getInstance($session,$_,1); + my $authInstance = WebGUI::Operation::Auth::getInstance($session,$authName,1); $tabform->getTab( "auth" )->addFieldset( $authInstance->editUserSettingsForm, name => $authName, label => $authName ); } From 26a104229743c7be424351c82f21c9814406b889 Mon Sep 17 00:00:00 2001 From: David Delikat Date: Fri, 24 Feb 2012 16:14:15 +0000 Subject: [PATCH 6/7] fixed user field update --- lib/WebGUI/Auth/Facebook.pm | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/WebGUI/Auth/Facebook.pm b/lib/WebGUI/Auth/Facebook.pm index 19ac2bc944..8dfd18d78b 100644 --- a/lib/WebGUI/Auth/Facebook.pm +++ b/lib/WebGUI/Auth/Facebook.pm @@ -46,9 +46,9 @@ sub createFacebookUser { my ( $self, $fbuser ) = @_; my $user = WebGUI::User->create( $self->session ); $user->username( $fbuser->{name} ); - $user->get('email', $fbuser->{email}); - $user->get('firstName', $fbuser->{first_name}); - $user->get('lastName', $fbuser->{last_name}); + $user->update('email', $fbuser->{email}); + $user->update('firstName', $fbuser->{first_name}); + $user->update('lastName', $fbuser->{last_name}); $self->update( "facebookUserId" => $fbuser->{id}, ); From 5fb47903a7c8012f5b1f06df249dd75ba7f85055 Mon Sep 17 00:00:00 2001 From: David Delikat Date: Fri, 2 Mar 2012 17:16:51 +0000 Subject: [PATCH 7/7] fixed related link duplication where links have group view restrictions --- docs/changelog/8.x.x.txt | 1 + lib/WebGUI/Asset/Event.pm | 6 +++++- t/Asset/Event.t | 24 ++++++++++++++++++++---- 3 files changed, 26 insertions(+), 5 deletions(-) diff --git a/docs/changelog/8.x.x.txt b/docs/changelog/8.x.x.txt index d6a39702f8..7872ba69cb 100644 --- a/docs/changelog/8.x.x.txt +++ b/docs/changelog/8.x.x.txt @@ -1,4 +1,5 @@ 8.0.0 + - #12010 - fixed related link duplication where links have group view restrictions - #10012 - larger meta data values for multi-value fields - #12310 - fixed rendering and submit button on user edit/add form - Replaced the existing caching mechanism with memcached, which results in a 400% improvement to cache speed. See migration.txt for API changes and gotcha.txt for prereq changes. diff --git a/lib/WebGUI/Asset/Event.pm b/lib/WebGUI/Asset/Event.pm index aa2a2397ca..0afce15916 100644 --- a/lib/WebGUI/Asset/Event.pm +++ b/lib/WebGUI/Asset/Event.pm @@ -469,7 +469,7 @@ override duplicate => sub { my $newAsset = super(); my $newStorage = $self->getStorageLocation->copy; $newAsset->update({storageId=>$newStorage->getId}); - my $links = $self->getRelatedLinks(); + my $links = $self->getRelatedLinks('nolimit'); my $id = $self->session->id; foreach my $link (@{ $links }) { $link->{new_event} = 1; @@ -1125,12 +1125,16 @@ Gets an arrayref of hashrefs of related links. sub getRelatedLinks { my $self = shift; + my $limitflag = shift || 'yes'; my $sth = $self->session->db->prepare( "SELECT * FROM Event_relatedlink WHERE assetId=? ORDER BY sequenceNumber", ); $sth->execute([ $self->getId ]); + if( $limitflag eq 'nolimit' ) { + return [ map { $sth->hashRef } ( 1..$sth->rows ) ]; + } my @links; while ( my $link = $sth->hashRef ) { diff --git a/t/Asset/Event.t b/t/Asset/Event.t index 1966295695..c0f9b82360 100644 --- a/t/Asset/Event.t +++ b/t/Asset/Event.t @@ -15,7 +15,7 @@ use WebGUI::Test; use Test::More; # increment this value for each test you create use Test::Deep; -plan tests => 30; +plan tests => 31; use WebGUI::Session; use WebGUI::Storage; @@ -174,10 +174,11 @@ $event6->setRelatedLinks([ sequenceNumber => 2, linkurl => 'http://www.somewhere.com', linktext => 'Another great link', - groupIdView => '7', + groupIdView => '2', eventlinkId => '28', }, ]); +$session->user({userId => 3}); # admin can see all the links cmp_deeply( $event6->getRelatedLinks(), [{ @@ -192,12 +193,25 @@ cmp_deeply( sequenceNumber => 2, linkURL => 'http://www.somewhere.com', linktext => 'Another great link', - groupIdView => '7', + groupIdView => '2', eventlinkId => '28', assetId => $event6->getId, }], 'related links stored in the database correctly' ); +$session->user({userId => 1}); # visitor can only see one link +cmp_deeply( + $event6->getRelatedLinks(), + [{ + sequenceNumber => 1, + linkURL => 'http://www.nowhere.com', + linktext => 'Great link', + groupIdView => '7', + eventlinkId => '27', + assetId => $event6->getId, + }], + 'related links:user access restriction works' +); ####################################### # @@ -208,6 +222,7 @@ cmp_deeply( my $event6b = $event6->duplicate(); ok($session->id->valid($event6b->get('storageId')), 'duplicated event got a valid storageId'); isnt($event6b->get('storageId'), $event6->get('storageId'), 'duplicating an asset creates a new storage location'); +$session->user({userId => 3}); # admin can see all the links cmp_deeply( $event6b->getRelatedLinks(), [{ @@ -222,12 +237,13 @@ cmp_deeply( sequenceNumber => 2, linkURL => 'http://www.somewhere.com', linktext => 'Another great link', - groupIdView => '7', + groupIdView => '2', eventlinkId => ignore(), assetId => $event6b->getId, }], 'duplicated event has relatedLinks' ); +$session->user({userId => 1}); # run remaining tests as visitor ####################################### #