Пример #1
0
 function testTagFields()
 {
     $POD = new PeoplePod();
     $user = $POD->getPerson();
     $user->email = '*****@*****.**';
     //create user
     $user->password = '******';
     $user->set('nick', 'test');
     $user->save();
     $POD->changeActor(array('id' => $user->id));
     //log in as user
     $user2 = $POD->getPerson();
     $user2->email = '*****@*****.**';
     //create user
     $user2->password = '******';
     $user2->set('nick', 'test2');
     $user2->save();
     $user2->sendMessage('hi user2');
     sleep(2);
     $user2->sendMessage('hi again user2');
     $POD->changeActor(array('id' => $user2->id));
     $inbox = $POD->getInbox();
     $this->assertTrue($inbox);
     $thread = $inbox->newThread($user->id);
     $this->assertNotNull($thread->MESSAGES);
     $messages = $thread->messages();
     $this->assertEqual($thread->unreadCount(), 2);
     $this->assertEqual($messages->count(), 2);
     $first_message = $messages->getNext();
     $this->assertEqual($first_message->to()->get('id'), $user2->id);
     $this->assertEqual($first_message->from()->get('id'), $user->id);
     $thread->markAsRead();
     $this->assertEqual($thread->unreadCount(), 0);
     $this->assertEqual($thread->recipient()->get('id'), $user->id);
     $second_message = $messages->getNext();
     $thread->reply('hello to you');
     $this->assertTrue($thread->success());
     $POD->changeActor(array('id' => $user->id));
     $inbox = $POD->getInbox();
     $thread = $inbox->newThread($user2->id);
     $this->assertEqual($thread->unreadCount(), 1);
     $messages = $thread->messages();
     $this->assertEqual($messages->count(), 3);
     $messages->reset();
     $message = $messages->getNext();
     $this->assertEqual($message->message, 'hi user2');
     ///Test fields of message object//////
     $this->assertNotNull($message->id);
     $this->assertEqual($message->userId, $user->id);
     $this->assertEqual($message->fromId, $user->id);
     $this->assertEqual($message->targetUserId, $user2->id);
     $this->assertNotNull($message->date);
     $this->assertEqual($message->status, 'read');
     ///////////////////////////////////
     $POD->changeActor(array('id' => $user->id));
     $user->delete();
     $POD->changeActor(array('id' => $user2->id));
     $user2->delete();
 }
Пример #2
0
 function Test_messages()
 {
     $POD = new PeoplePod();
     $user = $POD->getPerson();
     $user->email = '*****@*****.**';
     //create user
     $user->password = '******';
     $user->nick = 'test';
     $user->save();
     $POD->changeActor(array('id' => $user->id));
     //log in as user
     $user2 = $POD->getPerson();
     $user2->email = '*****@*****.**';
     //create user
     $user2->password = '******';
     $user2->nick = 'test2';
     $user2->save();
     $message1 = "first message";
     $message2 = "second message";
     $user2->sendMessage($message1);
     sleep(2);
     $user2->sendMessage($message2);
     $inbox = $POD->getInbox(2, 0);
     $this->assertIsA($inbox, 'Stack');
     $total_unread = $inbox->unreadCount();
     $this->assertEqual($total_unread, 0);
     //user's sent messages should be automatically flagged as read
     $inbox->fill();
     $thread = $inbox->getNext();
     $this->assertIsA($thread, 'Thread');
     $sent_to = $thread->recipient();
     $this->assertIsA($sent_to, 'Person');
     $this->assertEqual($sent_to->get('nick'), 'test2');
     $messages = $thread->messages();
     //get list of message objects
     $this->assertIsA($messages, 'Stack');
     $message = $messages->getNext();
     //get individual message object from stack
     $this->assertIsA($message, 'Message');
     $from = $message->from();
     $this->assertEqual($from->get('nick'), 'test');
     $to = $message->to();
     $this->assertEqual($to->get('nick'), 'test2');
     $POD->changeActor(array('id' => $user2->id));
     $inbox2 = $POD->getInbox(2, 0);
     $total_unread2 = $inbox2->unreadCount();
     $this->assertEqual($total_unread2, 2);
     //user2's inbox should have 2 unread messages
     $thread = $inbox2->getNext();
     //get one thread
     $this->assertIsA($thread, 'Thread');
     $messages = $thread->messages();
     $message = $messages->getNext();
     $this->assertEqual($message->get('message'), 'second message');
     $thread->markAsRead();
     $unread = $thread->unreadCount();
     $this->assertEqual($unread, 0);
     $reply = "this is a reply";
     $thread->reply($reply);
     $thread->clear();
     $inbox2 = $POD->getInbox(2, 0);
     $total_unread2 = $inbox2->unreadCount();
     $this->assertEqual($total_unread2, 0);
     $POD->changeActor(array('id' => $user->id));
     $inbox = $POD->getInbox(3, 0);
     $total_unread = $inbox->unreadCount();
     $this->assertEqual($total_unread, 1);
     $thread = $inbox->getNext();
     $messages = $thread->messages();
     $message = $messages->getNext();
     $message = $messages->getNext();
     $message = $messages->getNext();
     $this->assertEqual($message->get('message'), 'first message');
     $POD->changeActor(array('id' => $user->id));
     $user->delete();
     $POD->changeActor(array('id' => $user2->id));
     $user2->delete();
 }
Пример #3
0
<?php

/***********************************************
* This file is part of PeoplePods
* (c) xoxco, inc  
* http://peoplepods.net http://xoxco.com
*
* core_private_messaging/inbox.php
* Handles requests to /inbox
*
* Documentation for this pod can be found here:
* http://peoplepods.net/readme/messaging
/**********************************************/
include_once "../../PeoplePods.php";
$POD = new PeoplePod(array('debug' => 2, 'lockdown' => 'verified', 'authSecret' => @$_COOKIE['pp_auth']));
if (!$POD->libOptions('enable_core_private_messaging')) {
    header("Location: " . $POD->siteRoot(false));
    exit;
}
$offset = 0;
if (isset($_GET['offset'])) {
    $offset = $_GET['offset'];
}
$inbox = $POD->getInbox(20, $offset);
$POD->header("Conversations");
$inbox->output('thread_short', 'header', 'pager', 'Conversations', 'You don\'t have any messages. :(');
$POD->footer();
Пример #4
0
* (c) xoxco, inc  
* http://peoplepods.net http://xoxco.com
*
* core_private_messaging/thread.php
* Displays a single thread, accepts new messages
*
* Documentation for this pod can be found here:
* http://peoplepods.net/readme/messaging
/**********************************************/
include_once "../../PeoplePods.php";
$POD = new PeoplePod(array('debug' => 0, 'lockdown' => 'verified', 'authSecret' => @$_COOKIE['pp_auth']));
if (!$POD->libOptions('enable_core_private_messaging')) {
    header("Location: " . $POD->siteRoot(false));
    exit;
}
$inbox = $POD->getInbox();
$username = $_GET['username'];
$user = $POD->getPerson(array('stub' => $username));
if (!$user->success()) {
    header("Status: 404 Not Found");
    echo "404 Not Found";
    exit;
}
$thread = $inbox->newThread($user->get('id'));
if (isset($_POST['message'])) {
    $thread->reply(strip_tags($_POST['message']));
}
if (isset($_GET['clear'])) {
    $thread->clear();
    if (!$thread->success()) {
        $POD->addMessage("Conversation could not be cleared! " . $thread->error());