replaced MessageLog with Inbox

This commit is contained in:
JT Smith 2006-03-21 22:44:31 +00:00
parent d63ea20c9e
commit b6ad963119
18 changed files with 345 additions and 440 deletions

View file

@ -29,8 +29,10 @@
otherwise be slow or complex pages. More details in migration.txt.
- The SMTP mail backend has been replaced with a new API that's capable of
sending attachments, HTML messages, and more. This will introduce many new
- Added a mail queue system.
options for developers.
- Replaced the old Message Log system with a new Inbox system that's more
reliable, and scalable.
- Added a mail queue system.
- The group mail screen now allows sending of HTML messages.
- Added prequery statements to the SQLReport and configurable allowed statements
to the database link properties. (Martin Kamerbeek / Procolix)

View file

@ -886,6 +886,13 @@ messages, and to multiple recipients, unlike WebGUI::Mail. Please see the API
for details.
5.25 WebGUI::MessageLog Replaced
IN 6.99 the venerable WebGUI::MessageLog has been retired and replaced with
WebGUI::Inbox, which has an object oriented API, is more resource efficient,
is more flexible, is more reliable, and is compliant with the new mail system.
6. Automatic list of Assets in Help System.
-------------------------------------

View file

@ -0,0 +1,53 @@
#PBtmpl0000000000000206
#create
#namespace:Inbox
#url:default_inbox
#title:Default Inbox
#menuTitle:Default Inbox
<h1><tmpl_var title></h1>
<table width="100%" cellspacing="1" cellpadding="2" border="0">
<tr>
<td class="tableHeader">
<tmpl_var subject.label>
</td>
<td class="tableHeader">
<tmpl_var status.label>
</td>
<td class="tableHeader">
<tmpl_var dateStamp.label>
</td>
</tr>
<tmpl_if message.noresults>
<tr>
<td class="tableData">
<tmpl_var noresults>
</td>
<td class="tableData">
&nbsp;
</td>
<td class="tableData">
&nbsp;
</td>
</tr>
<tmpl_else>
<tmpl_loop messages>
<tr>
<td class="tableData">
<tmpl_var subject>
</td>
<td class="tableData">
<tmpl_var status>
</td>
<td class="tableData">
<tmpl_var dateStamp>
</td>
</tr>
</tmpl_loop>
</tmpl_if>
</table>
<ul class="accountOptions">
<tmpl_loop accountOptions>
<li><tmpl_var options.display>
</tmpl_loop>
</ul>

View file

@ -0,0 +1,20 @@
#PBtmpl0000000000000205
#create
#namespace:Inbox/Message
#url:default_inbox_message
#title:Default Inbox Message
#menuTitle:Default Inbox Message
<h1><tmpl_var title></h1>
<b><tmpl_var subject></b><br />
<tmpl_var dateStamp><br />
<tmpl_var status><br /><br />
<p> <tmpl_var message></p>
<div class="accountOptions">
<ul>
<tmpl_loop accountOptions>
<li><tmpl_var options.display></li>
</tmpl_loop>
</ul>
</div>

View file

