5 function directory_init(App $a) {
6 $a->set_pager_itemspage(60);
9 require_once('include/contact_widgets.php');
11 $a->page['aside'] .= findpeople_widget();
13 $a->page['aside'] .= follow_widget();
16 unset($_SESSION['theme']);
17 unset($_SESSION['mobile-theme']);
21 function directory_post(App $a) {
22 if(x($_POST,'search'))
23 $a->data['search'] = $_POST['search'];
26 function directory_content(App $a) {
29 require_once("mod/proxy.php");
31 if((get_config('system','block_public')) && (! local_user()) && (! remote_user()) ||
32 (get_config('system','block_local_dir')) && (! local_user()) && (! remote_user())) {
33 notice( t('Public access denied.') . EOL);
38 nav_set_selected('directory');
40 if(x($a->data,'search'))
41 $search = notags(trim($a->data['search']));
43 $search = ((x($_GET,'search')) ? notags(trim(rawurldecode($_GET['search']))) : '');
46 $dirurl = get_config('system','directory');
48 $gdirpath = zrl($dirurl,true);
52 $search = dbesc($search);
54 $sql_extra = " AND ((`profile`.`name` LIKE '%$search%') OR
55 (`user`.`nickname` LIKE '%$search%') OR
56 (`profile`.`pdesc` LIKE '%$search%') OR
57 (`profile`.`locality` LIKE '%$search%') OR
58 (`profile`.`region` LIKE '%$search%') OR
59 (`profile`.`country-name` LIKE '%$search%') OR
60 (`profile`.`gender` LIKE '%$search%') OR
61 (`profile`.`marital` LIKE '%$search%') OR
62 (`profile`.`sexual` LIKE '%$search%') OR
63 (`profile`.`about` LIKE '%$search%') OR
64 (`profile`.`romance` LIKE '%$search%') OR
65 (`profile`.`work` LIKE '%$search%') OR
66 (`profile`.`education` LIKE '%$search%') OR
67 (`profile`.`pub_keywords` LIKE '%$search%') OR
68 (`profile`.`prv_keywords` LIKE '%$search%'))";
71 $publish = ((get_config('system','publish_all')) ? '' : " AND `publish` = 1 " );
74 $r = $db->q("SELECT COUNT(*) AS `total` FROM `profile`
75 LEFT JOIN `user` ON `user`.`uid` = `profile`.`uid`
76 WHERE `is-default` = 1 $publish AND `user`.`blocked` = 0 $sql_extra ");
77 if (dbm::is_result($r))
78 $a->set_pager_total($r[0]['total']);
80 $order = " ORDER BY `name` ASC ";
82 $limit = intval($a->pager['start']).",".intval($a->pager['itemspage']);
84 $r = $db->q("SELECT `profile`.*, `profile`.`uid` AS `profile_uid`, `user`.`nickname`, `user`.`timezone` , `user`.`page-flags`,
85 `contact`.`addr`, `contact`.`url` AS profile_url FROM `profile`
86 LEFT JOIN `user` ON `user`.`uid` = `profile`.`uid`
87 LEFT JOIN `contact` ON `contact`.`uid` = `user`.`uid`
88 WHERE `is-default` = 1 $publish AND `user`.`blocked` = 0 AND `contact`.`self` $sql_extra $order LIMIT ".$limit);
89 if (dbm::is_result($r)) {
91 if (in_array('small', $a->argv)) {
102 $itemurl = (($rr['addr'] != "") ? $rr['addr'] : $rr['profile_url']);
104 $profile_link = 'profile/' . ((strlen($rr['nickname'])) ? $rr['nickname'] : $rr['profile_uid']);
106 $pdesc = (($rr['pdesc']) ? $rr['pdesc'] . '<br />' : '');
109 if(strlen($rr['locality']))
110 $details .= $rr['locality'];
111 if(strlen($rr['region'])) {
112 if(strlen($rr['locality']))
114 $details .= $rr['region'];
116 if(strlen($rr['country-name'])) {
119 $details .= $rr['country-name'];
121 // if(strlen($rr['dob'])) {
122 // if(($years = age($rr['dob'],$rr['timezone'],'')) != 0)
123 // $details .= '<br />' . t('Age: ') . $years ;
125 // if(strlen($rr['gender']))
126 // $details .= '<br />' . t('Gender: ') . $rr['gender'];
130 if((x($profile,'address') == 1)
131 || (x($profile,'locality') == 1)
132 || (x($profile,'region') == 1)
133 || (x($profile,'postal-code') == 1)
134 || (x($profile,'country-name') == 1))
135 $location = t('Location:');
137 $gender = ((x($profile,'gender') == 1) ? t('Gender:') : False);
139 $marital = ((x($profile,'marital') == 1) ? t('Status:') : False);
141 $homepage = ((x($profile,'homepage') == 1) ? t('Homepage:') : False);
143 $about = ((x($profile,'about') == 1) ? t('About:') : False);
145 if($a->theme['template_engine'] === 'internal') {
146 $location_e = template_escape($location);
149 $location_e = $location;
153 'profile' => array(t("View Profile"), zrl($profile_link))
158 'url' => $profile_link,
159 'itemurl' => $itemurl,
160 'thumb' => proxy_url($rr[$photo], false, PROXY_SIZE_THUMB),
161 'img_hover' => $rr['name'],
162 'name' => $rr['name'],
163 'details' => $details,
164 'account_type' => account_type($rr),
165 'profile' => $profile,
166 'location' => $location_e,
167 'tags' => $rr['pub_keywords'],
170 'marital' => $marital,
171 'homepage' => $homepage,
173 'photo_menu' => $photo_menu,
177 $arr = array('contact' => $rr, 'entry' => $entry);
179 call_hooks('directory_item', $arr);
187 $entries[] = $arr['entry'];
191 $tpl = get_markup_template('directory_header.tpl');
193 $o .= replace_macros($tpl, array(
194 '$search' => $search,
195 '$globaldir' => t('Global Directory'),
196 '$gdirpath' => $gdirpath,
197 '$desc' => t('Find on this site'),
198 '$contacts' => $entries,
199 '$finding' => t('Results for:'),
200 '$findterm' => (strlen($search) ? $search : ""),
201 '$title' => t('Site Directory'),
202 '$submit' => t('Find'),
203 '$paginate' => paginate($a),
208 info( t("No entries \x28some entries may be hidden\x29.") . EOL);