4 * @file include/forums.php
5 * @brief functions related to forum functionality *
10 * @brief function to list all forums a user is connected with
12 * @param int $uid of the profile owner
13 * @param boolean $showhidden
14 * show frorums which are not hidden
15 * @param boolean $lastitem
17 * @param boolean $showprivate
22 * 'name' => forum name
23 * 'id' => number of the key from the array
24 * 'micro' => contact photo in format micro
26 function get_forumlist($uid, $showhidden = true, $lastitem, $showprivate = false) {
30 $order = (($showhidden) ? '' : " AND `hidden` = 0 ");
31 $order .= (($lastitem) ? ' ORDER BY `last-item` ASC ' : ' ORDER BY `name` ASC ');
32 $select = "`forum` = 1";
34 $select = "( `forum` = 1 OR `prv` = 1 )";
37 $contacts = q("SELECT `contact`.`id`, `contact`.`url`, `contact`.`name`, `contact`.`micro` FROM contact
38 WHERE `network`= 'dfrn' AND $select AND `uid` = %d
39 AND `blocked` = 0 AND `hidden` = 0 AND `pending` = 0 AND `archive` = 0
44 foreach($contacts as $contact) {
46 'url' => $contact['url'],
47 'name' => $contact['name'],
48 'id' => $contact['id'],
49 'micro' => $contact['micro'],
57 * @brief forumlist widget
59 * Sidebar widget to show subcribed friendica forums. If activated
60 * in the settings, it appears at the notwork page sidebar
65 function widget_forumlist($a) {
67 if(! intval(feature_enabled(local_user(),'forumlist')))
72 //sort by last updated item
75 $contacts = get_forumlist($a->user['uid'],true,$lastitem, true);
76 $total = count($contacts);
79 if(count($contacts)) {
83 foreach($contacts as $contact) {
86 'url' => $a->get_baseurl() . '/network?f=&cid=' . $contact['id'],
87 'external_url' => $a->get_baseurl() . '/redir/' . $contact['id'],
88 'name' => $contact['name'],
89 'micro' => proxy_url($contact['micro'], false, PROXY_SIZE_MICRO),
95 $tpl = get_markup_template('widget_forumlist.tpl');
97 $o .= replace_macros($tpl,array(
98 '$title' => t("Forums"),
99 '$forums' => $entries,
100 '$link_desc' => t('External link to forum'),
102 '$visible_forums' => $visible_forums,
103 '$showmore' => t('show more'),
111 * @brief format forumlist as contact block
113 * This function is used to show the forumlist in
114 * the advanced profile.
120 function forumlist_profile_advanced($uid) {
122 $profile = intval(feature_enabled($uid,'forumlist_profile'));
128 // place holder in case somebody wants configurability
131 //don't sort by last updated item
134 $contacts = get_forumlist($uid,false,$lastitem,false);
138 foreach($contacts as $contact) {
139 $forumlist .= micropro($contact,false,'forumlist-profile-advanced');
141 if($total_shown == $show_total)
145 if(count($contacts) > 0)