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) {
27 require_once("mod/proxy.php");
29 if((get_config('system','block_public')) && (! local_user()) && (! remote_user()) ||
30 (get_config('system','block_local_dir')) && (! local_user()) && (! remote_user())) {
31 notice( t('Public access denied.') . EOL);
36 nav_set_selected('directory');
38 if(x($a->data,'search'))
39 $search = notags(trim($a->data['search']));
41 $search = ((x($_GET,'search')) ? notags(trim(rawurldecode($_GET['search']))) : '');
44 $dirurl = get_config('system','directory');
46 $gdirpath = zrl($dirurl,true);
50 $search = dbesc($search);
52 $sql_extra = " AND ((`profile`.`name` LIKE '%$search%') OR
53 (`user`.`nickname` LIKE '%$search%') OR
54 (`profile`.`pdesc` LIKE '%$search%') OR
55 (`profile`.`locality` LIKE '%$search%') OR
56 (`profile`.`region` LIKE '%$search%') OR
57 (`profile`.`country-name` LIKE '%$search%') OR
58 (`profile`.`gender` LIKE '%$search%') OR
59 (`profile`.`marital` LIKE '%$search%') OR
60 (`profile`.`sexual` LIKE '%$search%') OR
61 (`profile`.`about` LIKE '%$search%') OR
62 (`profile`.`romance` LIKE '%$search%') OR
63 (`profile`.`work` LIKE '%$search%') OR
64 (`profile`.`education` LIKE '%$search%') OR
65 (`profile`.`pub_keywords` LIKE '%$search%') OR
66 (`profile`.`prv_keywords` LIKE '%$search%'))";
69 $publish = ((get_config('system','publish_all')) ? '' : " AND `publish` = 1 " );
72 $r = q("SELECT COUNT(*) AS `total` FROM `profile`
73 LEFT JOIN `user` ON `user`.`uid` = `profile`.`uid`
74 WHERE `is-default` = 1 $publish AND `user`.`blocked` = 0 $sql_extra ");
75 if (dbm::is_result($r))
76 $a->set_pager_total($r[0]['total']);
78 $order = " ORDER BY `name` ASC ";
80 $limit = intval($a->pager['start']).",".intval($a->pager['itemspage']);
82 $r = q("SELECT `profile`.*, `profile`.`uid` AS `profile_uid`, `user`.`nickname`, `user`.`timezone` , `user`.`page-flags`,
83 `contact`.`addr`, `contact`.`url` AS profile_url FROM `profile`
84 LEFT JOIN `user` ON `user`.`uid` = `profile`.`uid`
85 LEFT JOIN `contact` ON `contact`.`uid` = `user`.`uid`
86 WHERE `is-default` $publish AND `user`.`blocked` = 0 AND `contact`.`self` $sql_extra $order LIMIT ".$limit);
87 if (dbm::is_result($r)) {
89 if (in_array('small', $a->argv)) {
100 $itemurl = (($rr['addr'] != "") ? $rr['addr'] : $rr['profile_url']);
102 $profile_link = 'profile/' . ((strlen($rr['nickname'])) ? $rr['nickname'] : $rr['profile_uid']);
104 $pdesc = (($rr['pdesc']) ? $rr['pdesc'] . '<br />' : '');
107 if(strlen($rr['locality']))
108 $details .= $rr['locality'];
109 if(strlen($rr['region'])) {
110 if(strlen($rr['locality']))
112 $details .= $rr['region'];
114 if(strlen($rr['country-name'])) {
117 $details .= $rr['country-name'];
119 // if(strlen($rr['dob'])) {
120 // if(($years = age($rr['dob'],$rr['timezone'],'')) != 0)
121 // $details .= '<br />' . t('Age: ') . $years ;
123 // if(strlen($rr['gender']))
124 // $details .= '<br />' . t('Gender: ') . $rr['gender'];
128 if((x($profile,'address') == 1)
129 || (x($profile,'locality') == 1)
130 || (x($profile,'region') == 1)
131 || (x($profile,'postal-code') == 1)
132 || (x($profile,'country-name') == 1))
133 $location = t('Location:');
135 $gender = ((x($profile,'gender') == 1) ? t('Gender:') : False);
137 $marital = ((x($profile,'marital') == 1) ? t('Status:') : False);
139 $homepage = ((x($profile,'homepage') == 1) ? t('Homepage:') : False);
141 $about = ((x($profile,'about') == 1) ? t('About:') : False);
143 if($a->theme['template_engine'] === 'internal') {
144 $location_e = template_escape($location);
147 $location_e = $location;
151 'profile' => array(t("View Profile"), zrl($profile_link))
156 'url' => $profile_link,
157 'itemurl' => $itemurl,
158 'thumb' => proxy_url($rr[$photo], false, PROXY_SIZE_THUMB),
159 'img_hover' => $rr['name'],
160 'name' => $rr['name'],
161 'details' => $details,
162 'account_type' => account_type($rr),
163 'profile' => $profile,
164 'location' => $location_e,
165 'tags' => $rr['pub_keywords'],
168 'marital' => $marital,
169 'homepage' => $homepage,
171 'photo_menu' => $photo_menu,
175 $arr = array('contact' => $rr, 'entry' => $entry);
177 call_hooks('directory_item', $arr);
185 $entries[] = $arr['entry'];
189 $tpl = get_markup_template('directory_header.tpl');
191 $o .= replace_macros($tpl, array(
192 '$search' => $search,
193 '$globaldir' => t('Global Directory'),
194 '$gdirpath' => $gdirpath,
195 '$desc' => t('Find on this site'),
196 '$contacts' => $entries,
197 '$finding' => t('Results for:'),
198 '$findterm' => (strlen($search) ? $search : ""),
199 '$title' => t('Site Directory'),
200 '$submit' => t('Find'),
201 '$paginate' => paginate($a),
206 info( t("No entries \x28some entries may be hidden\x29.") . EOL);