/** * List all deleted contributions. * The logged in user must have the 'deletedhistory' right * * @access public * @param bool $content Whether or not to return content of each contribution. Default false * @param string $start Timestamp to start at. Default null. * @param string $end Timestamp to end at. Default null. * @param string $dir Direction to list. Default 'older' * @param array $prop Information to retrieve. Default array( 'revid', 'user', 'parsedcomment', 'minor', 'len', 'content', 'token' ) * @return array */ public function deletedcontribs($content = false, $start = null, $end = null, $dir = 'older', $prop = array('revid', 'user', 'parsedcomment', 'minor', 'len', 'content', 'token')) { if (!in_array('deletedhistory', $this->wiki->get_userrights())) { pecho("User is not allowed to view deleted revisions", PECHO_FATAL); return false; } if ($content) { $prop[] = 'content'; } $drArray = array('_code' => 'dr', 'list' => 'deletedrevs', 'druser' => $this->username, 'drprop' => implode('|', $prop), 'drdir' => $dir); if (!is_null($start)) { $drArray['drstart'] = $start; } if (!is_null($end)) { $drArray['drend'] = $end; } Hooks::runHook('StartDelrevs', array(&$drArray)); pecho("Getting deleted revisions by {$this->username}...\n\n", PECHO_NORMAL); return $this->wiki->listHandler($drArray); }
public function rollback($force = false, $summary = null, $markbot = false, $watch = null) { global $pgNotag, $pgTag; if (!in_array('rollback', $this->wiki->get_userrights())) { pecho("User is not allowed to rollback edits", PECHO_FATAL); return false; } if (!$force) { try { $this->preEditChecks(); } catch (EditError $e) { pecho("Error: {$e}\n\n", PECHO_FATAL); return false; } } $history = $this->history(1, 'older', false, null, true); $params = array('action' => 'rollback', 'title' => $this->title, 'user' => $history[0]['user'], 'token' => $history[0]['rollbacktoken']); if (!is_null($summary)) { if (mb_strlen($summary, '8bit') > 255) { pecho("Summary is over 255 bytes, the maximum allowed.\n\n", PECHO_FATAL); return false; } if (!$pgNotag) { $summary .= $pgTag; } $params['summary'] = $summary; } if ($markbot) { $params['markbot'] = 'yes'; } if (!is_null($watch)) { if ($watch) { $params['watchlist'] = 'watch'; } elseif (!$watch) { $params['watchlist'] = 'nochange'; } elseif (in_array($watch, array('watch', 'unwatch', 'preferences', 'nochange'))) { $params['watchlist'] = $watch; } else { pecho("Watch parameter set incorrectly. Omitting...\n\n", PECHO_WARN); } } try { $this->preEditChecks("Rollback"); } catch (EditError $e) { pecho("Error: {$e}\n\n", PECHO_FATAL); return false; } Hooks::runHook('PreRollback', array(&$params)); pecho("Rolling back {$this->title}...\n\n", PECHO_NOTICE); $result = $this->wiki->apiQuery($params, true); if (isset($result['rollback'])) { if (isset($result['rollback']['title'])) { $this->__construct($this->wiki, $this->title); return true; } else { pecho("Rollback error...\n\n" . print_r($result['rollback'], true) . "\n\n", PECHO_FATAL); return false; } } else { pecho("Rollback error...\n\n" . print_r($result, true), PECHO_FATAL); return false; } }