| Index: trunk/extensions/SocialProfile/UserRelationship/SpecialViewRelationshipRequests.php |
| — | — | @@ -31,7 +31,7 @@ |
| 32 | 32 | * Redirect Non-logged in users to Login Page |
| 33 | 33 | * It will automatically return them to the ViewRelationshipRequests page |
| 34 | 34 | */ |
| 35 | | - if ( $wgUser->getID() == 0 ) { |
| | 35 | + if ( !$wgUser->isLoggedIn() ) { |
| 36 | 36 | $wgOut->setPageTitle( wfMsg( 'ur-error-page-title' ) ); |
| 37 | 37 | $login = SpecialPage::getTitleFor( 'Userlogin' ); |
| 38 | 38 | $wgOut->redirect( |
| — | — | @@ -47,7 +47,7 @@ |
| 48 | 48 | $friend_request_count = $rel->getOpenRequestCount( $wgUser->getID(), 1 ); |
| 49 | 49 | $foe_request_count = $rel->getOpenRequestCount( $wgUser->getID(), 2 ); |
| 50 | 50 | |
| 51 | | - if ( count( $_POST ) && $_SESSION['alreadysubmitted'] == false ) { |
| | 51 | + if ( $wgRequest->wasPosted() && $_SESSION['alreadysubmitted'] == false ) { |
| 52 | 52 | $_SESSION['alreadysubmitted'] = true; |
| 53 | 53 | $rel->addRelationshipRequest( |
| 54 | 54 | $this->user_name_to, |
| Index: trunk/extensions/SocialProfile/UserRelationship/SpecialAddRelationship.php |
| — | — | @@ -53,6 +53,10 @@ |
| 54 | 54 | if ( !$this->relationship_type || !is_numeric( $this->relationship_type ) ) { |
| 55 | 55 | $this->relationship_type = 1; |
| 56 | 56 | } |
| | 57 | + $hasRelationship = UserRelationship::getUserRelationshipByID( |
| | 58 | + $this->user_id_to, |
| | 59 | + $wgUser->getID() |
| | 60 | + ); |
| 57 | 61 | |
| 58 | 62 | if ( ( $wgUser->getID() == $this->user_id_to ) && ( $wgUser->getID() != 0 ) ) { |
| 59 | 63 | $wgOut->setPageTitle( wfMsg( 'ur-error-title' ) ); |
| — | — | @@ -96,9 +100,9 @@ |
| 97 | 101 | |
| 98 | 102 | $wgOut->addHTML( $out ); |
| 99 | 103 | |
| 100 | | - } elseif ( UserRelationship::getUserRelationshipByID( $this->user_id_to, $wgUser->getID() ) >= 1 ) { |
| | 104 | + } elseif ( $hasRelationship >= 1 ) { |
| 101 | 105 | |
| 102 | | - if ( UserRelationship::getUserRelationshipByID( $this->user_id_to, $wgUser->getID() ) == 1 ) { |
| | 106 | + if ( $hasRelationship == 1 ) { |
| 103 | 107 | $error = wfMsg( 'ur-add-error-message-existing-relationship-friend', $this->user_name_to ); |
| 104 | 108 | } else { |
| 105 | 109 | $error = wfMsg( 'ur-add-error-message-existing-relationship-foe', $this->user_name_to ); |
| Index: trunk/extensions/SocialProfile/UserRelationship/SpecialViewRelationships.php |
| — | — | @@ -43,7 +43,7 @@ |
| 44 | 44 | * Redirect Non-logged in users to Login Page |
| 45 | 45 | * It will automatically return them to the ViewRelationships page |
| 46 | 46 | */ |
| 47 | | - if ( $wgUser->getID() == 0 && $user_name == '' ) { |
| | 47 | + if ( !$wgUser->isLoggedIn() && $user_name == '' ) { |
| 48 | 48 | $wgOut->setPageTitle( wfMsg( 'ur-error-page-title' ) ); |
| 49 | 49 | $login = SpecialPage::getTitleFor( 'Userlogin' ); |
| 50 | 50 | $wgOut->redirect( $login->escapeFullURL( 'returnto=Special:ViewRelationships' ) ); |
| — | — | @@ -69,14 +69,14 @@ |
| 70 | 70 | $user_name = $wgUser->getName(); |
| 71 | 71 | } |
| 72 | 72 | $user_id = User::idFromName( $user_name ); |
| 73 | | - $user = Title::makeTitle( NS_USER, $user_name ); |
| | 73 | + $userPage = Title::makeTitle( NS_USER, $user_name ); |
| 74 | 74 | |
| 75 | 75 | /** |
| 76 | 76 | * Error message for username that does not exist (from URL) |
| 77 | 77 | */ |
| 78 | 78 | if ( $user_id == 0 ) { |
| 79 | 79 | $wgOut->setPageTitle( wfMsg( 'ur-error-title' ) ); |
| 80 | | - $out .= '<div class="relationship-error-message">' . |
| | 80 | + $out = '<div class="relationship-error-message">' . |
| 81 | 81 | wfMsg( 'ur-error-message-no-user' ) . |
| 82 | 82 | '</div> |
| 83 | 83 | <div class="relationship-request-buttons"> |
| — | — | @@ -149,7 +149,7 @@ |
| 150 | 150 | ); |
| 151 | 151 | |
| 152 | 152 | // Safe titles |
| 153 | | - $user = Title::makeTitle( NS_USER, $relationship['user_name'] ); |
| | 153 | + $userPage = Title::makeTitle( NS_USER, $relationship['user_name'] ); |
| 154 | 154 | $addRelationshipLink = SpecialPage::getTitleFor( 'AddRelationship' ); |
| 155 | 155 | $removeRelationshipLink = SpecialPage::getTitleFor( 'RemoveRelationship' ); |
| 156 | 156 | $giveGiftLink = SpecialPage::getTitleFor( 'GiveGift' ); |
| — | — | @@ -171,10 +171,10 @@ |
| 172 | 172 | } |
| 173 | 173 | |
| 174 | 174 | $output .= "<div class=\"relationship-item\"> |
| 175 | | - <a href=\"{$user->escapeFullURL()}\">{$avatar_img}</a> |
| | 175 | + <a href=\"{$userPage->escapeFullURL()}\">{$avatar_img}</a> |
| 176 | 176 | <div class=\"relationship-info\"> |
| 177 | 177 | <div class=\"relationship-name\"> |
| 178 | | - <a href=\"{$user->escapeFullURL()}\">{$user_name_display}</a> |
| | 178 | + <a href=\"{$userPage->escapeFullURL()}\">{$user_name_display}</a> |
| 179 | 179 | </div> |
| 180 | 180 | <div class=\"relationship-actions\">"; |
| 181 | 181 | if ( $indivRelationship == false ) { |
| Index: trunk/extensions/SocialProfile/UserRelationship/UserRelationshipClass.php |
| — | — | @@ -3,17 +3,13 @@ |
| 4 | 4 | * Functions for managing relationship data |
| 5 | 5 | */ |
| 6 | 6 | class UserRelationship { |
| 7 | | - /**#@+ |
| 8 | | - * @private |
| 9 | | - */ |
| 10 | | - var $user_id; |
| 11 | | - var $user_name; |
| | 7 | + private $user_id; |
| | 8 | + private $user_name; |
| 12 | 9 | |
| 13 | 10 | /** |
| 14 | 11 | * Constructor |
| 15 | | - * @private |
| 16 | 12 | */ |
| 17 | | - /* private */ function __construct( $username ) { |
| | 13 | + public function __construct( $username ) { |
| 18 | 14 | $title1 = Title::newFromDBkey( $username ); |
| 19 | 15 | $this->user_name = $title1->getText(); |
| 20 | 16 | $this->user_id = User::idFromName( $this->user_name ); |
| — | — | @@ -365,8 +361,8 @@ |
| 366 | 362 | * @return bool |
| 367 | 363 | */ |
| 368 | 364 | public function verifyRelationshipRequest( $relationshipRequestId ) { |
| 369 | | - $dbw = wfGetDB( DB_MASTER ); |
| 370 | | - $s = $dbw->selectRow( |
| | 365 | + $dbr = wfGetDB( DB_SLAVE ); |
| | 366 | + $s = $dbr->selectRow( |
| 371 | 367 | 'user_relationship_request', |
| 372 | 368 | array( 'ur_user_id_to' ), |
| 373 | 369 | array( 'ur_id' => $relationshipRequestId ), |
| — | — | @@ -386,8 +382,8 @@ |
| 387 | 383 | * @return Mixed: integer or boolean false |
| 388 | 384 | */ |
| 389 | 385 | static function getUserRelationshipByID( $user1, $user2 ) { |
| 390 | | - $dbw = wfGetDB( DB_MASTER ); |
| 391 | | - $s = $dbw->selectRow( |
| | 386 | + $dbr = wfGetDB( DB_SLAVE ); |
| | 387 | + $s = $dbr->selectRow( |
| 392 | 388 | 'user_relationship', |
| 393 | 389 | array( 'r_type' ), |
| 394 | 390 | array( 'r_user_id' => $user1, 'r_user_id_relation' => $user2 ), |
| — | — | @@ -406,8 +402,8 @@ |
| 407 | 403 | * @return bool |
| 408 | 404 | */ |
| 409 | 405 | static function userHasRequestByID( $user1, $user2 ) { |
| 410 | | - $dbw = wfGetDB( DB_MASTER ); |
| 411 | | - $s = $dbw->selectRow( |
| | 406 | + $dbr = wfGetDB( DB_SLAVE ); |
| | 407 | + $s = $dbr->selectRow( |
| 412 | 408 | 'user_relationship_request', |
| 413 | 409 | array( 'ur_type' ), |
| 414 | 410 | array( |
| — | — | @@ -432,7 +428,7 @@ |
| 433 | 429 | * ID, type, requester, etc. |
| 434 | 430 | */ |
| 435 | 431 | public function getRequest( $id ) { |
| 436 | | - $dbr = wfGetDB( DB_MASTER ); |
| | 432 | + $dbr = wfGetDB( DB_SLAVE ); |
| 437 | 433 | $res = $dbr->select( |
| 438 | 434 | 'user_relationship_request', |
| 439 | 435 | array( |
| — | — | @@ -470,7 +466,7 @@ |
| 471 | 467 | * @return Array: array of open relationship requests |
| 472 | 468 | */ |
| 473 | 469 | public function getRequestList( $status, $limit = 0 ) { |
| 474 | | - $dbr = wfGetDB( DB_MASTER ); |
| | 470 | + $dbr = wfGetDB( DB_SLAVE ); |
| 475 | 471 | |
| 476 | 472 | $options = array(); |
| 477 | 473 | |