Wikinaut has submitted this change and it was merged.

Change subject: (bug 45323) allow deletion of selected or all trusted sites in 
OpenID Preferences
......................................................................


(bug 45323) allow deletion of selected or all trusted sites in OpenID 
Preferences

version 3.04 20130310

Change-Id: Ife58ad1900135291dd4116966a4799704ab6fcbd
---
M CHANGES
M OpenID.hooks.php
M OpenID.i18n.php
M OpenID.php
M README.OpenID-mediawiki-extension
M SpecialOpenIDServer.body.php
6 files changed, 137 insertions(+), 16 deletions(-)

Approvals:
  Wikinaut: Verified; Looks good to me, approved



diff --git a/CHANGES b/CHANGES
index 8bb91d1..7e7aa7e 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,6 +1,7 @@
 CHANGES
 =======
 
+3.04  20130310  fix bug45323 add deletion of trusted sites to OpenID 
Preferences
 3.03  20130310  fix bug45928 change deprecated wgAllowRealName to 
wgHiddenPrefs checks
 3.02  20130309  when used as Provider, show the own OpenID in OpenID 
preference tab
                 fix bug 45322 show own OpenID as subtitle on own userpage 
(user option)
diff --git a/OpenID.hooks.php b/OpenID.hooks.php
index 1607dea..bc459cc 100644
--- a/OpenID.hooks.php
+++ b/OpenID.hooks.php
@@ -195,21 +195,57 @@
                $rows = '';
 
                foreach ( $trusted_sites as $key => $value ) {
+
+                       $deleteTrustedSiteTitle = SpecialPage::getTitleFor( 
'OpenIDServer', 'DeleteTrustedSite' );
+
                        if ( $key !== "" ) {
+
                                $rows .= Xml::tags( 'tr', array(),
                                        Xml::tags( 'td',
                                                array(),
                                                Xml::element( 'a', array( 
'href' => $key ), $key )
+                                       ) .
+                                       Xml::tags( 'td',
+                                               array(),
+                                               Linker::link( 
$deleteTrustedSiteTitle,
+                                                       wfMessage( 
'openid-trusted-sites-delete-link-action-text' )->text(),
+                                                       array(),
+                                                       array( 'url' => $key )
+                                               )
                                        )
                                ) . "\n";
+
                        }
+
+               }
+
+               if ( $rows !== "" ) {
+
+                       $rows .= Xml::tags( 'tr', array(),
+                               Xml::tags( 'td',
+                                       array(),
+                                       " "
+                               ) .
+                               Xml::tags( 'td',
+                                       array(),
+                                       Linker::link( $deleteTrustedSiteTitle,
+                                               wfMessage( 
'openid-trusted-sites-delete-all-link-action-text' )->text(),
+                                               array(),
+                                               array( 'url' => "*" )
+                                       )
+                               )
+                       ) . "\n";
+
                }
 
                return Xml::tags( 'table', array( 'class' => 'wikitable' ),
                        Xml::tags( 'tr', array(),
                                Xml::element( 'th',
                                        array(),
-                                       wfMessage( 
'openid-trusted-sites-table-header' )->text() )
+                                       wfMessage( 
'openid-trusted-sites-table-header-column-url' )->text() ) .
+                               Xml::element( 'th',
+                                       array(),
+                                       wfMessage( 
'openid-trusted-sites-table-header-column-action' )->text() )
                        ) . "\n" .
                        $rows
                );
diff --git a/OpenID.i18n.php b/OpenID.i18n.php
index 2c06c2f..443ee06 100644
--- a/OpenID.i18n.php
+++ b/OpenID.i18n.php
@@ -107,7 +107,7 @@
 To use OpenID in the future, you can [[Special:OpenIDConvert|convert your 
account to OpenID]] after you have logged in normally.',
        'openidupdateuserinfo' => 'Update my personal information:',
        'openiddelete' => 'Delete OpenID',
