r99777 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r99776‎ | r99777 | r99778 >
Date:16:01, 14 October 2011
Author:cervidae
Status:deferred (Comments)
Tags:
Comment:
Adding GlobalUserGroups extension
Modified paths:
  • /branches/REL1_16/extensions/GlobalUserGroups (added) (history)
  • /branches/REL1_16/extensions/GlobalUserGroups/GlobalUserGroups.i18n.extras.php (added) (history)
  • /branches/REL1_16/extensions/GlobalUserGroups/GlobalUserGroups.i18n.php (added) (history)
  • /branches/REL1_16/extensions/GlobalUserGroups/GlobalUserGroups.php (added) (history)

Diff [purge]

Index: branches/REL1_16/extensions/GlobalUserGroups/GlobalUserGroups.i18n.php
@@ -0,0 +1,29 @@
 2+<?php
 3+
 4+/**
 5+ * Internationalization file for the GlobalUserGroups extension
 6+ *
 7+ * @since 1.0
 8+ *
 9+ * @file GlobalUserGroups.i18n.php
 10+ * @ingroup GlobalUserGroups
 11+ *
 12+ * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later
 13+ * @author Tim Weyer (SVG) <svg@tim-weyer.org>
 14+ */
 15+
 16+$messages = array();
 17+
 18+/** English
 19+ * @author SVG
 20+ */
 21+$messages['en'] = array(
 22+ 'globalusergroups-desc' => 'Allows the use of defined local user groups as global groups',
 23+);
 24+
 25+/** German (Deutsch)
 26+ * @author SVG
 27+ */
 28+$messages['de'] = array(
 29+ 'globalusergroups-desc' => 'Ermöglicht das Nutzen von definierten lokalen Benutzergruppen als globale Gruppen',
 30+);
Index: branches/REL1_16/extensions/GlobalUserGroups/GlobalUserGroups.php
@@ -0,0 +1,103 @@
 2+<?php
 3+/**
 4+ * GlobalUserGroups - adds specified user groups as to all 'user_groups' tables in a wiki family ($wgLocalDatabases)
 5+ *
 6+ * @package MediaWiki
 7+ * @subpackage Extensions
 8+ *
 9+ * @author Tim Weyer (SVG) <svg@tim-weyer.org>
 10+ *
 11+ * @copyright Copyright (C) 2011 by Tim Weyer
 12+ * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later
 13+ */
 14+
 15+if (!defined('MEDIAWIKI')){
 16+ echo ('THIS IS NOT VALID ENTRY POINT.'); exit (1);
 17+}
 18+
 19+$wgExtensionFunctions[] = 'efGlobalUserGroupsEMWT';
 20+
 21+$wgExtensionCredits['specialpage'][] = array(
 22+ 'name' => 'GlobalUserGroups',
 23+ 'url' => 'http://www.mediawiki.org/wiki/Extension:GlobalUserGroups',
 24+ 'author' => 'Tim Weyer',
 25+ 'descriptionmsg' => 'globalusergroups-desc',
 26+ 'version' => '1.0.1',
 27+);
 28+
 29+// Use extra translations for various user group names and similars
 30+$wgGlobalUserGroupsUseEMWT = true;
 31+
 32+// Translations
 33+$dir = dirname( __FILE__ ) . '/';
 34+$wgExtensionMessagesFiles['GlobalUserGroups'] = $dir . 'GlobalUserGroups.i18n.php';
 35+
 36+// Hooks
 37+$wgHooks['UserRights'][] = 'efManageGlobalUserGroups';
 38+
 39+function efManageGlobalUserGroups($user, $addgroup, $removegroup) {
 40+ global $wgGlobalUserGroups, $wgLocalDatabases;
 41+
 42+ # Remove groups in all local databases if there is anything to remove
 43+ if (!empty($removegroup)) {
 44+ $global_removeable = array_intersect($removegroup, $wgGlobalUserGroups);
 45+
 46+ if (!empty($global_removeable)) {
 47+
 48+ foreach ( $wgLocalDatabases as $wikiID ) {
 49+ $db = wfGetDB( DB_MASTER, array(), $wikiID );
 50+
 51+
 52+ foreach ( $global_removeable as $group ) {
 53+
 54+ # delete from all local databases
 55+ $db->delete('user_groups', array(
 56+ 'ug_user' => $user->getId(),
 57+ 'ug_group' => $group),
 58+ 'GlobalUserGroups::removeGroup'
 59+ );
 60+
 61+ }
 62+ }
 63+ }
 64+ }
 65+
 66+ # Add groups in all local databases if there is anything to add
 67+ if (!empty($addgroup)) {
 68+ $global_addable = array_intersect($addgroup, $wgGlobalUserGroups);
 69+
 70+ if (!empty($global_addable)) {
 71+
 72+ foreach ( $wgLocalDatabases as $wikiID ) {
 73+ $db = wfGetDB( DB_MASTER, array(), $wikiID );
 74+
 75+ foreach ( $global_addable as $group ) {
 76+
 77+ # insert into all local databases
 78+ $db->insert('user_groups', array(
 79+ 'ug_user' => $user->getId(),
 80+ 'ug_group' => $group),
 81+ 'GlobalUserGroups::addGroup',
 82+ 'IGNORE'
 83+ );
 84+
 85+ }
 86+ }
 87+ }
 88+ }
 89+
 90+ return true;
 91+}
 92+
 93+
 94+
 95+function efGlobalUserGroupsEMWT() {
 96+ global $wgGlobalUserGroupsUseEMWT;
 97+ global $wgExtensionMessagesFiles;
 98+
 99+ $dir = dirname( __FILE__ ) . '/';
 100+
 101+ if ( $wgGlobalUserGroupsUseEMWT ) {
 102+ $wgExtensionMessagesFiles['GlobalUserGroupsExtras'] = $dir . 'GlobalUserGroups.i18n.extras.php';
 103+ }
 104+}
