r50629 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r50628‎ | r50629 | r50630 >
Date:15:15, 15 May 2009
Author:ashley
Status:deferred
Tags:
Comment:
SocialProfile: cleanup to UserRelationship stuff:
*rewrote JS to be less YUI-dependent
*rewrote a raw SQL query to use Database class in UserRelationshipClass.php
*spacing
*a bit of documentation
*removed unused globals
Modified paths:
  • /trunk/extensions/SocialProfile/UserRelationship/Relationship_AjaxFunctions.php (modified) (history)
  • /trunk/extensions/SocialProfile/UserRelationship/SpecialAddRelationship.php (modified) (history)
  • /trunk/extensions/SocialProfile/UserRelationship/SpecialRemoveRelationship.php (modified) (history)
  • /trunk/extensions/SocialProfile/UserRelationship/SpecialViewRelationshipRequests.php (modified) (history)
  • /trunk/extensions/SocialProfile/UserRelationship/SpecialViewRelationships.php (modified) (history)
  • /trunk/extensions/SocialProfile/UserRelationship/UserRelationship.i18n.php (modified) (history)
  • /trunk/extensions/SocialProfile/UserRelationship/UserRelationship.js (modified) (history)
  • /trunk/extensions/SocialProfile/UserRelationship/UserRelationshipClass.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SocialProfile/UserRelationship/SpecialViewRelationshipRequests.php
@@ -32,31 +32,30 @@
3333 * It will automatically return them to the ViewRelationshipRequests page
3434 */
3535 if( $wgUser->getID() == 0 ){
36 - $wgOut->setPagetitle( wfMsg('ur-error-page-title') );
37 - $login = SpecialPage::getTitleFor( 'UserLogin' );
38 - $wgOut->redirect( $login->getFullURL('returnto=Special:ViewRelationshipRequests') );
 36+ $wgOut->setPageTitle( wfMsg( 'ur-error-page-title' ) );
 37+ $login = SpecialPage::getTitleFor( 'Userlogin' );
 38+ $wgOut->redirect( $login->getFullURL( 'returnto=Special:ViewRelationshipRequests' ) );
3939 return false;
4040 }
4141
42 - $wgOut->addScriptFile( $wgUserRelationshipScripts.'/UserRelationship.js' );
43 - $wgOut->addStyle( '../..' . $wgUserRelationshipScripts . '/UserRelationship.css' );
 42+ $wgOut->addScriptFile( $wgUserRelationshipScripts . '/UserRelationship.js' );
 43+ $wgOut->addExtensionStyle( $wgUserRelationshipScripts . '/UserRelationship.css' );
4444
4545 $rel = new UserRelationship( $wgUser->getName() );
46 - $friend_request_count = $rel->getOpenRequestCount($wgUser->getID(), 1);
47 - $foe_request_count = $rel->getOpenRequestCount($wgUser->getID(), 2);
 46+ $friend_request_count = $rel->getOpenRequestCount( $wgUser->getID(), 1 );
 47+ $foe_request_count = $rel->getOpenRequestCount( $wgUser->getID(), 2 );
4848
49 - if( count($_POST) && $_SESSION['alreadysubmitted'] == false ) {
 49+ if( count( $_POST ) && $_SESSION['alreadysubmitted'] == false ) {
5050 $_SESSION['alreadysubmitted'] = true;
5151 $rel->addRelationshipRequest( $this->user_name_to, $this->relationship_type, $_POST['message'] );
5252 $out = '<br /><span class="title">' . wfMsg( 'ur-already-submitted' ) . '</span><br /><br />';
53 - $wgOut->addHTML($out);
 53+ $wgOut->addHTML( $out );
5454 } else {
5555 $_SESSION['alreadysubmitted'] = false;
5656 $output = '';
57 - $plural = '';
5857
59 - $output .= $wgOut->setPagetitle( wfMsg('ur-requests-title') );
60 - $requests = $rel->getRequestList(0);
 58+ $output .= $wgOut->setPagetitle( wfMsg( 'ur-requests-title' ) );
 59+ $requests = $rel->getRequestList( 0 );
6160
6261 if( $requests ) {
6362
@@ -75,24 +74,22 @@
7675 $message = $wgOut->parse( trim( $request['message'] ), false );
7776
7877 $output .= "<div class=\"relationship-action black-text\" id=\"request_action_{$request["id"]}\">
79 - {$avatar_img}
80 - ".$msg;
 78+ {$avatar_img}" . $msg;
8179 if( $request['message'] ) {
82 - $output .= '<div class="relationship-message">'.$message.'</div>';
 80+ $output .= '<div class="relationship-message">' . $message . '</div>';
8381 }
84 - $output .= "<div class=\"cleared\"></div>
85 - <div class=\"relationship-buttons\">
86 - <input type=\"button\" class=\"site-button\" value=\"".wfMsg('ur-accept')."\" onclick=\"javascript:requestResponse(1,{$request["id"]})\">
87 - <input type=\"button\" class=\"site-button\" value=\"".wfMsg('ur-reject')."\" onclick=\"javascript:requestResponse(-1,{$request["id"]})\">
 82+ $output .= '<div class="cleared"></div>
 83+ <div class="relationship-buttons">
 84+ <input type="button" class="site-button" value="' . wfMsg( 'ur-accept' ) . '" onclick="javascript:requestResponse(1,' . $request['id'] . ')" />
 85+ <input type="button" class="site-button" value="' . wfMsg( 'ur-reject' ) . '" onclick="javascript:requestResponse(-1,' . $request['id'] . ')" />
8886 </div>
89 - </div>";
 87+ </div>';
9088 }
9189 } else {
92 - #$invite_link = SpecialPage::getTitleFor( 'InviteContacts' );
93 - $invite_link = Title::makeTitle( NS_SPECIAL, 'InviteContacts' );
 90+ $invite_link = SpecialPage::getTitleFor( 'InviteContacts' );
9491 $output = wfMsg( 'ur-no-requests-message', $invite_link->escapeFullURL() );
9592 }
96 - $wgOut->addHTML($output);
 93+ $wgOut->addHTML( $output );
9794 }
9895 }
9996 }
\ No newline at end of file
Index: trunk/extensions/SocialProfile/UserRelationship/SpecialAddRelationship.php
@@ -6,7 +6,7 @@
77 * Example URL: index.php?title=Special:AddRelationship&user=Pean&rel_type=2 (for adding as foe)
88 *
99 * @file
10 - * @ingroup Extension
 10+ * @ingroup Extensions
1111 * @author David Pean <david.pean@gmail.com>
1212 * @copyright Copyright © 2007, Wikia Inc.
1313 * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later
@@ -32,9 +32,9 @@
3333 wfLoadExtensionMessages( 'SocialProfileUserRelationship' );
3434 $this->setHeaders();
3535
36 - $wgOut->addStyle( '../..' . $wgUserRelationshipScripts . '/UserRelationship.css' );
 36+ $wgOut->addExtensionStyle( $wgUserRelationshipScripts . '/UserRelationship.css' );
3737
38 - $usertitle = Title::newFromDBkey( $wgRequest->getVal('user') );
 38+ $usertitle = Title::newFromDBkey( $wgRequest->getVal( 'user' ) );
