diff options
author | Friendika <info@friendika.com> | 2011-02-11 02:35:19 -0800 |
---|---|---|
committer | Friendika <info@friendika.com> | 2011-02-11 02:35:19 -0800 |
commit | c16e86add81d9f2867a0da024954b5cbc14a9f4b (patch) | |
tree | 012c13873b4c876b5198d9c8c0c7f0e91a29455f | |
parent | 40574589e27d9135a434dcc4f9dfa899fe5f8ec6 (diff) | |
download | volse-hubzilla-c16e86add81d9f2867a0da024954b5cbc14a9f4b.tar.gz volse-hubzilla-c16e86add81d9f2867a0da024954b5cbc14a9f4b.tar.bz2 volse-hubzilla-c16e86add81d9f2867a0da024954b5cbc14a9f4b.zip |
toggles "post to facebook, post to twitter", etc.
-rw-r--r-- | addon/facebook/facebook.php | 45 | ||||
-rw-r--r-- | addon/twitter/twitter.php | 36 | ||||
-rw-r--r-- | boot.php | 2 | ||||
-rw-r--r-- | mod/network.php | 5 | ||||
-rw-r--r-- | mod/profile.php | 6 | ||||
-rw-r--r-- | view/de/jot.tpl | 6 | ||||
-rw-r--r-- | view/en/jot.tpl | 6 | ||||
-rw-r--r-- | view/fr/jot.tpl | 7 | ||||
-rw-r--r-- | view/it/jot.tpl | 7 | ||||
-rw-r--r-- | view/theme/duepuntozero/style.css | 11 | ||||
-rw-r--r-- | view/theme/loozah/style.css | 11 |
11 files changed, 127 insertions, 15 deletions
diff --git a/addon/facebook/facebook.php b/addon/facebook/facebook.php index a41344a3d..2a5715b2e 100644 --- a/addon/facebook/facebook.php +++ b/addon/facebook/facebook.php @@ -3,6 +3,9 @@ /** * This module still needs a lot of work, but is functional today. * Please review this section if you upgrade because things will change. + * If you have issues upgrading, remove facebook from the addon list, + * view a page on your site, then add it back to the list. This will reset + * all of the plugin 'hooks'. * * 1. register an API key from developer.facebook.com * a. We'd be very happy if you include "Friendika" in the application name @@ -77,7 +80,7 @@ function facebook_init(&$a) { if(strpos($token,'&') !== false) $token = substr($token,0,strpos($token,'&')); set_pconfig($uid,'facebook','access_token',$token); - set_pconfig($uid,'facebook','post','true'); + set_pconfig($uid,'facebook','post','1'); } // todo: is this a browser session or a server session? where do we go? @@ -118,12 +121,41 @@ function facebook_content(&$a) { } function facebook_install() { - register_hook('post_local_end', 'addon/facebook/facebook.php', 'facebook_post_hook'); + register_hook('post_local_end', 'addon/facebook/facebook.php', 'facebook_post_hook'); + register_hook('jot_networks', 'addon/facebook/facebook.php', 'facebook_jot_nets'); + register_hook('post_local_start','addon/facebook/facebook.php', 'facebook_post_local'); + } function facebook_uninstall() { - unregister_hook('post_local_end', 'addon/facebook/facebook.php', 'facebook_post_hook'); + unregister_hook('post_local_end', 'addon/facebook/facebook.php', 'facebook_post_hook'); + unregister_hook('jot_networks', 'addon/facebook/facebook.php', 'facebook_jot_nets'); + unregister_hook('post_local_start','addon/facebook/facebook.php', 'facebook_post_local'); +} + + +function facebook_jot_nets(&$a,&$b) { + if(! local_user()) + return; + + $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" ' : ''); + $b .= '<div class="profile-jot-net"><input type="checkbox" name="facebook_enable" $selected value="1" /> ' + . t('Post to Facebook') . '</div>'; + } +} + +function facebook_post_local(&$a,&$b) { + if(! local_user()) + return; + + if((x($b,'facebook_enable')) && (intval($b['facebook_enable']))) + set_pconfig(local_user(),'facebook','enable','1'); + else + del_pconfig(local_user(),'facebook','enable'); } @@ -143,10 +175,11 @@ function facebook_post_hook(&$a,&$b) { if($appid && $secret) { - $fb_post = get_pconfig(local_user(),'facebook','post'); - $fb_token = get_pconfig(local_user(),'facebook','access_token'); + $fb_post = intval(get_pconfig(local_user(),'facebook','post')); + $fb_enable = intval(get_pconfig(local_user(),'facebook','enable')); + $fb_token = get_pconfig(local_user(),'facebook','access_token'); - if($fb_post && $fb_token) { + if($fb_post && $fb_token && $fb_enable) { require_once('library/facebook.php'); require_once('include/bbcode.php'); diff --git a/addon/twitter/twitter.php b/addon/twitter/twitter.php index a0c6db931..6a0365e09 100644 --- a/addon/twitter/twitter.php +++ b/addon/twitter/twitter.php @@ -40,6 +40,8 @@ function twitter_install() { register_hook('plugin_settings', 'addon/twitter/twitter.php', 'twitter_settings'); 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('jot_networks', 'addon/twitter/twitter.php', 'twitter_jot_nets'); + register_hook('post_local_start', 'addon/twitter/twitter.php', 'twitter_post_start'); logger("installed twitter"); } @@ -48,8 +50,39 @@ function twitter_uninstall() { unregister_hook('plugin_settings', 'addon/twitter/twitter.php', 'twitter_settings'); 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('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) { + if(! local_user()) + return; + + $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" ' : ''); + $b .= '<div class="profile-jot-net"><input type="checkbox" name="twitter_enable" $selected value="1" /> ' + . t('Post to Twitter') . '</div>'; + } + + } +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) { if(! local_user()) return; @@ -181,8 +214,9 @@ function twitter_post_hook(&$a,&$b) { if($ckey && $csecret && $otoken && $osecret) { $twitter_post = get_pconfig(local_user(),'twitter','post'); + $twitter_enable = intval(get_pconfig(local_user(),'twitter','enable')); - if($twitter_post) { + if($twitter_post && $twitter_enable) { require_once('addon/twitter/twitteroauth.php'); require_once('include/bbcode.php'); $tweet = new TwitterOAuth($ckey,$csecret,$otoken,$osecret); @@ -516,6 +516,7 @@ function check_config(&$a) { } } } + load_hooks(); return; }} @@ -2189,6 +2190,7 @@ function unregister_hook($hook,$file,$function) { if(! function_exists('load_hooks')) { function load_hooks() { $a = get_app(); + $a->hooks = array(); $r = q("SELECT * FROM `hook` WHERE 1"); if(count($r)) { foreach($r as $rr) { diff --git a/mod/network.php b/mod/network.php index b0196f92a..f11db45a8 100644 --- a/mod/network.php +++ b/mod/network.php @@ -79,8 +79,10 @@ function network_content(&$a, $update = 0) { $celeb = ((($a->user['page-flags'] == PAGE_SOAPBOX) || ($a->user['page-flags'] == PAGE_COMMUNITY)) ? true : false); - $jotplugins = ""; + $jotplugins = ''; + $jotnets = ''; call_hooks('jot_tool', $jotplugins); + call_hooks('jot_networks', $jotnets); $tpl = replace_macros($tpl,array('$jotplugins' => $jotplugins)); @@ -90,6 +92,7 @@ function network_content(&$a, $update = 0) { '$defloc' => $a->user['default-location'], '$visitor' => 'block', '$emailcc' => t('CC: email addresses'), + '$jotnets' => $jotnets, '$emtitle' => t('Example: bob@example.com, mary@example.com'), '$lockstate' => $lockstate, '$acl' => populate_acl((($group) ? $group_acl : $a->user), $celeb), diff --git a/mod/profile.php b/mod/profile.php index 3b4616a34..8ec29d382 100644 --- a/mod/profile.php +++ b/mod/profile.php @@ -135,9 +135,12 @@ function profile_content(&$a, $update = 0) { else $lockstate = 'unlock'; - $jotplugins = ""; + $jotplugins = ''; + $jotnets = ''; call_hooks('jot_tool', $jotplugins); + call_hooks('jot_networks', $jotnets); + $tpl = replace_macros($tpl,array('$jotplugins' => $jotplugins)); $o .= replace_macros($tpl,array( @@ -147,6 +150,7 @@ function profile_content(&$a, $update = 0) { '$visitor' => (($is_owner || $commvisitor) ? 'block' : 'none'), '$lockstate' => $lockstate, '$emailcc' => t('CC: email addresses'), + '$jotnets' => $jotnets, '$emtitle' => t('Example: bob@example.com, mary@example.com'), '$bang' => '', '$acl' => (($is_owner) ? populate_acl($a->user, $celeb) : ''), diff --git a/view/de/jot.tpl b/view/de/jot.tpl index 545bbdadd..db73b17a6 100644 --- a/view/de/jot.tpl +++ b/view/de/jot.tpl @@ -42,12 +42,16 @@ <div id="profile-rotator-wrapper" style="display: $visitor;" > <img id="profile-rotator" src="images/rotator.gif" alt="Bitte warten" title="Bitte warten" style="display: none;" /> </div> - <div id="profile-jot-perms" class="profile-jot-perms" style="display: $visitor;" ><img id="jot-perms-icon" src="images/$lockstate_icon.gif" alt="Berechtigungseinstellungen" title="Berechtigungseinstellungen" onClick="openClose('profile-jot-acl-wrapper'); openClose('profile-jot-email-wrapper');" />$bang</div> + <div id="profile-jot-perms" class="profile-jot-perms" style="display: $visitor;" ><img id="jot-perms-icon" src="images/$lockstate_icon.gif" alt="Berechtigungseinstellungen" title="Berechtigungseinstellungen" onClick="openClose('profile-jot-acl-wrapper'); openClose('profile-jot-email-wrapper'); openClose('profile-jot-networks');" />$bang</div> <div id="profile-jot-perms-end"></div> <div id="profile-jot-email-wrapper" style="display: none;" > <div id="profile-jot-email-label">$emailcc</div><input type="text" name="emailcc" id="profile-jot-email" title="$emtitle"> <div id="profile-jot-email-end"></div> </div> + <div id="profile-jot-networks" style="display: none;" > + $jotnets + </div> + <div id="profile-jot-networks-end"></div> <div id="profile-jot-acl-wrapper" style="display: none;" >$acl</div> </div> diff --git a/view/en/jot.tpl b/view/en/jot.tpl index 5f9935778..7c6a857e8 100644 --- a/view/en/jot.tpl +++ b/view/en/jot.tpl @@ -40,12 +40,16 @@ <div id="profile-rotator-wrapper" style="display: $visitor;" > <img id="profile-rotator" src="images/rotator.gif" alt="Please wait" title="Please wait" style="display: none;" /> </div> - <div id="profile-jot-perms" class="profile-jot-perms" style="display: $visitor;" ><img id="jot-perms-icon" src="images/$lockstate_icon.gif" alt="Permission Settings" title="Permission Settings" onClick="openClose('profile-jot-acl-wrapper'); openClose('profile-jot-email-wrapper');" />$bang</div> + <div id="profile-jot-perms" class="profile-jot-perms" style="display: $visitor;" ><img id="jot-perms-icon" src="images/$lockstate_icon.gif" alt="Permission Settings" title="Permission Settings" onClick="openClose('profile-jot-acl-wrapper'); openClose('profile-jot-email-wrapper'); openClose('profile-jot-networks');" />$bang</div> <div id="profile-jot-perms-end"></div> <div id="profile-jot-email-wrapper" style="display: none;" > <div id="profile-jot-email-label">$emailcc</div><input type="text" name="emailcc" id="profile-jot-email" title="$emtitle"> <div id="profile-jot-email-end"></div> </div> + <div id="profile-jot-networks" style="display: none;" > + $jotnets + </div> + <div id="profile-jot-networks-end"></div> <div id="profile-jot-acl-wrapper" style="display: none;" >$acl</div> </div> diff --git a/view/fr/jot.tpl b/view/fr/jot.tpl index 720cb0d1b..d64632da0 100644 --- a/view/fr/jot.tpl +++ b/view/fr/jot.tpl @@ -42,13 +42,16 @@ <div id="profile-rotator-wrapper" style="display: $visitor;" > <img id="profile-rotator" src="images/rotator.gif" alt="Please wait" title="Please wait" style="display: none;" /> </div> - <div id="profile-jot-perms" class="profile-jot-perms" style="display: $visitor;" ><img id="jot-perms-icon" src="images/$lockstate_icon.gif" alt="Permission Settings" title="Permission Settings" onClick="openClose('profile-jot-acl-wrapper'); openClose('profile-jot-email-wrapper');" />$bang</div> + <div id="profile-jot-perms" class="profile-jot-perms" style="display: $visitor;" ><img id="jot-perms-icon" src="images/$lockstate_icon.gif" alt="Permission Settings" title="Permission Settings" onClick="openClose('profile-jot-acl-wrapper'); openClose('profile-jot-email-wrapper'); openClose('profile-jot-networks');" />$bang</div> <div id="profile-jot-perms-end"></div> <div id="profile-jot-email-wrapper" style="display: none;" > <div id="profile-jot-email-label">$emailcc</div><input type="text" name="emailcc" id="profile-jot-email" title="$emtitle"> <div id="profile-jot-email-end"></div> </div> - + <div id="profile-jot-networks" style="display: none;" > + $jotnets + </div> + <div id="profile-jot-networks-end"></div> <div id="profile-jot-acl-wrapper" style="display: none;" >$acl</div> </div> diff --git a/view/it/jot.tpl b/view/it/jot.tpl index eae3ecba8..c4b63eb01 100644 --- a/view/it/jot.tpl +++ b/view/it/jot.tpl @@ -41,13 +41,16 @@ <div id="profile-rotator-wrapper" style="display: $visitor;" > <img id="profile-rotator" src="images/rotator.gif" alt="Attendi" title="Attendi" style="display: none;" /> </div> - <div id="profile-jot-perms" class="profile-jot-perms" style="display: $visitor;" ><img id="jot-perms-icon" src="images/$lockstate_icon.gif" alt="Impostazione permessi" title="Impostazione permessi" onClick="openClose('profile-jot-acl-wrapper'); openClose('profile-jot-email-wrapper');" />$bang</div> + <div id="profile-jot-perms" class="profile-jot-perms" style="display: $visitor;" ><img id="jot-perms-icon" src="images/$lockstate_icon.gif" alt="Impostazione permessi" title="Impostazione permessi" onClick="openClose('profile-jot-acl-wrapper'); openClose('profile-jot-email-wrapper'); openClose('profile-jot-networks');" />$bang</div> <div id="profile-jot-perms-end"></div> <div id="profile-jot-email-wrapper" style="display: none;" > <div id="profile-jot-email-label">$emailcc</div><input type="text" name="emailcc" id="profile-jot-email" title="$emtitle"> <div id="profile-jot-email-end"></div> </div> - + <div id="profile-jot-networks" style="display: none;" > + $jotnets + </div> + <div id="profile-jot-networks-end"></div> <div id="profile-jot-acl-wrapper" style="display: none;" >$acl</div> </div> diff --git a/view/theme/duepuntozero/style.css b/view/theme/duepuntozero/style.css index 0c56c4233..45e5efb6c 100644 --- a/view/theme/duepuntozero/style.css +++ b/view/theme/duepuntozero/style.css @@ -960,6 +960,17 @@ input#dfrn-url { #profile-jot-plugin-end{ clear: both; } +.profile-jot-net { + float: left; + margin-right: 10px; + margin-top: 5px; + margin-bottom: 5px; +} + +#profile-jot-networks-end { + clear: both; +} + #profile-jot-end { /*clear: both;*/ margin-bottom: 30px; diff --git a/view/theme/loozah/style.css b/view/theme/loozah/style.css index d7d735d6d..2a037bf9f 100644 --- a/view/theme/loozah/style.css +++ b/view/theme/loozah/style.css @@ -1085,6 +1085,17 @@ input#dfrn-url { #profile-jot-plugin-end { clear:both; } +.profile-jot-net { + float: left; + margin-right: 10px; + margin-top: 5px; + margin-bottom: 5px; +} + +#profile-jot-networks-end { + clear: both; +} + #profile-jot-end { clear: both; margin-bottom: 30px; |