Message.php 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. <?php
  2. /**
  3. *
  4. * PHP Pro Bid $Id$ shLePNyvP8anDJPt/sDAZ0Az1MTo4W/rR1YZj/idBB8=
  5. *
  6. * @link http://www.phpprobid.com
  7. * @copyright Copyright (c) 2014 Online Ventures Software LTD & CodeCube SRL
  8. * @license http://www.phpprobid.com/license Commercial License
  9. *
  10. * @version 7.0
  11. */
  12. /**
  13. * messaging table row object model
  14. */
  15. namespace Ppb\Db\Table\Row;
  16. class Message extends AbstractRow
  17. {
  18. /**
  19. *
  20. * returns an array used by the url view helper to generate the messaging topic display url
  21. *
  22. * @param bool $admin if in admin module, generate a different link
  23. * @return array|false
  24. */
  25. public function link($admin = false)
  26. {
  27. $user = $this->getUser();
  28. if (!in_array($user['id'], array($this->getData('sender_id'), $this->getData('receiver_id')))) {
  29. return false;
  30. }
  31. if ($admin) {
  32. return array(
  33. 'module' => 'admin',
  34. 'controller' => 'tools',
  35. 'action' => 'messaging-topic',
  36. 'id' => $this->getData('id'),
  37. );
  38. }
  39. return array(
  40. 'module' => 'members',
  41. 'controller' => 'messaging',
  42. 'action' => 'topic',
  43. 'id' => $this->getData('id'),
  44. );
  45. }
  46. public function getTopicTitle()
  47. {
  48. $topicTitle = $this->getData('topic_title');
  49. if (!empty($topicTitle)) {
  50. return $topicTitle;
  51. }
  52. else {
  53. return $this->findParentRow('\Ppb\Db\Table\Messaging')->getData('topic_title');
  54. }
  55. }
  56. }