diff options
author | Kjartan Mannes <kjartan@2.no-reply.drupal.org> | 2002-09-08 18:48:49 +0000 |
---|---|---|
committer | Kjartan Mannes <kjartan@2.no-reply.drupal.org> | 2002-09-08 18:48:49 +0000 |
commit | bd650f9f8e0e6d4b9c9791d4f5210f4470a14540 (patch) | |
tree | d4f21759d9e1ba4e966993bf33b71ff023c2a1cc /modules/user.module | |
parent | ba4363016cafcf7b595beb49babddceee58aac2f (diff) | |
download | brdo-bd650f9f8e0e6d4b9c9791d4f5210f4470a14540.tar.gz brdo-bd650f9f8e0e6d4b9c9791d4f5210f4470a14540.tar.bz2 |
- fixing creation of first user.
- password is now printed for uid 1.
- made user_fields() always return something.
Diffstat (limited to 'modules/user.module')
-rw-r--r-- | modules/user.module | 25 |
1 files changed, 17 insertions, 8 deletions
diff --git a/modules/user.module b/modules/user.module index 8c1dbcbfa..8a1f58dc8 100644 --- a/modules/user.module +++ b/modules/user.module @@ -94,6 +94,7 @@ function user_save($account, $array = array()) { ** Dynamically compose a SQL query: */ + $user_fields = user_fields(); if ($account->uid) { $data = unserialize(db_result(db_query("SELECT data FROM users WHERE uid = '$account->uid'"))); foreach ($array as $key => $value) { @@ -101,7 +102,7 @@ function user_save($account, $array = array()) { $query .= "$key = '". md5($value) ."', "; } else if (substr($key, 0, 4) !== "auth") { - if (in_array($key, user_fields())) { + if (in_array($key, $user_fields)) { $query .= "$key = '". check_query($value) ."', "; } else { @@ -124,7 +125,7 @@ function user_save($account, $array = array()) { $values[] = "'". md5($value) ."'"; } else if (substr($key, 0, 4) !== "auth") { - if (in_array($key, user_fields())) { + if (in_array($key, user_fields)) { $fields[] = check_query($key); $values[] = "'". check_query($value) ."'"; } @@ -277,10 +278,13 @@ function user_fields() { if (!$fields) { $result = db_query("SELECT * FROM users WHERE uid = 1"); - $fields = array_keys(db_fetch_array($result)); + if (db_num_rows($result)) { + $fields = array_keys(db_fetch_array($result)); + } } - return $fields; + // Make sure we return the default fields at least + return is_array($fields) ? $fields: array("uid", "name", "pass", "mail", "homepage", "mode", "sort", "threshold", "theme", "signature", "timestamp", "hostname", "status", "timezone", "rating", "language", "sid", "init", "session", "data", "rid"); } /*** Module hooks **********************************************************/ @@ -610,6 +614,7 @@ function user_login($edit = array(), $msg = "") { if ($msg) { $output .= "<p>$msg</p>"; } + //TODO: alter text if there are not affiliates $output .= form_textfield(t("Username"), "name", $edit["name"], 20, 64, t("Enter your %s username, or an ID from one of our affiliates: %a.", array("%s" => variable_get("site_name", "local"), "%a" => implode(", ", user_auth_help_links())))); $output .= form_password(t("Password"), "pass", $pass, 20, 64, t("Enter the password that accompanies your username.")); $output .= form_checkbox(t("Remember me"), "remember_me", 1, 0, 0); @@ -763,13 +768,13 @@ function user_register($edit = array()) { if ($success) { - watchdog("user", "new user: '". $edit["name"] ."' <". $edit["mail"] .">"); - $from = variable_get("site_mail", ini_get("sendmail_from")); $pass = user_password(); // create new user account, noting whether administrator approval is required + admin_access_init(); $account = user_save("", array_merge(array("name" => $edit["name"], "pass" => $pass, "init" => $edit["mail"], "mail" => $edit["mail"], "rid" => _user_authenticated_id(), "status" => (variable_get("user_register", 1) == 1 ? 1 : 0)), $data)); + watchdog("user", "new user: '". $edit["name"] ."' <". $edit["mail"] .">"); $variables = array("%username" => $edit["name"], "%site" => variable_get("site_name", "drupal"), "%password" => $pass, "%uri" => path_uri(), "%uri_brief" => path_uri(1), "%mailto" => $edit["mail"], "%date" => format_date(time())); @@ -1470,10 +1475,14 @@ function user_admin_account() { function admin_access_init() { $role = db_fetch_object(db_query("SELECT * FROM role WHERE name = 'anonymous user'")); - if (!$role) db_query("INSERT INTO role (name) VALUES ('anonymous user')"); + if (!$role) { + db_query("INSERT INTO role (name) VALUES ('anonymous user')"); + } $role = db_fetch_object(db_query("SELECT * FROM role WHERE name = 'authenticated user'")); - if (!$role) db_query("INSERT INTO role (name) VALUES ('authenticated user')"); + if (!$role) { + db_query("INSERT INTO role (name) VALUES ('authenticated user')"); + } } function user_admin() { |