Add token check to the Thread::load method

This commit is contained in:
Dmitriy Simushev 2012-09-21 15:57:54 +00:00
parent 5c7d525871
commit 1613a1052e

View File

@ -222,7 +222,7 @@ Class Thread {
* @param int $id ID of the thread to load
* @return boolean|Thread Returns an object of the Thread class or boolean false on failure
*/
public static function load($id) {
public static function load($id, $last_token = null) {
// Check $id
if (empty($id)) {
return false;
@ -235,6 +235,12 @@ Class Thread {
if ($thread->id != $id) {
return false;
}
// Check last token
if (! is_null($last_token)) {
if ($thread->lastToken != $last_token) {
return false;
}
}
return $thread;
}