コード例 #1
0
ファイル: ajax.tickets.php プロジェクト: supaket/helpdesk
 function releaseLock($params)
 {
     global $thisuser;
     if ($params['id'] && is_numeric($params['id'])) {
         //Lock Id provided!
         $lock = new TicketLock($params['id']);
         //Already gone?
         if (!$lock->load() || !$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() == $thisuser->getId() && $lock->release() ? 1 : 0;
     } elseif ($params['tid']) {
         //release all the locks the user owns on the ticket.
         return TicketLock::removeStaffLocks($thisuser->getId(), $params['tid']) ? 1 : 0;
     }
     return 0;
 }
コード例 #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() . '}';
 }