Welcome Guest, Not a member yet? Register   Sign In
Private Message Module (p3s_pm)
#1

[eluser]Syed Mobarak[/eluser]
I have been searching a CI based PM module for my application but couldn't get any. Finally, I made this simple one and thought to upload here if some gets help or enhance it. Below is the base codes. I don't have enough time describe it right now. I'll be working on it more to update it whenever get time.

Please check out the attached zip file.
#2

[eluser]Phil Sturgeon[/eluser]
I was tempted to bung this into PyroCMS but it still needs some work I think.

Two things I'm not loving:

Code:
switch($type)
        {
            case "0":
                $conditions = "`to` = '".$this->userid."' && `to_viewed` = '0' && `to_deleted` = '0'";
                $orderby="`created` DESC";
                break;
                // New messages
            case "1":
                $conditions = "`to` = '".$this->userid."' && `to_viewed` = '1' && `to_deleted` = '0'";
                $orderby="`to_vdate` DESC";
                break;
                // Read messages
            case "2":
                $conditions = "`from` = '".$this->userid."'";
                $orderby="`created` DESC";
                break;
                // Sent messages
            case "3":
                $conditions = "`to` = '".$this->userid."' && `to_deleted` = '1'";
                $orderby="`to_ddate` DESC";
                break;
                // Deleted messages
            default:
                $conditions = "`to` = '".$this->userid."'";
                $orderby="`created` DESC";
                break;
                // New messages
        }

That is pretty unclear using integers there, possibly define some constants or use strings for $type?

Code:
<table width="100%" border="1" style="border-collapse:collapse; border-color:#CCCCCC;" cellpadding="4" cellspacing="4">
                                    <tr>
                                        <td style="padding:10px;"><a href="&lt;?php echo site_url().">Inbox</a>&nbsp;&nbsp;&nbsp;<a href="&lt;?php echo site_url().">New</a>&nbsp;&nbsp;&nbsp;<a href="&lt;?php echo site_url().">Sent</a>&nbsp;&nbsp;&nbsp;<a href="&lt;?php echo site_url().">Trashed</a>&nbsp;&nbsp;&nbsp;<a href="&lt;?php echo site_url().">Viewed</a>&nbsp;&nbsp;&nbsp;<a href="&lt;?php echo site_url().">Compose</a></td>
                                    </tr>

AAAGGH!
#3

[eluser]Andrew Cairns[/eluser]
Will download have have a nose!
#4

[eluser]Syed Mobarak[/eluser]
@phil Sturgeon: As I told that it's the simple thing I just made. Need more work to do on it. The views are not attractive yet. Even I didn't use html/body tags there. I liked your idea (define some constants or use strings for $type). Thanks for that. If you did anything better than it, please attach. Else, I'll keep your idea in my for next version.
#5

[eluser]Phil Sturgeon[/eluser]
If you release an improved version soon I may well use it, otherwise in a month or so when I actually have some damn free time I will contribute some changes and put this into PyroCMS. Either way, thanks very much for this module. :-)
#6

[eluser]AgentPhoenix[/eluser]
I've done a bunch lately with creating a private message system, so I checked this over to see how you did it. I thought I'd throw in my two cents here with your database schema. Originally, I'd used a single table, but then I got in to wanting to be able to send messages to multiple recipients and making it as scalable as possible, so I did some research a while back and came up with the following schema after looking at a few implementations. Not sure if you want to use something like this, but if you do, feel free!

Code:
CREATE TABLE IF NOT EXISTS `privmsgs` (
  `privmsgs_id` bigint(20) NOT NULL AUTO_INCREMENT,
  `privmsgs_author` int(8) DEFAULT NULL,
  `privmsgs_date` bigint(20) DEFAULT NULL,
  `privmsgs_subject` varchar(255) DEFAULT '',
  `privmsgs_content` text,
  `privmsgs_author_display` enum('y','n') DEFAULT 'y',
  PRIMARY KEY (`privmsgs_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;

CREATE TABLE IF NOT EXISTS `privmsgs_to` (
  `pmto_id` bigint(20) NOT NULL AUTO_INCREMENT,
  `pmto_message` bigint(20) DEFAULT NULL,
  `pmto_recipient` int(8) DEFAULT NULL,
  `pmto_unread` enum('y','n') DEFAULT 'y',
  `pmto_display` enum('y','n') DEFAULT 'y',
  PRIMARY KEY (`pmto_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;

This lets you set the message in the first table then create as many "to" records as you want. It also lets the recipients delete the message without ever affecting the original message for the author or the other recipients (deleting is actually more about changing display flags, not actually deleting the records).

I haven't looked through the model in this library yet, but hats off for packing this stuff up into a library!
#7

[eluser]Phil Sturgeon[/eluser]
+1 for the multiple recipient stuff. I had the same problem with my old privmsg module, if one user deleted it got deleted for everyone lol.
#8

[eluser]AgentPhoenix[/eluser]
All of my private message code is pretty specific to my application, but I should be able to get in and clean some of it up if anyone wants to take a look at it.
#9

[eluser]Xeoncross[/eluser]
That database schema is just what I need. I'm usually not that interested in other peoples code - just in their design choices. Since you have already done the footwork in figuring out how to better handle messages, it saves research time for people like me.

Thanks!
#10

[eluser]Syed Mobarak[/eluser]
Well, it would be great if the message system has the multiple recipient capacity. Right now I am busy with other things but I'll work on it having this concept as soon as I manage my time. I think I might have the database schema for multiple recipient. I have to search in my archive. I'll share you guys to verify if I find it.




Theme © iAndrew 2016 - Forum software by © MyBB