Permalink
Browse files

Merge remote branch 'upstream/master'

Conflicts:
	README
	lib/sfFacebook.class.php
  • Loading branch information...
2 parents 8343d53 + f179e9a commit 53cfdcdffdec597bd4afd654f57a050c8dad574b @benja-M-1 benja-M-1 committed Oct 27, 2010
View
128 README
@@ -1,5 +1,5 @@
sfFacebookConnectPlugin
-================
+=======================
The sfFacebookConnect plugin :
@@ -13,6 +13,7 @@ Installation
* Install the plugin : the __git__ and recommanded way
+
$ git submodule add http://github.com/fabriceb/sfFacebookConnectPlugin.git plugins/sfFacebookConnectPlugin
$ cd plugins/sfFacebookConnectPlugin
$ git submodule init # add the facebook php-sdk as a submodule
@@ -21,82 +22,77 @@ Installation
# or all in one
$ git submodule add --recursive http://github.com/fabriceb/sfFacebookConnectPlugin.git plugins/sfFacebookConnectPlugin
- * Install the plugin : the depreacated way.
-
- $ svn co http://svn.symfony-project.com/plugins/sfFacebookConnectPlugin/trunk sfFacebookConnectPlugin
-
* Create your application on Facebook
http://www.facebook.com/developers/
- * Configure your app.yml file with all the correct settings
-
- # default values
- all:
- facebook:
- api_key: xxx
- api_secret: xxx
- api_id: xxx
- redirect_after_connect: false
- redirect_after_connect_url: ''
- connect_signin_url: 'sfFacebookConnectAuth/signin'
- app_url: '/my-app' # the facebook application canvas url
- guard_adapter: ~ # to customise a guard adapter
- js_framework: none # none, jQuery or prototype.
+ * Configure your `app.yml` file with all the correct settings
+
+ [yml]
+ # default values
+ all:
+ facebook:
+ api_key: xxx
+ api_secret: xxx
+ api_id: xxx
+ redirect_after_connect: false
+ redirect_after_connect_url: ''
+ connect_signin_url: 'sfFacebookConnectAuth/signin'
+ app_url: '/my-app' # the facebook application canvas url
+ guard_adapter: ~ # to customise a guard adapter
+ js_framework: none # none, jQuery or prototype.
- # It is highly recommended to use a js framework if you want a correct experience in IE
- sf_guard_plugin:
- profile_class: sfGuardUserProfile
- profile_field_name: user_id
- profile_facebook_uid_name: facebook_uid
- profile_email_name: email
- profile_email_hash_name: email_hash
+ # It is highly recommended to use a js framework if you want a correct experience in IE
+ sf_guard_plugin:
+ profile_class: sfGuardUserProfile
+ profile_field_name: user_id
+ profile_facebook_uid_name: facebook_uid
+ profile_email_name: email
+ profile_email_hash_name: email_hash
- facebook_connect:
- load_routing: true
- user_permissions: []
-
+ facebook_connect:
+ load_routing: true
+ user_permissions: []
- * Modify your sfGaurdUserProfile schema to add the 3 new columns needed
+ * Modify your `sfGaurdUserProfile` schema to add the 3 new columns needed
+ [yml]
# Doctrine schema sample
- sfGuardUserProfile:
- tableName: sf_guard_user_profile
- columns:
- user_id: integer(4)
- first_name: varchar(20)
- last_name: varchar(20)
- facebook_uid: integer(4)
- email: varchar(255)
- email_hash: varchar(255)
- relations:
- sfGuardUser:
- type: one
- foreignType: one
- class: sfGuardUser
- local: user_id
- foreign: id
- onDelete: cascade
- foreignAlias: Profile
-
-
- * Enable the auth module in your `settings.yml`: sfFacebookConnectAuth
-
- [php]
- all:
- .settings:
- enabled_modules: [default, sfFacebookConnectAuth]
-
- * Optional: enable the sample module in your `settings.yml`: sfFacebookConnectDemo
-
- [php]
- all:
- .settings:
- enabled_modules: [default, sfFacebookConnectAuth, sfFacebookConnectDemo]
-
- * Eventually make myUser.class.php extend sfFacebookUser
+ sfGuardUserProfile:
+ tableName: sf_guard_user_profile
+ columns:
+ user_id: integer(4)
+ first_name: varchar(20)
+ last_name: varchar(20)
+ facebook_uid: integer(4)
+ email: varchar(255)
+ email_hash: varchar(255)
+ relations:
+ sfGuardUser:
+ type: one
+ foreignType: one
+ class: sfGuardUser
+ local: user_id
+ foreign: id
+ onDelete: cascade
+ foreignAlias: Profile
+
+
+ * Enable the auth module in your `settings.yml`: `sfFacebookConnectAuth`
+
+ [php]
+ all:
+ .settings:
+ enabled_modules: [default, sfFacebookConnectAuth]
+
+ * (Optional) Enable the sample module in your `settings.yml`: `sfFacebookConnectDemo`
+
+ [php]
+ all:
+ .settings:
+ enabled_modules: [default, sfFacebookConnectAuth, sfFacebookConnectDemo]
* Eventually use the sfFacebook filters
View
@@ -0,0 +1,59 @@
+<?php
+/**
+ * Generates and updates a package.xml file
+ * dependencies : PEAR_PackageFileManager 1.6+
+ * @author Laurent Bachelier <laurent@bachelier.name>
+ */
+
+/**
+ * INSTALL on Ubuntu 10.10
+ * sudo pear config-set preferred_state beta
+ * sudo pear install --alldeps PEAR_PackageFileManager
+ * sudo pear config-set preferred_state stable
+ */
+
+error_reporting(E_ALL); // no E_STRICT
+require_once('PEAR/PackageFileManager2.php');
+PEAR::setErrorHandling(PEAR_ERROR_DIE);
+
+$packagexml = new PEAR_PackageFileManager2;
+$packagexml->setOptions(
+array('baseinstalldir' => '/',
+ 'packagedirectory' => dirname(__FILE__),
+ 'filelistgenerator' => 'file',
+ 'ignore' => array('TODO'),
+ 'exceptions' => array('README' => 'doc', 'LICENSE' => 'doc'),
+));
+
+$packagexml->setPackage('sfFacebookConnectPlugin');
+$packagexml->setSummary('Add easily Facebook connect to your symfony website and/or develop IFrame-FBML agnostic Facebook applications.');
+$packagexml->setDescription('The sfFacebookConnectPlugin provides multiples functionalities geared both at making Facebook Connect integration in a symfony website easy and also help develop Facebook applications. This is achieved by smoothly connecting sfGuard (Doctrine AND Propel) with Facebook and helping developers program without worrying about whether the application is FBML or IFrame/Facebook Connect.');
+$packagexml->setChannel('plugins.symfony-project.org');
+$packagexml->addMaintainer('lead', 'fabriceb', 'Fabrice Bernhard', 'fabriceb@theodo.fr');
+$packagexml->addMaintainer('developer', 'oncletom', 'Thomas Parisot', 'thomas@oncle-tom.net');
+$packagexml->addMaintainer('developer', 'dalexandre', 'Damien Alexandre', 'dalexandre@clever-age.com');
+$packagexml->addMaintainer('developer', 'benjaming', 'Benjamin Grandfond', 'benjaming@theodo.fr');
+
+$packagexml->setLicense('MIT License', 'http://www.symfony-project.org/license');
+
+// This will ADD a changelog entry to an existing package.xml
+$packagexml->setAPIVersion('1.1.1');
+$packagexml->setReleaseVersion('1.1.1');
+$packagexml->setNotes('Symfony 1.4 officialy compatible version');
+
+$packagexml->setReleaseStability('stable');
+$packagexml->setAPIStability('stable');
+$packagexml->addRelease();
+$packagexml->setPackageType('php');
+$packagexml->setPhpDep('5.2.0');
+$packagexml->setPearinstallerDep('1.4.1');
+
+// Supported versions of Symfony
+$packagexml->addPackageDepWithChannel('required', 'symfony', 'pear.symfony-project.com', '1.0.0', '1.5.0');
+
+$packagexml->generateContents(); // Add the files
+
+if (isset($_GET['make']) || (isset($_SERVER['argv']) && @$_SERVER['argv'][1] == 'make'))
+ $packagexml->writePackageFile();
+else
+ $packagexml->debugPackageFile();
View
@@ -15,6 +15,7 @@ class sfFacebook
protected static
$is_js_loaded = false;
+
public static function getFacebookCookie()
{
$app_id = self::getApiId();
@@ -47,6 +48,35 @@ public static function getFacebookCookie()
* @since 2010-05-12 Benjamin Grandfond <benjaming@theodo.fr>: new Facebook php-sdk
* @since 2010-09-03 Benjamin Grandfond : correct the parameters sent to the facebook class constructor
*/
+
+
+ public static function getFacebookCookie()
+ {
+ $app_id = self::getApiKey();
+ $application_secret = self::getApiSecret();
+ $args = array();
+ if (!isset($_COOKIE['fbs_' . $app_id]))
+ {
+ return null;
+ }
+ parse_str(trim($_COOKIE['fbs_' . $app_id], '\\"'), $args);
+ ksort($args);
+ $payload = '';
+ foreach ($args as $key => $value)
+ {
+ if ($key != 'sig')
+ {
+ $payload .= $key . '=' . $value;
+ }
+ }
+ if (md5($payload . $application_secret) != $args['sig'])
+ {
+ return null;
+ }
+ return $args;
+ }
+
+
public static function getFacebookClient()
{
if (self::$client === null)
@@ -433,7 +463,8 @@ public static function getLocale($culture = null)
$culture_to_locale = array(
'fr' => 'fr_FR',
'en' => 'en_US',
- 'de' => 'de_DE'
+ 'de' => 'de_DE',
+ 'it' => 'it_IT',
);
return array_key_exists($culture, $culture_to_locale) ? $culture_to_locale[$culture] : $culture;
@@ -1,38 +0,0 @@
-<?php
-
-/**
- *
- * @author fabriceb
- * @package sfFacebookConnectPlugin
- * @since Aug 24, 2009
- *
- */
-class sfFacebookApplicationFilter extends sfFilter
-{
-
- public function execute ($filterChain)
- {
- if ($this->isFirstCall() && !$this->getContext()->getUser()->isAuthenticated())
- {
- if (sfConfig::get('sf_logging_enabled'))
- {
- sfContext::getInstance()->getLogger()->info('{sfFacebookApplicationFilter} Trying to authenticate the current user');
- }
- $sfGuardUser = sfFacebook::getSfGuardUserByFacebookSession();
- if ($sfGuardUser)
- {
- $this->getContext()->getUser()->signIn($sfGuardUser, true);
- $this->getContext()->getUser()->setCurrentFacebookUid(sfFacebook::getGuardAdapter()->getUserProfileProperty($sfGuardUser,'facebook_uid'));
- }
- else
- {
- if (sfConfig::get('sf_logging_enabled'))
- {
- sfContext::getInstance()->getLogger()->info('{sfFacebookApplicationFilter} No user found');
- }
- }
- }
-
- $filterChain->execute();
- }
-}
@@ -1,28 +1,29 @@
<?php
-/**
- *
+/**
+ *
* Based on sfGuardRememberMeFilter
*
* Place this filter before the security filter in filters.yml e.g.
* ...
- * facebook_connect_remember_me:
- * class: sfFacebookConnectRememberMeFilter
+ * facebook_connect:
+ * class: sfFacebookAutoConnectFilter
* security: ~
* ...
*
+ * This filter will auto-connect you looking at your Facebook session.
+ *
* @package sfFacebookConnectPlugin
* @author fabriceb
*/
-class sfFacebookConnectRememberMeFilter extends sfFilter
+class sfFacebookAutoConnectFilter extends sfFilter
{
/**
* @see sfFilter
*/
public function execute($filterChain)
{
-
if ($this->isFirstCall() && $this->context->getUser()->isAnonymous())
{
$sfGuardUser = sfFacebook::getSfGuardUserByFacebookSession();
@@ -75,7 +75,7 @@ public static function getSfGuardUserByFacebookEmail($facebook_uid, $isActive =
// Since we looked up by email_hash, save the fb_uid
// so we can look up directly next time
sfFacebook::getGuardAdapter()->setUserFacebookUid($sfGuardUser, $facebook_uid);
- self::newSfGuardConnectionHook(&$sfGuardUser, $facebook_uid);
+ self::newSfGuardConnectionHook($sfGuardUser, $facebook_uid);
$sfGuardUser->getProfile()->save();
}
@@ -106,7 +106,7 @@ public static function newSfGuardConnectionHook($sfGuardUser, $facebook_uid)
{
foreach (sfMixer::getCallables('sfFacebookConnect:newSfGuardConnection:preSave') as $callable)
{
- call_user_func($callable, &$sfGuardUser, $facebook_uid);
+ call_user_func($callable, $sfGuardUser, $facebook_uid);
}
}
}
Oops, something went wrong.

0 comments on commit 53cfdcd

Please sign in to comment.