Index: trunk/extensions/Widgets/Widgets.php |
— | — | @@ -16,7 +16,7 @@ |
17 | 17 | 'path' => __FILE__, |
18 | 18 | 'name' => 'Widgets', |
19 | 19 | 'descriptionmsg' => 'widgets-desc', |
20 | | - 'version' => '0.9.0-dev', |
| 20 | + 'version' => '0.9.1-dev', |
21 | 21 | 'author' => '[http://www.sergeychernyshev.com Sergey Chernyshev]', |
22 | 22 | 'url' => 'http://www.mediawiki.org/wiki/Extension:Widgets' |
23 | 23 | ); |
— | — | @@ -43,6 +43,9 @@ |
44 | 44 | // Define new right |
45 | 45 | $wgAvailableRights[] = 'editwidgets'; |
46 | 46 | |
| 47 | +// Set this to true to use FlaggedRevs extension's stable version for widget security |
| 48 | +$wgWidgetsUseFlaggedRevs = false; |
| 49 | + |
47 | 50 | $dir = dirname( __FILE__ ) . '/'; |
48 | 51 | |
49 | 52 | // Initialize Smarty |
— | — | @@ -200,22 +203,36 @@ |
201 | 204 | } |
202 | 205 | |
203 | 206 | function widgetNamespacesInit() { |
204 | | - global $wgGroupPermissions, $wgNamespaceProtection; |
| 207 | + global $wgGroupPermissions, $wgNamespaceProtection, $wgWidgetsUseFlaggedRevs; |
205 | 208 | |
206 | | - // Assign editing to widgeteditor group only (widgets can be dangerous so we do it here, not in LocalSettings) |
207 | | - $wgGroupPermissions['*']['editwidgets'] = false; |
208 | | - $wgGroupPermissions['widgeteditor']['editwidgets'] = true; |
| 209 | + if (!$wgWidgetsUseFlaggedRevs) |
| 210 | + { |
| 211 | + // Assign editing to widgeteditor group only (widgets can be dangerous so we do it here, not in LocalSettings) |
| 212 | + $wgGroupPermissions['*']['editwidgets'] = false; |
| 213 | + $wgGroupPermissions['widgeteditor']['editwidgets'] = true; |
209 | 214 | |
210 | | - // Setting required namespace permission rights |
211 | | - $wgNamespaceProtection[NS_WIDGET] = array( 'editwidgets' ); |
| 215 | + // Setting required namespace permission rights |
| 216 | + $wgNamespaceProtection[NS_WIDGET] = array( 'editwidgets' ); |
| 217 | + } |
212 | 218 | } |
213 | 219 | |
214 | 220 | // put these function somewhere in your application |
215 | 221 | function wiki_get_template( $widgetName, &$widgetCode, &$smarty_obj ) { |
| 222 | + global $wgWidgetsUseFlaggedRevs; |
| 223 | + |
216 | 224 | $widgetTitle = Title::newFromText($widgetName, NS_WIDGET); |
217 | 225 | if ( $widgetTitle && $widgetTitle->exists() ) { |
218 | | - $widgetArticle = new Article( $widgetTitle, 0 ); |
219 | | - $widgetCode = $widgetArticle->getContent(); |
| 226 | + if ($wgWidgetsUseFlaggedRevs) |
| 227 | + { |
| 228 | + $flaggedWidgetArticle = FlaggedArticle::getTitleInstance( $widgetTitle ); |
| 229 | + $flaggedWidgetArticleRevision = $flaggedWidgetArticle->getStableRev(); |
| 230 | + $widgetCode = $flaggedWidgetArticleRevision->getRevText(); |
| 231 | + } |
| 232 | + else |
| 233 | + { |
| 234 | + $widgetArticle = new Article( $widgetTitle, 0 ); |
| 235 | + $widgetCode = $widgetArticle->getContent(); |
| 236 | + } |
220 | 237 | |
221 | 238 | // Remove <noinclude> sections and <includeonly> tags from form definition |
222 | 239 | $widgetCode = StringUtils::delimiterReplace( '<noinclude>', '</noinclude>', '', $widgetCode ); |