public function execute($par) { $this->checkPermissions(); $this->checkReadOnly(); $output = $this->getOutput(); $user = $this->getUser(); $request = $this->getRequest(); // Check blocks if ($user->isBlocked()) { throw new UserBlockedError($user->getBlock()); } $this->setHeaders(); $this->outputHeader(); $this->getOutput()->addModules(['mediawiki.special.edittags', 'mediawiki.special.edittags.styles']); $this->submitClicked = $request->wasPosted() && $request->getBool('wpSubmit'); // Handle our many different possible input types $ids = $request->getVal('ids'); if (!is_null($ids)) { // Allow CSV from the form hidden field, or a single ID for show/hide links $this->ids = explode(',', $ids); } else { // Array input $this->ids = array_keys($request->getArray('ids', [])); } $this->ids = array_unique(array_filter($this->ids)); // No targets? if (count($this->ids) == 0) { throw new ErrorPageError('tags-edit-nooldid-title', 'tags-edit-nooldid-text'); } $this->typeName = $request->getVal('type'); $this->targetObj = Title::newFromText($request->getText('target')); // sanity check of parameter switch ($this->typeName) { case 'logentry': case 'logging': $this->typeName = 'logentry'; break; default: $this->typeName = 'revision'; break; } // Allow the list type to adjust the passed target // Yuck! Copied straight out of SpecialRevisiondelete, but it does exactly // what we want $this->targetObj = RevisionDeleter::suggestTarget($this->typeName === 'revision' ? 'revision' : 'logging', $this->targetObj, $this->ids); $this->isAllowed = $user->isAllowed('changetags'); $this->reason = $request->getVal('wpReason'); // We need a target page! if (is_null($this->targetObj)) { $output->addWikiMsg('undelete-header'); return; } // Give a link to the logs/hist for this page $this->showConvenienceLinks(); // Either submit or create our form if ($this->isAllowed && $this->submitClicked) { $this->submit(); } else { $this->showForm(); } // Show relevant lines from the tag log $tagLogPage = new LogPage('tag'); $output->addHTML("<h2>" . $tagLogPage->getName()->escaped() . "</h2>\n"); LogEventsList::showLogExtract($output, 'tag', $this->targetObj, '', ['lim' => 25, 'conds' => [], 'useMaster' => $this->wasSaved]); }
public function execute($par) { $this->useTransactionalTimeLimit(); $this->checkPermissions(); $this->checkReadOnly(); $output = $this->getOutput(); $user = $this->getUser(); $this->setHeaders(); $this->outputHeader(); $request = $this->getRequest(); $this->submitClicked = $request->wasPosted() && $request->getBool('wpSubmit'); # Handle our many different possible input types. $ids = $request->getVal('ids'); if (!is_null($ids)) { # Allow CSV, for backwards compatibility, or a single ID for show/hide links $this->ids = explode(',', $ids); } else { # Array input $this->ids = array_keys($request->getArray('ids', array())); } // $this->ids = array_map( 'intval', $this->ids ); $this->ids = array_unique(array_filter($this->ids)); $this->typeName = $request->getVal('type'); $this->targetObj = Title::newFromText($request->getText('target')); # For reviewing deleted files... $this->archiveName = $request->getVal('file'); $this->token = $request->getVal('token'); if ($this->archiveName && $this->targetObj) { $this->tryShowFile($this->archiveName); return; } $this->typeName = RevisionDeleter::getCanonicalTypeName($this->typeName); # No targets? if (!$this->typeName || count($this->ids) == 0) { throw new ErrorPageError('revdelete-nooldid-title', 'revdelete-nooldid-text'); } # Allow the list type to adjust the passed target $this->targetObj = RevisionDeleter::suggestTarget($this->typeName, $this->targetObj, $this->ids); # We need a target page! if ($this->targetObj === null) { $output->addWikiMsg('undelete-header'); return; } $this->typeLabels = self::$UILabels[$this->typeName]; $list = $this->getList(); $list->reset(); $bitfield = $list->current()->getBits(); $this->mIsAllowed = $user->isAllowed(RevisionDeleter::getRestriction($this->typeName)); $canViewSuppressedOnly = $this->getUser()->isAllowed('viewsuppressed') && !$this->getUser()->isAllowed('suppressrevision'); $pageIsSuppressed = $bitfield & Revision::DELETED_RESTRICTED; $this->mIsAllowed = $this->mIsAllowed && !($canViewSuppressedOnly && $pageIsSuppressed); $this->otherReason = $request->getVal('wpReason'); # Give a link to the logs/hist for this page $this->showConvenienceLinks(); # Initialise checkboxes $this->checks = array(array($this->typeLabels['check-label'], 'wpHidePrimary', RevisionDeleter::getRevdelConstant($this->typeName)), array('revdelete-hide-comment', 'wpHideComment', Revision::DELETED_COMMENT), array('revdelete-hide-user', 'wpHideUser', Revision::DELETED_USER)); if ($user->isAllowed('suppressrevision')) { $this->checks[] = array('revdelete-hide-restricted', 'wpHideRestricted', Revision::DELETED_RESTRICTED); } # Either submit or create our form if ($this->mIsAllowed && $this->submitClicked) { $this->submit($request); } else { $this->showForm(); } $qc = $this->getLogQueryCond(); # Show relevant lines from the deletion log $deleteLogPage = new LogPage('delete'); $output->addHTML("<h2>" . $deleteLogPage->getName()->escaped() . "</h2>\n"); LogEventsList::showLogExtract($output, 'delete', $this->targetObj, '', array('lim' => 25, 'conds' => $qc, 'useMaster' => $this->wasSaved)); # Show relevant lines from the suppression log if ($user->isAllowed('suppressionlog')) { $suppressLogPage = new LogPage('suppress'); $output->addHTML("<h2>" . $suppressLogPage->getName()->escaped() . "</h2>\n"); LogEventsList::showLogExtract($output, 'suppress', $this->targetObj, '', array('lim' => 25, 'conds' => $qc, 'useMaster' => $this->wasSaved)); } }
public function execute() { $this->useTransactionalTimeLimit(); $params = $this->extractRequestParams(); $user = $this->getUser(); if (!$user->isAllowed(RevisionDeleter::getRestriction($params['type']))) { $this->dieUsageMsg('badaccess-group0'); } if ($user->isBlocked()) { $block = $user->getBlock(); // Die using the appropriate message depending on block type if ($block->getType() == TYPE_AUTO) { $this->dieUsage('Your IP address has been blocked automatically, because it was used by a blocked user', 'autoblocked', 0, array('blockinfo' => ApiQueryUserInfo::getBlockInfo($block))); } else { $this->dieUsage('You have been blocked from editing', 'blocked', 0, array('blockinfo' => ApiQueryUserInfo::getBlockInfo($block))); } } if (!$params['ids']) { $this->dieUsage("At least one value is required for 'ids'", 'badparams'); } $hide = $params['hide'] ?: array(); $show = $params['show'] ?: array(); if (array_intersect($hide, $show)) { $this->dieUsage("Mutually exclusive values for 'hide' and 'show'", 'badparams'); } elseif (!$hide && !$show) { $this->dieUsage("At least one value is required for 'hide' or 'show'", 'badparams'); } $bits = array('content' => RevisionDeleter::getRevdelConstant($params['type']), 'comment' => Revision::DELETED_COMMENT, 'user' => Revision::DELETED_USER); $bitfield = array(); foreach ($bits as $key => $bit) { if (in_array($key, $hide)) { $bitfield[$bit] = 1; } elseif (in_array($key, $show)) { $bitfield[$bit] = 0; } else { $bitfield[$bit] = -1; } } if ($params['suppress'] === 'yes') { if (!$user->isAllowed('suppressrevision')) { $this->dieUsageMsg('badaccess-group0'); } $bitfield[Revision::DELETED_RESTRICTED] = 1; } elseif ($params['suppress'] === 'no') { $bitfield[Revision::DELETED_RESTRICTED] = 0; } else { $bitfield[Revision::DELETED_RESTRICTED] = -1; } $targetObj = null; if ($params['target']) { $targetObj = Title::newFromText($params['target']); } $targetObj = RevisionDeleter::suggestTarget($params['type'], $targetObj, $params['ids']); if ($targetObj === null) { $this->dieUsage('A target title is required for this RevDel type', 'needtarget'); } $list = RevisionDeleter::createList($params['type'], $this->getContext(), $targetObj, $params['ids']); $status = $list->setVisibility(array('value' => $bitfield, 'comment' => $params['reason'], 'perItemStatus' => true)); $result = $this->getResult(); $data = $this->extractStatusInfo($status); $data['target'] = $targetObj->getFullText(); $data['items'] = array(); foreach ($status->itemStatuses as $id => $s) { $data['items'][$id] = $this->extractStatusInfo($s); $data['items'][$id]['id'] = $id; } $list->reloadFromMaster(); // @codingStandardsIgnoreStart Avoid function calls in a FOR loop test part for ($item = $list->reset(); $list->current(); $item = $list->next()) { $data['items'][$item->getId()] += $item->getApiData($this->getResult()); } // @codingStandardsIgnoreEnd $data['items'] = array_values($data['items']); ApiResult::setIndexedTagName($data['items'], 'i'); $result->addValue(null, $this->getModuleName(), $data); }