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