Index: branches/REL1_16/extensions/GlobalUserGroups/GlobalUserGroups.i18n.extras.php
@@ -0,0 +1,128 @@
 2+<?php
 3+/**
 4+ * Internationalization file for extra user groups if GlobalUserGroups extension is used
 5+ *
 6+ * @since 1.0
 7+ *
 8+ * @file GlobalUserGroups.i18n.extras.php
 9+ * @ingroup GlobalUserGroupsExtras
 10+ *
 11+ * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later
 12+ * @author Tim Weyer (SVG) <svg@tim-weyer.org>
 13+ */
 14+
 15+$messages = array();
 16+
 17+/** English
 18+ * @author SVG
 19+ */
 20+$messages['en'] = array(
 21+ 'group-bot-global' => 'Global Bots',
 22+ 'group-bot-global-member' => 'global bot',
 23+ 'grouppage-bot-global' => '{{ns:help}}:Global Bots',
 24+
 25+ 'group-checkuser-global' => 'Global Check users',
 26+ 'group-checkuser-global-member' => 'global check user',
 27+ 'grouppage-checkuser-global' => '{{ns:help}}:Global Checkusers',
 28+
 29+ 'group-communitymanager' => 'Community managers',
 30+ 'group-communitymanager-member' => 'community manager',
 31+ 'grouppage-communitymanager' => '{{ns:help}}:Community managers',
 32+
 33+ 'group-helper' => 'Helpers',
 34+ 'group-helper-member' => 'helper',
 35+ 'grouppage-helper' => '{{ns:help}}:Helpers',
 36+
 37+ 'group-helper-global' => 'Global Helpers',
 38+ 'group-helper-global-member' => 'global helper',
 39+ 'grouppage-helper-global' => '{{ns:help}}:Global Helpers',
 40+
 41+ 'group-ipblock-exempt' => 'IP block exemptions',
 42+ 'group-ipblock-exempt-member' => 'ip block exemption',
 43+ 'grouppage-ipblock-exempt' => '{{ns:help}}:IP block exemptions',
 44+
 45+ 'group-ipblock-exempt-g' => 'Global IP block exemptions',
 46+ 'group-ipblock-exempt-g-member' => 'global ip block exemption',
 47+ 'grouppage-ipblock-exempt-g' => '{{ns:help}}:Global IP block exemptions',
 48+
 49+ 'group-rollback-global' => 'Global Rollbackers',
 50+ 'group-rollback-global-member' => 'global rollbacker',
 51+ 'grouppage-rollback-global' => '{{ns:help}}:Global Rollbackers',
 52+
 53+ 'group-steward' => 'Stewards',
 54+ 'group-steward-member' => 'steward',
 55+ 'grouppage-steward' => '{{ns:help}}:Stewards',
 56+
 57+ 'group-steward-global' => 'Global Stewards',
 58+ 'group-steward-global-member' => 'global steward',
 59+ 'grouppage-steward-global' => '{{ns:help}}:Global Stewards',
 60+
 61+ 'group-sysadmin' => 'System administrators',
 62+ 'group-sysadmin-member' => 'system administrator',
 63+ 'grouppage-sysadmin' => '{{ns:help}}:System administrators',
 64+
 65+ 'group-sysadmin-global' => 'Global System administrators',
 66+ 'group-sysadmin-global-member' => 'global system administrator',
 67+ 'grouppage-sysadmin-global' => '{{ns:help}}:Global System administrators',
 68+
 69+ 'group-sysop-global' => 'Global Administrators',
 70+ 'group-sysop-global-member' => 'global administrator',
 71+ 'grouppage-sysop-global' => '{{ns:help}}:Global Administrators',
 72+);
 73+
 74+/** German (Deutsch)
 75+ * @author SVG
 76+ */
 77+$messages['de'] = array(
 78+ 'group-bot-global' => 'Globale Bots',
 79+ 'group-bot-global-member' => 'Globaler Bot',
 80+ 'grouppage-bot-global' => '{{ns:help}}:Globale Bots',
 81+
 82+ 'group-communitymanager' => 'Community Manager',
 83+ 'group-communitymanager-member' => 'Community Manager',
 84+ 'grouppage-communitymanager' => '{{ns:help}}:Community Manager',
 85+
 86+ 'group-checkuser-global' => 'Globale Checkuser',
 87+ 'group-checkuser-global-member' => 'Globaler Checkuser',
 88+ 'grouppage-checkuser-global' => '{{ns:help}}:Globale Checkuser',
 89+
 90+ 'group-helper' => 'Helfer',
 91+ 'group-helper-member' => 'Helfer',
 92+ 'grouppage-helper' => '{{ns:help}}:Helfer',
 93+
 94+ 'group-helper-global' => 'Globale Helfer',
 95+ 'group-helper-global-member' => 'Globaler Helfer',
 96+ 'grouppage-helper-global' => '{{ns:help}}:Globale Helfer',
 97+
 98+ 'group-ipblock-exempt' => 'IP-Sperre-Ausnahmen',
 99+ 'group-ipblock-exempt-member' => 'IP-Sperre-Ausnahme',
 100+ 'grouppage-ipblock-exempt' => '{{ns:help}}:IP-Sperre-Ausnahmen',
 101+
 102+ 'group-ipblock-exempt-g' => 'Globale IP-Sperre-Ausnahmen',
 103+ 'group-ipblock-exempt-g-member' => 'Globale IP-Sperre-Ausnahme',
 104+ 'grouppage-ipblock-exempt-g' => '{{ns:help}}:Globale IP-Sperre-Ausnahmen',
 105+
 106+ 'group-rollback-global' => 'Globale Zurücksetzer',
 107+ 'group-rollback-global-member' => 'Globaler Zurücksetzer',
 108+ 'grouppage-rollback-global' => '{{ns:help}}:Globale Zurücksetzer',
 109+
 110+ 'group-steward' => 'Stewards',
 111+ 'group-steward-member' => 'Steward',
 112+ 'grouppage-steward' => '{{ns:help}}:Stewards',
 113+
 114+ 'group-steward-global' => 'Globale Stewards',
 115+ 'group-steward-global-member' => 'Globaler Steward',
 116+ 'grouppage-steward-global' => '{{ns:help}}:Globale Stewards',
 117+
 118+ 'group-sysadmin' => 'Systemadministratoren',
 119+ 'group-sysadmin-member' => 'Systemadministrator',
 120+ 'grouppage-sysadmin' => '{{ns:help}}:Systemadministratoren',
 121+
 122+ 'group-sysadmin-global' => 'Globale Systemadministratoren',
 123+ 'group-sysadmin-global-member' => 'Globaler Systemadministrator',
 124+ 'grouppage-sysadmin-global' => '{{ns:help}}:Globale Systemadministratoren',
 125+
 126+ 'group-sysop-global' => 'Globale Administratoren',
 127+ 'group-sysop-global-member' => 'Globaler Administrator',
 128+ 'grouppage-sysop-global' => '{{ns:help}}:Globale Administratoren',
 129+);
\ No newline at end of file

Follow-up revisions

RevisionCommit summaryAuthorDate
r99882adding svn eol-style native and updating capitalisation from trunkcervidae12:01, 15 October 2011

Comments

#Comment by SVG (talk | contribs)   19:21, 14 October 2011

fixed

Status & tagging log