diff options
author | Andreas Gohr <andi@splitbrain.org> | 2009-09-11 10:18:33 +0200 |
---|---|---|
committer | Andreas Gohr <andi@splitbrain.org> | 2009-09-11 10:18:33 +0200 |
commit | 1246e01639ddb1343de1532a6a46182c4137ca7a (patch) | |
tree | d7d67d3bfb6cdca3e3102b65d501ebd402c64e1c /inc/actions.php | |
parent | a29759c7b5b6da57539d8b25d25cbd43c68ad917 (diff) | |
download | rpg-1246e01639ddb1343de1532a6a46182c4137ca7a.tar.gz rpg-1246e01639ddb1343de1532a6a46182c4137ca7a.tar.bz2 |
One click revert for managers
Ignore-this: e3c9b5f941b2f1aa83ca375861203a2f
This patch adds another button for users with the $conf['manager'] role when
viewing an old revision. It allows them to revert to this revision with a
single click.
darcs-hash:20090911081833-7ad00-5a64feb7e3e1b37178295c290a6c97c3923e82e3.gz
Diffstat (limited to 'inc/actions.php')
-rw-r--r-- | inc/actions.php | 53 |
1 files changed, 51 insertions, 2 deletions
diff --git a/inc/actions.php b/inc/actions.php index 27aa37515..d61781629 100644 --- a/inc/actions.php +++ b/inc/actions.php @@ -79,6 +79,15 @@ function act_dispatch(){ } } + //revert + if($ACT == 'revert'){ + if(checkSecurityToken()){ + $ACT = act_revert($ACT); + }else{ + $ACT = 'show'; + } + } + //save if($ACT == 'save'){ if(checkSecurityToken()){ @@ -185,7 +194,7 @@ function act_clean($act){ //disable all acl related commands if ACL is disabled if(!$conf['useacl'] && in_array($act,array('login','logout','register','admin', - 'subscribe','unsubscribe','profile', + 'subscribe','unsubscribe','profile','revert', 'resendpwd','subscribens','unsubscribens',))){ msg('Command unavailable: '.htmlspecialchars($act),-1); return 'show'; @@ -193,7 +202,7 @@ function act_clean($act){ if(!in_array($act,array('login','logout','register','save','cancel','edit','draft', 'preview','search','show','check','index','revisions', - 'diff','recent','backlink','admin','subscribe', + 'diff','recent','backlink','admin','subscribe','revert', 'unsubscribe','profile','resendpwd','recover','wordblock', 'draftdel','subscribens','unsubscribens',)) && substr($act,0,7) != 'export_' ) { msg('Command unknown: '.htmlspecialchars($act),-1); @@ -225,6 +234,9 @@ function act_permcheck($act){ } }elseif(in_array($act,array('login','search','recent','profile'))){ $permneed = AUTH_NONE; + }elseif($act == 'revert'){ + $permneed = AUTH_ADMIN; + if($INFO['ismanager']) $permneed = AUTH_EDIT; }elseif($act == 'register'){ $permneed = AUTH_NONE; }elseif($act == 'resendpwd'){ @@ -320,6 +332,43 @@ function act_save($act){ } /** + * Revert to a certain revision + * + * @author Andreas Gohr <andi@splitbrain.org> + */ +function act_revert($act){ + global $ID; + global $REV; + global $lang; + + // when no revision is given, delete current one + // FIXME this feature is not exposed in the GUI currently + $text = ''; + $sum = $lang['deleted']; + if($REV){ + $text = rawWiki($ID,$REV); + if(!$text) return 'show'; //something went wrong + $sum = $lang['restored']; + } + + // spam check + if(checkwordblock($Text)) + return 'wordblock'; + + saveWikiText($ID,$text,$sum,false); + msg($sum,1); + + //delete any draft + act_draftdel($act); + session_write_close(); + + // when done, show current page + $_SERVER['REQUEST_METHOD'] = 'post'; //should force a redirect + $REV = ''; + return 'show'; +} + +/** * Do a redirect after receiving post data * * Tries to add the section id as hash mark after section editing |