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

Fix thread lookup functions.

parent 0cfa7353
Branches
Tags
No related merge requests found
...@@ -163,9 +163,12 @@ Class ThreadEntry { ...@@ -163,9 +163,12 @@ Class ThreadEntry {
/* static calls */ /* static calls */
function _lookup($id, $type='', $tid=0) { function lookup($id, $tid=0, $type='') {
return ($id && is_numeric($id) return ($id
&& ($e = new ThreadEntry($id, $type, $tid)) && $e->getId()==$id)?$e:null; && is_numeric($id)
&& ($e = new ThreadEntry($id, $type, $tid))
&& $e->getId()==$id
)?$e:null;
} }
} }
...@@ -180,8 +183,13 @@ class Message extends ThreadEntry { ...@@ -180,8 +183,13 @@ class Message extends ThreadEntry {
return $this->getTitle(); return $this->getTitle();
} }
function lookup($id, $tid) { function lookup($id, $tid, $type='M') {
return parent::_lookup($id, 'M', $tid);
return ($id
&& is_numeric($id)
&& ($m = new Message($id, $tid))
&& $m->getId()==$id
)?$m:null;
} }
} }
...@@ -200,8 +208,13 @@ class Response extends ThreadEntry { ...@@ -200,8 +208,13 @@ class Response extends ThreadEntry {
return $this->getStaff(); return $this->getStaff();
} }
function lookup($id, $tid) { function lookup($id, $tid, $type='R') {
return parent::_lookup($id, 'R', $tid);
return ($id
&& is_numeric($id)
&& ($r = new Response($id, $tid))
&& $r->getId()==$id
)?$r:null;
} }
} }
...@@ -216,7 +229,13 @@ class Note extends ThreadEntry { ...@@ -216,7 +229,13 @@ class Note extends ThreadEntry {
return $this->getBody(); return $this->getBody();
} }
function lookup($id, $tid) { function lookup($id, $tid, $type='N') {
return parent::_lookup($id, 'N', $tid);
return ($id
&& is_numeric($id)
&& ($n = new Note($id, $tid))
&& $n->getId()==$id
)?$n:null;
} }
} }
?>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment