Exemplo n.º 1
0
 /**
  * callback.
  *
  * @return	void
  */
 public function callback()
 {
     // CSRF prevention disabled, we are trusting in code authentication
     /*
     if ($this->csrfProtection)
     {
     	$this->_csrfProtection();
     }
     */
     try {
         // $channelId = $this->input->getUint('channelId');
         $session = JFactory::getSession();
         $channelId = $session->get('channelId');
         // Invalidating
         $session->set('channelId', false);
         $gpluscode = $this->input->getVar('code');
         $logger = AutotweetLogger::getInstance();
         $logger->log(JLog::INFO, 'GplusChannels callback: ' . $gpluscode);
         // Error throw
         if (!empty($gpluscode)) {
             $channel = F0FTable::getAnInstance('Channel', 'AutoTweetTable');
             $result = $channel->load($channelId);
             if (!$result) {
                 $msg = 'Channel failed to load!';
                 $logger->log(JLog::ERROR, $msg);
                 throw new Exception($msg);
             }
             $gplusChannelHelper = new GplusChannelHelper($channel);
             $gplusChannelHelper->authenticate($gpluscode);
             // Redirect
             $url = 'index.php?option=com_autotweet&view=channels&task=edit&id=' . $channelId;
             $this->setRedirect($url);
             $this->redirect();
         }
     } catch (Exception $e) {
         $logger = AutotweetLogger::getInstance();
         $logger->log(JLog::ERROR, $e->getMessage());
         throw $e;
     }
 }
Exemplo n.º 2
0
 /**
  * getGplusValidation.
  *
  * @return	void
  */
 public function getGplusValidation()
 {
     @ob_end_clean();
     header('Content-type: text/plain');
     // No JInputJSON in J2.5
     $raw = file_get_contents('php://input');
     $data = json_decode($raw, true);
     $safeHtmlFilter = JFilterInput::getInstance();
     $token = $data['token'];
     $token = $safeHtmlFilter->clean($token, 'ALNUM');
     $this->input->set($token, 1);
     // CSRF prevention
     if ($this->csrfProtection) {
         $this->_csrfProtection();
     }
     $channel_id = $data['channel_id'];
     $channel_id = $safeHtmlFilter->clean($channel_id, 'ALNUM');
     $status = false;
     $error_message = 'Unknown';
     $channel = F0FTable::getAnInstance('Channel', 'AutoTweetTable');
     $result = $channel->load($channel_id);
     $user = null;
     $url = null;
     $icon = null;
     if (!$result) {
         $error_message = 'Channel failed to load!';
     } else {
         try {
             $gplusChannelHelper = new GplusChannelHelper($channel);
             $isAuth = $gplusChannelHelper->isAuth();
             if ($isAuth) {
                 $status = true;
                 $error_message = 'Ok';
                 $user = $gplusChannelHelper->getUser();
                 $url = $user['url'];
                 $icon = F0FModel::getTmpInstance('Channeltypes', 'AutoTweetModel')->getIcon(AutotweetModelChanneltypes::TYPE_GPLUS_CHANNEL);
             } else {
                 $error_message = JText::_('COM_AUTOTWEET_CHANNEL_GPLUS_NOT_AUTH_ERR');
             }
         } catch (Exception $e) {
             $error_message = $e->getMessage();
         }
     }
     $message = json_encode(array('status' => $status, 'error_message' => $error_message, 'user' => $user, 'social_icon' => $icon, 'social_url' => $url));
     echo EJSON_START . $message . EJSON_END;
     flush();
     JFactory::getApplication()->close();
 }
Exemplo n.º 3
0
</div>

<?php 
echo EHtmlSelect::yesNoControl($this->item->xtform->get('schemaorg_url', 0), 'xtform[schemaorg_url]', 'COM_AUTOTWEET_CHANNEL_GPLUS_POST_URL', 'COM_AUTOTWEET_CHANNEL_GPLUS_POST_URL_DESC');
$accessToken = null;
$userId = null;
$expiresIn = null;
$authUrl = '#';
$authUrlButtonStyle = 'disabled';
$validationGroupStyle = 'hide';
// New channel, not even saved
if ($this->item->id == 0) {
    $message = JText::_('COM_AUTOTWEET_CHANNEL_GPLUS_NEWCHANNEL_NOAUTHORIZATION');
    include_once 'auth_button.php';
} else {
    $gplusChannelHelper = new GplusChannelHelper($this->item);
    $isAuth = $gplusChannelHelper->isAuth();
    // New channel, but saved
    if ($isAuth) {
        // We have an access Token!
        $accessToken = $gplusChannelHelper->getAccessToken();
        $user = $gplusChannelHelper->getUser();
        $userId = $user['id'];
        $this->item->xtform->set('social_url', $user['url']);
        $expiresIn = $gplusChannelHelper->getExpiresIn();
        $validationGroupStyle = null;
        include_once 'validation_button.php';
    } else {
        $message = JText::_('COM_AUTOTWEET_CHANNEL_GPLUS_NEWCHANNEL_AUTHORIZATION');
        $authUrl = $gplusChannelHelper->getAuthorizationUrl();
        $authUrlButtonStyle = null;