From: friendica Date: Thu, 27 Sep 2012 09:27:29 +0000 (-0700) Subject: beyond "page" and "pages" X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=6916fa594c31bedbfa3dc6608614cf37304b2780;p=friendica-addons.git beyond "page" and "pages" --- diff --git a/forumlist.tgz b/forumlist.tgz new file mode 100644 index 00000000..9288d147 Binary files /dev/null and b/forumlist.tgz differ diff --git a/forumlist/forumlist.css b/forumlist/forumlist.css new file mode 100644 index 00000000..4fbcdfd3 --- /dev/null +++ b/forumlist/forumlist.css @@ -0,0 +1,22 @@ + +#hide-forum-list { + opacity: 0.3; + filter:alpha(opacity=30); +} + +#hide-forum-list:hover { + opacity: 1.0; + filter:alpha(opacity=100); +} + + +#forumlist-settings-label, #forumlist-random-label, #forumlist-profile-label { + float: left; + width: 200px; + margin-bottom: 25px; +} + +#forumlist-max-forumlists, #forumlist-random, #forumlist-profile { + float: left; +} + diff --git a/forumlist/forumlist.php b/forumlist/forumlist.php new file mode 100644 index 00000000..d570a60c --- /dev/null +++ b/forumlist/forumlist.php @@ -0,0 +1,167 @@ + + * 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 .= '
'; + +} + +