Skip to content
Browse files

Fixing authdb->close() in some places. Credir goes to Seiti. MDL-9212

  • Loading branch information...
1 parent b60f49c commit f16220e6a9270fe6d2022ad6e409fd665a67d27f stronk7 committed Apr 5, 2007
Showing with 17 additions and 19 deletions.
  1. +17 −19 auth/db/auth.php
View
36 auth/db/auth.php
@@ -182,6 +182,7 @@ function get_userinfo($username) {
}
$authdb->Close();
return $result;
+
}
@@ -390,53 +391,50 @@ function sync_users($do_updates=false) {
function user_exists($username) {
+ /// Init result value
+ $result = false;
+
$textlib = textlib_get_instance();
$extusername = $textlib->convert(stripslashes($username), 'utf-8', $this->config->extencoding);
$authdb = $this->db_init();
$rs = $authdb->Execute("SELECT * FROM {$this->config->table}
WHERE {$this->config->fielduser} = '".$this->ext_addslashes($extusername)."' ");
- $authdb->Close();
if (!$rs) {
print_error('auth_dbcantconnect','auth');
- return false;
- }
-
- if ( $rs->RecordCount() ) {
+ } else if ( $rs->RecordCount() ) {
// user exists exterally
- return $rs->RecordCount();
- } else {
- // user does not exist externally
- return false;
+ $result = $rs->RecordCount();
}
+
+ $authdb->Close();
+ return $result;
}
function get_userlist() {
+ /// Init result value
+ $result = array();
+
$authdb = $this->db_init();
// fetch userlist
$rs = $authdb->Execute("SELECT {$this->config->fielduser} AS username
FROM {$this->config->table} ");
- $authdb->Close();
if (!$rs) {
print_error('auth_dbcantconnect','auth');
- return false;
- }
-
- if ( $rs->RecordCount() ) {
- $userlist = array();
+ } else if ( $rs->RecordCount() ) {
while ($rec = rs_fetch_next_record($rs)) {
- array_push($userlist, $rec->username);
+ array_push($result, $rec->username);
}
- return $userlist;
- } else {
- return array();
}
+
+ $authdb->Close();
+ return $result;
}
/**

0 comments on commit f16220e

Please sign in to comment.
Something went wrong with that request. Please try again.