| [ Index ] |
PHP Cross Reference of Drupal 6 (gatewave) |
[Summary view] [Print] [Text view]
1 <?php 2 // $Id: openid.pages.inc,v 1.5.2.2 2009/09/16 19:34:14 goba Exp $ 3 4 /** 5 * @file 6 * User page callbacks for the openid module. 7 */ 8 9 /** 10 * Menu callback; Process an OpenID authentication. 11 */ 12 function openid_authentication_page() { 13 $result = openid_complete(); 14 switch ($result['status']) { 15 case 'success': 16 return openid_authentication($result); 17 case 'failed': 18 drupal_set_message(t('OpenID login failed.'), 'error'); 19 break; 20 case 'cancel': 21 drupal_set_message(t('OpenID login cancelled.')); 22 break; 23 } 24 drupal_goto(); 25 } 26 27 /** 28 * Menu callback; Manage OpenID identities for the specified user. 29 */ 30 function openid_user_identities($account) { 31 drupal_set_title(check_plain($account->name)); 32 drupal_add_css(drupal_get_path('module', 'openid') .'/openid.css', 'module'); 33 34 // Check to see if we got a response 35 $result = openid_complete(); 36 if ($result['status'] == 'success') { 37 $identity = $result['openid.claimed_id']; 38 db_query("INSERT INTO {authmap} (uid, authname, module) VALUES (%d, '%s','openid')", $account->uid, $identity); 39 drupal_set_message(t('Successfully added %identity', array('%identity' => $identity))); 40 } 41 42 $header = array(t('OpenID'), t('Operations')); 43 $rows = array(); 44 45 $result = db_query("SELECT * FROM {authmap} WHERE module='openid' AND uid=%d", $account->uid); 46 while ($identity = db_fetch_object($result)) { 47 $rows[] = array(check_plain($identity->authname), l(t('Delete'), 'user/'. $account->uid .'/openid/delete/'. $identity->aid)); 48 } 49 50 $output = theme('table', $header, $rows); 51 $output .= drupal_get_form('openid_user_add'); 52 return $output; 53 } 54 55 /** 56 * Form builder; Add an OpenID identity. 57 * 58 * @ingroup forms 59 * @see openid_user_add_validate() 60 */ 61 function openid_user_add() { 62 $form['openid_identifier'] = array( 63 '#type' => 'textfield', 64 '#title' => t('OpenID'), 65 ); 66 $form['submit'] = array('#type' => 'submit', '#value' => t('Add an OpenID')); 67 return $form; 68 } 69 70 function openid_user_add_validate($form, &$form_state) { 71 // Check for existing entries. 72 $claimed_id = _openid_normalize($form_state['values']['openid_identifier']); 73 if (db_result(db_query("SELECT authname FROM {authmap} WHERE authname='%s'", $claimed_id))) { 74 form_set_error('openid_identifier', t('That OpenID is already in use on this site.')); 75 } 76 } 77 78 function openid_user_add_submit($form, &$form_state) { 79 $return_to = url('user/'. arg(1) .'/openid', array('absolute' => TRUE)); 80 openid_begin($form_state['values']['openid_identifier'], $return_to); 81 } 82 83 84 /** 85 * Present a confirmation form to delete the specified OpenID identity from the system. 86 * 87 * @ingroup forms 88 * @see openid_user_delete_form_submit() 89 */ 90 function openid_user_delete_form($form_state, $account, $aid = 0) { 91 $authname = db_result(db_query('SELECT authname FROM {authmap} WHERE uid = %d AND aid = %d', $account->uid, $aid)); 92 93 $form = array(); 94 95 $form['uid'] = array( 96 '#type' => 'value', 97 '#value' => $account->uid, 98 ); 99 100 $form['aid'] = array( 101 '#type' => 'value', 102 '#value' => $aid, 103 ); 104 105 return confirm_form($form, t('Are you sure you want to delete the OpenID %authname for %user?', array('%authname' => $authname, '%user' => $account->name)), 'user/'. $account->uid .'/openid'); 106 } 107 108 function openid_user_delete_form_submit($form, &$form_state) { 109 db_query("DELETE FROM {authmap} WHERE uid = %d AND aid = %d AND module = 'openid'", $form_state['values']['uid'], $form_state['values']['aid']); 110 if (db_affected_rows()) { 111 drupal_set_message(t('OpenID deleted.')); 112 } 113 $form_state['redirect'] = 'user/'. $form_state['values']['uid'] .'/openid'; 114 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Thu Mar 24 11:18:33 2011 | Cross-referenced by PHPXref 0.7 |