diff --git a/www/.htaccess b/www/.htaccess index d596e62..983ab3a 100644 --- a/www/.htaccess +++ b/www/.htaccess @@ -1,5 +1,5 @@ RewriteEngine on -RewriteBase /usuarios/ +RewriteBase /profind/ # if a directory or a file exists, use it directly RewriteCond %{REQUEST_FILENAME} !-f diff --git a/www/protected/config/mode_development.php b/www/protected/config/mode_development.php index aa2c278..dc4facc 100644 --- a/www/protected/config/mode_development.php +++ b/www/protected/config/mode_development.php @@ -23,29 +23,6 @@ $configSpecific = array( 'class' => 'system.gii.GiiModule', 'password' => 'password', ), - 'socialConnect' => array( - 'callbackUrl' => 'site/callback', - 'debug_mode' => true, - 'debug_file' => 'socialconnect.log', - 'providers' => array( - 'facebook' => array( - 'enabled' => true, - 'keys' => array('id' => '', 'secret' => ''), - 'scope' => 'email,publish_stream', - ), - 'twitter' => array( - 'enabled' => true, - 'keys' => array( - 'key' => '0aBDNeQOFTPMxHb7TMjHlA', - 'secret' => 'qjVCKdLjRngBUpGnbPw3NXRiIK1BdJWYCnHhZ4pClXk' - ) - ), - 'linkedin' => array( - 'enabled' => true, - 'keys' => array('key' => '', 'secret' => '') - ), - ) - ), ), // Application components @@ -75,7 +52,7 @@ $configSpecific = array( 'socialConnect' => array( 'class' => 'application.extensions.yii-socialconnect.YiiSocialConnect', 'callbackUrl' => 'site/callback', - 'debug_mode' => true, + 'debug_mode' => false, 'debug_file' => dirname(__FILE__) . '/../runtime/socialconnect.log', 'providers' => array( 'Facebook' => array( @@ -90,9 +67,12 @@ $configSpecific = array( 'secret' => 'qjVCKdLjRngBUpGnbPw3NXRiIK1BdJWYCnHhZ4pClXk' ) ), - 'Linkedin' => array( + 'LinkedIn' => array( 'enabled' => true, - 'keys' => array('key' => '', 'secret' => '') + 'keys' => array( + 'key' => 'zgiloy0zgkcw', + 'secret' => 'x0WGj5CvjDlWsLC9' + ) ), ) ), diff --git a/www/protected/controllers/EmpresaController.php b/www/protected/controllers/EmpresaController.php index 9c3cc86..c705f07 100644 --- a/www/protected/controllers/EmpresaController.php +++ b/www/protected/controllers/EmpresaController.php @@ -32,26 +32,39 @@ class EmpresaController extends Controller { * Updates a particular model. * If update is successful, the browser will be redirected to the 'view' page. * @param integer $id the ID of the model to be updated + * @param string $provider */ - public function actionModificar($id) { + public function actionModificar($id, $provider = '') { if ($id != Yii::app()->user->id_empresa) throw new CHttpException(404, Yii::t('profind', 'La página solicitada no existe.')); - $model = $this->loadModel($id); + if (($provider != '') && (!isset($_POST['Empresa']))) { + switch ($provider) { + case 'Twitter': + case 'Facebook': + case 'LinkedIn': + $empresa = $this->loadModelwithSocialData($id, $provider); + break; + default: + throw new CHttpException(404, Yii::t('profind', 'La página solicitada no existe.')); + } + } + else + $empresa = $this->loadModel($id); // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); if (isset($_POST['Empresa'])) { - $model->attributes = $_POST['Empresa']; - if ($model->save()) { + $empresa->attributes = $_POST['Empresa']; + if ($empresa->save()) { Yii::app()->user->setFlash('success', Yii::t('profind', 'Se ha actualizado los datos de la empresa')); - $this->redirect(array('modificar', 'id' => $model->id)); + $this->redirect(array('modificar', 'id' => $empresa->id)); } } $this->render('modificar', array( - 'model' => $model, + 'model' => $empresa, )); } @@ -74,6 +87,38 @@ class EmpresaController extends Controller { return $model; } + public function loadModelwithSocialData($id, $provider) { + $empresa = $this->loadModel($id); + + if (!Yii::app()->socialConnect->loadUserProfile($provider)) { + throw new CHttpException( + Yii::app()->socialConnect->errorCode, + Yii::t('profind', Yii::app()->socialConnect->errorMessage) + ); + } + + $profile = Yii::app()->socialConnect->userProfile; + + Yii::log(CVarDumper::dumpAsString($profile)); + + $empresa->nombre = $profile->displayName; + $empresa->pagina_web = $profile->webSiteURL; + $empresa->email = $profile->email; + $empresa->descripcion = $profile->description; + + switch ($provider) { + case 'Twitter': + $empresa->direccion = $profile->region; + break; + case 'Facebook': + case 'LinkedIn': + $empresa->direccion = $profile->city; + break; + } + + return $empresa; + } + /** * Performs the AJAX validation. * @param CModel the model to be validated diff --git a/www/protected/controllers/UsuarioController.php b/www/protected/controllers/UsuarioController.php index e1963d2..c6f3adf 100644 --- a/www/protected/controllers/UsuarioController.php +++ b/www/protected/controllers/UsuarioController.php @@ -41,16 +41,16 @@ class UsuarioController extends Controller { if (($provider != '') && (!isset($_POST['Usuario']))) { switch ($provider) { - case 'twitter': - case 'facebook': - case 'linkedin': + case 'Twitter': + case 'Facebook': + case 'LinkedIn': $usuario = $this->loadModelwithSocialData($id, $provider); break; default: throw new CHttpException(404, Yii::t('profind', 'La página solicitada no existe.')); } } - else + else $usuario = $this->loadModel($id); // Uncomment the following line if AJAX validation is needed @@ -80,15 +80,31 @@ class UsuarioController extends Controller { public function loadModelwithSocialData($id, $provider) { $usuario = $this->loadModel($id); - - $profile = Yii::app()->socialConnect->getUserProfile($provider); - - if ($twitter) { - $usuario->email = $twitter['email']; - $usuario->nombre = $twitter['displayName']; - $usuario->apellidos = $twitter['displayName']; - $usuario->descripcion = $twitter['photoURL']; + + if (!Yii::app()->socialConnect->loadUserProfile($provider)) { + throw new CHttpException( + Yii::app()->socialConnect->errorCode, + Yii::t('profind', Yii::app()->socialConnect->errorMessage) + ); } + + $profile = Yii::app()->socialConnect->userProfile; + + //$usuario->email = $profile->email; <-- el email no lo cambio + $usuario->nombre = $profile->firstName; + $usuario->apellidos = $profile->lastName; + $usuario->descripcion = $profile->description; + + switch ($provider) { + case 'Twitter': + $usuario->localidad = $profile->region; + break; + case 'Facebook': + case 'LinkedIn': + $usuario->localidad = $profile->city; + break; + } + return $usuario; } diff --git a/www/protected/extensions/yii-socialconnect/YiiSocialConnect.php b/www/protected/extensions/yii-socialconnect/YiiSocialConnect.php index 2c653d7..009dfb3 100644 --- a/www/protected/extensions/yii-socialconnect/YiiSocialConnect.php +++ b/www/protected/extensions/yii-socialconnect/YiiSocialConnect.php @@ -38,18 +38,18 @@ class YiiSocialConnect extends CApplicationComponent { * @var integer código de error. Si hay algún error, el código de error será distinto de 0. */ public $errorCode = self::ERROR_UNSPECIFIED; - + /** * @var */ public $userProfile = NULL; - + /** * Inicialización del componente */ public function init() { $this->registerScripts(); - parent::init(); + parent::init(); } /** @@ -72,14 +72,16 @@ class YiiSocialConnect extends CApplicationComponent { * @return array configuración */ public function getConfig() { - - return array( + $config = array( 'baseUrl' => Yii::app()->getBaseUrl(true), 'base_url' => Yii::app()->createAbsoluteUrl($this->callbackUrl), // URL for Hybrid_Auth callback 'providers' => $this->providers, - 'debug_file' => $this->debug_file, - 'debug_mode' => $this->debug_mode, ); + if ($this->debug_mode) { + $config['debug_file'] = $this->debug_file; + $config['debug_mode'] = $this->debug_mode; + } + return $config; } public function callback() { @@ -139,10 +141,10 @@ class YiiSocialConnect extends CApplicationComponent { } } } - + if ($this->errorCode) Yii::log($this->getErrorMessage(), CLogger::LEVEL_ERROR); - + return !$this->errorCode; } @@ -183,6 +185,7 @@ class YiiSocialConnect extends CApplicationComponent { } return $message; } + } ?> diff --git a/www/protected/extensions/yii-socialconnect/vendors/CHANGELOG b/www/protected/extensions/yii-socialconnect/vendors/CHANGELOG new file mode 100644 index 0000000..552f275 --- /dev/null +++ b/www/protected/extensions/yii-socialconnect/vendors/CHANGELOG @@ -0,0 +1,64 @@ +Hybridauth Change log +===================== + +2.1.0 - 04 aug 2012 + Yahoo! provider adapter is now based on OAuth1 protocol (by Lukasz Koprowski) + Windows Live provider adapter is now based on OAuth2 protocol (by Lukasz Koprowski) + Yahoo! and Google openid based are now part of the "additional providers package" + Add proxy config for providers API (by fedetorre) + Fix Hybrid_Providers_Google::getUserContacts() + Fix Twitter user's profile url + Fix the user profile url on Hybrid_Providers_Facebook::getUserActivity() + ... + + + +2.0.11 - 25 jan 2012 + Fix a bug with Twitter update status + Add a way to specify adapters and wrappers from config + Added emailVerified property to profile object. + Added ability to pass display type to Facebook SDK. + Refactored endpoind + Add user contacts list for Google Hybrid_Providers_Google::getUserContacts() + Add Hybrid_Auth::getProviders() to return array listing all enabled providers as well as a flag if you are connected. + + + +2.0.10 - 05 dec 2011 + Fix a bug with Facebook update status setUserStatus() + Fix a bug with linkedin get contacts list getUserContacts() + Fix refresh token issue with oauth2 client + Remove https://www.googleapis.com/auth/plus.me from the default Google scope + Fix an issue with openid identifier verification + Fix an issue where a user cancel the auth it will persist for some providers + Another numbers of bug fixes and improvments + + + +2.0.9 - 24 nov 2011 + Move Google to work with OAuth 2 protocol. + Get back Foursquare and AOL to library core as supported networks + Add 2 new examples "Sign-in/Sign-up Users" and "Basic Facebook integration" + Fix a bug with linkedin update status setUserStatus() + + + +2.0.8 - 18 nov 2011 + Add an auto insaller to make life a bit easier. + Change the configuration file name from hybridauth.php to config.php + Setting facebook scope from the configuration, now override the default requested scope + Fix a bug with twitter update status setUserStatus() + Fix a bug with logoutAllProviders() + Hubrid_Auth_Activity::$date return now a timestamp across supproted social networks + Introduce the refresh_token as its needed for some providers + fixed some minor issues and improved bunch of other stuff + Thanks for KVC, RB Lin and danhstevens! + + + +2.0.7 - 12 oct 2011 + Add some generic functions: Hybrid_Provider_Adapter::getUserContacts(), Hybrid_Provider_Adapter::setUserStatus() and Hybrid_Provider_Adapter::getUserActivity() to Facebook, MySpace, Twitter, Identica and LinkedIn. + Add a generic function to logout all connected provider at once Hybrid_Auth::logoutAllProviders() + Correct a bug with Hybrid_Auth::getCurrentUrl() + Split HybridAuth into 2 packages. i) a core library which come with 8 major providers by default, ii) the others one which containt some additional providers + fixed some minors issues and improved some stuff and whatnot diff --git a/www/protected/extensions/yii-socialconnect/vendors/Hybrid/Auth.php b/www/protected/extensions/yii-socialconnect/vendors/Hybrid/Auth.php index 7ca4a0c..5b076d1 100644 --- a/www/protected/extensions/yii-socialconnect/vendors/Hybrid/Auth.php +++ b/www/protected/extensions/yii-socialconnect/vendors/Hybrid/Auth.php @@ -14,7 +14,7 @@ */ class Hybrid_Auth { - public static $version = "2.1.0"; + public static $version = "2.1.0-dev"; public static $config = array(); diff --git a/www/protected/extensions/yii-socialconnect/vendors/Hybrid/Logger.php b/www/protected/extensions/yii-socialconnect/vendors/Hybrid/Logger.php index 8ec18d9..bdc95ca 100644 --- a/www/protected/extensions/yii-socialconnect/vendors/Hybrid/Logger.php +++ b/www/protected/extensions/yii-socialconnect/vendors/Hybrid/Logger.php @@ -15,7 +15,7 @@ class Hybrid_Logger // if debug mode is set to true, then check for the writable log file if ( Hybrid_Auth::$config["debug_mode"] ){ if ( ! file_exists( Hybrid_Auth::$config["debug_file"] ) ){ - throw new Exception( "'debug_mode' is set to 'true', but no log file path 'debug_file' given.", 1 ); + throw new Exception( "'debug_mode' is set to 'true', but the file " . Hybrid_Auth::$config['debug_file'] . " in 'debug_file' does not exit.", 1 ); } if ( ! is_writable( Hybrid_Auth::$config["debug_file"] ) ){ diff --git a/www/protected/extensions/yii-socialconnect/vendors/Hybrid/Providers/Facebook.php b/www/protected/extensions/yii-socialconnect/vendors/Hybrid/Providers/Facebook.php index 6495fe2..ffa6851 100644 --- a/www/protected/extensions/yii-socialconnect/vendors/Hybrid/Providers/Facebook.php +++ b/www/protected/extensions/yii-socialconnect/vendors/Hybrid/Providers/Facebook.php @@ -26,7 +26,7 @@ class Hybrid_Providers_Facebook extends Hybrid_Provider_Model throw new Exception( "Your application id and secret are required in order to connect to {$this->providerId}.", 4 ); } - if ( ! class_exists('FacebookApiException') ) { + if ( ! class_exists('FacebookApiException', false) ) { require_once Hybrid_Auth::$config["path_libraries"] . "Facebook/base_facebook.php"; require_once Hybrid_Auth::$config["path_libraries"] . "Facebook/facebook.php"; } diff --git a/www/protected/extensions/yii-socialconnect/vendors/Hybrid/Providers/LinkedIn.php b/www/protected/extensions/yii-socialconnect/vendors/Hybrid/Providers/LinkedIn.php index 5e755c1..1ab9c7d 100644 --- a/www/protected/extensions/yii-socialconnect/vendors/Hybrid/Providers/LinkedIn.php +++ b/www/protected/extensions/yii-socialconnect/vendors/Hybrid/Providers/LinkedIn.php @@ -89,8 +89,8 @@ class Hybrid_Providers_LinkedIn extends Hybrid_Provider_Model function getUserProfile() { try{ - // http://developer.linkedin.com/docs/DOC-1061 - $response = $this->api->profile('~:(id,first-name,last-name,public-profile-url,picture-url,email-address,date-of-birth,phone-numbers,summary)'); + // http://developer.linkedin.com/docs/DOC-1061 + $response = $this->api->profile('~:(id,first-name,last-name,public-profile-url,picture-url,email-address,main-address,date-of-birth,phone-numbers,summary)'); } catch( LinkedInException $e ){ throw new Exception( "User profile request failed! {$this->providerId} returned an error: $e", 6 ); @@ -103,6 +103,8 @@ class Hybrid_Providers_LinkedIn extends Hybrid_Provider_Model throw new Exception( "User profile request failed! {$this->providerId} returned an invalide xml data.", 6 ); } + Yii::log(CVarDumper::dumpAsString($data)); + $this->user->profile->identifier = (string) $data->{'id'}; $this->user->profile->firstName = (string) $data->{'first-name'}; $this->user->profile->lastName = (string) $data->{'last-name'}; @@ -115,7 +117,9 @@ class Hybrid_Providers_LinkedIn extends Hybrid_Provider_Model $this->user->profile->profileURL = (string) $data->{'public-profile-url'}; $this->user->profile->description = (string) $data->{'summary'}; - $this->user->profile->phone = (string) $data->{'phone-numbers'}->{'phone-number'}->{'phone-number'}; + $this->user->profile->phone = (string) $data->{'phone-numbers'}; + + $this->user->webSiteURL = (string) $data->{'main-address'}; if( $data->{'date-of-birth'} ) { $this->user->profile->birthDay = (string) $data->{'date-of-birth'}->day; diff --git a/www/protected/extensions/yii-socialconnect/vendors/Hybrid/resources/config.php.tpl b/www/protected/extensions/yii-socialconnect/vendors/Hybrid/resources/config.php.tpl index 3d82b68..a0576a3 100644 --- a/www/protected/extensions/yii-socialconnect/vendors/Hybrid/resources/config.php.tpl +++ b/www/protected/extensions/yii-socialconnect/vendors/Hybrid/resources/config.php.tpl @@ -25,7 +25,7 @@ return "Yahoo" => array ( "enabled" => #YAHOO_ADAPTER_STATUS#, - "keys" => array ( "id" => "#YAHOO_APPLICATION_KEY#", "secret" => "#YAHOO_APPLICATION_SECRET#" ) + "keys" => array ( "key" => "#YAHOO_APPLICATION_KEY#", "secret" => "#YAHOO_APPLICATION_SECRET#" ) ), "Google" => array ( diff --git a/www/protected/extensions/yii-socialconnect/vendors/Hybrid/thirdparty/OAuth/OAuth1Client.php b/www/protected/extensions/yii-socialconnect/vendors/Hybrid/thirdparty/OAuth/OAuth1Client.php index 34bad87..4c6dc52 100644 --- a/www/protected/extensions/yii-socialconnect/vendors/Hybrid/thirdparty/OAuth/OAuth1Client.php +++ b/www/protected/extensions/yii-socialconnect/vendors/Hybrid/thirdparty/OAuth/OAuth1Client.php @@ -78,7 +78,7 @@ class OAuth1Client{ if ( $callback ) { $this->redirect_uri = $parameters['oauth_callback'] = $callback; } - + $request = $this->signedRequest( $this->request_token_url, $this->request_token_method, $parameters ); $token = OAuthUtil::parse_parameters( $request ); $this->token = new OAuthConsumer( $token['oauth_token'], $token['oauth_token_secret'] ); diff --git a/www/protected/models/UsuarioFotografia.php b/www/protected/models/UsuarioFotografia.php index fdee73e..0335660 100644 --- a/www/protected/models/UsuarioFotografia.php +++ b/www/protected/models/UsuarioFotografia.php @@ -67,7 +67,6 @@ class UsuarioFotografia { * Guarda una fotografía subida por el usuario * return CUploadedFile fichero subido */ - public function guardarFotografia($fichero) { if (!$this->usuario) throw new CException(Yii::t('profind', 'Usuario no asignado.')); @@ -84,7 +83,6 @@ class UsuarioFotografia { * Elimina la fotografía del usuario * return bool */ - public function eliminarFotografia() { if (!$this->usuario) throw new CException(Yii::t('profind', 'Usuario no asignado.')); diff --git a/www/themes/profind/views/empresa/_form.php b/www/themes/profind/views/empresa/_form.php index e1cf027..83dd582 100644 --- a/www/themes/profind/views/empresa/_form.php +++ b/www/themes/profind/views/empresa/_form.php @@ -1,6 +1,16 @@

