]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
trac750 Use Facebook dialogs for success and error messages during initial setup...
authorZach Copley <zach@controlyourself.ca>
Mon, 8 Dec 2008 01:54:12 +0000 (20:54 -0500)
committerZach Copley <zach@controlyourself.ca>
Mon, 8 Dec 2008 01:54:12 +0000 (20:54 -0500)
darcs-hash:20081208015412-7b5ce-c899a3b743621f7d003b93f383b78a2c8ba9fb52.gz

actions/facebookhome.php
lib/facebookaction.php

index b261e6a8c3634eff82cd2592b99a431300c4284b..8ee2d4cd36812392931078833652f4b86d9ebfc6 100644 (file)
@@ -34,7 +34,6 @@ class FacebookhomeAction extends FacebookAction {
                $user = null;
 
                $facebook = $this->get_facebook();
-
                $fbuid = $facebook->require_login();
 
                # check to see whether there's already a Facebook link for this user
@@ -42,21 +41,12 @@ class FacebookhomeAction extends FacebookAction {
 
                if ($flink) {
 
-                       $this->display($facebook, $fbuid);
-
                        $user = $flink->getUser();
-
-
-                       $notice = $user->getCurrentNotice();
-
-                       echo $this->show_notices($user);
-
-
-                       $this->update_profile_box($facebook, $fbuid, $user);
-
+                       $this->show_home($facebook, $fbuid, $user);
 
                } else {
 
+                       # Make the user put in her Laconica creds
                        $nickname = common_canonical_nickname($this->trimmed('nickname'));
                        $password = $this->arg('password');
 
@@ -64,12 +54,11 @@ class FacebookhomeAction extends FacebookAction {
 
                                if (common_check_user($nickname, $password)) {
 
-                                       echo '<h2>Successful authentication!</h2>';
 
                                        $user = User::staticGet('nickname', $nickname);
 
                                        if (!$user) {
-                                               echo '<h2>Couldn\'t get user!</h2>';
+                                               echo '<fb:error message="Coudln\'t get user!" />';
                                                $this->show_login_form();
                                        }
 
@@ -84,16 +73,15 @@ class FacebookhomeAction extends FacebookAction {
                                        $flink_id = $flink->insert();
 
                                        if ($flink_id) {
-                                               echo '<h2>Successfully made Identi.ca -> Facebook link</h2>';
+                                               echo '<fb:success message="You can now use the Identi.ca from Facebook!" />';
                                        }
 
-                                       $this->display($facebook, $fbuid);
+                                       $this->show_home($facebook, $fbuid, $user);
 
                                        return;
                                } else {
-                                       echo '<h2>Fail!</h2>';
+                                       echo '<fb:error message="Incorrect username or password." />';
                                }
-
                        }
 
                        $this->show_login_form();
@@ -101,17 +89,16 @@ class FacebookhomeAction extends FacebookAction {
 
        }
 
-       function display($facebook, $fbuid) {
+       function show_home($facebook, $fbuid, $user) {
 
                $this->show_header('Home');
 
-               // Greet the currently logged-in user!
-               echo "<p>Hello, <fb:name uid=\"$fbuid\" useyou=\"false\" />!</p>";
+               echo $this->show_notices($user);
+               $this->update_profile_box($facebook, $fbuid, $user);
 
                $this->show_footer();
        }
 
-
        function show_notices($user) {
 
                $page = $this->trimmed('page');
@@ -142,58 +129,4 @@ class FacebookhomeAction extends FacebookAction {
 
        }
 
-
-
-       function update_profile_box($facebook, $fbuid, $user) {
-
-               $notice = $user->getCurrentNotice();
-
-               # Need to include CSS for styling the Profile box
-
-               $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>';
-
-               $html = $this->render_notice($notice);
-
-               $fbml = "<fb:wide>$content $html</fb:wide>";
-               $fbml .= "<fb:narrow>$content $html</fb:narrow>";
-
-               $fbml_main = "<fb:narrow>$content $html</fb:narrow>";
-
-               $facebook->api_client->profile_setFBML(NULL, $fbuid, $fbml, NULL, NULL, $fbml_main);
-
-       }
-
 }
index 8872934aaec1ba10d3d038170fa05c8908dc5e27..d5f0adbb88d3e17fdc386e328758f257c9d95708 100644 (file)
@@ -33,6 +33,56 @@ class FacebookAction extends Action {
                return new Facebook($apikey, $secret);
        }
 
+       function update_profile_box($facebook, $fbuid, $user) {
+
+               $notice = $user->getCurrentNotice();
+
+               # Need to include inline CSS for styling the Profile box
+
+               $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>';
+
+               $html = $this->render_notice($notice);
+
+               $fbml = "<fb:wide>$content $html</fb:wide>";
+               $fbml .= "<fb:narrow>$content $html</fb:narrow>";
+
+               $fbml_main = "<fb:narrow>$content $html</fb:narrow>";
+
+               $facebook->api_client->profile_setFBML(NULL, $fbuid, $fbml, NULL, NULL, $fbml_main);
+       }
 
        # Display methods
 
@@ -180,14 +230,14 @@ class FacebookAction extends Action {
 
                return $html;
        }
-       
+
        function pagination($have_before, $have_after, $page, $fbaction, $args=NULL) {
 
                $html = '';
 
                if ($have_before || $have_after) {
                        $html = '<div id="pagination">';
-                       $html .'<ul id="nav_pagination">';                      
+                       $html .'<ul id="nav_pagination">';
                }
 
                if ($have_before) {
@@ -225,5 +275,5 @@ class FacebookAction extends Action {
 
                return "$fbaction?${extra}";
        }
-       
+
 }