Ejemplo n.º 1
0
 /**
  * Get the oatuh adapter using the controller name
  * 
  * @return ComConnectOauthApiAbstract
  */
 public function getAPI()
 {
     if (!isset($this->_api)) {
         $session = new KConfig(KRequest::get('session.oauth', 'raw', array()));
         $api = pick($this->getRequest()->server, $session->api);
         if (!$api) {
             return null;
         }
         //get the api server from the request
         $this->_api = $this->getService('com://site/connect.oauth.service.' . $api);
         if (!$this->_consumer) {
             $name = $this->_api->getName();
             $key = get_config_value('com_connect.' . $name . '_key');
             $secret = get_config_value('com_connect.' . $name . '_secret');
             $query = array('option=com_' . $this->_mixer->getIdentifier()->package, 'view=' . $this->_mixer->getIdentifier()->name, 'server=' . $this->server, 'get=accesstoken');
             if ($this->oid) {
                 $query[] = 'oid=' . $this->oid;
             }
             $callback = JRoute::_(implode($query, '&'), true);
             $this->_consumer = new ComConnectOauthConsumer(new KConfig(array('key' => $key, 'secret' => $secret, 'callback_url' => (string) $callback)));
         }
         //set the consumer
         $this->_api->setConsumer($this->_consumer);
         $this->_api->setToken($session->token);
     }
     return $this->_api;
 }
Ejemplo n.º 2
0
 /**
  * store user method.
  *
  * Method is called after user data is stored in the database
  *
  * @param 	array		holds the new user data
  * @param 	bool		true if a new user is stored
  * @param	bool		true if user was succesfully stored in the database
  * @param	string		message
  */
 public function onAfterStoreUser($user, $isnew, $succes, $msg)
 {
     $this->_createToken($user['username']);
     $userId = $user['id'];
     if ($this->_person) {
         //unblock the user
         $user = KService::get('repos://site/users')->find($userId);
         $user->block = false;
         $user->save();
         $user = $this->_api->getUser();
         if (KRequest::get('post.import_avatar', 'cmd') && $user->large_avatar) {
             $this->_person->setPortraitImage(array('url' => $user->large_avatar));
         }
         $this->_person->enabled = true;
         $this->_person->save();
     }
 }