function addSubscriptions(){ $facebook = plgSystemmyApiConnect::getFacebook(); require_once(JPATH_SITE.DS.'components'.DS.'com_myapi'.DS.'models'.DS.'myapi.php'); $myApiModel = new MyapiModelMyapi; $config =& JFactory::getConfig(); $u =& JURI::getInstance( JURI::root() ); $port = ($u->getPort() == '') ? '' : ":".$u->getPort(); $callback = $u->getScheme().'://'.$u->getHost().$port.$u->getPath().'index.php?option=com_myapi&task=facebookRealTime'; try{ $subscription = $facebook->api('/'.$facebook->getAppId().'/subscriptions','post',array('object' => 'user', 'fields' => 'email,name,pic,status,about_me,username','callback_url' => $callback, 'verify_token' => $config->getValue( 'config.secret' ), 'access_token' => $this->getRealTimeAccess() )); $subscription = $facebook->api('/'.$facebook->getAppId().'/subscriptions','post',array('object' => 'permissions', 'fields' => implode(',',$myApiModel->getPerms()),'callback_url' => $callback, 'verify_token' => $config->getValue( 'config.secret' ), 'access_token' => $this->getRealTimeAccess() )); JFactory::getApplication()->enqueueMessage( JText::_('SUBSCRIPTIONS_ADDED') ); } catch (FacebookApiException $e) { JError::raiseNotice( 100, $e->__toString()); } return; }
$facebookmodel = new myapiModelfacebook; //Bring the myAPI facebook model $linked = false; $user = JFactory::getUser(); if(!$user->guest){ $db = JFactory::getDBO(); $query = "SELECT * FROM ".$db->nameQuote('#__myapi_users')." WHERE userId =".$db->quote($user->id); $db->setQuery($query); $db->query(); $num_rows = $db->getNumRows(); if($num_rows == 0){ $linked = false; } else { $linked = true; } } require_once JPATH_SITE.DS.'components'.DS.'com_myapi'.DS.'models'.DS.'myapi.php'; $myApiModel = new MyapiModelMyapi; //Bring the myAPI facebook model $avatar = $myApiModel->getAvatar(); ?> <div id="myApiLoginWrapper" class="<?php echo $params->get('moduleclass_sfx'); ?>"> <?php if($user->guest): ?> <div style="text-align:center; margin-bottom:10px; padding:10px 0px;"> <fb:login-button id="fbLoginButton" autologoutlink="false" v="2" size="<?php echo $button_size; ?>" onlogin="******" perms="email,user_likes,user_photos,user_status,read_stream,publish_stream,offline_access">Connect with facebook</fb:login-button> <div style="margin-top:15px;"></div> <?php if($params->get('login_facepile') == '1') : ?> <fb:facepile width="<?php echo $params->get('login_facepileWidth'); ?>" max-rows="<?php echo $params->get('login_facepileRows'); ?>"></fb:facepile> <?php endif; ?>
** ** ** myApi_fblogin is distributed in the hope that it will be useful, ** ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** ** GNU General Public License for more details. ** ** ** ** You should have received a copy of the GNU General Public License ** ** along with myApi_fblogin. If not, see <http://www.gnu.org/licenses/> ** ** ** *****************************************************************************/ if(!class_exists('plgSystemmyApiConnect') || !$this->_facebook = plgSystemmyApiConnect::getFacebook() || !file_exists(JPATH_SITE.DS.'components'.DS.'com_myapi'.DS.'models'.DS.'myapi.php')) return; require_once JPATH_SITE.DS.'components'.DS.'com_myapi'.DS.'models'.DS.'myapi.php'; $myApiModel = new MyapiModelMyapi; $doc =& JFactory::getDocument(); $doc->addScript('components'.DS.'com_myapi'.DS.'assets'.DS.'js'.DS.'myApi.js'); $doc->addStylesheet('modules'.DS.'mod_myapi_fbLogin'.DS.'mod_myapi_fbLogin.css'); $user = JFactory::getUser(); $classSfx = $params->get('moduleclass_sfx'); $width = $params->get('login_width'); $show_faces = $params->get('login_facepile'); $max_rows = $params->get('login_facepileRows'); $permissions = implode(',',$myApiModel->getPerms()); if($params->get('login_userRedirect') != '1'){ //same page $u =& JFactory::getURI();