function onFacebookPage($page, &$class)
 {
     global $mainframe;
     $class->addMenu('profile', JText::_('PROFILE'), 'profile', 'right', 5);
     JPluginHelper::importPlugin('facebook');
     $content = '';
     if ($page == 'profile') {
         $facebook =& JoomlaFacebook::getFacebookPlatform();
         $facebook->require_install();
         if (JRequest::getVar('action') == 'save' || JRequest::getVar('action') == 'update') {
             $error = '';
             if (JRequest::getVar('action') == 'save') {
                 $fbml = '<p style="text-align:right"><a href="http://apps.facebook.com/' . JoomlaFacebook::getAppname() . '/profile&action=update">Update Profile Box</a></p>';
                 $fbml .= $this->_params->get('header');
                 $mainframe->triggerEvent('onFacebookSaveForm', array(&$fbml, &$error));
                 $fbml .= $this->_params->get('footer');
                 $facebook->api_client->profile_setFBML($fbml, $facebook->require_login());
             }
             $mainframe->triggerEvent('onFacebookUpdate', array(&$error));
             if ($error != '') {
                 $content .= '<fb:error><fb:message>' . JText::_('UPDATEERROR') . '</fb:message> ' . $error . '</fb:error>';
             } else {
                 $content .= '<fb:success message="' . JText::_('UPDATESUCCESS') . '" /> ';
             }
         }
         $content .= '<h1>' . JText::_('PROFILESETTING') . '</h1><fb:editor action="profile" labelwidth="100">  ';
         $mainframe->triggerEvent('onFacebookConfigForm', array(&$content));
         $content .= '<br/><fb:editor-custom><input type="hidden" name="action" value="save"/></fb:editor-custom><fb:editor-buttonset><fb:editor-button value="' . JText::_('APPLY') . '"/><fb:editor-cancel href="" /></fb:editor-buttonset></fb:editor>';
         $class->addContent($content, 0);
     }
     return true;
 }
 function onAuthenticate($credentials, $options, &$response)
 {
     if (defined('_JOOMLAFACEBOOK')) {
         if ($credentials['username'] == 'FACEBOOK' || $credentials['username'] == 'FACEBOOKSESSION') {
             $facebook = JoomlaFacebook::getRestClient();
             $fbsession = array();
             if ($credentials['username'] == 'FACEBOOK') {
                 $fbsession = $facebook->auth_getSession($credentials['password']);
             }
             if ($credentials['username'] == 'FACEBOOKSESSION' && $credentials['password'] != '') {
                 $facebook->session_key = $credentials['password'];
                 $fbsession['uid'] = $facebook->users_getLoggedInUser();
             }
             if ($fbsession['uid'] != '') {
                 $query = 'SELECT first_name,last_name,sex,current_location.zip,current_location.country,timezone FROM user WHERE uid=' . $fbsession['uid'];
                 $fbuserprofile = $facebook->fql_query($query);
                 $response->status = JAUTHENTICATE_STATUS_SUCCESS;
                 @($response->username = '******' . $fbsession['uid']);
                 @($response->email = $fbsession['uid'] . '@facebook.com');
                 @($response->fullname = $fbuserprofile[0]['first_name'] . ' ' . $fbuserprofile[0]['last_name']);
                 @($response->gender = strtoupper(substr($fbuserprofile[0]['sex'], 0, 1)));
                 @($response->postcode = $fbuserprofile[0]['current_location']['zip']);
                 @($response->country = $fbuserprofile[0]['current_location']['country']);
                 @($response->timezone = $fbuserprofile[0]['timezone']);
                 return;
             }
         }
     }
     $response->status = JAUTHENTICATE_STATUS_FAILURE;
 }
 function addMenu($page, $label, $url = '', $align = 'left', $priority = 0)
 {
     if ($url == '') {
         $url = $page;
     }
     if (strpos($url, '://') == false) {
         $url = 'http://apps.facebook.com/' . JoomlaFacebook::getAppname() . '/' . $url;
     }
     $this->_menu[$align][$priority][$page] = array('label' => $label, 'url' => $url);
 }
 function onFacebookPage($page, &$class)
 {
     global $mainframe;
     $facebook =& JoomlaFacebook::getFacebookPlatform();
     $class->addMenu('invite', JText::_('INVITE'), 'invite', 'right', 10);
     $invitetext = $this->_params->get('invitetext', '');
     $invitetext .= '<fb:req-choice url="http://apps.facebook.com/"' . JoomlaFacebook::getAppname() . ' label=' . JText::_('VISITSITE') . '>';
     $invitetext = str_replace('SITENAME', $mainframe->getCfg('sitename'), $invitetext);
     if ($page == 'invite') {
         $class->addContent('<fb:request-form method="post" content="' . htmlentities($invitetext) . '" type="' . htmlentities($mainframe->getCfg('sitename')) . '" invite="false" action="http://app.facebook.com/joomlatest"><fb:multi-friend-selector actiontext="' . JText::_('INVITETITLE') . '" bypass="******"/></fb:request-form>', 0);
     }
     return true;
 }
 function onFacebookUpdate($error)
 {
     $facebook =& JoomlaFacebook::getFacebookPlatform();
     $db =& JFactory::getDBO();
     $query = 'SELECT id,title,created FROM #__content ORDER BY created DESC LIMIT 0,' . $this->_params->get('num', 10);
     $db->setQuery($query);
     $result = $db->loadObjectList();
     $config =& JFactory::getConfig();
     $n = 0;
     foreach ($result as $record) {
         $facebook->api_client->fbml_setRefHandle('content-' . $n, '<a href="' . JURI::base() . '/index.php?option=com_content&id=' . $record->id . '">' . $record->title . '</a> (Created on' . $record->created . ')');
         $n++;
     }
     return true;
 }
 * @link 		http://joomlacode.org/gf/project/joomla-facebook/
 * @license		GNU/GPL, see LICENSE.php
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 * 
 * This program 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 this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */
// Check to ensure this file is included in Joomla!
defined('_JEXEC') or die;
@(include_once JPATH_SITE . DS . 'components' . DS . 'com_facebook' . DS . 'api.php');
if (defined('_JOOMLAFACEBOOK')) {
    // Include the syndicate functions only once
    $apikey = JoomlaFacebook::getAPIKey();
    $module =& JModuleHelper::getModule('facebook');
    $params = new JParameter($module->params);
    $showadmin = $params->get('showadmin', 1) == 1;
    $showimg = $params->get('showimg', 1) == 1;
    $imgpath = 'http://static.ak.facebook.com/images/devsite/facebook_login.gif';
    require JModuleHelper::getLayoutPath('mod_facebook');
} else {
    echo JText::_('NOTINSTALL');
}