-       'openiddelete-text' => 'By clicking the "{{int:openiddelete-button}}" 
button, you will remove the OpenID $1 from your account.
+       'openiddelete-text' => 'By clicking the "{{int:openiddelete-button}}" 
button, you will remove the OpenID "$1" from your account.
 You will no longer be able to log in with this OpenID.',
        'openiddelete-button' => 'Confirm',
        'openiddeleteerrornopassword' => 'You cannot delete all your OpenIDs 
because your account has no password.
@@ -136,7 +136,17 @@
        'openid-urls-delete' => 'Delete',
        'openid-add-url' => 'Add a new OpenID to your account',
        'openid-trusted-sites-label' => 'Sites you trust and where you have 
used your OpenID for logging in:',
-       'openid-trusted-sites-table-header' => 'Trusted sites',
+       'openid-trusted-sites-table-header-column-url' => 'Trusted sites',
+       'openid-trusted-sites-table-header-column-action' => 'Action',
+       'openid-trusted-sites-delete-link-action-text' => 'Delete',
+       'openid-trusted-sites-delete-all-link-action-text' => 'Delete all 
trusted sites',
+       'openid-trusted-sites-delete-confirmation-page-title' => 'Site trust 
deletion',
+       'openid-trusted-sites-delete-confirmation-question' => 'By clicking the 
"{{int:openid-trusted-sites-delete-confirmation-button-text}}" button, you will 
remove "$1" from the list of sites you trust.',
+       'openid-trusted-sites-delete-all-confirmation-question' => 'By clicking 
the "{{int:openid-trusted-sites-delete-confirmation-button-text}}" button, you 
will remove all trusted sites from your user profile.',
+       'openid-trusted-sites-delete-confirmation-button-text' => 'Confirm',
+       'openid-trusted-sites-delete-confirmation-success-text' => '"$1" was 
successfully removed from the list of sites you trust.',
+       'openid-trusted-sites-delete-all-confirmation-success-text' => 'All 
sites you previously trusted were successfully removed from your user profile.',
+
        'openid-local-identity' => 'Your OpenID:',
 
        'openid-login-or-create-account' => 'Log in or create a new account',
@@ -243,8 +253,21 @@
 Used in the same way as {{msg-mw|prefs-registration-date-time}}.',
        'openid-urls-delete' => '{{Identical|Delete}}',
        'openid-trusted-sites-label' => 'Sites you trust and where you have 
used your OpenID for logging in: (preference label)',
-       'openid-trusted-sites-table-header' => 'Trusted sites (table header).
+       'openid-trusted-sites-table-header-column-url' => 'Trusted sites (table 
header, url column).
 {{Identical|Trusted site}}',
+       'openid-trusted-sites-table-header-column-action' => 'Trusted sites 
(table header, action column).
+{{Identical|Action}}',
+       'openid-trusted-sites-delete-link-action-text' => 
'{{Identical|Delete}}',
+       'openid-trusted-sites-delete-all-link-action-text' => 'A text for the 
link in the table to click to delete all trusted sites, e.g. "Delete all 
trusted sites"',
+       'openid-trusted-sites-delete-confirmation-page-title' => 'The page 
title for "Site trust deletion"',
+       'openid-trusted-sites-delete-confirmation-question' => 'The question of 
By clicking the "{{int:openid-trusted-sites-delete-confirmation-button-text}}" 
button, you will remove $1 from the list of sites you trust.
+* $1 is the url of the removed site',
+       'openid-trusted-sites-delete-all-confirmation-question' => 'The 
question of By clicking the 
"{{int:openid-trusted-sites-delete-confirmation-button-text}}" button, you will 
remove all trusted sites from the list.',
+       'openid-trusted-sites-delete-confirmation-button-text' => 
'{{Identical|Confirm}}',
+       'openid-trusted-sites-delete-confirmation-success-text' => 'A 
confirmation text which is shown, when the user has successfully removed a site 
from the list of trusted site.
+* $1 is the url of the removed site',
+       'openid-trusted-sites-delete-all-confirmation-success-text' => 'A 
confirmation text which is shown, when the user has successfully removed all 
sites from the list of trusted site.',
+
        'openid-local-identity' => 'Your OpenID when used a identity to other 
sites (preference label)',
        'specialpages-group-openid' => 'Display group name for OpenID-extension 