@ -25,6 +25,7 @@ my $quiet; # this line required
my $session = start(); # this line required
addWorkflow();
convertMessageLogToInbox();
templateParsers();
removeFiles();
addSearchEngine();
@ -41,6 +42,48 @@ updateHelpTemplate();
finish($session); # this line required
#-------------------------------------------------
sub convertMessageLogToInbox {
print "\tConverting message log to inbox.\n";
$session->db->write("create table inbox (
messageId varchar(22) binary not null primary key,
status varchar(15) not null default 'pending',
dateStamp bigint not null,
completedOn bigint,
completedBy varchar(22) binary,
userId varchar(22) binary,
groupId varchar(22) binary,
subject varchar(256) not null default 'No Subject',
message mediumtext
)");
$session->db->write("alter table Matrix_listing add column approvalMessageId varchar(22) binary");
my $prepared = $session->db->prepare("insert into inbox (messageId, status, dateStamp, completedOn, completedBy, userId, subject, message)
values ( ?,?,?,?,?,?,?,? )");
my $rs = $session->db->read("select * from messageLog");
while (my $data = $rs->hashRef) {
$prepared->execute([
$session->id->generate,
'completed',
$data->{dateOfEntry},
time(),
'3',
$data->{userId},
$data->{subject},
$data->{message}
]);
}
$session->db->write("delete from userProfileField where fieldname='INBOXNotifications'");
$session->db->write("delete from userProfileData where fieldname='INBOXNotifications'");
$session->db->write("drop table MessageLog");
$rs = $session->db->read("select distinct assetId from template where namespace='Operation/MessageLog/View' or namespace='Operation/MessageLog/Message'");
while (my ($id) = $rs->array) {
my $asset = WebGUI::Asset->new($session, $id, "WebGUI::Asset::Template");
if (defined $asset) {
$asset->trash;
}
}
}
#-------------------------------------------------
sub addCsPopularityContest {
print "\tAdding collaboration system popularity system based upon karma.\n";
@ -669,6 +712,8 @@ sub templateParsers {
#-------------------------------------------------
sub removeFiles {
print "\tRemoving old unneeded files.\n" unless ($quiet);
unlink '../../lib/WebGUI/MessageLog.pm';
unlink '../../lib/WebGUI/Operation/MessageLog.pm';
unlink '../../lib/WebGUI/ErrorHandler.pm';
unlink '../../lib/WebGUI/HTTP.pm';
unlink '../../lib/WebGUI/Privilege.pm';

View file

@ -20,7 +20,7 @@ use WebGUI::Group;
use WebGUI::HTML;
use WebGUI::HTMLForm;
use WebGUI::International;
use WebGUI::MessageLog;
use WebGUI::Inbox;
use WebGUI::Operation;
use WebGUI::Paginator;
use WebGUI::SQL;
@ -620,30 +620,25 @@ Send notifications to the thread and forum subscribers that a new post has been
sub notifySubscribers {
my $self = shift;
my %subscribers;
my $group = WebGUI::Group->new($self->session,$self->getThread->get("subscriptionGroupId"));
foreach my $userId (@{$group->getUsers(undef,1)}) {
$subscribers{$userId} = $userId unless ($userId eq $self->get("ownerUserId"));
}
$group = WebGUI::Group->new($self->session, $self->getThread->getParent->get("subscriptionGroupId"));
foreach my $userId (@{$group->getUsers(undef,1)}) {
$subscribers{$userId} = $userId unless ($userId eq $self->get("ownerUserId"));
}
my %lang;
my $i18n = WebGUI::International->new($self->session);
foreach my $userId (keys %subscribers) {
my $u = WebGUI::User->new($self->session, $userId);
if ($lang{$u->profileField("language")}{message} eq "") {
$lang{$u->profileField("language")}{var} = $self->getTemplateVars();
$self->getThread->getParent->appendTemplateLabels($lang{$u->profileField("language")}{var});
$lang{$u->profileField("language")}{var}{url} = $self->session->url->getSiteURL().$self->getUrl;
$lang{$u->profileField("language")}{var}{'notify.subscription.message'} =
$i18n->get(875,"Asset_Post",$u->profileField("language"));
$lang{$u->profileField("language")}{subject} = $i18n->get(523,"Asset_Post",$u->profileField("language"));
$lang{$u->profileField("language")}{message} = $self->processTemplate($lang{$u->profileField("language")}{var}, $self->getThread->getParent->get("notificationTemplateId"));
}
WebGUI::MessageLog::addEntry($userId,"",$lang{$u->profileField("language")}{subject},$lang{$u->profileField("language")}{message});
}
my $inbox = WebGUI::Inbox->new($self->session);
my $var = $self->getTemplateVars();
$self->getThread->getParent->appendTemplateLabels($var);
$var->{url} = $self->session->url->getSiteURL().$self->getUrl;
$var->{'notify.subscription.message'} = $i18n->get(875,"Asset_Post");
my $message = $self->processTemplate($var, $self->getThread->getParent->get("notificationTemplateId"));
$inbox->addMessage({
groupId=>$self->getThread->getParent->get("subscriptionGroupId"),
status=>"completed",
subject=>$self->get("subject"),
message=>$message
});
$inbox->addMessage({
groupId=>$self->getThread->get("subscriptionGroupId"),
status=>"completed",
subject=>$self->get("subject"),
message=>$message
});
}
@ -801,7 +796,12 @@ sub setStatusApproved {
$self->getThread->incrementReplies($self->get("dateUpdated"),$self->getId) if ($self->isReply && ($self->session->form->process('assetId') eq
"new"));
unless ($self->isPoster) {
WebGUI::MessageLog::addInternationalizedEntry($self->get("ownerUserId"),'',$self->session->url->getSiteURL().'/'.$self->getUrl,579);
my $i18n = WebGUI::International->new($self->session);
WebGUI::Inbox->new($self->session)->addMessage({
userId=>$self->get("ownerUserId"),
status=>'completed',
message=>$i18n->get(579)."\n\n".$self->session->url->getSiteURL().'/'.$self->getUrl
});
}
$self->notifySubscribers unless ($self->session->form->process("func") eq 'add');
}
@ -837,8 +837,12 @@ sub setStatusPending {
$self->setStatusApproved;
} else {
$self->update({status=>'pending'});
WebGUI::MessageLog::addInternationalizedEntry('',$self->getThread->getParent->get("moderateGroupId"),
$self->session->url->getSiteURL().'/'.$self->getUrl("revision=".$self->get("revisionDate")),578,'WebGUI','pending');
my $i18n = WebGUI::International->new($self->session);
WebGUI::Inbox->new($self->session)->addMessage({
status=>'pending',
message=>$i18n->get("578")."\n\n".$self->session->url->getSiteURL().'/'.$self->getUrl("revision=".$self->get("revisionDate")),
groupId=>$self->getThread->getParent->get("moderateGroupId")
});
}
}

View file

@ -15,7 +15,6 @@ use WebGUI::Asset::Template;
use WebGUI::Asset::Post;
use WebGUI::Group;
use WebGUI::International;
use WebGUI::MessageLog;
use WebGUI::Paginator;
use WebGUI::SQL;
use WebGUI::Utility;

View file

@ -19,7 +19,7 @@ use WebGUI::HTMLForm;
use WebGUI::International;
use WebGUI::Mail::Send;
use WebGUI::Macro;
use WebGUI::MessageLog;
use WebGUI::Inbox;
use WebGUI::SQL;
use WebGUI::Asset::Wobject;
use WebGUI::Utility;
@ -661,7 +661,13 @@ sub sendEmail {
unless ($userId || $groupId) {
$self->session->errorHandler->warn($self->getId.": Unable to send message, no user or group found.");
} else {
WebGUI::MessageLog::addEntry($userId, $groupId, $subject, $message, "", "", $from);
WebGUI::Inbox->new($self->session)->addMessage({
userId=>$userId,
groupId=>$groupId,
subject=>$subject,
message=>$message,
status=>'complete'
});
my $mail = WebGUI::Mail::Send->create($self->session,{to=>$cc, subject=>$subject, from=>$from});
if ($cc) {

View file

@ -8,6 +8,7 @@ use WebGUI::Mail::Send;
use WebGUI::SQL;
use WebGUI::User;
use WebGUI::Utility;
use WebGUI::Inbox;
use WebGUI::Asset::Wobject;
use WebGUI::Asset::Wobject::Collaboration;
@ -219,9 +220,17 @@ sub www_approveListing {
return $self->session->privilege->insufficient() unless($self->canEdit);
my $listing = $self->session->db->getRow("Matrix_listing","listingId",$self->session->form->process("listingId"));
$self->session->db->write("update Matrix_listing set status='approved' where listingId=".$self->session->db->quote($self->session->form->process("listingId")));
WebGUI::MessageLog::addEntry($listing->{maintainerId},"","New Listing Approved","Your new listing, ".$listing->{productName}.", has been approved.",
$self->formatURL("viewDetail",$self->session->form->process("listingId")),"notice");
WebGUI::MessageLog::completeEntry($self->session->form->process("mlog"));
my $inbox = WebGUI::Inbox->new($self->session);
$inbox->addMessage({
subject=>"New Listing Approved",
message=>"Your new listing, ".$listing->{productName}.", has been approved.",
status=>'completed',
userId=>$listing->{maintainerId}
});
my $message = $inbox->getMessage($listing->{approvalMessageId});
if (defined $message) {
$message->setCompleted;
}
return $self->www_viewDetail;
}
@ -349,8 +358,17 @@ sub www_deleteListingConfirm {
$self->session->db->write("delete from Matrix_listingData where listingId=".$self->session->db->quote($self->session->form->process("listingId")));
$self->session->db->write("delete from Matrix_rating where listingId=".$self->session->db->quote($self->session->form->process("listingId")));
$self->session->db->write("delete from Matrix_ratingSummary where listingId=".$self->session->db->quote($self->session->form->process("listingId")));
WebGUI::MessageLog::addEntry($listing->{maintainerId},"","Listing Deleted","Your listing, ".$listing->{productName}.", has been deleted from the matrix.","","notice");
WebGUI::MessageLog::completeEntry($self->session->form->process("mlog"));
my $inbox = WebGUI::Inbox->new($self->session);
$inbox->addMessage({
status=>'completed',
subject=>"Listing Deleted",
message=>"Your listing, ".$listing->{productName}.", has been deleted from the matrix.",
userId=>$listing->{maintainerId}
});
my $message = $inbox->getMessage($listing->{approvalMessageId});
if (defined $message) {
$message->setCompleted;
}
return "";
}
@ -646,9 +664,14 @@ sub www_editListingSave {
$data{maintainerId} = $self->session->form->process("maintainerId") if ($self->canEdit);
$data{assetId} = $self->getId;
$self->session->form->process("listingId") = $self->session->db->setRow("Matrix_listing","listingId",\%data);
if ($data{status} eq "pending") {
WebGUI::MessageLog::addEntry($self->get("ownerUserId"),$self->get("groupIdEdit"),"New Listing Added","A new listing, ".$data{productName}.", is waiting to be added.",
$self->session->url->getSiteURL()."/".$self->formatURL("viewDetail",$self->session->form->process("listingId")),"pending");
if ($data{status} eq "pending" && !$listing->{approvalMessageId}) {
$data{approvalMessageId} = WebGUI::Inbox->new($self->session)->addMessage({
status=>'pending',
groupId=>$self->get("groupIdEdit"),
userId=>$self->get("ownerUserId"),
subject=>"New Listing Added",
message=>"A new listing, ".$data{productName}.", is waiting to be added.\n\n".$self->session->url->getSiteURL()."/".$self->formatURL("viewDetail",$self->session->form->process("listingId"))
});
}
my $a = $self->session->db->read("select fieldId, name, fieldType from Matrix_field");
while (my ($id, $name, $type) = $a->array) {

View file

@ -95,14 +95,14 @@ A user object.
=head3 limit
An integer indicating the number of messages to fetch. Defaults to 30.
An integer indicating the number of messages to fetch. Defaults to 50.
=cut
sub getMessagesForUser {
my $self = shift;
my $user = shift;
my $limit = shift;
my $limit = shift || 50;
my @messages = ();
my $counter = 0;
my $rs = $self->session->db->read("select messageId, userId, groupId from inbox order by status='pending', dateStamp");

View file

@ -15,6 +15,7 @@ package WebGUI::Inbox::Message;
=cut
use strict;
use WebGUI::Mail::Send;
=head1 NAME
@ -57,7 +58,7 @@ The content of this message.
=head4 subject
The topic of this message.
The topic of this message. Defaults to 'Notification'.
=head4 status
@ -82,7 +83,7 @@ sub create {
my $self = {};
$self->{_properties}{messageId} = "new";
$self->{_properties}{status} = $properties->{status} || "pending";
$self->{_properties}{subject} = $properties->{subject} || "No Subject";
$self->{_properties}{subject} = $properties->{subject} || WebGUI::International->new($session)->get(523);
$self->{_properties}{message} = $properties->{message};
$self->{_properties}{dateStamp} = time();
$self->{_properties}{userId} = $properties->{userId};
@ -92,6 +93,19 @@ sub create {
$self->{_properties}{completedOn} = time();
}
$self->{_messageId} = $self->{_properties}{messageId} = $session->setRow("inbox","messageId",$self->{_properties});
my $mail = WebGUI::Mail::Send->create($session, {
toUser=>$self->{_properties}{userId},
toGroup=>$self->{_properties}{groupId},
subject=>$self->{_properties}{subject}
});
if (defined $mail) {
if ($self->{_properties}{message} =~ m/\<.*\>/) {
$mail->addHtml($self->{_properties}{message});
} else {
$mail->addText($self->{_properties}{message});
}
$mail->queue;
}
$self->{_session} = $session;
bless $self, $class;
}

View file

@ -142,6 +142,10 @@ A hash reference containing addressing and other header level options.
A string containing a comma seperated list of email addresses to send to.
=head4 toUser
A WebGUI userId of a user you'd like to send this message to.
=head4 toGroup
A WebGUI groupId. The email address of the users in this group will be looked up and will each be sent a copy of this message.
@ -176,6 +180,19 @@ sub create {
my $class = shift;
my $session = shift;
my $headers = shift;
if ($headers->{toUser}) {
my $user = WebGUI::User->new($session, $headers->{toUser});
if (defined $user) {
my $email = $user->profileField("email");
if ($email) {
if ($headers->{to}) {
$headers->{to} .= ','.$email;
} else {
$headers->{to} = $email;
}
}
}
}
my $message = MIME::Entity->build(
Type=>$headers->{contentType} || "multipart/mixed",
From=>$headers->{from} || $session->setting->get("companyEmail"),

View file

@ -1,239 +0,0 @@
package WebGUI::MessageLog;
=head1 LEGAL
-------------------------------------------------------------------
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
-------------------------------------------------------------------
=cut
use strict;
use Tie::CPHash;
use WebGUI::Macro;
use WebGUI::Mail::Send;
use WebGUI::User;
use WebGUI::Utility;
=head1 NAME
Package WebGUI::MessageLog
=head1 DESCRIPTION
This package is WebGUI's notification system.
=head1 SYNOPSIS
use WebGUI::MessageLog;
WebGUI::MessageLog::addEntry($userId, $groupId,$subject,$message);
WebGUI::MessageLog::addInternationalizedEntry($userId,$groupId,$url,$internationalId);
WebGUI::MessageLog::completeEntry($messageLogId);
=head1 METHODS
These functions are available from this package:
=cut
#-------------------------------------------------------------------
sub _notify {
my ($u, $message, $subject, $from);
$u = $_[0];
$subject = $_[1];
$message = $_[2];
$from = $_[3];
if ($u->profileField("INBOXNotifications") eq "email") {
if ($u->profileField("email") ne "") {
#WebGUI::Mail::send($u->profileField("email"),$subject,$message, "", $from);
}
} elsif ($u->profileField("INBOXNotifications") eq "emailToPager") {
if ($u->profileField("emailToPagerGateway") ne "") {
#WebGUI::Mail::send($u->profileField("emailToPagerGateway"),$subject,$message, "", $from);
}
} elsif ($u->profileField("INBOXNotifications") eq "icq") {
if ($u->profileField("icq")) {
#WebGUI::Mail::send($u->profileField("icq").'@pager.icq.com',$subject,$message, "", $from);
}
}
}
#-------------------------------------------------------------------
=head2 addEntry ( userId, groupId, subject, message [ , url, status, from ] )
Adds an entry to the message log and sends out notification to users.
=head3 userId
The id of the user that should receive this notification.
B<NOTE:> This can be left blank if you're specifying a groupId.
=head3 groupId
The id of the group that should receive this notification.
B<NOTE:> This can be left blank if you're specifying a userId.
=head3 subject
The subject of the notification.
=head3 message
The content of the notification.
=head3 url
The URL of any action that should be taken based upon this notification (if any).
=head3 status
Defaults to 'notice'. Can be 'pending', 'notice', or 'completed'.
=head3 from
The addressee email address. Defaults to company email.
=cut
sub addEntry {
# my ($u, @users, $messageLogId, $sth, $userId, $groupId, $subject, $message, $url, $status, $user, $from);
# $messageLogId = $self->session->id->generate();
# $userId = $_[0];
# $groupId = $_[1];
# $subject = $_[2];
# $message = $_[3];
# $url = $_[4];
# if ($url && !$url =~ /^http/) {
# $url = $self->session->url->getSiteURL().$url;
# }
# if ($url && !($url =~ /func=/ || $url =~ /op=/)) {
# $url = $self->session->url->append($url, "op=viewMessageLogMessage");
# }
# $status = $_[5];
# $from = $_[6];
# if ($groupId ne "") {
# @users = $self->session->db->buildArray("select userId from groupings where groupId=".$self->session->db->quote($groupId));
# }
# @users = ($userId,@users) if ($userId ne "" && !isIn($userId, @users));
# foreach $user (@users) {
# $u = WebGUI::User->new($user);
# if ($u->userId ne "") {
# $self->session->db->write("insert into messageLog (messageLogId, userId, message, url, dateOfEntry,
# subject, status) values (".$self->session->db->quote($messageLogId).",".$self->session->db->quote($u->userId).",
# ".$self->session->db->quote($message).",".$self->session->db->quote($url).","$self->session->datetime->time().",".$self->session->db->quote($subject).", ".$self->session->db->quote($status).")");
# if ($url ne "") {
# $message .= "\n".$self->session->url->append($url,'mlog='.$messageLogId);
# }
# _notify($u,$subject,$message,$from);
# }
# }
}
#-------------------------------------------------------------------
=head2 addInternationalizedEntry ( userId, groupId, url, internationalId [ , namespace, status ] )
Adds an entry to the message log using a translated message from the internationalization system and sends out notifications to users.
=head3 userId
The id of the user that should receive this notification.
B<NOTE:> This can be left blank if you're specifying a groupId.
=head3 groupId
The id of the group that should receive this notification.
B<NOTE:> This can be left blank if you're specifying a userId.
=head3 url
The URL of any action that should be taken based upon this notification (if any).
=head3 internationalId
The unique identifier from the internationalization system of the message to send.
=head3 namespace
The namespace from the internationalization system of the message to send. Defaults to "WebGUI";
=head3 status
Defaults to 'notice'. Can be 'pending', 'notice', or 'completed'.
=cut
sub addInternationalizedEntry {
# my ($u, $userId, $url, $groupId, $internationalId, @users, $messageLogId,$sth, $user, %message, %subject, $message, $subject, $namespace, $status);
# $messageLogId = $self->session->id->generate();
# $userId = $_[0];
# $groupId = $_[1];
# $url = $_[2];
# if ($url && !$url =~ /^http/) {
# $url = $self->session->url->getSiteURL().$url;
# }
# if ($url && !($url =~ /func=/ || $url =~ /op=/)) {
# $url = $self->session->url->append($url, "op=viewMessageLogMessage");
# }
# $internationalId = $_[3];
# $namespace = $_[4] || "WebGUI";
# $status = $_[5] || 'notice';
# my $languages = WebGUI::International::getLanguages();
# foreach my $language (keys %{$languages}) {
# $message{$language} = WebGUI::International::get($internationalId,$namespace,$language);
# $subject{$language} = WebGUI::International::get(523,"WebGUI",$language);
# }
# if ($groupId ne "") {
# @users = $self->session->db->buildArray("select userId from groupings where groupId=".$self->session->db->quote($groupId));
# }
# @users = ($userId,@users) if ($userId ne "" && !isIn($userId, @users));
# foreach $user (@users) {
# $u = WebGUI::User->new($user);
# if ($u->userId ne "") {
# $subject{$u->profileField("language")} = $subject{1} if ($subject{$u->profileField("language")} eq "");
# $subject = $subject{$u->profileField("language")};
# $message{$u->profileField("language")} = $message{1} if ($message{$u->profileField("language")} eq "");
# $message = $message{$u->profileField("language")};
# WebGUI::Macro::process($self->session,\$message);
# $self->session->db->write("insert into messageLog values (".$self->session->db->quote($messageLogId).",".$self->session->db->quote($u->userId).",
# ".$self->session->db->quote($message).",".$self->session->db->quote($url).","$self->session->datetime->time().",".$self->session->db->quote($message).",".$self->session->db->quote($status).")");
# if ($url ne "") {
# $message .= "\n".$self->session->url->append($url,'mlog='.$messageLogId);
# }
# _notify($u,$subject,$message);
# }
# }
}
#-------------------------------------------------------------------
=head2 completeEntry ( messageLogId )
Set a message log entry to complete.
=head3 messageLogId
The id of the message to complete.
=cut
sub completeEntry {
# $self->session->db->write("update messageLog set status='completed', dateOfEntry="$self->session->datetime->time()." where messageLogId=".$self->session->db->quote($_[0]));
}
1;

View file

@ -141,8 +141,8 @@ sub getOperations {
'viewHelpIndex' => 'WebGUI::Operation::Help',
'viewHelpTOC' => 'WebGUI::Operation::Help',
'viewHelpChapter' => 'WebGUI::Operation::Help',
'viewMessageLog' => 'WebGUI::Operation::MessageLog',
'viewMessageLogMessage' => 'WebGUI::Operation::MessageLog',
'viewInbox' => 'WebGUI::Operation::Inbox',
'viewInboxMessage' => 'WebGUI::Operation::Inbox',
'editProfile' => 'WebGUI::Operation::Profile',
'editProfileSave' => 'WebGUI::Operation::Profile',
'viewProfile' => 'WebGUI::Operation::Profile',

View 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;

View file

@ -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;

View file

@ -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") {

View file

@ -884,11 +884,6 @@ to add or remove users from their groups.
lastUpdated => 1031514049
},
'519' => {
message => q|I would not like to be notified.|,
lastUpdated => 1031514049
},
'1074' => {
message => q|Style templates are a special kind of template in WebGUI. They allow you to keep your content separated from the look and feel of your site. The following are the template variables available in style templates:
@ -1537,11 +1532,6 @@ As with any delete operation, you are prompted to be sure you wish to proceed wi
lastUpdated => 1100154599
},
'520' => {
message => q|I would like to be notified via email.|,
lastUpdated => 1031514049
},
'1004' => {
message => q|Cache external groups for how long?|,
lastUpdated => 1057208065
@ -2054,11 +2044,6 @@ You can find out more about karma in <a href="http://www.plainblack.com/ruling_w
lastUpdated => 1031514049
},
'521' => {
message => q|I would like to be notified via email to pager.|,
lastUpdated => 1031514049
},
'880' => {
message => q|Last Resort Editor|,
lastUpdated => 1044705137
@ -2546,11 +2531,6 @@ The headings of columns on things like message boards and user contributions.
lastUpdated => 1058092984
},
'518' => {
message => q|Inbox Notifications|,
lastUpdated => 1031514049
},
'748' => {
message => q|User Count|,
lastUpdated => 1036553016
@ -2626,11 +2606,6 @@ As with any delete operation, you are prompted to be sure you wish to proceed wi
lastUpdated => 1031514049
},
'522' => {
message => q|I would like to be notified via ICQ.|,
lastUpdated => 1031514049
},
'44' => {
message => q|Yes, I'm sure.|,
lastUpdated => 1031514049