]> git.mjollnir.org Git - moodle.git/commitdiff
Fixing authdb->close() in some places. Credir goes to Seiti. MDL-9212
authorstronk7 <stronk7>
Thu, 5 Apr 2007 22:22:28 +0000 (22:22 +0000)
committerstronk7 <stronk7>
Thu, 5 Apr 2007 22:22:28 +0000 (22:22 +0000)
Merged from MOODLE_18_STABLE

auth/db/auth.php

index 1bc28a580e4ff3613790612efa8b38ee4f4fd46a..4e742c8dd21163c3eca11ab1562bd3aadfe24abe 100644 (file)
@@ -182,6 +182,7 @@ class auth_plugin_db extends auth_plugin_base {
         }
         $authdb->Close();
         return $result;
+
     }
 
 
@@ -390,6 +391,9 @@ class auth_plugin_db extends auth_plugin_base {
 
     function user_exists($username) {
 
+    /// Init result value
+        $result = false;
+
         $textlib = textlib_get_instance();
         $extusername = $textlib->convert(stripslashes($username), 'utf-8', $this->config->extencoding);
 
@@ -397,46 +401,40 @@ class auth_plugin_db extends auth_plugin_base {
 
         $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;
     }
 
     /**