Ejemplo n.º 1
0
/**
 * Undo any database changes made by the OpenID plugin.  Do not attempt to preserve any data.
 */
function openid_delete_tables() {
	global $wpdb;
	$wpdb->query('DROP TABLE IF EXISTS ' . openid_identity_table());
	$wpdb->query( $wpdb->prepare('DELETE FROM ' . $wpdb->postmeta . ' WHERE meta_key=%s', 'openid_comments') );
	
	// old database changes... just to make sure
	$wpdb->query('DROP TABLE IF EXISTS ' . openid_table_prefix(true) . 'openid_nonces');
	$wpdb->query('DROP TABLE IF EXISTS ' . openid_table_prefix(true) . 'openid_associations');

	// clear old way of storing OpenID comments
	$openid_column = $wpdb->get_row('SHOW COLUMNS FROM ' . openid_table_prefix(true) . 'comments LIKE "openid"');
	if ($openid_column) {
		$wpdb->query('ALTER table ' . $comments_table . ' DROP COLUMN openid');
		$wpdb->query( $wpdb->prepare('UPDATE ' . $comments_table . ' SET comment_type=%s WHERE comment_type=%s', '', 'openid') );
	}
}
Ejemplo n.º 2
0
/**
 * Remove all identity urls from user.
 *
 * @param int $user_id user id
 */
function openid_drop_all_identities($user_id)
{
    global $wpdb;
    return $wpdb->query(wpdb_prepare('DELETE FROM ' . openid_identity_table() . ' WHERE user_id = %s', $user_id));
}
Ejemplo n.º 3
0
/**
 * Get the user associated with the specified OpenID.
 *
 * @param string $openid identifier to match
 * @return int|null ID of associated user, or null if no associated user
 * @access public
 * @since 3.0
 */
function get_user_by_openid($url) {
	global $wpdb;
	return $wpdb->get_var( $wpdb->prepare('SELECT user_id FROM '.openid_identity_table().' WHERE url = %s', $url) );
}
Ejemplo n.º 4
0
/**
 * Create OpenID related tables in the WordPress database.
 */
function openid_create_tables()
{
    global $wp_version, $wpdb;
    $store = openid_getStore();
    if ($wp_version >= '2.3') {
        require_once ABSPATH . 'wp-admin/includes/upgrade.php';
    } else {
        require_once ABSPATH . 'wp-admin/admin-db.php';
        require_once ABSPATH . 'wp-admin/upgrade-functions.php';
    }
    // Create the SQL and call the WP schema upgrade function
    $statements = array("CREATE TABLE " . openid_identity_table() . " (\n\t\tuurl_id bigint(20) NOT NULL auto_increment,\n\t\tuser_id bigint(20) NOT NULL default '0',\n\t\turl text,\n\t\thash char(32),\n\t\tPRIMARY KEY  (uurl_id),\n\t\tUNIQUE KEY uurl (hash),\n\t\tKEY url (url(30)),\n\t\tKEY user_id (user_id)\n\t\t)");
    $sql = implode(';', $statements);
    dbDelta($sql);
    update_option('openid_db_revision', OPENID_DB_REVISION);
}