Upgrade to 3.3.4

This commit is contained in:
Bastian Allgeier
2020-02-18 09:52:14 +01:00
parent 9c87f2fbc3
commit 211e325864
16 changed files with 11378 additions and 145 deletions

View File

@@ -40,6 +40,24 @@ class ContentLock
$this->data = $this->kirby()->locks()->get($model);
}
/**
* Clears the lock unconditionally
*
* @return bool
*/
protected function clearLock(): bool
{
// if no lock exists, skip
if (isset($this->data['lock']) === false) {
return true;
}
// remove lock
unset($this->data['lock']);
return $this->kirby()->locks()->set($this->model, $this->data);
}
/**
* Sets lock with the current user
*
@@ -74,19 +92,20 @@ class ContentLock
{
$data = $this->data['lock'] ?? [];
if (
empty($data) === false &&
$data['user'] !== $this->user()->id() &&
$user = $this->kirby()->user($data['user'])
) {
$time = (int)($data['time']);
if (empty($data) === false && $data['user'] !== $this->user()->id()) {
if ($user = $this->kirby()->user($data['user'])) {
$time = (int)($data['time']);
return [
'user' => $user->id(),
'email' => $user->email(),
'time' => $time,
'unlockable' => ($time + 60) <= time()
];
return [
'user' => $user->id(),
'email' => $user->email(),
'time' => $time,
'unlockable' => ($time + 60) <= time()
];
}
// clear lock if user not found
$this->clearLock();
}
return false;
@@ -150,10 +169,7 @@ class ContentLock
]);
}
// remove lock
unset($this->data['lock']);
return $this->kirby()->locks()->set($this->model, $this->data);
return $this->clearLock();
}
/**
@@ -193,10 +209,7 @@ class ContentLock
$this->data['unlock'] = $this->data['unlock'] ?? [];
$this->data['unlock'][] = $this->data['lock']['user'];
// remove lock
unset($this->data['lock']);
return $this->kirby()->locks()->set($this->model, $this->data);
return $this->clearLock();
}
/**