Merge pull request #3346 from splitbrain/userrevert
Allow revert action for logged in users only
This commit is contained in:
commit
769d8ef12d
|
@ -17,7 +17,7 @@ abstract class AbstractUserAction extends AbstractAclAction {
|
|||
public function checkPreconditions() {
|
||||
parent::checkPreconditions();
|
||||
global $INPUT;
|
||||
if(!$INPUT->server->str('REMOTE_USER')) {
|
||||
if($INPUT->server->str('REMOTE_USER') === '') {
|
||||
throw new ActionUserRequiredException();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,10 +12,12 @@ use dokuwiki\Action\Exception\ActionException;
|
|||
*
|
||||
* @package dokuwiki\Action
|
||||
*/
|
||||
class Revert extends AbstractAction {
|
||||
class Revert extends AbstractUserAction
|
||||
{
|
||||
|
||||
/** @inheritdoc */
|
||||
public function minimumPermission() {
|
||||
public function minimumPermission()
|
||||
{
|
||||
return AUTH_EDIT;
|
||||
}
|
||||
|
||||
|
@ -26,7 +28,8 @@ class Revert extends AbstractAction {
|
|||
* @throws ActionException
|
||||
* @todo check for writability of the current page ($INFO might do it wrong and check the attic version)
|
||||
*/
|
||||
public function preProcess() {
|
||||
public function preProcess()
|
||||
{
|
||||
if (!checkSecurityToken()) throw new ActionException();
|
||||
|
||||
global $ID;
|
||||
|
|
|
@ -7,15 +7,18 @@ namespace dokuwiki\Menu\Item;
|
|||
*
|
||||
* Quick revert to the currently shown page revision
|
||||
*/
|
||||
class Revert extends AbstractItem {
|
||||
class Revert extends AbstractItem
|
||||
{
|
||||
|
||||
/** @inheritdoc */
|
||||
public function __construct() {
|
||||
public function __construct()
|
||||
{
|
||||
global $REV;
|
||||
global $INFO;
|
||||
global $INPUT;
|
||||
parent::__construct();
|
||||
|
||||
if(!$REV || !$INFO['writable']) {
|
||||
if (!$REV || !$INFO['writable'] || $INPUT->server->str('REMOTE_USER') === '') {
|
||||
throw new \RuntimeException('revert not available');
|
||||
}
|
||||
$this->params['rev'] = $REV;
|
||||
|
|
Loading…
Reference in New Issue