Merge commit '4969f31e1f' into WebGUI8

This commit is contained in:
Colin Kuskie 2010-06-26 14:37:31 -07:00
commit e5b82bc861
61 changed files with 2199 additions and 521 deletions

View file

@ -452,6 +452,14 @@ property postReceivedTemplateId => (
hoverHelp => [ 'post received template hoverHelp', 'Asset_Collaboration' ],
default => 'default_post_received1',
);
property unsubscribeTemplateId => (
fieldType => 'template',
namespace => 'Collaboration/Unsubscribe',
tab => 'display',
label => [ 'unsubscribe template', 'Asset_Collaboration' ],
hoverHelp => [ 'unsubscribe template hoverHelp', 'Asset_Collaboration' ],
default => 'default_CS_unsubscribe',
);
with 'WebGUI::Role::Asset::RssFeed';
@ -1557,18 +1565,22 @@ sub subscribe {
#-------------------------------------------------------------------
=head2 unsubscribe ( )
=head2 unsubscribe ( [$user] )
Unsubscribes a user from this collaboration system
=head3 $user
An optional user object to unsubscribe. If the object isn't passed, then it uses the session user.
=cut
sub unsubscribe {
my $self = shift;
my $self = shift;
my $user = shift || $self->session->user;
my $group = WebGUI::Group->new($self->session,$self->subscriptionGroupId);
return
unless $group;
$group->deleteUsers([$self->session->user->userId],[$self->subscriptionGroupId]);
return unless $group;
$group->deleteUsers([$user->userId]);
}
@ -1706,24 +1718,64 @@ sub www_unarchiveAll {
#-------------------------------------------------------------------
=head2 www_unsubscribe ( )
=head2 www_unsubscribe ( [$message] )
The web method to unsubscribe from a collaboration.
=head3 $message
An error message to display to the user.
=cut
sub www_unsubscribe {
my $self = shift;
my $self = shift;
my $message = shift;
if($self->canSubscribe){
$self->unsubscribe;
return $self->www_view;
}else{
return $self->session->privilege->noAccess;
}
else {
my $session = $self->session;
my $i18n = WebGUI::International->new($session, 'Asset_Collaboration');
my $var = $self->get();
$var->{title} = $self->getTitle;
$var->{url} = $self->getUrl;
$var->{formHeader} = WebGUI::Form::formHeader($session)
. WebGUI::Form::hidden($session, { name => 'func', value => 'unsubscribeConfirm', }, ),
$var->{formFooter} = WebGUI::Form::formFooter($session),
$var->{formSubmit} = WebGUI::Form::submit($session, { value => $i18n->get('unsubscribe'), }),
$var->{formEmail} = WebGUI::Form::email($session, { name => 'userEmail', value => $session->form->process('userEmail'), }),
$var->{formMessage} = $message;
return $self->processStyle($self->processTemplate($var, $self->get("unsubscribeTemplateId")));
}
}
#-------------------------------------------------------------------
=head2 www_unsubscribeConfirm ( )
Process the unsubscribe form.
=cut
sub www_unsubscribeConfirm {
my $self = shift;
my $session = $self->session;
return $self->www_view unless $session->form->validToken;
my $email = $session->form->process('userEmail', 'email');
return $self->www_view unless $email;
my $user = WebGUI::User->newByEmail($session, $email);
my $i18n = WebGUI::International->new($session, 'Asset_Collaboration');
if (! $user) {
return $self->www_unsubscribe($i18n->get('no user email error message'));
}
$self->unsubscribe($user);
return $self->www_unsubscribe($i18n->get('You have been unsubscribed'));
}
#-------------------------------------------------------------------
=head2 www_view
Extend the base method to handle the visitor cache timeout.