function releaseLock($tid, $id = 0) { global $thisstaff; if ($id && is_numeric($id)) { //Lock Id provided! $lock = TicketLock::lookup($id, $tid); //Already gone? if (!$lock || !$lock->getStaffId() || $lock->isExpired()) { //Said lock doesn't exist or is is expired return 1; } //make sure the user actually owns the lock before releasing it. return $lock->getStaffId() == $thisstaff->getId() && $lock->release() ? 1 : 0; } elseif ($tid) { //release all the locks the user owns on the ticket. return TicketLock::removeStaffLocks($thisstaff->getId(), $tid) ? 1 : 0; } return 0; }
function getLock() { if (!$this->tlock && $this->getLockId()) { $this->tlock = TicketLock::lookup($this->getLockId(), $this->getId()); } return $this->tlock; }