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']);
19 function directory_post(&$a) {
20 if(x($_POST,'search'))
21 $a->data['search'] = $_POST['search'];
26 function directory_content(&$a) {
28 if((get_config('system','block_public')) && (! local_user()) && (! remote_user())) {
29 notice( t('Public access denied.') . EOL);
34 nav_set_selected('directory');
36 if(x($a->data,'search'))
37 $search = notags(trim($a->data['search']));
39 $search = ((x($_GET,'search')) ? notags(trim(rawurldecode($_GET['search']))) : '');
41 $tpl = get_markup_template('directory_header.tpl');
44 $gdirpath = dirname(get_config('system','directory_submit_url'));
45 if(strlen($gdirpath)) {
46 $globaldir = '<ul><li><div id="global-directory-link"><a href="'
47 . zrl($gdirpath,true) . '">' . t('Global Directory') . '</a></div></li></ul>';
52 $o .= replace_macros($tpl, array(
54 '$globaldir' => $globaldir,
55 '$desc' => t('Find on this site'),
57 '$finding' => (strlen($search) ? '<h4>' . t('Finding: ') . "'" . $search . "'" . '</h4>' : ""),
58 '$sitedir' => t('Site Directory'),
59 '$submit' => t('Find')
63 $search = dbesc($search);
64 $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) " : "");
66 $publish = ((get_config('system','publish_all')) ? '' : " AND `publish` = 1 " );
69 $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 ");
71 $a->set_pager_total($r[0]['total']);
73 $order = " ORDER BY `name` ASC ";
76 $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 ",
77 intval($a->pager['start']),
78 intval($a->pager['itemspage'])
82 if(in_array('small', $a->argv))
90 $profile_link = $a->get_baseurl() . '/profile/' . ((strlen($rr['nickname'])) ? $rr['nickname'] : $rr['profile_uid']);
92 $pdesc = (($rr['pdesc']) ? $rr['pdesc'] . '<br />' : '');
95 if(strlen($rr['locality']))
96 $details .= $rr['locality'];
97 if(strlen($rr['region'])) {
98 if(strlen($rr['locality']))
100 $details .= $rr['region'];
102 if(strlen($rr['country-name'])) {
105 $details .= $rr['country-name'];
107 if(strlen($rr['dob'])) {
108 if(($years = age($rr['dob'],$rr['timezone'],'')) != 0)
109 $details .= '<br />' . t('Age: ') . $years ;
111 if(strlen($rr['gender']))
112 $details .= '<br />' . t('Gender: ') . $rr['gender'];
114 if($rr['page-flags'] == PAGE_NORMAL)
115 $page_type = "Personal Profile";
116 if($rr['page-flags'] == PAGE_SOAPBOX)
117 $page_type = "Fan Page";
118 if($rr['page-flags'] == PAGE_COMMUNITY)
119 $page_type = "Community Forum";
120 if($rr['page-flags'] == PAGE_FREELOVE)
121 $page_type = "Open Forum";
122 if($rr['page-flags'] == PAGE_PRVGROUP)
123 $page_type = "Private Group";
127 if((x($profile,'address') == 1)
128 || (x($profile,'locality') == 1)
129 || (x($profile,'region') == 1)
130 || (x($profile,'postal-code') == 1)
131 || (x($profile,'country-name') == 1))
132 $location = t('Location:');
134 $gender = ((x($profile,'gender') == 1) ? t('Gender:') : False);
136 $marital = ((x($profile,'marital') == 1) ? t('Status:') : False);
138 $homepage = ((x($profile,'homepage') == 1) ? t('Homepage:') : False);
140 $about = ((x($profile,'about') == 1) ? t('About:') : False);
142 $tpl = get_markup_template('directory_item.tpl');
144 $entry = replace_macros($tpl,array(
146 '$profile-link' => $profile_link,
147 '$photo' => $a->get_cached_avatar_image($rr[$photo]),
148 '$alt-text' => $rr['name'],
149 '$name' => $rr['name'],
150 '$details' => $pdesc . $details,
151 '$page-type' => $page_type,
152 '$profile' => $profile,
153 '$location' => template_escape($location),
154 '$gender' => $gender,
156 '$marital' => $marital,
157 '$homepage' => $homepage,
162 $arr = array('contact' => $rr, 'entry' => $entry);
164 call_hooks('directory_item', $arr);
173 $o .= "<div class=\"directory-end\" ></div>\r\n";
178 info( t("No entries \x28some entries may be hidden\x29.") . EOL);