@@ 673-720 (lines=48) @@ | ||
670 | * |
|
671 | * @return \Cake\Network\Response |
|
672 | */ |
|
673 | public function go($messageId = null) |
|
674 | { |
|
675 | $this->loadModel('ConversationsMessages'); |
|
676 | ||
677 | $message = $this->ConversationsMessages |
|
678 | ->find() |
|
679 | ->contain([ |
|
680 | 'Conversations' |
|
681 | ]) |
|
682 | ->where([ |
|
683 | 'ConversationsMessages.id' => $messageId |
|
684 | ]) |
|
685 | ->first(); |
|
686 | ||
687 | if (is_null($message)) { |
|
688 | $this->Flash->error(__d('conversations', "This message doesn't exist or has been deleted.")); |
|
689 | ||
690 | return $this->redirect(['controller' => 'conversations', 'action' => 'index']); |
|
691 | } |
|
692 | ||
693 | $message->toArray(); |
|
694 | ||
695 | //Count the number of messages before this message. |
|
696 | $messagesBefore = $this->ConversationsMessages |
|
697 | ->find() |
|
698 | ->where([ |
|
699 | 'ConversationsMessages.conversation_id' => $message->conversation_id, |
|
700 | 'ConversationsMessages.created <' => $message->created |
|
701 | ]) |
|
702 | ->count(); |
|
703 | ||
704 | //Get the number of messages per page. |
|
705 | $messagesPerPage = Configure::read('Conversations.messages_per_page'); |
|
706 | ||
707 | //Calculate the page. |
|
708 | $page = ceil($messagesBefore / $messagesPerPage); |
|
709 | ||
710 | $page = ($page > 1) ? $page : 1; |
|
711 | ||
712 | //Redirect the user. |
|
713 | return $this->redirect([ |
|
714 | '_name' => 'conversations-view', |
|
715 | 'slug' => $message->conversation->title, |
|
716 | 'id' => $message->conversation->id, |
|
717 | '?' => ['page' => $page], |
|
718 | '#' => 'message-' . $messageId |
|
719 | ]); |
|
720 | } |
|
721 | ||
722 | /** |
|
723 | * Function to kick an user from a conversation. |
@@ 328-375 (lines=48) @@ | ||
325 | * |
|
326 | * @return \Cake\Network\Response |
|
327 | */ |
|
328 | public function go($commentId = null) |
|
329 | { |
|
330 | $this->loadModel('BlogArticlesComments'); |
|
331 | ||
332 | $comment = $this->BlogArticlesComments |
|
333 | ->find() |
|
334 | ->contain([ |
|
335 | 'BlogArticles' |
|
336 | ]) |
|
337 | ->where([ |
|
338 | 'BlogArticlesComments.id' => $commentId |
|
339 | ]) |
|
340 | ->first(); |
|
341 | ||
342 | if (is_null($comment)) { |
|
343 | $this->Flash->error(__("This comment doesn't exist or has been deleted.")); |
|
344 | ||
345 | return $this->redirect(['action' => 'index']); |
|
346 | } |
|
347 | ||
348 | $comment->toArray(); |
|
349 | ||
350 | //Count the number of message before this message. |
|
351 | $messagesBefore = $this->BlogArticlesComments |
|
352 | ->find() |
|
353 | ->where([ |
|
354 | 'BlogArticlesComments.article_id' => $comment->article_id, |
|
355 | 'BlogArticlesComments.created <' => $comment->created |
|
356 | ]) |
|
357 | ->count(); |
|
358 | ||
359 | //Get the number of messages per page. |
|
360 | $messagesPerPage = Configure::read('Blog.comment_per_page'); |
|
361 | ||
362 | //Calculate the page. |
|
363 | $page = floor($messagesBefore / $messagesPerPage) + 1; |
|
364 | ||
365 | $page = ($page > 1) ? $page : 1; |
|
366 | ||
367 | //Redirect the user. |
|
368 | return $this->redirect([ |
|
369 | '_name' => 'blog-article', |
|
370 | 'slug' => $comment->blog_article->title, |
|
371 | 'id' => $comment->blog_article->id, |
|
372 | '?' => ['page' => $page], |
|
373 | '#' => 'comment-' . $commentId |
|
374 | ]); |
|
375 | } |
|
376 | ||
377 | /** |
|
378 | * Get all articles by a date formatted to "m-Y". |