cleanup plugin and post settings

This commit is contained in:
Friendika 2011-02-23 18:24:29 -08:00
parent 352fef6208
commit 834439b730
7 changed files with 61 additions and 30 deletions

View file

@ -0,0 +1,8 @@
#facebook-enable-wrapper {
margin-top: 20px;
}
#facebook-disable-wrapper {
margin-top: 20px;
}

View file

@ -114,14 +114,18 @@ function facebook_content(&$a) {
return ''; return '';
} }
$a->page['htmlhead'] .= '<link rel="stylesheet" type="text/css" href="'
. $a->get_baseurl() . '/addon/facebook/facebook.css' . '" media="all" />' . "\r\n";
$o .= '<h3>' . t('Facebook Connect') . '</h3>'; $o .= '<h3>' . t('Facebook Connect') . '</h3>';
$o .= '<br />'; $o .= '<div id="facebook-enable-wrapper">';
$o .= '<a href="https://www.facebook.com/dialog/oauth?client_id=' . $appid . '&redirect_uri=' $o .= '<a href="https://www.facebook.com/dialog/oauth?client_id=' . $appid . '&redirect_uri='
. $a->get_baseurl() . '/facebook/' . $a->user['nickname'] . '&scope=publish_stream,read_stream,offline_access">' . t('Install Facebook post connector') . '</a><br /><br />'; . $a->get_baseurl() . '/facebook/' . $a->user['nickname'] . '&scope=publish_stream,read_stream,offline_access">' . t('Install Facebook post connector') . '</a>';
$o .= '</div><div id="facebook-disable-wrapper">';
$o .= '<a href="' . $a->get_baseurl() . '/facebook/remove' . '">' . t('Remove Facebook post connector') . '</a><br />'; $o .= '<a href="' . $a->get_baseurl() . '/facebook/remove' . '">' . t('Remove Facebook post connector') . '</a></div>';
return $o; return $o;
@ -143,8 +147,10 @@ function facebook_uninstall() {
function facebook_plugin_settings(&$a,&$b) { function facebook_plugin_settings(&$a,&$b) {
$b .= '<div class="settings-block">';
$b .= '<h3>' . t('Facebook') . '</h3>'; $b .= '<h3>' . t('Facebook') . '</h3>';
$b .= '<a href="facebook">' . t('Facebook Connector Settings') . '</a><br />'; $b .= '<a href="facebook">' . t('Facebook Connector Settings') . '</a><br />';
$b .= '</div>';
} }

View file

@ -167,6 +167,7 @@ function randplace_settings(&$a,&$s) {
/* Add some HTML to the existing form */ /* Add some HTML to the existing form */
$s .= '<div class="settings-block">';
$s .= '<h3>' . t('Randplace Settings') . '</h3>'; $s .= '<h3>' . t('Randplace Settings') . '</h3>';
$s .= '<div id="randplace-enable-wrapper">'; $s .= '<div id="randplace-enable-wrapper">';
$s .= '<label id="randplace-enable-label" for="randplace-checkbox">' . t('Enable Randplace Plugin') . '</label>'; $s .= '<label id="randplace-enable-label" for="randplace-checkbox">' . t('Enable Randplace Plugin') . '</label>';
@ -175,6 +176,6 @@ function randplace_settings(&$a,&$s) {
/* provide a submit button */ /* provide a submit button */
$s .= '<div class="settings-submit-wrapper" ><input type="submit" name="submit" class="settings-submit" value="' . t('Submit') . '" /></div>'; $s .= '<div class="settings-submit-wrapper" ><input type="submit" name="submit" class="settings-submit" value="' . t('Submit') . '" /></div></div>';
} }

View file

@ -63,6 +63,22 @@ function statusnet_uninstall() {
unregister_hook('post_local_end', 'addon/statusnet/statusnet.php', 'statusnet_post_hook'); unregister_hook('post_local_end', 'addon/statusnet/statusnet.php', 'statusnet_post_hook');
} }
function statusnet_jot_nets(&$a,&$b) {
if(! local_user())
return;
$statusnet_post = get_pconfig(local_user(),'statusnet','post');
if(intval($statusnet_post) == 1) {
$statusnet_defpost = get_pconfig(local_user(),'statusnet','post_by_default');
$selected = ((intval($statusnet_defpost == 1)) ? ' selected="selected" ' : '');
$b .= '<div class="profile-jot-net"><input type="checkbox" name="statusnet_enable"' . $selected . 'value="1" /> '
. t('Post to StatusNet') . '</div>';
}
}
function statusnet_settings_post ($a,$post) { function statusnet_settings_post ($a,$post) {
if(! local_user()) if(! local_user())
return; return;
@ -123,6 +139,7 @@ function statusnet_settings(&$a,&$s) {
$osecret = get_pconfig(local_user(), 'statusnet', 'oauthsecret' ); $osecret = get_pconfig(local_user(), 'statusnet', 'oauthsecret' );
$enabled = get_pconfig(local_user(), 'statusnet', 'post'); $enabled = get_pconfig(local_user(), 'statusnet', 'post');
$checked = (($enabled) ? ' checked="checked" ' : ''); $checked = (($enabled) ? ' checked="checked" ' : '');
$s .= '<div class="settings-block">';
$s .= '<h3>'. t('StatusNet Posting Settings').'</h3>'; $s .= '<h3>'. t('StatusNet Posting Settings').'</h3>';
if ( (!$ckey) && (!$csecret) ) { if ( (!$ckey) && (!$csecret) ) {
@ -185,7 +202,7 @@ function statusnet_settings(&$a,&$s) {
$s .= '<div class="settings-submit-wrapper" ><input type="submit" name="submit" class="settings-submit" value="' . t('Submit') . '" /></div>'; $s .= '<div class="settings-submit-wrapper" ><input type="submit" name="submit" class="settings-submit" value="' . t('Submit') . '" /></div>';
} }
} }
$s .= '</div><div class="clear"></div>'; $s .= '</div><div class="clear"></div></div>';
} }
@ -210,8 +227,9 @@ function statusnet_post_hook(&$a,&$b) {
if($ckey && $csecret && $otoken && $osecret) { if($ckey && $csecret && $otoken && $osecret) {
$statusnet_post = get_pconfig(local_user(),'statusnet','post'); $statusnet_post = get_pconfig(local_user(),'statusnet','post');
$statusnet_enable = (($statusnet_post && x($_POST,'statusnet_enable')) ? intval($_POST['statusnet_enable']) : 0);
if($statusnet_post) { if($statusnet_enable && $statusnet_post) {
require_once('include/bbcode.php'); require_once('include/bbcode.php');
$dent = new StatusNetOAuth($api,$ckey,$csecret,$otoken,$osecret); $dent = new StatusNetOAuth($api,$ckey,$csecret,$otoken,$osecret);
$max_char = $dent->get_maxlength(); // max. length for a dent $max_char = $dent->get_maxlength(); // max. length for a dent

View file

@ -41,7 +41,6 @@ function twitter_install() {
register_hook('plugin_settings_post', 'addon/twitter/twitter.php', 'twitter_settings_post'); register_hook('plugin_settings_post', 'addon/twitter/twitter.php', 'twitter_settings_post');
register_hook('post_local_end', 'addon/twitter/twitter.php', 'twitter_post_hook'); register_hook('post_local_end', 'addon/twitter/twitter.php', 'twitter_post_hook');
register_hook('jot_networks', 'addon/twitter/twitter.php', 'twitter_jot_nets'); register_hook('jot_networks', 'addon/twitter/twitter.php', 'twitter_jot_nets');
register_hook('post_local_start', 'addon/twitter/twitter.php', 'twitter_post_start');
logger("installed twitter"); logger("installed twitter");
} }
@ -51,8 +50,6 @@ function twitter_uninstall() {
unregister_hook('plugin_settings_post', 'addon/twitter/twitter.php', 'twitter_settings_post'); unregister_hook('plugin_settings_post', 'addon/twitter/twitter.php', 'twitter_settings_post');
unregister_hook('post_local_end', 'addon/twitter/twitter.php', 'twitter_post_hook'); unregister_hook('post_local_end', 'addon/twitter/twitter.php', 'twitter_post_hook');
unregister_hook('jot_networks', 'addon/twitter/twitter.php', 'twitter_jot_nets'); unregister_hook('jot_networks', 'addon/twitter/twitter.php', 'twitter_jot_nets');
unregister_hook('post_local_start', 'addon/twitter/twitter.php', 'twitter_post_start');
} }
function twitter_jot_nets(&$a,&$b) { function twitter_jot_nets(&$a,&$b) {
@ -70,19 +67,6 @@ function twitter_jot_nets(&$a,&$b) {
} }
function twitter_post_start(&$a,&$b) {
if(! local_user())
return;
if((x($b,'twitter_enable')) && (intval($b['twitter_enable'])))
set_pconfig(local_user(),'twitter','enable','1');
else
del_pconfig(local_user(),'twitter','enable');
}
function twitter_settings_post ($a,$post) { function twitter_settings_post ($a,$post) {
if(! local_user()) if(! local_user())
return; return;
@ -134,6 +118,7 @@ function twitter_settings(&$a,&$s) {
$osecret = get_pconfig(local_user(), 'twitter', 'oauthsecret' ); $osecret = get_pconfig(local_user(), 'twitter', 'oauthsecret' );
$enabled = get_pconfig(local_user(), 'twitter', 'post'); $enabled = get_pconfig(local_user(), 'twitter', 'post');
$checked = (($enabled) ? ' checked="checked" ' : ''); $checked = (($enabled) ? ' checked="checked" ' : '');
$s .= '<div class="settings-block">';
$s .= '<h3>'. t('Twitter Posting Settings') .'</h3>'; $s .= '<h3>'. t('Twitter Posting Settings') .'</h3>';
if ( (!$ckey) && (!$csecret) ) { if ( (!$ckey) && (!$csecret) ) {
@ -190,7 +175,7 @@ function twitter_settings(&$a,&$s) {
$s .= '<div class="settings-submit-wrapper" ><input type="submit" name="submit" class="settings-submit" value="' . t('Submit') . '" /></div>'; $s .= '<div class="settings-submit-wrapper" ><input type="submit" name="submit" class="settings-submit" value="' . t('Submit') . '" /></div>';
} }
} }
$s .= '</div><div class="clear"></div>'; $s .= '</div><div class="clear"></div></div>';
} }
@ -213,11 +198,11 @@ function twitter_post_hook(&$a,&$b) {
if($ckey && $csecret && $otoken && $osecret) { if($ckey && $csecret && $otoken && $osecret) {
$twitter_post = get_pconfig(local_user(),'twitter','post'); $twitter_post = intval(get_pconfig(local_user(),'twitter','post'));
$twitter_enable = intval(get_pconfig(local_user(),'twitter','enable')); $twitter_enable = (($twitter_post && x($_POST,'twitter_enable')) ? intval($_POST['twitter_enable']) : 0);
if($twitter_post && $twitter_enable) { if($twitter_post && $twitter_enable) {
require_once('addon/twitter/twitteroauth.php'); require_once('library/twitteroauth.php');
require_once('include/bbcode.php'); require_once('include/bbcode.php');
$tweet = new TwitterOAuth($ckey,$csecret,$otoken,$osecret); $tweet = new TwitterOAuth($ckey,$csecret,$otoken,$osecret);
$max_char = 140; // max. length for a tweet $max_char = 140; // max. length for a tweet

View file

@ -2025,3 +2025,9 @@ a.mail-list-link {
.today { .today {
color: #FF0000; color: #FF0000;
} }
.settings-block {
border: 1px solid #AAA;
margin: 10px;
padding: 10px;
}

View file

@ -2073,3 +2073,10 @@ a.mail-list-link {
.today { .today {
color: #FF0000; color: #FF0000;
} }
.settings-block {
border: 1px solid #AAA;
margin: 10px;
padding: 10px;
}