Index: trunk/extensions/CloseWikis/CloseWikis.php |
— | — | @@ -107,8 +107,9 @@ |
108 | 108 | |
109 | 109 | /** Returns list of closed wikis in form of string array. Cached in CloseWikis::$cachedList */ |
110 | 110 | static function getList() { |
111 | | - if( self::$cachedList ) |
| 111 | + if( self::$cachedList ) { |
112 | 112 | return self::$cachedList; |
| 113 | + } |
113 | 114 | $list = array(); |
114 | 115 | $dbr = self::getMasterDB(); // Used only on writes |
115 | 116 | $result = $dbr->select( 'closedwikis', 'cw_wiki', false, __METHOD__ ); |
— | — | @@ -131,15 +132,19 @@ |
132 | 133 | global $wgMemc; |
133 | 134 | $memcKey = "closedwikis:{$wiki}"; |
134 | 135 | $cached = $wgMemc->get( $memcKey ); |
135 | | - if( is_object( $cached ) ) |
| 136 | + if( is_object( $cached ) ) { |
136 | 137 | return $cached; |
| 138 | + } |
137 | 139 | $dbr = self::getSlaveDB(); |
138 | 140 | $result = new CloseWikisRow( $dbr->selectRow( 'closedwikis', '*', array( 'cw_wiki' => $wiki ), __METHOD__ ) ); |
139 | 141 | $wgMemc->set( $memcKey, $result ); |
140 | 142 | return $result; |
141 | 143 | } |
142 | 144 | |
143 | | - /** Closes a wiki */ |
| 145 | + /** Closes a wiki |
| 146 | + * |
| 147 | + * @param $by User |
| 148 | + */ |
144 | 149 | static function close( $wiki, $dispreason, $by ) { |
145 | 150 | global $wgMemc; |
146 | 151 | $dbw = CloseWikis::getMasterDB(); |
— | — | @@ -181,15 +186,26 @@ |
182 | 187 | } |
183 | 188 | |
184 | 189 | class CloseWikisHooks { |
| 190 | + /** |
| 191 | + * @static |
| 192 | + * @param $title |
| 193 | + * @param $user User |
| 194 | + * @param $action |
| 195 | + * @param $result |
| 196 | + * @return bool |
| 197 | + */ |
185 | 198 | static function userCan( &$title, &$user, $action, &$result ) { |
186 | 199 | static $closed = null; |
187 | 200 | global $wgLang; |
188 | | - if( $action == 'read' ) |
| 201 | + if( $action == 'read' ) { |
189 | 202 | return true; |
190 | | - if( is_null( $closed ) ) |
| 203 | + } |
| 204 | + |
| 205 | + if( is_null( $closed ) ) { |
191 | 206 | $closed = CloseWikis::getClosedRow( wfWikiID() ); |
| 207 | + } |
| 208 | + |
192 | 209 | if( $closed->isClosed() && !$user->isAllowed( 'editclosedwikis' ) ) { |
193 | | - |
194 | 210 | $reason = $closed->getReason(); |
195 | 211 | $ts = $closed->getTimestamp(); |
196 | 212 | $by = $closed->getBy(); |
Index: trunk/extensions/CloseWikis/CloseWikis.list.php |
— | — | @@ -23,7 +23,6 @@ |
24 | 24 | |
25 | 25 | class SpecialListClosedWikis extends SpecialPage { |
26 | 26 | public function __construct() { |
27 | | - |
28 | 27 | parent::__construct( 'ListClosedWikis' ); |
29 | 28 | } |
30 | 29 | |
— | — | @@ -32,7 +31,7 @@ |
33 | 32 | } |
34 | 33 | |
35 | 34 | public function execute( $par ) { |
36 | | - global $wgUser, $wgOut, $wgLang; |
| 35 | + global $wgOut, $wgLang; |
37 | 36 | |
38 | 37 | $this->setHeaders(); |
39 | 38 | $wgOut->addWikiMsg( 'closewikis-list-intro' ); |
Index: trunk/extensions/CloseWikis/CloseWikis.page.php |
— | — | @@ -41,16 +41,18 @@ |
42 | 42 | } |
43 | 43 | |
44 | 44 | $this->closeForm(); |
45 | | - if( CloseWikis::getList() ) |
| 45 | + if( CloseWikis::getList() ) { |
46 | 46 | $this->reopenForm(); |
| 47 | + } |
47 | 48 | } |
48 | 49 | |
49 | 50 | protected function buildSelect( $list, $name, $default = '' ) { |
50 | 51 | sort( $list ); |
51 | 52 | $select = new XmlSelect( $name ); |
52 | 53 | $select->setDefault( $default ); |
53 | | - foreach( $list as $wiki ) |
| 54 | + foreach( $list as $wiki ) { |
54 | 55 | $select->addOption( $wiki ); |
| 56 | + } |
55 | 57 | return $select->getHTML(); |
56 | 58 | } |
57 | 59 | |
— | — | @@ -85,8 +87,9 @@ |
86 | 88 | $defaultDisplayReason = $statusOK ? '' : $wgRequest->getVal( 'wpcDisplayReason' ); |
87 | 89 | $defaultReason = $statusOK ? '' : $wgRequest->getVal( 'wpcReason' ); |
88 | 90 | // For some reason Xml::textarea( 'blabla', null ) produces an unclosed tag |
89 | | - if( !$defaultDisplayReason ) |
| 91 | + if( !$defaultDisplayReason ) { |
90 | 92 | $defaultDisplayReason = ''; |
| 93 | + } |
91 | 94 | |
92 | 95 | $wgOut->addHTML( "<fieldset><legend>{$legend}</legend>" ); |
93 | 96 | if( $status ) { |
— | — | @@ -99,7 +102,7 @@ |
100 | 103 | $form['closewikis-page-close-dreason'] = Xml::textarea( 'wpcDisplayReason', $defaultDisplayReason ); |
101 | 104 | $form['closewikis-page-close-reason'] = Xml::input( 'wpcReason', false, $defaultReason ); |
102 | 105 | $wgOut->addHTML( Xml::buildForm( $form, 'closewikis-page-close-submit' ) ); |
103 | | - $wgOut->addHTML( Xml::hidden( 'wpcEdittoken', $wgUser->editToken() ) ); |
| 106 | + $wgOut->addHTML( Html::hidden( 'wpcEdittoken', $wgUser->editToken() ) ); |
104 | 107 | $wgOut->addHTML( "</form></fieldset>" ); |
105 | 108 | } |
106 | 109 | |
— | — | @@ -142,9 +145,7 @@ |
143 | 146 | $form['closewikis-page-reopen-wiki'] = $this->buildSelect( CloseWikis::getList(), 'wprWiki', $defaultWiki ); |
144 | 147 | $form['closewikis-page-reopen-reason'] = Xml::input( 'wprReason', false, $defaultReason ); |
145 | 148 | $wgOut->addHTML( Xml::buildForm( $form, 'closewikis-page-reopen-submit' ) ); |
146 | | - $wgOut->addHTML( Xml::hidden( 'wprEdittoken', $wgUser->editToken() ) ); |
| 149 | + $wgOut->addHTML( Html::hidden( 'wprEdittoken', $wgUser->editToken() ) ); |
147 | 150 | $wgOut->addHTML( "</form></fieldset>" ); |
148 | 151 | } |
149 | | - |
150 | | - |
151 | 152 | } |