function lookup($id, $tid)
 {
     return $id && ($lock = new TicketLock($id, $tid)) && $lock->getId() == $id ? $lock : null;
 }
Exemple #2
0
 function renewLock($params)
 {
     global $thisuser;
     if (!$params['id'] or !is_numeric($params['id'])) {
         return '{"id":0, "retry":true}';
     }
     $lock = new TicketLock($params['id']);
     if (!$lock->load() || !$lock->getStaffId() || $lock->isExpired()) {
         //Said lock doesn't exist or is is expired
         return TicketsAjaxAPI::acquireLock($params);
     }
     //acquire the lock
     if ($lock->getStaffId() != $thisuser->getId()) {
         //user doesn't own the lock anymore??? sorry...try to next time.
         return '{"id":0, "retry":false}';
     }
     //Give up...
     //Renew the lock.
     $lock->renew();
     //Failure here is not an issue since the lock is not expired yet..
     return '{"id":' . $lock->getId() . ', "time":' . $lock->getTime() . '}';
 }