http://www.mediawiki.org/wiki/Special:Code/MediaWiki/88406
Revision: 88406
Author: jeroendedauw
Date: 2011-05-19 14:19:04 +0000 (Thu, 19 May 2011)
Log Message:
-----------
update swl_users_per_group depending on user preferences
Modified Paths:
--------------
trunk/extensions/SemanticWatchlist/SemanticWatchlist.hooks.php
trunk/extensions/SemanticWatchlist/SemanticWatchlist.i18n.php
trunk/extensions/SemanticWatchlist/SemanticWatchlist.php
Modified: trunk/extensions/SemanticWatchlist/SemanticWatchlist.hooks.php
===================================================================
--- trunk/extensions/SemanticWatchlist/SemanticWatchlist.hooks.php
2011-05-19 13:28:26 UTC (rev 88405)
+++ trunk/extensions/SemanticWatchlist/SemanticWatchlist.hooks.php
2011-05-19 14:19:04 UTC (rev 88406)
@@ -139,7 +139,45 @@
}
return true;
- }
+ }
+
+ /**
+ * Called just before saving user preferences/options.
+ * Find the watchlist groups the user watches, and update the
swl_users_per_group table.
+ *
+ * @since 0.1
+ *
+ * @param User $user
+ * @param array $options
+ *
+ * @return true
+ */
+ public static function onUserSaveOptions( User $user, array &$options )
{
+ $dbw = wfGetDB( DB_MASTER );
+
+ $dbw->begin();
+
+ $dbw->delete(
+ 'swl_users_per_group',
+ array( 'upg_user_id' => $user->getId() )
+ );
+
+ foreach ( $options as $name => $value ) {
+ if ( strpos( $name, 'swl_watchgroup_' ) === 0 && $value
) {
+ $dbw->insert(
+ 'swl_users_per_group',
+ array(
+ 'upg_user_id' => $user->getId(),
+ 'upg_group_id' => (int)substr(
$name, strrpos( $name, '_' ) + 1 )
+ )
+ );
+ }
+ }
+
+ $dbw->commit();
+
+ return true;
+ }
/**
* Schema update to set up the needed database tables.
Modified: trunk/extensions/SemanticWatchlist/SemanticWatchlist.i18n.php
===================================================================
--- trunk/extensions/SemanticWatchlist/SemanticWatchlist.i18n.php
2011-05-19 13:28:26 UTC (rev 88405)
+++ trunk/extensions/SemanticWatchlist/SemanticWatchlist.i18n.php
2011-05-19 14:19:04 UTC (rev 88406)
@@ -52,7 +52,7 @@
'swl-prefs-category-label' => "'''$1''':
{{PLURAL:$2|property|properties}} $3 from category ''$4''",
'swl-prefs-namespace-label' => "'''$1''':
{{PLURAL:$2|property|properties}} $3 from namespace ''$4''",
'swl-prefs-concept-label' => "'''$1''':
{{PLURAL:$2|property|properties}} $3 from concept ''$4''",
- 'swl-prefs-emailnofity' => 'E-mail me on changes to properties I am
watching'
+ 'swl-prefs-emailnofity' => 'E-mail me on changes to properties I am
watching',
);
/** German (Deutsch)
Modified: trunk/extensions/SemanticWatchlist/SemanticWatchlist.php
===================================================================
--- trunk/extensions/SemanticWatchlist/SemanticWatchlist.php 2011-05-19
13:28:26 UTC (rev 88405)
+++ trunk/extensions/SemanticWatchlist/SemanticWatchlist.php 2011-05-19
14:19:04 UTC (rev 88406)
@@ -83,6 +83,9 @@
$wgHooks['GetPreferences'][] = 'SWLHooks::onGetPreferences';
+$wgHooks['UserSaveOptions'][] = 'SWLHooks::onUserSaveOptions';
+
+
$moduleTemplate = array(
'localBasePath' => dirname( __FILE__ ),
'remoteBasePath' => $egSWLScriptPath
_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs