Skip to content
Snippets Groups Projects
Commit 3f1edadb authored by Peter Rotich's avatar Peter Rotich
Browse files

Add client lookup by email

parent 6a3297b9
No related branches found
No related tags found
No related merge requests found
......@@ -30,12 +30,12 @@ class Client {
var $ht;
function Client($email,$id) {
function Client($id, $email=null) {
$this->id =0;
$this->load($id,$email);
}
function load($id=0, $email='') {
function load($id=0, $email=null) {
if(!$id && !($id=$this->getId()))
return false;
......@@ -115,8 +115,23 @@ class Client {
}
/* ------------- Static ---------------*/
function lookup($id, $email) {
function getLastTicketIdByEmail($email) {
$sql='SELECT ticketID FROM '.TICKET_TABLE
.' WHERE email='.db_input($email)
.' ORDER BY created '
.' LIMIT 1';
if(($res=db_query($sql)) && db_num_rows($res))
list($tid) = db_fetch_row($res);
return $tid;
}
function lookup($id, $email=null) {
return ($id && is_numeric($id) && ($c=new Client($id,$email)) && $c->getId()==$id)?$c:null;
}
function lookupByEmail($email) {
return (($id=self::getLastTicketIdByEmail($email)))?self::lookup($id, $email):null;
}
}
?>
......@@ -107,8 +107,8 @@ class ClientSession extends Client {
var $session;
function ClientSession($email,$id){
parent::Client($email,$id);
function ClientSession($email, $id){
parent::Client($id, $email);
$this->session= new UserSession($email);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment