1168f9feeSAndreas Gohr<?php 2168f9feeSAndreas Gohrif(!defined('DOKU_INC')) define('DOKU_INC',realpath(dirname(__FILE__).'/../../../').'/'); 3168f9feeSAndreas Gohrif(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/'); 4168f9feeSAndreas Gohrrequire_once(DOKU_PLUGIN.'admin.php'); 5168f9feeSAndreas Gohrrequire_once(DOKU_INC.'inc/changelog.php'); 6168f9feeSAndreas Gohr 7168f9feeSAndreas Gohr/** 8168f9feeSAndreas Gohr * All DokuWiki plugins to extend the admin function 9168f9feeSAndreas Gohr * need to inherit from this class 10168f9feeSAndreas Gohr */ 11168f9feeSAndreas Gohrclass admin_plugin_revert extends DokuWiki_Admin_Plugin { 12168f9feeSAndreas Gohr var $cmd; 13168f9feeSAndreas Gohr 14168f9feeSAndreas Gohr /** 15168f9feeSAndreas Gohr * Constructor 16168f9feeSAndreas Gohr */ 17168f9feeSAndreas Gohr function admin_plugin_revert(){ 18168f9feeSAndreas Gohr $this->setupLocale(); 19168f9feeSAndreas Gohr } 20168f9feeSAndreas Gohr 21168f9feeSAndreas Gohr /** 22168f9feeSAndreas Gohr * return some info 23168f9feeSAndreas Gohr */ 24168f9feeSAndreas Gohr function getInfo(){ 25168f9feeSAndreas Gohr return array( 26168f9feeSAndreas Gohr 'author' => 'Andreas Gohr', 27168f9feeSAndreas Gohr 'email' => 'andi@splitbrain.org', 28122b469fSAndreas Gohr 'date' => '2005-11-10', 29168f9feeSAndreas Gohr 'name' => 'Revert Manager', 30168f9feeSAndreas Gohr 'desc' => 'Allows you to mass revert recent edits', 31168f9feeSAndreas Gohr 'url' => 'http://wiki.splitbrain.org/plugin:revert', 32168f9feeSAndreas Gohr ); 33168f9feeSAndreas Gohr } 34168f9feeSAndreas Gohr 35168f9feeSAndreas Gohr /** 36f8cc712eSAndreas Gohr * access for managers 37f8cc712eSAndreas Gohr */ 38f8cc712eSAndreas Gohr function forAdminOnly(){ 39f8cc712eSAndreas Gohr return false; 40f8cc712eSAndreas Gohr } 41f8cc712eSAndreas Gohr 42f8cc712eSAndreas Gohr /** 43168f9feeSAndreas Gohr * return sort order for position in admin menu 44168f9feeSAndreas Gohr */ 45168f9feeSAndreas Gohr function getMenuSort() { 46168f9feeSAndreas Gohr return 40; 47168f9feeSAndreas Gohr } 48168f9feeSAndreas Gohr 49168f9feeSAndreas Gohr /** 50168f9feeSAndreas Gohr * handle user request 51168f9feeSAndreas Gohr */ 52168f9feeSAndreas Gohr function handle() { 53168f9feeSAndreas Gohr } 54168f9feeSAndreas Gohr 55168f9feeSAndreas Gohr /** 56168f9feeSAndreas Gohr * output appropriate html 57168f9feeSAndreas Gohr */ 58168f9feeSAndreas Gohr function html() { 59168f9feeSAndreas Gohr 60122b469fSAndreas Gohr echo $this->plugin_locale_xhtml('intro'); 61168f9feeSAndreas Gohr 62122b469fSAndreas Gohr $this->_searchform(); 63168f9feeSAndreas Gohr 64122b469fSAndreas Gohr if(is_array($_REQUEST['revert'])){ 65122b469fSAndreas Gohr $this->_revert($_REQUEST['revert']); 66122b469fSAndreas Gohr }elseif(isset($_REQUEST['filter'])){ 67168f9feeSAndreas Gohr $this->_list($_REQUEST['filter']); 68168f9feeSAndreas Gohr } 69122b469fSAndreas Gohr } 70168f9feeSAndreas Gohr 71122b469fSAndreas Gohr /** 72122b469fSAndreas Gohr * Display the form for searching spam pages 73122b469fSAndreas Gohr */ 74122b469fSAndreas Gohr function _searchform(){ 75122b469fSAndreas Gohr global $lang; 76122b469fSAndreas Gohr echo '<form action="" method="post">'; 77122b469fSAndreas Gohr echo '<label>'.$this->getLang('filter').': </label>'; 78122b469fSAndreas Gohr echo '<input type="text" name="filter" class="edit" value="'.hsc($_REQUEST['filter']).'" />'; 79122b469fSAndreas Gohr echo '<input type="submit" class="button" value="'.$lang['btn_search'].'" />'; 80122b469fSAndreas Gohr echo ' <span>'.$this->getLang('note').'</span>'; 81122b469fSAndreas Gohr echo '</form><br /><br />'; 82122b469fSAndreas Gohr } 83122b469fSAndreas Gohr 84122b469fSAndreas Gohr /** 85122b469fSAndreas Gohr * Start the reversion process 86122b469fSAndreas Gohr */ 87168f9feeSAndreas Gohr function _revert($revert){ 88168f9feeSAndreas Gohr global $conf; 89122b469fSAndreas Gohr 90122b469fSAndreas Gohr echo '<hr /><br />'; 91122b469fSAndreas Gohr echo '<p>'.$this->getLang('revstart').'</p>'; 92122b469fSAndreas Gohr 93122b469fSAndreas Gohr echo '<ul>'; 94168f9feeSAndreas Gohr foreach($revert as $id){ 95168f9feeSAndreas Gohr global $REV; 96168f9feeSAndreas Gohr $old = getRevisions($id, 0, 1); 97168f9feeSAndreas Gohr $REV = $old[0]; 98168f9feeSAndreas Gohr if($REV){ 99168f9feeSAndreas Gohr saveWikiText($id,rawWiki($id,$REV),'old revision restored',false); 100122b469fSAndreas Gohr printf('<li><div class="li">'.$this->getLang('reverted').'</div></li>',$id,$REV); 101168f9feeSAndreas Gohr }else{ 102168f9feeSAndreas Gohr saveWikiText($id,'','',false); 103122b469fSAndreas Gohr printf('<li><div class="li">'.$this->getLang('removed').'</div></li>',$id,$REV); 104168f9feeSAndreas Gohr } 105168f9feeSAndreas Gohr @set_time_limit(10); 106168f9feeSAndreas Gohr flush(); 107168f9feeSAndreas Gohr } 108122b469fSAndreas Gohr echo '</ul>'; 109122b469fSAndreas Gohr 110122b469fSAndreas Gohr echo '<p>'.$this->getLang('revstop').'</p>'; 111168f9feeSAndreas Gohr } 112168f9feeSAndreas Gohr 113122b469fSAndreas Gohr /** 114122b469fSAndreas Gohr * List recent edits matching the given filter 115122b469fSAndreas Gohr */ 116168f9feeSAndreas Gohr function _list($filter){ 117168f9feeSAndreas Gohr global $conf; 118122b469fSAndreas Gohr echo '<hr /><br />'; 119122b469fSAndreas Gohr echo '<form action="" method="post">'; 120122b469fSAndreas Gohr echo '<input type="hidden" name="filter" value="'.hsc($filter).'" />'; 121168f9feeSAndreas Gohr 122168f9feeSAndreas Gohr $recents = getRecents(0,800); 123122b469fSAndreas Gohr echo '<ul>'; 124168f9feeSAndreas Gohr 125122b469fSAndreas Gohr 126122b469fSAndreas Gohr $cnt = 0; 127168f9feeSAndreas Gohr foreach($recents as $recent){ 128168f9feeSAndreas Gohr if($filter){ 129168f9feeSAndreas Gohr if(strpos(rawWiki($recent['id']),$filter) === false) continue; 130168f9feeSAndreas Gohr } 131168f9feeSAndreas Gohr 132122b469fSAndreas Gohr $cnt++; 133168f9feeSAndreas Gohr $date = date($conf['dformat'],$recent['date']); 134168f9feeSAndreas Gohr 135*ebf1501fSBen Coburn echo ($recent['type']===DOKU_CHANGE_TYPE_MINOR_EDIT) ? '<li class="minor">' : '<li>'; 136122b469fSAndreas Gohr echo '<div class="li">'; 137122b469fSAndreas Gohr echo '<input type="checkbox" name="revert[]" value="'.hsc($recent['id']).'" checked="checked" id="revert__'.$cnt.'" />'; 138122b469fSAndreas Gohr echo '<label for="revert__'.$cnt.'">'.$date.'</label> '; 139168f9feeSAndreas Gohr 140122b469fSAndreas Gohr echo '<a href="'.wl($recent['id'],"do=diff").'">'; 141168f9feeSAndreas Gohr $p = array(); 142168f9feeSAndreas Gohr $p['src'] = DOKU_BASE.'lib/images/diff.png'; 143168f9feeSAndreas Gohr $p['width'] = 15; 144168f9feeSAndreas Gohr $p['height'] = 11; 145168f9feeSAndreas Gohr $p['title'] = $lang['diff']; 146168f9feeSAndreas Gohr $p['alt'] = $lang['diff']; 147168f9feeSAndreas Gohr $att = buildAttributes($p); 148122b469fSAndreas Gohr echo "<img $att />"; 149122b469fSAndreas Gohr echo '</a> '; 150168f9feeSAndreas Gohr 151122b469fSAndreas Gohr echo '<a href="'.wl($recent['id'],"do=revisions").'">'; 152168f9feeSAndreas Gohr $p = array(); 153168f9feeSAndreas Gohr $p['src'] = DOKU_BASE.'lib/images/history.png'; 154168f9feeSAndreas Gohr $p['width'] = 12; 155168f9feeSAndreas Gohr $p['height'] = 14; 156168f9feeSAndreas Gohr $p['title'] = $lang['btn_revs']; 157168f9feeSAndreas Gohr $p['alt'] = $lang['btn_revs']; 158168f9feeSAndreas Gohr $att = buildAttributes($p); 159122b469fSAndreas Gohr echo "<img $att />"; 160122b469fSAndreas Gohr echo '</a> '; 161168f9feeSAndreas Gohr 162122b469fSAndreas Gohr echo html_wikilink(':'.$recent['id'],$conf['useheading']?NULL:$recent['id']); 163122b469fSAndreas Gohr echo ' – '.htmlspecialchars($recent['sum']); 164168f9feeSAndreas Gohr 165122b469fSAndreas Gohr echo ' <span class="user">'; 166122b469fSAndreas Gohr echo $recent['user'].' '.$recent['ip']; 167122b469fSAndreas Gohr echo '</span>'; 168168f9feeSAndreas Gohr 169122b469fSAndreas Gohr echo '</div>'; 170122b469fSAndreas Gohr echo '</li>'; 171168f9feeSAndreas Gohr 172168f9feeSAndreas Gohr @set_time_limit(10); 173168f9feeSAndreas Gohr flush(); 174168f9feeSAndreas Gohr } 175122b469fSAndreas Gohr echo '</ul>'; 176168f9feeSAndreas Gohr 177122b469fSAndreas Gohr echo '<input type="submit" class="button" value="'.$this->getLang('revert').'" />'; 178122b469fSAndreas Gohr 179168f9feeSAndreas Gohr echo '</form>'; 180168f9feeSAndreas Gohr } 181168f9feeSAndreas Gohr 182168f9feeSAndreas Gohr} 183168f9feeSAndreas Gohr//Setup VIM: ex: et ts=4 enc=utf-8 : 184