BxAnonFollowGridSubscribedMe.php 3.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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 AnonymousFollow Anonymous Follow
  7. * @ingroup UnaModules
  8. *
  9. * @{
  10. */
  11. class BxAnonFollowGridSubscribedMe extends BxDolGridSubscribedMe
  12. {
  13. protected $MODULE;
  14. protected $_oModule;
  15. public function __construct ($aOptions, $oTemplate = false)
  16. {
  17. $this->MODULE = 'bx_anon_follow';
  18. $this->_oModule = BxDolModule::getInstance($this->MODULE);
  19. parent::__construct ($aOptions, $oTemplate);
  20. $CNF = $this->_oModule->_oConfig->CNF;
  21. $this->addMarkers(array(
  22. 'join_connections2' => 'LEFT JOIN `' . $CNF['TABLE_ENTRIES'] . '` AS `c2` ON `c`.`' . $CNF['FIELD_INITIATOR'] . '` = `c2`.`' . $CNF['FIELD_INITIATOR'] . '` AND `c`.`' . $CNF['FIELD_CONTENT'] . '` = `c2`.`' . $CNF['FIELD_CONTENT'] . '` '
  23. ));
  24. }
  25. protected function _getCellName($mixedValue, $sKey, $aField, $aRow)
  26. {
  27. $mixedValue = strip_tags(htmlspecialchars_decode($mixedValue));
  28. $aTitle = array();
  29. $oProfile = BxDolProfile::getInstance($aRow['id']);
  30. $aProfile = $oProfile->getInfo();
  31. $oModule = BxDolModule::getInstance($aProfile['type']);
  32. $aFields = $oModule->serviceGetSearchableFieldsExtended();
  33. $aProfileData = $oModule->serviceGetContentInfoById($aProfile['content_id']);
  34. $sShowFields = $aProfile['type'] == 'bx_persons' ? getParam('bx_anon_follow_persons_fields') : getParam('bx_anon_follow_orgs_fields');
  35. $aShowFields = explode(',', $sShowFields);
  36. $sTitle = '';
  37. foreach($aShowFields as $aField){
  38. $sValue = "";
  39. if (isset($aProfileData[$aField])){
  40. if (isset($aFields[$aField]) && $aFields[$aField]['type'] == 'select' && substr_count($aFields[$aField]['values'], '#!')){
  41. $aValuesList = BxDolForm::getDataItems(str_replace('#!', '', $aFields[$aField]['values']));
  42. if (isset($aValuesList[$aProfileData[$aField]])){
  43. $sValue = $aValuesList[$aProfileData[$aField]];
  44. }
  45. }
  46. else{
  47. $sValue = $aProfileData[$aField];
  48. }
  49. }
  50. if (trim($sValue) != '')
  51. $aTitle[] = $sValue;
  52. }
  53. $sTitle = implode(getParam('bx_anon_follow_fields_separator'), $aTitle);
  54. if ($aRow['anonimus'] == ''){
  55. $sTitle = $this->_oModule->_oTemplate->parseHtmlByName('profile_link.html', array('href' => $oProfile->getUrl(), 'content' => $oProfile->getDisplayName() . getParam('bx_anon_follow_fields_separator') . $sTitle));
  56. }
  57. else{
  58. $sTitle = _t('_bx_anon_follow_txt_grid_title_default') . $sTitle;
  59. }
  60. return parent::_getCellDefault($sTitle, $sKey, $aField, $aRow);
  61. }
  62. protected function _getActionSubscribe ($sType, $sKey, $a, $isSmall = false, $isDisabled = false, $aRow = array())
  63. {
  64. $iViewerId = bx_get_logged_profile_id();
  65. if(!isLogged() || $iViewerId == $aRow['id'] || $this->_oConnection->isConnected($iViewerId, $aRow['id']) || $aRow['anonimus'] != '')
  66. return '';
  67. return parent::_getActionDefault ($sType, $sKey, $a, $isSmall, $isDisabled, $aRow);
  68. }
  69. protected function _getRowHead ()
  70. {
  71. return "";
  72. }
  73. protected function _getFilterControls ()
  74. {
  75. return "";
  76. }
  77. }
  78. /** @} */