added: Two new approval activities, byLineage and byCommitterGroup
added: Show a message to users when they log in fixed: Gallery search form doesn't work right in IE6 fixed: Minor bug in new gallery approval handling
This commit is contained in:
parent
a0ec44567a
commit
614b37e31d
12 changed files with 515 additions and 32 deletions
|
|
@ -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') . ';'
|
||||
|
|
|
|||
|
|
@ -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) } );
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -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 .= '<p><a href="' . $redirectUrl . '">' . $i18n->get( 'showMessageOnLogin return' )
|
||||
. '</a></p>'
|
||||
;
|
||||
|
||||
# No matter what, we won't be redirecting after this
|
||||
$self->session->scratch->delete( 'redirectAfterLogin' );
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 user ( [user] )
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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<committerGroupId>
|
||||
and then request approval.
|
||||
|
||||
If the tag is not covered, just continue with the workflow.
|
||||
|
||||
=cut
|
||||
|
||||
sub execute {
|
||||
my $self = shift;
|
||||
my $tag = shift;
|
||||
my $instance = shift;
|
||||
my $committedBy = WebGUI::User->new( $self->session, $tag->get( 'committedBy' ) );
|
||||
|
||||
# If tag is handled by this activity
|
||||
if ( $committedBy->isInGroup( $self->get( 'committerGroupId' ) ) ) {
|
||||
return $self->SUPER::execute( $tag, $instance );
|
||||
}
|
||||
else {
|
||||
return $self->COMPLETE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
1;
|
||||
|
||||
|
|
@ -0,0 +1,103 @@
|
|||
package WebGUI::Workflow::Activity::RequestApprovalForVersionTag::ByLineage;
|
||||
|
||||
|
||||
=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::ByLineage
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
Requests approval for a version tag only if all the content is under
|
||||
the specified asset.
|
||||
|
||||
In this way we can create sections of our site that require approval
|
||||
from certain people.
|
||||
|
||||
=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_ByLineage");
|
||||
push @{ $definition }, {
|
||||
name => $i18n->get( "topicName" ),
|
||||
properties => {
|
||||
assetId => {
|
||||
fieldType => "asset",
|
||||
defaultValue => 0,
|
||||
label => $i18n->get( 'assetId label' ),
|
||||
hoverHelp => $i18n->get( 'assetId description' ),
|
||||
},
|
||||
},
|
||||
};
|
||||
return $class->SUPER::definition( $session, $definition );
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
=head2 execute ( tag, instance )
|
||||
|
||||
Request the approval. Make sure the tag is covered by the C<assetId>
|
||||
and then request approval.
|
||||
|
||||
If the tag is not covered, just continue with the workflow.
|
||||
|
||||
=cut
|
||||
|
||||
sub execute {
|
||||
my $self = shift;
|
||||
my $tag = shift;
|
||||
my $instance = shift;
|
||||
my $ancestor = WebGUI::Asset->newByDynamicClass( $self->session, $self->get( 'assetId' ) );
|
||||
my $lineage = $ancestor->get( 'lineage' );
|
||||
# Descendant has at least the ancestors lineage plus 6 more character
|
||||
my $isDescendant = qr{^$lineage.{6}};
|
||||
|
||||
# If one piece of content isn't under our ancestor, complete
|
||||
for my $asset ( @{ $tag->getAssets } ) {
|
||||
if ( $asset->get( 'lineage' ) !~ $isDescendant ) {
|
||||
return $self->COMPLETE;
|
||||
}
|
||||
}
|
||||
|
||||
# Every piece is under our ancestor, get some approval
|
||||
return $self->SUPER::execute( $tag, $instance );
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
package WebGUI::i18n::English::Activity_RequestApprovalForVersionTag_ByCommitterGroup;
|
||||
|
||||
use strict;
|
||||
|
||||
our $I18N = {
|
||||
'committerGroupId label' => {
|
||||
message => q{Committer Group to Require Approval},
|
||||
lastUpdated => 0,
|
||||
context => q{Label for activity property},
|
||||
},
|
||||
'committerGroupId description' => {
|
||||
message => q{The group that needs approval from this activity. If the committer is not
|
||||
a member of this group, the workflow will continue with the next activity. },
|
||||
lastUpdated => 0,
|
||||
context => q{Description of activity property},
|
||||
},
|
||||
topicName => {
|
||||
message => q{Request Approval By Committer Group},
|
||||
lastUpdated => 0,
|
||||
},
|
||||
};
|
||||
|
||||
1;
|
||||
|
|
@ -0,0 +1,24 @@
|
|||
package WebGUI::i18n::English::Activity_RequestApprovalForVersionTag_ByLineage;
|
||||
|
||||
use strict;
|
||||
|
||||
our $I18N = {
|
||||
'assetId label' => {
|
||||
message => q{Ancestor Asset},
|
||||
lastUpdated => 0,
|
||||
context => q{Label for activity property},
|
||||
},
|
||||
'assetId description' => {
|
||||
message => q{The ancestor of the content that requires approval by this activity.
|
||||
All content must be under this ancestor, otherwise the workflow will
|
||||
continue on with the next activity.},
|
||||
lastUpdated => 0,
|
||||
context => q{Description of activity property},
|
||||
},
|
||||
topicName => {
|
||||
message => q{Request Approval By Asset Lineage},
|
||||
lastUpdated => 0,
|
||||
},
|
||||
};
|
||||
|
||||
1;
|
||||
|
|
@ -198,6 +198,17 @@ our $I18N = {
|
|||
lastUpdated => 1149220294,
|
||||
},
|
||||
|
||||
'showMessageOnLogin return' => {
|
||||
message => q{Continue to the site},
|
||||
lastUpdated => 0,
|
||||
},
|
||||
|
||||
"showMessageOnLoginSeen" => {
|
||||
message => q{Seen Message On Login Times},
|
||||
lastUpdated => 0,
|
||||
context => q{Label for user profile field},
|
||||
},
|
||||
|
||||
'topicName' => {
|
||||
message => q|Authentication|,
|
||||
lastUpdated => 1164338173,
|
||||
|
|
|
|||
|
|
@ -3959,6 +3959,55 @@ LongTruncOk=1</p>
|
|||
message => q{Attachments},
|
||||
lastUpdated => 1202274234,
|
||||
},
|
||||
|
||||
'showMessageOnLogin label' => {
|
||||
message => q{Show Message On Login?},
|
||||
lastUpdated => 0,
|
||||
context => q{Label for site setting},
|
||||
},
|
||||
|
||||
'showMessageOnLogin description' => {
|
||||
message => q{If yes, show a message after a user logs in.},
|
||||
lastUpdated => 0,
|
||||
context => q{Description for site setting},
|
||||
},
|
||||
|
||||
'showMessageOnLoginTimes label' => {
|
||||
message => q{Show Message Number of Times},
|
||||
lastUpdated => 0,
|
||||
context => q{Label for site setting},
|
||||
},
|
||||
|
||||
'showMessageOnLoginTimes description' => {
|
||||
message => q{The number of times a user sees the message, one per login},
|
||||
lastUpdated => 0,
|
||||
context => q{Description for site setting},
|
||||
},
|
||||
|
||||
'showMessageOnLoginReset label' => {
|
||||
message => q{Reset All Users Number of Times Seen},
|
||||
lastUpdated => 0,
|
||||
context => q{Label for site setting},
|
||||
},
|
||||
|
||||
'showMessageOnLoginReset description' => {
|
||||
message => q{If "yes", will force all users to see the login message again},
|
||||
lastUpdated => 0,
|
||||
context => q{Description for site setting},
|
||||
},
|
||||
|
||||
'showMessageOnLoginBody label' => {
|
||||
message => q{Message on Login Body},
|
||||
lastUpdated => 0,
|
||||
context => q{Label for site setting},
|
||||
},
|
||||
|
||||
'showMessageOnLoginBody description' => {
|
||||
message => q{The body of the message to show on login. Macros are allowed.},
|
||||
lastUpdated => 0,
|
||||
context => q{Description for site setting},
|
||||
},
|
||||
|
||||
};
|
||||
|
||||
1;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue