fb "post by default" implemented, post_by_default logic fixed for other plugins

This commit is contained in:
Friendika 2011-03-09 14:39:18 -08:00
parent 6f9eadfe6e
commit 1c779e2061
4 changed files with 37 additions and 9 deletions

View File

@ -6,3 +6,8 @@
#facebook-disable-wrapper {
margin-top: 20px;
}
#facebook-post-default-form input {
margin-top: 20px;
margin-right: 20px;
}

View File

@ -95,6 +95,15 @@ function facebook_init(&$a) {
}
function facebook_post(&$a) {
if(local_user()){
$value = ((x($_POST,'post_by_default')) ? intval($_POST['post_by_default']) : 0);
set_pconfig(local_user(),'facebook','post_by_default', $value);
}
return;
}
function facebook_content(&$a) {
if(! local_user()) {
@ -107,6 +116,8 @@ function facebook_content(&$a) {
notice( t('Facebook disabled') . EOL);
}
$fb_installed = get_pconfig(local_user(),'facebook','post');
$appid = get_config('facebook','appid');
if(! $appid) {
@ -119,14 +130,26 @@ function facebook_content(&$a) {
$o .= '<h3>' . t('Facebook Connect') . '</h3>';
$o .= '<div id="facebook-enable-wrapper">';
if(! $fb_installed) {
$o .= '<div id="facebook-enable-wrapper">';
$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>';
$o .= '</div><div id="facebook-disable-wrapper">';
$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>';
$o .= '</div>';
}
$o .= '<a href="' . $a->get_baseurl() . '/facebook/remove' . '">' . t('Remove Facebook post connector') . '</a></div>';
if($fb_installed) {
$o .= '<div id="facebook-disable-wrapper">';
$o .= '<a href="' . $a->get_baseurl() . '/facebook/remove' . '">' . t('Remove Facebook post connector') . '</a></div>';
$o .= '<div id="facebook-post-default-form">';
$o .= '<form action="facebook" method="post" >';
$post_by_default = get_pconfig(local_user(),'facebook','post_by_default');
$checked = (($post_by_default) ? ' checked="checked" ' : '');
$o .= '<input type="checkbox" name="post_by_default" value="1"' . $checked . '/>' . ' ' . t('Post to Facebook by default') . '<br />';
$o .= '<input type="submit" name="submit" value="' . t('Submit') . '" /></form></div>';
}
return $o;
}
@ -161,7 +184,7 @@ function facebook_jot_nets(&$a,&$b) {
$fb_post = get_pconfig(local_user(),'facebook','post');
if(intval($fb_post) == 1) {
$fb_defpost = get_pconfig(local_user(),'facebook','post_by_default');
$selected = ((intval($fb_defpost == 1)) ? ' selected="selected" ' : '');
$selected = ((intval($fb_defpost) == 1) ? ' checked="checked" ' : '');
$b .= '<div class="profile-jot-net"><input type="checkbox" name="facebook_enable"' . $selected . 'value="1" /> '
. t('Post to Facebook') . '</div>';
}
@ -202,7 +225,7 @@ function facebook_post_hook(&$a,&$b) {
// make links readable before we strip the code
$msg = preg_replace("/\[url=(.+?)\](.+?)\[\/url\]/is",'$2 ($1)',$msg);
$msg = preg_replace("/\[url=(.+?)\](.+?)\[\/url\]/is",'$2 [$1]',$msg);
$msg = preg_replace("/\[img\](.+?)\[\/img\]/is", t('Image: ') . '$1',$msg);

View File

@ -73,7 +73,7 @@ function statusnet_jot_nets(&$a,&$b) {
$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" ' : '');
$selected = ((intval($statusnet_defpost) == 1) ? ' checked="checked" ' : '');
$b .= '<div class="profile-jot-net"><input type="checkbox" name="statusnet_enable"' . $selected . 'value="1" /> '
. t('Post to StatusNet') . '</div>';
}

View File

@ -59,7 +59,7 @@ function twitter_jot_nets(&$a,&$b) {
$tw_post = get_pconfig(local_user(),'twitter','post');
if(intval($tw_post) == 1) {
$tw_defpost = get_pconfig(local_user(),'twitter','post_by_default');
$selected = ((intval($tw_defpost == 1)) ? ' selected="selected" ' : '');
$selected = ((intval($tw_defpost) == 1) ? ' checked="checked" ' : '');
$b .= '<div class="profile-jot-net"><input type="checkbox" name="twitter_enable"' . $selected . 'value="1" /> '
. t('Post to Twitter') . '</div>';
}