related special pages for [[Special:SpecialPages]].',
        'right-openid-converter-access' => 
'{{doc-right|openid-converter-access}}
@@ -690,7 +713,7 @@
        'openid-urls-delete' => 'Desaniciar',
        'openid-add-url' => 'Amestar una OpenID nueva a la so cuenta',
        'openid-trusted-sites-label' => "Sitios nos que tien enfotu y onde yá 
utilizó la so OpenID p'aniciar sesión:",
-       'openid-trusted-sites-table-header' => 'Sitios enfotaos',
+       'openid-trusted-sites-table-header-column-url' => 'Sitios enfotaos',
        'openid-login-or-create-account' => 'Entrar o crear una cuenta nueva',
        'openid-provider-label-openid' => 'Escribi la URL de la to OpenID',
        'openid-provider-label-google' => 'Aniciar sesión usando la to cuenta 
de Google',
@@ -1494,7 +1517,7 @@
        'openid-urls-delete' => 'Löschen',
        'openid-add-url' => 'Eine neue OpenID deinem Benutzerkonto hinzufügen',
        'openid-trusted-sites-label' => 'Websites, denen du vertraust, und bei 
denen du mit deiner OpenID bekannt bist:',
-       'openid-trusted-sites-table-header' => 'Websites, denen du vertraust',
+       'openid-trusted-sites-table-header-column-url' => 'Websites, denen du 
vertraust',
        'openid-login-or-create-account' => 'Anmelden oder ein neues 
Benutzerkonto erstellen',
        'openid-provider-label-openid' => 'Gib deine OpenID-URL an',
        'openid-provider-label-google' => 'Mit deinem Google-Benutzerkonto 
anmelden',
@@ -1689,7 +1712,7 @@
        'openid-urls-delete' => 'Lašowaś',
        'openid-add-url' => 'Nowy OpenID twójomu kontoju pśidaś',
        'openid-trusted-sites-label' => 'Sedła, kótarymž dowěriš a źož sy swój 
OpenID za pśizjawjenje wužył:',
-       'openid-trusted-sites-table-header' => 'Dowěry gódne sedła',
+       'openid-trusted-sites-table-header-column-url' => 'Dowěry gódne sedła',
        'openid-login-or-create-account' => 'Pśizjawiś abo nowe konto załožyś',
        'openid-provider-label-openid' => 'Zapódaj swój URL OpenID',
        'openid-provider-label-google' => 'Z pomocu twójogo konta Google se 
pśizjawiś',
@@ -2309,7 +2332,7 @@
        'openid-urls-delete' => 'Supprimer',
        'openid-add-url' => 'Ajouter un nouvel OpenID à  votre compte',
        'openid-trusted-sites-label' => 'Sites en qui vous avez confiance et où 
vous avez utilisé votre OpenID pour vous connecter:',
-       'openid-trusted-sites-table-header' => 'Sites de confiance',
+       'openid-trusted-sites-table-header-column-url' => 'Sites de confiance',
        'openid-login-or-create-account' => 'Se connecter ou créer un nouveau 
compte',
        'openid-provider-label-openid' => 'Entrez votre URL OpenID',
        'openid-provider-label-google' => 'Vous connecter en utilisant votre 
compte Google',
@@ -2533,7 +2556,7 @@
        'openid-urls-delete' => 'Borrar',
        'openid-add-url' => 'Engadir un novo OpenID á súa conta',
        'openid-trusted-sites-label' => 'Sitios nos que confía e nos que 
utilizou o seu OpenID para identificarse:',
-       'openid-trusted-sites-table-header' => 'Sitios de confianza',
+       'openid-trusted-sites-table-header-column-url' => 'Sitios de confianza',
        'openid-login-or-create-account' => 'Acceder ou crear unha conta nova',
        'openid-provider-label-openid' => 'Insira o enderezo URL do seu OpenID',
        'openid-provider-label-google' => 'Acceder usando a súa conta do 
Google',
@@ -3056,7 +3079,7 @@
        'openid-urls-delete' => 'Wušmórnyć',
        'openid-add-url' => 'Nowy OpenID twojemu kontu přidać',
        'openid-trusted-sites-label' => 'Sydła, kotrymž dowěrješ a hdźež sy 
