defaultData(); $resource = $this->getResource($this->getRequestParameter('id')); $lockData = LockManager::getImplementation()->getLockData($resource); $this->setData( 'topclass-label', $this->hasRequestParameter('topclass-label') ? $this->getRequestParameter('topclass-label') : __('Resource') ); if (AclProxy::hasAccess($this->getSession()->getUser(), __CLASS__, 'forceRelease', ['uri' => $resource->getUri()])) { $this->setData('id', $resource->getUri()); $this->setData('forceRelease', true); } $this->setData('lockDate', $lockData->getCreationTime()); $this->setData('ownerHtml', UserHelper::renderHtmlUser($lockData->getOwnerId())); if ($this->hasRequestParameter('view') && $this->hasRequestParameter('ext')) { $this->setView($this->getRequestParameter('view'), $this->getRequestParameter('ext')); } else { $this->setView('Lock/locked.tpl', 'tao'); } } public function release($uri) { $resource = $this->getResource($uri); try { $userId = $this->getSession()->getUser()->getIdentifier(); $success = LockManager::getImplementation()->releaseLock($resource, $userId); return $this->returnJson([ 'success' => $success, 'message' => $success ? __('%s has been released', $resource->getLabel()) : __('%s could not be released', $resource->getLabel()) ]); //the connected user is not the owner of the lock } catch (common_exception_Unauthorized $e) { return $this->returnJson([ 'success' => false, 'message' => __('You are not authorised to remove this lock') ]); } } public function forceRelease($uri) { $success = LockManager::getImplementation()->forceReleaseLock( $this->getResource($uri) ); return $this->returnJson([ 'success' => $success ]); } }