summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorDries Buytaert <dries@buytaert.net>2009-03-17 14:02:49 +0000
committerDries Buytaert <dries@buytaert.net>2009-03-17 14:02:49 +0000
commit76b8ab58c75c90875d532b3a7ce017c15bd6e9fc (patch)
treeeeaf12ae4d79242050007dd85caa1740ae7dcfd5 /modules
parent4072ea46521512da7ff9f57a21cbeb4c4f7c2cfa (diff)
downloadbrdo-76b8ab58c75c90875d532b3a7ce017c15bd6e9fc.tar.gz
brdo-76b8ab58c75c90875d532b3a7ce017c15bd6e9fc.tar.bz2
- Patch #394488 by csevb10, tizzo et al: convert the OpenID module to the new database abstraction layer.
Diffstat (limited to 'modules')
-rw-r--r--modules/openid/openid.pages.inc27
1 files changed, 20 insertions, 7 deletions
diff --git a/modules/openid/openid.pages.inc b/modules/openid/openid.pages.inc
index 06a5edfdb..7018676f1 100644
--- a/modules/openid/openid.pages.inc
+++ b/modules/openid/openid.pages.inc
@@ -35,15 +35,21 @@ function openid_user_identities($account) {
$result = openid_complete();
if ($result['status'] == 'success') {
$identity = $result['openid.claimed_id'];
- db_query("INSERT INTO {authmap} (uid, authname, module) VALUES (%d, '%s','openid')", $account->uid, $identity);
+ $query = db_insert('authmap')
+ ->fields(array(
+ 'uid' => $account->uid,
+ 'authname' => $identity,
+ 'module' => 'openid',
+ ))
+ ->execute();
drupal_set_message(t('Successfully added %identity', array('%identity' => $identity)));
}
$header = array(t('OpenID'), t('Operations'));
$rows = array();
- $result = db_query("SELECT * FROM {authmap} WHERE module='openid' AND uid=%d", $account->uid);
- while ($identity = db_fetch_object($result)) {
+ $result = db_query("SELECT * FROM {authmap} WHERE module='openid' AND uid=:uid", array(':uid' => $account->uid));
+ foreach ($result as $identity) {
$rows[] = array(check_plain($identity->authname), l(t('Delete'), 'user/' . $account->uid . '/openid/delete/' . $identity->aid));
}
@@ -70,7 +76,7 @@ function openid_user_add() {
function openid_user_add_validate($form, &$form_state) {
// Check for existing entries.
$claimed_id = _openid_normalize($form_state['values']['openid_identifier']);
- if (db_result(db_query("SELECT authname FROM {authmap} WHERE authname='%s'", $claimed_id))) {
+ if (db_query("SELECT authname FROM {authmap} WHERE authname = :authname", (array(':authname' => $claimed_id)))->fetchField()) {
form_set_error('openid_identifier', t('That OpenID is already in use on this site.'));
}
else {
@@ -83,13 +89,20 @@ function openid_user_add_validate($form, &$form_state) {
* Menu callback; Delete the specified OpenID identity from the system.
*/
function openid_user_delete_form($form_state, $account, $aid = 0) {
- $authname = db_result(db_query('SELECT authname FROM {authmap} WHERE uid = %d AND aid = %d', $account->uid, $aid));
+ $authname = db_query('SELECT authname FROM {authmap} WHERE uid = :uid AND aid = :aid', array(
+ ':uid' => $account->uid,
+ ':aid' => $aid,
+ ))
+ ->fetchField();
return confirm_form(array(), t('Are you sure you want to delete the OpenID %authname for %user?', array('%authname' => $authname, '%user' => $account->name)), 'user/'. $account->uid .'/openid');
}
function openid_user_delete_form_submit(&$form_state, $form_values) {
- db_query("DELETE FROM {authmap} WHERE uid = %d AND aid = %d AND module = 'openid'", $form_state['#args'][0]->uid, $form_state['#args'][1]);
- if (db_affected_rows()) {
+ $query = db_delete('authmap')
+ ->condition('uid', $form_state['#parameters'][2]->uid)
+ ->condition('aid', $form_state['#parameters'][3])
+ ->execute();
+ if ($query) {
drupal_set_message(t('OpenID deleted.'));
}
$form_state['#redirect'] = 'user/'. $form_state['#args'][0]->uid .'/openid';