3 function directory_init(&$a) {
4 $a->set_pager_itemspage(60);
7 require_once('include/contact_widgets.php');
9 $a->page['aside'] .= findpeople_widget();
13 unset($_SESSION['theme']);
14 unset($_SESSION['mobile-theme']);
21 function directory_post(&$a) {
22 if(x($_POST,'search'))
23 $a->data['search'] = $_POST['search'];
28 function directory_content(&$a) {
31 require_once("mod/proxy.php");
33 if((get_config('system','block_public')) && (! local_user()) && (! remote_user()) ||
34 (get_config('system','block_local_dir')) && (! local_user()) && (! remote_user())) {
35 notice( t('Public access denied.') . EOL);
40 nav_set_selected('directory');
42 if(x($a->data,'search'))
43 $search = notags(trim($a->data['search']));
45 $search = ((x($_GET,'search')) ? notags(trim(rawurldecode($_GET['search']))) : '');
47 $tpl = get_markup_template('directory_header.tpl');
50 $gdirpath = dirname(get_config('system','directory_submit_url'));
51 if(strlen($gdirpath)) {
52 $globaldir = '<ul><li><div id="global-directory-link"><a href="'
53 . zrl($gdirpath,true) . '">' . t('Global Directory') . '</a></div></li></ul>';
58 $o .= replace_macros($tpl, array(
60 '$globaldir' => $globaldir,
61 '$desc' => t('Find on this site'),
63 '$finding' => (strlen($search) ? '<h4>' . t('Finding: ') . "'" . $search . "'" . '</h4>' : ""),
64 '$sitedir' => t('Site Directory'),
65 '$submit' => t('Find')
69 $search = dbesc($search);
71 $sql_extra = " AND ((`profile`.`name` LIKE '%$search%') OR
72 (`user`.`nickname` LIKE '%$search%') OR
73 (`pdesc` LIKE '%$search%') OR
74 (`locality` LIKE '%$search%') OR
75 (`region` LIKE '%$search%') OR
76 (`country-name` LIKE '%$search%') OR
77 (`gender` LIKE '%$search%') OR
78 (`marital` LIKE '%$search%') OR
79 (`sexual` LIKE '%$search%') OR
80 (`about` LIKE '%$search%') OR
81 (`romance` LIKE '%$search%') OR
82 (`work` LIKE '%$search%') OR
83 (`education` LIKE '%$search%') OR
84 (`pub_keywords` LIKE '%$search%') OR
85 (`prv_keywords` LIKE '%$search%'))";
88 $publish = ((get_config('system','publish_all')) ? '' : " AND `publish` = 1 " );
91 $r = $db->q("SELECT COUNT(*) AS `total` FROM `profile` LEFT JOIN `user` ON `user`.`uid` = `profile`.`uid` WHERE `is-default` = 1 $publish AND `user`.`blocked` = 0 $sql_extra ");
93 $a->set_pager_total($r[0]['total']);
95 $order = " ORDER BY `name` ASC ";
97 $limit = intval($a->pager['start']).",".intval($a->pager['itemspage']);
99 $r = $db->q("SELECT `profile`.*, `profile`.`uid` AS `profile_uid`, `user`.`nickname`, `user`.`timezone` , `user`.`page-flags` FROM `profile` LEFT JOIN `user` ON `user`.`uid` = `profile`.`uid` WHERE `is-default` = 1 $publish AND `user`.`blocked` = 0 $sql_extra $order LIMIT ".$limit);
102 if(in_array('small', $a->argv))
110 $profile_link = $a->get_baseurl() . '/profile/' . ((strlen($rr['nickname'])) ? $rr['nickname'] : $rr['profile_uid']);
112 $pdesc = (($rr['pdesc']) ? $rr['pdesc'] . '<br />' : '');
115 if(strlen($rr['locality']))
116 $details .= $rr['locality'];
117 if(strlen($rr['region'])) {
118 if(strlen($rr['locality']))
120 $details .= $rr['region'];
122 if(strlen($rr['country-name'])) {
125 $details .= $rr['country-name'];
127 if(strlen($rr['dob'])) {
128 if(($years = age($rr['dob'],$rr['timezone'],'')) != 0)
129 $details .= '<br />' . t('Age: ') . $years ;
131 if(strlen($rr['gender']))
132 $details .= '<br />' . t('Gender: ') . $rr['gender'];
134 if($rr['page-flags'] == PAGE_NORMAL)
135 $page_type = "Personal Profile";
136 if($rr['page-flags'] == PAGE_SOAPBOX)
137 $page_type = "Fan Page";
138 if($rr['page-flags'] == PAGE_COMMUNITY)
139 $page_type = "Community Forum";
140 if($rr['page-flags'] == PAGE_FREELOVE)
141 $page_type = "Open Forum";
142 if($rr['page-flags'] == PAGE_PRVGROUP)
143 $page_type = "Private Group";
147 if((x($profile,'address') == 1)
148 || (x($profile,'locality') == 1)
149 || (x($profile,'region') == 1)
150 || (x($profile,'postal-code') == 1)
151 || (x($profile,'country-name') == 1))
152 $location = t('Location:');
154 $gender = ((x($profile,'gender') == 1) ? t('Gender:') : False);
156 $marital = ((x($profile,'marital') == 1) ? t('Status:') : False);
158 $homepage = ((x($profile,'homepage') == 1) ? t('Homepage:') : False);
160 $about = ((x($profile,'about') == 1) ? t('About:') : False);
162 $tpl = get_markup_template('directory_item.tpl');
164 if($a->theme['template_engine'] === 'internal') {
165 $location_e = template_escape($location);
168 $location_e = $location;
171 $entry = replace_macros($tpl,array(
173 '$profile_link' => $profile_link,
174 '$photo' => proxy_url($a->get_cached_avatar_image($rr[$photo])),
175 '$alt_text' => $rr['name'],
176 '$name' => $rr['name'],
177 '$details' => $pdesc . $details,
178 '$page_type' => $page_type,
179 '$profile' => $profile,
180 '$location' => $location_e,
181 '$gender' => $gender,
183 '$marital' => $marital,
184 '$homepage' => $homepage,
189 $arr = array('contact' => $rr, 'entry' => $entry);
191 call_hooks('directory_item', $arr);
200 $o .= "<div class=\"directory-end\" ></div>\r\n";
205 info( t("No entries \x28some entries may be hidden\x29.") . EOL);