Index: trunk/extensions/WhoIsWatching/SpecialWhoIsWatching_body.php |
— | — | @@ -22,7 +22,7 @@ |
23 | 23 | } |
24 | 24 | |
25 | 25 | function execute($par) { |
26 | | - global $wgRequest, $wgOut, $wgCanonicalNamespaceNames, $whoiswatching_nametype; |
| 26 | + global $wgRequest, $wgOut, $wgCanonicalNamespaceNames, $whoiswatching_nametype, $whoiswatching_allowaddingpeople; |
27 | 27 | |
28 | 28 | $this->setHeaders(); |
29 | 29 | $wgOut->setPagetitle(wfMsg('whoiswatching')); |
— | — | @@ -77,27 +77,30 @@ |
78 | 78 | asort($watchingusers); |
79 | 79 | foreach ($watchingusers as $id => $link) |
80 | 80 | $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>"); |
96 | 105 | } |
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>"); |
103 | 106 | } |
104 | 107 | } |
Index: trunk/extensions/WhoIsWatching/SpecialWhoIsWatching.php |
— | — | @@ -10,7 +10,7 @@ |
11 | 11 | } |
12 | 12 | |
13 | 13 | $wgExtensionCredits['specialpage'][] = array( |
14 | | - 'version' => '0.5', |
| 14 | + 'version' => '0.6', |
15 | 15 | 'name' => 'WhoIsWatching', |
16 | 16 | 'author' => 'Paul Grinberg, Siebrand Mazeland', |
17 | 17 | 'email' => 'gri6507 at yahoo dot com', |
— | — | @@ -26,6 +26,9 @@ |
27 | 27 | # Set the following to either 'UserName' or 'RealName' to display the list of watching users as such. |
28 | 28 | $whoiswatching_nametype = 'RealName'; |
29 | 29 | |
| 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 | + |
30 | 33 | function whoiswatching(&$specialPageArray, $code) { |
31 | 34 | # The localized title of the special page is among the messages of the extension: |
32 | 35 | WhoIsWatching::loadMessages(); |