From 6916fa594c31bedbfa3dc6608614cf37304b2780 Mon Sep 17 00:00:00 2001 From: friendica Date: Thu, 27 Sep 2012 02:27:29 -0700 Subject: [PATCH] beyond "page" and "pages" --- forumlist.tgz | Bin 0 -> 2175 bytes forumlist/forumlist.css | 22 ++++++ forumlist/forumlist.php | 167 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 189 insertions(+) create mode 100644 forumlist.tgz create mode 100644 forumlist/forumlist.css create mode 100644 forumlist/forumlist.php diff --git a/forumlist.tgz b/forumlist.tgz new file mode 100644 index 0000000000000000000000000000000000000000..9288d147faf520076bee4d789e650b71e540bb14 GIT binary patch literal 2175 zcmV-_2!Qt=iwFSd8)Q%b1MOK^bK6D|)+_lddJ(MwIutL7mRAz#xDsXaAUj*JEBhd; zs39;UrwCxMgMp4D{_op8I0%5Gjw;#N)M}(+5p(q2U-y7Bsgl4KvF`4CvC+eEcsSe{ z3=a+mgM*#k@YUeeLEp@0W2Zmp?e}~A!Tur6_Xo5chF?yk)ktE^6u?fv+__L!BHXes znh#&~U%!6+HDvmVV^;XT_||db_(^%(=l|isAou_9aIla59}W-pccAyAQfwLj=l*Yg zvk)HNGtS>5@5ArShK!gi^z9M!I{U}X#!UE{t0U$|3+7~Nqy1j%xcRxccK&D~uehpE z>34eDsPuaondUb|{O!eDYZ1=lJ)cdv--gnXVxcF44GWQy$bhFS#C_&VrjNkqGmXrz zg{K!sFzEH78+;6ynu~C6Dz%mYP7i7Jb47@N-Ru=l@dhC_v0r11H2-W5-#s?vf3%36 zl*irq-`{`rs#nVY1C#&5-gEwcjdAh@z1{4-eA$GT@SX+y2!5nMIKx1osULXkDiLWR z!z1{xkk>I7l#nxslPRrDxd*Ncf+WO*1`|aw$PhxVuccZ-jQB8RiirKnRcr|LJAHb7 zo9Km9NAON8IlRjq04D)He^)r9gVe{gead3wg`^`k=P^Wnf=LY1+bSt{!4Ls{m2><& zAwrQ*O!F{eN^{ZiIMKrYZnHT{LYFjyBK9XD#CY(1r$wo(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mx>$Eb~gBv~QB{Lx(50&?h%wlB@?5WyzXNwiJ~+?NIqiWX%vogOXW--tCs&-sV9{ zVDLDD{d>XlcplH=c|4Ej@jU+e + * based on pages plugin by + * Author: Michael Vogel + * + */ + +function forumlist_install() { + register_hook('network_mod_init', 'addon/forumlist/forumlist.php', 'forumlist_network_mod_init'); + register_hook('plugin_settings', 'addon/forumlist/forumlist.php', 'forumlist_plugin_settings'); + register_hook('plugin_settings_post', 'addon/forumlist/forumlist.php', 'forumlist_plugin_settings_post'); + register_hook('profile_advanced', 'addon/forumlist/forumlist.php', 'forumlist_profile_advanced'); + +} + +function forumlist_uninstall() { + unregister_hook('network_mod_init', 'addon/forumlist/forumlist.php', 'forumlist_network_mod_init'); + unregister_hook('plugin_settings', 'addon/forumlist/forumlist.php', 'forumlist_plugin_settings'); + unregister_hook('plugin_settings_post', 'addon/forumlist/forumlist.php', 'forumlist_plugin_settings_post'); + unregister_hook('profile_advanced', 'addon/forumlist/forumlist.php', 'forumlist_profile_advanced'); + +} + + +function forumlist_getpage($uid,$showhidden = true,$randomise = false) { + + + $forumlist = array(); + + $order = (($showhidden) ? '' : " and hidden = 0 "); + $order .= (($randomise) ? ' order by rand() ' : ' order by name asc '); + + $contacts = q("SELECT `contact`.`id`, `contact`.`url`, `contact`.`name`, `contact`.`micro` from contact + WHERE `network`= 'dfrn' AND `forum` = 1 AND `uid` = %d + $order ", + intval($uid) + ); + + // Look if the profile is a community page + foreach($contacts as $contact) { + $forumlist[] = array("url"=>$contact["url"], "name"=>$contact["name"], "id"=>$contact["id"], "micro"=>$contact['micro']); + } + return($forumlist); +} + +function forumlist_network_mod_init($a,$b) { + $a->page['htmlhead'] .= '' . "\r\n"; + + $forumlist = '
+
+

'.t("Forums").'

'; + + $forumlist .= '' + . '
"; + if (sizeof($contacts) > 0) + $a->page['aside'] = $forumlist . $a->page['aside']; +} + + +function forumlist_profile_advanced($a,&$b) { + $a->page['htmlhead'] .= '' . "\r\n"; + + $profile = intval(get_pconfig($a->profile['profile_uid'],'forumlist','show_on_profile')); + if(! $profile) + return; + + $forumlist = '
+
'.t("Forums:").'
+
'; + + // place holder in case somebody wants configurability + $show_total = 9999; + + $randomise = true; + + $contacts = forumlist_getforumlist($a->user['uid'],false,$randomise); + + $total_shown = 0; + $more = false; + + foreach($contacts as $contact) { + $forumlist .= micropro($contact,false,'forumlist-profile-advanced'); + $total_shown ++; + if($total_shown == $show_total) + break; + } + $forumlist .= '
'; + + if(count($contacts) > 0) + $b .= $forumlist; + +} + + + +function forumlist_plugin_settings_post($a,$post) { + if(! local_user() || (! x($_POST,'forumlist-settings-submit'))) + return; + +// set_pconfig(local_user(),'forumlist','max_forumlists',intval($_POST['forumlist_max_forumlists'])); + set_pconfig(local_user(),'forumlist','randomise',intval($_POST['forumlist_random'])); + set_pconfig(local_user(),'forumlist','show_on_profile',intval($_POST['forumlist_profile'])); + + info( t('Forumlist settings updated.') . EOL); +} + + +function forumlist_plugin_settings(&$a,&$s) { + + if(! local_user()) + return; + + /* Add our stylesheet to the forumlist so we can make our settings look nice */ + + $a->page['htmlhead'] .= '' . "\r\n"; + + /* Get the current state of our config variable */ + + $randomise = intval(get_pconfig(local_user(),'forumlist','randomise')); + $randomise_checked = (($randomise) ? ' checked="checked" ' : ''); + + $profile = intval(get_pconfig(local_user(),'forumlist','show_on_profile')); + $profile_checked = (($profile) ? ' checked="checked" ' : ''); + + + /* Add some HTML to the existing form */ + + $s .= '
'; + $s .= '

' . t('Forumlist Settings') . '

'; + $s .= '
'; + $s .= ''; + $s .= ''; + $s .= '
'; + $s .= ''; + $s .= ''; + $s .= '
'; + + $s .= '
'; + + /* provide a submit button */ + + $s .= '
'; + +} + +