[pLog-svn] r5639 - in plog/trunk/class: action/admin dao
mark at devel.lifetype.net
mark at devel.lifetype.net
Tue Jul 10 09:21:49 EDT 2007
Author: mark
Date: 2007-07-10 09:21:48 -0400 (Tue, 10 Jul 2007)
New Revision: 5639
Modified:
plog/trunk/class/action/admin/adminsendprivatemessageaction.class.php
plog/trunk/class/dao/privatemessage.class.php
plog/trunk/class/dao/privatemessagebox.class.php
plog/trunk/class/dao/privatemessageboxes.class.php
plog/trunk/class/dao/privatemessages.class.php
Log:
Some more updates,end private message works now, but the in/outbox list view still not working.
Modified: plog/trunk/class/action/admin/adminsendprivatemessageaction.class.php
===================================================================
--- plog/trunk/class/action/admin/adminsendprivatemessageaction.class.php 2007-07-10 11:31:28 UTC (rev 5638)
+++ plog/trunk/class/action/admin/adminsendprivatemessageaction.class.php 2007-07-10 13:21:48 UTC (rev 5639)
@@ -3,7 +3,7 @@
lt_include( PLOG_CLASS_PATH."class/dao/privatemessages.class.php" );
lt_include( PLOG_CLASS_PATH."class/data/validator/stringvalidator.class.php" );
lt_include( PLOG_CLASS_PATH."class/view/admin/admintemplatedview.class.php" );
- lt_include( PLOG_CLASS_PATH."class/view/admin/adminoutgoingprivatemessageslistview.class.php" );
+ lt_include( PLOG_CLASS_PATH."class/view/admin/adminprivatemessagesoutboxlistview.class.php" );
/**
* \ingroup Action
@@ -70,23 +70,38 @@
$this->_receiverId = $receiver->getId();
$this->_senderId = $this->_userInfo->getId();
+ // get private message inbox from receiver id
+ lt_include( PLOG_CLASS_PATH."class/dao/privatemessageboxes.class.php" );
+ $privateMessageBoxes = new PrivateMessageBoxes();
+ $receiverInbox = $privateMessageBoxes->getPrivateMessageInboxFromUserId( $this->_receiverId );
+
// create the private message object...
lt_include( PLOG_CLASS_PATH."class/dao/privatemessages.class.php" );
$privateMessages = new PrivateMessages();
- $privateMessage = new PrivateMessage( $this->_receiverId,
- $this->_senderId,
- $this->_subject,
- $this->_messageText );
+ $receiverPrivateMessage = new PrivateMessage( $receiverInbox->getId(),
+ $this->_receiverId,
+ $this->_senderId,
+ $this->_subject,
+ $this->_messageText );
// fire the pre event...
- $this->notifyEvent( EVENT_PRE_SEND_PRIVATE_MESSAGE, Array( "privatemessage" => &$privateMessage ));
+ $this->notifyEvent( EVENT_PRE_SEND_PRIVATE_MESSAGE, Array( "privatemessage" => &$receiverPrivateMessage ));
// once we have built the object, we can add it to the database!
- if( $privateMessages->addPrivateMessage( $privateMessage )) {
- $this->_view = new AdminOutgoingPrivateMessagesListView( $this->_blogInfo );
+ if( $privateMessages->addPrivateMessage( $receiverPrivateMessage )) {
+ if( $this->_backupPrivateMessage ) {
+ $senderOutbox = $privateMessageBoxes->getPrivateMessageOutboxFromUserId( $this->_senderId );
+ $senderPrivateMessage = new PrivateMessage( $senderOutbox->getId(),
+ $this->_receiverId,
+ $this->_senderId,
+ $this->_subject,
+ $this->_messageText );
+ $privateMessages->addPrivateMessage( $senderPrivateMessage );
+ }
+ $this->_view = new AdminPrivateMessagesOutboxListView( $this->_blogInfo );
$this->_view->setSuccess( true );
- $this->_view->setSuccessMessage( $this->_locale->pr("private_message_sended_ok", $privateMessage->getSubject()));
- $this->notifyEvent( EVENT_POST_SEND_PRIVATE_MESSAGE, Array( "privatemessage" => &$privateMessage ));
+ $this->_view->setSuccessMessage( $this->_locale->pr("private_message_sended_ok", $receiverPrivateMessage->getSubject()));
+ $this->notifyEvent( EVENT_POST_SEND_PRIVATE_MESSAGE, Array( "privatemessage" => &$receiverPrivateMessage ));
$this->sendPrivateMessageEmail( $receiver );
Modified: plog/trunk/class/dao/privatemessage.class.php
===================================================================
--- plog/trunk/class/dao/privatemessage.class.php 2007-07-10 11:31:28 UTC (rev 5638)
+++ plog/trunk/class/dao/privatemessage.class.php 2007-07-10 13:21:48 UTC (rev 5639)
@@ -30,9 +30,8 @@
var $_senderInfo;
var $_box;
- function PrivateMessage( $boxId, $receiverId, $senderId, $subject, $message, $date,
- $receiverReadStatus = PRIVATE_MESSAGE_RECEIVER_UNREAD,
- $id = -1 )
+ function PrivateMessage( $boxId, $receiverId, $senderId, $subject, $message, $date = '',
+ $receiverReadStatus = PRIVATE_MESSAGE_RECEIVER_UNREAD, $id = -1 )
{
$this->DbObject();
@@ -43,20 +42,27 @@
$this->_senderId = $senderId;
$this->_subject = $subject;
$this->_message = $message;
- $this->_date = $date;
+ if( $this->_date == '' ) {
+ lt_include( PLOG_CLASS_PATH."class/data/timestamp.class.php" );
+ $this->_timestamp = new Timestamp();
+ $this->_date = $this->_timestamp->getTimestamp();
+ } else {
+ $this->_date = $date;
+ $this->_timestamp = null;
+ }
$this->_receiverReadStatus = $receiverReadStatus;
$this->_id = $id;
$this->_normalizedSubject = '';
$this->_normalizedMessage = '';
- $this->_timestamp = null;
$this->_receiverInfo = null;
$this->_senderInfo = null;
$this->_box = null;
$this->_pk = "id";
$this->_fields = Array(
+ "box_id" => "getBoxId",
"receiver_id" => "getReceiverId",
"sender_id" => "getSenderId",
"subject" => "getSubject",
@@ -104,6 +110,7 @@
return $this->_box;
}
+
/**
* Returns the receiver id of this message
*
Modified: plog/trunk/class/dao/privatemessagebox.class.php
===================================================================
--- plog/trunk/class/dao/privatemessagebox.class.php 2007-07-10 11:31:28 UTC (rev 5638)
+++ plog/trunk/class/dao/privatemessagebox.class.php 2007-07-10 13:21:48 UTC (rev 5639)
@@ -141,7 +141,7 @@
*/
function setNumUnreadPrivateMessages( $numUnreadPrivateMessages )
{
- return $this->_numUnreadPrivateMessages;
+ $this->_numUnreadPrivateMessages = $numUnreadPrivateMessages;
}
/**
@@ -153,7 +153,7 @@
*/
function setNumPrivateMessages( $numPrivateMessages )
{
- return $this->_numPrivateMessages;
+ $this->_numPrivateMessages = $numPrivateMessages;
}
/**
Modified: plog/trunk/class/dao/privatemessageboxes.class.php
===================================================================
--- plog/trunk/class/dao/privatemessageboxes.class.php 2007-07-10 11:31:28 UTC (rev 5638)
+++ plog/trunk/class/dao/privatemessageboxes.class.php 2007-07-10 13:21:48 UTC (rev 5639)
@@ -36,7 +36,8 @@
*/
function getPrivateMessageInboxFromUserId( $userId )
{
- if( $box = $this->_cache->getData( $userId, CACHE_PRIVATE_MESSAGE_INBOX_BY_USERID ) )
+ $inbox = $this->_cache->getData( $userId, CACHE_PRIVATE_MESSAGE_INBOX_BY_USERID );
+ if( empty( $inbox ) )
{
$query = "SELECT * FROM ".$this->table." WHERE user_id = ".$userId;
$query .= " AND box_type = ".BOX_TYPE_INBOX;
@@ -47,11 +48,11 @@
return( Array());
$row = $result->FetchRow();
- $box = $this->mapRow( $row );
- $this->_cache->setData( $userId, CACHE_PRIVATE_MESSAGE_INBOX_BY_USERID, $box );
- }
+ $inbox = $this->mapRow( $row );
+ $this->_cache->setData( $userId, CACHE_PRIVATE_MESSAGE_INBOX_BY_USERID, $inbox );
+ }
- return( $box );
+ return( $inbox );
}
/**
@@ -62,22 +63,24 @@
*/
function getPrivateMessageOutboxFromUserId( $userId )
{
- if( $box = $this->_cache->getData( $userId, CACHE_PRIVATE_MESSAGE_OUTBOX_BY_USERID ) )
+ $outbox = $this->_cache->getData( $userId, CACHE_PRIVATE_MESSAGE_OUTBOX_BY_USERID );
+ if( empty( $outbox ) )
{
$query = "SELECT * FROM ".$this->table." WHERE user_id = ".$userId;
$query .= " AND box_type = ".BOX_TYPE_OUTBOX;
+ echo $query;
$result = $this->Execute( $query );
if( !$result )
return( Array());
$row = $result->FetchRow();
- $box = $this->mapRow( $row );
- $this->_cache->setData( $userId, CACHE_PRIVATE_MESSAGE_OUTBOX_BY_USERID, $box );
- }
+ $outbox = $this->mapRow( $row );
+ $this->_cache->setData( $userId, CACHE_PRIVATE_MESSAGE_OUTBOX_BY_USERID, $outbox );
+ }
- return( $box );
+ return( $outbox );
}
/**
Modified: plog/trunk/class/dao/privatemessages.class.php
===================================================================
--- plog/trunk/class/dao/privatemessages.class.php 2007-07-10 11:31:28 UTC (rev 5638)
+++ plog/trunk/class/dao/privatemessages.class.php 2007-07-10 13:21:48 UTC (rev 5639)
@@ -37,7 +37,6 @@
$box = $privateMessage->getBox();
$box->setNumPrivateMessages( $box->getNumPrivateMessages() + 1 );
$box->setNumUnreadPrivateMessages( $box->getNumUnreadPrivateMessages() + 1 );
- lt_include( PLOG_CLASS_PATH."class/dao/users.class.php" );
$privateMessageBoxes = new PrivateMessageBoxes();
$privateMessageBoxes->updatePrivateMessageBox( $box );
}
@@ -72,18 +71,16 @@
$privateMessage->getReceiverReadStatus() == PRIVATE_MESSAGE_RECEIVER_READ )
{
$box->setNumUnreadPrivateMessages( $box->getNumUnreadPrivateMessages() - 1 );
- lt_include( PLOG_CLASS_PATH."class/dao/users.class.php" );
$privateMessageBoxes = new PrivateMessageBoxes();
$privateMessageBoxes->updatePrivateMessageBox( $box );
} elseif ( $prevVersion->getReceiverReadStatus() == PRIVATE_MESSAGE_RECEIVER_READ &&
$privateMessage->getReceiverReadStatus() == PRIVATE_MESSAGE_RECEIVER_UNREAD )
{
$box->setNumUnreadPrivateMessages( $box->getNumUnreadPrivateMessages() + 1 );
- lt_include( PLOG_CLASS_PATH."class/dao/users.class.php" );
$privateMessageBoxes = new PrivateMessageBoxes();
$privateMessageBoxes->updatePrivateMessageBox( $box );
}
-
+
return true;
}
@@ -189,7 +186,6 @@
{
$box->setNumUnreadPrivateMessages( $box->getNumUnreadPrivateMessages() - 1 );
}
- lt_include( PLOG_CLASS_PATH."class/dao/users.class.php" );
$privateMessageBoxes = new PrivateMessageBoxes();
$privateMessageBoxes->updatePrivateMessageBox( $box );
More information about the pLog-svn
mailing list