Exemple #1
0
 /**
  * Fetches specified message
  * 
  * @param number $id
  * @return \GitGis\Whatsapp\Model\Message>
  */
 public function fetch($id)
 {
     $db = DBConnection::getInstance();
     $item = null;
     if (empty($id)) {
         return new Message();
     }
     $query = $db->prepare("SELECT * FROM messages WHERE id=:id ");
     $query->bindParam('id', $id);
     $query->execute();
     $row = $query->fetch();
     if (!empty($row)) {
         $item = new Message();
         $item->setId($row['id']);
         $item->setGroupId($row['group_id']);
         $item->setSenderId($row['sender_id']);
         $item->setUserId($row['user_id']);
         $item->setkind($row['kind']);
         $item->setTarget($row['target']);
         $item->setData($row['data']);
         $item->setCtime($row['ctime']);
         $item->setStime($row['stime']);
     }
     return $item;
 }
Exemple #2
0
<?php

require_once __DIR__ . '/../vendor/autoload.php';
define("MAINDIR", __DIR__ . '/../');
require_once __DIR__ . '/../config.php';
use GitGis\Whatsapp\Model\Message;
use GitGis\Whatsapp\Model\MessageDAO;
use GitGis\Whatsapp\Model\Group;
use GitGis\Whatsapp\Model\GroupDAO;
use GitGis\Whatsapp\Model\WhatsappDAO;
$groupDao = new GroupDAO();
$group = $groupDao->fetch(1);
$messageDao = new MessageDAO();
for ($cnt = 0; $cnt < 200; $cnt++) {
    $message = new Message();
    $message->setKind(Message::KIND_TEXT_MSG);
    $message->setCtime(time());
    $message->setUserId(1);
    $message->setData('Test ' . $cnt);
    $message->setStime(time());
    $message->setGroupId($group->getId());
    $message = $messageDao->save($message);
    $messageDao->addStatus($message, Message::MESSAGE_STATUS_TO_SEND);
}
 /**
  * Creates video message and redirects to edit
  */
 public static function getSendVideo()
 {
     $app = \Slim\Slim::getInstance();
     $dao = new MessageDAO();
     $item = new Message();
     $item->setKind(Message::KIND_VIDEO_MSG);
     $item->setCtime(time());
     $strong = \Strong\Strong::getInstance();
     $user = $strong->getUser();
     $item->setUserId($user['id']);
     $item = $dao->save($item);
     $app->redirect(MAINURL . '/messages/edit/' . $item->getId());
 }