3 function directory_init(&$a) {
4 $a->set_pager_itemspage(60);
7 require_once('include/contact_widgets.php');
9 $a->page['aside'] .= findpeople_widget();
11 $a->page['aside'] .= follow_widget();
15 unset($_SESSION['theme']);
16 unset($_SESSION['mobile-theme']);
23 function directory_post(&$a) {
24 if(x($_POST,'search'))
25 $a->data['search'] = $_POST['search'];
30 function directory_content(&$a) {
33 require_once("mod/proxy.php");
35 if((get_config('system','block_public')) && (! local_user()) && (! remote_user()) ||
36 (get_config('system','block_local_dir')) && (! local_user()) && (! remote_user())) {
37 notice( t('Public access denied.') . EOL);
42 nav_set_selected('directory');
44 if(x($a->data,'search'))
45 $search = notags(trim($a->data['search']));
47 $search = ((x($_GET,'search')) ? notags(trim(rawurldecode($_GET['search']))) : '');
50 $dirurl = get_config('system','directory');
52 $gdirpath = zrl($dirurl,true);
56 $search = dbesc($search);
58 $sql_extra = " AND ((`profile`.`name` LIKE '%$search%') OR
59 (`user`.`nickname` LIKE '%$search%') OR
60 (`profile`.`pdesc` LIKE '%$search%') OR
61 (`profile`.`locality` LIKE '%$search%') OR
62 (`profile`.`region` LIKE '%$search%') OR
63 (`profile`.`country-name` LIKE '%$search%') OR
64 (`profile`.`gender` LIKE '%$search%') OR
65 (`profile`.`marital` LIKE '%$search%') OR
66 (`profile`.`sexual` LIKE '%$search%') OR
67 (`profile`.`about` LIKE '%$search%') OR
68 (`profile`.`romance` LIKE '%$search%') OR
69 (`profile`.`work` LIKE '%$search%') OR
70 (`profile`.`education` LIKE '%$search%') OR
71 (`profile`.`pub_keywords` LIKE '%$search%') OR
72 (`profile`.`prv_keywords` LIKE '%$search%'))";
75 $publish = ((get_config('system','publish_all')) ? '' : " AND `publish` = 1 " );
78 $r = $db->q("SELECT COUNT(*) AS `total` FROM `profile`
79 LEFT JOIN `user` ON `user`.`uid` = `profile`.`uid`
80 WHERE `is-default` = 1 $publish AND `user`.`blocked` = 0 $sql_extra ");
82 $a->set_pager_total($r[0]['total']);
84 $order = " ORDER BY `name` ASC ";
86 $limit = intval($a->pager['start']).",".intval($a->pager['itemspage']);
88 $r = $db->q("SELECT `profile`.*, `profile`.`uid` AS `profile_uid`, `user`.`nickname`, `user`.`timezone` , `user`.`page-flags`,
89 `contact`.`addr`, `contact`.`url` AS profile_url FROM `profile`
90 LEFT JOIN `user` ON `user`.`uid` = `profile`.`uid`
91 LEFT JOIN `contact` ON `contact`.`uid` = `user`.`uid`
92 WHERE `is-default` = 1 $publish AND `user`.`blocked` = 0 AND `contact`.`self` $sql_extra $order LIMIT ".$limit);
95 if(in_array('small', $a->argv))
105 $itemurl = (($rr['addr'] != "") ? $rr['addr'] : $rr['profile_url']);
107 $profile_link = 'profile/' . ((strlen($rr['nickname'])) ? $rr['nickname'] : $rr['profile_uid']);
109 $pdesc = (($rr['pdesc']) ? $rr['pdesc'] . '<br />' : '');
112 if(strlen($rr['locality']))
113 $details .= $rr['locality'];
114 if(strlen($rr['region'])) {
115 if(strlen($rr['locality']))
117 $details .= $rr['region'];
119 if(strlen($rr['country-name'])) {
122 $details .= $rr['country-name'];
124 // if(strlen($rr['dob'])) {
125 // if(($years = age($rr['dob'],$rr['timezone'],'')) != 0)
126 // $details .= '<br />' . t('Age: ') . $years ;
128 // if(strlen($rr['gender']))
129 // $details .= '<br />' . t('Gender: ') . $rr['gender'];
132 // show if account is a community account
133 /// @TODO The other page types should be also respected, but first we need a good
134 /// translatiion and systemwide consistency for displaying the page type
135 if((intval($rr['page-flags']) == PAGE_COMMUNITY) OR (intval($rr['page-flags']) == PAGE_PRVGROUP))
140 if((x($profile,'address') == 1)
141 || (x($profile,'locality') == 1)
142 || (x($profile,'region') == 1)
143 || (x($profile,'postal-code') == 1)
144 || (x($profile,'country-name') == 1))
145 $location = t('Location:');
147 $gender = ((x($profile,'gender') == 1) ? t('Gender:') : False);
149 $marital = ((x($profile,'marital') == 1) ? t('Status:') : False);
151 $homepage = ((x($profile,'homepage') == 1) ? t('Homepage:') : False);
153 $about = ((x($profile,'about') == 1) ? t('About:') : False);
155 if($a->theme['template_engine'] === 'internal') {
156 $location_e = template_escape($location);
159 $location_e = $location;
163 'profile' => array(t("View Profile"), zrl($profile_link))
168 'url' => $profile_link,
169 'itemurl' => $itemurl,
170 'thumb' => proxy_url($rr[$photo], false, PROXY_SIZE_THUMB),
171 'img_hover' => $rr['name'],
172 'name' => $rr['name'],
173 'details' => $details,
174 'account_type' => ($community ? t('Forum') : ''),
175 'profile' => $profile,
176 'location' => $location_e,
177 'tags' => $rr['pub_keywords'],
180 'marital' => $marital,
181 'homepage' => $homepage,
183 'photo_menu' => $photo_menu,
187 $arr = array('contact' => $rr, 'entry' => $entry);
189 call_hooks('directory_item', $arr);
197 $entries[] = $arr['entry'];
201 $tpl = get_markup_template('directory_header.tpl');
203 $o .= replace_macros($tpl, array(
204 '$search' => $search,
205 '$globaldir' => t('Global Directory'),
206 '$gdirpath' => $gdirpath,
207 '$desc' => t('Find on this site'),
208 '$contacts' => $entries,
209 '$finding' => t('Results for:'),
210 '$findterm' => (strlen($search) ? $search : ""),
211 '$title' => t('Site Directory'),
212 '$submit' => t('Find'),
213 '$paginate' => paginate($a),
218 info( t("No entries \x28some entries may be hidden\x29.") . EOL);