Commit 2e4bd357 authored by Dries's avatar Dries

- Patch #7723 by Roderik: added strtolower()s to make PostgreSQL behave like...

- Patch #7723 by Roderik: added strtolower()s to make PostgreSQL behave like MySQL and to be more 'forgiving' for users logging in on a PostgreSQL powered Drupal site.
parent 68d82828
...@@ -34,7 +34,7 @@ function user_load($array = array()) { ...@@ -34,7 +34,7 @@ function user_load($array = array()) {
$query .= "u.$key = '". md5($value) ."' AND "; $query .= "u.$key = '". md5($value) ."' AND ";
} }
else { else {
$query .= "u.$key = '". check_query($value) ."' AND "; $query .= "LOWER(u.$key) = '". strtolower(check_query($value)) ."' AND ";
} }
} }
$result = db_query_range("SELECT u.*, r.name AS role FROM {role} r INNER JOIN {users} u ON r.rid = u.rid WHERE $query u.status < 3", 0, 1); $result = db_query_range("SELECT u.*, r.name AS role FROM {role} r INNER JOIN {users} u ON r.rid = u.rid WHERE $query u.status < 3", 0, 1);
...@@ -297,10 +297,10 @@ function user_perm() { ...@@ -297,10 +297,10 @@ function user_perm() {
function user_search($keys) { function user_search($keys) {
$find = array(); $find = array();
// Replace wildcards with mysql wildcards // Replace wildcards with (MySQL/PostgreSQL wildcards
$keys = str_replace("*", "%", $keys); $keys = str_replace("*", "%", $keys);
$result = db_query_range("SELECT * FROM {users} WHERE name LIKE '%%%s%%'", $keys, 0, 20); $result = db_query_range("SELECT * FROM {users} WHERE LOWER(name) LIKE '%%%s%%'", strtolower($keys), 0, 20);
while ($account = db_fetch_object($result)) { while ($account = db_fetch_object($result)) {
$find[] = array("title" => $account->name, "link" => (strstr(request_uri(), "admin") ? url("admin/user/edit/$account->uid") : url("user/view/$account->uid")), 'user' => $account->name); $find[] = array("title" => $account->name, "link" => (strstr(request_uri(), "admin") ? url("admin/user/edit/$account->uid") : url("user/view/$account->uid")), 'user' => $account->name);
} }
...@@ -700,11 +700,11 @@ function user_pass($edit = array()) { ...@@ -700,11 +700,11 @@ function user_pass($edit = array()) {
global $base_url; global $base_url;
if ($edit['name']) { if ($edit['name']) {
$account = db_fetch_object(db_query("SELECT uid, name, mail FROM {users} WHERE status = 1 AND name = '%s'", $edit['name'])); $account = db_fetch_object(db_query("SELECT uid, name, mail FROM {users} WHERE status = 1 AND LOWER(name) = '%s'", strtolower($edit['name'])));
if (!$account) $error = t("Sorry. The username <i>%s</i> is not recognized.", array("%s" => $edit['name'])); if (!$account) $error = t("Sorry. The username <i>%s</i> is not recognized.", array("%s" => $edit['name']));
} }
else if ($edit['mail']) { else if ($edit['mail']) {
$account = db_fetch_object(db_query("SELECT uid, name, mail FROM {users} WHERE status = 1 AND mail = '%s'", $edit['mail'])); $account = db_fetch_object(db_query("SELECT uid, name, mail FROM {users} WHERE status = 1 AND LOWER(mail) = '%s'", strtolower($edit['mail'])));
if (!$account) $error = t("Sorry. The e-mail address <i>%s</i> is not recognized.", array("%s" => $edit['mail'])); if (!$account) $error = t("Sorry. The e-mail address <i>%s</i> is not recognized.", array("%s" => $edit['mail']));
} }
if ($account) { if ($account) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment