/[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.7, Thu Sep 6 06:34:55 2007 UTC revision 1.8, Thu Sep 6 07:07:13 2007 UTC
# Line 1  Line 1 
1  <?php  <?php
2  // $Id: facebook_auth.module,v 1.6 2007/06/16 06:21:01 halkeye Exp $  // $Id: facebook_auth.module,v 1.7 2007/09/06 06:34:55 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 52  function facebook_auth_menu($may_cache) Line 52  function facebook_auth_menu($may_cache)
52        );        );
53    
54     }     }
55       else {
56          if (arg(0) == 'user' && is_numeric(arg(1))) {
57             $account = user_load(array('uid' => arg(1)));
58    
59             if ($account->uid) {
60                global $user;
61    
62                $access = (user_access('administer users') || $user->uid == arg(1));
63                $items[] = array(
64                   'path' => 'user/'. arg(1) .'/facebook',
65                   'title' => t('Facebook Identities'),
66                   'callback' => 'facebook_user_identities',
67                   'callback arguments' => array($account),
68                   'access' => $access,
69                   'type' => MENU_LOCAL_TASK
70                );
71                $items[] = array(
72                   'path' => 'user/'. arg(1) .'/facebook/delete',
73                   'title' => t('Delete Facebook'),
74                   'callback' => 'facebook_user_delete',
75                   'callback arguments' => array($account),
76                   'access' => $access,
77                   'type' => MENU_CALLBACK
78                );
79             }
80          }
81       }
82     return $items;     return $items;
83  }  }
84    
# Line 139  function facebook_auth_admin() { Line 166  function facebook_auth_admin() {
166  }  }
167    
168  /**  /**
169   * Implementation of hook_form_alter : adds OpenID login to the login forms.   * Implementation of hook_form_alter : adds Facebook login to the login forms.
170   */   */
171  function facebook_auth_form_alter($form_id, &$form) {  function facebook_auth_form_alter($form_id, &$form) {
172     $api_key = variable_get('facebook_apikey', '');     $api_key = variable_get('facebook_apikey', '');
# Line 206  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) {
237      $header = array(t('Facebook'), t('Operations'));
238      $rows = array();
239    
240      $result = db_query("SELECT * FROM {authmap} WHERE module='facebook' AND uid=%d", $account->uid);
241      while ($identity = db_fetch_object($result)) {
242        $rows[] = array($identity->authname, l(t('Delete'), 'user/'. $account->uid .'/facebook/delete/'. $identity->aid));
243      }
244    
245      $output = theme('table', $header, $rows);
246      $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);
247      return $output;
248    }

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

  ViewVC Help
Powered by ViewVC 1.1.2