Lewis Cawte has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/325133

Change subject: [WIP] Replacement of old AJAX stuff with API modules, based on 
ikasty's code
......................................................................

[WIP] Replacement of old AJAX stuff with API modules, based on ikasty's code

Original diff can be found at
https://github.com/wiki-chan/Social/commit/bb932d15d36bcb4ee076bdcf0e8494496eb0906b
Some cleanup, (copypasted) "brand new" code, etc. by me.

* Renamed API modules to clearly mark them as such
** SendUserBoardMessage --> ApiSendUserBoardMessage
** RelationshipResponse --> ApiRelationshipResponse
* Also prefixed the API actions with socialprofile- instead of social-, for 
consistency
(unlike the Wiki-Chan fork, SocialProfile's canonical name is SocialProfile); 
i.e. socialprofile-send-message
instead of social-send-message for the UserBoard API module used to send out 
board messages
* Added new API module for deleting UserBoard messages 
(ApiDeleteUserBoardMessage)
* Made the API modules use $this->getUser() instead of the global $wgUser
* Translated various hard-coded Korean strings (via Google Translate) in the 
API modules to English

And random, not directly related changes nevertheless bundled here:
* Moved one hard-coded English string from UserProfilePage.js into the i18n file
** This is kinda shitty because technically it should be and actually *is*
already a UserBoard string (userboard_confirmdelete) and now it's
duplicated here as user-board-confirm-delete
* And also in UserProfilePage.js, got rid of an unnecessary variable (replaceID)

Change-Id: I91bb1b68c3a66f7af422435307085daa709a2156
---
M SocialProfile.php
A UserBoard/ApiDeleteUserBoardMessage.php
A UserBoard/ApiSendUserBoardMessage.php
M UserBoard/SpecialUserBoard.php
M UserBoard/UserBoard.js
D UserBoard/UserBoard_AjaxFunctions.php
M UserProfile/UserProfile.php
M UserProfile/UserProfilePage.js
M UserProfile/i18n/en.json
M UserProfile/i18n/fi.json
A UserRelationship/ApiRelationshipResponse.php
D UserRelationship/Relationship_AjaxFunctions.php
M UserRelationship/UserRelationship.js
13 files changed, 256 insertions(+), 124 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/SocialProfile 
refs/changes/33/325133/1

diff --git a/SocialProfile.php b/SocialProfile.php
index 3cb910b..f4b722a 100644
--- a/SocialProfile.php
+++ b/SocialProfile.php
@@ -31,12 +31,12 @@
 $wgMessagesDirs['SocialProfileUserProfile'] = __DIR__ . '/UserProfile/i18n';
 $wgMessagesDirs['SocialProfileUserRelationship'] = __DIR__ . 
'/UserRelationship/i18n';
 $wgMessagesDirs['SocialProfileUserStats'] = __DIR__ . '/UserStats/i18n';
+
 $wgExtensionMessagesFiles['SocialProfileNamespaces'] = __DIR__ . 
'/SocialProfile.namespaces.php';
 $wgExtensionMessagesFiles['AvatarMagic'] = __DIR__ . 
'/UserProfile/Avatar.magic.i18n.php';
 
 // Classes to be autoloaded
 $wgAutoloadClasses['GenerateTopUsersReport'] = __DIR__ . 
'/UserStats/GenerateTopUsersReport.php';
-
 $wgAutoloadClasses['SpecialAddRelationship'] = __DIR__ . 
'/UserRelationship/SpecialAddRelationship.php';
 $wgAutoloadClasses['SpecialBoardBlast'] = __DIR__ . 
'/UserBoard/SpecialSendBoardBlast.php';
 $wgAutoloadClasses['SpecialEditProfile'] = __DIR__ . 
'/UserProfile/SpecialEditProfile.php';
@@ -67,9 +67,18 @@
 $wgAutoloadClasses['AvatarParserFunction'] = __DIR__ . 
'/UserProfile/AvatarParserFunction.php';
 $wgAutoloadClasses['SPUserSecurity'] = __DIR__ . 
'/UserSecurity/UserSecurityClass.php';
 
-// API module
+// API modules
 $wgAutoloadClasses['ApiUserProfilePrivacy'] = __DIR__ . 
'/UserProfile/ApiUserProfilePrivacy.php';
 $wgAPIModules['smpuserprivacy'] = 'ApiUserProfilePrivacy';
+
+$wgAutoloadClasses['ApiDeleteUserBoardMessage'] = __DIR__ . 
'/UserBoard/ApiDeleteUserBoardMessage.php';
+$wgAPIModules['socialprofile-delete-message'] = 'ApiDeleteUserBoardMessage';
+
+$wgAutoloadClasses['ApiSendUserBoardMessage'] = __DIR__ . 
'/UserBoard/ApiSendUserBoardMessage.php';
+$wgAPIModules['socialprofile-send-message'] = 'ApiSendUserBoardMessage';
+
+$wgAutoloadClasses['ApiRelationshipResponse'] = __DIR__ . 
'/UserRelationship/ApiRelationshipResponse.php';
+$wgAPIModules['socialprofile-request-response'] = 'ApiRelationshipResponse';
 
 // New special pages
 $wgSpecialPages['AddRelationship'] = 'SpecialAddRelationship';
@@ -89,10 +98,6 @@
 $wgSpecialPages['UserBoard'] = 'SpecialViewUserBoard';
 $wgSpecialPages['ViewRelationshipRequests'] = 
'SpecialViewRelationshipRequests';
 $wgSpecialPages['ViewRelationships'] = 'SpecialViewRelationships';
-
-// Necessary AJAX functions
-require_once( 
"$IP/extensions/SocialProfile/UserBoard/UserBoard_AjaxFunctions.php" );
-require_once( 
"$IP/extensions/SocialProfile/UserRelationship/Relationship_AjaxFunctions.php" 
);
 
 // What to display on social profile pages by default?
 $wgUserProfileDisplay['board'] = true;
@@ -116,7 +121,7 @@
        'path' => __FILE__,
        'name' => 'SocialProfile',
        'author' => array( 'Aaron Wright', 'David Pean', 'Jack Phoenix' ),
-       'version' => '1.8',
+       'version' => '1.9',
        'url' => 'https://www.mediawiki.org/wiki/Extension:SocialProfile',
        'descriptionmsg' => 'socialprofile-desc',
 );
