function AddNew(MessageEntity $message) { $message->SafeFields(); $msg = array(); $msg['subject'] = $message->subject; $msg['content'] = $message->content; $msg['uid'] = $message->uid; $msg['dateline'] = time(); $msgId = $this->DatabaseHandler->Insert2($msg, 'message'); if ($msgId && $msgId > 0) { $msg['msgid'] = $msgId; $msg_in = array(); $msg_in['msgid'] = $msgId; $msg_in['uid'] = $message->uid; $msg_in['touid'] = $message->touid; $msg['touid'] = $message->touid; $msg_in['dateline'] = $msg['dateline']; $msg_in['read_status'] = 0; $msg_inId = $this->DatabaseHandler->Insert2($msg_in, 'message_in'); $msg_out = array(); $msg_out['msgid'] = $msgId; $msg_out['uid'] = $message->uid; $msg_out['touid'] = $message->touid; $msg_out['dateline'] = $msg['dateline']; $msg_outId = $this->DatabaseHandler->Insert2($msg_out, 'message_out'); return $msg; } else { return false; } }
public function sendmsg() { $mc = new MessagesCollection($_SESSION['user_id']); $msg = new MessageEntity(); $msg->setMessage($_POST['msg']); $mc->save($msg); }
public function index() { if (isset($_SESSION['user_id'])) { $message_collection = new MessagesCollection($_SESSION['user_id']); } else { header('Location: index.php?frontcontroller=login'); } if ($_SERVER['REQUEST_METHOD'] == 'POST') { $message = new MessageEntity(); $message->setMessage($_POST['message']); $message_collection->save($message); } $this->loadView('website/chat', array()); }
public static function fromResponse($data) { $arrayOfMessageEntity = []; foreach ($data as $messageEntity) { $arrayOfMessageEntity[] = MessageEntity::fromResponse($messageEntity); } return $arrayOfMessageEntity; }
/** * Get the text of a given message entity. * * @param MessageEntity $entity * @return string */ public function getEntityText($entity) { return $this->substr($this->getText(), $entity->getOffset(), $entity->getLength()); }
/** * @param array $attributes */ public function loadRelated(array $attributes) { parent::loadRelated($attributes); if (isset($attributes['from'])) { $this->from = User::create($attributes['from']); } if (isset($attributes['chat'])) { $this->chat = isset($attributes['chat']->title) ? GroupChat::create($attributes['chat']) : User::create($attributes['chat']); } if (isset($attributes['forward_from'])) { $this->forward_from = User::create($attributes['forward_from']); } if (isset($attributes['forward_from_chat'])) { $this->forward_from_chat = Chat::create($attributes['forward_from_chat']); } if (isset($attributes['reply_to_message'])) { $this->reply_to_message = Message::create($attributes['reply_to_message']); } if (isset($attributes['entities'])) { $this->entities = array_map(function ($entity) { return MessageEntity::create($entity); }, $attributes['entities']); } if (isset($attributes['audio'])) { $this->audio = Audio::create($attributes['audio']); } if (isset($attributes['document'])) { $this->document = Document::create($attributes['document']); } if (isset($attributes['photo'])) { $this->photo = array_map(function ($photo) { return PhotoSize::create($photo); }, $attributes['photo']); } if (isset($attributes['sticker'])) { $this->sticker = Sticker::create($attributes['sticker']); } if (isset($attributes['video'])) { $this->video = Video::create($attributes['video']); } if (isset($attributes['voice'])) { $this->voice = Voice::create($attributes['voice']); } if (isset($attributes['contact'])) { $this->contact = Contact::create($attributes['contact']); } if (isset($attributes['location'])) { $this->location = Location::create($attributes['location']); } if (isset($attributes['venue'])) { $this->venue = Venue::create($attributes['venue']); } if (isset($attributes['new_chat_member'])) { $this->new_chat_member = User::create($attributes['new_chat_member']); } if (isset($attributes['left_chat_member'])) { $this->left_chat_member = new User($attributes['left_chat_member']); } if (isset($attributes['new_chat_photo'])) { $this->new_chat_photo = array_map(function ($photo) { return PhotoSize::create($photo); }, $attributes['new_chat_photo']); } }