本文整理汇总了PHP中Conversation类的典型用法代码示例。如果您正苦于以下问题:PHP Conversation类的具体用法?PHP Conversation怎么用?PHP Conversation使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Conversation类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: showAction
public function showAction()
{
$this->logger->entering();
$this->logger->info('Loading conversation');
$conversations = new Conversation();
$conversation = $conversations->find($this->_getParam('id'))->current();
$this->logger->info('Loading Item');
$item = $conversation->findParentItem();
$this->logger->info('Ensure authorized to view');
if ($this->session->user_id != $conversation->user_id && $this->session->user_id != $item->owner_id) {
$this->flash->notice = "Invalid Action";
$this->_redirect('/');
}
$this->logger->info('Loading Messages');
$messageRows = $conversation->findMessage();
foreach ($messageRows as $messageRow) {
$message = $messageRow->toArray();
$message['user'] = $messageRow->findParentUser()->toArray();
$messages[] = $message;
}
$this->logger->info('Loading View');
$this->view->assign(array('conversation' => $conversation, 'messages' => $messages, 'item' => $item));
$this->logger->info('Rendering view');
$this->render();
$this->logger->exiting();
}
示例2: ConversationsToHTML
public function ConversationsToHTML()
{
global $conversationsInfos;
$myDBConnector = new DBConnector();
$dbARY = $myDBConnector->infos();
$connection = new mysqli($dbARY[0], $dbARY[1], $dbARY[2], $dbARY[3]);
if ($connection->connect_error) {
echo "Database bağlantı hatası";
} else {
$query = "SELECT * FROM conversations WHERE (user1=\"" . $conversationsInfos["Pour Qui"] . "\" OR user2=\"" . $conversationsInfos["Pour Qui"] . "\") ORDER BY lastDate DESC ";
$results = $connection->query($query);
if ($results->num_rows == 0) {
echo "<div style=\"margin:2%;background-color:#e6e6e6;color:#6e6e6e;font-size:18px;font-family: Verdana,Geneva,sans-serif;\">";
echo "Henüz mesajlaşmamışsınz.";
echo "</div>";
} else {
while ($curResult = $results->fetch_assoc()) {
if ($curResult["user1"] == $conversationsInfos["Pour Qui"]) {
$other = $curResult["user2"];
} else {
$other = $curResult["user1"];
}
$ary = array($other, $conversationsInfos["Pour Qui"], $conversationsInfos["Pour Qui"]);
$myConversation = new Conversation($ary);
$myConversation->ConversationToHTML();
}
}
$connection->close();
}
}
示例3: create
/**
* @param array $values
* @return \HorseStories\Models\Conversations\Conversation
*/
public function create($values)
{
$conversation = new Conversation();
$conversation->subject = $values['subject'];
$conversation->save();
return $conversation;
}
示例4: testFetchWithParticipant
public function testFetchWithParticipant()
{
$usersConvsIds = array(1, 2, 3, 4, 5);
$conversation = new Conversation();
$conversation->criteriaWithParticipants(1);
$result = $conversation->findAll();
foreach ($result as $key => $conv) {
$this->assertTrue(in_array($conv->id, $usersConvsIds));
}
}
示例5: testsSendNotificationOnNewComment
public function testsSendNotificationOnNewComment()
{
$super = User::getByUsername('super');
$steven = User::getByUsername('steven');
$jack = User::getByUsername('jack');
$conversation = new Conversation();
$conversation->owner = Yii::app()->user->userModel;
$conversation->subject = 'My test subject2';
$conversation->description = 'My test description2';
$this->assertTrue($conversation->save());
$comment = new Comment();
$comment->description = 'This is the 1st test comment';
//Confirm no email notifications are sitting in the queue
$this->assertEquals(0, Yii::app()->emailHelper->getQueuedCount());
$this->assertEquals(0, Yii::app()->emailHelper->getSentCount());
//Confirm there is no inbox notification
$this->assertEquals(0, Notification::getCount());
//No message was sent because Steven and Jack don't have primary email address
CommentsUtil::sendNotificationOnNewComment($conversation, $comment, array($steven, $jack));
$this->assertEquals(0, Yii::app()->emailHelper->getQueuedCount());
$this->assertEquals(0, Yii::app()->emailHelper->getSentCount());
//Two inbox notifications sent
$this->assertEquals(2, Notification::getCount());
$super->primaryEmail->emailAddress = 'super@zurmo.org';
$steven->primaryEmail->emailAddress = 'steven@zurmo.org';
$jack->primaryEmail->emailAddress = 'jack@zurmo.org';
$this->assertTrue($super->save());
$this->assertTrue($steven->save());
$this->assertTrue($jack->save());
//Two email message were sent one to Steven and one to Jack
CommentsUtil::sendNotificationOnNewComment($conversation, $comment, array($steven, $jack));
$this->assertEquals(2, Yii::app()->emailHelper->getQueuedCount());
$this->assertEquals(0, Yii::app()->emailHelper->getSentCount());
$emailMessages = EmailMessage::getAll();
$emailMessage1 = $emailMessages[0];
$emailMessage2 = $emailMessages[1];
$this->assertCount(1, $emailMessage1->recipients);
$this->assertCount(1, $emailMessage2->recipients);
//Two inbox notifications created
$this->assertEquals(4, Notification::getCount());
//One email message was sent to Super but not to Steven
//One inbox notification to Steven but not to Super
NotificationTestHelper::setNotificationSettingsForUser($steven, 'ConversationNewComment', true, false);
NotificationTestHelper::setNotificationSettingsForUser($super, 'ConversationNewComment', false, true);
CommentsUtil::sendNotificationOnNewComment($conversation, $comment, array($steven, $super));
$this->assertEquals(3, Yii::app()->emailHelper->getQueuedCount());
$this->assertEquals(0, Yii::app()->emailHelper->getSentCount());
$emailMessages = EmailMessage::getAll();
$emailMessage = $emailMessages[2];
$this->assertEquals(1, count($emailMessage->recipients));
$this->assertEquals(5, Notification::getCount());
$notifications = Notification::getAll();
$notification = $notifications[4];
$this->assertEquals(strval($steven), strval($notification->owner));
}
示例6: run
public function run(User $userToSendTo, $messageLogger)
{
$conversation = new Conversation();
$conversation->owner = Yii::app()->user->userModel;
$conversation->subject = 'My test subject';
$conversation->description = 'My test description';
if (!$conversation->save()) {
throw new FailedToSaveModelException();
}
ConversationParticipantsUtil::sendEmailInviteToParticipant($conversation, $userToSendTo);
$messageLogger->addInfoMessage('Sending conversation invite message');
}
示例7: store
/**
* Store a newly created conversation in storage.
*
* @return Response
*/
public function store()
{
$rules = array('users' => 'required|array', 'body' => 'required');
$validator = Validator::make(Input::only('users', 'body'), $rules);
if ($validator->fails()) {
return Response::json(['success' => false, 'result' => $validator->messages()]);
}
// Create Conversation
$params = array('created_at' => new DateTime(), 'name' => str_random(30), 'author_id' => Auth::user()->id);
$conversation = Conversation::create($params);
$conversation->users()->attach(Input::get('users'));
$conversation->users()->attach(array(Auth::user()->id));
// Create Message
$params = array('conversation_id' => $conversation->id, 'body' => Input::get('body'), 'user_id' => Auth::user()->id, 'created_at' => new DateTime());
$message = Message::create($params);
// Create Message Notifications
$messages_notifications = array();
foreach (Input::get('users') as $user_id) {
array_push($messages_notifications, new MessageNotification(array('user_id' => $user_id, 'read' => false, 'conversation_id' => $conversation->id)));
// Publish Data To Redis
$data = array('room' => $user_id, 'message' => array('conversation_id' => $conversation->id));
Event::fire(ChatConversationsEventHandler::EVENT, array(json_encode($data)));
}
$message->messages_notifications()->saveMany($messages_notifications);
return Redirect::route('chat.index', array('conversation', $conversation->name));
}
示例8: onTeamMembershipChange
/**
* Called every time a member is added/removed from a team
*
* @param TeamAbandonEvent|TeamJoinEvent|TeamKickEvent $event The event
* @param string $type The type of the event
*/
public function onTeamMembershipChange(Event $event, $type)
{
$query = \Conversation::getQueryBuilder()->forTeam($event->getTeam());
foreach ($query->getModels() as $conversation) {
\ConversationEvent::storeEvent($conversation->getId(), $event, $type);
}
}
示例9: prepare
/**
* For initializing members of the class.
*
* @param array $argarray misc. arguments
*
* @return boolean true
*/
function prepare($argarray)
{
parent::prepare($argarray);
$convId = $this->trimmed('id');
if (empty($convId)) {
// TRANS: Client exception thrown when no conversation ID is given.
throw new ClientException(_('No conversation ID.'));
}
$this->conversation = Conversation::staticGet('id', $convId);
if (empty($this->conversation)) {
// TRANS: Client exception thrown when referring to a non-existing conversation ID (%d).
$this->clientError(_('No conversation ID found'), 404);
return false;
}
$profile = Profile::current();
$stream = new ConversationNoticeStream($convId, $profile);
$notice = $stream->getNotices(($this->page - 1) * $this->count, $this->count, $this->since_id, $this->max_id);
$this->notices = $notice->fetchAll();
$originalConversation = new Notice();
$originalConversation->whereAdd('conversation=' . $convId);
$originalConversation->limit(1);
$originalConversation->orderBy('created');
$originalConversation->find();
if ($originalConversation->fetch()) {
$this->originalNotice = $originalConversation;
}
return true;
}
示例10: SendEmail
public function SendEmail()
{
/*
* validate the Inputs sent
*/
$rules = array('email_cc' => "required_if:email_to,''|required_if:email_bcc,''", 'email_to' => "required_if:email_cc,''|required_if:email_bcc,''", 'email_bcc' => "required_if:email_cc,''|required_if:email_to,''", 'message' => 'required', 'subject' => 'required');
$messages = array("required_without" => "Please select atleast one recipient", "subject.required" => "Please enter message subject", "message.required" => "Please enter message to send");
$validator = Validator::make(Input::all(), $rules, $messages);
$messages = $validator->messages();
if ($validator->fails()) {
return Redirect::to(URL::previous())->withErrors($validator)->withInput();
} else {
if (Conversation::saveEmail()) {
Session::flash('_feedback', '<div class="alert alert-info alert-dismissable">
<i class="fa fa-info"></i>
<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button><b>Alert!</b>
Email has been successfully queued for sending</div>');
//Helpers::uploadCampaignFile(Input::file('attachment'), $attachment_ref);
return Redirect::to(URL::route('conversation'));
} else {
Session::flash('_feedback', '<div class="alert alert-info alert-dismissable">
<i class="fa fa-info"></i>
<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button><b>Alert!</b>
Error occured, please try again later</div>');
return Redirect::to(URL::route('conversation'));
}
}
}
示例11: unserialize
/**
* {@inheritdoc}
*/
public function unserialize($data)
{
$data = unserialize($data);
$conversation = \Conversation::get($data['conversation']);
$players = \Player::arrayIdToModel($data['players']);
$teams = \Team::arrayIdToModel($data['teams']);
$this->__construct($conversation, array_merge($players, $teams));
}
示例12: getChats
public static function getChats($message_hash, $data)
{
if ($data == '') {
Conversation::updateConversation($message_hash);
}
$result = DB::Select("SELECT target_user_id as recipient_id,source_user_id as sender_id,(SELECT CONCAT(firstname,' ', lastname) \n FROM accounts_dbx WHERE account_id = mradi_messages.source_user_id) AS sender,CONCAT(firstname,' ', lastname) as recipient,\n `time_sent`,`mradi_messages`.`message`,(case when time_read is not null then 1 else 0 end)as time_read FROM `mradi_messages` \n LEFT JOIN `accounts_dbx` ON `accounts_dbx`.`account_id` = `mradi_messages`.`target_user_id`\n WHERE message_hash = ? AND `mradi_messages`.`status` IN (0,1) order by time_sent asc", array($message_hash));
return $result;
}
示例13: index
public function index()
{
$this->template->title = "Test Controller";
Conversation::factory();
Conversation::last_conversation()->view();
$this->template->content = Conversation::last_conversation()->flushBuffer();
$form = new Forge();
print_r(class_parents($form));
}
示例14: create
/**
* Factory method for creating a new conversation
*
* @return Conversation the new conversation DO
*/
static function create()
{
$conv = new Conversation();
$conv->created = common_sql_now();
$id = $conv->insert();
if (empty($id)) {
common_log_db_error($conv, 'INSERT', __FILE__);
return null;
}
$orig = clone $conv;
$orig->uri = common_local_url('conversation', array('id' => $id), null, null, false);
$result = $orig->update($conv);
if (empty($result)) {
common_log_db_error($conv, 'UPDATE', __FILE__);
return null;
}
return $conv;
}
示例15: forPlayer
/**
* Only return messages that are sent from/to a specific player
*
* @param Player $player The player related to the messages
* @return self
*/
public function forPlayer($player)
{
$this->extras .= '
LEFT JOIN player_conversations ON player_conversations.conversation=conversations.id
';
$this->column('player_conversations.player')->is($player);
$this->column('conversations.status')->isOneOf(Conversation::getActiveStatuses());
return $this;
}