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.

209 lines
5.6 KiB

10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
  1. <?php
  2. use Friendica\App;
  3. function directory_init(App $a) {
  4. $a->set_pager_itemspage(60);
  5. if(local_user()) {
  6. require_once('include/contact_widgets.php');
  7. $a->page['aside'] .= findpeople_widget();
  8. $a->page['aside'] .= follow_widget();
  9. }
  10. else {
  11. unset($_SESSION['theme']);
  12. unset($_SESSION['mobile-theme']);
  13. }
  14. }
  15. function directory_post(App $a) {
  16. if(x($_POST,'search'))
  17. $a->data['search'] = $_POST['search'];
  18. }
  19. function directory_content(App $a) {
  20. require_once("mod/proxy.php");
  21. if((get_config('system','block_public')) && (! local_user()) && (! remote_user()) ||
  22. (get_config('system','block_local_dir')) && (! local_user()) && (! remote_user())) {
  23. notice( t('Public access denied.') . EOL);
  24. return;
  25. }
  26. $o = '';
  27. nav_set_selected('directory');
  28. if(x($a->data,'search'))
  29. $search = notags(trim($a->data['search']));
  30. else
  31. $search = ((x($_GET,'search')) ? notags(trim(rawurldecode($_GET['search']))) : '');
  32. $gdirpath = '';
  33. $dirurl = get_config('system','directory');
  34. if(strlen($dirurl)) {
  35. $gdirpath = zrl($dirurl,true);
  36. }
  37. if($search) {
  38. $search = dbesc($search);
  39. $sql_extra = " AND ((`profile`.`name` LIKE '%$search%') OR
  40. (`user`.`nickname` LIKE '%$search%') OR
  41. (`profile`.`pdesc` LIKE '%$search%') OR
  42. (`profile`.`locality` LIKE '%$search%') OR
  43. (`profile`.`region` LIKE '%$search%') OR
  44. (`profile`.`country-name` LIKE '%$search%') OR
  45. (`profile`.`gender` LIKE '%$search%') OR
  46. (`profile`.`marital` LIKE '%$search%') OR
  47. (`profile`.`sexual` LIKE '%$search%') OR
  48. (`profile`.`about` LIKE '%$search%') OR
  49. (`profile`.`romance` LIKE '%$search%') OR
  50. (`profile`.`work` LIKE '%$search%') OR
  51. (`profile`.`education` LIKE '%$search%') OR
  52. (`profile`.`pub_keywords` LIKE '%$search%') OR
  53. (`profile`.`prv_keywords` LIKE '%$search%'))";
  54. }
  55. $publish = ((get_config('system','publish_all')) ? '' : " AND `publish` = 1 " );
  56. $r = q("SELECT COUNT(*) AS `total` FROM `profile`
  57. LEFT JOIN `user` ON `user`.`uid` = `profile`.`uid`
  58. WHERE `is-default` = 1 $publish AND `user`.`blocked` = 0 $sql_extra ");
  59. if (dbm::is_result($r))
  60. $a->set_pager_total($r[0]['total']);
  61. $order = " ORDER BY `name` ASC ";
  62. $limit = intval($a->pager['start']).",".intval($a->pager['itemspage']);
  63. $r = q("SELECT `profile`.*, `profile`.`uid` AS `profile_uid`, `user`.`nickname`, `user`.`timezone` , `user`.`page-flags`,
  64. `contact`.`addr`, `contact`.`url` AS profile_url FROM `profile`
  65. LEFT JOIN `user` ON `user`.`uid` = `profile`.`uid`
  66. LEFT JOIN `contact` ON `contact`.`uid` = `user`.`uid`
  67. WHERE `is-default` $publish AND `user`.`blocked` = 0 AND `contact`.`self` $sql_extra $order LIMIT ".$limit);
  68. if (dbm::is_result($r)) {
  69. if (in_array('small', $a->argv)) {
  70. $photo = 'thumb';
  71. }
  72. else {
  73. $photo = 'photo';
  74. }
  75. foreach ($r as $rr) {
  76. $itemurl= '';
  77. $itemurl = (($rr['addr'] != "") ? $rr['addr'] : $rr['profile_url']);
  78. $profile_link = 'profile/' . ((strlen($rr['nickname'])) ? $rr['nickname'] : $rr['profile_uid']);
  79. $pdesc = (($rr['pdesc']) ? $rr['pdesc'] . '<br />' : '');
  80. $details = '';
  81. if(strlen($rr['locality']))
  82. $details .= $rr['locality'];
  83. if(strlen($rr['region'])) {
  84. if(strlen($rr['locality']))
  85. $details .= ', ';
  86. $details .= $rr['region'];
  87. }
  88. if(strlen($rr['country-name'])) {
  89. if(strlen($details))
  90. $details .= ', ';
  91. $details .= $rr['country-name'];
  92. }
  93. // if(strlen($rr['dob'])) {
  94. // if(($years = age($rr['dob'],$rr['timezone'],'')) != 0)
  95. // $details .= '<br />' . t('Age: ') . $years ;
  96. // }
  97. // if(strlen($rr['gender']))
  98. // $details .= '<br />' . t('Gender: ') . $rr['gender'];
  99. $profile = $rr;
  100. if((x($profile,'address') == 1)
  101. || (x($profile,'locality') == 1)
  102. || (x($profile,'region') == 1)
  103. || (x($profile,'postal-code') == 1)
  104. || (x($profile,'country-name') == 1))
  105. $location = t('Location:');
  106. $gender = ((x($profile,'gender') == 1) ? t('Gender:') : False);
  107. $marital = ((x($profile,'marital') == 1) ? t('Status:') : False);
  108. $homepage = ((x($profile,'homepage') == 1) ? t('Homepage:') : False);
  109. $about = ((x($profile,'about') == 1) ? t('About:') : False);
  110. if($a->theme['template_engine'] === 'internal') {
  111. $location_e = template_escape($location);
  112. }
  113. else {
  114. $location_e = $location;
  115. }
  116. $photo_menu = array(
  117. 'profile' => array(t("View Profile"), zrl($profile_link))
  118. );
  119. $entry = array(
  120. 'id' => $rr['id'],
  121. 'url' => $profile_link,
  122. 'itemurl' => $itemurl,
  123. 'thumb' => proxy_url($rr[$photo], false, PROXY_SIZE_THUMB),
  124. 'img_hover' => $rr['name'],
  125. 'name' => $rr['name'],
  126. 'details' => $details,
  127. 'account_type' => account_type($rr),
  128. 'profile' => $profile,
  129. 'location' => $location_e,
  130. 'tags' => $rr['pub_keywords'],
  131. 'gender' => $gender,
  132. 'pdesc' => $pdesc,
  133. 'marital' => $marital,
  134. 'homepage' => $homepage,
  135. 'about' => $about,
  136. 'photo_menu' => $photo_menu,
  137. );
  138. $arr = array('contact' => $rr, 'entry' => $entry);
  139. call_hooks('directory_item', $arr);
  140. unset($profile);
  141. unset($location);
  142. if(! $arr['entry'])
  143. continue;
  144. $entries[] = $arr['entry'];
  145. }
  146. $tpl = get_markup_template('directory_header.tpl');
  147. $o .= replace_macros($tpl, array(
  148. '$search' => $search,
  149. '$globaldir' => t('Global Directory'),
  150. '$gdirpath' => $gdirpath,
  151. '$desc' => t('Find on this site'),
  152. '$contacts' => $entries,
  153. '$finding' => t('Results for:'),
  154. '$findterm' => (strlen($search) ? $search : ""),
  155. '$title' => t('Site Directory'),
  156. '$submit' => t('Find'),
  157. '$paginate' => paginate($a),
  158. ));
  159. }
  160. else
  161. info( t("No entries \x28some entries may be hidden\x29.") . EOL);
  162. return $o;
  163. }