BxPersonsSearchResult.php 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  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 Persons Persons
  7. * @ingroup TridentModules
  8. *
  9. * @{
  10. */
  11. class BxPersonsSearchResult extends BxBaseModProfileSearchResult
  12. {
  13. function __construct($sMode = '', $aParams = false)
  14. {
  15. parent::__construct($sMode, $aParams);
  16. $this->aCurrent = array(
  17. 'name' => 'bx_persons',
  18. 'module_name' => 'bx_persons',
  19. 'object_metatags' => 'bx_persons',
  20. 'title' => _t('_bx_persons_page_title_browse'),
  21. 'table' => 'sys_profiles',
  22. 'tableSearch' => 'bx_persons_data',
  23. 'ownFields' => array(),
  24. 'searchFields' => array('fullname', 'description'),
  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_persons', 'field' => 'type', 'operator' => '='),
  29. 'owner' => array('value' => '', 'field' => 'author', 'operator' => '=', 'table' => 'bx_persons_data'),
  30. 'online' => array('value' => '', 'field' => 'date', 'operator' => '>', 'table' => 'sys_sessions'),
  31. ),
  32. 'join' => array (
  33. 'profile' => array(
  34. 'type' => 'INNER',
  35. 'table' => 'bx_persons_data',
  36. 'mainField' => 'content_id',
  37. 'onField' => 'id',
  38. 'joinFields' => array('id', 'fullname', 'picture', 'added', 'author', 'allow_view_to'),
  39. ),
  40. 'account' => array(
  41. 'type' => 'INNER',
  42. 'table' => 'sys_accounts',
  43. 'mainField' => 'account_id',
  44. 'onField' => 'id',
  45. 'joinFields' => array(),
  46. ),
  47. 'session' => array(
  48. 'type' => 'INNER',
  49. 'table' => 'sys_sessions',
  50. 'mainField' => 'account_id',
  51. 'onField' => 'user_id',
  52. 'joinFields' => array('date'),
  53. ),
  54. ),
  55. 'paginate' => array('perPage' => 20, 'start' => 0),
  56. 'sorting' => 'none',
  57. 'rss' => array(
  58. 'title' => '',
  59. 'link' => '',
  60. 'image' => '',
  61. 'profile' => 0,
  62. 'fields' => array (
  63. 'Guid' => 'link',
  64. 'Link' => 'link',
  65. 'Title' => 'fullname',
  66. 'DateTimeUTS' => 'added',
  67. 'Desc' => 'fullname',
  68. 'Picture' => 'picture',
  69. ),
  70. ),
  71. 'ident' => 'id'
  72. );
  73. $this->sFilterName = 'bx_persons_filter';
  74. $this->oModule = $this->getMain();
  75. switch ($sMode) {
  76. case 'connections':
  77. if ($this->_setConnectionsConditions($aParams)) {
  78. $oProfile = BxDolProfile::getInstance($aParams['profile']);
  79. $oProfile2 = isset($aParams['profile2']) ? BxDolProfile::getInstance($aParams['profile2']) : null;
  80. if (isset($aParams['type']) && $aParams['type'] == 'common' && $oProfile && $oProfile2)
  81. $this->aCurrent['title'] = _t('_bx_persons_page_title_browse_connections_mutual', $oProfile->getDisplayName(), $oProfile2->getDisplayName());
  82. elseif ((!isset($aParams['type']) || $aParams['type'] != 'common') && $oProfile)
  83. $this->aCurrent['title'] = _t('_bx_persons_page_title_browse_connections', $oProfile->getDisplayName());
  84. $this->aCurrent['rss']['link'] = 'modules/?r=persons/rss/' . $sMode . '/' . $aParams['object'] . '/' . $aParams['type'] . '/' . (int)$aParams['profile'] . '/' . (int)$aParams['profile2'] . '/' . (int)$aParams['mutual'];
  85. }
  86. break;
  87. case 'recent':
  88. $this->aCurrent['rss']['link'] = 'modules/?r=persons/rss/' . $sMode;
  89. $this->aCurrent['title'] = _t('_bx_persons_page_title_browse_recent');
  90. $this->aCurrent['sorting'] = 'last';
  91. $this->sBrowseUrl = 'page.php?i=persons-home';
  92. break;
  93. case 'active':
  94. $this->aCurrent['rss']['link'] = 'modules/?r=persons/rss/' . $sMode;
  95. $this->aCurrent['title'] = _t('_bx_persons_page_title_browse_active');
  96. $this->aCurrent['sorting'] = 'active';
  97. $this->sBrowseUrl = 'page.php?i=persons-active';
  98. break;
  99. case 'online':
  100. $this->aCurrent['rss']['link'] = 'modules/?r=persons/rss/' . $sMode;
  101. $this->aCurrent['title'] = _t('_bx_persons_page_title_browse_online');
  102. $this->aCurrent['restriction']['online']['value'] = time() - 60 * (int)getParam('sys_account_online_time');
  103. $this->aCurrent['sorting'] = 'online';
  104. $this->sBrowseUrl = 'page.php?i=persons-online';
  105. break;
  106. case '': // search results
  107. $this->sBrowseUrl = BX_DOL_SEARCH_KEYWORD_PAGE;
  108. $this->aCurrent['title'] = _t('_bx_persons');
  109. $this->aCurrent['paginate']['perPage'] = 5;
  110. unset($this->aCurrent['rss']);
  111. break;
  112. default:
  113. $this->isError = true;
  114. }
  115. parent::__construct();
  116. }
  117. function getAlterOrder()
  118. {
  119. switch ($this->aCurrent['sorting']) {
  120. case 'none':
  121. return array();
  122. case 'active':
  123. return array('order' => ' ORDER BY `sys_accounts`.`logged` DESC ');
  124. case 'online':
  125. return array('order' => ' ORDER BY `sys_sessions`.`date` DESC ');
  126. case 'last':
  127. default:
  128. return array('order' => ' ORDER BY `bx_persons_data`.`added` DESC ');
  129. }
  130. }
  131. function _getPseud ()
  132. {
  133. return array(
  134. 'id' => 'id',
  135. 'fullname' => 'fullname',
  136. 'added' => 'added',
  137. 'author' => 'author',
  138. 'picture' => 'picture',
  139. );
  140. }
  141. }
  142. /** @} */