diff --git a/docs/changelog/7.x.x.txt b/docs/changelog/7.x.x.txt index 4d3b02862..2b0e3c56f 100644 --- a/docs/changelog/7.x.x.txt +++ b/docs/changelog/7.x.x.txt @@ -91,6 +91,9 @@ - All group operations now show group id and name (Yung Han Khoe) - Added: On the commit screen of version tags, you can now set a Start/End Time for when the tag should appear. - Added: WaitUntil workflow activity associated with version tags that waits until the start or end time of a version tag has been reached before continuing the workflow + - added: Show a Message when users login + - added: Two new approval activities, ByCommitterGroup and ByLineage + - fixed: Gallery Search form doesn't work right in IE6 7.5.10 - fix: Syntax error in GetCsMail diff --git a/docs/upgrades/upgrade_7.5.10-7.5.11.pl b/docs/upgrades/upgrade_7.5.10-7.5.11.pl index 954976e03..1350355bc 100644 --- a/docs/upgrades/upgrade_7.5.10-7.5.11.pl +++ b/docs/upgrades/upgrade_7.5.10-7.5.11.pl @@ -68,11 +68,63 @@ addAssetManager( $session ); removeSqlForm($session); migratePaymentPlugins( $session ); removeRecurringPaymentActivity( $session ); +addLoginMessage( $session ); +addNewApprovalActivities( $session ); addUserListWobject( $session ); addInheritUrlFromParent( $session ); finish($session); # this line required +#---------------------------------------------------------------------------- +# Add two new approval activities +sub addNewApprovalActivities { + my $session = shift; + print "\tAdding new approval activities... " unless $quiet; + + my $activities = $session->config->get( "workflowActivities" ); + push @{ $activities->{ 'WebGUI::VersionTag' } }, + 'WebGUI::Workflow::Activity::RequestApprovalForVersionTag::ByCommitterGroup', + 'WebGUI::Workflow::Activity::RequestApprovalForVersionTag::ByLineage', + ; + + $session->config->set( "workflowActivities", $activities ); + + print "DONE!\n" unless $quiet; +} + +#---------------------------------------------------------------------------- +# Add the necessary settings and profile fields for the new login message +sub addLoginMessage { + my $session = shift; + print "\tAdding Login Message... " unless $quiet; + + # Add some settings + my %settings = ( + showMessageOnLogin => '0', + showMessageOnLoginTimes => '0', + showMessageOnLoginBody => '', + ); + for my $setting ( keys %settings ) { + $session->setting->add( $setting, $settings{ $setting } ); + } + + # Add a profile field + WebGUI::ProfileField->create( $session, + 'showMessageOnLoginSeen', + { + fieldType => 'integer', + dataDefault => '0', + visible => '0', + editable => '0', + protected => '1', + required => '0', + label => 'WebGUI::International::get("showMessageOnLoginSeen","Auth");', + }, + ); + + print "DONE!\n" unless $quiet; +} + #---------------------------------------------------------------------------- sub removeSqlForm { my $session = shift; diff --git a/lib/WebGUI/Asset/Wobject/Gallery.pm b/lib/WebGUI/Asset/Wobject/Gallery.pm index b2e160109..6f97ea098 100644 --- a/lib/WebGUI/Asset/Wobject/Gallery.pm +++ b/lib/WebGUI/Asset/Wobject/Gallery.pm @@ -994,7 +994,15 @@ sub www_search { # NOTE: Search form is added as part of getTemplateVars() # Get search results, if necessary. - if ($form->get("submit")) { + my $doSearch + = ( + $form->get( 'basicSearch' ) || $form->get( 'keywords' ) + || $form->get( 'title' ) || $form->get( 'description' ) + || $form->get( 'userId' ) || $form->get( 'className' ) + || $form->get( 'creationDate_after' ) || $form->get( 'creationDate_before' ) + ); + + if ( $doSearch ) { # Keywords to search on my $keywords = join " ", $form->get('basicSearch'), $form->get('keywords'), @@ -1032,7 +1040,7 @@ sub www_search { # Build a URL for the pagination my $url = $self->getUrl( - 'func=search;submit=1;' + 'func=search;' . 'basicSearch=' . $form->get('basicSearch') . ';' . 'keywords=' . $form->get('keywords') . ';' . 'title=' . $form->get('title') . ';' diff --git a/lib/WebGUI/Asset/Wobject/GalleryAlbum.pm b/lib/WebGUI/Asset/Wobject/GalleryAlbum.pm index e03fbea08..d2b6c38b0 100644 --- a/lib/WebGUI/Asset/Wobject/GalleryAlbum.pm +++ b/lib/WebGUI/Asset/Wobject/GalleryAlbum.pm @@ -411,7 +411,21 @@ sub getFileIds { my $self = shift; my $gallery = $self->getParent; - return $self->getLineage( ['descendants'], { } ); + # Deal with "pending" files. + my %pendingRules; + if ( $self->canEdit ) { + $pendingRules{ statusToInclude } = [ 'pending', 'approved' ]; + } + else { + $pendingRules{ statusToInclude } = [ 'pending', 'approved' ]; + $pendingRules{ whereClause } = q{ + ( + status = "approved" || ownerUserId = "} . $self->session->user->userId . q{" + ) + }; + } + + return $self->getLineage( ['descendants'], { (%pendingRules) } ); } #---------------------------------------------------------------------------- diff --git a/lib/WebGUI/Auth.pm b/lib/WebGUI/Auth.pm index 70b6d7186..5af7aecea 100644 --- a/lib/WebGUI/Auth.pm +++ b/lib/WebGUI/Auth.pm @@ -31,6 +31,10 @@ use WebGUI::Operation::Profile; use WebGUI::Workflow::Instance; use WebGUI::Inbox; +# Profile field name for the number of times the showMessageOnLogin has been +# seen. +my $LOGIN_MESSAGE_SEEN = 'showMessageOnLoginSeen'; + =head1 NAME Package WebGUI::Auth @@ -296,16 +300,20 @@ sub createAccountSave { } - # If we have a redirectAfterLogin, redirect the user - if ($self->session->form->get('returnUrl')) { + # If we have something to do after login, do it + if ( $self->session->setting->get( 'showMessageOnLogin' ) ) { + return $self->showMessageOnLogin; + } + elsif ($self->session->form->get('returnUrl')) { $self->session->http->setRedirect( $self->session->form->get('returnUrl') ); $self->session->scratch->delete("redirectAfterLogin"); } elsif ($self->session->scratch->get("redirectAfterLogin")) { my $url = $self->session->scratch->delete("redirectAfterLogin"); $self->session->http->setRedirect($url); - return undef; - } else { + return undef; + } + else { $self->session->http->setStatus(201,"Account Registration Successful"); } @@ -694,16 +702,7 @@ sub login { $self->session->http->setRedirect($currentUrl); } - # Set the proper redirect - if ($self->session->form->get('returnUrl')) { - $self->session->http->setRedirect( $self->session->form->get('returnUrl') ); - $self->session->scratch->delete("redirectAfterLogin"); - } - elsif ($self->session->scratch->get("redirectAfterLogin")) { - $self->session->http->setRedirect($self->session->scratch->get("redirectAfterLogin")); - $self->session->scratch->delete("redirectAfterLogin"); - } - + # Run on login my $command = $self->session->config->get("runOnLogin"); if ($command ne "") { WebGUI::Macro::process($self->session,\$command); @@ -711,6 +710,23 @@ sub login { $self->session->errorHandler->warn($error) if $error; } + + # Set the proper redirect + if ( $self->session->setting->get( 'showMessageOnLogin' ) + && $self->user->profileField( $LOGIN_MESSAGE_SEEN ) + < $self->session->setting->get( 'showMessageOnLoginTimes' ) + ) { + return $self->showMessageOnLogin; + } + elsif ( $self->session->form->get('returnUrl') ) { + $self->session->http->setRedirect( $self->session->form->get('returnUrl') ); + $self->session->scratch->delete("redirectAfterLogin"); + } + elsif ( $self->session->scratch->get("redirectAfterLogin") ) { + $self->session->http->setRedirect($self->session->scratch->get("redirectAfterLogin")); + $self->session->scratch->delete("redirectAfterLogin"); + } + return undef; } @@ -774,7 +790,7 @@ sub new { $self->{profile} = (); $self->{warning} = ""; my $call = shift; - my @callable = ('init', @{$call}); + my @callable = ('init', 'showMessageOnLogin', @{$call}); $self->{callable} = \@callable; bless $self, $class; return $self; @@ -850,6 +866,45 @@ sub saveParams { } } +#---------------------------------------------------------------------------- + +=head2 showMessageOnLogin ( ) + +Show the requested message after the user logs in. Add another tally to the +number of times the message has been displayed. Show a link to the next +stage for the user. + +=cut + +sub showMessageOnLogin { + my $self = shift; + my $i18n = WebGUI::International->new( $self->session, 'Auth' ); + + # Increment the number of time seen. + $self->user->profileField( $LOGIN_MESSAGE_SEEN, + $self->user->profileField( $LOGIN_MESSAGE_SEEN ) + 1 + ); + + # Show the message, processing for macros + my $output = $self->session->setting->get( 'showMessageOnLoginBody' ); + WebGUI::Macro::process( $self->session, \$output ); + + # Add the link to continue + my $redirectUrl = $self->session->form->get( 'returnUrl' ) + || $self->session->scratch->get( 'redirectAfterLogin' ) + || $self->session->url->getSiteURL + ; + + $output .= '
' . $i18n->get( 'showMessageOnLogin return' ) + . '
' + ; + + # No matter what, we won't be redirecting after this + $self->session->scratch->delete( 'redirectAfterLogin' ); + + return $output; +} + #------------------------------------------------------------------- =head2 user ( [user] ) diff --git a/lib/WebGUI/Operation/Settings.pm b/lib/WebGUI/Operation/Settings.pm index 02b03c706..ca0d890e8 100644 --- a/lib/WebGUI/Operation/Settings.pm +++ b/lib/WebGUI/Operation/Settings.pm @@ -450,6 +450,37 @@ sub definition { label => $i18n->get("manage friends template", "Friends"), hoverHelp => $i18n->get("manage friends template help", "Friends"), }); + push @fields, { + tab => "user", + name => "showMessageOnLogin", + fieldType => "yesNo", + defaultValue => 0, + label => $i18n->get( 'showMessageOnLogin label' ), + hoverHelp => $i18n->get( 'showMessageOnLogin description' ), + }; + push @fields, { + tab => "user", + name => "showMessageOnLoginTimes", + fieldType => "integer", + defaultValue => 1, + label => $i18n->get( 'showMessageOnLoginTimes label' ), + hoverHelp => $i18n->get( 'showMessageOnLoginTimes description' ), + }; + push @fields, { + tab => "user", + name => 'showMessageOnLoginReset', + fieldType => 'yesNo', + defaultValue => 0, + label => $i18n->get( 'showMessageOnLoginReset label' ), + hoverHelp => $i18n->get( 'showMessageOnLoginReset description' ), + }; + push @fields, { + tab => "user", + name => 'showMessageOnLoginBody', + fieldType => 'HTMLArea', + label => $i18n->get( 'showMessageOnLoginBody label' ), + hoverHelp => $i18n->get( 'showMessageOnLoginBody description' ), + }; # auth settings my $options; foreach (@{$session->config->get("authMethods")}) { @@ -593,28 +624,39 @@ is in group Admin (3). Returns the user to the Edit Settings screen, www_editSe =cut sub www_saveSettings { - my $session = shift; - return $session->privilege->adminOnly() unless ($session->user->isInGroup(3)); - my $i18n = WebGUI::International->new($session, "WebGUI"); - my $setting = $session->setting; - my $form = $session->form; + my $session = shift; + return $session->privilege->adminOnly() unless ($session->user->isInGroup(3)); + my $i18n = WebGUI::International->new($session, "WebGUI"); + my $setting = $session->setting; + my $form = $session->form; my @errors; # Errors trying to save the form - my $definitions = definition($session, $i18n); - foreach my $definition (@{$definitions}) { - $setting->set($definition->{name}, $form->process($definition->{name}, $definition->{fieldType}, undef, $definition)); - } + my $definitions = definition($session, $i18n); + foreach my $definition (@{$definitions}) { + next if ( $definition->{ noFormPost } ); + $setting->set($definition->{name}, $form->process($definition->{name}, $definition->{fieldType}, undef, $definition)); + } - foreach (@{$session->config->get("authMethods")}) { - my $authInstance = WebGUI::Operation::Auth::getInstance($session,$_,1); + foreach (@{$session->config->get("authMethods")}) { + my $authInstance = WebGUI::Operation::Auth::getInstance($session,$_,1); - my $authErrors = $authInstance->editUserSettingsFormSave; + my $authErrors = $authInstance->editUserSettingsFormSave; if ($authErrors) { push @errors, @{ $authErrors }; } - } + } - return www_editSettings($session, { errors => \@errors, message => $i18n->get("editSettings done") }); + ### Handle special settings + # Reset login message seen numbers + if ( $session->form->get( 'showMessageOnLoginReset' ) ) { + $session->db->write( + "UPDATE userProfileData SET showMessageOnLoginSeen=0" + ); + # Delete the user cache + WebGUI::Cache->new( $session, [ "user" ] )->deleteChunk( [ "user" ] ); + } + + return www_editSettings($session, { errors => \@errors, message => $i18n->get("editSettings done") }); } 1; diff --git a/lib/WebGUI/Workflow/Activity/RequestApprovalForVersionTag/ByCommitterGroup.pm b/lib/WebGUI/Workflow/Activity/RequestApprovalForVersionTag/ByCommitterGroup.pm new file mode 100644 index 000000000..d6f258b45 --- /dev/null +++ b/lib/WebGUI/Workflow/Activity/RequestApprovalForVersionTag/ByCommitterGroup.pm @@ -0,0 +1,99 @@ +package WebGUI::Workflow::Activity::RequestApprovalForVersionTag::ByCommitterGroup; + + +=head1 LEGAL + + ------------------------------------------------------------------- + WebGUI is Copyright 2001-2008 Plain Black Corporation. + ------------------------------------------------------------------- + Please read the legal notices (docs/legal.txt) and the license + (docs/license.txt) that came with this distribution before using + this software. + ------------------------------------------------------------------- + http://www.plainblack.com info@plainblack.com + ------------------------------------------------------------------- + +=cut + +use strict; +use base 'WebGUI::Workflow::Activity::RequestApprovalForVersionTag'; + +=head1 NAME + +Package WebGUI::Workflow::Activity::RequestApprovalForVersionTag::ByCommitterGroup + +=head1 DESCRIPTION + +Requests approval for a version tag only if the committer is a member of +the specified group. + +In this way, we can make certain groups of users go through additional +approval. + +=head1 SYNOPSIS + +See WebGUI::Workflow::Activity for details on how to use any activity. + +=head1 METHODS + +These methods are available from this class: + +=cut + + +#------------------------------------------------------------------- + +=head2 definition ( session, definition ) + +See WebGUI::Workflow::Activity::defintion() for details. + +=cut + +sub definition { + my $class = shift; + my $session = shift; + my $definition = shift; + my $i18n = WebGUI::International->new($session, "Activity_RequestApprovalForVersionTag_ByCommitterGroup"); + push @{ $definition }, { + name => $i18n->get( "topicName" ), + properties => { + committerGroupId => { + fieldType => "group", + defaultValue => 0, + label => $i18n->get( 'committerGroupId label' ), + hoverHelp => $i18n->get( 'committerGroupId description' ), + }, + }, + }; + return $class->SUPER::definition( $session, $definition ); +} + +#---------------------------------------------------------------------------- + +=head2 execute ( tag, instance ) + +Request the approval. Make sure the tag is covered by the C