swój OpenID za přizjewjenje wužił:',
-       'openid-trusted-sites-table-header' => 'Dowěryhódne sydła',
+       'openid-trusted-sites-table-header-column-url' => 'Dowěryhódne sydła',
        'openid-login-or-create-account' => 'Přizjewić abo nowe konto załožić',
        'openid-provider-label-openid' => 'Zapodaj swój URL OpenID',
        'openid-provider-label-google' => 'Z pomocu twojeho konta Google so 
přizjewić',
@@ -3629,7 +3652,7 @@
        'openid-urls-registration' => '登録日時',
        'openid-urls-delete' => '削除',
        'openid-add-url' => '自分のアカウントに新しい OpenID を追加',
-       'openid-trusted-sites-table-header' => '信頼済みサイト',
+       'openid-trusted-sites-table-header-column-url' => '信頼済みサイト',
        'openid-login-or-create-account' => 'ログインまたは新規アカウント作成',
        'openid-provider-label-openid' => 'あなたの OpenID URL を入力します',
        'openid-provider-label-google' => 'あなたの Google アカウントを使用してログインする',
@@ -4174,7 +4197,7 @@
        'openid-urls-action' => 'Aktioun',
        'openid-urls-delete' => 'Läschen',
        'openid-add-url' => 'Eng nei OpenID bäi Äre Benotzerkont derbäisetzen',
-       'openid-trusted-sites-table-header' => 'Siten, deenen Dir traut',
+       'openid-trusted-sites-table-header-column-url' => 'Siten, deenen Dir 
traut',
        'openid-login-or-create-account' => 'Loggt Iech an oder maacht en neie 
Benotzerkont op',
        'openid-provider-label-openid' => 'Gitt Är OpenID URL un',
        'openid-provider-label-google' => 'Loggt Iech mat Ärem 
Goggle-Benotzerkont an',
@@ -4339,7 +4362,7 @@
        'openid-urls-delete' => 'Избриши',
        'openid-add-url' => 'Додај нов OpenID кон сметката',
        'openid-trusted-sites-label' => 'Мрежните места на коишто им верувате и 
кајшто го имате користено вашиот OpenID за најава:',
-       'openid-trusted-sites-table-header' => 'Мрежни места од доверба',
+       'openid-trusted-sites-table-header-column-url' => 'Мрежни места од 
доверба',
        'openid-login-or-create-account' => 'Најавете се или создајте нова 
сметка',
        'openid-provider-label-openid' => 'Внесете ја вашата OpenID URL адреса',
        'openid-provider-label-google' => 'Најавете се со вашата сметка на 
Google',
diff --git a/OpenID.php b/OpenID.php
index 4681753..827d2cd 100644
--- a/OpenID.php
+++ b/OpenID.php
@@ -29,7 +29,7 @@
        exit( 1 );
 }
 
-define( 'MEDIAWIKI_OPENID_VERSION', '3.03 20130310' );
+define( 'MEDIAWIKI_OPENID_VERSION', '3.04 20130310' );
 
 $path = dirname( __FILE__ );
 set_include_path( implode( PATH_SEPARATOR, array( $path ) ) . PATH_SEPARATOR . 
get_include_path() );
diff --git a/README.OpenID-mediawiki-extension 
b/README.OpenID-mediawiki-extension
index e8cdc56..34cc32f 100644
--- a/README.OpenID-mediawiki-extension
+++ b/README.OpenID-mediawiki-extension
@@ -1,5 +1,8 @@
 MediaWiki OpenID extension README.OpenID-mediawiki-extension file
 version 1.004 20120427
+
+### FIXME: UPDATE TO VERSION 3.x REQUIRED TG 20130310
+
 Homepage and manual http://www.mediawiki.org/wiki/Extension:OpenID
 
 Please check OpenID.setup.php for the current program version number
diff --git a/SpecialOpenIDServer.body.php b/SpecialOpenIDServer.body.php
index d513791..adf588f 100644
--- a/SpecialOpenIDServer.body.php
+++ b/SpecialOpenIDServer.body.php
@@ -138,6 +138,16 @@
                        }
                        break;
 
