replaced MessageLog with Inbox
This commit is contained in:
parent
d63ea20c9e
commit
b6ad963119
18 changed files with 345 additions and 440 deletions
108
lib/WebGUI/Operation/Inbox.pm
Normal file
108
lib/WebGUI/Operation/Inbox.pm
Normal file
|
|
@ -0,0 +1,108 @@
|
|||
package WebGUI::Operation::Inbox;
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
# WebGUI is Copyright 2001-2006 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
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
use strict qw(vars subs);
|
||||
use URI;
|
||||
use WebGUI::International;
|
||||
use WebGUI::Paginator;
|
||||
use WebGUI::SQL;
|
||||
use WebGUI::Asset::Template;
|
||||
use WebGUI::User;
|
||||
use WebGUI::Utility;
|
||||
use WebGUI::Operation::Shared;
|
||||
|
||||
=head1 NAME
|
||||
|
||||
Package WebGUI::Operation::Inbox
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
Operations for viewing message logs and individual messages.
|
||||
|
||||
=cut
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 _status ( )
|
||||
|
||||
returns a hashref with internationalized values for message status.
|
||||
|
||||
=cut
|
||||
|
||||
sub _status {
|
||||
my $session = shift;
|
||||
my $i18n = WebGUI::International->new($session);
|
||||
return {"pending"=>$i18n->get(552),"completed"=>$i18n->get(350)};
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 www_viewInbox ( )
|
||||
|
||||
Templated display all messages for the current user.
|
||||
|
||||
=cut
|
||||
|
||||
sub www_viewInbox {
|
||||
my $session = shift;
|
||||
return $session->privilege->insufficient() unless ($session->user->isInGroup(2));
|
||||
my $i18n = WebGUI::International->new($session);
|
||||
$vars->{title} = $i18n->get(159);
|
||||
$vars->{'subject.label'} = $i18n->get(351);
|
||||
$vars->{'status.label'} = $i18n->get(553);
|
||||
$vars->{'dateStamp.label'} = $i18n->get(352);
|
||||
my $messages = WebGUI::Inbox->getMessagesForUser($session, $session->user);
|
||||
foreach my $message (@$messages) {
|
||||
my $hash;
|
||||
$hash->{'subject'} = '<a href="'.$session->url->page('op=viewInboxMessage;messageId='.$message->getId).'">'.$message->get("subject").'</a>';
|
||||
$hash->{status} = _status($session)->{$message->get("status")};
|
||||
$hash->{'dateStamp'} =$session->datetime->epochToHuman($message->get("dateStamp"));
|
||||
push(@msg,$hash);
|
||||
}
|
||||
$vars->{'messages'} = \@msg;
|
||||
$vars->{'noresults'} = $i18n->get(353) unless (scalar(@$messages) > 0);
|
||||
$vars->{'accountOptions'} = WebGUI::Operation::Shared::accountOptions($session);
|
||||
return $session->style->userStyle(WebGUI::Asset::Template->new($session,"PBtmpl0000000000000206")->process($vars));
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 www_viewInboxMessage ( )
|
||||
|
||||
Templated display of a single message for the user.
|
||||
|
||||
=cut
|
||||
|
||||
sub www_viewInboxMessage {
|
||||
my $session = shift;
|
||||
my ($data, $vars);
|
||||
return $session->privilege->insufficient() unless ($session->user->isInGroup(2));
|
||||
my $i18n = WebGUI::International->new($session);
|
||||
$vars->{title} = $i18n->get(159);
|
||||
my $message = WebGUI::Inbox->getMessage($session, $session->form->param("messageId"));
|
||||
if (defined $message) {
|
||||
$vars->{'subject'} = $data->{subject};
|
||||
$vars->{'dateStamp'} =$session->datetime->epochToHuman($data->{dateStamp});
|
||||
$vars->{'status'} = _status($session)->{$data->{status}};
|
||||
unless ($data->{message} =~ /\<div/ig || $data->{message} =~ /\<br/ig || $data->{message} =~ /\<p/ig) {
|
||||
$data->{message} =~ s/\n/\<br\>/g;
|
||||
}
|
||||
unless ($data->{message} =~ /\<a/ig) {
|
||||
$data->{message} =~ s/(http\S*)\s/\<a href=\"$1\"\>$1\<\/a\>/g;
|
||||
}
|
||||
$vars->{'message'} = $data->{message};
|
||||
}
|
||||
$vars->{'accountOptions'} = WebGUI::Operation::Shared::accountOptions($session);
|
||||
return $session->style->userStyle(WebGUI::Asset::Template->new($session,"PBtmpl0000000000000205")->process($vars));
|
||||
}
|
||||
|
||||
1;
|
||||
|
|
@ -1,129 +0,0 @@
|
|||
package WebGUI::Operation::MessageLog;
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
# WebGUI is Copyright 2001-2006 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
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
use strict qw(vars subs);
|
||||
use URI;
|
||||
use WebGUI::International;
|
||||
use WebGUI::Paginator;
|
||||
use WebGUI::SQL;
|
||||
use WebGUI::Asset::Template;
|
||||
use WebGUI::User;
|
||||
use WebGUI::Utility;
|
||||
use WebGUI::Operation::Shared;
|
||||
|
||||
=head1 NAME
|
||||
|
||||
Package WebGUI::Operation::MessageLog
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
Operations for viewing message logs and individual messages.
|
||||
|
||||
=cut
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 _status ( )
|
||||
|
||||
returns a hashref with internationalized values for message status.
|
||||
|
||||
=cut
|
||||
|
||||
sub _status {
|
||||
my $session = shift;
|
||||
my $i18n = WebGUI::International->new($session);
|
||||
return {"notice"=>$i18n->get(551),"pending"=>$i18n->get(552),"completed"=>$i18n->get(350)};
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 www_viewMessageLog ( )
|
||||
|
||||
Templated display all messages for the current user.
|
||||
|
||||
=cut
|
||||
|
||||
sub www_viewMessageLog {
|
||||
my $session = shift;
|
||||
my (@msg, $vars);
|
||||
return $session->privilege->insufficient() unless ($session->user->isInGroup(2));
|
||||
my $i18n = WebGUI::International->new($session);
|
||||
$vars->{displayTitle} = '<h1>'.$i18n->get(159).'</h1>';
|
||||
my $p = WebGUI::Paginator->new($session,$session->url->page('op=viewMessageLog'));
|
||||
my $query = "select messageLogId,subject,url,dateOfEntry,status from messageLog where userId=".$session->db->quote($session->user->userId)." order by dateOfEntry desc";
|
||||
$p->setDataByQuery($query);
|
||||
|
||||
$vars->{'message.subject.label'} = $i18n->get(351);
|
||||
$vars->{'message.status.label'} = $i18n->get(553);
|
||||
$vars->{'message.dateOfEntry.label'} = $i18n->get(352);
|
||||
|
||||
my $messages = $p->getPageData;
|
||||
foreach my $message (@$messages) {
|
||||
my $hash;
|
||||
$hash->{'message.subject'} = '<a href="'.$session->url->page('op=viewMessageLogMessage;mlog='.$message->{messageLogId}).'">'.$message->{subject}.'</a>';
|
||||
my $status = _status($session)->{$message->{status}};
|
||||
$status = '<a href="'.$session->url->append($message->{url},'mlog='.$message->{messageLogId}).'">'.$status.'</a>' if ($message->{url} ne "");
|
||||
$hash->{'message.status'} = $status;
|
||||
$hash->{'message.dateOfEntry'} =$session->datetime->epochToHuman($message->{dateOfEntry});
|
||||
push(@msg,$hash);
|
||||
}
|
||||
$vars->{'message.loop'} = \@msg;
|
||||
$vars->{'message.noresults'} = $i18n->get(353) unless (scalar(@$messages) > 0);
|
||||
|
||||
$vars->{'message.firstPage'} = $p->getFirstPageLink;
|
||||
$vars->{'message.lastPage'} = $p->getLastPageLink;
|
||||
$vars->{'message.nextPage'} = $p->getNextPageLink;
|
||||
$vars->{'message.pageList'} = $p->getPageLinks;
|
||||
$vars->{'message.previousPage'} = $p->getPreviousPageLink;
|
||||
$vars->{'message.multiplePages'} = ($p->getNumberOfPages > 1);
|
||||
$vars->{'message.accountOptions'} = WebGUI::Operation::Shared::accountOptions($session);
|
||||
|
||||
return $session->style->userStyle(WebGUI::Asset::Template->new($session,"PBtmpl0000000000000050")->process($vars));
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 www_viewMessageLog ( )
|
||||
|
||||
Templated display of a single message for the user.
|
||||
|
||||
=cut
|
||||
|
||||
sub www_viewMessageLogMessage {
|
||||
my $session = shift;
|
||||
my ($data, $vars);
|
||||
return $session->privilege->insufficient() unless ($session->user->isInGroup(2));
|
||||
my $i18n = WebGUI::International->new($session);
|
||||
$vars->{displayTitle} = '<h1>'.$i18n->get(159).'</h1>';
|
||||
|
||||
$data = $session->db->quickHashRef("select * from messageLog where messageLogId=".$session->db->quote($session->form->process("mlog"))." and userId=".$session->db->quote($session->user->userId));
|
||||
|
||||
$vars->{'message.subject'} = $data->{subject};
|
||||
$vars->{'message.dateOfEntry'} =$session->datetime->epochToHuman($data->{dateOfEntry});
|
||||
|
||||
my $status = _status($session)->{$data->{status}};
|
||||
if ($data->{url} ne "" && $data->{status} eq 'pending'){
|
||||
$status = '<a href="'.$session->url->append($data->{url},'mlog='.$data->{messageLogId}).'">'.$status.'</a>';
|
||||
$vars->{'message.takeAction'} = '<a href="'.$session->url->append($data->{url},'mlog='.$data->{messageLogId}).'">'.$i18n->get(554).'</a>'
|
||||
}
|
||||
$vars->{'message.status'} = $status;
|
||||
|
||||
unless ($data->{message} =~ /\<div\>/ig || $data->{message} =~ /\<br\>/ig || $data->{message} =~ /\<p\>/ig) {
|
||||
$data->{message} =~ s/\n/\<br\>/g;
|
||||
}
|
||||
|
||||
$vars->{'message.text'} = $data->{message};
|
||||
$vars->{'message.accountOptions'} = WebGUI::Operation::Shared::accountOptions($session);
|
||||
return $session->style->userStyle(WebGUI::Asset::Template->new($session,"PBtmpl0000000000000049")->process($vars));
|
||||
}
|
||||
|
||||
1;
|
||||
|
|
@ -59,9 +59,9 @@ is in group Admin (3). Returns the user to the List Database Links screen.
|
|||
$hash{'options.display'} = '<a href="'.$session->url->page('op=viewProfile;uid='.$session->user->userId).'">'.$i18n->get(343).'</a>';
|
||||
push(@array,\%hash);
|
||||
}
|
||||
unless ($session->form->process("op") eq "viewMessageLog"){
|
||||
unless ($session->form->process("op") eq "viewInbox"){
|
||||
my %hash;
|
||||
$hash{'options.display'} = '<a href="'.$session->url->page('op=viewMessageLog').'">'.$i18n->get(354).'</a>';
|
||||
$hash{'options.display'} = '<a href="'.$session->url->page('op=viewInbox').'">'.$i18n->get(354).'</a>';
|
||||
push(@array,\%hash);
|
||||
}
|
||||
unless ($session->form->process("op") eq "redeemSubscriptionCode") {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue