[Mapbender-commits] r5388 - trunk/mapbender/http/plugins

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Thu Jan 21 04:57:56 EST 2010


Author: christoph
Date: 2010-01-21 04:57:56 -0500 (Thu, 21 Jan 2010)
New Revision: 5388

Modified:
   trunk/mapbender/http/plugins/mb_twitter.php
   trunk/mapbender/http/plugins/mb_twitter_signin.js
Log:


Modified: trunk/mapbender/http/plugins/mb_twitter.php
===================================================================
--- trunk/mapbender/http/plugins/mb_twitter.php	2010-01-21 09:57:22 UTC (rev 5387)
+++ trunk/mapbender/http/plugins/mb_twitter.php	2010-01-21 09:57:56 UTC (rev 5388)
@@ -18,22 +18,46 @@
 $ajaxResponse = new AjaxResponse($_POST);
 
 switch ($ajaxResponse->getMethod()) {
-  case "signin" :
+	case "isSignedIn" :
+		echo Mapbender::session()->get("oauth_token");die;
+		if (Mapbender::session()->get("oauth_token") !== false) {
+			$ajaxResponse->setSuccess(true);
+			$ajaxResponse->setResult(array("signedIn" => true)); 
+			$ajaxResponse->setMessage(_mb("Signed in."));
+			$ajaxResponse->send();
+		}
 
-    if (!isset($consumerKey) || !isset($consumerSecret)) {
-      $ajaxResponse->setSuccess(false);
-      $ajaxResponse->setMessage(_mb("Element vars consumerKey and consumerSecret are not set. If you don't have them, get them from Twitter."));
-      $ajaxResponse->send();
-    }
-    $Twitter = new EpiTwitter($consumerKey, $consumerSecret);
-    $url = $Twitter->getAuthenticateUrl();
-    $ajaxResponse->setResult(array("url" => $url)); 
-    $ajaxResponse->setSuccess(true);
-    break;
-  default: 
-    $ajaxResponse->setSuccess(false);
-    $ajaxResponse->setMessage(_mb("An unknown error occured."));
-    break;
+		$ajaxResponse->setResult(array("signedIn" => false)); 
+		$ajaxResponse->setMessage(_mb("Not signed in."));
+		$ajaxResponse->setSuccess(true);
+		break;
+
+	case "signin" :
+	
+		if (!isset($consumerKey) || !isset($consumerSecret)) {
+			$ajaxResponse->setSuccess(false);
+			$ajaxResponse->setMessage(_mb("Element vars consumerKey and consumerSecret are not set. If you don't have them, get them from Twitter."));
+			$ajaxResponse->send();
+		}
+
+		$Twitter = new EpiTwitter($consumerKey, $consumerSecret);
+		try {
+			$url = $Twitter->getAuthenticateUrl();
+		}
+		catch (Exception $e) {
+			$ajaxResponse->setSuccess(false);
+			$ajaxResponse->setMessage(_mb("Could not connect to Twitter."));
+			$ajaxResponse->send();
+		}
+
+		$ajaxResponse->setResult(array("url" => $url)); 
+		$ajaxResponse->setSuccess(true);
+		break;
+
+	default: 
+		$ajaxResponse->setSuccess(false);
+		$ajaxResponse->setMessage(_mb("An unknown error occured."));
+		break;
 }
 $ajaxResponse->send();
 ?>

Modified: trunk/mapbender/http/plugins/mb_twitter_signin.js
===================================================================
--- trunk/mapbender/http/plugins/mb_twitter_signin.js	2010-01-21 09:57:22 UTC (rev 5387)
+++ trunk/mapbender/http/plugins/mb_twitter_signin.js	2010-01-21 09:57:56 UTC (rev 5388)
@@ -1,5 +1,76 @@
+/**
+ * Package: twitter_signin
+ *
+ * Description:
+ * Authenticate with Twitter
+ * 
+ * Files:
+ *  - http/plugins/mb_twitter_signin.js
+ *
+ * SQL:
+ * > INSERT INTO gui_element(fkey_gui_id, e_id, e_pos, e_public, e_comment, 
+ * > e_title, e_element, e_src, e_attributes, e_left, e_top, e_width, 
+ * > e_height, e_z_index, e_more_styles, e_content, e_closetag, e_js_file, 
+ * > e_mb_mod, e_target, e_requires, e_url) VALUES('<appId>','twitter_signin',
+ * > 1,1,'Authenticate with Twitter','Authenticate with Twitter','img',
+ * > '../img/twitter_signin.png','',900,10,NULL ,NULL ,NULL ,'','','',
+ * > '../plugins/mb_twitter_signin.js','','','','');
+ * >
+ * > INSERT INTO gui_element_vars(fkey_gui_id, fkey_e_id, var_name, 
+ * > var_value, context, var_type) VALUES('<appId>', 'twitter_signin', 
+ * > 'consumerKey', '<your key>', '' ,'php_var');
+ * >
+ * > INSERT INTO gui_element_vars(fkey_gui_id, fkey_e_id, var_name, 
+ * > var_value, context, var_type) VALUES('<appId>', 'twitter_signin', 
+ * > 'consumerSecret', '<your secret>', 
+ * > '' ,'php_var');
+ * 
+ * Help:
+ * http://www.mapbender.org/Twitter_signin
+ *
+ * Maintainer:
+ * http://www.mapbender.org/User:Christoph_Baudson
+ * 
+ * Parameters:
+ * consumerKey      - your consumer key from Twitter (PHP var)
+ * consumerSecret   - your consumer secret from Twitter (PHP var)
+ *
+ * License:
+ * Copyright (c) 2009, Open Source Geospatial Foundation
+ * This program is dual licensed under the GNU General Public License 
+ * and Simplified BSD license.  
+ * http://svn.osgeo.org/mapbender/trunk/mapbender/license/license.txt
+ */
+
 var $this = $(this);
+
+$this.mapbender({
+	signedIn: false
+});
+
 Mapbender.events.init.register(function () {
+
+	// check if signed in
+	var req = new Mapbender.Ajax.Request({
+		url: "../plugins/mb_twitter.php",
+		method: "isSignedIn",
+		parameters: {
+		},
+		callback: function (obj, result, message) {
+			if (!result) {
+				alert(message);
+				return;
+			}
+			if (obj.signedIn) {
+				alert(message);
+			}
+			$this.mapbender("signedIn", obj.signedIn);
+			alert($this.mapbender("signedIn"));
+		}
+	});
+	req.send();
+	
+
 	$this.click(function () {
 		var req = new Mapbender.Ajax.Request({
 			url: "../plugins/mb_twitter.php",



More information about the Mapbender_commits mailing list