2012-03-23 08:18:45 +00:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* Name: Page
|
2012-11-19 04:19:13 +00:00
|
|
|
* Description: This addon is now deprecated. Administrators should switch to forumlist instead. Developers should also add any functionality to forumlist instead of here.
|
2012-03-23 08:18:45 +00:00
|
|
|
* Version: 1.0
|
|
|
|
* Author: Mike Macgirvin <mike@macgirvin.com>
|
|
|
|
* based on pages plugin by
|
|
|
|
* Author: Michael Vogel <ike@piratenpartei.de>
|
2014-08-16 08:25:29 +00:00
|
|
|
* Status: Unsupported
|
2012-03-23 08:18:45 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
function page_install() {
|
2012-06-19 09:30:44 +00:00
|
|
|
register_hook('network_mod_init', 'addon/page/page.php', 'page_network_mod_init');
|
|
|
|
register_hook('plugin_settings', 'addon/page/page.php', 'page_plugin_settings');
|
|
|
|
register_hook('plugin_settings_post', 'addon/page/page.php', 'page_plugin_settings_post');
|
2012-06-30 08:28:10 +00:00
|
|
|
register_hook('profile_advanced', 'addon/page/page.php', 'page_profile_advanced');
|
2012-06-19 09:30:44 +00:00
|
|
|
|
2012-03-23 08:18:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function page_uninstall() {
|
2012-06-19 09:30:44 +00:00
|
|
|
unregister_hook('network_mod_init', 'addon/page/page.php', 'page_network_mod_init');
|
|
|
|
unregister_hook('plugin_settings', 'addon/page/page.php', 'page_plugin_settings');
|
|
|
|
unregister_hook('plugin_settings_post', 'addon/page/page.php', 'page_plugin_settings_post');
|
2012-06-30 08:28:10 +00:00
|
|
|
unregister_hook('profile_advanced', 'addon/page/page.php', 'page_profile_advanced');
|
2012-06-19 09:30:44 +00:00
|
|
|
|
|
|
|
// remove only - obsolete
|
2012-03-23 08:18:45 +00:00
|
|
|
unregister_hook('page_end', 'addon/page/page.php', 'page_page_end');
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-06-30 08:28:10 +00:00
|
|
|
function page_getpage($uid,$showhidden = true,$randomise = false) {
|
2012-03-23 08:18:45 +00:00
|
|
|
|
|
|
|
|
|
|
|
$pagelist = array();
|
|
|
|
|
2012-06-30 08:28:10 +00:00
|
|
|
$order = (($showhidden) ? '' : " and hidden = 0 ");
|
|
|
|
$order .= (($randomise) ? ' order by rand() ' : ' order by name asc ');
|
2012-06-19 10:27:51 +00:00
|
|
|
|
2012-06-30 08:28:10 +00:00
|
|
|
$contacts = q("SELECT `id`, `url`, `name`, `micro` FROM `contact`
|
2012-05-03 01:11:53 +00:00
|
|
|
WHERE `network`= 'dfrn' AND `forum` = 1 AND `uid` = %d
|
2012-10-04 01:25:46 +00:00
|
|
|
and blocked = 0 and hidden = 0 and pending = 0 and archive = 0
|
2012-06-19 10:39:30 +00:00
|
|
|
$order ",
|
2012-03-23 08:18:45 +00:00
|
|
|
intval($uid)
|
|
|
|
);
|
|
|
|
|
|
|
|
$page = array();
|
|
|
|
|
|
|
|
// Look if the profile is a community page
|
|
|
|
foreach($contacts as $contact) {
|
2012-03-23 08:44:24 +00:00
|
|
|
$page[] = array("url"=>$contact["url"], "name"=>$contact["name"], "id"=>$contact["id"], "micro"=>$contact['micro']);
|
2012-03-23 08:18:45 +00:00
|
|
|
}
|
|
|
|
return($page);
|
|
|
|
}
|
|
|
|
|
|
|
|
function page_page_end($a,&$b) {
|
|
|
|
// Only move on if if it's the "network" module and there is a logged on user
|
|
|
|
if (($a->module != "network") OR ($a->user['uid'] == 0))
|
|
|
|
return;
|
|
|
|
|
|
|
|
$page = '<div id="page-sidebar" class="widget">
|
|
|
|
<div class="title tool">
|
2012-03-30 12:35:55 +00:00
|
|
|
<h3>'.t("Forums").'</h3></div>
|
2012-03-23 08:18:45 +00:00
|
|
|
<div id="sidebar-page-list"><ul>';
|
|
|
|
|
2012-05-03 03:33:45 +00:00
|
|
|
|
2012-03-23 08:18:45 +00:00
|
|
|
$contacts = page_getpage($a->user['uid']);
|
|
|
|
|
2012-05-03 03:33:45 +00:00
|
|
|
$total_shown = 0;
|
|
|
|
$more = false;
|
|
|
|
|
2012-03-23 08:18:45 +00:00
|
|
|
foreach($contacts as $contact) {
|
2014-02-11 22:30:28 +00:00
|
|
|
$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">'.
|
2012-03-23 08:18:45 +00:00
|
|
|
$contact["name"]."</a></li>";
|
2012-05-03 03:33:45 +00:00
|
|
|
$total_shown ++;
|
|
|
|
if($total_shown == 6) {
|
|
|
|
$more = true;
|
|
|
|
$page .= '</ul><div id="hide-comments-page-widget" class="fakelink" onclick="showHideComments(\'page-widget\');" >' . t('show more')
|
|
|
|
. '</div><div id="collapsed-comments-page-widget" style="display: none;" ><ul>';
|
|
|
|
}
|
2012-03-23 08:18:45 +00:00
|
|
|
}
|
2012-05-03 03:33:45 +00:00
|
|
|
if($more)
|
|
|
|
$page .= '</div>';
|
2012-03-23 08:18:45 +00:00
|
|
|
$page .= "</ul></div></div>";
|
|
|
|
if (sizeof($contacts) > 0)
|
|
|
|
$a->page['aside'] = $page . $a->page['aside'];
|
|
|
|
}
|
2012-05-03 01:11:53 +00:00
|
|
|
|
2012-06-19 09:30:44 +00:00
|
|
|
function page_network_mod_init($a,$b) {
|
|
|
|
|
|
|
|
$page = '<div id="page-sidebar" class="widget">
|
|
|
|
<div class="title tool">
|
|
|
|
<h3>'.t("Forums").'</h3></div>
|
|
|
|
<div id="sidebar-page-list"><ul>';
|
|
|
|
|
|
|
|
$show_total = intval(get_pconfig(local_user(),'page','max_pages'));
|
|
|
|
if($show_total === false)
|
|
|
|
$show_total = 6;
|
2012-06-19 10:27:51 +00:00
|
|
|
$randomise = intval(get_pconfig(local_user(),'page','randomise'));
|
|
|
|
|
2012-06-30 08:28:10 +00:00
|
|
|
$contacts = page_getpage($a->user['uid'],true,$randomise);
|
2012-06-19 09:30:44 +00:00
|
|
|
|
|
|
|
$total_shown = 0;
|
|
|
|
$more = false;
|
|
|
|
|
|
|
|
foreach($contacts as $contact) {
|
2014-02-11 22:30:28 +00:00
|
|
|
$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">'.
|
2012-06-19 09:30:44 +00:00
|
|
|
$contact["name"]."</a></li>";
|
|
|
|
$total_shown ++;
|
|
|
|
if(($show_total) && ($total_shown == $show_total)) {
|
|
|
|
$more = true;
|
|
|
|
$page .= '</ul><div id="hide-comments-page-widget" class="fakelink" onclick="showHideComments(\'page-widget\');" >' . t('show more')
|
|
|
|
. '</div><div id="collapsed-comments-page-widget" style="display: none;" ><ul>';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if($more)
|
|
|
|
$page .= '</div>';
|
|
|
|
$page .= "</ul></div></div>";
|
|
|
|
if (sizeof($contacts) > 0)
|
|
|
|
$a->page['aside'] = $page . $a->page['aside'];
|
|
|
|
}
|
|
|
|
|
2012-06-30 08:28:10 +00:00
|
|
|
|
|
|
|
function page_profile_advanced($a,&$b) {
|
|
|
|
|
2012-06-30 09:01:20 +00:00
|
|
|
$profile = intval(get_pconfig($a->profile['profile_uid'],'page','show_on_profile'));
|
|
|
|
if(! $profile)
|
|
|
|
return;
|
|
|
|
|
2012-06-30 08:28:10 +00:00
|
|
|
$page = '<div id="page-profile">
|
|
|
|
<div class="title">'.t("Forums:").'</div>
|
|
|
|
<div id="profile-page-list">';
|
|
|
|
|
2012-07-01 00:37:05 +00:00
|
|
|
// place holder in case somebody wants configurability
|
|
|
|
$show_total = 9999;
|
|
|
|
|
2012-06-30 08:28:10 +00:00
|
|
|
$randomise = true;
|
|
|
|
|
|
|
|
$contacts = page_getpage($a->user['uid'],false,$randomise);
|
|
|
|
|
|
|
|
$total_shown = 0;
|
|
|
|
$more = false;
|
|
|
|
|
|
|
|
foreach($contacts as $contact) {
|
|
|
|
$page .= micropro($contact,false,'page-profile-advanced');
|
|
|
|
$total_shown ++;
|
2012-06-30 08:35:45 +00:00
|
|
|
if($total_shown == $show_total)
|
|
|
|
break;
|
2012-06-30 08:28:10 +00:00
|
|
|
}
|
|
|
|
$page .= '</div></div><div class="clear"></div>';
|
|
|
|
|
|
|
|
if(count($contacts) > 0)
|
|
|
|
$b .= $page;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-06-19 09:30:44 +00:00
|
|
|
function page_plugin_settings_post($a,$post) {
|
|
|
|
if(! local_user() || (! x($_POST,'page-settings-submit')))
|
|
|
|
return;
|
|
|
|
|
|
|
|
set_pconfig(local_user(),'page','max_pages',intval($_POST['page_max_pages']));
|
2012-06-19 10:27:51 +00:00
|
|
|
set_pconfig(local_user(),'page','randomise',intval($_POST['page_random']));
|
2012-06-30 09:01:20 +00:00
|
|
|
set_pconfig(local_user(),'page','show_on_profile',intval($_POST['page_profile']));
|
2012-06-19 10:27:51 +00:00
|
|
|
|
2012-06-19 09:30:44 +00:00
|
|
|
info( t('Page settings updated.') . EOL);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function page_plugin_settings(&$a,&$s) {
|
|
|
|
|
|
|
|
if(! local_user())
|
|
|
|
return;
|
|
|
|
|
|
|
|
/* Add our stylesheet to the page so we can make our settings look nice */
|
|
|
|
|
|
|
|
$a->page['htmlhead'] .= '<link rel="stylesheet" type="text/css" href="' . $a->get_baseurl() . '/addon/page/page.css' . '" media="all" />' . "\r\n";
|
|
|
|
|
|
|
|
/* Get the current state of our config variable */
|
|
|
|
|
|
|
|
$max_pages = get_pconfig(local_user(),'page','max_pages');
|
|
|
|
if($max_pages === false)
|
|
|
|
$max_pages = 6;
|
2012-06-19 10:27:51 +00:00
|
|
|
|
|
|
|
$randomise = intval(get_pconfig(local_user(),'page','randomise'));
|
|
|
|
$randomise_checked = (($randomise) ? ' checked="checked" ' : '');
|
|
|
|
|
2012-06-30 09:01:20 +00:00
|
|
|
$profile = intval(get_pconfig(local_user(),'page','show_on_profile'));
|
|
|
|
$profile_checked = (($profile) ? ' checked="checked" ' : '');
|
|
|
|
|
2012-06-19 09:30:44 +00:00
|
|
|
|
|
|
|
/* Add some HTML to the existing form */
|
|
|
|
|
|
|
|
$s .= '<div class="settings-block">';
|
|
|
|
$s .= '<h3>' . t('Page Settings') . '</h3>';
|
|
|
|
$s .= '<div id="page-settings-wrapper">';
|
|
|
|
$s .= '<label id="page-settings-label" for="page-max-pages">' . t('How many forums to display on sidebar without paging') . '</label>';
|
|
|
|
$s .= '<input id="page-max-pages" type="text" name="page_max_pages" value="' . intval($max_pages) . '" ' . '/>';
|
2012-06-19 10:27:51 +00:00
|
|
|
$s .= '<div class="clear"></div>';
|
|
|
|
$s .= '<label id="page-random-label" for="page-random">' . t('Randomise Page/Forum list') . '</label>';
|
|
|
|
$s .= '<input id="page-random" type="checkbox" name="page_random" value="1" ' . $randomise_checked . '/>';
|
|
|
|
$s .= '<div class="clear"></div>';
|
2012-06-30 09:01:20 +00:00
|
|
|
$s .= '<label id="page-profile-label" for="page-profile">' . t('Show pages/forums on profile page') . '</label>';
|
|
|
|
$s .= '<input id="page-profile" type="checkbox" name="page_profile" value="1" ' . $profile_checked . '/>';
|
|
|
|
$s .= '<div class="clear"></div>';
|
2012-06-19 10:27:51 +00:00
|
|
|
|
|
|
|
$s .= '</div>';
|
2012-06-19 09:30:44 +00:00
|
|
|
|
|
|
|
/* provide a submit button */
|
|
|
|
|
2013-11-19 13:10:27 +00:00
|
|
|
$s .= '<div class="settings-submit-wrapper" ><input type="submit" name="page-settings-submit" class="settings-submit" value="' . t('Save Settings') . '" /></div></div>';
|
2012-06-19 09:30:44 +00:00
|
|
|
|
|
|
|
}
|
2012-05-03 01:11:53 +00:00
|
|
|
|
|
|
|
|