4 * Description: This addon is now deprecated. Administrators should switch to forumlist instead. Developers should also add any functionality to forumlist instead of here.
6 * Author: Mike Macgirvin <mike@macgirvin.com>
7 * based on pages plugin by
8 * Author: Michael Vogel <ike@piratenpartei.de>
13 function page_install() {
14 register_hook('network_mod_init', 'addon/page/page.php', 'page_network_mod_init');
15 register_hook('plugin_settings', 'addon/page/page.php', 'page_plugin_settings');
16 register_hook('plugin_settings_post', 'addon/page/page.php', 'page_plugin_settings_post');
17 register_hook('profile_advanced', 'addon/page/page.php', 'page_profile_advanced');
21 function page_uninstall() {
22 unregister_hook('network_mod_init', 'addon/page/page.php', 'page_network_mod_init');
23 unregister_hook('plugin_settings', 'addon/page/page.php', 'page_plugin_settings');
24 unregister_hook('plugin_settings_post', 'addon/page/page.php', 'page_plugin_settings_post');
25 unregister_hook('profile_advanced', 'addon/page/page.php', 'page_profile_advanced');
27 // remove only - obsolete
28 unregister_hook('page_end', 'addon/page/page.php', 'page_page_end');
32 function page_getpage($uid,$showhidden = true,$randomise = false) {
37 $order = (($showhidden) ? '' : " and hidden = 0 ");
38 $order .= (($randomise) ? ' order by rand() ' : ' order by name asc ');
40 $contacts = q("SELECT `id`, `url`, `name`, `micro` FROM `contact`
41 WHERE `network`= 'dfrn' AND `forum` = 1 AND `uid` = %d
42 and blocked = 0 and hidden = 0 and pending = 0 and archive = 0
49 // Look if the profile is a community page
50 foreach($contacts as $contact) {
51 $page[] = array("url"=>$contact["url"], "name"=>$contact["name"], "id"=>$contact["id"], "micro"=>$contact['micro']);
56 function page_page_end($a,&$b) {
57 // Only move on if if it's the "network" module and there is a logged on user
58 if (($a->module != "network") OR ($a->user['uid'] == 0))
61 $page = '<div id="page-sidebar" class="widget">
62 <div class="title tool">
63 <h3>'.t("Forums").'</h3></div>
64 <div id="sidebar-page-list"><ul>';
67 $contacts = page_getpage($a->user['uid']);
72 foreach($contacts as $contact) {
73 $page .= '<li style="list-style-type: none;" class="tool"><img height="20" width="20" src="' . $contact['micro'] .'" alt="' . $contact['url'] . '" /> <a href="'.$a->get_baseurl().'/redir/'.$contact["id"].'" title="' . $contact['url'] . '" class="label sparkle" target="_blank">'.
74 $contact["name"]."</a></li>";
76 if($total_shown == 6) {
78 $page .= '</ul><div id="hide-comments-page-widget" class="fakelink" onclick="showHideComments(\'page-widget\');" >' . t('show more')
79 . '</div><div id="collapsed-comments-page-widget" style="display: none;" ><ul>';
84 $page .= "</ul></div></div>";
85 if (sizeof($contacts) > 0)
86 $a->page['aside'] = $page . $a->page['aside'];
89 function page_network_mod_init($a,$b) {
91 $page = '<div id="page-sidebar" class="widget">
92 <div class="title tool">
93 <h3>'.t("Forums").'</h3></div>
94 <div id="sidebar-page-list"><ul>';
96 $show_total = intval(get_pconfig(local_user(),'page','max_pages'));
97 if($show_total === false)
99 $randomise = intval(get_pconfig(local_user(),'page','randomise'));
101 $contacts = page_getpage($a->user['uid'],true,$randomise);
106 foreach($contacts as $contact) {
107 $page .= '<li style="list-style-type: none;" class="tool"><img height="20" width="20" src="' . $contact['micro'] .'" alt="' . $contact['url'] . '" /> <a href="'.$a->get_baseurl().'/redir/'.$contact["id"].'" title="' . $contact['url'] . '" class="label sparkle" target="_blank">'.
108 $contact["name"]."</a></li>";
110 if(($show_total) && ($total_shown == $show_total)) {
112 $page .= '</ul><div id="hide-comments-page-widget" class="fakelink" onclick="showHideComments(\'page-widget\');" >' . t('show more')
113 . '</div><div id="collapsed-comments-page-widget" style="display: none;" ><ul>';
118 $page .= "</ul></div></div>";
119 if (sizeof($contacts) > 0)
120 $a->page['aside'] = $page . $a->page['aside'];
124 function page_profile_advanced($a,&$b) {
126 $profile = intval(get_pconfig($a->profile['profile_uid'],'page','show_on_profile'));
130 $page = '<div id="page-profile">
131 <div class="title">'.t("Forums:").'</div>
132 <div id="profile-page-list">';
134 // place holder in case somebody wants configurability
139 $contacts = page_getpage($a->user['uid'],false,$randomise);
144 foreach($contacts as $contact) {
145 $page .= micropro($contact,false,'page-profile-advanced');
147 if($total_shown == $show_total)
150 $page .= '</div></div><div class="clear"></div>';
152 if(count($contacts) > 0)
159 function page_plugin_settings_post($a,$post) {
160 if(! local_user() || (! x($_POST,'page-settings-submit')))
163 set_pconfig(local_user(),'page','max_pages',intval($_POST['page_max_pages']));
164 set_pconfig(local_user(),'page','randomise',intval($_POST['page_random']));
165 set_pconfig(local_user(),'page','show_on_profile',intval($_POST['page_profile']));
167 info( t('Page settings updated.') . EOL);
171 function page_plugin_settings(&$a,&$s) {
176 /* Add our stylesheet to the page so we can make our settings look nice */
178 $a->page['htmlhead'] .= '<link rel="stylesheet" type="text/css" href="' . $a->get_baseurl() . '/addon/page/page.css' . '" media="all" />' . "\r\n";
180 /* Get the current state of our config variable */
182 $max_pages = get_pconfig(local_user(),'page','max_pages');
183 if($max_pages === false)
186 $randomise = intval(get_pconfig(local_user(),'page','randomise'));
187 $randomise_checked = (($randomise) ? ' checked="checked" ' : '');
189 $profile = intval(get_pconfig(local_user(),'page','show_on_profile'));
190 $profile_checked = (($profile) ? ' checked="checked" ' : '');
193 /* Add some HTML to the existing form */
195 $s .= '<div class="settings-block">';
196 $s .= '<h3>' . t('Page Settings') . '</h3>';
197 $s .= '<div id="page-settings-wrapper">';
198 $s .= '<label id="page-settings-label" for="page-max-pages">' . t('How many forums to display on sidebar without paging') . '</label>';
199 $s .= '<input id="page-max-pages" type="text" name="page_max_pages" value="' . intval($max_pages) . '" ' . '/>';
200 $s .= '<div class="clear"></div>';
201 $s .= '<label id="page-random-label" for="page-random">' . t('Randomise Page/Forum list') . '</label>';
202 $s .= '<input id="page-random" type="checkbox" name="page_random" value="1" ' . $randomise_checked . '/>';
203 $s .= '<div class="clear"></div>';
204 $s .= '<label id="page-profile-label" for="page-profile">' . t('Show pages/forums on profile page') . '</label>';
205 $s .= '<input id="page-profile" type="checkbox" name="page_profile" value="1" ' . $profile_checked . '/>';
206 $s .= '<div class="clear"></div>';
210 /* provide a submit button */
212 $s .= '<div class="settings-submit-wrapper" ><input type="submit" name="page-settings-submit" class="settings-submit" value="' . t('Save Settings') . '" /></div></div>';