Friendica Communications Platform (please note that this is a clone of the repository at github, issues are handled there) https://friendi.ca
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

125 lignes
3.1KB

  1. <?php
  2. use Friendica\Core\Config;
  3. function community_init(App $a) {
  4. if (! local_user()) {
  5. unset($_SESSION['theme']);
  6. unset($_SESSION['mobile-theme']);
  7. }
  8. }
  9. function community_content(App $a, $update = 0) {
  10. $o = '';
  11. if ((Config::get('system','block_public')) && (! local_user()) && (! remote_user())) {
  12. notice( t('Public access denied.') . EOL);
  13. return;
  14. }
  15. if (Config::get('system','community_page_style') == CP_NO_COMMUNITY_PAGE) {
  16. notice( t('Not available.') . EOL);
  17. return;
  18. }
  19. require_once("include/bbcode.php");
  20. require_once('include/security.php');
  21. require_once('include/conversation.php');
  22. $o .= '<h3>' . t('Community') . '</h3>';
  23. if (! $update) {
  24. nav_set_selected('community');
  25. }
  26. if (x($a->data,'search')) {
  27. $search = notags(trim($a->data['search']));
  28. } else {
  29. $search = ((x($_GET,'search')) ? notags(trim(rawurldecode($_GET['search']))) : '');
  30. }
  31. // Here is the way permissions work in this module...
  32. // Only public posts can be shown
  33. // OR your own posts if you are a logged in member
  34. $r = community_getitems($a->pager['start'], $a->pager['itemspage']);
  35. if (! dbm::is_result($r)) {
  36. info( t('No results.') . EOL);
  37. return $o;
  38. }
  39. $maxpostperauthor = Config::get('system','max_author_posts_community_page');
  40. if ($maxpostperauthor != 0) {
  41. $count = 1;
  42. $previousauthor = "";
  43. $numposts = 0;
  44. $s = array();
  45. do {
  46. foreach ($r AS $row=>$item) {
  47. if ($previousauthor == $item["author-link"]) {
  48. ++$numposts;
  49. } else {
  50. $numposts = 0;
  51. }
  52. $previousauthor = $item["author-link"];
  53. if (($numposts < $maxpostperauthor) AND (sizeof($s) < $a->pager['itemspage'])) {
  54. $s[] = $item;
  55. }
  56. }
  57. if ((sizeof($s) < $a->pager['itemspage'])) {
  58. $r = community_getitems($a->pager['start'] + ($count * $a->pager['itemspage']), $a->pager['itemspage']);
  59. }
  60. } while ((sizeof($s) < $a->pager['itemspage']) AND (++$count < 50) AND (sizeof($r) > 0));
  61. } else {
  62. $s = $r;
  63. }
  64. // we behave the same in message lists as the search module
  65. $o .= conversation($a, $s, 'community', $update);
  66. $o .= alt_pager($a, count($r));
  67. return $o;
  68. }
  69. function community_getitems($start, $itemspage) {
  70. if (Config::get('system','community_page_style') == CP_GLOBAL_COMMUNITY) {
  71. return(community_getpublicitems($start, $itemspage));
  72. }
  73. $r = qu("SELECT %s
  74. FROM `thread`
  75. INNER JOIN `user` ON `user`.`uid` = `thread`.`uid` AND NOT `user`.`hidewall`
  76. INNER JOIN `item` ON `item`.`id` = `thread`.`iid`
  77. AND `item`.`allow_cid` = '' AND `item`.`allow_gid` = ''
  78. AND `item`.`deny_cid` = '' AND `item`.`deny_gid` = ''
  79. %s AND `contact`.`self`
  80. WHERE `thread`.`visible` AND NOT `thread`.`deleted` AND NOT `thread`.`moderated`
  81. AND NOT `thread`.`private` AND `thread`.`wall`
  82. ORDER BY `thread`.`received` DESC LIMIT %d, %d",
  83. item_fieldlists(), item_joins(),
  84. intval($start), intval($itemspage)
  85. );
  86. return($r);
  87. }
  88. function community_getpublicitems($start, $itemspage) {
  89. $r = qu("SELECT %s
  90. FROM `thread`
  91. INNER JOIN `item` ON `item`.`id` = `thread`.`iid` %s
  92. WHERE `thread`.`uid` = 0
  93. ORDER BY `thread`.`created` DESC LIMIT %d, %d",
  94. item_fieldlists(), item_joins(),
  95. intval($start), intval($itemspage)
  96. );
  97. return($r);
  98. }