BxMsgGrid.php 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. <?php defined('BX_DOL') or die('hack attempt');
  2. /**
  3. * Copyright (c) BoonEx Pty Limited - http://www.boonex.com/
  4. * CC-BY License - http://creativecommons.org/licenses/by/3.0/
  5. *
  6. * @defgroup Messages Messages
  7. * @ingroup DolphinModules
  8. *
  9. * @{
  10. */
  11. bx_import('BxTemplGrid');
  12. class BxMsgGrid extends BxTemplGrid
  13. {
  14. protected static $MODULE;
  15. public function __construct ($aOptions, $oTemplate = false)
  16. {
  17. self::$MODULE = 'bx_messages';
  18. parent::__construct ($aOptions, $oTemplate);
  19. $this->_sDefaultSortingOrder = 'DESC';
  20. }
  21. public function performActionCompose()
  22. {
  23. $oModule = BxDolModule::getInstance(self::$MODULE);
  24. $CNF = &$oModule->_oConfig->CNF;
  25. bx_import('BxDolPermalinks');
  26. $sUrl = BX_DOL_URL_ROOT . BxDolPermalinks::getInstance()->permalink('page.php?i=' . $CNF['URI_ADD_ENTRY']);
  27. header('Location:' . $sUrl);
  28. }
  29. protected function _getActionAdd ($sType, $sKey, $a, $isSmall = false, $isDisabled = false, $aRow = array())
  30. {
  31. $oModule = BxDolModule::getInstance(self::$MODULE);
  32. $CNF = &$oModule->_oConfig->CNF;
  33. bx_import('BxDolPermalinks');
  34. $sUrl = BX_DOL_URL_ROOT . BxDolPermalinks::getInstance()->permalink('page.php?i=' . $CNF['URI_ADD_ENTRY']);
  35. $a['attr']['onclick'] = "document.location='$sUrl'";
  36. unset($a['attr']['bx_grid_action_independent']);
  37. return parent::_getActionDefault ($sType, $sKey, $a, $isSmall, $isDisabled, $aRow);
  38. }
  39. protected function _getCellPreview ($mixedValue, $sKey, $aField, $aRow)
  40. {
  41. $oModule = BxDolModule::getInstance(self::$MODULE);
  42. $CNF = &$oModule->_oConfig->CNF;
  43. bx_import('BxDolPermalinks');
  44. $sUrl = BX_DOL_URL_ROOT . BxDolPermalinks::getInstance()->permalink('page.php?i=' . $CNF['URI_VIEW_ENTRY'] . '&id=' . $aRow[$CNF['FIELD_ID']]);
  45. $s = strmaxtextlen($aRow['text'], 100);
  46. $s = '<a href="' . $sUrl . '">' . $s . '</a>';
  47. if ($aRow['comments'] - $aRow['read_comments'] > 0)
  48. $s = '<b>' . $s . '</b>';
  49. return parent::_getCellDefault ($s, $sKey, $aField, $aRow);
  50. }
  51. protected function _getCellLastReplyTimestamp ($mixedValue, $sKey, $aField, $aRow)
  52. {
  53. $s = bx_time_js($mixedValue, BX_FORMAT_DATE);
  54. if ($aRow['comments'] - $aRow['read_comments'] > 0)
  55. $s = '<b>' . $s . '</b>';
  56. return parent::_getCellDefault ($s, $sKey, $aField, $aRow);
  57. }
  58. protected function _getCellCollaborators ($mixedValue, $sKey, $aField, $aRow)
  59. {
  60. $oModule = BxDolModule::getInstance(self::$MODULE);
  61. $s = $oModule->_oTemplate->entryCollaborators ($aRow);
  62. return parent::_getCellDefault ($s, $sKey, $aField, $aRow);
  63. }
  64. protected function _getCellComments ($mixedValue, $sKey, $aField, $aRow)
  65. {
  66. if ($aRow['comments'] - $aRow['read_comments'] > 0)
  67. $mixedValue = _t('_bx_msg_x_new_messages', 1 + $mixedValue, $aRow['comments'] - $aRow['read_comments']);
  68. else
  69. $mixedValue = 1 + $mixedValue;
  70. return parent::_getCellDefault ($mixedValue, $sKey, $aField, $aRow);
  71. }
  72. }
  73. /** @} */