/[drupal]/contributions/modules/facebook_auth/facebook_auth.module
ViewVC logotype

Diff of /contributions/modules/facebook_auth/facebook_auth.module

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph | View Patch Patch

revision 1.8, Thu Sep 6 07:07:13 2007 UTC revision 1.9, Thu Sep 6 07:25:03 2007 UTC
# Line 1  Line 1 
1  <?php  <?php
2  // $Id: facebook_auth.module,v 1.7 2007/09/06 06:34:55 halkeye Exp $  // $Id: facebook_auth.module,v 1.8 2007/09/06 07:07:13 halkeye Exp $
3  if (substr(phpversion(), 0, 1) == '4') {  if (substr(phpversion(), 0, 1) == '4') {
4     if (file_exists(dirname(__FILE__) . '/facebook-platform/php4client/facebook.php')) {     if (file_exists(dirname(__FILE__) . '/facebook-platform/php4client/facebook.php')) {
5        require_once('facebook-platform/php4client/facebook.php');        require_once('facebook-platform/php4client/facebook.php');
# Line 61  function facebook_auth_menu($may_cache) Line 61  function facebook_auth_menu($may_cache)
61    
62              $access = (user_access('administer users') || $user->uid == arg(1));              $access = (user_access('administer users') || $user->uid == arg(1));
63              $items[] = array(              $items[] = array(
64                 'path' => 'user/'. arg(1) .'/facebook',                 'path' => 'user/'. arg(1) .'/facebook_auth',
65                 'title' => t('Facebook Identities'),                 'title' => t('Facebook Identities'),
66                 'callback' => 'facebook_user_identities',                 'callback' => 'facebook_auth_user_identities',
67                 'callback arguments' => array($account),                 'callback arguments' => array($account),
68                 'access' => $access,                 'access' => $access,
69                 'type' => MENU_LOCAL_TASK                 'type' => MENU_LOCAL_TASK
70              );              );
71              $items[] = array(              $items[] = array(
72                 'path' => 'user/'. arg(1) .'/facebook/delete',                 'path' => 'user/'. arg(1) .'/facebook_auth/delete',
73                 'title' => t('Delete Facebook'),                 'title' => t('Delete Facebook'),
74                 'callback' => 'facebook_user_delete',                 'callback' => 'facebook_auth_user_delete',
75                 'callback arguments' => array($account),                 'callback arguments' => array($account),
76                 'access' => $access,                 'access' => $access,
77                 'type' => MENU_CALLBACK                 'type' => MENU_CALLBACK
# Line 233  function facebook_auth_user_assoc_submit Line 233  function facebook_auth_user_assoc_submit
233     return drupal_goto('user/'. $user->uid .'/edit');     return drupal_goto('user/'. $user->uid .'/edit');
234  }  }
235    
236  function facebook_user_identities($account) {  function facebook_auth_user_identities($account) {
237    $header = array(t('Facebook'), t('Operations'));     $header = array(t('Facebook'), t('Operations'));
238    $rows = array();     $rows = array();
239    
240    $result = db_query("SELECT * FROM {authmap} WHERE module='facebook' AND uid=%d", $account->uid);     $result = db_query("SELECT * FROM {authmap} WHERE module='facebook_auth' AND uid=%d", $account->uid);
241    while ($identity = db_fetch_object($result)) {     while ($identity = db_fetch_object($result)) {
242      $rows[] = array($identity->authname, l(t('Delete'), 'user/'. $account->uid .'/facebook/delete/'. $identity->aid));        list($userId) = explode('@',$identity->authname);
243    }        $rows[] = array(l($userId,'http://www.facebook.com/profile.php?id='.$userId), l(t('Delete'), 'user/'. $account->uid .'/facebook_auth/delete/'. $identity->aid));
244       }
245    
246    $output = theme('table', $header, $rows);     $output = theme('table', $header, $rows);
247    $output .= l(theme('image', 'http://static.ak.facebook.com/images/devsite/facebook_login.gif', t('Login to facebook'), t('Login to facebook'), NULL, FALSE), 'facebook', array(), 'destination='.$_GET['q'], NULL, FALSE, TRUE);     $output .= l(theme('image', 'http://static.ak.facebook.com/images/devsite/facebook_login.gif', t('Login to facebook'), t('Login to facebook'), NULL, FALSE), 'facebook', array(), 'destination='.$_GET['q'], NULL, FALSE, TRUE);
248    return $output;     return $output;
249    }
250    
251    function facebook_auth_user_delete($account, $aid = 0) {
252      db_query("DELETE FROM {authmap} WHERE uid=%d AND aid=%d AND module='facebook_auth'", $account->uid, $aid);
253      if (db_affected_rows()) {
254        drupal_set_message(t('Facebook association deleted.'));
255      }
256      drupal_goto('user/'. $account->uid .'/facebook_auth');
257  }  }

Legend:
Removed from v.1.8  
changed lines
  Added in v.1.9

  ViewVC Help
Powered by ViewVC 1.1.2