@@ -306,6 +311,7 @@
 
 $wgResourceModules['ext.socialprofile.userrelationship.js'] = array(
        'scripts' => 'UserRelationship.js',
+       'dependencies' => 'mediawiki.util',
        'localBasePath' => __DIR__ . '/UserRelationship',
        'remoteExtPath' => 'SocialProfile/UserRelationship',
 );
diff --git a/UserBoard/ApiDeleteUserBoardMessage.php 
b/UserBoard/ApiDeleteUserBoardMessage.php
new file mode 100644
index 0000000..b1428bb
--- /dev/null
+++ b/UserBoard/ApiDeleteUserBoardMessage.php
@@ -0,0 +1,52 @@
+<?php
+
+class ApiDeleteUserBoardMessage extends ApiBase {
+       public function execute() {
+               $main = $this->getMain();
+               $user = $this->getUser();
+
+               $messageId = $main->getVal( 'id' );
+
+               // Don't allow deleting messages when the database is locked 
for some reason
+               if ( wfReadOnly() ) {
+                       $this->getResult()->addValue( null, 'result', 'You 
cannot delete messages right now.' );
+                       return true;
+               }
+
+               $b = new UserBoard();
+               if (
+                       $b->doesUserOwnMessage( $user->getId(), $messageId ) ||
+                       $user->isAllowed( 'userboard-delete' )
+               )
+               {
+                       $b->deleteMessage( $messageId );
+               }
+
+               $this->getResult()->addValue( null, 'result', 'ok' );
+
+               return true;
+       }
+
+       public function getDescription() {
+               return 'Delete a UserBoard message.';
+       }
+
+       public function getAllowedParams() {
+               return array_merge( parent::getAllowedParams(), array(
+                       'id' => array(
+                               ApiBase::PARAM_TYPE => 'integer',
+                               ApiBase::PARAM_REQUIRED => false
+                       )
+               ) );
+       }
+
+       public function getParamDescription() {
+               return array_merge( parent::getParamDescription(), array(
+                       'id' => 'Unique identifier of the board message to 
delete.'
+               ) );
+       }
+
+       public function getExamplesMessages() {
+               return array();
+       }
+}
\ No newline at end of file
diff --git a/UserBoard/ApiSendUserBoardMessage.php 
b/UserBoard/ApiSendUserBoardMessage.php
new file mode 100644
index 0000000..5bf6622
--- /dev/null
+++ b/UserBoard/ApiSendUserBoardMessage.php
@@ -0,0 +1,71 @@
+<?php
+
+class ApiSendUserBoardMessage extends ApiBase {
+       public function execute() {
+               $main = $this->getMain();
+
+               $user_name = $main->getVal( 'username' );
+               $message = $main->getVal( 'message' );
+               $message_type = $main->getVal( 'type' ) || 0;
+
+               $user = $this->getUser();
+
+               // Don't allow blocked users to send messages and also don't 
allow message
+               // sending when the database is locked for some reason
+               if ( $user->isBlocked() || wfReadOnly() ) {
+                       $this->getResult()->addValue( null, 'result', 'You 
cannot send messages.' );
+                       return true;
+               }
+
+               $user_name = stripslashes( $user_name );
+               $user_name = urldecode( $user_name );
+               $user_id_to = User::idFromName( $user_name );
+               $b = new UserBoard();
+
+               $m = $b->sendBoardMessage(
+                       $user->getId(),
+                       $user->getName(),
+                       $user_id_to,
+                       $user_name,
+                       urldecode( $message ),
+                       $message_type
+               );
+
+               $this->getResult()->addValue( null, 'result', 
$b->displayMessages( $user_id_to, 0, 1 ) );
+
+               return true;
+       }
+
+       public function getDescription() {
+               return 'Send a message to a user\'s UserBoard.';
+       }
+
+       public function getAllowedParams() {
+               return array_merge( parent::getAllowedParams(), array(
+                       'username' => array(
+                               ApiBase::PARAM_TYPE => 'string',
+                               ApiBase::PARAM_REQUIRED => true
+                       ),
+                       'message' => array(
+                               ApiBase::PARAM_TYPE => 'string',
+                               ApiBase::PARAM_REQUIRED => true
+                       ),
+                       'type' => array(
+                               ApiBase::PARAM_TYPE => 'integer',
+                               ApiBase::PARAM_REQUIRED => false
+                       )
+               ) );
+       }
+
+       public function getParamDescription() {
+               return array_merge( parent::getParamDescription(), array(
+                       'username' => 'The recipient\'s user name.',
+                       'message' => 'urlencoded version of the message to 
send.',
+                       'type' => 'Message type; 0 for a public message, 1 for 
a private message.'
+               ) );
+       }
+
+       public function getExamplesMessages() {
+               return array();
+       }
+}
\ No newline at end of file
diff --git a/UserBoard/SpecialUserBoard.php b/UserBoard/SpecialUserBoard.php
index f20f3e7..b230b4c 100644
--- a/UserBoard/SpecialUserBoard.php
+++ b/UserBoard/SpecialUserBoard.php
@@ -317,7 +317,7 @@
                                $userPageURL = htmlspecialchars( 
$user->getFullURL() );
                                $output .= "<div class=\"user-board-message\">
                                        <div class=\"user-board-message-from\">
-                                                       <a 
href=\"{$userPageURL}\" 
title=\"{$ub_message['user_name_from']}}\">{$ub_message['user_name_from']} </a> 
{$ub_message_type_label}
+                                                       <a 
href=\"{$userPageURL}\" 
title=\"{$ub_message['user_name_from']}\">{$ub_message['user_name_from']} </a> 
{$ub_message_type_label}
                                        </div>
                                        <div class=\"user-board-message-time\">"
                                                . $this->msg( 
'userboard_posted_ago', $b->getTimeAgo( $ub_message['timestamp'] ) )->parse() .
diff --git a/UserBoard/UserBoard.js b/UserBoard/UserBoard.js
index 5ec071a..ba61efe 100644
--- a/UserBoard/UserBoard.js
+++ b/UserBoard/UserBoard.js
@@ -14,10 +14,12 @@
                                encodedMsg = encodeURIComponent( message ),
                                messageType = document.getElementById( 
'message_type' ).value;
                        jQuery.post(
-                               mediaWiki.util.wikiScript(), {
-                                       action: 'ajax',
-                                       rs: 'wfSendBoardMessage',
-                                       rsargs: [encodedName, encodedMsg, 
messageType, perPage]
+                               mediaWiki.util.wikiScript( 'api' ), {
+                                       action: 'socialprofile-send-message',
+                                       format: 'json',
+                                       username: encodedName,
+                                       message: encodedMsg,
+                                       type: messageType
                                },
                                function() {
                                        UserBoard.posted = 0;
@@ -40,10 +42,10 @@
        deleteMessage: function( id ) {
                if ( window.confirm( mediaWiki.msg( 'userboard_confirmdelete' ) 
) ) {
                        jQuery.post(
-                               mediaWiki.util.wikiScript(), {
-                                       action: 'ajax',
-                                       rs: 'wfDeleteBoardMessage',
-                                       rsargs: [id]
+                               mediaWiki.util.wikiScript( 'api' ), {
+                                       action: 'socialprofile-delete-message',
+                                       format: 'json',
+                                       'id': id
                                },
                                function() {
                                        //window.location.reload();
diff --git a/UserBoard/UserBoard_AjaxFunctions.php 
b/UserBoard/UserBoard_AjaxFunctions.php
deleted file mode 100644
index b0d3057..0000000
--- a/UserBoard/UserBoard_AjaxFunctions.php
+++ /dev/null
@@ -1,46 +0,0 @@
-<?php
-/**
- * AJAX functions used by UserBoard.
- */
-$wgAjaxExportList[] = 'wfSendBoardMessage';
-function wfSendBoardMessage( $user_name, $message, $message_type, $count ) {
-       global $wgUser;
-
-       // Don't allow blocked users to send messages and also don't allow 
message
-       // sending when the database is locked for some reason
-       if ( $wgUser->isBlocked() || wfReadOnly() ) {
-               return '';
-       }
-
-       $user_name = stripslashes( $user_name );
-       $user_name = urldecode( $user_name );
-       $user_id_to = User::idFromName( $user_name );
-       $b = new UserBoard();
-
-       $m = $b->sendBoardMessage(
-               $wgUser->getID(), $wgUser->getName(), $user_id_to, $user_name,
-               urldecode( $message ), $message_type
-       );
-
-       return $b->displayMessages( $user_id_to, 0, $count );
-}
-
-$wgAjaxExportList[] = 'wfDeleteBoardMessage';
-function wfDeleteBoardMessage( $ub_id ) {
-       global $wgUser;
-
-       // Don't allow deleting messages when the database is locked for some 
reason
-       if ( wfReadOnly() ) {
-               return '';
-       }
-
-       $b = new UserBoard();
-       if (
-               $b->doesUserOwnMessage( $wgUser->getID(), $ub_id ) ||
-               $wgUser->isAllowed( 'userboard-delete' )
-       ) {
-               $b->deleteMessage( $ub_id );
-       }
-
-       return 'ok';
-}
\ No newline at end of file
diff --git a/UserProfile/UserProfile.php b/UserProfile/UserProfile.php
index baf00d8..95c8230 100644
--- a/UserProfile/UserProfile.php
+++ b/UserProfile/UserProfile.php
@@ -77,6 +77,8 @@
 
 $wgResourceModules['ext.socialprofile.userprofile.js'] = array(
        'scripts' => 'UserProfilePage.js',
+       'messages' => array( 'user-board-confirm-delete' ),
+       'dependencies' => 'mediawiki.util',
        'localBasePath' => __DIR__,
        'remoteExtPath' => 'SocialProfile/UserProfile',
 );
diff --git a/UserProfile/UserProfilePage.js b/UserProfile/UserProfilePage.js
index 8c7d86f..c05ef1f 100644
--- a/UserProfile/UserProfilePage.js
+++ b/UserProfile/UserProfilePage.js
@@ -1,7 +1,6 @@
 /**
  * JavaScript functions used by UserProfile
  */
-var replaceID;
 var UserProfilePage = {
        posted: 0,
        numReplaces: 0,
@@ -16,27 +15,29 @@
                if ( document.getElementById( 'message' ).value && 
!UserProfilePage.posted ) {
                        UserProfilePage.posted = 1;
                        jQuery.post(
-                               mediaWiki.util.wikiScript(), {
-                                       action: 'ajax',
-                                       rs: 'wfSendBoardMessage',
-                                       rsargs: [userTo, encMsg, msgType, 10]
+                               mediaWiki.util.wikiScript( 'api' ), {
+                                       action: 'socialprofile-send-message',
+                                       format: 'json',
+                                       username: userTo,
+                                       message: encMsg,
+                                       type: msgType
                                },
                                function( data ) {
-                                       jQuery( '#user-page-board' ).html( data 
);
+                                       jQuery( data.result ).prependTo( 
'#user-page-board' );
                                        UserProfilePage.posted = 0;
-                                       jQuery( '#message' ).text( '' );
+                                       jQuery( '#message' ).val( '' );
                                }
                        );
                }
        },
 
        deleteMessage: function( id ) {
-               if ( window.confirm( 'Are you sure you want to delete this 
message?' ) ) {
+               if ( window.confirm( mediaWiki.msg( 'user-board-confirm-delete' 
) ) ) {
                        jQuery.post(
-                               mediaWiki.util.wikiScript(), {
-                                       action: 'ajax',
-                                       rs: 'wfDeleteBoardMessage',
-                                       rsargs: [id]
+                               mediaWiki.util.wikiScript( 'api' ), {
+                                       action: 'socialprofile-delete-message',
+                                       format: 'json',
+                                       'id': id
                                },
                                function() {
                                        //window.location.reload();
@@ -55,7 +56,7 @@
        },
 
        uploadError: function( message ) {
-               document.getElementById( 'mini-gallery-' + replaceID 
).innerHTML = UserProfilePage.oldHtml;
+               document.getElementById( 'mini-gallery-' + 
UserProfilePage.replaceID ).innerHTML = UserProfilePage.oldHtml;
                document.getElementById( 'upload-frame-errors' ).innerHTML = 
message;
                document.getElementById( 'imageUpload-frame' ).src = 
'index.php?title=Special:MiniAjaxUpload&wpThumbWidth=75';
 
diff --git a/UserProfile/i18n/en.json b/UserProfile/i18n/en.json
index 7e989da..8d20588 100644
--- a/UserProfile/i18n/en.json
+++ b/UserProfile/i18n/en.json
@@ -195,6 +195,7 @@
        "user-type-toggle-old": "Use wiki userpage",
        "user-type-toggle-new": "Use social userpage",
        "user-board-login-message": "You must be <a href=\"$1\">logged in</a> 
to post messages to other users",
+       "user-board-confirm-delete": "Are you sure you want to delete this 
message?",
        "removeavatar": "Remove avatar",
        "givegift": "Give a gift",
        "viewgifts": "View gifts",
diff --git a/UserProfile/i18n/fi.json b/UserProfile/i18n/fi.json
index d6a5e65..9e1750a 100644
--- a/UserProfile/i18n/fi.json
+++ b/UserProfile/i18n/fi.json
@@ -104,7 +104,7 @@
        "user-profile-personal-info": "Tiedot",
        "user-profile-personal-name": "Nimi",
        "user-profile-personal-email": "Sähköposti",
-       "user-profile-personal-email-needs-auth": "(sähköpostiosoitteesi tulee 
olla varmennettu, jotta voit saada sivuston huomautuksia)",
+       "user-profile-personal-email-needs-auth": "(sähköpostiosoitteesi tulee 
olla varmennettu, jotta voit saada sivuston ilmoituksia)",
        "user-profile-personal-confirmemail": "Vahvista sähköpostisi",
        "user-profile-personal-location": "Sijainti",
        "user-profile-personal-city": "Kaupunki",
@@ -132,7 +132,7 @@
        "user-profile-interests-eats": "Syö",
        "user-profile-interests-foodsnacks": "Ruoka & naposteltavat",
        "user-profile-interests-drinks": "Juomat",
-       "user-profile-preferences-emails": "Sähköpostihuomatukset",
+       "user-profile-preferences-emails": "Sähköposti-ilmoitukset",
        "user-profile-preferences-emails-personalmessage": "Kun saan 
yksityisviestin",
        "user-profile-preferences-emails-friendfoe": "Kun toinen käyttäjä lisää 
minut ystäväksi tai viholliseksi",
        "user-profile-preferences-emails-gift": "Kun saan lahjan",
diff --git a/UserRelationship/ApiRelationshipResponse.php 
b/UserRelationship/ApiRelationshipResponse.php
new file mode 100644
index 0000000..0c61887
--- /dev/null
+++ b/UserRelationship/ApiRelationshipResponse.php
@@ -0,0 +1,84 @@
+<?php
+
+class ApiRelationshipResponse extends ApiBase {
+       public function execute() {
+               $main = $this->getMain();
+
+               $response = $main->getVal( 'response' );
+               $requestId = $main->getVal( 'id' );
+
+               $user = $this->getUser();
+
+               // Don't allow blocked users to send messages and also don't 
allow message
+               // sending when the database is locked for some reason
+               if ( $user->isBlocked() || wfReadOnly() ) {
+                       return false;
+               }
+
+               $out = '';
+
+               $rel = new UserRelationship( $user->getName() );
+               if ( $rel->verifyRelationshipRequest( $requestId ) == true ) {
+                       $request = $rel->getRequest( $requestId );
+                       $user_name_from = $request[0]['user_name_from'];
+                       $user_id_from = User::idFromName( $user_name_from );
+                       $rel_type = strtolower( $request[0]['type'] );
+
+                       $rel->updateRelationshipRequestStatus( $requestId, 
intval( $response ) );
+
+                       $avatar = new wAvatar( $user_id_from, 'l' );
+                       $avatar_img = $avatar->getAvatarURL();
+
+                       if ( $response == 1 ) {
+                               $rel->addRelationship( $requestId );
+                               $out .= "<div class=\"relationship-action 
red-text\">
+                                       {$avatar_img}" .
+                                               wfMessage( 
"ur-requests-added-message-{$rel_type}", $user_name_from )->escaped() .
+                                       '<div class="visualClear"></div>
+                               </div>';
+                       } else {
+                               $out .= "<div class=\"relationship-action 
red-text\">
+                                       {$avatar_img}" .
+                                               wfMessage( 
"ur-requests-reject-message-{$rel_type}", $user_name_from )->escaped() .
+                                       '<div class="visualClear"></div>
+                               </div>';
+                       }
+                       $rel->deleteRequest( $requestId );
+               } else {
+                       return false;
+               }
+
+               $this->getResult()->addValue( null, 'html', $out );
+
+               return true;
+       }
+
+       public function getDescription() {
+               return 'Responds to user relationship (friend/foe) requests.';
+       }
+
+       public function getAllowedParams() {
+               return array_merge( parent::getAllowedParams(), array(
+                       'response' => array(
+                               ApiBase::PARAM_TYPE => 'integer',
+                               ApiBase::PARAM_REQUIRED => true
+                       ),
+                       'id' => array(
+                               ApiBase::PARAM_TYPE => 'integer',
+                               ApiBase::PARAM_REQUIRED => true
+                       )
+               ) );
+       }
+
+       public function getParamDescription() {
+               return array_merge( parent::getParamDescription(), array(
+                       'response' => 'Response to the relationship request; 1 
to accept, -1 to reject.',
+                       'id' => 'Unique identifier of the relationship request'
+               ) );
+       }
+
+       public function getExamplesMessages() {
+               return array();
+       }
+}
+
diff --git a/UserRelationship/Relationship_AjaxFunctions.php 
b/UserRelationship/Relationship_AjaxFunctions.php
deleted file mode 100644
index f919c25..0000000
--- a/UserRelationship/Relationship_AjaxFunctions.php
+++ /dev/null
@@ -1,42 +0,0 @@
-<?php
-/**
- * AJAX functions used by UserRelationship extension.
- */
-
-$wgAjaxExportList[] = 'wfRelationshipRequestResponse';
-function wfRelationshipRequestResponse( $response, $requestId ) {
-       global $wgUser;
-       $out = '';
-
-       $rel = new UserRelationship( $wgUser->getName() );
-       if ( $rel->verifyRelationshipRequest( $requestId ) == true ) {
-               $request = $rel->getRequest( $requestId );
-               $user_name_from = $request[0]['user_name_from'];
-               $user_id_from = User::idFromName( $user_name_from );
-               $rel_type = strtolower( $request[0]['type'] );
-
-               $response = ( isset( $_POST['response' ] ) ) ? 
$_POST['response'] : $response;
-               $rel->updateRelationshipRequestStatus( $requestId, intval( 
$response ) );
-
-               $avatar = new wAvatar( $user_id_from, 'l' );
-               $avatar_img = $avatar->getAvatarURL();
-
-               if ( $response == 1 ) {
-                       $rel->addRelationship( $requestId );
-                       $out .= "<div class=\"relationship-action red-text\">
-                               {$avatar_img}" .
-                                       wfMessage( 
"ur-requests-added-message-{$rel_type}", $user_name_from )->escaped() .
-                               '<div class="visualClear"></div>
-                       </div>';
-               } else {
-                       $out .= "<div class=\"relationship-action red-text\">
-                               {$avatar_img}" .
-                                       wfMessage( 
"ur-requests-reject-message-{$rel_type}", $user_name_from )->escaped() .
-                               '<div class="visualClear"></div>
-                       </div>';
-               }
-               $rel->deleteRequest( $requestId );
-       }
-
-       return $out;
-}
diff --git a/UserRelationship/UserRelationship.js 
b/UserRelationship/UserRelationship.js
index 5107d1a..de0d54f 100644
--- a/UserRelationship/UserRelationship.js
+++ b/UserRelationship/UserRelationship.js
@@ -7,13 +7,14 @@
        document.getElementById( 'request_action_' + id ).style.visibility = 
'hidden';
 
        jQuery.post(
-               mediaWiki.util.wikiScript(), {
-                       action: 'ajax',
-                       rs: 'wfRelationshipRequestResponse',
-                       rsargs: [response, id]
+               mediaWiki.util.wikiScript( 'api' ), {
+                       action: 'socialprofile-request-response',
+                       format: 'json',
+                       response: response,
+                       id: id
                },
                function( data ) {
-                       document.getElementById( 'request_action_' + id 
).innerHTML = data;
+                       document.getElementById( 'request_action_' + id 
).innerHTML = data.html;
                        jQuery( '#request_action_' + id ).fadeIn( 2000 );
                        document.getElementById( 'request_action_' + id 
).style.display = 'block';
                        document.getElementById( 'request_action_' + id 
).style.visibility = 'visible';

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I91bb1b68c3a66f7af422435307085daa709a2156
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/SocialProfile
Gerrit-Branch: master
Gerrit-Owner: Lewis Cawte <[email protected]>
Gerrit-Reviewer: Jack Phoenix <[email protected]>

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

Reply via email to