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) {
30 if((get_config('system','block_public')) && (! 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']))) : '');
43 $tpl = get_markup_template('directory_header.tpl');
46 $gdirpath = dirname(get_config('system','directory_submit_url'));
47 if(strlen($gdirpath)) {
48 $globaldir = '<ul><li><div id="global-directory-link"><a href="'
49 . zrl($gdirpath,true) . '">' . t('Global Directory') . '</a></div></li></ul>';
54 $o .= replace_macros($tpl, array(
56 '$globaldir' => $globaldir,
57 '$desc' => t('Find on this site'),
59 '$finding' => (strlen($search) ? '<h4>' . t('Finding: ') . "'" . $search . "'" . '</h4>' : ""),
60 '$sitedir' => t('Site Directory'),
61 '$submit' => t('Find')
65 $search = dbesc($search);
66 $sql_extra = ((strlen($search)) ? " AND MATCH (`profile`.`name`, `user`.`nickname`, `pdesc`, `locality`,`region`,`country-name`,`gender`,`marital`,`sexual`,`about`,`romance`,`work`,`education`,`pub_keywords`,`prv_keywords` ) AGAINST ('$search' IN BOOLEAN MODE) " : "");
68 $publish = ((get_config('system','publish_all')) ? '' : " AND `publish` = 1 " );
71 $r = 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 ");
73 $a->set_pager_total($r[0]['total']);
75 $order = " ORDER BY `name` ASC ";
78 $r = 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 %d , %d ",
79 intval($a->pager['start']),
80 intval($a->pager['itemspage'])
84 if(in_array('small', $a->argv))
92 $profile_link = $a->get_baseurl() . '/profile/' . ((strlen($rr['nickname'])) ? $rr['nickname'] : $rr['profile_uid']);
94 $pdesc = (($rr['pdesc']) ? $rr['pdesc'] . '<br />' : '');
97 if(strlen($rr['locality']))
98 $details .= $rr['locality'];
99 if(strlen($rr['region'])) {
100 if(strlen($rr['locality']))
102 $details .= $rr['region'];
104 if(strlen($rr['country-name'])) {
107 $details .= $rr['country-name'];
109 if(strlen($rr['dob'])) {
110 if(($years = age($rr['dob'],$rr['timezone'],'')) != 0)
111 $details .= '<br />' . t('Age: ') . $years ;
113 if(strlen($rr['gender']))
114 $details .= '<br />' . t('Gender: ') . $rr['gender'];
116 if($rr['page-flags'] == PAGE_NORMAL)
117 $page_type = "Personal Profile";
118 if($rr['page-flags'] == PAGE_SOAPBOX)
119 $page_type = "Fan Page";
120 if($rr['page-flags'] == PAGE_COMMUNITY)
121 $page_type = "Community Forum";
122 if($rr['page-flags'] == PAGE_FREELOVE)
123 $page_type = "Open Forum";
124 if($rr['page-flags'] == PAGE_PRVGROUP)
125 $page_type = "Private Group";
129 if((x($profile,'address') == 1)
130 || (x($profile,'locality') == 1)
131 || (x($profile,'region') == 1)
132 || (x($profile,'postal-code') == 1)
133 || (x($profile,'country-name') == 1))
134 $location = t('Location:');
136 $gender = ((x($profile,'gender') == 1) ? t('Gender:') : False);
138 $marital = ((x($profile,'marital') == 1) ? t('Status:') : False);
140 $homepage = ((x($profile,'homepage') == 1) ? t('Homepage:') : False);
142 $about = ((x($profile,'about') == 1) ? t('About:') : False);
144 $tpl = get_markup_template('directory_item.tpl');
146 $entry = replace_macros($tpl,array(
148 '$profile-link' => $profile_link,
149 '$photo' => $a->get_cached_avatar_image($rr[$photo]),
150 '$alt-text' => $rr['name'],
151 '$name' => $rr['name'],
152 '$details' => $pdesc . $details,
153 '$page-type' => $page_type,
154 '$profile' => $profile,
155 '$location' => template_escape($location),
156 '$gender' => $gender,
158 '$marital' => $marital,
159 '$homepage' => $homepage,
164 $arr = array('contact' => $rr, 'entry' => $entry);
166 call_hooks('directory_item', $arr);
175 $o .= "<div class=\"directory-end\" ></div>\r\n";
180 info( t("No entries \x28some entries may be hidden\x29.") . EOL);