Exemple #1
0
 private function awardPoints($name, $href)
 {
     $point = new JFBConnectPoint();
     $point->set('name', $name);
     $point->set('key', $href);
     $point->award();
 }
Exemple #2
0
 function requestSent()
 {
     $jfbcRequestId = JRequest::getInt('jfbcId');
     $fbRequestId = JRequest::getString('requestId');
     $inToList = JRequest::getVar('to');
     // Get the from user id from the request
     $to = $inToList[0];
     $requestInfo = JFBCFactory::provider('facebook')->api('/' . $fbRequestId . "_" . $to);
     $fbFrom = $requestInfo['from']['id'];
     // Not using the model, as we're doing a simple store.
     JTable::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_jfbconnect/tables');
     $data = array();
     $data['fb_request_id'] = $fbRequestId;
     $data['fb_user_from'] = $fbFrom;
     $data['jfbc_request_id'] = $jfbcRequestId;
     $data['created'] = JFactory::getDate()->toSql();
     $data['modified'] = null;
     //        $data['destination_url'] = JRequest::getString('destinationUrl');
     foreach ($inToList as $fbTo) {
         $row =& JTable::getInstance('JFBConnectNotification', 'Table');
         $to = JFilterInput::clean($fbTo, 'ALNUM');
         $data['fb_user_to'] = $to;
         $row->save($data);
         $point = new JFBConnectPoint();
         $point->set('name', 'facebook.request.create');
         $point->set('key', $to);
         $point->award();
     }
     $app = JFactory::getApplication();
     $app->close();
 }
Exemple #3
0
 function map($jUserId, $providerUserId, $provider, $token = null)
 {
     if ($jUserId && $providerUserId) {
         // Check for a previous mapping first. This could be a previous account the user had connected to their Joomla account.
         // Also, LinkedIn returns a different member ID for each API key. If the admin switches API keys, 'old' member IDs may
         // be mapped and need to be deleted here. This is a really bad scenario though as admins shouldn't be changing their API key.
         $oldProviderId = $this->getProviderUserId($jUserId, $provider);
         if ($oldProviderId && $oldProviderId != $providerUserId) {
             $this->deleteMapping($oldProviderId, $provider);
         }
         JTable::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_jfbconnect/tables/');
         $row = $this->getTable();
         $row->load(array('provider_user_id' => $providerUserId, 'provider' => $provider));
         if (!$row->id) {
             $row->created_at = JFactory::getDate()->toSql();
         }
         if ($token) {
             $row->access_token = json_encode($token);
         }
         $row->updated_at = JFactory::getDate()->toSql();
         $row->j_user_id = $jUserId;
         $row->provider_user_id = $providerUserId;
         $row->authorized = true;
         $row->provider = $provider;
         if (!$row->check() || !$row->store()) {
             $this->setError($this->_db->getErrorMsg());
             return false;
         }
         // Now, trigger the point rewards
         $point = new JFBConnectPoint();
         $point->set('name', 'account.map');
         $point->set('key', $provider);
         $point->set('userid', $jUserId);
         $point->award();
         return true;
     } else {
         return false;
     }
 }