diff options
author | Zach Copley <zach@controlyourself.ca> | 2009-01-04 23:02:12 -0500 |
---|---|---|
committer | Zach Copley <zach@controlyourself.ca> | 2009-01-04 23:02:12 -0500 |
commit | e0fbf02bbf516db10070bddaabbbaea31d336cda (patch) | |
tree | c44b562a6a8bb73766884f2539928b2fb6209729 /_darcs/pristine/actions | |
parent | fd6f9b9d7622f280f92810770deb217eb7301c14 (diff) |
trac750 configurable sync flags for Facebook app (noticesync, replysync)
darcs-hash:20090105040212-7b5ce-37f6195649dc673241e4566a93183b13e428d98f.gz
Diffstat (limited to '_darcs/pristine/actions')
-rw-r--r-- | _darcs/pristine/actions/facebookhome.php | 3 | ||||
-rw-r--r-- | _darcs/pristine/actions/facebooksettings.php | 66 | ||||
-rw-r--r-- | _darcs/pristine/actions/twittersettings.php | 26 |
3 files changed, 62 insertions, 33 deletions
diff --git a/_darcs/pristine/actions/facebookhome.php b/_darcs/pristine/actions/facebookhome.php index a23d1aa07..069ea5e75 100644 --- a/_darcs/pristine/actions/facebookhome.php +++ b/_darcs/pristine/actions/facebookhome.php @@ -70,8 +70,7 @@ class FacebookhomeAction extends FacebookAction $flink->foreign_id = $fbuid; $flink->service = 2; # Facebook $flink->created = common_sql_now(); - - # $this->set_flags($flink, $noticesync, $replysync, $friendsync); + $flink->set_flags(true, false, false); $flink_id = $flink->insert(); diff --git a/_darcs/pristine/actions/facebooksettings.php b/_darcs/pristine/actions/facebooksettings.php index 17812850c..469bcfc45 100644 --- a/_darcs/pristine/actions/facebooksettings.php +++ b/_darcs/pristine/actions/facebooksettings.php @@ -28,30 +28,82 @@ class FacebooksettingsAction extends FacebookAction { parent::handle($args); - $this->display(); + if ($this->arg('save')) { + $this->save_settings(); + } else { + $this->show_form(); + } } - function display() - { + + function save_settings() { + + $noticesync = $this->arg('noticesync'); + $replysync = $this->arg('replysync'); $facebook = get_facebook(); + $fbuid = $facebook->require_login(); + + $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." />'; + } + + $this->show_form(); + + } + + function show_form() { + $facebook = get_facebook(); $fbuid = $facebook->require_login(); + $flink = Foreign_link::getByForeignID($fbuid, 2); // 2 == Facebook + + $this->show_header('Settings'); + $fbml = '<fb:if-section-not-added section="profile">' - .'<h2>Add an Identi.ca box to your profile!</h2>' + .'<h2>Add an Identi.ca box to my profile</h2>' .'<fb:add-section-button section="profile"/>' .'</fb:if-section-not-added>'; - $fbml .= '<fb:prompt-permission perms="status_update"><h2>Allow Identi.ca to update my Facebook status</h2></fb:prompt-permission>'; - $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>'; echo $fbml; $this->show_footer(); - } } diff --git a/_darcs/pristine/actions/twittersettings.php b/_darcs/pristine/actions/twittersettings.php index 26dede0ac..d66427339 100644 --- a/_darcs/pristine/actions/twittersettings.php +++ b/_darcs/pristine/actions/twittersettings.php @@ -251,7 +251,7 @@ class TwittersettingsAction extends SettingsAction $flink->credentials = $password; $flink->created = common_sql_now(); - $this->set_flags($flink, $noticesync, $replysync, $friendsync); + $flink->set_flags($noticesync, $replysync, $friendsync); $flink_id = $flink->insert(); @@ -323,7 +323,7 @@ class TwittersettingsAction extends SettingsAction $screen_name = $fuser->nickname; $original = clone($flink); - $this->set_flags($flink, $noticesync, $replysync, $friendsync); + $flink->set_flags($noticesync, $replysync, $friendsync); $result = $flink->update($original); if ($result === false) { @@ -363,27 +363,5 @@ class TwittersettingsAction extends SettingsAction return false; } - 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; - } }
\ No newline at end of file |