r35972 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r35971‎ | r35972 | r35973 >
Date:16:55, 6 June 2008
Author:gri6507
Status:old
Tags:
Comment:
v0.6 - Optionally disable the feature to make other users watch the page.
Modified paths:
  • /trunk/extensions/WhoIsWatching/SpecialWhoIsWatching.php (modified) (history)
  • /trunk/extensions/WhoIsWatching/SpecialWhoIsWatching_body.php (modified) (history)

Diff [purge]

Index: trunk/extensions/WhoIsWatching/SpecialWhoIsWatching_body.php
@@ -22,7 +22,7 @@
2323 }
2424
2525 function execute($par) {
26 - global $wgRequest, $wgOut, $wgCanonicalNamespaceNames, $whoiswatching_nametype;
 26+ global $wgRequest, $wgOut, $wgCanonicalNamespaceNames, $whoiswatching_nametype, $whoiswatching_allowaddingpeople;
2727
2828 $this->setHeaders();
2929 $wgOut->setPagetitle(wfMsg('whoiswatching'));
@@ -77,27 +77,30 @@
7878 asort($watchingusers);
7979 foreach ($watchingusers as $id => $link)
8080 $wgOut->addWikiText($link);
81 -
82 - $wgOut->addWikiText("== ".wfMsg('specialwhoiswatchingaddusers')." ==");
83 -
84 - $wgOut->addHTML("<form method=\"post\">");
85 - $wgOut->addHTML("<input type=\"hidden\" value=\"".sha1("whoiswatching")."\" name=\"whoiswatching\" />");
86 - $wgOut->addHTML("<div style=\"border: thin solid #000000\"><table cellpadding=\"15\" cellspacing=\"0\" border=\"0\">");
87 - $wgOut->addHTML("<tr><td>");
88 - $wgOut->addHTML('<select name="idArray[]" size="12" multiple="multiple">');
89 - $users = array();
90 - $res = $dbr->select( 'user', 'user_name', '', __METHOD__);
91 - for ( $row = $dbr->fetchObject($res); $row; $row = $dbr->fetchObject($res)) {
92 - $u = User::newFromName($row->user_name);
93 - if (!array_key_exists($u->getID(), $watchingusers))
94 - if ($u->isAllowed('read') && ($u->getEmail() != ''))
95 - $users[strtolower($u->getRealName())] = $u->getID();
 81+
 82+ if ($whoiswatching_allowaddingpeople)
 83+ {
 84+ $wgOut->addWikiText("== ".wfMsg('specialwhoiswatchingaddusers')." ==");
 85+
 86+ $wgOut->addHTML("<form method=\"post\">");
 87+ $wgOut->addHTML("<input type=\"hidden\" value=\"".sha1("whoiswatching")."\" name=\"whoiswatching\" />");
 88+ $wgOut->addHTML("<div style=\"border: thin solid #000000\"><table cellpadding=\"15\" cellspacing=\"0\" border=\"0\">");
 89+ $wgOut->addHTML("<tr><td>");
 90+ $wgOut->addHTML('<select name="idArray[]" size="12" multiple="multiple">');
 91+ $users = array();
 92+ $res = $dbr->select( 'user', 'user_name', '', __METHOD__);
 93+ for ( $row = $dbr->fetchObject($res); $row; $row = $dbr->fetchObject($res)) {
 94+ $u = User::newFromName($row->user_name);
 95+ if (!array_key_exists($u->getID(), $watchingusers))
 96+ if ($u->isAllowed('read') && ($u->getEmail() != ''))
 97+ $users[strtolower($u->getRealName())] = $u->getID();
 98+ }
 99+ ksort($users);
 100+ foreach ($users as $name => $id)
 101+ $wgOut->addHTML("<option value=\"".$id."\">".$name."</option>");
 102+ $wgOut->addHTML('</select></td><td>');
 103+ $wgOut->addHTML("<input type=\"submit\" value=\"".wfMsg('specialwhoiswatchingaddbtn')."\" />");
 104+ $wgOut->addHTML("</td></tr></table></div></form>");
96105 }
97 - ksort($users);
98 - foreach ($users as $name => $id)
99 - $wgOut->addHTML("<option value=\"".$id."\">".$name."</option>");
100 - $wgOut->addHTML('</select></td><td>');
101 - $wgOut->addHTML("<input type=\"submit\" value=\"".wfMsg('specialwhoiswatchingaddbtn')."\" />");
102 - $wgOut->addHTML("</td></tr></table></div></form>");
103106 }
104107 }
Index: trunk/extensions/WhoIsWatching/SpecialWhoIsWatching.php
@@ -10,7 +10,7 @@
1111 }
1212
1313 $wgExtensionCredits['specialpage'][] = array(
14 - 'version' => '0.5',
 14+ 'version' => '0.6',
1515 'name' => 'WhoIsWatching',
1616 'author' => 'Paul Grinberg, Siebrand Mazeland',
1717 'email' => 'gri6507 at yahoo dot com',
@@ -26,6 +26,9 @@
2727 # Set the following to either 'UserName' or 'RealName' to display the list of watching users as such.
2828 $whoiswatching_nametype = 'RealName';
2929
 30+# Set the following to either True or False to optionally allow users to add others to watch a particular page
 31+$whoiswatching_allowaddingpeople = true;
 32+
3033 function whoiswatching(&$specialPageArray, $code) {
3134 # The localized title of the special page is among the messages of the extension:
3235 WhoIsWatching::loadMessages();

Status & tagging log