BxDolGridRelatedMe.php 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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 UnaCore UNA Core
  7. * @{
  8. */
  9. class BxDolGridRelatedMe extends BxDolGridConnectionIn
  10. {
  11. public function __construct ($aOptions, $oTemplate = false)
  12. {
  13. parent::__construct ($aOptions, $oTemplate);
  14. $this->_sConnectionObject = 'sys_profiles_relations';
  15. }
  16. public function performActionConfirm()
  17. {
  18. list($iId, $iViewedId) = $this->_prepareIds();
  19. if(!$iId)
  20. return echoJson(array('msg' => _t('_sys_txt_error_occured')));
  21. $a = $this->_oConnection->actionConfirm($iId, $iViewedId);
  22. if (isset($a['err']) && $a['err'])
  23. echoJson(array('msg' => $a['msg']));
  24. else
  25. echoJson(array('grid' => $this->getCode(false), 'blink' => $iId));
  26. }
  27. public function performActionDecline()
  28. {
  29. list($iId, $iViewedId) = $this->_prepareIds();
  30. if(!$iId)
  31. return echoJson(array('msg' => _t('_sys_txt_error_occured')));
  32. $a = $this->_oConnection->actionReject($iId, $iViewedId);
  33. if (isset($a['err']) && $a['err'])
  34. echoJson(array('msg' => $a['msg']));
  35. else
  36. echoJson(array('grid' => $this->getCode(false), 'blink' => $iId));
  37. }
  38. protected function _getCellMutual($mixedValue, $sKey, $aField, $aRow)
  39. {
  40. $mixedValue = _t('_sys_' . ((int)$mixedValue != 1 ? 'un' : '') . 'confirmed');
  41. return parent::_getCellDefault($mixedValue, $sKey, $aField, $aRow);
  42. }
  43. protected function _getCellRelation($mixedValue, $sKey, $aField, $aRow)
  44. {
  45. return parent::_getCellDefault($this->_oConnection->getRelationTranslation($mixedValue), $sKey, $aField, $aRow);
  46. }
  47. protected function _getActionConfirm($sType, $sKey, $a, $isSmall = false, $isDisabled = false, $aRow = array())
  48. {
  49. if(!$this->_bOwner || $aRow['mutual'])
  50. return '';
  51. return parent::_getActionDefault($sType, $sKey, $a, $isSmall, $isDisabled, $aRow);
  52. }
  53. protected function _getActionDecline($sType, $sKey, $a, $isSmall = false, $isDisabled = false, $aRow = array())
  54. {
  55. if(!$this->_bOwner || $aRow['mutual'])
  56. return '';
  57. return parent::_getActionDefault($sType, $sKey, $a, $isSmall, $isDisabled, $aRow);
  58. }
  59. protected function _getActionAdd($sType, $sKey, $a, $isSmall = false, $isDisabled = false, $aRow = array())
  60. {
  61. if(!isLogged() || (int)$aRow['id'] == $this->_iViewerId)
  62. return '';
  63. if($this->_oConnection->isConnected($this->_iViewerId, $aRow['id']))
  64. return '';
  65. unset($a['attr']['bx_grid_action_single']);
  66. $a['attr']['onclick'] = "javascript: bx_menu_popup('sys_add_relation', window, {}, {profile_id: " . $aRow['id'] . "});";
  67. return parent::_getActionDefault($sType, $sKey, $a, $isSmall, $isDisabled, $aRow);
  68. }
  69. }
  70. /** @} */