Giter Club home page Giter Club logo

phppm's Introduction

phpPM

phpPM is a lightweight private messaging library

phpPM based on threads. Each new message starts a thread in which the conversation(between two user) runs ;)

Features:

  • Uses PDO
  • Uses prepare statements -> SQL-Injection safe
  • Each user has a MessageBox
  • Delete messages(not physically)
    • Delete the thread too if the thread has no messages
  • Delete threads(not physically)
  • Provide all needed functions for a postbox...

How to use

After you have configure phpPM(see https://github.com/simb0/phpPM/wiki) you can use it as follow.

Get the MessageBox for your user:
$userId is just the unique id for the user in your application
$pdo here you can provide your database pdo object. You can also provide null to force phpPM to use your configuration
$msgBox = new MSGBox($userId,$pdo);

Let's send a new message to another user:
$msgBox->sendNewMessage($subject,$text,$date,$toUserId);
Now you have startet a conversation to answer just add(not send) a message to this thread:
$msgBox->addMessage($subject,$text,$date,$threadId);

Let's have a look at the thread:
$id we assume the thread is 100
$thread = $msgBox->getThread($id);
This function returns a 'Thread' object:
$messages = $thread->getMessages();
Now we have an array of 'MSG' that belongs to the thread
$messages[0]->getText(); // this provide the content of the message

They are more functions available that helps:
We can ask the thread if there new messages
$thread->hasNewMessages(); //true or false
$msgBox->getCountNotReadedMessages(); // count how much messages the user doesn't have readed now
$msgBox->getCountReadedMessages(); // count how much messages the user have readed now
....

phppm's People

Contributors

simb0 avatar

Stargazers

Margelani avatar Spencer Thayer avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.