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 require_once("mod/proxy.php");
32 if((get_config('system','block_public')) && (! local_user()) && (! remote_user()) ||
33 (get_config('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']))) : '');
46 $tpl = get_markup_template('directory_header.tpl');
49 $gdirpath = dirname(get_config('system','directory_submit_url'));
50 if(strlen($gdirpath)) {
51 $globaldir = '<ul><li><div id="global-directory-link"><a href="'
52 . zrl($gdirpath,true) . '">' . t('Global Directory') . '</a></div></li></ul>';
57 $o .= replace_macros($tpl, array(
59 '$globaldir' => $globaldir,
60 '$desc' => t('Find on this site'),
62 '$finding' => (strlen($search) ? '<h4>' . t('Finding: ') . "'" . $search . "'" . '</h4>' : ""),
63 '$sitedir' => t('Site Directory'),
64 '$submit' => t('Find')
68 $search = dbesc($search);
69 $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) " : "");
71 $publish = ((get_config('system','publish_all')) ? '' : " AND `publish` = 1 " );
74 $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 ");
76 $a->set_pager_total($r[0]['total']);
78 $order = " ORDER BY `name` ASC ";
81 $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 ",
82 intval($a->pager['start']),
83 intval($a->pager['itemspage'])
87 if(in_array('small', $a->argv))
95 $profile_link = $a->get_baseurl() . '/profile/' . ((strlen($rr['nickname'])) ? $rr['nickname'] : $rr['profile_uid']);
97 $pdesc = (($rr['pdesc']) ? $rr['pdesc'] . '<br />' : '');
100 if(strlen($rr['locality']))
101 $details .= $rr['locality'];
102 if(strlen($rr['region'])) {
103 if(strlen($rr['locality']))
105 $details .= $rr['region'];
107 if(strlen($rr['country-name'])) {
110 $details .= $rr['country-name'];
112 if(strlen($rr['dob'])) {
113 if(($years = age($rr['dob'],$rr['timezone'],'')) != 0)
114 $details .= '<br />' . t('Age: ') . $years ;
116 if(strlen($rr['gender']))
117 $details .= '<br />' . t('Gender: ') . $rr['gender'];
119 if($rr['page-flags'] == PAGE_NORMAL)
120 $page_type = "Personal Profile";
121 if($rr['page-flags'] == PAGE_SOAPBOX)
122 $page_type = "Fan Page";
123 if($rr['page-flags'] == PAGE_COMMUNITY)
124 $page_type = "Community Forum";
125 if($rr['page-flags'] == PAGE_FREELOVE)
126 $page_type = "Open Forum";
127 if($rr['page-flags'] == PAGE_PRVGROUP)
128 $page_type = "Private Group";
132 if((x($profile,'address') == 1)
133 || (x($profile,'locality') == 1)
134 || (x($profile,'region') == 1)
135 || (x($profile,'postal-code') == 1)
136 || (x($profile,'country-name') == 1))
137 $location = t('Location:');
139 $gender = ((x($profile,'gender') == 1) ? t('Gender:') : False);
141 $marital = ((x($profile,'marital') == 1) ? t('Status:') : False);
143 $homepage = ((x($profile,'homepage') == 1) ? t('Homepage:') : False);
145 $about = ((x($profile,'about') == 1) ? t('About:') : False);
147 $tpl = get_markup_template('directory_item.tpl');
149 if($a->theme['template_engine'] === 'internal') {
150 $location_e = template_escape($location);
153 $location_e = $location;
156 $entry = replace_macros($tpl,array(
158 '$profile_link' => $profile_link,
159 '$photo' => proxy_url($a->get_cached_avatar_image($rr[$photo])),
160 '$alt_text' => $rr['name'],
161 '$name' => $rr['name'],
162 '$details' => $pdesc . $details,
163 '$page_type' => $page_type,
164 '$profile' => $profile,
165 '$location' => $location_e,
166 '$gender' => $gender,
168 '$marital' => $marital,
169 '$homepage' => $homepage,
174 $arr = array('contact' => $rr, 'entry' => $entry);
176 call_hooks('directory_item', $arr);
185 $o .= "<div class=\"directory-end\" ></div>\r\n";
190 info( t("No entries \x28some entries may be hidden\x29.") . EOL);