3 * Name: Forum Directory
4 * Description: Add a directory of forums hosted on your server, with verbose descriptions.
6 * Author: Thomas Willingham <https://kakste.com/profile/beardyunixer>
9 function forumdirectory_install() {
10 register_hook('app_menu', 'addon/forumdirectory/forumdirectory.php', 'forumdirectory_app_menu');
13 function forumdirectory_uninstall() {
14 unregister_hook('app_menu', 'addon/forumdirectory/forumdirectory.php', 'forumdirectory_app_menu');
17 function forumdirectory_module() {
21 function forumdirectory_init(&$a) {
22 $a->page['htmlhead'] .= '<link rel="stylesheet" type="text/css" href="'.$a->get_baseurl().'/addon/forumdirectory/forumdirectory.css" media="all" />';
24 $a->set_pager_itemspage(60);
27 require_once('include/contact_widgets.php');
29 $a->page['aside'] .= findpeople_widget();
33 unset($_SESSION['theme']);
39 function forumdirectory_post(&$a) {
40 if(x($_POST,'search'))
41 $a->data['search'] = $_POST['search'];
46 function forumdirectory_content(&$a) {
48 if((get_config('system','block_public')) && (! local_user()) && (! remote_user())) {
49 notice( t('Public access denied.') . EOL);
54 nav_set_selected('directory');
56 if(x($a->data,'search'))
57 $search = notags(trim($a->data['search']));
59 $search = ((x($_GET,'search')) ? notags(trim(rawurldecode($_GET['search']))) : '');
61 $tpl = get_markup_template('directory_header.tpl');
64 $gdirpath = dirname(get_config('system','directory_submit_url'));
65 if(strlen($gdirpath)) {
66 $globaldir = '<ul><li><div id="global-directory-link"><a href="'
67 . zrl($gdirpath,true) . '">' . t('Global Directory') . '</a></div></li></ul>';
72 $o .= replace_macros($tpl, array(
74 '$globaldir' => $globaldir,
75 '$desc' => t('Find on this site'),
77 '$finding' => (strlen($search) ? '<h4>' . t('Finding: ') . "'" . $search . "'" . '</h4>' : ""),
78 '$sitedir' => t('Site Directory'),
79 '$submit' => t('Find')
83 $search = dbesc($search);
84 $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) " : "");
86 $publish = ((get_config('system','publish_all')) ? '' : " AND `publish` = 1 " );
89 $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 AND `page-flags` = 2 $sql_extra ");
91 $a->set_pager_total($r[0]['total']);
93 $order = " ORDER BY `name` ASC ";
96 $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 AND `page-flags` = 2 $sql_extra $order LIMIT %d , %d ",
97 intval($a->pager['start']),
98 intval($a->pager['itemspage'])
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 = file_get_contents( dirname(__file__).'/forumdirectory_item.tpl');
164 $entry = replace_macros($tpl,array(
166 '$profile-link' => $profile_link,
167 '$photo' => $a->get_cached_avatar_image($rr[$photo]),
168 '$alt-text' => $rr['name'],
169 '$name' => $rr['name'],
170 '$details' => $pdesc . $details,
171 '$page-type' => $page_type,
172 '$profile' => $profile,
173 '$location' => template_escape($location),
174 '$gender' => $gender,
176 '$marital' => $marital,
177 '$homepage' => $homepage,
182 $arr = array('contact' => $rr, 'entry' => $entry);
184 call_hooks('directory_item', $arr);
193 $o .= "<div class=\"directory-end\" ></div>\r\n";
198 info( t("No entries \x28some entries may be hidden\x29.") . EOL);