BxCnvGrid.php 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. <?php defined('BX_DOL') or die('hack attempt');
  2. /**
  3. * Copyright (c) UNA, Inc - https://una.io
  4. * MIT License - https://opensource.org/licenses/MIT
  5. *
  6. * @defgroup Convos Convos
  7. * @ingroup UnaModules
  8. *
  9. * @{
  10. */
  11. require_once(BX_DIRECTORY_PATH_INC . "design.inc.php");
  12. class BxCnvGrid extends BxBaseModGeneralGridAdministration
  13. {
  14. protected $_sFilter1Name;
  15. protected $_sFilter1Value;
  16. protected $_aFilter1Values;
  17. public function __construct ($aOptions, $oTemplate = false)
  18. {
  19. $this->MODULE = 'bx_convos';
  20. parent::__construct ($aOptions, $oTemplate);
  21. $this->_sDefaultSortingOrder = 'DESC';
  22. if ($iFolderId = (int)bx_get('folder_id'))
  23. $this->addMarkers(array(
  24. 'folder_id' => $iFolderId,
  25. 'profile_id' => bx_get_logged_profile_id(),
  26. ));
  27. $this->_sFilter1Name = 'filter1';
  28. $this->_aFilter1Values = array(
  29. '' => _t('_bx_cnv_grid_filter_item_title_adm_all'),
  30. 'unread' => _t('_bx_cnv_grid_filter_item_title_adm_unread'),
  31. );
  32. $sFilter1 = bx_get($this->_sFilter1Name);
  33. if(!empty($sFilter1)) {
  34. $this->_sFilter1Value = bx_process_input($sFilter1);
  35. $this->_aQueryAppend['filter1'] = $this->_sFilter1Value;
  36. }
  37. $this->_sManageType = BX_DOL_MANAGE_TOOLS_COMMON;
  38. }
  39. protected function _getDataSql($sFilter, $sOrderField, $sOrderDir, $iStart, $iPerPage)
  40. {
  41. if(strpos($sFilter, $this->_sParamsDivider) !== false)
  42. list($this->_sFilter1Value, $sFilter) = explode($this->_sParamsDivider, $sFilter);
  43. if(!empty($this->_sFilter1Value)){
  44. $CNF = &$this->_oModule->_oConfig->CNF;
  45. $this->_aOptions['source'] .= $this->_oModule->_oDb->prepareAsString(" WHERE `c`.`comments` > `f`.`read_comments` ");
  46. }
  47. return parent::_getDataSql($sFilter, $sOrderField, $sOrderDir, $iStart, $iPerPage);
  48. }
  49. //--- Layout methods ---//
  50. protected function _getFilterControls()
  51. {
  52. parent::_getFilterControls();
  53. return $this->_getFilterSelectOne($this->_sFilter1Name, $this->_sFilter1Value, $this->_aFilter1Values) . $this->_getSearchInput();
  54. }
  55. public function performActionCompose()
  56. {
  57. $CNF = &$this->_oModule->_oConfig->CNF;
  58. $sUrl = bx_absolute_url(BxDolPermalinks::getInstance()->permalink('page.php?i=' . $CNF['URI_ADD_ENTRY']));
  59. header('Location:' . $sUrl);
  60. }
  61. protected function _getActionAdd ($sType, $sKey, $a, $isSmall = false, $isDisabled = false, $aRow = array())
  62. {
  63. $CNF = &$this->_oModule->_oConfig->CNF;
  64. $sUrl = bx_absolute_url(BxDolPermalinks::getInstance()->permalink('page.php?i=' . $CNF['URI_ADD_ENTRY']));
  65. $a['attr']['onclick'] = "document.location='$sUrl'";
  66. unset($a['attr']['bx_grid_action_independent']);
  67. return parent::_getActionDefault ($sType, $sKey, $a, $isSmall, $isDisabled, $aRow);
  68. }
  69. protected function _getCellHeaderWrapper ($sKey, $aField, $sHeader, $sAttr)
  70. {
  71. $sHeader = '<span>' . $sHeader . '</span>';
  72. return parent::_getCellHeaderWrapper ($sKey, $aField, $sHeader, $sAttr);
  73. }
  74. protected function _getCellPreview ($mixedValue, $sKey, $aField, $aRow)
  75. {
  76. return parent::_getCellDefault ('', $sKey, $aField, $aRow);
  77. }
  78. protected function _getCellLastReplyTimestamp ($mixedValue, $sKey, $aField, $aRow)
  79. {
  80. $s = $this->_oModule->_oTemplate->entryMessagePreviewInGrid ($aRow);
  81. return parent::_getCellDefault ($s, $sKey, $aField, $aRow);
  82. }
  83. protected function _getCellCollaborators ($mixedValue, $sKey, $aField, $aRow)
  84. {
  85. $s = $this->_oModule->_oTemplate->entryCollaborators ($aRow);
  86. return parent::_getCellDefault ($s, $sKey, $aField, $aRow);
  87. }
  88. protected function _getCellComments ($mixedValue, $sKey, $aField, $aRow)
  89. {
  90. $s = $this->_oModule->_oTemplate->getMessageLabel(1 + $mixedValue, $aRow);
  91. return parent::_getCellDefault ($s, $sKey, $aField, $aRow);
  92. }
  93. protected function _doDelete ($iId, $aParams = array())
  94. {
  95. if ($sErrorMsg = $this->_oModule->deleteConvo ($iId))
  96. return 0;
  97. return 1;
  98. }
  99. protected function _addJsCss()
  100. {
  101. parent::_addJsCss();
  102. $this->_oModule->_oTemplate->addJs('main.js');
  103. $this->_oModule->_oTemplate->addCss(array('main-media-tablet.css', 'main-media-desktop.css'));
  104. }
  105. }
  106. /** @} */