+
+
+

Recoger datos desde la red: + createUrl('empresa/modificar', array('id' => $model->id, 'provider' => 'LinkedIn'))); ?>, + Facebook, + createUrl('empresa/modificar', array('id' => $model->id, 'provider' => 'Twitter'))); ?>. +

+
+
+
hasErrors()) { ?> @@ -54,7 +64,7 @@
labelEx($model, 'direccion', array('class' => 'control-label')); ?>
- textField($model, 'direccion', array('class' => 'input-xlarge')); ?> + textArea($model, 'direccion', array('class' => 'input-xlarge')); ?>
diff --git a/www/themes/profind/views/equipo/_invitacion_form.php b/www/themes/profind/views/equipo/_invitacion_form.php index c41f905..bbd4e62 100644 --- a/www/themes/profind/views/equipo/_invitacion_form.php +++ b/www/themes/profind/views/equipo/_invitacion_form.php @@ -17,7 +17,7 @@ beginWidget('CActiveForm', array( 'id' => 'invitacion-agente-form', - 'enableAjaxValidation' => true, + 'enableAjaxValidation' => false, 'htmlOptions' => array( 'class' => '' ), diff --git a/www/themes/profind/views/layouts/main.php b/www/themes/profind/views/layouts/main.php index 58ca752..82423ef 100644 --- a/www/themes/profind/views/layouts/main.php +++ b/www/themes/profind/views/layouts/main.php @@ -8,7 +8,7 @@ - + @@ -20,7 +20,7 @@ - + @@ -49,35 +49,48 @@