Ejemplo n.º 1
0
function wfSpecialRemoveRestrictions()
{
    global $wgOut, $wgRequest, $wgUser, $wgLang;
    $sk = $wgUser->getSkin();
    $title = SpecialPage::getTitleFor('RemoveRestrictions');
    $id = $wgRequest->getVal('id');
    if (!is_numeric($id)) {
        $wgOut->addWikiMsg('removerestrictions-noid');
        return;
    }
    UserRestriction::purgeExpired();
    $r = UserRestriction::newFromId($id, true);
    if (!$r) {
        $wgOut->addWikiMsg('removerestrictions-wrongid');
        return;
    }
    $form = array();
    $form['removerestrictions-user'] = $sk->userLink($r->getSubjectId(), $r->getSubjectText()) . $sk->userToolLinks($r->getSubjectId(), $r->getSubjectText());
    $form['removerestrictions-type'] = UserRestriction::formatType($r->getType());
    if ($r->isPage()) {
        $form['removerestrictions-page'] = $sk->link($r->getPage());
    }
    if ($r->isNamespace()) {
        $form['removerestrictions-namespace'] = $wgLang->getDisplayNsText($r->getNamespace());
    }
    $form['removerestrictions-reason'] = Xml::input('reason');
    $result = null;
    if ($wgRequest->wasPosted() && $wgUser->matchEditToken($wgRequest->getVal('edittoken'))) {
        $result = wfSpecialRemoveRestrictionsProcess($r);
    }
    $wgOut->addWikiMsg('removerestrictions-intro');
    $wgOut->addHTML(Xml::fieldset(wfMsgHtml('removerestrictions-legend')));
    if ($result) {
        $wgOut->addHTML('<strong class="success">' . wfMsgExt('removerestrictions-success', 'parseinline', $r->getSubjectText()) . '</strong>');
    }
    $wgOut->addHTML(Xml::openElement('form', array('action' => $title->getLocalUrl(array('id' => $id)), 'method' => 'post')));
    $wgOut->addHTML(Xml::buildForm($form, 'removerestrictions-submit'));
    $wgOut->addHTML(Xml::hidden('id', $r->getId()));
    $wgOut->addHTML(Xml::hidden('title', $title->getPrefixedDbKey()));
    $wgOut->addHTML(Xml::hidden('edittoken', $wgUser->editToken()));
    $wgOut->addHTML("</form></fieldset>");
}
Ejemplo n.º 2
0
 public function formatRow($row)
 {
     return self::formatRestriction(UserRestriction::newFromRow($row));
 }
Ejemplo n.º 3
0
 public static function doNamespaceRestriction($uid, $user)
 {
     global $wgUser, $wgRequest;
     $r = new UserRestriction();
     $r->setType(UserRestriction::NAMESPACE);
     $r->setNamespace($wgRequest->getVal('namespace'));
     $r->setSubjectId($uid);
     $r->setSubjectText($user);
     $r->setBlockerId($wgUser->getId());
     $r->setBlockerText($wgUser->getName());
     $r->setReason($wgRequest->getVal('reason'));
     $r->setExpiry(UserRestriction::convertExpiry($wgRequest->getVal('expiry')));
     $r->setTimestamp(wfTimestampNow(TS_MW));
     $r->commit();
     $logExpiry = $wgRequest->getVal('expiry') ? $wgRequest->getVal('expiry') : Block::infinity();
     $l = new LogPage('restrict');
     $l->addEntry('restrict', Title::makeTitle(NS_USER, $user), $r->getReason(), array($r->getType(), $r->getNamespace(), $logExpiry));
 }