Friendica Communications Platform (please note that this is a clone of the repository at github, issues are handled there) https://friendi.ca
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

104 lines
3.0 KiB

  1. <?php
  2. function community_init(&$a) {
  3. if(! local_user()) {
  4. unset($_SESSION['theme']);
  5. unset($_SESSION['mobile-theme']);
  6. }
  7. }
  8. function community_content(&$a, $update = 0) {
  9. $o = '';
  10. if((get_config('system','block_public')) && (! local_user()) && (! remote_user())) {
  11. notice( t('Public access denied.') . EOL);
  12. return;
  13. }
  14. if(get_config('system','no_community_page')) {
  15. notice( t('Not available.') . EOL);
  16. return;
  17. }
  18. require_once("include/bbcode.php");
  19. require_once('include/security.php');
  20. require_once('include/conversation.php');
  21. $o .= '<h3>' . t('Community') . '</h3>';
  22. if(! $update) {
  23. nav_set_selected('community');
  24. }
  25. if(x($a->data,'search'))
  26. $search = notags(trim($a->data['search']));
  27. else
  28. $search = ((x($_GET,'search')) ? notags(trim(rawurldecode($_GET['search']))) : '');
  29. // Here is the way permissions work in this module...
  30. // Only public posts can be shown
  31. // OR your own posts if you are a logged in member
  32. if(! get_pconfig(local_user(),'system','alt_pager')) {
  33. $r = q("SELECT COUNT(distinct(`item`.`uri`)) AS `total`
  34. FROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id` LEFT JOIN `user` ON `user`.`uid` = `item`.`uid`
  35. WHERE `item`.`visible` = 1 AND `item`.`deleted` = 0 and `item`.`moderated` = 0
  36. AND `item`.`allow_cid` = '' AND `item`.`allow_gid` = ''
  37. AND `item`.`deny_cid` = '' AND `item`.`deny_gid` = ''
  38. AND `item`.`private` = 0 AND `item`.`wall` = 1 AND `user`.`hidewall` = 0
  39. AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0"
  40. );
  41. if(count($r))
  42. $a->set_pager_total($r[0]['total']);
  43. if(! $r[0]['total']) {
  44. info( t('No results.') . EOL);
  45. return $o;
  46. }
  47. }
  48. $r = q("SELECT distinct(`item`.`uri`), `item`.*, `item`.`id` AS `item_id`,
  49. `contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`alias`, `contact`.`rel`,
  50. `contact`.`network`, `contact`.`thumb`, `contact`.`self`, `contact`.`writable`,
  51. `contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid`,
  52. `user`.`nickname`, `user`.`hidewall`
  53. FROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
  54. LEFT JOIN `user` ON `user`.`uid` = `item`.`uid`
  55. WHERE `item`.`visible` = 1 AND `item`.`deleted` = 0 and `item`.`moderated` = 0
  56. AND `item`.`allow_cid` = '' AND `item`.`allow_gid` = ''
  57. AND `item`.`deny_cid` = '' AND `item`.`deny_gid` = ''
  58. AND `item`.`private` = 0 AND `item`.`wall` = 1 AND `user`.`hidewall` = 0
  59. AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0 group by `item`.`uri`
  60. ORDER BY `received` DESC LIMIT %d, %d ",
  61. intval($a->pager['start']),
  62. intval($a->pager['itemspage'])
  63. );
  64. if(! count($r)) {
  65. info( t('No results.') . EOL);
  66. return $o;
  67. }
  68. // we behave the same in message lists as the search module
  69. $o .= conversation($a,$r,'community',$update);
  70. if(! get_pconfig(local_user(),'system','alt_pager')) {
  71. $o .= paginate($a);
  72. }
  73. else {
  74. $o .= alt_pager($a,count($r));
  75. }
  76. return $o;
  77. }