r30979 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r30978‎ | r30979 | r30980 >
Date:21:26, 15 February 2008
Author:gri6507
Status:old
Tags:
Comment:
v0.6 - give the restricted users the ability to request page access
Modified paths:
  • /trunk/extensions/WhiteList/SpecialWhitelistEdit.i18n.php (modified) (history)
  • /trunk/extensions/WhiteList/SpecialWhitelistEdit.php (modified) (history)
  • /trunk/extensions/WhiteList/SpecialWhitelistEdit_body.php (modified) (history)

Diff [purge]

Index: trunk/extensions/WhiteList/SpecialWhitelistEdit_body.php
@@ -486,7 +486,7 @@
487487 }
488488
489489 function execute($user = '') {
490 - global $wgRequest, $wgOut, $wgUser, $wgWhitelistOverride;
 490+ global $wgRequest, $wgOut, $wgUser, $wgWhitelistOverride, $wgWhiteListManagerGroup, $wgSitename;
491491 $dbr = wfGetDB( DB_SLAVE );
492492
493493 $user = ($user == '') ? $wgUser : User::newFromId($user);
@@ -494,24 +494,71 @@
495495 $this->setHeaders();
496496 $wgOut->setPagetitle(wfMsgTL('whitelist'));
497497
498 - $wgOut->addWikiText(wfMsg('whitelistpagelist', $user->getRealName()));
 498+ if ($wgRequest->getVal('submit', '') == wfMsg('whitelistnewtableprocess'))
 499+ {
 500+ $sender = new MailAddress($wgUser->getEmail(), $wgUser->getRealName());
 501+ $to = '';
 502+ if (constant("MW_USER_VERSION") < 4) {
 503+ $to = new User();
 504+ $to->mId = $wgRequest->getint('manager',0);
 505+ } else {
 506+ $to = User::newFromId($wgRequest->getint('manager',0));
 507+ }
 508+ $to->sendMail("[${wgSitename}] " . wfMsg('whitelistrequest'),
 509+ wfMsg('whitelistrequestmsg',$wgUser->getRealName(), $wgRequest->getVal('newPages')),
 510+ $sender->toString()
 511+ );
499512
 513+ $wgOut->addWikiText(wfMsg('whitelistrequestconf', $to->getRealName()));
 514+ $wgOut->addWikiText("");
 515+ }
 516+
 517+
 518+ $wgOut->addHtml("<table cellspacing=0 cellpadding=2 border=1 width=100%><tr>");
 519+ $wgOut->addHtml("<th>" . wfMsg('whitelistpagelist', $user->getRealName()) . "</th><th>" . wfMsg('whitelistrequest') . "</th>");
 520+ $wgOut->addHtml("</tr><tr><td width=30%>");
 521+
500522 $res = WhitelistEdit::contractorWhitelistTable($dbr, $user->getId());
501523 for ($row = $dbr->fetchObject($res); $row; $row = $dbr->fetchObject($res)) {
502524 $wgOut->addWikiText("* [[$row->wl_page_title]]");
503525 }
504526 $dbr->freeResult($res);
505 -
506527 $pages = array();
507 -
508528 foreach ($wgWhitelistOverride['always']['read'] as $page)
509529 array_push($pages, $page);
510530 foreach ($wgWhitelistOverride['always']['edit'] as $page)
511531 array_push($pages, $page);
512 -
513532 sort($pages);
514533 foreach ($pages as $page)
515534 $wgOut->addWikiText("* [[$page]]");
 535+
 536+
 537+ $wgOut->addHtml("</td><td valign=top>");
 538+ $wgOut->addHtml("<table cellspacing=0 cellpadding=2 border=0 width=100%><tr><td align='right'>$wgWhiteListManagerGroup:</td><td>");
 539+ $wgOut->addHTML("<form method=\"post\">");
 540+ $wgOut->addHTML('<select name="manager">');
 541+
 542+ $users = array();
 543+ $res = $dbr->select( 'user_groups', 'ug_user', array('ug_group'=>$wgWhiteListManagerGroup), __METHOD__);
 544+ for ( $row = $dbr->fetchObject($res); $row; $row = $dbr->fetchObject($res)) {
 545+ $u = User::newFromID($row->ug_user);
 546+ $users[$u->getRealName()] = $row->ug_user;
 547+ }
 548+ $dbr->freeResult($res);
 549+ ksort($users);
 550+ foreach ($users as $name => $id)
 551+ $wgOut->addHTML("<option value=\"$id\">".$name."</option>");
 552+ $wgOut->addHTML('</select> ');
 553+
 554+
 555+ $wgOut->addHtml("</td></tr><tr><td align='right'>" . wfMsg('mywhitelistpages') . ":</td><td>");
 556+ $wgOut->addHtml("<textarea name='newPages' cols=40 rows=5></textarea>");
 557+ $wgOut->addHtml("</td></tr><tr><td colspan=2><center>");
 558+ $wgOut->addHTML("<input type='submit' name='submit' value='" . wfMsg('whitelistnewtableprocess') . "' />");
 559+ $wgOut->addHTML("</form>");
 560+ $wgOut->addHtml("</center></td></tr></table>");
 561+ $wgOut->addHtml("</td></tr></table>");
 562+ $wgOut->addHtml("</td></tr></table>");
516563 }
517564 }
518565
Index: trunk/extensions/WhiteList/SpecialWhitelistEdit.i18n.php
@@ -56,7 +56,7 @@
5757 'whitelistnewtableprocess' => 'Process',
5858 'whitelistnewtablereview' => 'Review',
5959 'whitelistselectrestricted' => '== Select Restricted User Name ==',
60 - 'whitelistpagelist' => "== {{SITENAME}} pages for $1 ==",
 60+ 'whitelistpagelist' => "{{SITENAME}} pages for $1",
6161 'whitelistnocalendar' => "<font color='red' size=3>It looks like [http://www.mediawiki.org/wiki/Extension:Usage_Statistics Extension:UsageStatistics], a prerequisite for this extension, was not installed properly!</font>",
6262 'whitelistbadtitle' => 'Bad title - ',
6363 'whitelistoverview' => "== Overview of changes for $1 ==",
@@ -64,6 +64,9 @@
6565 'whitelistoverviewsa' => "* Setting access to '''$1''' for [[$2]]",
6666 'whitelistoverviewrm' => "* Removing access to [[$1]]",
6767 'whitelistoverviewna' => "* Adding [[$1]] to whitelist with access '''$2''' and '''$3''' expiry date",
 68+ 'whitelistrequest' => "Request access to more pages",
 69+ 'whitelistrequestmsg' => "$1 has requested access to the following pages:\n\n$2",
 70+ 'whitelistrequestconf' => "Request for new pages was sent to $1",
6871 )
6972 );
7073 ?>
Index: trunk/extensions/WhiteList/SpecialWhitelistEdit.php
@@ -31,7 +31,7 @@
3232
3333 $wgExtensionCredits['specialpage'][] = array(
3434 'name' => 'WhiteListEdit',
35 - 'version' => 'v0.5',
 35+ 'version' => 'v0.6',
3636 'author' => 'Paul Grinberg, Mike Sullivan',
3737 'email' => 'gri6507 at yahoo dot com, ms-mediawiki AT umich DOT edu',
3838 'description' => 'Edit the access permissions of restricted users',

Status & tagging log