r65139 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r65138‎ | r65139 | r65140 >
Date:21:24, 16 April 2010
Author:sergeychernyshev
Status:deferred
Tags:
Comment:
Added support for FlaggedRev extension controlling Widget review.
Modified paths:
  • /trunk/extensions/Widgets/Widgets.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Widgets/Widgets.php
@@ -16,7 +16,7 @@
1717 'path' => __FILE__,
1818 'name' => 'Widgets',
1919 'descriptionmsg' => 'widgets-desc',
20 - 'version' => '0.9.0-dev',
 20+ 'version' => '0.9.1-dev',
2121 'author' => '[http://www.sergeychernyshev.com Sergey Chernyshev]',
2222 'url' => 'http://www.mediawiki.org/wiki/Extension:Widgets'
2323 );
@@ -43,6 +43,9 @@
4444 // Define new right
4545 $wgAvailableRights[] = 'editwidgets';
4646
 47+// Set this to true to use FlaggedRevs extension's stable version for widget security
 48+$wgWidgetsUseFlaggedRevs = false;
 49+
4750 $dir = dirname( __FILE__ ) . '/';
4851
4952 // Initialize Smarty
@@ -200,22 +203,36 @@
201204 }
202205
203206 function widgetNamespacesInit() {
204 - global $wgGroupPermissions, $wgNamespaceProtection;
 207+ global $wgGroupPermissions, $wgNamespaceProtection, $wgWidgetsUseFlaggedRevs;
205208
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;
209214
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+ }
212218 }
213219
214220 // put these function somewhere in your application
215221 function wiki_get_template( $widgetName, &$widgetCode, &$smarty_obj ) {
 222+ global $wgWidgetsUseFlaggedRevs;
 223+
216224 $widgetTitle = Title::newFromText($widgetName, NS_WIDGET);
217225 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+ }
220237
221238 // Remove <noinclude> sections and <includeonly> tags from form definition
222239 $widgetCode = StringUtils::delimiterReplace( '<noinclude>', '</noinclude>', '', $widgetCode );

Status & tagging log