4 use Friendica\Core\Config;
5 use Friendica\Database\DBM;
6 use Friendica\Model\Contact;
8 function directory_init(App $a) {
9 $a->set_pager_itemspage(60);
12 require_once('include/contact_widgets.php');
14 $a->page['aside'] .= findpeople_widget();
16 $a->page['aside'] .= follow_widget();
19 unset($_SESSION['theme']);
20 unset($_SESSION['mobile-theme']);
24 function directory_post(App $a) {
25 if(x($_POST,'search'))
26 $a->data['search'] = $_POST['search'];
29 function directory_content(App $a) {
30 require_once("mod/proxy.php");
32 if((Config::get('system','block_public')) && (! local_user()) && (! remote_user()) ||
33 (Config::get('system','block_local_dir')) && (! local_user()) && (! remote_user())) {
34 notice( t('Public access denied.') . EOL);
39 nav_set_selected('directory');
41 if(x($a->data,'search'))
42 $search = notags(trim($a->data['search']));
44 $search = ((x($_GET,'search')) ? notags(trim(rawurldecode($_GET['search']))) : '');
47 $dirurl = Config::get('system','directory');
49 $gdirpath = zrl($dirurl,true);
53 $search = dbesc($search);
55 $sql_extra = " AND ((`profile`.`name` LIKE '%$search%') OR
56 (`user`.`nickname` LIKE '%$search%') OR
57 (`profile`.`pdesc` LIKE '%$search%') OR
58 (`profile`.`locality` LIKE '%$search%') OR
59 (`profile`.`region` LIKE '%$search%') OR
60 (`profile`.`country-name` LIKE '%$search%') OR
61 (`profile`.`gender` LIKE '%$search%') OR
62 (`profile`.`marital` LIKE '%$search%') OR
63 (`profile`.`sexual` LIKE '%$search%') OR
64 (`profile`.`about` LIKE '%$search%') OR
65 (`profile`.`romance` LIKE '%$search%') OR
66 (`profile`.`work` LIKE '%$search%') OR
67 (`profile`.`education` LIKE '%$search%') OR
68 (`profile`.`pub_keywords` LIKE '%$search%') OR
69 (`profile`.`prv_keywords` LIKE '%$search%'))";
72 $publish = ((Config::get('system','publish_all')) ? '' : " AND `publish` = 1 " );
75 $r = q("SELECT COUNT(*) AS `total` FROM `profile`
76 LEFT JOIN `user` ON `user`.`uid` = `profile`.`uid`
77 WHERE `is-default` = 1 $publish AND `user`.`blocked` = 0 $sql_extra ");
78 if (DBM::is_result($r))
79 $a->set_pager_total($r[0]['total']);
81 $order = " ORDER BY `name` ASC ";
83 $limit = intval($a->pager['start']).",".intval($a->pager['itemspage']);
85 $r = q("SELECT `profile`.*, `profile`.`uid` AS `profile_uid`, `user`.`nickname`, `user`.`timezone` , `user`.`page-flags`,
86 `contact`.`addr`, `contact`.`url` AS profile_url FROM `profile`
87 LEFT JOIN `user` ON `user`.`uid` = `profile`.`uid`
88 LEFT JOIN `contact` ON `contact`.`uid` = `user`.`uid`
89 WHERE `is-default` $publish AND `user`.`blocked` = 0 AND `contact`.`self` $sql_extra $order LIMIT ".$limit);
90 if (DBM::is_result($r)) {
92 if (in_array('small', $a->argv)) {
103 $itemurl = (($rr['addr'] != "") ? $rr['addr'] : $rr['profile_url']);
105 $profile_link = 'profile/' . ((strlen($rr['nickname'])) ? $rr['nickname'] : $rr['profile_uid']);
107 $pdesc = (($rr['pdesc']) ? $rr['pdesc'] . '<br />' : '');
110 if(strlen($rr['locality']))
111 $details .= $rr['locality'];
112 if(strlen($rr['region'])) {
113 if(strlen($rr['locality']))
115 $details .= $rr['region'];
117 if(strlen($rr['country-name'])) {
120 $details .= $rr['country-name'];
122 // if(strlen($rr['dob'])) {
123 // if(($years = age($rr['dob'],$rr['timezone'],'')) != 0)
124 // $details .= '<br />' . t('Age: ') . $years ;
126 // if(strlen($rr['gender']))
127 // $details .= '<br />' . t('Gender: ') . $rr['gender'];
131 if((x($profile,'address') == 1)
132 || (x($profile,'locality') == 1)
133 || (x($profile,'region') == 1)
134 || (x($profile,'postal-code') == 1)
135 || (x($profile,'country-name') == 1))
136 $location = t('Location:');
138 $gender = ((x($profile,'gender') == 1) ? t('Gender:') : False);
140 $marital = ((x($profile,'marital') == 1) ? t('Status:') : False);
142 $homepage = ((x($profile,'homepage') == 1) ? t('Homepage:') : False);
144 $about = ((x($profile,'about') == 1) ? t('About:') : False);
146 $location_e = $location;
149 'profile' => array(t("View Profile"), zrl($profile_link))
154 'url' => $profile_link,
155 'itemurl' => $itemurl,
156 'thumb' => proxy_url($rr[$photo], false, PROXY_SIZE_THUMB),
157 'img_hover' => $rr['name'],
158 'name' => $rr['name'],
159 'details' => $details,
160 'account_type' => Contact::getAccountType($rr),
161 'profile' => $profile,
162 'location' => $location_e,
163 'tags' => $rr['pub_keywords'],
166 'marital' => $marital,
167 'homepage' => $homepage,
169 'photo_menu' => $photo_menu,
173 $arr = array('contact' => $rr, 'entry' => $entry);
175 call_hooks('directory_item', $arr);
183 $entries[] = $arr['entry'];
187 $tpl = get_markup_template('directory_header.tpl');
189 $o .= replace_macros($tpl, array(
190 '$search' => $search,
191 '$globaldir' => t('Global Directory'),
192 '$gdirpath' => $gdirpath,
193 '$desc' => t('Find on this site'),
194 '$contacts' => $entries,
195 '$finding' => t('Results for:'),
196 '$findterm' => (strlen($search) ? $search : ""),
197 '$title' => t('Site Directory'),
198 '$submit' => t('Find'),
199 '$paginate' => paginate($a),
204 info( t("No entries \x28some entries may be hidden\x29.") . EOL);