BxCnvGrid.php 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  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 Convos Convos
  7. * @ingroup DolphinModules
  8. *
  9. * @{
  10. */
  11. require_once(BX_DIRECTORY_PATH_INC . "design.inc.php");
  12. bx_import('BxTemplGrid');
  13. class BxCnvGrid extends BxTemplGrid
  14. {
  15. protected $MODULE;
  16. public function __construct ($aOptions, $oTemplate = false)
  17. {
  18. $this->MODULE = 'bx_convos';
  19. parent::__construct ($aOptions, $oTemplate);
  20. $this->_sDefaultSortingOrder = 'DESC';
  21. if ($iFolderId = (int)bx_get('folder_id'))
  22. $this->addMarkers(array(
  23. 'folder_id' => $iFolderId,
  24. 'profile_id' => bx_get_logged_profile_id(),
  25. ));
  26. }
  27. public function performActionCompose()
  28. {
  29. bx_import('BxDolModule');
  30. $oModule = BxDolModule::getInstance($this->MODULE);
  31. $CNF = &$oModule->_oConfig->CNF;
  32. bx_import('BxDolPermalinks');
  33. $sUrl = BX_DOL_URL_ROOT . BxDolPermalinks::getInstance()->permalink('page.php?i=' . $CNF['URI_ADD_ENTRY']);
  34. header('Location:' . $sUrl);
  35. }
  36. protected function _getActionAdd ($sType, $sKey, $a, $isSmall = false, $isDisabled = false, $aRow = array())
  37. {
  38. bx_import('BxDolModule');
  39. $oModule = BxDolModule::getInstance($this->MODULE);
  40. $CNF = &$oModule->_oConfig->CNF;
  41. bx_import('BxDolPermalinks');
  42. $sUrl = BX_DOL_URL_ROOT . BxDolPermalinks::getInstance()->permalink('page.php?i=' . $CNF['URI_ADD_ENTRY']);
  43. $a['attr']['onclick'] = "document.location='$sUrl'";
  44. unset($a['attr']['bx_grid_action_independent']);
  45. return parent::_getActionDefault ($sType, $sKey, $a, $isSmall, $isDisabled, $aRow);
  46. }
  47. protected function _getCellPreview ($mixedValue, $sKey, $aField, $aRow)
  48. {
  49. bx_import('BxDolModule');
  50. $oModule = BxDolModule::getInstance($this->MODULE);
  51. $CNF = &$oModule->_oConfig->CNF;
  52. bx_import('BxDolPermalinks');
  53. $sUrl = BX_DOL_URL_ROOT . BxDolPermalinks::getInstance()->permalink('page.php?i=' . $CNF['URI_VIEW_ENTRY'] . '&id=' . $aRow[$CNF['FIELD_ID']]);
  54. $s = strmaxtextlen($aRow['text'], 100);
  55. $s = '<a href="' . $sUrl . '">' . $s . '</a>';
  56. if ($aRow['comments'] - $aRow['read_comments'] > 0)
  57. $s = '<b>' . $s . '</b>';
  58. return parent::_getCellDefault ($s, $sKey, $aField, $aRow);
  59. }
  60. protected function _getCellLastReplyTimestamp ($mixedValue, $sKey, $aField, $aRow)
  61. {
  62. $s = bx_time_js($mixedValue, BX_FORMAT_DATE);
  63. if ($aRow['comments'] - $aRow['read_comments'] > 0)
  64. $s = '<b>' . $s . '</b>';
  65. return parent::_getCellDefault ($s, $sKey, $aField, $aRow);
  66. }
  67. protected function _getCellCollaborators ($mixedValue, $sKey, $aField, $aRow)
  68. {
  69. bx_import('BxDolModule');
  70. $oModule = BxDolModule::getInstance($this->MODULE);
  71. $s = $oModule->_oTemplate->entryCollaborators ($aRow);
  72. return parent::_getCellDefault ($s, $sKey, $aField, $aRow);
  73. }
  74. protected function _getCellComments ($mixedValue, $sKey, $aField, $aRow)
  75. {
  76. if ($aRow['comments'] - $aRow['read_comments'] > 0)
  77. $mixedValue = _t('_bx_cnv_x_new_messages', 1 + $mixedValue, $aRow['comments'] - $aRow['read_comments']);
  78. else
  79. $mixedValue = 1 + $mixedValue;
  80. return parent::_getCellDefault ($mixedValue, $sKey, $aField, $aRow);
  81. }
  82. protected function _delete ($mixedId)
  83. {
  84. bx_import('BxDolModule');
  85. $oModule = BxDolModule::getInstance($this->MODULE);
  86. if ($sErrorMsg = $oModule->deleteConvo ($mixedId))
  87. return false;
  88. return $oModule->_oDb->moveConvo((int)$mixedId, bx_get_logged_profile_id(), BX_CNV_FOLDER_TRASH);
  89. }
  90. }
  91. /** @} */