BxGroupsSearchResult.php 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  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 Groups Groups
  7. * @ingroup TridentModules
  8. *
  9. * @{
  10. */
  11. class BxGroupsSearchResult extends BxBaseModProfileSearchResult
  12. {
  13. function __construct($sMode = '', $aParams = false)
  14. {
  15. parent::__construct($sMode, $aParams);
  16. $this->aCurrent = array(
  17. 'name' => 'bx_groups',
  18. 'module_name' => 'bx_groups',
  19. 'object_metatags' => 'bx_groups',
  20. 'title' => _t('_bx_groups_page_title_browse'),
  21. 'table' => 'sys_profiles',
  22. 'tableSearch' => 'bx_groups_data',
  23. 'ownFields' => array(),
  24. 'searchFields' => array('group_name', 'group_desc'),
  25. 'restriction' => array(
  26. 'account_id' => array('value' => '', 'field' => 'account_id', 'operator' => '='),
  27. 'perofileStatus' => array('value' => 'active', 'field' => 'status', 'operator' => '='),
  28. 'perofileType' => array('value' => 'bx_groups', 'field' => 'type', 'operator' => '='),
  29. 'owner' => array('value' => '', 'field' => 'author', 'operator' => '=', 'table' => 'bx_groups_data'),
  30. ),
  31. 'join' => array (
  32. 'profile' => array(
  33. 'type' => 'INNER',
  34. 'table' => 'bx_groups_data',
  35. 'mainField' => 'content_id',
  36. 'onField' => 'id',
  37. 'joinFields' => array('id', 'group_name', 'picture', 'cover', 'added'),
  38. ),
  39. 'account' => array(
  40. 'type' => 'INNER',
  41. 'table' => 'sys_accounts',
  42. 'mainField' => 'account_id',
  43. 'onField' => 'id',
  44. 'joinFields' => array(),
  45. ),
  46. ),
  47. 'paginate' => array('perPage' => 20, 'start' => 0),
  48. 'sorting' => 'none',
  49. 'rss' => array(
  50. 'title' => '',
  51. 'link' => '',
  52. 'image' => '',
  53. 'profile' => 0,
  54. 'fields' => array (
  55. 'Guid' => 'link',
  56. 'Link' => 'link',
  57. 'Title' => 'group_name',
  58. 'DateTimeUTS' => 'added',
  59. 'Desc' => 'group_name',
  60. 'Picture' => 'picture',
  61. ),
  62. ),
  63. 'ident' => 'id'
  64. );
  65. $this->sFilterName = 'bx_groups_data_filter';
  66. $this->oModule = $this->getMain();
  67. switch ($sMode) {
  68. case 'connections':
  69. if ($this->_setConnectionsConditions($aParams)) {
  70. $oProfile = BxDolProfile::getInstance($aParams['profile']);
  71. $oProfile2 = isset($aParams['profile2']) ? BxDolProfile::getInstance($aParams['profile2']) : null;
  72. if (isset($aParams['type']) && $aParams['type'] == 'common' && $oProfile && $oProfile2)
  73. $this->aCurrent['title'] = _t('_bx_groups_page_title_browse_connections_mutual', $oProfile->getDisplayName(), $oProfile2->getDisplayName());
  74. elseif ((!isset($aParams['type']) || $aParams['type'] != 'common') && $oProfile)
  75. $this->aCurrent['title'] = _t('_bx_groups_page_title_browse_connections', $oProfile->getDisplayName());
  76. $this->aCurrent['rss']['link'] = 'modules/?r=groups/rss/' . $sMode . '/' . $aParams['object'] . '/' . $aParams['type'] . '/' . (int)$aParams['profile'] . '/' . (int)$aParams['profile2'] . '/' . (int)$aParams['mutual'];
  77. }
  78. break;
  79. case 'recent':
  80. $this->aCurrent['rss']['link'] = 'modules/?r=groups/rss/' . $sMode;
  81. $this->aCurrent['title'] = _t('_bx_groups_page_title_browse_recent');
  82. $this->aCurrent['sorting'] = 'last';
  83. $this->sBrowseUrl = 'page.php?i=groups-home';
  84. break;
  85. case 'active':
  86. $this->aCurrent['rss']['link'] = 'modules/?r=groups/rss/' . $sMode;
  87. $this->aCurrent['title'] = _t('_bx_groups_page_title_browse_active');
  88. $this->aCurrent['sorting'] = 'active';
  89. $this->sBrowseUrl = 'page.php?i=groups-active';
  90. break;
  91. case '': // search results
  92. $this->sBrowseUrl = BX_DOL_SEARCH_KEYWORD_PAGE;
  93. $this->aCurrent['title'] = _t('_bx_groups');
  94. $this->aCurrent['paginate']['perPage'] = 5;
  95. unset($this->aCurrent['rss']);
  96. break;
  97. default:
  98. $this->isError = true;
  99. }
  100. $this->sCenterContentUnitSelector = false;
  101. }
  102. function getAlterOrder()
  103. {
  104. switch ($this->aCurrent['sorting']) {
  105. case 'none':
  106. return array('order' => ' ORDER BY `sys_accounts`.`logged` DESC ');
  107. case 'last':
  108. default:
  109. return array('order' => ' ORDER BY `bx_groups_data`.`added` DESC ');
  110. }
  111. }
  112. function _getPseud ()
  113. {
  114. return array(
  115. 'id' => 'id',
  116. 'group_name' => 'group_name',
  117. 'added' => 'added',
  118. 'author' => 'author',
  119. 'picture' => 'picture',
  120. );
  121. }
  122. }
  123. /** @} */