]> git.mxchange.org Git - friendica.git/blob - mod/directory.php
default acl's
[friendica.git] / mod / directory.php
1 <?php
2 function directory_init(&$a) {
3         $a->set_pager_itemspage(60);
4 }
5
6 function directory_content(&$a) {
7
8         $search = ((x($_GET,'search')) ? notags(trim($_GET['search'])) : '');
9
10         $tpl .= file_get_contents('view/directory_header.tpl');
11
12         $o .= replace_macros($tpl, array(
13                 '$search' => $search,
14                 '$finding' => (strlen($search) ? "<h4>Finding: '$search'</h4>" : "")
15         ));
16
17         if($search)
18                 $search = dbesc($search);
19         $sql_extra = ((strlen($search)) ? " AND MATCH (`profile`.`name`, `user`.`nickname`, `locality`,`region`,`country-name`,`gender`,`marital`,`sexual`,`about`,`romance`,`work`,`education`) AGAINST ('$search' IN BOOLEAN MODE) " : "");
20
21
22         $r = q("SELECT COUNT(*) AS `total` FROM `profile` LEFT JOIN `user` ON `user`.`uid` = `profile`.`uid` WHERE `is-default` = 1 AND `publish` = 1 AND `user`.`blocked` = 0 $sql_extra ");
23         if(count($r))
24                 $a->set_pager_total($r[0]['total']);
25
26
27
28         $r = q("SELECT `profile`.*, `profile`.`uid` AS `profile_uid`, `user`.`nickname`, `user`.`timezone` FROM `profile` LEFT JOIN `user` ON `user`.`uid` = `profile`.`uid` WHERE `is-default` = 1 AND `publish` = 1 AND `user`.`blocked` = 0 $sql_extra ORDER BY `name` ASC LIMIT %d , %d ",
29                 intval($a->pager['start']),
30                 intval($a->pager['itemspage'])
31         );
32         if(count($r)) {
33
34                 $tpl = file_get_contents('view/directory_item.tpl');
35
36                 if(in_array('small', $a->argv))
37                         $photo = 'thumb';
38                 else
39                         $photo = 'photo';
40
41                 foreach($r as $rr) {
42
43
44                         $profile_link = $a->get_baseurl() . '/profile/' . ((strlen($rr['nickname'])) ? $rr['nickname'] : $rr['profile_uid']);
45                         $details = '';
46                         if(strlen($rr['locality']))
47                                 $details .= $rr['locality'];
48                         if(strlen($rr['region'])) {
49                                 if(strlen($rr['locality']))
50                                         $details .= ', ';
51                                 $details .= $rr['region'];
52                         }
53                         if(strlen($rr['country-name'])) {
54                                 if(strlen($details))
55                                         $details .= ', ';
56                                 $details .= $rr['country-name'];
57                         }
58                         if(strlen($rr['dob'])) {
59                                 if(($years = age($rr['dob'],$rr['timezone'],'')) != 0)
60                                         $details .= "<br />Age: $years" ; 
61                         }
62                         if(strlen($rr['gender']))
63                                 $details .= '<br />Gender: ' . $rr['gender'];
64
65                         $o .= replace_macros($tpl,array(
66                                 '$id' => $rr['id'],
67                                 '$profile-link' => $profile_link,
68                                 '$photo' => $rr[$photo],
69                                 '$alt-text' => $rr['name'],
70                                 '$name' => $rr['name'],
71                                 '$details' => $details  
72
73
74                         ));
75
76                 }
77                 $o .= "<div class=\"directory-end\" ></div>\r\n";
78                 $o .= paginate($a);
79
80         }
81         else
82                 notice("No entries (some entries may be hidden).");
83
84         return $o;
85 }