3939
4040 if( !$usertitle ){
4141 $wgOut->addWikiText( wfMsgNoTrans( 'ur-add-no-user' ) );
@@ -44,69 +44,69 @@
4545 $user = Title::makeTitle( NS_USER, $usertitle->getText() );
4646
4747 $this->user_name_to = $usertitle->getText();
48 - $this->user_id_to = User::idFromName($this->user_name_to);
49 - $this->relationship_type = $wgRequest->getVal('rel_type');
50 - if( !$this->relationship_type || !is_numeric($this->relationship_type) ) $this->relationship_type = 1;
 48+ $this->user_id_to = User::idFromName( $this->user_name_to );
 49+ $this->relationship_type = $wgRequest->getVal( 'rel_type' );
 50+ if( !$this->relationship_type || !is_numeric( $this->relationship_type ) ) $this->relationship_type = 1;
5151
52 - if( ($wgUser->getID()== $this->user_id_to) && ($wgUser->getID() != 0) ) {
53 - $out .= $wgOut->setPagetitle( wfMsg('ur-error-title') );
 52+ if( ( $wgUser->getID() == $this->user_id_to ) && ( $wgUser->getID() != 0 ) ) {
 53+ $out .= $wgOut->setPageTitle( wfMsg( 'ur-error-title' ) );
5454 $out .= '<div class="relationship-error-message">
55 - '.wfMsg('ur-add-error-message-yourself').'
 55+ ' . wfMsg( 'ur-add-error-message-yourself' ) . '
5656 </div>
5757 <div>
58 - <input type="button" class="site-button" value="'.wfMsg('ur-main-page').'" size="20" onclick=\'window.location="index.php?title="' . wfMsgForContent( 'mainpage' ) . '"\' />';
 58+ <input type="button" class="site-button" value="' . wfMsg( 'ur-main-page' ) . '" size="20" onclick=\'window.location="index.php?title="' . wfMsgForContent( 'mainpage' ) . '"\' />';
5959 if( $wgUser->isLoggedIn() ){
60 - $out.= '<input type="button" class="site-button" value="'.wfMsg('ur-your-profile').'" size="20" onclick=\'window.location="'.$wgUser->getUserPage()->escapeFullURL() . '"\' />';
 60+ $out.= '<input type="button" class="site-button" value="' . wfMsg( 'ur-your-profile' ) . '" size="20" onclick=\'window.location="' . $wgUser->getUserPage()->escapeFullURL() . '"\' />';
6161 }
6262 $out .= '</div>';
6363
64 - $wgOut->addHTML($out);
 64+ $wgOut->addHTML( $out );
6565
6666 } else if( $wgUser->isBlocked() ) {
67 - $out .= $wgOut->setPagetitle( wfMsg('ur-error-title') );
 67+ $out .= $wgOut->setPageTitle( wfMsg( 'ur-error-title' ) );
6868 $out .= '<div class="relationship-error-message">
69 - '.wfMsg('ur-add-error-message-blocked').'
 69+ ' . wfMsg( 'ur-add-error-message-blocked' ) . '
7070 </div>
7171 <div>
72 - <input type="button" class="site-button" value="'.wfMsg('ur-main-page').'" size="20" onclick=\'window.location="index.php?title="' . wfMsgForContent( 'mainpage' ) . '"\' />';
 72+ <input type="button" class="site-button" value="' . wfMsg( 'ur-main-page' ) . '" size="20" onclick=\'window.location="index.php?title="' . wfMsgForContent( 'mainpage' ) . '"\' />';
7373 if( $wgUser->isLoggedIn() ){
74 - $out.= '<input type="button" class="site-button" value="'.wfMsg('ur-your-profile').'" size="20" onclick=\'window.location="'.$wgUser->getUserPage()->escapeFullURL() . '"\' />';
 74+ $out.= '<input type="button" class="site-button" value="' . wfMsg( 'ur-your-profile' ) . '" size="20" onclick=\'window.location="' . $wgUser->getUserPage()->escapeFullURL() . '"\' />';
7575 }
7676 $out .= '</div>';
7777
78 - $wgOut->addHTML($out);
 78+ $wgOut->addHTML( $out );
7979
8080 } else if( $this->user_id_to == 0 ) {
81 - $out .= $wgOut->setPagetitle( wfMsg('ur-error-title') );
 81+ $out .= $wgOut->setPageTitle( wfMsg( 'ur-error-title' ) );
8282 $out .= '<div class="relationship-error-message">
83 - '.wfMsg('ur-add-error-message-no-user').'
 83+ ' . wfMsg( 'ur-add-error-message-no-user' ) . '
8484 </div>
8585 <div>
86 - <input type="button" class="site-button" value="'.wfMsg('ur-main-page').'" size="20" onclick=\'window.location="index.php?title="' . wfMsgForContent( 'mainpage' ) . '"\' />';
 86+ <input type="button" class="site-button" value="' . wfMsg( 'ur-main-page' ) . '" size="20" onclick=\'window.location="index.php?title="' . wfMsgForContent( 'mainpage' ) . '"\' />';
8787 if( $wgUser->isLoggedIn() ){
88 - $out.= '<input type="button" class="site-button" value="'.wfMsg('ur-your-profile').'" size="20" onclick=\'window.location="'.$wgUser->getUserPage()->escapeFullURL() . '"\' />';
 88+ $out.= '<input type="button" class="site-button" value="' . wfMsg( 'ur-your-profile' ) . '" size="20" onclick=\'window.location="' . $wgUser->getUserPage()->escapeFullURL() . '"\' />';
8989 }
9090 $out .= '</div>';
9191
92 - $wgOut->addHTML($out);
 92+ $wgOut->addHTML( $out );
9393
9494 } else if( UserRelationship::getUserRelationshipByID( $this->user_id_to, $wgUser->getID() ) >=1 ){
9595
9696 if( UserRelationship::getUserRelationshipByID( $this->user_id_to, $wgUser->getID() ) == 1 ) {
97 - $error = wfMsg('ur-add-error-message-existing-relationship-friend', $this->user_name_to);
 97+ $error = wfMsg( 'ur-add-error-message-existing-relationship-friend', $this->user_name_to );
9898 } else {
99 - $error = wfMsg('ur-add-error-message-existing-relationship-foe', $this->user_name_to);
 99+ $error = wfMsg( 'ur-add-error-message-existing-relationship-foe', $this->user_name_to );
100100 }
101101
102 - $avatar = new wAvatar($this->user_id_to, 'l');
103 - $avatar_img = '<img src="'.$wgUploadPath.'/avatars/' . $avatar->getAvatarImage() . '" alt="" border="0" />';
 102+ $avatar = new wAvatar( $this->user_id_to, 'l' );
 103+ $avatar_img = '<img src="' . $wgUploadPath . '/avatars/' . $avatar->getAvatarImage() . '" alt="" border="0" />';
104104
105105 $out = '';
106 - $out .= $wgOut->setPagetitle( wfMsg('ur-error-title') );
 106+ $out .= $wgOut->setPageTitle( wfMsg( 'ur-error-title' ) );
107107
108108 $out .= "<div class=\"relationship-action\">
109109 {$avatar_img}
110 - ".$error."
 110+ " . $error . "
111111 <div class=\"relationship-buttons\">
112112 <input type=\"button\" class=\"site-button\" value=\"".wfMsg('ur-main-page')."\" size=\"20\" onclick=\"window.location='index.php?title=" . wfMsgForContent( 'mainpage' ) . "'\"/>
113113 <input type=\"button\" class=\"site-button\" value=\"".wfMsg('ur-your-profile')."\" size=\"20\" onclick=\"window.location='".$wgUser->getUserPage()->escapeFullURL() . "'\"/>
@@ -114,86 +114,86 @@
115115 <div class=\"cleared\"></div>
116116 </div>";
117117
118 - $wgOut->addHTML($out);
 118+ $wgOut->addHTML( $out );
119119
120120 } else if( UserRelationship::userHasRequestByID( $this->user_id_to, $wgUser->getID() ) == true ){
121121
122122 if( $this->relationship_type == 1 ) {
123 - $error = wfMsg('ur-add-error-message-pending-friend-request', $this->user_name_to);
 123+ $error = wfMsg( 'ur-add-error-message-pending-friend-request', $this->user_name_to );
124124 } else {
125 - $error = wfMsg('ur-add-error-message-pending-foe-request', $this->user_name_to);
 125+ $error = wfMsg( 'ur-add-error-message-pending-foe-request', $this->user_name_to );
126126 }
127127
128 - $avatar = new wAvatar($this->user_id_to, 'l');
129 - $avatar_img = '<img src="'.$wgUploadPath.'/avatars/' . $avatar->getAvatarImage() . '" alt="" border="0" />';
 128+ $avatar = new wAvatar( $this->user_id_to, 'l' );
 129+ $avatar_img = '<img src="' . $wgUploadPath . '/avatars/' . $avatar->getAvatarImage() . '" alt="" border="0" />';
130130
131131 $out = '';
132 - $out .= $wgOut->setPagetitle( wfMsg('ur-add-error-message-pending-request-title') );
 132+ $out .= $wgOut->setPageTitle( wfMsg( 'ur-add-error-message-pending-request-title' ) );
133133 $out .= "<div class=\"relationship-action\">
134134 {$avatar_img}
135 - ".$error."
 135+ " . $error . "
136136 <div class=\"relationship-buttons\">
137 - <input type=\"button\" class=\"site-button\" value=\"".wfMsg('ur-main-page')."\" size=\"20\" onclick=\"window.location='index.php?title=" . wfMsgForContent( 'mainpage' ) . "'\"/>
138 - <input type=\"button\" class=\"site-button\" value=\"".wfMsg('ur-your-profile')."\" size=\"20\" onclick=\"window.location='".$wgUser->getUserPage()->escapeFullURL() . "'\"/>
 137+ <input type=\"button\" class=\"site-button\" value=\"" . wfMsg( 'ur-main-page' ) . "\" size=\"20\" onclick=\"window.location='index.php?title=" . wfMsgForContent( 'mainpage' ) . "'\"/>
 138+ <input type=\"button\" class=\"site-button\" value=\"" . wfMsg( 'ur-your-profile' ) . "\" size=\"20\" onclick=\"window.location='" . $wgUser->getUserPage()->escapeFullURL() . "'\"/>
139139 </div>
140140 <div class=\"cleared\"></div>
141141 </div>";
142142
143 - $wgOut->addHTML($out);
 143+ $wgOut->addHTML( $out );
144144 } else if( UserRelationship::userHasRequestByID( $wgUser->getID(), $this->user_id_to ) == true ) {
145145 $relationship_request = SpecialPage::getTitleFor( 'ViewRelationshipRequests' );
146146 $wgOut->redirect( $relationship_request->getFullURL() );
147147 } else if( $wgUser->getID() == 0 ){
148 - $login_link = SpecialPage::getTitleFor( 'UserLogin' );
 148+ $login_link = SpecialPage::getTitleFor( 'Userlogin' );
149149
150 - if( $this->relationship_type == 1) {
151 - $error = wfMsg('ur-add-error-message-not-loggedin-friend');
 150+ if( $this->relationship_type == 1 ) {
 151+ $error = wfMsg( 'ur-add-error-message-not-loggedin-friend' );
152152 } else {
153 - $error = wfMsg('ur-add-error-message-not-loggedin-foe');
 153+ $error = wfMsg( 'ur-add-error-message-not-loggedin-foe' );
154154 }
155155
156156 $out = '';
157 - $out .= $wgOut->setPagetitle( wfMsg('ur-error-title') );
 157+ $out .= $wgOut->setPageTitle( wfMsg( 'ur-error-title' ) );
158158 $out .= '<div class="relationship-error-message">
159 - '.$error.'
 159+ ' . $error . '
160160 </div>
161161 <div>
162 - <input type="button" class="site-button" value="'.wfMsg('ur-main-page').'" size="20" onclick=\'window.location="index.php?title="' . wfMsgForContent( 'mainpage' ) . '"\' />
163 - <input type="button" class="site-button" value="'.wfMsg('ur-login').'" size="20" onclick="window.location="'.$login_link->escapeFullURL() . '""/>';
 162+ <input type="button" class="site-button" value="' . wfMsg( 'ur-main-page' ) . '" size="20" onclick=\'window.location="index.php?title="' . wfMsgForContent( 'mainpage' ) . '"\' />
 163+ <input type="button" class="site-button" value="' . wfMsg( 'ur-login' ) . '" size="20" onclick="window.location=\'' . $login_link->escapeFullURL() . '\'" />';
164164 $out .= '</div>';
165165
166 - $wgOut->addHTML($out);
 166+ $wgOut->addHTML( $out );
167167 } else {
168168 $rel = new UserRelationship( $wgUser->getName() );
169169
170170 if( $wgRequest->wasPosted() && $_SESSION['alreadysubmitted'] == false ) {
171171 $_SESSION['alreadysubmitted'] = true;
172 - $rel = $rel->addRelationshipRequest( $this->user_name_to, $this->relationship_type, $wgRequest->getVal('message') );
 172+ $rel = $rel->addRelationshipRequest( $this->user_name_to, $this->relationship_type, $wgRequest->getVal( 'message' ) );
173173
174 - $avatar = new wAvatar($this->user_id_to, 'l');
175 - $avatar_img = '<img src="'.$wgUploadPath.'/avatars/' . $avatar->getAvatarImage() . '" alt="" border="0" />';
 174+ $avatar = new wAvatar( $this->user_id_to, 'l' );
 175+ $avatar_img = '<img src="' . $wgUploadPath . '/avatars/' . $avatar->getAvatarImage() . '" alt="" border="0" />';
176176
177177 $out = '';
178178
179179 if( $this->relationship_type == 1 ){
180 - $out .= $wgOut->setPagetitle( wfMsg('ur-add-sent-title-friend', $this->user_name_to) );
181 - $sent = wfMsg('ur-add-sent-message-friend', $this->user_name_to);
 180+ $out .= $wgOut->setPageTitle( wfMsg( 'ur-add-sent-title-friend', $this->user_name_to ) );
 181+ $sent = wfMsg( 'ur-add-sent-message-friend', $this->user_name_to );
182182 } else {
183 - $out .= $wgOut->setPagetitle( wfMsg('ur-add-sent-title-foe', $this->user_name_to) );
184 - $sent = wfMsg('ur-add-sent-message-foe', $this->user_name_to);
 183+ $out .= $wgOut->setPageTitle( wfMsg( 'ur-add-sent-title-foe', $this->user_name_to ) );
 184+ $sent = wfMsg( 'ur-add-sent-message-foe', $this->user_name_to );
185185 }
186186
187187 $out .= "<div class=\"relationship-action\">
188188 {$avatar_img}
189 - ".$sent."
 189+ " . $sent . "
190190 <div class=\"relationship-buttons\">
191 - <input type=\"button\" class=\"site-button\" value=\"".wfMsg('ur-main-page')."\" size=\"20\" onclick=\"window.location='index.php?title=" . wfMsgForContent( 'mainpage' ) . "'\"/>
192 - <input type=\"button\" class=\"site-button\" value=\"".wfMsg('ur-your-profile')."\" size=\"20\" onclick=\"window.location='".$wgUser->getUserPage()->escapeFullURL() . "'\"/>
 191+ <input type=\"button\" class=\"site-button\" value=\"" . wfMsg( 'ur-main-page' ) . "\" size=\"20\" onclick=\"window.location='index.php?title=" . wfMsgForContent( 'mainpage' ) . "'\"/>
 192+ <input type=\"button\" class=\"site-button\" value=\"" . wfMsg( 'ur-your-profile' ) . "\" size=\"20\" onclick=\"window.location='" . $wgUser->getUserPage()->escapeFullURL() . "'\"/>
193193 </div>
194194 <div class=\"cleared\"></div>
195195 </div>";
196196
197 - $wgOut->addHTML($out);
 197+ $wgOut->addHTML( $out );
198198 } else {
199199 $_SESSION['alreadysubmitted'] = false;
200200 $wgOut->addHTML( $this->displayForm() );
@@ -201,42 +201,46 @@
202202 }
203203 }
204204
 205+ /**
 206+ * Displays the form for adding a friend or a foe
 207+ * @return $form Mixed: HTML code for the form
 208+ */
205209 function displayForm() {
206 - global $wgOut, $wgUser, $wgUploadPath;
 210+ global $wgOut, $wgUploadPath;
207211 wfLoadExtensionMessages( 'SocialProfileUserRelationship' );
208212
209213 $form = '';
210214
211215 if( $this->relationship_type == 1 ) {
212 - $form .= $wgOut->setPagetitle( wfMsg('ur-add-title-friend', $this->user_name_to) );
213 - $add = wfMsg('ur-add-message-friend', $this->user_name_to);
214 - $button = wfMsg('ur-add-button-friend');
 216+ $form .= $wgOut->setPageTitle( wfMsg( 'ur-add-title-friend', $this->user_name_to ) );
 217+ $add = wfMsg( 'ur-add-message-friend', $this->user_name_to );
 218+ $button = wfMsg( 'ur-add-button-friend' );
215219 } else {
216 - $form .= $wgOut->setPagetitle( wfMsg('ur-add-title-foe', $this->user_name_to) );
217 - $add = wfMsg('ur-add-message-foe', $this->user_name_to);
218 - $button = wfMsg('ur-add-button-foe');
 220+ $form .= $wgOut->setPageTitle( wfMsg( 'ur-add-title-foe', $this->user_name_to ) );
 221+ $add = wfMsg( 'ur-add-message-foe', $this->user_name_to );
 222+ $button = wfMsg( 'ur-add-button-foe' );
219223 }
220224
221 - $avatar = new wAvatar($this->user_id_to, 'l');
222 - $avatar_img = '<img src="'.$wgUploadPath.'/avatars/' . $avatar->getAvatarImage() . '" alt="" border="0" />';
 225+ $avatar = new wAvatar( $this->user_id_to, 'l' );
 226+ $avatar_img = '<img src="' . $wgUploadPath . '/avatars/' . $avatar->getAvatarImage() . '" alt="" border="0" />';
223227
224228 $user_link = Title::makeTitle( NS_USER, $this->user_name_to );
225229
226230 $form .= "<form action=\"\" method=\"post\" enctype=\"multipart/form-data\" name=\"form1\">
227231 <div class=\"relationship-action\">
228232 {$avatar_img}
229 - ".$add."
230 - <div class=\"cleared\"></div>
 233+ " . $add . '
 234+ <div class="cleared"></div>
231235 </div>
232 - <div class=\"relationship-textbox-title\">
233 - ".wfMsg('ur-add-personal-message')."
 236+ <div class="relationship-textbox-title">
 237+ ' . wfMsg( 'ur-add-personal-message' ) . '
234238 </div>
235 - <textarea name=\"message\" id=\"message\" rows=\"3\" cols=\"50\"></textarea>
236 - <div class=\"relationship-buttons\">
237 - <input type=\"button\" class=\"site-button\" value=\"".$button."\" size=\"20\" onclick=\"document.form1.submit()\" />
238 - <input type=\"button\" class=\"site-button\" value=\"".wfMsg('ur-cancel')."\" size=\"20\" onclick=\"history.go(-1)\" />
 239+ <textarea name="message" id="message" rows="3" cols="50"></textarea>
 240+ <div class="relationship-buttons">
 241+ <input type="button" class="site-button" value="' . $button . '" size="20" onclick="document.form1.submit()" />
 242+ <input type="button" class="site-button" value="' . wfMsg( 'ur-cancel' ) . '" size="20" onclick="history.go(-1)" />
239243 </div>
240 - </form>";
 244+ </form>';
241245 return $form;
242246 }
243247 }
\ No newline at end of file
Index: trunk/extensions/SocialProfile/UserRelationship/Relationship_AjaxFunctions.php
@@ -5,39 +5,39 @@
66
77 $wgAjaxExportList[] = 'wfRelationshipRequestResponse';
88 function wfRelationshipRequestResponse( $response, $request_id ){
9 - global $wgUser, $wgOut;
 9+ global $wgUser;
1010 $out = '';
1111
1212 wfLoadExtensionMessages( 'SocialProfileUserRelationship' );
1313
1414 $rel = new UserRelationship( $wgUser->getName() );
15 - if( $rel->verifyRelationshipRequest($request_id) == true ){
16 - $request = $rel->getRequest($request_id);
 15+ if( $rel->verifyRelationshipRequest( $request_id ) == true ){
 16+ $request = $rel->getRequest( $request_id );
1717 $user_name_from = $request[0]['user_name_from'];
18 - $user_id_from = User::idFromName($user_name_from);
19 - $rel_type = strtolower($request[0]['type']);
 18+ $user_id_from = User::idFromName( $user_name_from );
 19+ $rel_type = strtolower( $request[0]['type'] );
2020
21 - // FIXME: Notice: Undefined index: response
22 - $rel->updateRelationshipRequestStatus($request_id, $_POST['response']);
 21+ $response = ( isset( $_POST['response' ] ) ) ? $_POST['response'] : $response;
 22+ $rel->updateRelationshipRequestStatus( $request_id, $response );
2323
24 - $avatar = new wAvatar($user_id_from, 'l');
 24+ $avatar = new wAvatar( $user_id_from, 'l' );
2525 $avatar_img = $avatar->getAvatarURL();
2626
2727 if( $response == 1 ){
28 - $rel->addRelationship($request_id);
 28+ $rel->addRelationship( $request_id );
2929 $out.= "<div class=\"relationship-action red-text\">
3030 {$avatar_img}
31 - ".wfMsg("ur-requests-added-message-{$rel_type}", $user_name_from)."
32 - <div class=\"cleared\"></div>
33 - </div>";
 31+ " . wfMsg( "ur-requests-added-message-{$rel_type}", $user_name_from ) . '
 32+ <div class="cleared"></div>
 33+ </div>';
3434 } else {
3535 $out.= "<div class=\"relationship-action red-text\">
3636 {$avatar_img}
37 - ".wfMsg("ur-requests-reject-message-{$rel_type}", $user_name_from)."
38 - <div class=\"cleared\"></div>
39 - </div>";
 37+ " . wfMsg( "ur-requests-reject-message-{$rel_type}", $user_name_from ) . '
 38+ <div class="cleared"></div>
 39+ </div>';
4040 }
41 - $rel->deleteRequest($request_id);
 41+ $rel->deleteRequest( $request_id );
4242 }
4343 return $out;
4444 }
\ No newline at end of file
Index: trunk/extensions/SocialProfile/UserRelationship/UserRelationship.i18n.php
@@ -1646,7 +1646,7 @@
16471647 );
16481648
16491649 /** Finnish (Suomi)
1650 - * @author Jack Phoenix
 1650+ * @author Jack Phoenix <jack@countervandalism.net>
16511651 */
16521652 $messages['fi'] = array(
16531653 'viewrelationships' => 'Ystävä- ja vihollislista',
Index: trunk/extensions/SocialProfile/UserRelationship/SpecialRemoveRelationship.php
@@ -31,83 +31,83 @@
3232 wfLoadExtensionMessages( 'SocialProfileUserRelationship' );
3333 $this->setHeaders();
3434
35 - $wgOut->addStyle( '../..' . $wgUserRelationshipScripts . '/UserRelationship.css' );
 35+ $wgOut->addExtensionStyle( $wgUserRelationshipScripts . '/UserRelationship.css' );
3636
37 - $usertitle = Title::newFromDBkey( $wgRequest->getVal('user') );
 37+ $usertitle = Title::newFromDBkey( $wgRequest->getVal( 'user' ) );
3838 if( !$usertitle ){
3939 $wgOut->addWikiText( wfMsgNoTrans( 'ur-add-no-user' ) );
4040 return false;
4141 }
4242
4343 $this->user_name_to = $usertitle->getText();
44 - $this->user_id_to = User::idFromName($this->user_name_to);
 44+ $this->user_id_to = User::idFromName( $this->user_name_to );
4545 $this->relationship_type = UserRelationship::getUserRelationshipByID( $this->user_id_to, $wgUser->getID() );
4646
4747 if( $this->relationship_type == 1 ){
48 - $confirmtitle = wfMsg('ur-remove-relationship-title-confirm-friend', $this->user_name_to);
49 - $confirmmsg = wfMsg('ur-remove-relationship-message-confirm-friend', $this->user_name_to);
50 - $error = wfMsg('ur-remove-error-not-loggedin-friend');
51 - $pending = wfMsg('ur-remove-error-message-pending-friend-request', $this->user_name_to);
 48+ $confirmtitle = wfMsg( 'ur-remove-relationship-title-confirm-friend', $this->user_name_to );
 49+ $confirmmsg = wfMsg( 'ur-remove-relationship-message-confirm-friend', $this->user_name_to );
 50+ $error = wfMsg( 'ur-remove-error-not-loggedin-friend' );
 51+ $pending = wfMsg( 'ur-remove-error-message-pending-friend-request', $this->user_name_to );
5252 } else {
53 - $confirmtitle = wfMsg('ur-remove-relationship-title-confirm-foe', $this->user_name_to);
54 - $confirmmsg = wfMsg('ur-remove-relationship-message-confirm-foe', $this->user_name_to);
55 - $error = wfMsg('ur-remove-error-not-loggedin-foe');
56 - $pending = wfMsg('ur-remove-error-message-pending-foe-request', $this->user_name_to);
 53+ $confirmtitle = wfMsg( 'ur-remove-relationship-title-confirm-foe', $this->user_name_to );
 54+ $confirmmsg = wfMsg( 'ur-remove-relationship-message-confirm-foe', $this->user_name_to );
 55+ $error = wfMsg( 'ur-remove-error-not-loggedin-foe' );
 56+ $pending = wfMsg( 'ur-remove-error-message-pending-foe-request', $this->user_name_to );
5757 }
5858
59 - if( $wgUser->getID()== $this->user_id_to ){
60 - $out .= $wgOut->setPagetitle( wfMsg('ur-error-title') );
 59+ if( $wgUser->getID() == $this->user_id_to ){
 60+ $out .= $wgOut->setPageTitle( wfMsg( 'ur-error-title' ) );
6161 $out .= '<div class="relationship-error-message">
62 - '.wfMsg('ur-remove-error-message-remove-yourself').'
 62+ ' . wfMsg( 'ur-remove-error-message-remove-yourself' ) . '
6363 </div>
6464 <div>
65 - <input type="button" class="site-button" value="'.wfMsg('ur-main-page').'" size="20" onclick=\'window.location="index.php?title=' . wfMsgForContent( 'mainpage' ) . '"\' />';
 65+ <input type="button" class="site-button" value="' . wfMsg( 'ur-main-page' ) . '" size="20" onclick=\'window.location="index.php?title=' . wfMsgForContent( 'mainpage' ) . '"\' />';
6666 if( $wgUser->isLoggedIn() ){
67 - $out.= '<input type="button" class="site-button" value="'.wfMsg('ur-your-profile').'" size="20" onclick=\'window.location="'. $wgUser->getUserPage()->escapeFullURL() . '"\' />';
 67+ $out.= '<input type="button" class="site-button" value="' . wfMsg( 'ur-your-profile' ) . '" size="20" onclick=\'window.location="'. $wgUser->getUserPage()->escapeFullURL() . '"\' />';
6868 }
6969 $out .= '</div>';
7070
71 - $wgOut->addHTML($out);
 71+ $wgOut->addHTML( $out );
7272 } else if( $this->relationship_type == false ) {
7373
74 - $out .= $wgOut->setPagetitle( wfMsg('ur-error-title') );
 74+ $out .= $wgOut->setPageTitle( wfMsg( 'ur-error-title' ) );
7575 $out .= '<div class="relationship-error-message">
76 - '.wfMsg('ur-remove-error-message-no-relationship', $this->user_name_to).'
 76+ ' . wfMsg( 'ur-remove-error-message-no-relationship', $this->user_name_to ) . '
7777 </div>
7878 <div>
79 - <input type="button" class="site-button" value="'.wfMsg('ur-main-page').'" size="20" onclick=\'window.location="index.php?title="' . wfMsgForContent( 'mainpage' ) . '"\' />';
 79+ <input type="button" class="site-button" value="' . wfMsg( 'ur-main-page' ) . '" size="20" onclick=\'window.location="index.php?title="' . wfMsgForContent( 'mainpage' ) . '"\' />';
8080 if( $wgUser->isLoggedIn() ){
81 - $out.= '<input type="button" class="site-button" value="'.wfMsg('ur-your-profile').'" size="20" onclick=\'window.location="'. $wgUser->getUserPage()->escapeFullURL() . '"\' />';
 81+ $out.= '<input type="button" class="site-button" value="' . wfMsg( 'ur-your-profile' ) . '" size="20" onclick=\'window.location="'. $wgUser->getUserPage()->escapeFullURL() . '"\' />';
8282 }
8383 $out .= '</div>';
8484
85 - $wgOut->addHTML($out);
 85+ $wgOut->addHTML( $out );
8686 } else if( UserRelationship::userHasRequestByID( $this->user_id_to, $wgUser->getID() ) == true ) {
87 - $out .= $wgOut->setPagetitle( wfMsg('ur-error-title') );
 87+ $out .= $wgOut->setPageTitle( wfMsg( 'ur-error-title' ) );
8888 $out .= '<div class="relationship-error-message">
89 - '.$pending.'
 89+ ' . $pending . '
9090 </div>
9191 <div>
92 - <input type="button" class="site-button" value="'.wfMsg('ur-main-page').'" size="20" onclick=\'window.location="index.php?title="' . wfMsgForContent( 'mainpage' ) . '"\' />';
 92+ <input type="button" class="site-button" value="' . wfMsg( 'ur-main-page' ) . '" size="20" onclick=\'window.location="index.php?title="' . wfMsgForContent( 'mainpage' ) . '"\' />';
9393 if( $wgUser->isLoggedIn() ){
94 - $out.= '<input type="button" class="site-button" value="'.wfMsg('ur-your-profile').'" size="20" onclick=\'window.location="'. $wgUser->getUserPage()->escapeFullURL() . '"\' />';
 94+ $out.= '<input type="button" class="site-button" value="' . wfMsg( 'ur-your-profile' ) . '" size="20" onclick=\'window.location="'. $wgUser->getUserPage()->escapeFullURL() . '"\' />';
9595 }
9696 $out .= '</div>';
9797
98 - $wgOut->addHTML($out);
 98+ $wgOut->addHTML( $out );
9999 } else if( $wgUser->getID() == 0 ) {
100 - $out .= $wgOut->setPagetitle( wfMsg('ur-error-title') );
 100+ $out .= $wgOut->setPageTitle( wfMsg( 'ur-error-title' ) );
101101 $out .= '<div class="relationship-error-message">
102 - '.$error.'
 102+ ' . $error . '
103103 </div>
104104 <div>
105 - <input type="button" class="site-button" value="'.wfMsg('ur-main-page').'" size="20" onclick=\'window.location="index.php?title="' . wfMsgForContent( 'mainpage' ) . '"\' />';
 105+ <input type="button" class="site-button" value="' . wfMsg( 'ur-main-page' ) . '" size="20" onclick=\'window.location="index.php?title="' . wfMsgForContent( 'mainpage' ) . '"\' />';
106106 if( $wgUser->isLoggedIn() ){
107 - $out.= '<input type="button" class="site-button" value="'.wfMsg('ur-your-profile').'" size="20" onclick=\'window.location="'. $wgUser->getUserPage()->escapeFullURL() . '"\' />';
 107+ $out.= '<input type="button" class="site-button" value="' . wfMsg( 'ur-your-profile' ) . '" size="20" onclick=\'window.location="'. $wgUser->getUserPage()->escapeFullURL() . '"\' />';
108108 }
109109 $out .= '</div>';
110110
111 - $wgOut->addHTML($out);
 111+ $wgOut->addHTML( $out );
112112 } else {
113113 $rel = new UserRelationship( $wgUser->getName() );
114114 if( $wgRequest->wasPosted() && $_SESSION['alreadysubmitted'] == false ){
@@ -115,21 +115,21 @@
116116 $_SESSION['alreadysubmitted'] = true;
117117 $rel->removeRelationshipByUserID( $this->user_id_to, $wgUser->getID() );
118118 $rel->sendRelationshipRemoveEmail( $this->user_id_to, $wgUser->getName(), $this->relationship_type );
119 - $avatar = new wAvatar($this->user_id_to, 'l');
120 - $avatar_img = '<img src="'.$wgUploadPath.'/avatars/' . $avatar->getAvatarImage() . '" alt="" border="" />';
 119+ $avatar = new wAvatar( $this->user_id_to, 'l' );
 120+ $avatar_img = '<img src="' . $wgUploadPath . '/avatars/' . $avatar->getAvatarImage() . '" alt="" border="" />';
121121
122122 $out .= $wgOut->setPagetitle( $confirmtitle );
123123 $out .= "<div class=\"relationship-action\">
124124 {$avatar_img}
125 - ".$confirmmsg."
 125+ " . $confirmmsg . "
126126 <div class=\"relationship-buttons\">
127 - <input type=\"button\" class=\"site-button\" value=\"".wfMsg('ur-main-page')."\" size=\"20\" onclick=\"window.location='index.php?title=" . wfMsgForContent( 'mainpage' ) . "'\"/>
128 - <input type=\"button\" class=\"site-button\" value=\"".wfMsg('ur-your-profile')."\" size=\"20\" onclick=\"window.location='".$wgUser->getUserPage()->escapeFullURL() . "'\"/>
 127+ <input type=\"button\" class=\"site-button\" value=\"" . wfMsg( 'ur-main-page' ) . "\" size=\"20\" onclick=\"window.location='index.php?title=" . wfMsgForContent( 'mainpage' ) . "'\"/>
 128+ <input type=\"button\" class=\"site-button\" value=\"" . wfMsg( 'ur-your-profile' ) . "\" size=\"20\" onclick=\"window.location='" . $wgUser->getUserPage()->escapeFullURL() . "'\"/>
129129 </div>
130130 <div class=\"cleared\"></div>
131131 </div>";
132132
133 - $wgOut->addHTML($out);
 133+ $wgOut->addHTML( $out );
134134 } else {
135135 $_SESSION['alreadysubmitted'] = false;
136136 $wgOut->addHTML( $this->displayForm() );
@@ -138,35 +138,39 @@
139139 }
140140 }
141141
 142+ /**
 143+ * Displays the form for removing a friend or a foe
 144+ * @return $form Mixed: HTML code for the form
 145+ */
142146 function displayForm() {
143147 global $wgOut, $wgUploadPath;
144148 wfLoadExtensionMessages( 'SocialProfileUserRelationship' );
145149
146150 $form = '';
147 - $avatar = new wAvatar($this->user_id_to, 'l');
148 - $avatar_img = '<img src="'.$wgUploadPath.'/avatars/'. $avatar->getAvatarImage() . '" alt="avatar" />';
 151+ $avatar = new wAvatar( $this->user_id_to, 'l' );
 152+ $avatar_img = '<img src="' . $wgUploadPath . '/avatars/' . $avatar->getAvatarImage() . '" alt="avatar" />';
149153
150154 if( $this->relationship_type == 1 ) {
151 - $title = wfMsg('ur-remove-relationship-title-friend', $this->user_name_to);
152 - $remove = wfMsg( 'ur-remove-relationship-message-friend', $this->user_name_to, wfMsg('ur-remove') );
 155+ $title = wfMsg( 'ur-remove-relationship-title-friend', $this->user_name_to );
 156+ $remove = wfMsg( 'ur-remove-relationship-message-friend', $this->user_name_to, wfMsg( 'ur-remove' ) );
153157 } else {
154 - $title = wfMsg('ur-remove-relationship-title-foe', $this->user_name_to);
155 - $remove = wfMsg( 'ur-remove-relationship-message-foe', $this->user_name_to, wfMsg('ur-remove') );
 158+ $title = wfMsg( 'ur-remove-relationship-title-foe', $this->user_name_to );
 159+ $remove = wfMsg( 'ur-remove-relationship-message-foe', $this->user_name_to, wfMsg( 'ur-remove' ) );
156160 }
157 - $form .= $wgOut->setPagetitle( $title );
 161+ $form .= $wgOut->setPageTitle( $title );
158162 $form .= "<form action=\"\" method=\"post\" enctype=\"multipart/form-data\" name=\"form1\">
159163 <div class=\"relationship-action\">
160164 {$avatar_img}
161 - ".$remove."
162 - <div class=\"relationship-buttons\">
163 - <input type=\"hidden\" name=\"user\" value=\"".addslashes($this->user_name_to)."\">
164 - <input type=\"button\" class=\"site-button\" value=\"".wfMsg('ur-remove')."\" size=\"20\" onclick=\"document.form1.submit()\" />
165 - <input type=\"button\" class=\"site-button\" value=\"".wfMsg('ur-cancel')."\" size=\"20\" onclick=\"history.go(-1)\" />
 165+ " . $remove . '
 166+ <div class="relationship-buttons">
 167+ <input type="hidden" name="user" value="' . addslashes( $this->user_name_to ) . '" />
 168+ <input type="button" class="site-button" value="' . wfMsg( 'ur-remove' ) . '" size="20" onclick="document.form1.submit()" />
 169+ <input type="button" class="site-button" value="' . wfMsg( 'ur-cancel' ) . '" size="20" onclick="history.go(-1)" />
166170 </div>
167 - <div class=\"cleared\"></div>
 171+ <div class="cleared"></div>
168172 </div>
169173
170 - </form>";
 174+ </form>';
171175 return $form;
172176 }
173177 }
\ No newline at end of file
Index: trunk/extensions/SocialProfile/UserRelationship/SpecialViewRelationships.php
@@ -30,33 +30,33 @@
3131
3232 wfLoadExtensionMessages( 'SocialProfileUserRelationship' );
3333
34 - $wgOut->addStyle( '../..' . $wgUserRelationshipScripts . '/UserRelationship.css' );
 34+ $wgOut->addExtensionStyle( $wgUserRelationshipScripts . '/UserRelationship.css' );
3535
3636 $output = '';
3737
3838 /**
3939 * Get querystring variables
4040 */
41 - $user_name = $wgRequest->getVal('user');
42 - $rel_type = $wgRequest->getVal('rel_type');
43 - $page = $wgRequest->getVal('page');
 41+ $user_name = $wgRequest->getVal( 'user' );
 42+ $rel_type = $wgRequest->getVal( 'rel_type' );
 43+ $page = $wgRequest->getVal( 'page' );
4444
4545 /**
4646 * Redirect Non-logged in users to Login Page
4747 * It will automatically return them to the ViewRelationships page
4848 */
4949 if( $wgUser->getID() == 0 && $user_name == '' ){
50 - $wgOut->setPageTitle( wfMsg('ur-error-page-title') );
51 - $login = SpecialPage::getTitleFor( 'UserLogin' );
52 - $wgOut->redirect( $login->escapeFullURL('returnto=Special:ViewRelationships') );
 50+ $wgOut->setPageTitle( wfMsg( 'ur-error-page-title' ) );
 51+ $login = SpecialPage::getTitleFor( 'Userlogin' );
 52+ $wgOut->redirect( $login->escapeFullURL( 'returnto=Special:ViewRelationships' ) );
5353 return false;
5454 }
5555
5656 /**
5757 * Set up config for page / default values
5858 */
59 - if(!$page || !is_numeric($page) ) $page = 1;
60 - if(!$rel_type || !is_numeric($rel_type) ) $rel_type = 1;
 59+ if( !$page || !is_numeric( $page ) ) $page = 1;
 60+ if( !$rel_type || !is_numeric( $rel_type ) ) $rel_type = 1;
6161 $per_page = 50;
6262 $per_row = 2;
6363
@@ -64,61 +64,60 @@
6565 * If no user is set in the URL, we assume its the current user
6666 */
6767 if( !$user_name ) $user_name = $wgUser->getName();
68 - $user_id = User::idFromName($user_name);
 68+ $user_id = User::idFromName( $user_name );
6969 $user = Title::makeTitle( NS_USER, $user_name );
7070
7171 /**
7272 * Error message for username that does not exist (from URL)
7373 */
7474 if( $user_id == 0 ){
75 - $wgOut->setPageTitle( wfMsg('ur-error-title') );
 75+ $wgOut->setPageTitle( wfMsg( 'ur-error-title' ) );
7676 $out .= '<div class="relationship-error-message">
77 - '.wfMsg('ur-error-message-no-user').'
 77+ ' . wfMsg( 'ur-error-message-no-user' ) . '
7878 </div>
7979 <div class="relationship-request-buttons">
80 - <input type="button" class="site-button" value="'.wfMsg('ur-main-page').'" onclick=\'window.location="index.php?title=' . wfMsgForContent( 'mainpage' ) . '"\' />';
 80+ <input type="button" class="site-button" value="' . wfMsg( 'ur-main-page' ) . '" onclick=\'window.location="index.php?title=' . wfMsgForContent( 'mainpage' ) . '"\' />';
8181 if( $wgUser->isLoggedIn() ){
82 - $out .= '<input type="button" class="site-button" value="'.wfMsg('ur-your-profile').'" onclick=\'window.location="'. $wgUser->getUserPage()->escapeFullURL() . '"\' />';
 82+ $out .= '<input type="button" class="site-button" value="' . wfMsg( 'ur-your-profile' ) . '" onclick=\'window.location="'. $wgUser->getUserPage()->escapeFullURL() . '"\' />';
8383 }
8484 $out .= '</div>';
85 - $wgOut->addHTML($out);
 85+ $wgOut->addHTML( $out );
8686 return false;
8787 }
8888
8989 /**
9090 * Get all relationships
9191 */
92 - $rel = new UserRelationship($user_name);
93 - $relationships = $rel->getRelationshipList($rel_type, $per_page, $page);
 92+ $rel = new UserRelationship( $user_name );
 93+ $relationships = $rel->getRelationshipList( $rel_type, $per_page, $page );
9494
95 - $stats = new UserStats($rel->user_id, $rel->user_name);
 95+ $stats = new UserStats( $rel->user_id, $rel->user_name );
9696 $stats_data = $stats->getUserStats();
9797 $friend_count = $stats_data['friend_count'];
9898 $foe_count = $stats_data['foe_count'];
9999
100100 $back_link = Title::makeTitle( NS_USER, $rel->user_name );
101 - $invite_contacts_link = Title::makeTitle( NS_SPECIAL, 'InviteContacts' );
102 - #$invite_contacts_link = SpecialPage::getTitleFor( 'InviteContacts' );
 101+ $invite_contacts_link = SpecialPage::getTitleFor( 'InviteContacts' );
103102
104103 if( $rel_type == 1 ) {
105104 $output .= $wgOut->setPageTitle( wfMsg( 'ur-title-friend', $rel->user_name ) );
106105 $total = $friend_count;
107106 $rem = wfMsg( 'ur-remove-relationship-friend' );
108107 $output .= '<div class="back-links">
109 - <a href="'.$back_link->escapeFullURL().'">'.wfMsg( 'ur-backlink', $rel->user_name ).'</a>
 108+ <a href="' . $back_link->escapeFullURL() . '">' . wfMsg( 'ur-backlink', $rel->user_name ) . '</a>
110109 </div>
111 - <div class="relationship-count">'.
112 - wfMsgExt( 'ur-relationship-count-friends', 'parsemag', $rel->user_name, $total, $invite_contacts_link->escapeFullURL() ).
 110+ <div class="relationship-count">'
 111+ . wfMsgExt( 'ur-relationship-count-friends', 'parsemag', $rel->user_name, $total, $invite_contacts_link->escapeFullURL() ) .
113112 '</div>';
114113 } else {
115114 $output .= $wgOut->setPageTitle( wfMsg( 'ur-title-foe', $rel->user_name ) );
116115 $total = $foe_count;
117116 $rem = wfMsg( 'ur-remove-relationship-foe' );
118117 $output .= '<div class="back-links">
119 - <a href="'.$back_link->escapeFullURL().'">'.wfMsg( 'ur-backlink', $rel->user_name ).'</a>
 118+ <a href="' . $back_link->escapeFullURL() . '">' . wfMsg( 'ur-backlink', $rel->user_name ) . '</a>
120119 </div>
121 - <div class="relationship-count">'.
122 - wfMsgExt( 'ur-relationship-count-foes', 'parsemag', $rel->user_name, $total, $invite_contacts_link->escapeFullURL() ).
 120+ <div class="relationship-count">'
 121+ . wfMsgExt( 'ur-relationship-count-foes', 'parsemag', $rel->user_name, $total, $invite_contacts_link->escapeFullURL() ) .
123122 '</div>';
124123 }
125124
@@ -145,8 +144,8 @@
146145 $username_length = strlen( $relationship['user_name'] );
147146 $username_space = stripos( $relationship['user_name'], ' ' );
148147
149 - if( ($username_space == false || $username_space >= "30") && $username_length > 30 ){
150 - $user_name_display = substr($relationship['user_name'], 0, 30)." ".substr($relationship['user_name'], 30, 50);
 148+ if( ( $username_space == false || $username_space >= "30" ) && $username_length > 30 ){
 149+ $user_name_display = substr( $relationship['user_name'], 0, 30 ) . ' ' . substr( $relationship['user_name'], 30, 50 );
151150 } else {
152151 $user_name_display = $relationship['user_name'];
153152 };
@@ -160,22 +159,22 @@
161160 <div class=\"relationship-actions\">";
162161 if( $indivRelationship == false ) {
163162 $output .= $wgLang->pipeList( array(
164 - '<a href="' . $add_relationship_link->escapeFullURL( 'user=' . $user_safe . '&rel_type=1' ) . '">' . wfMsg( 'ur-add-friend' ) . '</a>&nbsp;',
165 - '&nbsp;<a href="' . $add_relationship_link->escapeFullURL( 'user=' . $user_safe . '&rel_type=2' ) . '">' . wfMsg( 'ur-add-foe' ) . '</a>&nbsp;',
 163+ '<a href="' . $add_relationship_link->escapeFullURL( 'user=' . $user_safe . '&rel_type=1' ) . '">' . wfMsg( 'ur-add-friend' ) . '</a>',
 164+ '<a href="' . $add_relationship_link->escapeFullURL( 'user=' . $user_safe . '&rel_type=2' ) . '">' . wfMsg( 'ur-add-foe' ) . '</a>',
166165 ''
167166 ) );
168167 } else if( $user_name == $wgUser->getName() ) {
169 - $output .= '<a href="'.$remove_relationship_link->escapeFullURL( 'user=' . $user_safe ) . '">' . $rem . '</a>&nbsp;';
 168+ $output .= '<a href="' . $remove_relationship_link->escapeFullURL( 'user=' . $user_safe ) . '">' . $rem . '</a>';
170169 $output .= wfMsgExt( 'pipe-separator', 'escapenoentities' );
171170 }
172 - $output .= '&nbsp;<a href="'.$give_gift_link->escapeFullURL( 'user=' . $user_safe ).'">'.wfMsg( 'ur-give-gift' ).'</a>';
 171+ $output .= '<a href="' . $give_gift_link->escapeFullURL( 'user=' . $user_safe ) . '">' . wfMsg( 'ur-give-gift' ) . '</a>';
173172
174173 $output .= '</div>
175174 <div class="cleared"></div>
176175 </div>';
177176
178177 $output .= '</div>';
179 - if( $x == count($relationships) || $x != 1 && $x%$per_row == 0 ) $output .= '<div class="cleared"></div>';
 178+ if( $x == count( $relationships ) || $x != 1 && $x%$per_row == 0 ) $output .= '<div class="cleared"></div>';
180179 $x++;
181180 }
182181 }
@@ -191,23 +190,23 @@
192191 if( $numofpages > 1 ) {
193192 $output .= '<div class="page-nav">';
194193 if( $page > 1 ) {
195 - $output .= "<a href=\"".$page_link->escapeFullURL('user='.$user_name.'&rel_type='.$rel_type.'&page='.($page-1))."\">".wfMsg('ur-previous')."</a> ";
 194+ $output .= '<a href="' . $page_link->escapeFullURL( 'user=' . $user_name . '&rel_type=' . $rel_type . '&page=' . ( $page - 1 ) ) . '">' . wfMsg( 'ur-previous' ) . '</a> ';
196195 }
197196
198 - if( ($total % $per_page) != 0 ) $numofpages++;
 197+ if( ( $total % $per_page ) != 0 ) $numofpages++;
199198 if( $numofpages >=9 && $page < $total ) $numofpages = 9+$page;
200 - if( $numofpages >= ($total / $per_page) ) $numofpages = ($total / $per_page)+1;
 199+ if( $numofpages >= ( $total / $per_page ) ) $numofpages = ($total / $per_page)+1;
201200
202201 for( $i = 1; $i <= $numofpages; $i++ ){
203202 if( $i == $page ) {
204 - $output .= ($i." ");
 203+ $output .= ( $i . ' ' );
205204 } else {
206 - $output .= "<a href=\"".$page_link->escapeFullURL('user='.$user_name.'&rel_type='.$rel_type.'&page='.$i)."\">$i</a> ";
 205+ $output .= '<a href="' . $page_link->escapeFullURL( 'user=' . $user_name . '&rel_type=' . $rel_type . '&page=' . $i ) . "\">$i</a> ";
207206 }
208207 }
209208
210 - if( ($total - ($per_page * $page)) > 0 ){
211 - $output .= " <a href=\"".$page_link->escapeFullURL('user='.$user_name.'&rel_type='.$rel_type.'&page='.($page+1))."\">".wfMsg('ur-next')."</a>";
 209+ if( ( $total - ( $per_page * $page ) ) > 0 ){
 210+ $output .= ' <a href="' . $page_link->escapeFullURL( 'user=' . $user_name . '&rel_type=' . $rel_type . '&page=' . ( $page + 1 ) ) . '">' . wfMsg( 'ur-next' ) . '</a>';
212211 }
213212 $output .= '</div>';
214213 }
@@ -215,6 +214,6 @@
216215 /**
217216 * Build next/prev nav
218217 */
219 - $wgOut->addHTML($output);
 218+ $wgOut->addHTML( $output );
220219 }
221220 }
\ No newline at end of file
Index: trunk/extensions/SocialProfile/UserRelationship/UserRelationship.js
@@ -1,13 +1,12 @@
2 - function requestResponse(response,id){
3 - var url = "index.php?action=ajax";
4 - var pars = 'rs=wfRelationshipRequestResponse&rsargs[]=' + response + '&rsargs[]=' + id
5 - YAHOO.widget.Effects.Hide('request_action_'+id);
6 - var callback = {
7 - success: function( oResponse ) {
8 - $('request_action_'+id).innerHTML = oResponse.responseText;
9 - YAHOO.widget.Effects.Appear('request_action_'+id,{duration:2.0} );
10 - }
11 - };
12 - var request = YAHOO.util.Connect.asyncRequest('POST', url, callback, pars);
13 -
14 - }
 2+/**
 3+ * JavaScript for UserRelationship
 4+ * Used on Special:ViewRelationshipRequests
 5+ */
 6+function requestResponse( response, id ){
 7+ YAHOO.widget.Effects.Hide( 'request_action_' + id );
 8+ sajax_request_type = 'POST';
 9+ sajax_do_call( 'wfRelationshipRequestResponse', [ response, id ], function( request ){
 10+ document.getElementById( 'request_action_' + id ).innerHTML = request.responseText;
 11+ YAHOO.widget.Effects.Appear( 'request_action_' + id, { duration:2.0 } );
 12+ } );
 13+}
\ No newline at end of file
Index: trunk/extensions/SocialProfile/UserRelationship/UserRelationshipClass.php
@@ -13,43 +13,43 @@
1414 * Constructor
1515 * @private
1616 */
17 - /* private */ function __construct($username) {
 17+ /* private */ function __construct( $username ) {
1818 wfLoadExtensionMessages( 'SocialProfileUserRelationship' );
19 - $title1 = Title::newFromDBkey($username);
 19+ $title1 = Title::newFromDBkey( $username );
2020 $this->user_name = $title1->getText();
21 - $this->user_id = User::idFromName($this->user_name);
 21+ $this->user_id = User::idFromName( $this->user_name );
2222 }
2323
2424 public function addRelationshipRequest( $user_to, $type, $message, $email = true ){
25 - $user_id_to = User::idFromName($user_to);
 25+ $user_id_to = User::idFromName( $user_to );
2626 $dbw = wfGetDB( DB_MASTER );
2727
2828 $dbw->insert( 'user_relationship_request',
29 - array(
30 - 'ur_user_id_from' => $this->user_id,
31 - 'ur_user_name_from' => $this->user_name,
32 - 'ur_user_id_to' => $user_id_to,
33 - 'ur_user_name_to' => $user_to,
34 - 'ur_type' => $type,
35 - 'ur_message' => $message,
36 - 'ur_date' => date("Y-m-d H:i:s")
 29+ array(
 30+ 'ur_user_id_from' => $this->user_id,
 31+ 'ur_user_name_from' => $this->user_name,
 32+ 'ur_user_id_to' => $user_id_to,
 33+ 'ur_user_name_to' => $user_to,
 34+ 'ur_type' => $type,
 35+ 'ur_message' => $message,
 36+ 'ur_date' => date("Y-m-d H:i:s")
3737 ), __METHOD__
3838 );
3939 $request_id = $dbw->insertId();
4040
41 - $this->incNewRequestCount($user_id_to, $type);
 41+ $this->incNewRequestCount( $user_id_to, $type );
4242
43 - if( $email ) $this->sendRelationshipRequestEmail($user_id_to, $this->user_name, $type);
 43+ if( $email ) $this->sendRelationshipRequestEmail( $user_id_to, $this->user_name, $type );
4444 return $request_id;
4545 }
4646
4747 public function sendRelationshipRequestEmail( $user_id_to, $user_from, $type ){
48 - $user = User::newFromId($user_id_to);
 48+ $user = User::newFromId( $user_id_to );
4949 $user->loadFromDatabase();
5050 if( $user->getEmail() && $user->getIntOption( 'notifyfriendrequest', 1 ) ){ //if($user->isEmailConfirmed() && $user->getIntOption("notifyfriendrequest",1)){
5151 $request_link = SpecialPage::getTitleFor( 'ViewRelationshipRequests' );
5252 $update_profile_link = SpecialPage::getTitleFor( 'UpdateProfile' );
53 - if( $type == 1){
 53+ if( $type == 1 ){
5454 $subject = wfMsgExt( 'friend_request_subject', 'parsemag',
5555 $user_from
5656 );
@@ -70,12 +70,12 @@
7171 $update_profile_link->getFullURL()
7272 );
7373 }
74 - $user->sendMail($subject, $body);
 74+ $user->sendMail( $subject, $body );
7575 }
7676 }
7777
7878 public function sendRelationshipAcceptEmail( $user_id_to, $user_from, $type ){
79 - $user = User::newFromId($user_id_to);
 79+ $user = User::newFromId( $user_id_to );
8080 $user->loadFromDatabase();
8181 if( $user->getEmail() && $user->getIntOption( 'notifyfriendrequest', 1 ) ){ //if($user->isEmailConfirmed() && $user->getIntOption("notifyfriendrequest",1)){
8282 $user_link = Title::makeTitle( NS_USER, $user_from );
@@ -101,12 +101,12 @@
102102 $update_profile_link->getFullURL()
103103 );
104104 }
105 - $user->sendMail($subject, $body);
 105+ $user->sendMail( $subject, $body );
106106 }
107107 }
108108
109109 public function sendRelationshipRemoveEmail( $user_id_to, $user_from, $type ){
110 - $user = User::newFromId($user_id_to);
 110+ $user = User::newFromId( $user_id_to );
111111 $user->loadFromDatabase();
112112 if( $user->isEmailConfirmed() && $user->getIntOption( 'notifyfriendrequest', 1 ) ){
113113 $user_link = Title::makeTitle( NS_USER, $user_from );
@@ -141,8 +141,9 @@
142142
143143 $dbw = wfGetDB( DB_MASTER );
144144 $s = $dbw->selectRow( 'user_relationship_request',
145 - array( 'ur_user_id_from', 'ur_user_name_from', 'ur_type'),
146 - array( 'ur_id' => $relationship_request_id ), __METHOD__
 145+ array( 'ur_user_id_from', 'ur_user_name_from', 'ur_type' ),
 146+ array( 'ur_id' => $relationship_request_id ),
 147+ __METHOD__
147148 );
148149
149150 if ( $s == true ) {
@@ -150,47 +151,47 @@
151152 $ur_user_name_from = $s->ur_user_name_from;
152153 $ur_type = $s->ur_type;
153154
154 - if( self::getUserRelationshipByID($this->user_id, $ur_user_id_from) > 0 ){
 155+ if( self::getUserRelationshipByID( $this->user_id, $ur_user_id_from ) > 0 ){
155156 return '';
156157 }
157158
158159 $dbw->insert( 'user_relationship',
159 - array(
160 - 'r_user_id' => $this->user_id,
161 - 'r_user_name' => $this->user_name,
162 - 'r_user_id_relation' => $ur_user_id_from,
163 - 'r_user_name_relation' => $ur_user_name_from,
164 - 'r_type' => $ur_type,
165 - 'r_date' => date("Y-m-d H:i:s")
 160+ array(
 161+ 'r_user_id' => $this->user_id,
 162+ 'r_user_name' => $this->user_name,
 163+ 'r_user_id_relation' => $ur_user_id_from,
 164+ 'r_user_name_relation' => $ur_user_name_from,
 165+ 'r_type' => $ur_type,
 166+ 'r_date' => date("Y-m-d H:i:s")
166167 ), __METHOD__
167168 );
168169
169170 $dbw->insert( 'user_relationship',
170 - array(
171 - 'r_user_id' => $ur_user_id_from,
172 - 'r_user_name' => $ur_user_name_from,
173 - 'r_user_id_relation' => $this->user_id,
174 - 'r_user_name_relation' => $this->user_name,
175 - 'r_type' => $ur_type,
176 - 'r_date' => date("Y-m-d H:i:s")
 171+ array(
 172+ 'r_user_id' => $ur_user_id_from,
 173+ 'r_user_name' => $ur_user_name_from,
 174+ 'r_user_id_relation' => $this->user_id,
 175+ 'r_user_name_relation' => $this->user_name,
 176+ 'r_type' => $ur_type,
 177+ 'r_date' => date("Y-m-d H:i:s")
177178 ), __METHOD__
178179 );
179180
180 - $stats = new UserStatsTrack($this->user_id, $this->user_name);
 181+ $stats = new UserStatsTrack( $this->user_id, $this->user_name );
181182 if( $ur_type == 1 ){
182 - $stats->incStatField("friend");
 183+ $stats->incStatField( 'friend' );
183184 } else {
184 - $stats->incStatField("foe");
 185+ $stats->incStatField( 'foe' );
185186 }
186187
187 - $stats = new UserStatsTrack($ur_user_id_from, $ur_user_name_from);
 188+ $stats = new UserStatsTrack( $ur_user_id_from, $ur_user_name_from );
188189 if( $ur_type == 1 ){
189 - $stats->incStatField("friend");
 190+ $stats->incStatField( 'friend' );
190191 } else {
191 - $stats->incStatField("foe");
 192+ $stats->incStatField( 'foe' );
192193 }
193194
194 - if($email)$this->sendRelationshipAcceptEmail($ur_user_id_from, $this->user_name, $ur_type);
 195+ if( $email ) $this->sendRelationshipAcceptEmail( $ur_user_id_from, $this->user_name, $ur_type );
195196
196197 $wgMemc->delete( wfMemcKey( 'relationship', 'profile', "{$this->user_id}-{$ur_type}" ) );
197198 $wgMemc->delete( wfMemcKey( 'relationship', 'profile', "{$ur_user_id_from}-{$ur_type}" ) );
@@ -218,20 +219,20 @@
219220 $wgMemc->delete( wfMemcKey( 'relationship', 'profile', "{$user1}-2" ) );
220221 $wgMemc->delete( wfMemcKey( 'relationship', 'profile', "{$user2}-2" ) );
221222
222 - $stats = new UserStatsTrack($user1, '');
223 - $stats->updateRelationshipCount(1);
224 - $stats->updateRelationshipCount(2);
 223+ $stats = new UserStatsTrack( $user1, '' );
 224+ $stats->updateRelationshipCount( 1 );
 225+ $stats->updateRelationshipCount( 2 );
225226 $stats->clearCache();
226227
227 - $stats = new UserStatsTrack($user2, '');
228 - $stats->updateRelationshipCount(1);
229 - $stats->updateRelationshipCount(2);
 228+ $stats = new UserStatsTrack( $user2, '' );
 229+ $stats->updateRelationshipCount( 1 );
 230+ $stats->updateRelationshipCount( 2 );
230231 $stats->clearCache();
231232 }
232233
233234 public function deleteRequest( $id ){
234 - $request = $this->getRequest($id);
235 - $this->decNewRequestCount($this->user_id, $request[0]['rel_type']);
 235+ $request = $this->getRequest( $id );
 236+ $this->decNewRequestCount( $this->user_id, $request[0]['rel_type'] );
236237
237238 $dbw = wfGetDB( DB_MASTER );
238239 $dbw->delete( 'user_relationship_request', array( 'ur_id' => $id ), __METHOD__ );
@@ -240,11 +241,9 @@
241242 public function updateRelationshipRequestStatus( $relationship_request_id, $status ){
242243 $dbw = wfGetDB( DB_MASTER );
243244 $dbw->update( 'user_relationship_request',
244 - array( /* SET */
245 - 'ur_status' => $status
246 - ), array( /* WHERE */
247 - 'ur_id' => $relationship_request_id
248 - ), ""
 245+ /* SET */array( 'ur_status' => $status ),
 246+ /* WHERE */array( 'ur_id' => $relationship_request_id ),
 247+ __METHOD__
249248 );
250249 }
251250
@@ -280,12 +279,12 @@
281280 }
282281
283282 public function getRequest( $id ){
284 - global $wgDBprefix;
285283 $dbr = wfGetDB( DB_MASTER );
286 - $sql = "SELECT ur_id, ur_user_id_from, ur_user_name_from, ur_type, ur_message, ur_date
287 - FROM ".$wgDBprefix."user_relationship_request
288 - WHERE ur_id = {$id}";
289 - $res = $dbr->query($sql);
 284+ $res = $dbr->select( 'user_relationship_request',
 285+ array( 'ur_id', 'ur_user_id_from', 'ur_user_name_from', 'ur_type', 'ur_message', 'ur_date' ),
 286+ array( "ur_id = {$id}" ),
 287+ __METHOD__
 288+ );
290289 while( $row = $dbr->fetchObject( $res ) ) {
291290 if( $row->ur_type == 1 ){
292291 $type_name = 'Friend';
@@ -358,7 +357,7 @@
359358 $s = $dbr->selectRow( 'user_relationship_request', array( 'count(*) AS count' ), array( 'ur_user_id_to' => $user_id, 'ur_status' => 0, 'ur_type' => $rel_type ), __METHOD__ );
360359 if ( $s !== false ) $request_count = $s->count;
361360
362 - $wgMemc->set($key, $request_count);
 361+ $wgMemc->set( $key, $request_count );
363362
364363 return $request_count;
365364 }
@@ -375,13 +374,13 @@
376375 }
377376
378377 static function getOpenRequestCount( $user_id, $rel_type ){
379 - $data = self::getOpenRequestCountCache($user_id, $rel_type);
 378+ $data = self::getOpenRequestCountCache( $user_id, $rel_type );
380379
381380 if( $data != '' ){
382 - if( $data == -1 )$data = 0;
 381+ if( $data == -1 ) $data = 0;
383382 $count = $data;
384383 } else {
385 - $count = self::getOpenRequestCountDB($user_id, $rel_type);
 384+ $count = self::getOpenRequestCountDB( $user_id, $rel_type );
386385 }
387386 return $count;
388387 }
@@ -443,7 +442,7 @@
444443
445444 static function getRelationshipCountByUsername( $user_name ){
446445 $dbr = wfGetDB( DB_SLAVE );
447 - $user_id = User::idFromName($user_name);
 446+ $user_id = User::idFromName( $user_name );
448447 $sql = "SELECT rs_friend_count, rs_foe_count
449448 FROM {$dbr->tableName( 'user_relationship_stats' )}
450449 WHERE rs_user_id = {$user_id}

Status & tagging log