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,8 +28,9 @@ 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() {
|
||||
if(!checkSecurityToken()) throw new ActionException();
|
||||
public function preProcess()
|
||||
{
|
||||
if (!checkSecurityToken()) throw new ActionException();
|
||||
|
||||
global $ID;
|
||||
global $REV;
|
||||
|
@ -37,14 +40,14 @@ class Revert extends AbstractAction {
|
|||
// FIXME this feature is not exposed in the GUI currently
|
||||
$text = '';
|
||||
$sum = $lang['deleted'];
|
||||
if($REV) {
|
||||
if ($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));
|
||||
}
|
||||
|
||||
// spam check
|
||||
if(checkwordblock($text)) {
|
||||
if (checkwordblock($text)) {
|
||||
msg($lang['wordblock'], -1);
|
||||
throw new ActionException('edit');
|
||||
}
|
||||
|
|
|
@ -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