+               // request comes from OpenID preference page
+               // when user deletes a trusted site
+
+               case 'deletetrustedsite':
+
+                       $this->deleteTrustedSite();
+                       return;
+
+                       break;
+
                default:
 
                        if ( strlen( $par ) ) {
@@ -495,10 +505,9 @@
                }
        }
 
-       function SetUserTrust( &$user, $trust_root, $value ) {
+       function SetUserTrust( &$user, $trust_root, $value = NULL ) {
 
                $trust_array = $this->GetUserTrustArray( $user );
-
                if ( is_null( $value ) ) {
                        if ( array_key_exists( $trust_root, $trust_array ) ) {
                                unset( $trust_array[$trust_root] );
@@ -508,6 +517,7 @@
                }
 
                $this->SetUserTrustArray( $user, $trust_array );
+
        }
 
        static function GetUserTrustArray( $user ) {
@@ -558,6 +568,54 @@
                return in_array( $name, $fields );
        }
 
+
+       function deleteTrustedSite() {
+               global $wgUser, $wgOut, $wgRequest;
+
+               $trustedSiteToBeDeleted = $wgRequest->getVal( 'url' );
+               $wgOut->setPageTitle( wfMessage( 
'openid-trusted-sites-delete-confirmation-page-title' )->text() );
+
+               if ( $wgRequest->wasPosted()
+                       && $wgUser->matchEditToken( $wgRequest->getVal( 
'wpEditToken' ), $trustedSiteToBeDeleted ) ) {
+
+                       if ( $trustedSiteToBeDeleted === "*" ) {
+
+                               // NULL sets the default value: it removes this 
key
+                               $wgUser->setOption( 'openid_trust', NULL );
+                               $wgUser->saveSettings();
+                               $wgOut->addWikiMsg( 
'openid-trusted-sites-delete-all-confirmation-success-text' );
+
+                       } else {
+
+                               $this->SetUserTrust( $wgUser, 
$trustedSiteToBeDeleted, NULL );
+                               $wgUser->saveSettings();
+                               $wgOut->addWikiMsg( 
'openid-trusted-sites-delete-confirmation-success-text', 
$trustedSiteToBeDeleted );
+
+                       }
+
+                       return;
+               }
+
+               if ( $trustedSiteToBeDeleted === "*" ) {
+                       $wgOut->addWikiMsg( 
'openid-trusted-sites-delete-all-confirmation-question' );
+               } else {
+                       $wgOut->addWikiMsg( 
'openid-trusted-sites-delete-confirmation-question', $trustedSiteToBeDeleted );
+               }
+
+               $wgOut->addHtml(
+                       Xml::openElement( 'form',
+                               array(
+                                       'action' => $this->getTitle( 
'DeleteTrustedSite' )->getLocalUrl(),
+                                       'method' => 'post'
+                               )
+                       ) .
+                       Xml::submitButton( wfMessage( 
'openid-trusted-sites-delete-confirmation-button-text' )->text() ) . "\n" .
+                       Html::Hidden( 'url', $trustedSiteToBeDeleted ) . "\n" .
+                       Html::Hidden( 'wpEditToken', $wgUser->editToken( 
$trustedSiteToBeDeleted ) ) . "\n" .
+                       Xml::closeElement( 'form' )
+               );
+       }
+
        function SregFromQuery( $query ) {
                $sreg = array( 'required' => array(), 'optional' => array(),
                                          'policy_url' => null );

-- 
To view, visit https://gerrit.wikimedia.org/r/53032
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: Ife58ad1900135291dd4116966a4799704ab6fcbd
Gerrit-PatchSet: 12
Gerrit-Project: mediawiki/extensions/OpenID
Gerrit-Branch: master
Gerrit-Owner: Wikinaut <[email protected]>
Gerrit-Reviewer: Alex Monk <[email protected]>
Gerrit-Reviewer: Reedy <[email protected]>
Gerrit-Reviewer: Ryan Lane <[email protected]>
Gerrit-Reviewer: Wikinaut <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to