<?php
 // Include the class:

require_once("../include/constants.php");
require_once("../include/db.class.php"); 

     
class account
{

     //This function returns a data row for the given user
     function queryUser($adminID)
     {
     
        $db = new DB();
        $queryResult= $db->query("SELECT * FROM Administrator
                                    WHERE adminID='$adminID'");
        $result=$db->fetchNextObject($queryResult); 
        return $result;
     
     
     }
  
     //This function updates user info in the database
     function updateUser($adminID, $email, $phone, $backupPhone, $backupEmail)
     {
		 	$s="UPDATE Administrator SET email='%s',phone='%s',backupPhone='%s', backupEmail='%s' WHERE adminID='$adminID'";
			$sql=sprintf($s,
				get_magic_quotes_gpc() ?$email : addslashes($email),
				get_magic_quotes_gpc() ?$phone : addslashes($phone),
				get_magic_quotes_gpc() ?$backupPhone : addslashes($backupPhone),
				get_magic_quotes_gpc() ?$backupEmail : addslashes($backupEmail));
		            
            $db = new DB();
                
            $queryResult= $db->execute($sql);
             
            return $queryResult;
         
     }
       //This function updates user password in the database
     function updateUserPassword($adminID, $password)
     {
          if(strlen(trim($password))!=0 || !is_null($password))
          {
            $password = md5($password);
            
            $s="UPDATE Administrator SET password='$password' WHERE adminID='$adminID'";
            
            $db = new DB();
                
            $queryResult= $db->execute($s);
             
            return $queryResult;
          }
          return false;
         
     }
     //------------------------------------------------------------------------------------------
     //This function checks to see if a user with this name exists in the system.
     //if a user with this name exists, return true; else false;
     function userEmailDuplicateCheck($email)
     {
         $db = new DB(); 
        if(!get_magic_quotes_gpc()){
            $email = addslashes($email);
        }
        $q = "SELECT adminID FROM Administrator WHERE email='$email'";
        $result = $db->query($q);
        return (mysql_numrows($result) > 0);
     }
    
  
}
?>
