[pLog-svn] r5637 - in plog/trunk: class/action/admin class/controller class/dao class/dao/userdata class/plugin class/view/admin install templates/admin
mark at devel.lifetype.net
mark at devel.lifetype.net
Tue Jul 10 06:56:14 EDT 2007
Author: mark
Date: 2007-07-10 06:56:14 -0400 (Tue, 10 Jul 2007)
New Revision: 5637
Added:
plog/trunk/class/action/admin/admineditincomingprivatemessagesaction.class.php
plog/trunk/class/action/admin/admineditoutgoingprivatemessagesaction.class.php
plog/trunk/class/action/admin/adminnewprivatemessageaction.class.php
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/privatemessagereceiverreadstatus.class.php
plog/trunk/class/dao/privatemessages.class.php
plog/trunk/class/view/admin/adminincomingprivatemessageslistview.class.php
plog/trunk/class/view/admin/adminoutgoingprivatemessageslistview.class.php
plog/trunk/templates/admin/editincomingprivatemessages.template
plog/trunk/templates/admin/editoutgoingprivatemessages.template
plog/trunk/templates/admin/newprivatemessage.template
Removed:
plog/trunk/class/dao/privatemessage.php
plog/trunk/class/dao/privatemessages.php
plog/trunk/class/dao/privatemessagestatus.php
Modified:
plog/trunk/class/controller/admincontrollermap.properties.php
plog/trunk/class/dao/daocacheconstants.properties.php
plog/trunk/class/dao/userdata/baseuserdataprovider.class.php
plog/trunk/class/dao/userinfo.class.php
plog/trunk/class/plugin/eventlist.properties.php
plog/trunk/install/dbschemas.properties.php
plog/trunk/templates/admin/menus.xml
Log:
Check in the WIP of private messages. It is still not workable, so ... don't test it!
Added: plog/trunk/class/action/admin/admineditincomingprivatemessagesaction.class.php
===================================================================
--- plog/trunk/class/action/admin/admineditincomingprivatemessagesaction.class.php (rev 0)
+++ plog/trunk/class/action/admin/admineditincomingprivatemessagesaction.class.php 2007-07-10 10:56:14 UTC (rev 5637)
@@ -0,0 +1,37 @@
+<?php
+
+ lt_include( PLOG_CLASS_PATH."class/action/admin/adminaction.class.php" );
+ lt_include( PLOG_CLASS_PATH."class/view/admin/adminincomingprivatemessageslistview.class.php" );
+
+ /**
+ * \ingroup Action
+ * @private
+ *
+ * Action that shows the list privatemessages
+ */
+ class AdminEditIncomingPrivateMessagesAction extends AdminAction
+ {
+
+ /**
+ * Constructor. If nothing else, it also has to call the constructor of the parent
+ * class, BlogAction with the same parameters
+ */
+ function AdminEditIncomingPrivateMessagesAction( $actionInfo, $request )
+ {
+ $this->AdminAction( $actionInfo, $request );
+ }
+
+ /**
+ * Carries out the specified action
+ */
+ function perform()
+ {
+ $searchTerms = $this->_request->getValue( "searchTerms" );
+ $this->_view = new AdminIncomingPrivateMessagesListView( $this->_blogInfo, Array( "searchTerms" => $searchTerms ) );
+ $this->setCommonData();
+
+ // better to return true if everything fine
+ return true;
+ }
+ }
+?>
\ No newline at end of file
Added: plog/trunk/class/action/admin/admineditoutgoingprivatemessagesaction.class.php
===================================================================
--- plog/trunk/class/action/admin/admineditoutgoingprivatemessagesaction.class.php (rev 0)
+++ plog/trunk/class/action/admin/admineditoutgoingprivatemessagesaction.class.php 2007-07-10 10:56:14 UTC (rev 5637)
@@ -0,0 +1,37 @@
+<?php
+
+ lt_include( PLOG_CLASS_PATH."class/action/admin/adminaction.class.php" );
+ lt_include( PLOG_CLASS_PATH."class/view/admin/adminoutgoingprivatemessageslistview.class.php" );
+
+ /**
+ * \ingroup Action
+ * @private
+ *
+ * Action that shows the list privatemessages
+ */
+ class AdminEditOutgoingPrivateMessagesAction extends AdminAction
+ {
+
+ /**
+ * Constructor. If nothing else, it also has to call the constructor of the parent
+ * class, BlogAction with the same parameters
+ */
+ function AdminEditOutgoingPrivateMessagesAction( $actionInfo, $request )
+ {
+ $this->AdminAction( $actionInfo, $request );
+ }
+
+ /**
+ * Carries out the specified action
+ */
+ function perform()
+ {
+ $searchTerms = $this->_request->getValue( "searchTerms" );
+ $this->_view = new AdminOutgoingPrivateMessagesListView( $this->_blogInfo, Array( "searchTerms" => $searchTerms ) );
+ $this->setCommonData();
+
+ // better to return true if everything fine
+ return true;
+ }
+ }
+?>
\ No newline at end of file
Added: plog/trunk/class/action/admin/adminnewprivatemessageaction.class.php
===================================================================
--- plog/trunk/class/action/admin/adminnewprivatemessageaction.class.php (rev 0)
+++ plog/trunk/class/action/admin/adminnewprivatemessageaction.class.php 2007-07-10 10:56:14 UTC (rev 5637)
@@ -0,0 +1,33 @@
+<?php
+ lt_include( PLOG_CLASS_PATH."class/action/admin/adminaction.class.php" );
+ lt_include( PLOG_CLASS_PATH."class/view/admin/admintemplatedview.class.php" );
+
+ /**
+ * \ingroup Action
+ * @private
+ *
+ * Action that adds a new private message to the database
+ */
+ class AdminNewPrivateMessageAction extends AdminAction
+ {
+
+ /**
+ * Constructor. If nothing else, it also has to call the constructor of the parent
+ * class, BlogAction with the same parameters
+ */
+ function AdminNewPrivateMessageAction( $actionInfo, $request )
+ {
+ $this->AdminAction( $actionInfo, $request );
+ }
+
+ /**
+ * Carries out the specified action
+ */
+ function perform()
+ {
+ // initialize the view
+ $this->_view = new AdminTemplatedView( $this->_blogInfo, "newprivatemessage" );
+ $this->setCommonData();
+ }
+ }
+?>
\ No newline at end of file
Added: plog/trunk/class/action/admin/adminsendprivatemessageaction.class.php
===================================================================
--- plog/trunk/class/action/admin/adminsendprivatemessageaction.class.php (rev 0)
+++ plog/trunk/class/action/admin/adminsendprivatemessageaction.class.php 2007-07-10 10:56:14 UTC (rev 5637)
@@ -0,0 +1,127 @@
+<?php
+ lt_include( PLOG_CLASS_PATH."class/action/admin/adminaction.class.php" );
+ 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" );
+
+ /**
+ * \ingroup Action
+ * @private
+ *
+ * Action that adds a new private message to the database.
+ */
+ class AdminSendPrivateMessageAction extends AdminAction
+ {
+
+ var $_receiverName;
+ var $_subject;
+ var $_messageText;
+ var $_receiverId;
+ var $_senderId;
+ var $_backupPrivateMessage;
+
+ /**
+ * Constructor. If nothing else, it also has to call the constructor of the parent
+ * class, BlogAction with the same parameters
+ */
+ function AdminSendPrivateMessageAction( $actionInfo, $request )
+ {
+ $this->AdminAction( $actionInfo, $request );
+
+ // register two validators
+ $this->registerFieldValidator( "receiverName", new StringValidator() );
+ $this->registerFieldValidator( "subject", new StringValidator() );
+ $this->registerFieldValidator( "messageText", new StringValidator() );
+ $this->registerField( "backupPrivateMessage" );
+ // and the view we should show in case there is a validation error
+ $errorView = new AdminTemplatedView( $this->_blogInfo, "newprivatemessage" );
+ $errorView->setErrorMessage( $this->_locale->tr("error_sending_private_message" ));
+ $this->setValidationErrorView( $errorView );
+ }
+
+ /**
+ * Carries out the specified action
+ */
+ function perform()
+ {
+ // fetch the data, we already know it's valid and that we can trust it!
+ $this->_receiverName = Textfilter::filterAllHTML( $this->_request->getValue( "receiverName" ) );
+ $this->_subject = Textfilter::filterAllHTML( $this->_request->getValue( "subject" ) );
+ $this->_messageText = Textfilter::filterAllHTML( $this->_request->getValue( "messageText" ) );
+ $this->_backupPrivateMessage = $this->_request->getValue("backupPrivateMessage") ? 1 : 0;
+
+ // check the receiver exist or not
+ lt_include( PLOG_CLASS_PATH."class/dao/users.class.php" );
+ $users = new Users();
+ $receiver = $users->getUserInfoFromUsername( $this->_receiverName );
+
+ // see if the user exists
+ if( !$receiver || $receiver->getId() == $this->_userInfo->getId() ) {
+ $this->_view = new AdminTemplatedView( $this->_blogInfo, "newprivatemessage" );
+ $this->_view->setErrorMessage( $this->_locale->pr("error_invalid_receiver", $this->_receiverName) );
+ $this->_form->setFieldValidationStatus( "receiverName", false );
+ $this->setCommonData( true );
+
+ return false;
+ }
+
+ // retrive receiverId & senderId
+ $this->_receiverId = $receiver->getId();
+ $this->_senderId = $this->_userInfo->getId();
+
+ // 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 );
+
+ // fire the pre event...
+ $this->notifyEvent( EVENT_PRE_SEND_PRIVATE_MESSAGE, Array( "privatemessage" => &$privateMessage ));
+
+ // once we have built the object, we can add it to the database!
+ if( $privateMessages->addPrivateMessage( $privateMessage )) {
+ $this->_view = new AdminOutgoingPrivateMessagesListView( $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->sendPrivateMessageEmail( $receiver );
+
+ $this->setCommonData();
+ }
+ else {
+ // if there was an error, we should say so... as well as not changing the view since
+ $this->_view = new AdminTemplatedView( $this->_blogInfo, "newprivatemessage" );
+ $this->_view->setError( true );
+ $this->_view->setErrorMessage( $this->_locale->tr("error_sending_private_message" ));
+ $this->setCommonData( true );
+ }
+
+ return true;
+ }
+
+ function sendPrivateMessageEmail( $userInfo )
+ {
+ // if everything went fine, we can now send the private message to the receiver
+ // only if the receiver specified a valid email address
+ if( $userInfo->getEmail() != "" ) {
+ lt_include( PLOG_CLASS_PATH."class/mail/emailservice.class.php" );
+
+ // build an email message
+ $emailMessage = new EmailMessage();
+ $emailMessage->setBody( $this->_messageText );
+ $emailMessage->setSubject( "[Private Message]" . $this->_subject );
+ $emailMessage->addTo( $userInfo->getEmail());
+ $emailMessage->setFrom( $this->_userInfo->getEmail());
+ // and finally send it
+ $emailService = new EmailService();
+ $emailService->sendMessage( $emailMessage );
+ }
+
+ return true;
+ }
+ }
+?>
\ No newline at end of file
Modified: plog/trunk/class/controller/admincontrollermap.properties.php
===================================================================
--- plog/trunk/class/controller/admincontrollermap.properties.php 2007-07-09 21:32:01 UTC (rev 5636)
+++ plog/trunk/class/controller/admincontrollermap.properties.php 2007-07-10 10:56:14 UTC (rev 5637)
@@ -348,4 +348,13 @@
$actions["deleteFriends"] = "AdminDeleteFriendAction";
$actions["deleteFriend"] = "AdminDeleteFriendAction";
$actions["updateFriend"] = "AdminUpdateFriendAction";
+ // add this for private messages
+ $actions["newPrivateMessage"] = "AdminNewPrivateMessageAction";
+ $actions["sendPrivateMessage"] = "AdminSendPrivateMessageAction";
+ $actions["editIncomingPrivateMessages"] = "AdminEditIncomingPrivateMessagesAction";
+ $actions["editOutgoingPrivateMessages"] = "AdminEditOutgoingPrivateMessagesAction";
+ $actions["readPrivateMessage"] = "AdminReadPrivateMessageAction";
+ $actions["replyPrivateMessage"] = "AdminReplyPrivateMessageAction";
+ $actions["deletePrivateMessages"] = "AdminDeletePrivateMessageAction";
+ $actions["deletePrivateMessage"] = "AdminDeletePrivateMessageAction";
?>
\ No newline at end of file
Modified: plog/trunk/class/dao/daocacheconstants.properties.php
===================================================================
--- plog/trunk/class/dao/daocacheconstants.properties.php 2007-07-09 21:32:01 UTC (rev 5636)
+++ plog/trunk/class/dao/daocacheconstants.properties.php 2007-07-10 10:56:14 UTC (rev 5637)
@@ -126,6 +126,13 @@
define( "CACHE_FRIENDS", "friends" );
/**
+ * private message box
+ */
+ define( "CACHE_PRIVATE_MESSAGE_BOXES", "cache_private_message_BOXES" );
+ define( "CACHE_PRIVATE_MESSAGE_INBOX_BY_USERID", "cache_private_message_inbox_by_userid" );
+ define( "CACHE_PRIVATE_MESSAGE_OUTBOX_BY_USERID", "cache_private_message_outboxbox_by_userid" );
+
+ /**
* private messages
*/
define( "CACHE_PRIVATE_MESSAGES", "cache_private_messages" );
Copied: plog/trunk/class/dao/privatemessage.class.php (from rev 5636, plog/trunk/class/dao/privatemessage.php)
===================================================================
--- plog/trunk/class/dao/privatemessage.class.php (rev 0)
+++ plog/trunk/class/dao/privatemessage.class.php 2007-07-10 10:56:14 UTC (rev 5637)
@@ -0,0 +1,324 @@
+<?php
+
+ lt_include( PLOG_CLASS_PATH."class/database/dbobject.class.php" );
+ lt_include( PLOG_CLASS_PATH."class/dao/privatemessagereceiverreadstatus.class.php" );
+
+ /**
+ * \ingroup DAO
+ *
+ * This is the representation of a private message. It contains all the information we need to know,
+ * such as the boxId, senderId, receiverId, subject, message, date created and whether it's been read
+ * by the receiver yet.
+ */
+ class PrivateMessage extends DbObject
+ {
+
+ // the keys representing a message in the db.
+ var $_id;
+ var $_boxId;
+ var $_receiverId;
+ var $_senderId;
+ var $_subject;
+ var $_message;
+ var $_normalizedSubject;
+ var $_normalizedMessage;
+ var $_date;
+ var $_receiverReadStatus;
+
+ var $_timestamp;
+ var $_receiverInfo;
+ var $_senderInfo;
+ var $_box;
+
+ function PrivateMessage( $boxId, $receiverId, $senderId, $subject, $message, $date,
+ $receiverReadStatus = PRIVATE_MESSAGE_RECEIVER_UNREAD,
+ $id = -1 )
+ {
+
+ $this->DbObject();
+
+ //filling up the object-variables
+ $this->_boxId = $boxId;
+ $this->_receiverId = $receiverId;
+ $this->_senderId = $senderId;
+ $this->_subject = $subject;
+ $this->_message = $message;
+ $this->_date = $date;
+ $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(
+ "receiver_id" => "getReceiverId",
+ "sender_id" => "getSenderId",
+ "subject" => "getSubject",
+ "message" => "getMessage",
+ "normalized_subject" => "getNormalizedSubject",
+ "normalized_message" => "getNormalizedMessage",
+ "date" => "getDate",
+ "receiver_read_status" => "getReceiverReadStatus"
+ );
+ }
+
+ /**
+ * Returns the identifier of this message.
+ *
+ * @return An integer value with the identifier of this message.
+ */
+ function getId()
+ {
+ return $this->_id;
+ }
+
+ /**
+ * Returns the box id of this message
+ *
+ * @return An integer representing the id of the message
+ */
+ function getBoxId()
+ {
+ return $this->_boxId;
+ }
+
+ /**
+ * Returns the PrivateMessageBox object of this message
+ *
+ * @return A PrivateMessageBox of the message
+ */
+ function getBox()
+ {
+ if( empty( $this->_box ) ){
+ lt_include( PLOG_CLASS_PATH."class/dao/privatemessagebox.class.php" );
+
+ $privateMessageBoxes = new PrivateMessageBoxes();
+ $this->_box = $privateMessageBoxes->getPrivateMessageBox( $this->_boxId );
+ }
+ return $this->_box;
+ }
+
+ /**
+ * Returns the receiver id of this message
+ *
+ * @return An integer representing the id of the receiver
+ */
+ function getReceiverId()
+ {
+ return $this->_receiverId;
+ }
+
+ /**
+ * Returns the receiver info of this message
+ *
+ * @return a UserInfo of the receiver
+ */
+ function getReceiverInfo() {
+ if( empty( $this->_receiverInfo ) ){
+ lt_include( PLOG_CLASS_PATH."class/dao/users.class.php" );
+
+ $users = new Users();
+ $this->_receiverInfo = $users->getUserInfoFromId($this->_receiverId);
+ }
+ return $this->_receiverInfo;
+ }
+
+ /**
+ * Returns the sender id of this message
+ *
+ * @return An integer value representing the identifier of the user who is sending the message.
+ */
+ function getSenderId()
+ {
+ return $this->_senderId;
+ }
+
+ function getSenderInfo() {
+ if( empty( $this->_senderInfo ) ){
+ lt_include( PLOG_CLASS_PATH."class/dao/users.class.php" );
+
+ $users = new Users();
+ $this->_senderInfo = $users->getUserInfoFromId($this->_sender);
+ }
+ return $this->_senderInfo;
+ }
+
+ /**
+ * Returns the subject of this message
+ *
+ * @return A string containing the subject of this message.
+ */
+ function getSubject()
+ {
+ return $this->_subject;
+ }
+
+ /**
+ * Returns the message in this message
+ *
+ * @return A string containing the text in this message.
+ */
+ function getMessage()
+ {
+ return $this->_message;
+ }
+
+ /**
+ * returns the normalized subject
+ *
+ * @return the normalized sibject
+ */
+ function getNormalizedSubject()
+ {
+ if( $this->_normalizedSubject == "" ) {
+ $this->setNormalizedSubject( $this->getSubject());
+ }
+
+ return( $this->_normalizedSubject );
+ }
+
+ /**
+ * returns the normalized message
+ *
+ * @return the normalized message
+ */
+ function getNormalizedMessage()
+ {
+ if( $this->_normalizedMessage == "" ) {
+ $this->setNormalizedMessage( $this->getMessage());
+ }
+
+ return( $this->_normalizedMessage );
+ }
+
+ /**
+ * Returns the create_date for this message.
+ *
+ * @return Returns the create_date..
+ */
+ function getDate()
+ {
+ return $this->_date;
+ }
+
+ /**
+ * Returns the create date object for this message.
+ *
+ * @return Returns the create date object..
+ */
+ function getDateObject()
+ {
+ if( empty( $this->_timestamp ) ) {
+ lt_include( PLOG_CLASS_PATH."class/data/timestamp.class.php" );
+ $this->_timestamp = new Timestamp($this->_date);
+ }
+
+ return $this->_timestamp;
+ }
+
+ /**
+ * @private
+ */
+ function getReceiverReadStatus()
+ {
+ return $this->_receiverReadStatus;
+ }
+
+ /**
+ * @private
+ */
+ function setId( $id )
+ {
+ $this->_id = $id;
+ }
+
+ /**
+ * @private
+ */
+ function setBoxId( $newBoxId )
+ {
+ $this->_boxId = $newBoxId;
+ }
+
+ /**
+ * @private
+ */
+ function setReceiverId( $newReceiverId )
+ {
+ $this->_receiverId = $newReceiverId;
+ }
+
+ /**
+ * @private
+ */
+ function setSenderId( $newSenderId )
+ {
+ $this->_senderId = $newSenderId;
+ }
+
+ /**
+ * @private
+ */
+ function setSubject( $newSubject )
+ {
+ $this->_subject = $newSubject;
+ }
+
+ /**
+ * @private
+ */
+ function setMessasge( $newMessage )
+ {
+ $this->_message = $newMessage;
+ }
+
+ /**
+ * sets the normalized subject
+ *
+ * @param normalizedSubject
+ */
+ function setNormalizedSubject( $normalizedSubject )
+ {
+ // do a normalization again, just in case
+ lt_include( PLOG_CLASS_PATH."class/data/textfilter.class.php" );
+ $this->_normalizedSubject = TextFilter::normalizeText( $normalizedSubject );
+ }
+
+ /**
+ * sets the normalized message
+ *
+ * @param normalizedMessage
+ */
+ function setNormalizedMessage( $normalizedMessage )
+ {
+ // do a normalization again, just in case
+ lt_include( PLOG_CLASS_PATH."class/data/textfilter.class.php" );
+ $this->_normalizedMessage = TextFilter::normalizeText( $normalizedMessage );
+ }
+
+ /**
+ * @private
+ */
+ function setDate( $newDate )
+ {
+ lt_include( PLOG_CLASS_PATH."class/data/timestamp.class.php" );
+
+ $this->_date = $newDate;
+ $this->_timestamp = new Timestamp( $newDate );
+ }
+
+ /**
+ * @private
+ */
+ function setReceiverReadStatus( $newReceiverReadStatus )
+ {
+ $this->_receiverReadStatus = $newReceiverReadStatus;
+ }
+ }
+?>
\ No newline at end of file
Deleted: plog/trunk/class/dao/privatemessage.php
===================================================================
--- plog/trunk/class/dao/privatemessage.php 2007-07-09 21:32:01 UTC (rev 5636)
+++ plog/trunk/class/dao/privatemessage.php 2007-07-10 10:56:14 UTC (rev 5637)
@@ -1,218 +0,0 @@
-<?php
-
- lt_include( PLOG_CLASS_PATH."class/database/dbobject.class.php" );
- lt_include( PLOG_CLASS_PATH."class/dao/privatemessagestatus.class.php" );
-
- /**
- * \ingroup DAO
- *
- * This is the representation of a private message. It contains all the information we need to know,
- * such as the senderId, receiverId, subject, message, date created and whether it's been read by the user yet.
- */
- class PrivateMessage extends DbObject
- {
-
- // the keys representing a message in the db.
- var $_id;
- var $_receiverId;
- var $_senderId;
- var $_subject;
- var $_message;
- var $_date;
- var $_timestamp;
- var $_status;
-
- function PrivateMessage( $receiverId, $senderId, $subject, $message, $date = "",
- $status = PRIVATE_MESSAGE_UNREAD, $id = -1 ) {
-
- $this->DbObject();
- lt_include( PLOG_CLASS_PATH.'class/data/timestamp.class.php' );
-
- //filling up the object-variables
- $this->_receiverId = $receiverId;
- $this->_senderId = $senderId;
- $this->_subject = $subject;
- $this->_message = $message;
- $this->_date = $date;
- $this->_status = $status;
- $this->_id = $id;
-
- // if we're creating a new Message, then we're inserting the current date.
- if( $date == "" ) {
- lt_include( PLOG_CLASS_PATH."class/data/Date.class.php" );
- $dateObject = new Date();
- $date = $dateObject->getDate();
- }
- $this->setDate( $date );
-
- $this->_pk = "id";
- $this->_fields = Array(
- "receiver_id" => "getReceiverId",
- "sender_id" => "getSenderId",
- "subject" => "getSubject",
- "message" => "getMessage",
- "date" => "getDate",
- "status" => "getStatus"
- );
- }
-
- /**
- * Returns the identifier of this message.
- *
- * @return An integer value with the identifier of this message.
- */
- function getId()
- {
- return $this->_id;
- }
-
- /**
- * Returns the receiver id of this message
- *
- * @return An integer representing the id of the receiver
- */
- function getReceiverId()
- {
- return $this->_receiverId;
- }
-
- /**
- * Returns the receiver info of this message
- *
- * @return An integer representing the id of the receiver
- */
- function getReceiverInfo() {
- lt_include( PLOG_CLASS_PATH."class/dao/users.class.php" );
-
- $users = new Users();
- $user = $users->getUserInfoFromId($this->_receiver);
- return $user;
- }
-
- /**
- * Returns the sender id of this message
- *
- * @return An integer value representing the identifier of the user who is sending the message.
- */
- function getSenderId()
- {
- return $this->_senderId;
- }
-
- function getSenderInfo() {
- lt_include( PLOG_CLASS_PATH."class/dao/users.class.php" );
-
- $users = new Users();
- $user = $users->getUserInfoFromId($this->_sender);
- return $user;
- }
-
- /**
- * Returns the subject of this message
- *
- * @return A string containing the subject of this message.
- */
- function getSubject()
- {
- return $this->_subject;
- }
-
- /**
- * Returns the message in this message
- *
- * @return A string containing the text in this message.
- */
- function getMessage()
- {
- return $this->_message;
- }
-
-
- /**
- * Returns the create_date for this message.
- *
- * @return Returns the create_date..
- */
- function getDate()
- {
- return $this->_date;
- }
-
- /**
- * Returns the create date object for this message.
- *
- * @return Returns the create date object..
- */
- function getDateObject()
- {
- return $this->_timestamp;
- }
-
- /**
- * @private
- */
- function getStatus()
- {
- return $this->_status;
- }
-
- /**
- * @private
- */
- function setId( $id )
- {
- $this->_id = $id;
- }
-
- /**
- * @private
- */
- function setReceiverId( $newReceiverId )
- {
- $this->_receiverId = $newReceiverId;
- }
-
- /**
- * @private
- */
- function setSenderId( $newSenderId )
- {
- $this->_senderId = $newSenderId;
- }
-
- /**
- * @private
- */
- function setSubject( $newSubject )
- {
- $this->_subject = $newSubject;
- }
-
- /**
- * @private
- */
- function setMessasge( $newMessage )
- {
- $this->_message = $newMessage;
- }
-
- /**
- * @private
- */
- function setDate( $newDate )
- {
- lt_include( PLOG_CLASS_PATH."class/data/timestamp.class.php" );
-
- $this->_date = $newDate;
- $this->_timestamp = new Timestamp( $newDate );
- }
-
- /**
- * @private
- */
- function setStatus( $status )
- {
- $this->_status = $status;
- }
- }
-?>
\ No newline at end of file
Added: plog/trunk/class/dao/privatemessagebox.class.php
===================================================================
--- plog/trunk/class/dao/privatemessagebox.class.php (rev 0)
+++ plog/trunk/class/dao/privatemessagebox.class.php 2007-07-10 10:56:14 UTC (rev 5637)
@@ -0,0 +1,179 @@
+<?php
+
+ lt_include( PLOG_CLASS_PATH."class/database/dbobject.class.php" );
+
+ /**
+ * whether we'd like to fetch a inbox, outbox or anything
+ */
+ define( "BOX_TYPE_INBOX", 1 );
+ define( "BOX_TYPE_OUTBOX", 2 );
+ define( "BOX_TYPE_ANY", -1 );
+
+ /**
+ * \ingroup DAO
+ *
+ * The private messages one can add to a user can also be filed under different boxes.
+ * This object are the abstraction of those boxes and offer methods to check the value
+ * of some of its attributes.
+ */
+ class PrivateMessageBox extends DbObject
+ {
+
+ var $_id;
+ var $_userId;
+ var $_boxType;
+ var $_numUnreadPrivateMessages;
+ var $_numPrivateMessages;
+ var $_privateMessages;
+
+ /**
+ * Constructor.
+ *
+ * @param userId Identifier of the user to which it belongs
+ * @param boxType the private message box type
+ * @param id Identifier of the message box
+ */
+ function PrivateMessageBox( $userId, $boxType, $properties = Array(), $id = -1 )
+ {
+ lt_include( PLOG_CLASS_PATH."class/data/timestamp.class.php" );
+
+ $this->DbObject();
+
+ $this->_userId = $userId;
+ $this->_boxType = $boxType;
+ $this->setProperties( $properties );
+ $this->_id = $id;
+
+ $this->_numUnreadPrivateMessages = 0;
+ $this->_numPrivateMessages = 0;
+ $this->_privateMessages = null;
+
+ $this->_pk = "id";
+ $this->_fields = Array(
+ "user_id" => "getUserId",
+ "box_type" => "getBoxType",
+ "properties" => "getProperties",
+ "num_unread_messages" => "getNumUnreadPrivateMessages",
+ "num_messages" => "getNumPrivateMessages"
+ );
+ }
+
+ /**
+ * Returns the identifier assigned to this message box in the database.
+ *
+ * @return The identifier assigned to this message box in the database.
+ */
+ function getId()
+ {
+ return $this->_id;
+ }
+
+ /**
+ * Returns the user identifier to which this this message box belongs.
+ *
+ * @return An integer value.
+ */
+ function getUserId()
+ {
+ return $this->_userId;
+ }
+
+ /**
+ * Returns the type to which this this message box belongs.
+ *
+ * @return An integer value.
+ */
+ function getBoxType()
+ {
+ return $this->_boxType;
+ }
+
+ /**
+ * Returns how many messages no readed under this message box.
+ *
+ * @return Number of unread messages.
+ */
+ function getNumUnreadPrivateMessages()
+ {
+ return $this->_numUnreadPrivateMessages;
+ }
+
+ /**
+ * Returns how many messages have been file under this message box.
+ *
+ * @return Number of messages.
+ */
+ function getNumPrivateMessages()
+ {
+ return $this->_numPrivateMessages;
+ }
+
+ /**
+ * @private
+ */
+ function setId( $id )
+ {
+ $this->_id = $id;
+ }
+
+ /**
+ * @private
+ */
+ function setUserId( $userId )
+ {
+ $this->_userId = $userId;
+ }
+
+ /**
+ * @private
+ */
+ function setBoxType( $boxType )
+ {
+ $this->_boxType = $boxType;
+ }
+
+ /**
+ * Returns assign many unread private messages have been filed under this message box.
+ *
+ * @param Number of unread messages.
+ *
+ * @return nothing
+ */
+ function setNumUnreadPrivateMessages( $numUnreadPrivateMessages )
+ {
+ return $this->_numUnreadPrivateMessages;
+ }
+
+ /**
+ * Returns assign many private messages have been filed under this message box.
+ *
+ * @param Number of messages.
+ *
+ * @return nothing
+ */
+ function setNumPrivateMessages( $numPrivateMessages )
+ {
+ return $this->_numPrivateMessages;
+ }
+
+ /**
+ * Returns an array of private messages
+ *
+ * @return Array of PrivateMessage object
+ */
+ function getPrivateMessages( $userId, $searchTerms = "", $page = -1, $itemsPerPage = 15 )
+ {
+ lt_include( PLOG_CLASS_PATH."class/dao/privatemessage.class.php" );
+ $privateMessages = new PrivateMessages();
+ if( $this->_boxType == BOX_TYPE_INBOX ) {
+ $boxMessages = $privateMessages->getInboxPrivateMessages( $userId, $searchTerms, $page, $itemsPerPage );
+ } elseif( $this->_boxType == BOX_TYPE_OUTBOX ) {
+ $boxMessages = $privateMessages->getOutboxPrivateMessages( $userId, $searchTerms, $page, $itemsPerPage );
+ } else {
+ $boxMessages = $privateMessages->getPrivateMessages( $userId, $searchTerms, $page, $itemsPerPage );
+ }
+
+ return $boxMessages;
+ }
+ }
+?>
\ No newline at end of file
Added: plog/trunk/class/dao/privatemessageboxes.class.php
===================================================================
--- plog/trunk/class/dao/privatemessageboxes.class.php (rev 0)
+++ plog/trunk/class/dao/privatemessageboxes.class.php 2007-07-10 10:56:14 UTC (rev 5637)
@@ -0,0 +1,166 @@
+<?php
+
+ lt_include( PLOG_CLASS_PATH."class/dao/model.class.php" );
+ lt_include( PLOG_CLASS_PATH."class/dao/privatemessagebox.class.php" );
+
+ /**
+ * \ingroup DAO
+ *
+ * Provides an interface for working with PrivateMessageBoxes objects
+ */
+ class PrivateMessageBoxes extends Model
+ {
+
+ function PrivateMessageBoxes()
+ {
+ $this->Model();
+ $this->table = $this->getPrefix()."private_message_boxes";
+ }
+
+ /**
+ * loads the given private message box identifier
+ *
+ * @param id
+ * @return false if there was an error loading or a PrivateMessageBox object if it was found
+ */
+ function getPrivateMessageBox( $id )
+ {
+ return( $this->get( "id", $id, CACHE_PRIVATE_MESSAGE_BOXES ));
+ }
+
+ /**
+ * loads the private message inbox from user identifier
+ *
+ * @param user identifier
+ * @return false if there was an error loading or a PrivateMessageBox object if it was found
+ */
+ function getPrivateMessageInboxFromUserId( $userId )
+ {
+ if( $box = $this->_cache->getData( $userId, CACHE_PRIVATE_MESSAGE_INBOX_BY_USERID ) )
+ {
+ $query = "SELECT * FROM ".$this->table." WHERE user_id = ".$userId;
+ $query .= " AND box_type = ".BOX_TYPE_INBOX;
+
+ $result = $this->Execute( $query );
+
+ if( !$result )
+ return( Array());
+
+ $row = $result->FetchRow();
+ $box = $this->mapRow( $row );
+ $this->_cache->setData( $userId, CACHE_PRIVATE_MESSAGE_INBOX_BY_USERID, $box );
+ }
+
+ return( $box );
+ }
+
+ /**
+ * loads the private message outbox from user identifier
+ *
+ * @param user identifier
+ * @return false if there was an error loading or a PrivateMessageBox object if it was found
+ */
+ function getPrivateMessageOutboxFromUserId( $userId )
+ {
+ if( $box = $this->_cache->getData( $userId, CACHE_PRIVATE_MESSAGE_OUTBOX_BY_USERID ) )
+ {
+ $query = "SELECT * FROM ".$this->table." WHERE user_id = ".$userId;
+ $query .= " AND box_type = ".BOX_TYPE_OUTBOX;
+
+ $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 );
+ }
+
+ return( $box );
+ }
+
+ /**
+ * adds a new private message outbox
+ *
+ * @param privateMessageBox A PrivateMessageBox object
+ * @return true if successful or false otherwise. Upon success, $privateMessageBox->getId() will
+ * return the new id assigned to the object in the db.
+ */
+ function addPrivateMessageBox( &$privateMessageBox )
+ {
+ $result = $this->add( $privateMessageBox, Array( CACHE_PRIVATE_MESSAGE_BOXES => "getId" ));
+
+ return( $result );
+ }
+
+ /**
+ * deletes a private message outbox. Warning: the upper layers must have already made sure that there
+ * are no private messages that point to this private message box *before* removing it, or else we could
+ * have problems with data integrity.
+ *
+ * @param id
+ * @return True if successful, false otherwise
+ */
+ function deletePrivateMessageBox( $id )
+ {
+ $box = $this->getPrivateMessageBox( $id );
+ if(!$box)
+ return flase;
+
+ if( $box->getNumPrivateMessages() > 0 )
+ return flase;
+
+ $userId = $box->getUserId();
+ $boxType = $box->getBoxType();
+
+ if( ($result = $this->delete( "id", $id ))) {
+ $this->_cache->removeData( $id, CACHE_PRIVATE_MESSAGE_BOXES );
+ if( $boxType == BOX_TYPE_INBOX )
+ $this->_cache->removeData( $userId, CACHE_PRIVATE_MESSAGE_INBOX_BY_USERID );
+ elseif( $boxType == BOX_TYPE_OUTBOX )
+ $this->_cache->removeData( $userId, CACHE_PRIVATE_MESSAGE_OUTBOX_BY_USERID );
+ }
+
+ return( $result );
+ }
+
+ /**
+ * update a given private message outbox
+ *
+ * @param privateMessageBox A PrivateMessageBox object
+ * @return True if successful or false otherwise
+ */
+ function updatePrivateMessageBox( $privateMessageBox )
+ {
+ $id = $privateMessageBox->getId();
+ $userId = $privateMessageBox->getUserId();
+ $boxType = $privateMessageBox->getBoxType();
+
+ if( ($result = $this->update( $privateMessageBox ))) {
+ $this->_cache->removeData( $id, CACHE_PRIVATE_MESSAGE_BOXES );
+ if( $boxType == BOX_TYPE_INBOX )
+ $this->_cache->removeData( $userId, CACHE_PRIVATE_MESSAGE_INBOX_BY_USERID );
+ elseif( $boxType == BOX_TYPE_OUTBOX )
+ $this->_cache->removeData( $userId, CACHE_PRIVATE_MESSAGE_OUTBOX_BY_USERID );
+ }
+
+ return( $result );
+ }
+
+ /**
+ * @private
+ */
+ function mapRow( $row )
+ {
+ $privateMessageBox = new PrivateMessageBox( $row["user_id"],
+ $row["box_type"],
+ unserialize($row["properties"]),
+ $row["id"] );
+ $privateMessageBox->setNumUnreadPrivateMessages( $row["num_unread_messages"] );
+ $privateMessageBox->setNumPrivateMessages( $row["num_messages"] );
+
+ return( $privateMessageBox );
+ }
+ }
+?>
\ No newline at end of file
Copied: plog/trunk/class/dao/privatemessagereceiverreadstatus.class.php (from rev 5636, plog/trunk/class/dao/privatemessagestatus.php)
===================================================================
--- plog/trunk/class/dao/privatemessagereceiverreadstatus.class.php (rev 0)
+++ plog/trunk/class/dao/privatemessagereceiverreadstatus.class.php 2007-07-10 10:56:14 UTC (rev 5637)
@@ -0,0 +1,52 @@
+<?php
+
+ lt_include( PLOG_CLASS_PATH."class/dao/status/genericstatuslist.class.php" );
+
+ define( "PRIVATE_MESSAGE_RECEIVER_ALL", -1, true );
+ define( "PRIVATE_MESSAGE_RECEIVER_UNREAD", 1, true );
+ define( "PRIVATE_MESSAGE_RECEIVER_READ", 2, true );
+
+ /**
+ * This class keeps track of all the possible status that a private message can have. If plugins dynamically
+ * register new private message statuses, this class will still be able to handle them
+ *
+ * \ingroup DAO
+ */
+ class PrivateMessageReceiverReadStatus extends GenericStatusList
+ {
+
+ /**
+ * returns a list with all the private message statuses that have been defined
+ * so far in the code.
+ *
+ * @return Returns an array where every position is an array with two
+ * keys: "constant" and "value", where "constant" is the name of the constant
+ * that defines this status and "value" is the value assigned to it
+ */
+ function getStatusList( $includeStatusAll = false )
+ {
+ return( GenericStatusList::getStatusList( "PRIVATE_MESSAGE_RECEIVER_", "PRIVATE_MESSAGE_RECEIVER_ALL", $includeStatusAll ));
+ }
+
+ /**
+ * @param status The status code we'd like to check
+ *
+ * @return Returns true if the status is valid or false otherwise
+ */
+ function isValidStatus( $status )
+ {
+ $statusList = PrivateMessageReceiverReadStatus::getStatusList( true );
+ return( in_array( $status, $statusList ));
+ }
+
+ /**
+ * returns the default status code for this class
+ *
+ * @return The default status
+ */
+ function getDefaultStatus()
+ {
+ return( PRIVATE_MESSAGE_RECEIVER_ALL );
+ }
+ }
+?>
\ No newline at end of file
Copied: plog/trunk/class/dao/privatemessages.class.php (from rev 5636, plog/trunk/class/dao/privatemessages.php)
===================================================================
--- plog/trunk/class/dao/privatemessages.class.php (rev 0)
+++ plog/trunk/class/dao/privatemessages.class.php 2007-07-10 10:56:14 UTC (rev 5637)
@@ -0,0 +1,259 @@
+<?php
+
+ lt_include( PLOG_CLASS_PATH."class/dao/model.class.php" );
+ lt_include( PLOG_CLASS_PATH."class/dao/privatemessage.class.php" );
+
+ /**
+ * \ingroup DAO
+ *
+ * Model for the private message feature
+ */
+ class PrivateMessages extends Model
+ {
+
+ function PrivateMessages()
+ {
+ $this->Model();
+
+ $this->table = $this->getPrefix()."private_messages";
+ }
+
+ /**
+ * Adds a private message to the database
+ *
+ * @param privateMessage a PrivateMessage Object
+ * @return True if successful or false otherwise.
+ */
+ function addPrivateMessage( $privateMessage )
+ {
+ $result = $this->add( $privateMessage );
+
+ if( $result ) {
+ // clean the cache
+ $this->_cache->removeData( $privateMessage->getId(), CACHE_PRIVATE_MESSAGES );
+ $this->_cache->removeData( $privateMessage->getReceiverId(), CACHE_PRIVATE_MESSAGES_BY_RECEIVER_ID );
+ $this->_cache->removeData( $privateMessage->getSenderId(), CACHE_PRIVATE_MESSAGES_BY_SENDER_ID );
+ // update corresponding counters
+ $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 );
+ }
+
+ return $result;
+ }
+
+ /**
+ * Updates a private message to the database
+ *
+ * @param $privateMessage a PrivateMessage object
+ * @return True if successful or false otherwise.
+ */
+ function updatePrivateMessage( &$privateMessage )
+ {
+ // get the previous version of this private message before saving it
+ $prevVersion = $this->getPrivateMessage( $privateMessage->getId());
+
+ $result = $this->update( $privateMessage );
+
+ if( !$result ) {
+ return false;
+ }
+
+ // clean the cache
+ $this->_cache->removeData( $privateMessage->getId(), CACHE_PRIVATE_MESSAGES );
+ $this->_cache->removeData( $privateMessage->getReceiverId(), CACHE_PRIVATE_MESSAGES_BY_RECEIVER_ID );
+ $this->_cache->removeData( $privateMessage->getSenderId(), CACHE_PRIVATE_MESSAGES_BY_SENDER_ID );
+ // update corresponding counters
+ $box = $prevVersion->getBox();
+ if( $prevVersion->getReceiverReadStatus() == PRIVATE_MESSAGE_RECEIVER_UNREAD &&
+ $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;
+ }
+
+ /**
+ * Mark private message as read, a shortcut to updatePrivateMessage
+ *
+ * @param $privateMessage a PrivateMessage object
+ * @return True if successful or false otherwise.
+ */
+ function markPrivateMessasgeAsRead( &$privateMessage )
+ {
+ $privateMessage->setStatus( PRIVATE_MESSAGE_READ );
+ $result = $this->updatePrivateMessage( $privateMessage );
+
+ return $result;
+ }
+
+ /**
+ * Mark private message as unread, a shortcut to updatePrivateMessage
+ *
+ * @param $privateMessage a PrivateMessage object
+ * @return True if successful or false otherwise.
+ */
+ function markPrivateMessasgeAsUnread( &$privateMessage )
+ {
+ $privateMessage->setStatus( PRIVATE_MESSAGE_UNREAD );
+ $result = $this->updatePrivateMessage( $privateMessage );
+
+ return $result;
+ }
+
+ /**
+ * Get all iprivate messages from a boxId from the db.
+ *
+ * @param boxId Box identifier of the message
+ * @param searchTerms
+ * @param page
+ * @param itemsPerPage
+ * @return Returns an array of Private Messages for that specific Receiver.
+ */
+ function getPrivateMessagesFromBoxId( $boxId, $searchTerms = "", $page = -1, $itemsPerPage = 15 )
+ {
+ $privateMessages = $this->getMany( "box_id",
+ $boxId,
+ CACHE_PRIVATE_MESSAGES_BY_RECEIVER_ID,
+ Array( CACHE_PRIVATE_MESSAGES => "getId" ),
+ Array( "date" => "DESC" ),
+ $searchTerms,
+ $page,
+ $itemsPerPage );
+
+ if( !$privateMessages )
+ return Array();
+ else
+ return( $privateMessages );
+ }
+
+ function getNumIncomingMessagesFromReceiverId( $boxId, $searchTerms = "" )
+ {
+ return( count( $this->getPrivateMessagesFromBoxId( $boxId, $searchTerms )));
+ }
+
+ /**
+ * get a specific private message from the db.
+ *
+ * @param $messageId The id of the private message.
+ * @param $receiverId The user identifier. Used as a securityfunction, so that you
+ * can only see your own private messages.
+ * @return Returns the specific private message as a PrivateMessage object.
+ */
+ function getPrivateMessage( $messageId, $receiverId = -1 )
+ {
+ $privateMessage = $this->get( "id", $messageId, CACHE_PRIVATE_MESSAGES );
+ if( !$privateMessage )
+ return false;
+
+ if( $privateMessage->getReceiverId() == $receiverId )
+ return $privateMessage;
+ else
+ return false;
+ }
+
+ /**
+ * Removes a private message object from the database.
+ *
+ * @param messageId The private message identifier.
+ * @param receiverId The receiver identifier.
+ * @return True if successful or false otherwise.
+ */
+ function deletePrivateMessage( $messageId, $receiverId )
+ {
+ $privateMessage = $this->getPrivateMessage( $$messageId, $receiverId );
+ if( $privateMessage ) {
+ $this->delete( "id", $$messageId );
+ $this->_cache->removeData( $privateMessage->getId(), CACHE_PRIVATE_MESSAGES );
+ $this->_cache->removeData( $privateMessage->getReceiverId(), CACHE_PRIVATE_MESSAGES_BY_RECEIVER_ID );
+ $this->_cache->removeData( $privateMessage->getSenderId(), CACHE_PRIVATE_MESSAGES_BY_SENDER_ID );
+
+ // update corresponding counters
+ $box = $privateMessage->getReceiverInfo();
+ $box->setNumPrivateMessages( $box->geNumPrivateMessages() - 1 );
+ if( $privateMessage->getStatus() == PRIVATE_MESSAGE_UNREAD )
+ {
+ $box->setNumUnreadPrivateMessages( $box->getNumUnreadPrivateMessages() - 1 );
+ }
+ lt_include( PLOG_CLASS_PATH."class/dao/users.class.php" );
+ $privateMessageBoxes = new PrivateMessageBoxes();
+ $privateMessageBoxes->updatePrivateMessageBox( $box );
+
+ return true;
+ }
+ else
+ return false;
+ }
+
+ /**
+ * Removes all the private messages from the given receiver id
+ *
+ * @param receiverId The receiver identifier
+ */
+ function deletePrivateMessagesByReceiverId( $receiverId )
+ {
+ if( $this->delete( "receiver_id", $receiverId )) {
+ return( $this->_cache->removeData( $receiverId, CACHE_PRIVATE_MESSAGES_BY_RECEIVER_ID ));
+ }
+ else
+ return false;
+ }
+
+ /**
+ * Removes all the private messages from the given sender id
+ *
+ * @param senderId The sender identifier
+ */
+ function deletePrivateMessagesBySenderId( $senderId )
+ {
+ if( $this->delete( "sender_id", $senderId )) {
+ return( $this->_cache->removeData( $senderId, CACHE_PRIVATE_MESSAGES_BY_SENDER_ID ));
+ }
+ else
+ return false;
+ }
+
+ /**
+ * @see Model::getSearchConditions
+ */
+ function getSearchConditions( $searchTerms )
+ {
+ return( "(normalized_subject LIKE '%".Db::qstr( $searchTerms )."%' OR normalized_message LIKE '%".Db::qstr( $searchTerms )."%')" );
+ }
+
+ /**
+ * @private
+ */
+ function mapRow( $row )
+ {
+ $privateMessage = new PrivateMessage( $row["box_id"],
+ $row["receiver_id"],
+ $row["sender_id"],
+ $row["subject"],
+ $row["message"],
+ $row["date"],
+ $row["receiver_read_status"],
+ $row["id"] );
+
+ // set the normalized text and topic
+ $privateMessage->setNormalizedSubject( $row['normalized_subject'] );
+ $privateMessage->setNormalizedMessage( $row['normalized_message'] );
+
+ return $privateMessage;
+ }
+ }
+?>
\ No newline at end of file
Deleted: plog/trunk/class/dao/privatemessages.php
===================================================================
--- plog/trunk/class/dao/privatemessages.php 2007-07-09 21:32:01 UTC (rev 5636)
+++ plog/trunk/class/dao/privatemessages.php 2007-07-10 10:56:14 UTC (rev 5637)
@@ -1,279 +0,0 @@
-<?php
-
- lt_include( PLOG_CLASS_PATH."class/dao/model.class.php" );
- lt_include( PLOG_CLASS_PATH."class/dao/privatemessagestatus.class.php" );
-
- /**
- * \ingroup DAO
- *
- * Model for the private message feature
- */
- class PrivateMessages extends Model
- {
-
- function PrivateMessages()
- {
- $this->Model();
-
- $this->table = $this->getPrefix()."private_messages";
- }
-
- /**
- * Adds a private message to the database
- *
- * @param privateMessage a PrivateMessage Object
- * @return True if successful or false otherwise.
- */
- function addPrivateMessage( $privateMessage )
- {
- $result = $this->add( $privateMessage );
-
- if( $result ) {
- // clean the cache
- $this->_cache->removeData( $privateMessage->getId(), CACHE_PRIVATE_MESSAGES );
- $this->_cache->removeData( $privateMessage->getReceiverId(), CACHE_PRIVATE_MESSAGES_BY_RECEIVER_ID );
- $this->_cache->removeData( $privateMessage->getSenderId(), CACHE_PRIVATE_MESSAGES_BY_SENDER_ID );
- // update corresponding counters
- $receiver = $privateMessage->getReceiverInfo();
- $receiver->setNumPrivateMessages( $receiver->getNumPrivateMessages() + 1 );
- $receiver->setNumUnreadPrivateMessages( $receiver->getNumUnreadPrivateMessages() + 1 );
- lt_include( PLOG_CLASS_PATH."class/dao/users.class.php" );
- $users = new Users();
- $users->updateUser( $receiver );
- }
-
- return $result;
- }
-
- /**
- * Updates a private message to the database
- *
- * @param $privateMessage a PrivateMessage object
- * @return True if successful or false otherwise.
- */
- function updatePrivateMessage( &$privateMessage )
- {
- // get the previous version of this private message before saving it
- $prevVersion = $this->getPrivateMessage( $privateMessage->getId());
-
- $result = $this->update( $privateMessage );
-
- if( !$result ) {
- return false;
- }
-
- // clean the cache
- $this->_cache->removeData( $privateMessage->getId(), CACHE_PRIVATE_MESSAGES );
- $this->_cache->removeData( $privateMessage->getReceiverId(), CACHE_PRIVATE_MESSAGES_BY_RECEIVER_ID );
- $this->_cache->removeData( $privateMessage->getSenderId(), CACHE_PRIVATE_MESSAGES_BY_SENDER_ID );
- // update corresponding counters
- $receiver = $prevVersion->getReceiverInfo();
- if( $prevVersion->getStatus() == PRIVATE_MESSAGE_UNREAD &&
- $privateMessage->getStatus() == PRIVATE_MESSAGE_READ )
- {
- $receiver->setNumUnreadPrivateMessages( $receiver->getNumUnreadPrivateMessages() - 1 );
- lt_include( PLOG_CLASS_PATH."class/dao/users.class.php" );
- $users = new Users();
- $users->updateUser( $receiver );
- } elseif ( $prevVersion->getStatus() == PRIVATE_MESSAGE_READ &&
- $privateMessage->getStatus() == PRIVATE_MESSAGE_UNREAD )
- {
- $receiver->setNumUnreadPrivateMessages( $receiver->getNumUnreadPrivateMessages() + 1 );
- lt_include( PLOG_CLASS_PATH."class/dao/users.class.php" );
- $users = new Users();
- $users->updateUser( $receiver );
- }
-
- return true;
- }
-
- /**
- * Mark private message as read, a shortcut to updatePrivateMessage
- *
- * @param $privateMessage a PrivateMessage object
- * @return True if successful or false otherwise.
- */
- function markPrivateMessasgeAsRead( &$privateMessage )
- {
- $privateMessage->setStatus( PRIVATE_MESSAGE_READ );
- $result = $this->updatePrivateMessage( $privateMessage );
-
- return $result;
- }
-
- /**
- * Mark private message as unread, a shortcut to updatePrivateMessage
- *
- * @param $privateMessage a PrivateMessage object
- * @return True if successful or false otherwise.
- */
- function markPrivateMessasgeAsUnread( &$privateMessage )
- {
- $privateMessage->setStatus( PRIVATE_MESSAGE_UNREAD );
- $result = $this->updatePrivateMessage( $privateMessage );
-
- return $result;
- }
-
- /**
- * Get all incoming private messages from a receiverId from the db.
- *
- * @param receiverId Receiver identifier of the message
- * @param searchTerms
- * @param page
- * @param itemsPerPage
- * @return Returns an array of Private Messages for that specific Receiver.
- */
- function getAllIncomingMessagesFromReceiverId( $receiverId, $searchTerms = "", $page = -1, $itemsPerPage = 15 )
- {
- $privateMessages = $this->getMany( "receiver_id",
- $receiverId,
- CACHE_PRIVATE_MESSAGES_BY_RECEIVER_ID,
- Array( CACHE_PRIVATE_MESSAGES => "getId" ),
- Array( "date" => "DESC" ),
- $searchTerms,
- $page,
- $itemsPerPage );
-
- if( !$privateMessages )
- return Array();
- else
- return( $privateMessages );
- }
-
- /**
- * Get all outgoing private messages for a senderId from the db.
- *
- * @param senderId Receiver identifier of the message
- * @param searchTerms
- * @param page
- * @param itemsPerPage
- * @return Returns an array of Private Messages for that specific Receiver.
- */
- function getAllOutgoingMessagesFromSenderId( $senderId, $searchTerms = "", $page = -1, $itemsPerPage = 15 )
- {
- $privateMessages = $this->getMany( "sender_id",
- $senderId,
- CACHE_PRIVATE_MESSAGES_BY_SENDER_ID,
- Array( CACHE_PRIVATE_MESSAGES => "getId" ),
- Array( "date" => "DESC" ),
- $searchTerms,
- $page,
- $itemsPerPage );
-
- if( !$privateMessages )
- return Array();
- else
- return( $privateMessages );
- }
-
- /**
- * get a specific private message from the db.
- *
- * @param $messageId The id of the private message.
- * @param $receiverId The user identifier. Used as a securityfunction, so that you
- * can only see your own private messages.
- * @return Returns the specific private message as a PrivateMessage object.
- */
- function getPrivateMessage( $messageId, $receiverId = -1 )
- {
- $privateMessage = $this->get( "id", $messageId, CACHE_PRIVATE_MESSAGES );
- if( !$privateMessage )
- return false;
-
- if( $privateMessage->getReceiverId() == $receiverId )
- return $privateMessage;
- else
- return false;
- }
-
- /**
- * Removes a private message object from the database.
- *
- * @param messageId The private message identifier.
- * @param receiverId The receiver identifier.
- * @return True if successful or false otherwise.
- */
- function deletePrivateMessage( $messageId, $receiverId )
- {
- $privateMessage = $this->getPrivateMessage( $$messageId, $receiverId );
- if( $privateMessage ) {
- $this->delete( "id", $$messageId );
- $this->_cache->removeData( $privateMessage->getId(), CACHE_PRIVATE_MESSAGES );
- $this->_cache->removeData( $privateMessage->getReceiverId(), CACHE_PRIVATE_MESSAGES_BY_RECEIVER_ID );
- $this->_cache->removeData( $privateMessage->getSenderId(), CACHE_PRIVATE_MESSAGES_BY_SENDER_ID );
-
- // update corresponding counters
- $receiver = $privateMessage->getReceiverInfo();
- $receiver->setNumPrivateMessages( $receiver->geNumPrivateMessages() - 1 );
- if( $privateMessage->getStatus() == PRIVATE_MESSAGE_UNREAD )
- {
- $receiver->setNumUnreadPrivateMessages( $receiver->getNumUnreadPrivateMessages() - 1 );
- lt_include( PLOG_CLASS_PATH."class/dao/users.class.php" );
- $users = new Users();
- $users->updateUser( $receiver );
- }
- lt_include( PLOG_CLASS_PATH."class/dao/users.class.php" );
- $users = new Users();
- $users->updateUser( $receiver );
-
- return true;
- }
- else
- return false;
- }
-
- /**
- * Removes all the private messages from the given receiver id
- *
- * @param receiverId The receiver identifier
- */
- function deletePrivateMessagesByReceiverId( $receiverId )
- {
- if( $this->delete( "receiver_id", $receiverId )) {
- return( $this->_cache->removeData( $receiverId, CACHE_PRIVATE_MESSAGES_BY_RECEIVER_ID ));
- }
- else
- return false;
- }
-
- /**
- * Removes all the private messages from the given sender id
- *
- * @param senderId The sender identifier
- */
- function deletePrivateMessagesBySenderId( $senderId )
- {
- if( $this->delete( "sender_id", $senderId )) {
- return( $this->_cache->removeData( $senderId, CACHE_PRIVATE_MESSAGES_BY_SENDER_ID ));
- }
- else
- return false;
- }
-
- /**
- * @see Model::getSearchConditions
- */
- function getSearchConditions( $searchTerms )
- {
- return( "(normalized_subject LIKE '%".Db::qstr( $searchTerms )."%' OR normalized_message LIKE '%".Db::qstr( $searchTerms )."%')" );
- }
-
- /**
- * @private
- */
- function mapRow( $row )
- {
- $privateMessage = new PrivateMessage( $row["sender_id"],
- $row["receiver_id"],
- $row["subject"],
- $row["message"],
- $row["date"],
- $row["status"],
- $row["id"] );
-
- return $privateMessage;
-
- }
- }
-?>
\ No newline at end of file
Deleted: plog/trunk/class/dao/privatemessagestatus.php
===================================================================
--- plog/trunk/class/dao/privatemessagestatus.php 2007-07-09 21:32:01 UTC (rev 5636)
+++ plog/trunk/class/dao/privatemessagestatus.php 2007-07-10 10:56:14 UTC (rev 5637)
@@ -1,52 +0,0 @@
-<?php
-
- lt_include( PLOG_CLASS_PATH."class/dao/status/genericstatuslist.class.php" );
-
- define( "PRIVATE_MESSAGE_ALL", -1, true );
- define( "PRIVATE_MESSAGE_UNREAD", 1, true );
- define( "PRIVATE_MESSAGE_READ", 2, true );
-
- /**
- * This class keeps track of all the possible status that a private message can have. If plugins dynamically
- * register new private message statuses, this class will still be able to handle them
- *
- * \ingroup DAO
- */
- class PrivateMessageStatus extends GenericStatusList
- {
-
- /**
- * returns a list with all the private message statuses that have been defined
- * so far in the code.
- *
- * @return Returns an array where every position is an array with two
- * keys: "constant" and "value", where "constant" is the name of the constant
- * that defines this status and "value" is the value assigned to it
- */
- function getStatusList( $includeStatusAll = false )
- {
- return( GenericStatusList::getStatusList( "PRIVATE_MESSAGE_", "PRIVATE_MESSAGE_ALL", $includeStatusAll ));
- }
-
- /**
- * @param status The status code we'd like to check
- *
- * @return Returns true if the status is valid or false otherwise
- */
- function isValidStatus( $status )
- {
- $statusList = PrivateMessageStatus::getStatusList( true );
- return( in_array( $status, $statusList ));
- }
-
- /**
- * returns the default status code for this class
- *
- * @return The default status
- */
- function getDefaultStatus()
- {
- return( PRIVATE_MESSAGE_ALL );
- }
- }
-?>
\ No newline at end of file
Modified: plog/trunk/class/dao/userdata/baseuserdataprovider.class.php
===================================================================
--- plog/trunk/class/dao/userdata/baseuserdataprovider.class.php 2007-07-09 21:32:01 UTC (rev 5636)
+++ plog/trunk/class/dao/userdata/baseuserdataprovider.class.php 2007-07-10 10:56:14 UTC (rev 5637)
@@ -158,8 +158,6 @@
isset( $query_result["site_admin"] ) ? $siteAdmin = $query_result["site_admin"] : $siteAdmin = 0;
$userInfo->setSiteAdmin( $siteAdmin );
$userInfo->setStatus( $query_result["status"] );
- $userInfo->setNumPrivateMessages( $query_result["num_messages"] );
- $userInfo->setNumUnreadPrivateMessages( $query_result["num_unread_messages"] );
return $userInfo;
}
Modified: plog/trunk/class/dao/userinfo.class.php
===================================================================
--- plog/trunk/class/dao/userinfo.class.php 2007-07-09 21:32:01 UTC (rev 5636)
+++ plog/trunk/class/dao/userinfo.class.php 2007-07-10 10:56:14 UTC (rev 5637)
@@ -25,8 +25,6 @@
var $_resourcePicture;
var $_status;
var $_perms;
- var $_numPrivateMessages;
- var $_numUnreadPrivateMessages;
/**
* Constructor. Creates a new UserInfo object with the given information.
@@ -63,10 +61,6 @@
// by defaults, users are in status "active"
$this->setStatus( USER_STATUS_ACTIVE );
- // add the private messages counters
- $this->_numPrivateMessages = 0;
- $this->_numUnreadPrivateMessages = 0;
-
$this->_pk = "id";
$this->_fields = Array(
"username" => "getUsername",
@@ -77,9 +71,7 @@
"properties" => "getProperties",
"status" => "getStatus",
"resource_picture_id" => "getPictureId",
- "site_admin" => "isSiteAdmin",
- "num_messages" => "getNumPrivateMessages",
- "num_unread_messages" => "getNumUnreadPrivateMessages"
+ "site_admin" => "isSiteAdmin"
);
}
@@ -376,25 +368,5 @@
return( $this->perms[$blogId] );
}
-
- function getNumPrivateMessages()
- {
- return( $this->_numPrivateMessages );
- }
-
- function setNumPrivateMessages( $newNumPrivateMessages )
- {
- $this->_numPrivateMessages = $newNumPrivateMessages;
- }
-
- function getNumUnreadPrivateMessages()
- {
- return( $this->_numUnreadPrivateMessages );
- }
-
- function setNumUnreadPrivateMessages( $newNumUnreadPrivateMessages )
- {
- $this->_numUnreadPrivateMessages = $newNumUnreadPrivateMessages;
- }
}
?>
Modified: plog/trunk/class/plugin/eventlist.properties.php
===================================================================
--- plog/trunk/class/plugin/eventlist.properties.php 2007-07-09 21:32:01 UTC (rev 5636)
+++ plog/trunk/class/plugin/eventlist.properties.php 2007-07-10 10:56:14 UTC (rev 5637)
@@ -205,4 +205,11 @@
define( "EVENT_POST_DELETE_FRIEND", ++$eventValue );
define( "EVENT_FRIEND_LOADED", ++$eventValue );
define( "EVENT_FRIENDS_LOADED", ++$eventValue );
+ // friends
+ define( "EVENT_PRE_SEND_PRIVATE_MESSAGE", ++$eventValue );
+ define( "EVENT_POST_SEND_PRIVATE_MESSAGE", ++$eventValue );
+ define( "EVENT_PRE_DELETE_PRIVATE_MESSAGE", ++$eventValue );
+ define( "EVENT_POST_DELETE_PRIVATE_MESSAGE", ++$eventValue );
+ define( "EVENT_PRIVATE_MESSAGE_LOADED", ++$eventValue );
+ define( "EVENT_PRIVATE_MESSAGES_LOADED", ++$eventValue );
?>
\ No newline at end of file
Added: plog/trunk/class/view/admin/adminincomingprivatemessageslistview.class.php
===================================================================
--- plog/trunk/class/view/admin/adminincomingprivatemessageslistview.class.php (rev 0)
+++ plog/trunk/class/view/admin/adminincomingprivatemessageslistview.class.php 2007-07-10 10:56:14 UTC (rev 5637)
@@ -0,0 +1,60 @@
+<?php
+
+ lt_include( PLOG_CLASS_PATH."class/view/admin/admintemplatedview.class.php" );
+ lt_include( PLOG_CLASS_PATH."class/dao/privatemessages.class.php" );
+ lt_include( PLOG_CLASS_PATH."class/data/pager/pager.class.php" );
+
+ /**
+ * \ingroup View
+ * @private
+ *
+ * shows a list of private messages
+ */
+ class AdminIncomingPrivateMessagesListView extends AdminTemplatedView
+ {
+ var $_page;
+
+ function AdminIncomingPrivateMessagesListView( $blogInfo, $params = Array())
+ {
+ $this->AdminTemplatedView( $blogInfo, "editincomingprivatemessages" );
+
+ // save the parameters and put them in a nicer place after checking them
+ if( !isset( $params["searchTerms"] ) ) $params["searchTerms"] = "";
+ $this->setValue( "searchTerms", $params["searchTerms"] );
+
+ $this->_page = $this->getCurrentPageFromRequest();
+ }
+
+ function render()
+ {
+ $searchTerms = $this->getValue( "searchTerms" );
+ $blogSettings = $this->_blogInfo->getSettings();
+ // get the private messages
+ $privateMessages = new PrivateMessages();
+ $incomingMessages = $privateMessages->getIncomingMessagesFromReceiverId( $this->_userInfo->getId(),
+ $searchTerms,
+ $this->_page,
+ DEFAULT_ITEMS_PER_PAGE );
+
+ // get the total number of private messages
+ $numIncomingPrivateMessages = $privateMessages->getNumIncomingMessagesFromReceiverId( $this->_userInfo->getId(), $searchTerms );
+
+ // throw the event
+ $this->notifyEvent( EVENT_PRIVATE_MESSAGES_LOADED, Array( "privatemessages" => &$incomingMessages ));
+
+ // create the pager
+ $pager = new Pager( "?op=editIncomingPrivateMessages&searchTerms={$searchTerms}&page=",
+ $this->_page,
+ $numIncomingPrivateMessages,
+ DEFAULT_ITEMS_PER_PAGE );
+
+ // create the view and fill the template context
+ $this->setValue( "privatemessages", $incomingMessages );
+ $this->setValue( "searchTerms", $searchTerms );
+ $this->setValue( "pager", $pager );
+
+ // transfer control to the parent class
+ parent::render();
+ }
+ }
+?>
\ No newline at end of file
Added: plog/trunk/class/view/admin/adminoutgoingprivatemessageslistview.class.php
===================================================================
--- plog/trunk/class/view/admin/adminoutgoingprivatemessageslistview.class.php (rev 0)
+++ plog/trunk/class/view/admin/adminoutgoingprivatemessageslistview.class.php 2007-07-10 10:56:14 UTC (rev 5637)
@@ -0,0 +1,60 @@
+<?php
+
+ lt_include( PLOG_CLASS_PATH."class/view/admin/admintemplatedview.class.php" );
+ lt_include( PLOG_CLASS_PATH."class/dao/privatemessages.class.php" );
+ lt_include( PLOG_CLASS_PATH."class/data/pager/pager.class.php" );
+
+ /**
+ * \ingroup View
+ * @private
+ *
+ * shows a list of private messages
+ */
+ class AdminOutgoingPrivateMessagesListView extends AdminTemplatedView
+ {
+ var $_page;
+
+ function AdminOutgoingPrivateMessagesListView( $blogInfo, $params = Array())
+ {
+ $this->AdminTemplatedView( $blogInfo, "editoutgoingprivatemessages" );
+
+ // save the parameters and put them in a nicer place after checking them
+ if( !isset( $params["searchTerms"] ) ) $params["searchTerms"] = "";
+ $this->setValue( "searchTerms", $params["searchTerms"] );
+
+ $this->_page = $this->getCurrentPageFromRequest();
+ }
+
+ function render()
+ {
+ $searchTerms = $this->getValue( "searchTerms" );
+ $blogSettings = $this->_blogInfo->getSettings();
+ // get the private messages
+ $privateMessages = new PrivateMessages();
+ $outgoingMessages = $privateMessages->getOutgoingMessagesFromSenderId( $this->_userInfo->getId(),
+ $searchTerms,
+ $this->_page,
+ DEFAULT_ITEMS_PER_PAGE );
+
+ // get the total number of private messages
+ $numOutgoingPrivateMessages = $privateMessages->getNumOutgoingMessagesFromSenderId( $this->_userInfo->getId(), $searchTerms );
+
+ // throw the event
+ $this->notifyEvent( EVENT_PRIVATE_MESSAGES_LOADED, Array( "privatemessages" => &$outgoingMessages ));
+
+ // create the pager
+ $pager = new Pager( "?op=editOutgoingPrivateMessages&searchTerms={$searchTerms}&page=",
+ $this->_page,
+ $numOutgoingPrivateMessages,
+ DEFAULT_ITEMS_PER_PAGE );
+
+ // create the view and fill the template context
+ $this->setValue( "privatemessages", $outgoingMessages );
+ $this->setValue( "searchTerms", $searchTerms );
+ $this->setValue( "pager", $pager );
+
+ // transfer control to the parent class
+ parent::render();
+ }
+ }
+?>
\ No newline at end of file
Modified: plog/trunk/install/dbschemas.properties.php
===================================================================
--- plog/trunk/install/dbschemas.properties.php 2007-07-09 21:32:01 UTC (rev 5636)
+++ plog/trunk/install/dbschemas.properties.php 2007-07-10 10:56:14 UTC (rev 5637)
@@ -170,8 +170,6 @@
resource_picture_id I(10) NOTNULL DEFAULT 0,
site_admin I(10) NOTNULL DEFAULT '0',
last_login T(14),
- num_unread_messages I(10) NOTNULL DEFAULT '0',
- num_messages I(10) NOTNULL DEFAULT '0',
UNIQUE user (user)
";
$Tables["users"]["options"]["mysql"] = "TYPE=MyISAM";
@@ -409,7 +407,6 @@
num_pending_friends I(10) NOTNULL DEFAULT '0',
INDEX mangled_name (mangled_name)
";
-
$Tables["friend_groups"]["options"]["mysql"] = "TYPE=MyISAM";
$Tables["friends"]["schema"] = "
@@ -427,18 +424,34 @@
";
$Tables["friends"]["options"]["mysql"] = "TYPE=MyISAM";
+$Tables["private_message_boxes"]["schema"] = "
+ id I(10) NOTNULL PRIMARY AUTOINCREMENT,
+ user_id I(10) NOTNULL,
+ box_type I(10) NOTNULL,
+ properties TEXT NOTNULL DEFAULT '',
+ num_unread_messages I(10) NOTNULL DEFAULT '0',
+ num_messages I(10) NOTNULL DEFAULT '0',
+ INDEX user_id (receiver_id),
+ UNIQUE user_id_box_type (user_id, box_type)
+";
+$Tables["private_message_boxes"]["options"]["mysql"] = "TYPE=MyISAM";
+
$Tables["private_messages"]["schema"] = "
id I(10) NOTNULL PRIMARY AUTOINCREMENT,
+ box_id I(10) UNSIGNED NOTNULL DEFAULT '0',
+ receiver_id I(10) NOTNULL,
sender_id I(10) NOTNULL,
- receiver_id I(10) NOTNULL,
subject TEXT NOTNULL,
message TEXT NOTNULL,
normalized_subject TEXT NOTNULL DEFAULT '',
normalized_message TEXT NOTNULL DEFAULT '',
date DATETIME NOTNULL,
- status I(1) NOTNULL DEFAULT 1,
+ receiver_read_status I(1) NOTNULL DEFAULT 1,
+ INDEX box_id (box_id),
+ INDEX receiver_id (receiver_id),
INDEX sender_id (sender_id),
- INDEX receiver_id (receiver_id),
+ INDEX receiver_id_box_id (receiver_id, box_id),
+ INDEX sender_id_box_id (sender_id, box_id),
FULLTEXT normalized_message (normalized_message),
FULLTEXT normalized_subject (normalized_subject),
FULLTEXT normalized_fields (normalized_message, normalized_subject)
Added: plog/trunk/templates/admin/editincomingprivatemessages.template
===================================================================
--- plog/trunk/templates/admin/editincomingprivatemessages.template (rev 0)
+++ plog/trunk/templates/admin/editincomingprivatemessages.template 2007-07-10 10:56:14 UTC (rev 5637)
@@ -0,0 +1,86 @@
+{include file="$admintemplatepath/header.template"}
+{include file="$admintemplatepath/navigation.template" showOpt=editIncomingPrivateMessages title=$locale->tr("editIncomingPrivateMessages")}
+<script type="text/javascript">
+{literal}
+YAHOO.util.Event.addListener( window, "load", function() {
+ var t = new Lifetype.UI.TableEffects( "list" );
+ t.stripe();
+ t.highlightRows();
+ });
+{/literal}
+</script>
+ <div id="list_nav_bar">
+ <div id="list_nav_select">
+
+<form id="viewIncomingPrivateMessages" action="admin.php" method="post">
+ <fieldset>
+ <legend>{$locale->tr("show_by")}</legend>
+
+ <div class="list_nav_option">
+ <label for="search">{$locale->tr("search_terms")}</label>
+ <br />
+ <input type="text" name="searchTerms" value="{$searchTerms}" size="15" id="search" />
+ </div>
+
+ <div class="list_nav_option">
+ <br />
+ <input type="hidden" name="op" value="editIncomingPrivateMessages" />
+ <input type="submit" name="Show" value="{$locale->tr("show")}" />
+ </div>
+ </fieldset>
+ </form>
+ </div>
+ <br style="clear:both" />
+ </div>
+
+ <form id="incomingPrivateMessages" action="admin.php" method="post">
+ <div id="list">
+ {include file="$admintemplatepath/successmessage.template"}
+ {include file="$admintemplatepath/errormessage.template"}
+ <table id="list" class="info" summary="{$locale->tr("editIncomingPrivateMessages")}">
+ <thead>
+ <tr>
+ <th><input class="checkbox" type="checkbox" name="all" id="all" value="1" onclick="toggleAllChecks('incomingPrivateMessages');" /></th>
+ <th style="width:20%">{$locale->tr("senderName")}</th>
+ <th style="width:10%">{$locale->tr("date")}</th>
+ <th style="width:50%">{$locale->tr("subject")}</th>
+ <th style="width:10%">{$locale->tr("status")}</th>
+ <th style="width:10%">{$locale->tr("actions")}</th>
+ </tr>
+ </thead>
+ <tbody>
+ {foreach from=$privatemessages item=privatemessage}
+ <tr>
+ <td align="center"><input class="checkbox" type="checkbox" name="messageIds[{counter}]" value="{$privatemessage->getId()}"/></td>
+ <td class="col_highlighted">
+ <a href="admin.php?op=readPrivateMessage&messageId={$privatemessage->getId()}">{$privatemessage->getSenderId()}</a>
+ </td>
+ <td>
+ <a href="admin.php?op=readPrivateMessage&messageId={$privatemessage->getId()}">{$privatemessage->getDate()}</a>
+ </td>
+ <td>
+ <a href="admin.php?op=readPrivateMessage&messageId={$privatemessage->getId()}">{$privatemessage->getSubject()}</a>
+ </td>
+ <td>
+ <a href="admin.php?op=readPrivateMessage&messageId={$privatemessage->getId()}">{$privatemessage->getStatus()}</a>
+ </td>
+ <td>
+ <div class="list_action_button">
+ <a href="?op=editLinkCategory&categoryId={$category->getId()}"><img src="imgs/admin/icon_edit-16.png" alt="{$locale->tr("edit")}" /></a>
+ <a href="?op=deleteLinkCategory&categoryId={$category->getId()}"><img src="imgs/admin/icon_delete-16.png" alt="{$locale->tr("delete")}" /></a>
+ </div>
+ </td>
+ </tr>
+ {/foreach}
+ </tbody>
+ </table>
+ </div>
+ <div id="list_action_bar">
+ {adminpager style=list}
+ <input type="hidden" name="op" value="deleteLinkCategories"/>
+ <input type="submit" name="Delete selected" value="{$locale->tr("delete")}"/>
+ </div>
+ </form>
+
+{include file="$admintemplatepath/footernavigation.template"}
+{include file="$admintemplatepath/footer.template"}
Added: plog/trunk/templates/admin/editoutgoingprivatemessages.template
===================================================================
--- plog/trunk/templates/admin/editoutgoingprivatemessages.template (rev 0)
+++ plog/trunk/templates/admin/editoutgoingprivatemessages.template 2007-07-10 10:56:14 UTC (rev 5637)
@@ -0,0 +1,82 @@
+{include file="$admintemplatepath/header.template"}
+{include file="$admintemplatepath/navigation.template" showOpt=editOutgoingPrivateMessages title=$locale->tr("editOutgoingPrivateMessages")}
+<script type="text/javascript">
+{literal}
+YAHOO.util.Event.addListener( window, "load", function() {
+ var t = new Lifetype.UI.TableEffects( "list" );
+ t.stripe();
+ t.highlightRows();
+ });
+{/literal}
+</script>
+ <div id="list_nav_bar">
+ <div id="list_nav_select">
+
+<form id="viewPrivateMessages" action="admin.php" method="post">
+ <fieldset>
+ <legend>{$locale->tr("show_by")}</legend>
+
+ <div class="list_nav_option">
+ <label for="search">{$locale->tr("search_terms")}</label>
+ <br />
+ <input type="text" name="searchTerms" value="{$searchTerms}" size="15" id="search" />
+ </div>
+
+ <div class="list_nav_option">
+ <br />
+ <input type="hidden" name="op" value="editOutgoingPrivateMessages" />
+ <input type="submit" name="Show" value="{$locale->tr("show")}" />
+ </div>
+ </fieldset>
+ </form>
+ </div>
+ <br style="clear:both" />
+ </div>
+
+ <form id="outgoingPrivateMessages" action="admin.php" method="post">
+ <div id="list">
+ {include file="$admintemplatepath/successmessage.template"}
+ {include file="$admintemplatepath/errormessage.template"}
+ <table id="list" class="info" summary="{$locale->tr("editOutgoingPrivateMessages")}">
+ <thead>
+ <tr>
+ <th><input class="checkbox" type="checkbox" name="all" id="all" value="1" onclick="toggleAllChecks('outgoingPrivateMessages');" /></th>
+ <th style="width:20%">{$locale->tr("senderName")}</th>
+ <th style="width:10%">{$locale->tr("date")}</th>
+ <th style="width:50%">{$locale->tr("subject")}</th>
+ <th style="width:10%">{$locale->tr("status")}</th>
+ <th style="width:10%">{$locale->tr("actions")}</th>
+ </tr>
+ </thead>
+ <tbody>
+ {foreach from=$privatemessages item=privatemessage}
+ <tr>
+ <td align="center"><input class="checkbox" type="checkbox" name="messageIds[{counter}]" value="{$privatemessage->getId()}"/></td>
+ <td class="col_highlighted">
+ <a href="admin.php?op=readPrivateMessage&messageId={$privatemessage->getId()}">{$privatemessage->getSenderId()}</a>
+ </td>
+ <td>
+ <a href="admin.php?op=readPrivateMessage&messageId={$privatemessage->getId()}">{$privatemessage->getDate()}</a>
+ </td>
+ <td>
+ <a href="admin.php?op=readPrivateMessage&messageId={$privatemessage->getId()}">{$privatemessage->getSubject()}</a>
+ </td>
+ <td>
+ <a href="admin.php?op=readPrivateMessage&messageId={$privatemessage->getId()}">{$privatemessage->getStatus()}</a>
+ </td>
+ <td>
+ </td>
+ </tr>
+ {/foreach}
+ </tbody>
+ </table>
+ </div>
+ <div id="list_action_bar">
+ {adminpager style=list}
+ <input type="hidden" name="op" value="deleteLinkCategories"/>
+ <input type="submit" name="Delete selected" value="{$locale->tr("delete")}"/>
+ </div>
+ </form>
+
+{include file="$admintemplatepath/footernavigation.template"}
+{include file="$admintemplatepath/footer.template"}
Modified: plog/trunk/templates/admin/menus.xml
===================================================================
--- plog/trunk/templates/admin/menus.xml 2007-07-09 21:32:01 UTC (rev 5636)
+++ plog/trunk/templates/admin/menus.xml 2007-07-10 10:56:14 UTC (rev 5637)
@@ -32,7 +32,12 @@
<editFriends url="?op=editFriends"/>
<newFriendGroup url="?op=newFriendGroup"/>
<editFriendGroups url="?op=editFriendGroups"/>
- </manageFriends>
+ </manageFriends>
+ <managePrivateMessages ignoreBreadCrumbs="1">
+ <newPrivateMessage url="?op=newPrivateMessage"/>
+ <editIncomingPrivateMessages url="?op=editIncomingPrivateMessages"/>
+ <editOutgoingPrivateMessages url="?op=editOutgoingPrivateMessages"/>
+ </managePrivateMessages>
</friendManagement>
<controlCenter url="?op=controlCenter">
<manageSettings ignoreBreadCrumbs="1">
Added: plog/trunk/templates/admin/newprivatemessage.template
===================================================================
--- plog/trunk/templates/admin/newprivatemessage.template (rev 0)
+++ plog/trunk/templates/admin/newprivatemessage.template 2007-07-10 10:56:14 UTC (rev 5637)
@@ -0,0 +1,49 @@
+{include file="$admintemplatepath/header.template"}
+{include file="$admintemplatepath/navigation.template" showOpt=newPrivateMessage title=$locale->tr("newPrivateMessage")}
+
+ <form name="addNewPrivateMessage" method="post" action="admin.php">
+ <fieldset class="inputField">
+ <legend>{$locale->tr("newPrivateMessage")}</legend>
+ {include file="$admintemplatepath/formvalidate.template"}
+
+ <div class="field">
+ <label for="receiverName">{$locale->tr("receiver_name")}</label>
+ <span class="required">*</span><br/>
+ <div class="formHelp">{$locale->tr("receiver_name_help")}</div>
+ <input type="text" value="{$receiverName}" id="receiverName" name="receiverName" />
+ {include file="$admintemplatepath/validate.template" field=receiverName message=$locale->tr("error_receiver_name")}
+ </div>
+
+ <div class="field">
+ <label for="subject">{$locale->tr("subject")}</label>
+ <span class="required">*</span><br/>
+ <div class="formHelp">{$locale->tr("subject_help")}</div>
+ <input type="text" value="{$subject}" id="subject" name="subject" />
+ {include file="$admintemplatepath/validate.template" field=subject message=$locale->tr("error_empty_subject")}
+ </div>
+
+ <div class="field">
+ <label for="messageText">{$locale->tr("message_text")}</label>
+ <span class="required">*</span>
+ <div class="formHelp">{$locale->tr("message_text_help")}</div>
+ <textarea name="messageText" cols="60" id="messageText" rows="5">{$messageText}</textarea>
+ {include file="$admintemplatepath/validate.template" field=messageText message=$locale->tr("error_empty_message_text")}
+ </div>
+
+ <div class="field">
+ <label for="backupPrivateMessage">{$locale->tr("backup_private_message")}</label>
+ <div class="formHelp">
+ <input class="checkbox" type="checkbox" id="backupPrivateMessage" name="backupPrivateMessage" value="1" {if $backupPrivateMessage}checked="checked"{/if} />
+ {$locale->tr("backup_private_message_help")}
+ </div>
+ </div>
+
+ </fieldset>
+ <div class="buttons">
+ <input type="hidden" name="op" value="sendPrivateMessage" />
+ <input type="reset" name="Reset" value="{$locale->tr("reset")}" />
+ <input type="submit" name="Add" value="{$locale->tr("send")}" />
+ </div>
+ </form>
+{include file="$blogtemplate/footernavigation.template"}
+{include file="$admintemplatepath/footer.template"}
\ No newline at end of file
More information about the pLog-svn
mailing list