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() {
|
public function checkPreconditions() {
|
||||||
parent::checkPreconditions();
|
parent::checkPreconditions();
|
||||||
global $INPUT;
|
global $INPUT;
|
||||||
if(!$INPUT->server->str('REMOTE_USER')) {
|
if($INPUT->server->str('REMOTE_USER') === '') {
|
||||||
throw new ActionUserRequiredException();
|
throw new ActionUserRequiredException();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,10 +12,12 @@ use dokuwiki\Action\Exception\ActionException;
|
||||||
*
|
*
|
||||||
* @package dokuwiki\Action
|
* @package dokuwiki\Action
|
||||||
*/
|
*/
|
||||||
class Revert extends AbstractAction {
|
class Revert extends AbstractUserAction
|
||||||
|
{
|
||||||
|
|
||||||
/** @inheritdoc */
|
/** @inheritdoc */
|
||||||
public function minimumPermission() {
|
public function minimumPermission()
|
||||||
|
{
|
||||||
return AUTH_EDIT;
|
return AUTH_EDIT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -26,8 +28,9 @@ class Revert extends AbstractAction {
|
||||||
* @throws ActionException
|
* @throws ActionException
|
||||||
* @todo check for writability of the current page ($INFO might do it wrong and check the attic version)
|
* @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();
|
{
|
||||||
|
if (!checkSecurityToken()) throw new ActionException();
|
||||||
|
|
||||||
global $ID;
|
global $ID;
|
||||||
global $REV;
|
global $REV;
|
||||||
|
@ -37,14 +40,14 @@ class Revert extends AbstractAction {
|
||||||
// FIXME this feature is not exposed in the GUI currently
|
// FIXME this feature is not exposed in the GUI currently
|
||||||
$text = '';
|
$text = '';
|
||||||
$sum = $lang['deleted'];
|
$sum = $lang['deleted'];
|
||||||
if($REV) {
|
if ($REV) {
|
||||||
$text = rawWiki($ID, $REV);
|
$text = rawWiki($ID, $REV);
|
||||||
if(!$text) throw new ActionException(); //something went wrong
|
if (!$text) throw new ActionException(); //something went wrong
|
||||||
$sum = sprintf($lang['restored'], dformat($REV));
|
$sum = sprintf($lang['restored'], dformat($REV));
|
||||||
}
|
}
|
||||||
|
|
||||||
// spam check
|
// spam check
|
||||||
if(checkwordblock($text)) {
|
if (checkwordblock($text)) {
|
||||||
msg($lang['wordblock'], -1);
|
msg($lang['wordblock'], -1);
|
||||||
throw new ActionException('edit');
|
throw new ActionException('edit');
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,15 +7,18 @@ namespace dokuwiki\Menu\Item;
|
||||||
*
|
*
|
||||||
* Quick revert to the currently shown page revision
|
* Quick revert to the currently shown page revision
|
||||||
*/
|
*/
|
||||||
class Revert extends AbstractItem {
|
class Revert extends AbstractItem
|
||||||
|
{
|
||||||
|
|
||||||
/** @inheritdoc */
|
/** @inheritdoc */
|
||||||
public function __construct() {
|
public function __construct()
|
||||||
|
{
|
||||||
global $REV;
|
global $REV;
|
||||||
global $INFO;
|
global $INFO;
|
||||||
|
global $INPUT;
|
||||||
parent::__construct();
|
parent::__construct();
|
||||||
|
|
||||||
if(!$REV || !$INFO['writable']) {
|
if (!$REV || !$INFO['writable'] || $INPUT->server->str('REMOTE_USER') === '') {
|
||||||
throw new \RuntimeException('revert not available');
|
throw new \RuntimeException('revert not available');
|
||||||
}
|
}
|
||||||
$this->params['rev'] = $REV;
|
$this->params['rev'] = $REV;
|
||||||
|
|
Loading…
Reference in New Issue