forked from GNUsocial/gnu-social
trac750 added some output to the facebook_update.php script
darcs-hash:20090105045603-7b5ce-2cef1b92d9c91b0db70269d94f42ae06076229b2.gz
This commit is contained in:
parent
e0fbf02bbf
commit
53cabc0171
@ -116,4 +116,6 @@ Evan Prodromou <evan@prodromou.name>**20081230212202]
|
||||
[trac750 Automatically update linked Facebook users' statuses
|
||||
Zach Copley <zach@controlyourself.ca>**20090105010407]
|
||||
[trac750 configurable sync flags for Facebook app (noticesync, replysync)
|
||||
Zach Copley <zach@controlyourself.ca>**20090105040212]
|
||||
Zach Copley <zach@controlyourself.ca>**20090105040212]
|
||||
[trac750 added some output to the facebook_update.php script
|
||||
Zach Copley <zach@controlyourself.ca>**20090105045603]
|
Binary file not shown.
@ -48,6 +48,10 @@ $current_time = time();
|
||||
|
||||
$notice = get_facebook_notices(get_last_updated());
|
||||
|
||||
print date('r', $current_time) . " Looking for notices to send to Facebook...\n";
|
||||
|
||||
$cnt = 0;
|
||||
|
||||
while($notice->fetch()) {
|
||||
|
||||
$flink = Foreign_link::getByUserID($notice->profile_id, 2);
|
||||
@ -60,12 +64,15 @@ while($notice->fetch()) {
|
||||
if (!preg_match('/@[a-zA-Z0-9_]{1,15}\b/u', $content) ||
|
||||
(($flink->noticesync & FOREIGN_NOTICE_SEND_REPLY) == FOREIGN_NOTICE_SEND_REPLY)) {
|
||||
update_status($fbuid, $content);
|
||||
$cnt++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
update_last_updated($current_time);
|
||||
|
||||
print "Sent $cnt notices to Facebook.\n";
|
||||
|
||||
exit(0);
|
||||
|
||||
|
||||
|
@ -1,237 +1,10 @@
|
||||
hunk ./actions/facebookhome.php 73
|
||||
-
|
||||
- # $this->set_flags($flink, $noticesync, $replysync, $friendsync);
|
||||
+ $flink->set_flags(true, false, false);
|
||||
hunk ./actions/facebooksettings.php 31
|
||||
- $this->display();
|
||||
+ if ($this->arg('save')) {
|
||||
+ $this->save_settings();
|
||||
+ } else {
|
||||
+ $this->show_form();
|
||||
+ }
|
||||
hunk ./actions/facebooksettings.php 38
|
||||
- function display()
|
||||
- {
|
||||
hunk ./scripts/update_facebook.php 51
|
||||
+print date('r', $current_time) . " Looking for notices to send to Facebook...\n";
|
||||
+
|
||||
+ function save_settings() {
|
||||
+$cnt = 0;
|
||||
+
|
||||
+ $noticesync = $this->arg('noticesync');
|
||||
+ $replysync = $this->arg('replysync');
|
||||
hunk ./actions/facebooksettings.php 45
|
||||
+ $fbuid = $facebook->require_login();
|
||||
hunk ./scripts/update_facebook.php 67
|
||||
+ $cnt++;
|
||||
hunk ./scripts/update_facebook.php 74
|
||||
+print "Sent $cnt notices to Facebook.\n";
|
||||
+
|
||||
+ $flink = Foreign_link::getByForeignID($fbuid, 2); // 2 == Facebook
|
||||
+
|
||||
+ $original = clone($flink);
|
||||
+ $flink->set_flags($noticesync, $replysync, false);
|
||||
+ $result = $flink->update($original);
|
||||
+
|
||||
+ if ($result) {
|
||||
+ echo '<fb:success message="Sync preferences saved." />';
|
||||
+ }
|
||||
hunk ./actions/facebooksettings.php 57
|
||||
+ $this->show_form();
|
||||
+
|
||||
+ }
|
||||
+
|
||||
+ function show_form() {
|
||||
+
|
||||
+ $facebook = get_facebook();
|
||||
hunk ./actions/facebooksettings.php 66
|
||||
+ $flink = Foreign_link::getByForeignID($fbuid, 2); // 2 == Facebook
|
||||
+
|
||||
+ $this->show_header('Settings');
|
||||
+
|
||||
hunk ./actions/facebooksettings.php 71
|
||||
- .'<h2>Add an Identi.ca box to your profile!</h2>'
|
||||
+ .'<h2>Add an Identi.ca box to my profile</h2>'
|
||||
hunk ./actions/facebooksettings.php 75
|
||||
-
|
||||
hunk ./actions/facebooksettings.php 77
|
||||
- $this->show_header('Settings');
|
||||
+ $fbml .= '<form method="post" id="facebook_settings">'
|
||||
+ .'<h2>Sync preferences</h2>'
|
||||
+ .'<p>';
|
||||
+
|
||||
+ if ($flink->noticesync & FOREIGN_NOTICE_SEND) {
|
||||
+ $fbml .= '<input name="noticesync" type="checkbox" class="checkbox" id="noticesync" checked="checked"/>';
|
||||
+ } else {
|
||||
+ $fbml .= '<input name="noticesync" type="checkbox" class="checkbox" id="noticesync">';
|
||||
+ }
|
||||
+
|
||||
+ $fbml .= '<label class="checkbox_label" for="noticesync">Automatically update my Facebook status with my notices.</label>'
|
||||
+ .'</p>'
|
||||
+ .'<p>';
|
||||
+
|
||||
+ if ($flink->noticesync & FOREIGN_NOTICE_SEND_REPLY) {
|
||||
+ $fbml .= '<input name="replysync" type="checkbox" class="checkbox" id="replysync" checked="checked"/>';
|
||||
+ } else {
|
||||
+ $fbml .= '<input name="replysync" type="checkbox" class="checkbox" id="replysync"/>';
|
||||
+ }
|
||||
+
|
||||
+ $fbml .= '<label class="checkbox_label" for="replysync">Send "@" replies to Facebook.</label>'
|
||||
+ .'</p>'
|
||||
+ .'<p>'
|
||||
+ .'<input type="submit" id="save" name="save" class="submit" value="Save"/>'
|
||||
+ .'</p>'
|
||||
+ .'</form>';
|
||||
hunk ./actions/facebooksettings.php 107
|
||||
-
|
||||
hunk ./actions/twittersettings.php 254
|
||||
- $this->set_flags($flink, $noticesync, $replysync, $friendsync);
|
||||
+ $flink->set_flags($noticesync, $replysync, $friendsync);
|
||||
hunk ./actions/twittersettings.php 326
|
||||
- $this->set_flags($flink, $noticesync, $replysync, $friendsync);
|
||||
+ $flink->set_flags($noticesync, $replysync, $friendsync);
|
||||
hunk ./actions/twittersettings.php 366
|
||||
- function set_flags(&$flink, $noticesync, $replysync, $friendsync)
|
||||
- {
|
||||
- if ($noticesync) {
|
||||
- $flink->noticesync |= FOREIGN_NOTICE_SEND;
|
||||
- } else {
|
||||
- $flink->noticesync &= ~FOREIGN_NOTICE_SEND;
|
||||
- }
|
||||
-
|
||||
- if ($replysync) {
|
||||
- $flink->noticesync |= FOREIGN_NOTICE_SEND_REPLY;
|
||||
- } else {
|
||||
- $flink->noticesync &= ~FOREIGN_NOTICE_SEND_REPLY;
|
||||
- }
|
||||
-
|
||||
- if ($friendsync) {
|
||||
- $flink->friendsync |= FOREIGN_FRIEND_RECV;
|
||||
- } else {
|
||||
- $flink->friendsync &= ~FOREIGN_FRIEND_RECV;
|
||||
- }
|
||||
-
|
||||
- $flink->profilesync = 0;
|
||||
- }
|
||||
hunk ./classes/Foreign_link.php 59
|
||||
+
|
||||
+ function set_flags($noticesync, $replysync, $friendsync)
|
||||
+ {
|
||||
+ if ($noticesync) {
|
||||
+ $this->noticesync |= FOREIGN_NOTICE_SEND;
|
||||
+ } else {
|
||||
+ $this->noticesync &= ~FOREIGN_NOTICE_SEND;
|
||||
+ }
|
||||
+
|
||||
+ if ($replysync) {
|
||||
+ $this->noticesync |= FOREIGN_NOTICE_SEND_REPLY;
|
||||
+ } else {
|
||||
+ $this->noticesync &= ~FOREIGN_NOTICE_SEND_REPLY;
|
||||
+ }
|
||||
+
|
||||
+ if ($friendsync) {
|
||||
+ $this->friendsync |= FOREIGN_FRIEND_RECV;
|
||||
+ } else {
|
||||
+ $this->friendsync &= ~FOREIGN_FRIEND_RECV;
|
||||
+ }
|
||||
+
|
||||
+ $this->profilesync = 0;
|
||||
+ }
|
||||
hunk ./lib/facebookaction.php 40
|
||||
- $style = '<style>
|
||||
- #notices {
|
||||
- clear: both;
|
||||
- margin: 0 auto;
|
||||
- padding: 0;
|
||||
- list-style-type: none;
|
||||
- width: 600px;
|
||||
- border-top: 1px solid #dec5b5;
|
||||
- }
|
||||
- #notices a:hover {
|
||||
- text-decoration: underline;
|
||||
- }
|
||||
- .notice_single {
|
||||
- clear: both;
|
||||
- display: block;
|
||||
- margin: 0;
|
||||
- padding: 5px 5px 5px 0;
|
||||
- min-height: 48px;
|
||||
- font-family: Georgia, "Times New Roman", Times, serif;
|
||||
- font-size: 13px;
|
||||
- line-height: 16px;
|
||||
- border-bottom: 1px solid #dec5b5;
|
||||
- background-color:#FCFFF5;
|
||||
- opacity:1;
|
||||
- }
|
||||
- .notice_single:hover {
|
||||
- background-color: #f7ebcc;
|
||||
- }
|
||||
- .notice_single p {
|
||||
- display: inline;
|
||||
- margin: 0;
|
||||
- padding: 0;
|
||||
- }
|
||||
- </style>';
|
||||
+ $style = '<style>
|
||||
+ #notices {
|
||||
+ clear: both;
|
||||
+ margin: 0 auto;
|
||||
+ padding: 0;
|
||||
+ list-style-type: none;
|
||||
+ width: 600px;
|
||||
+ border-top: 1px solid #dec5b5;
|
||||
+ }
|
||||
+ #notices a:hover {
|
||||
+ text-decoration: underline;
|
||||
+ }
|
||||
+ .notice_single {
|
||||
+ clear: both;
|
||||
+ display: block;
|
||||
+ margin: 0;
|
||||
+ padding: 5px 5px 5px 0;
|
||||
+ min-height: 48px;
|
||||
+ font-family: Georgia, "Times New Roman", Times, serif;
|
||||
+ font-size: 13px;
|
||||
+ line-height: 16px;
|
||||
+ border-bottom: 1px solid #dec5b5;
|
||||
+ background-color:#FCFFF5;
|
||||
+ opacity:1;
|
||||
+ }
|
||||
+ .notice_single:hover {
|
||||
+ background-color: #f7ebcc;
|
||||
+ }
|
||||
+ .notice_single p {
|
||||
+ display: inline;
|
||||
+ margin: 0;
|
||||
+ padding: 0;
|
||||
+ }
|
||||
+ </style>';
|
||||
hunk ./lib/facebookaction.php 75
|
||||
- $html = $this->render_notice($notice);
|
||||
+ $html = Facebookaction::Aender_notice($notice);
|
||||
hunk ./lib/facebookaction.php 77
|
||||
- $fbml = "<fb:wide>$content $html</fb:wide>";
|
||||
- $fbml .= "<fb:narrow>$content $html</fb:narrow>";
|
||||
+
|
||||
+ $fbml = "<fb:wide>$style $html</fb:wide>";
|
||||
+ $fbml .= "<fb:narrow>$style $html</fb:narrow>";
|
||||
hunk ./lib/facebookaction.php 81
|
||||
- $fbml_main = "<fb:narrow>$content $html</fb:narrow>";
|
||||
+ $fbml_main = "<fb:narrow>$style $html</fb:narrow>";
|
||||
hunk ./scripts/update_facebook.php 55
|
||||
+ $content = $notice->content;
|
||||
hunk ./scripts/update_facebook.php 57
|
||||
- update_status($fbuid, $notice);
|
||||
+ if (($flink->noticesync & FOREIGN_NOTICE_SEND) == FOREIGN_NOTICE_SEND) {
|
||||
hunk ./scripts/update_facebook.php 59
|
||||
+ // If it's not a reply, or if the user WANTS to send replies...
|
||||
+ if (!preg_match('/@[a-zA-Z0-9_]{1,15}\b/u', $content) ||
|
||||
+ (($flink->noticesync & FOREIGN_NOTICE_SEND_REPLY) == FOREIGN_NOTICE_SEND_REPLY)) {
|
||||
+ update_status($fbuid, $content);
|
||||
+ }
|
||||
+ }
|
||||
hunk ./scripts/update_facebook.php 73
|
||||
-function update_status($fbuid, $notice) {
|
||||
+function update_status($fbuid, $content) {
|
||||
hunk ./scripts/update_facebook.php 77
|
||||
-
|
||||
- $result = $facebook->api_client->users_setStatus($notice->content, $fbuid, false, true);
|
||||
-
|
||||
+ $result = $facebook->api_client->users_setStatus($content, $fbuid, false, true);
|
||||
hunk ./scripts/update_facebook.php 79
|
||||
-
|
||||
hunk ./scripts/update_facebook.php 81
|
||||
-
|
||||
|
@ -48,6 +48,10 @@ $current_time = time();
|
||||
|
||||
$notice = get_facebook_notices(get_last_updated());
|
||||
|
||||
print date('r', $current_time) . " Looking for notices to send to Facebook...\n";
|
||||
|
||||
$cnt = 0;
|
||||
|
||||
while($notice->fetch()) {
|
||||
|
||||
$flink = Foreign_link::getByUserID($notice->profile_id, 2);
|
||||
@ -60,12 +64,15 @@ while($notice->fetch()) {
|
||||
if (!preg_match('/@[a-zA-Z0-9_]{1,15}\b/u', $content) ||
|
||||
(($flink->noticesync & FOREIGN_NOTICE_SEND_REPLY) == FOREIGN_NOTICE_SEND_REPLY)) {
|
||||
update_status($fbuid, $content);
|
||||
$cnt++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
update_last_updated($current_time);
|
||||
|
||||
print "Sent $cnt notices to Facebook.\n";
|
||||
|
||||
exit(0);
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user