r94139 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r94138‎ | r94139 | r94140 >
Date:23:37, 9 August 2011
Author:ashley
Status:deferred
Tags:
Comment:
SocialProfile: lots of miscellaneous cleanup to UserStatus, but the main big changes here are:
*more documentation
*changed us-link from an ID to a class because IDs must be unique
*shut up a PHP warning about ush_likes
*do escaping properly via all the appropriate MW functions and do escaping as close to the output as possible to avoid reviewer anxiety
*simple checking in wfSaveStatus to make sure that the user is who they claim to be; would probably be best to use edit token stuff here
*moved a lot of HTML building from JS to PHP
*decoupled UserStatus and UserProfile by removing UserProfilePage::getStatus() and moving the logic to UserStatus_AjaxFunctions.php, function wfUserProfileStatusOutput
*used Language::timeanddate() instead of custom DateTime building for status message dates

I probably broke something, even though I tried to test this rather extensively.
Modified paths:
  • /trunk/extensions/SocialProfile/UserProfile/UserProfilePage.php (modified) (history)
  • /trunk/extensions/SocialProfile/UserStatus/UserStatus.css (modified) (history)
  • /trunk/extensions/SocialProfile/UserStatus/UserStatus.js (modified) (history)
  • /trunk/extensions/SocialProfile/UserStatus/UserStatusClass.php (modified) (history)
  • /trunk/extensions/SocialProfile/UserStatus/UserStatus_AjaxFunctions.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SocialProfile/UserStatus/UserStatus_AjaxFunctions.php
@@ -5,63 +5,104 @@
66 $wgAjaxExportList[] = 'wfSaveStatus';
77
88 function wfSaveStatus( $u_id, $status ) {
9 - $us_class = new UserStatusClass();
10 - $us_class->setStatus( $u_id, $status );
11 - $user_status_array = $us_class->getStatus( $u_id );
12 - $us = htmlspecialchars($us_class->usHTMLcharacters($user_status_array['us_status']));
13 - $us .= "<br> <a id=\"us-link\" href=\"javascript:UserStatus.toEditMode('".($user_status_array['us_status'])."','$u_id');\">".wfMsg('userstatus-edit')."</a>";
 9+ global $wgUser;
 10+
 11+ $us = '';
 12+
 13+ // Would probably be best to pass an edit token here, like most other MW
 14+ // forms do
 15+ if ( $u_id == $wgUser->getId() ) {
 16+ // Decode what we encoded in JS, UserStatus.saveStatus; this is safe
 17+ // because the Database class that UserStatusClass uses for its DB queries
 18+ // will do all the escaping for us.
 19+ $status = urldecode( $status );
 20+
 21+ $us_class = new UserStatusClass();
 22+ $us_class->setStatus( $u_id, $status );
 23+
 24+ $user_status_array = $us_class->getStatus( $u_id );
 25+
 26+ $us = htmlspecialchars( $user_status_array['us_status'] );
 27+ $us .= '<br /> <a class="us-link" href="javascript:UserStatus.toEditMode();">' .
 28+ wfMsg( 'userstatus-edit' ) . '</a>';
 29+ }
 30+
1431 return $us;
1532 }
1633
1734 $wgAjaxExportList[] = 'wfGetHistory';
1835
1936 function wfGetHistory( $u_id ) {
 37+ global $wgLang, $wgUser;
 38+
2039 $us_class = new UserStatusClass();
21 - $historyArray = $us_class->useStatusHistory('select', $u_id);
22 - $output='<table id="user-status-history">';
23 - foreach ($historyArray as $row ) {
24 - $time = DateTime::createFromFormat('Y-m-d H:i:s',$row['ush_timestamp']);
25 - $us = htmlspecialchars($us_class->usHTMLcharacters($row['ush_status']));
26 -
27 - $output .= '<tr><td width="60" id="status-history-time">'.date_format($time, 'j M G:i').' </td>';
28 - $output .= '<td width="360"><a href="javascript:UserStatus.fromHistoryToStatus(\''.$us.'\');">'
29 - .$us.'</a></td>';
 40+ $historyArray = $us_class->useStatusHistory( 'select', $u_id );
 41+
 42+ $output = '<table id="user-status-history">';
 43+
 44+ if ( empty( $historyArray ) ) {
 45+ $output .= 'No status history.';
 46+ } else {
 47+ foreach ( $historyArray as $row ) {
 48+ $us = htmlspecialchars( $row['ush_status'] );
 49+ $statusId = intval( $row['ush_id'] );
 50+
 51+ $href = '';
 52+ // We can only *view* other user's past status updates, we cannot
 53+ // do anything with them...so don't bother generating the href
 54+ // attribute when we're not viewing our own profile
 55+ if ( $u_id == $wgUser->getId() ) {
 56+ $href = ' href="javascript:UserStatus.insertStatusFromHistory(' . $statusId .
 57+ ');"';
 58+ }
 59+
 60+ $output .= '<tr>
 61+ <td width="60" id="status-history-time">' .
 62+ $wgLang->timeanddate( wfTimestamp( TS_MW, $row['ush_timestamp'] ), true ) .
 63+ '</td>
 64+ <td width="360">
 65+ <a id="status-history-entry-' . $statusId . '"' . $href . '>'.
 66+ $us . '</a>
 67+ </td>
 68+ </tr>';
3069 }
31 - $output.='</table>';
 70+ }
 71+
 72+ $output .= '</table>';
 73+
3274 return $output;
3375 }
3476
3577 $wgAjaxExportList[] = 'SpecialGetStatusByName';
3678
3779 function SpecialGetStatusByName( $user_name ) {
38 - global $wgUser;
39 - $output="";
40 - $user_id = $wgUser->idFromName($user_name);
 80+ $output = '';
 81+ $user_id = User::idFromName( $user_name );
4182
42 - if (empty ($user_id)) {
43 - $output.="<div>Wrong name or user does not exist</div>";
 83+ if ( empty( $user_id ) ) {
 84+ $output .= '<div>Wrong name or user does not exist</div>';
4485 } else {
4586 $us_class = new UserStatusClass();
46 - $currentStatus = $us_class->getStatus($user_id);
47 - $output .="<br><div>USER ID: $user_id, USERNAME: $user_name</div><br>";
 87+ $currentStatus = $us_class->getStatus( $user_id );
 88+ $output .= "<br /><div>USER ID: $user_id, USERNAME: $user_name</div><br>";
4889
49 - if (!empty ($currentStatus)) {
50 - $output .="CURRENT STATUS:<br>
51 - <input id=\"ush_delete\" type=\"button\" value=\"Delete\"
 90+ if ( !empty( $currentStatus ) ) {
 91+ $output .="CURRENT STATUS:<br />
 92+ <input id=\"ush_delete\" type=\"button\" value=\"Delete\"
5293 onclick=\"javascript:UserStatus.specialStatusDelete('".$currentStatus['us_id']."');\">"
53 - .$currentStatus['us_status']."<br><br>";
 94+ .$currentStatus['us_status'] . '<br /><br />';
5495 }
5596
56 - $output .="HISTORY:<br>";
 97+ $output .= 'HISTORY:<br />';
5798
58 - $userHistory = $us_class->useStatusHistory('select', $user_id);
59 - if(empty ($userHistory)) {
60 - $output .= "No history";
 99+ $userHistory = $us_class->useStatusHistory( 'select', $user_id );
 100+ if( empty( $userHistory ) ) {
 101+ $output .= 'No history';
61102 } else {
62103 foreach ( $userHistory as $row ) {
63 - $output .= "<input id=\"ush_delete\" type=\"button\" value=\"Delete\"
 104+ $output .= "<input id=\"ush_delete\" type=\"button\" value=\"Delete\"
64105 onclick=\"javascript:UserStatus.specialHistoryDelete('".$row['ush_id']."');\">"
65 - .$row['ush_timestamp']." - ".$row['ush_status']." <br>";
 106+ .$row['ush_timestamp']." - ".$row['ush_status']." <br />";
66107 }
67108 }
68109 }
@@ -71,15 +112,15 @@
72113 $wgAjaxExportList[] = 'SpecialHistoryDelete';
73114 function SpecialHistoryDelete( $id ) {
74115 $us_class = new UserStatusClass();
75 - $us_class->removeHistoryStatus($id);
76 - return "";
 116+ $us_class->removeHistoryStatus( $id );
 117+ return '';
77118 }
78119
79120 $wgAjaxExportList[] = 'SpecialStatusDelete';
80121 function SpecialStatusDelete( $id ) {
81122 $us_class = new UserStatusClass();
82 - $us_class->removeStatus($id);
83 - return "";
 123+ $us_class->removeStatus( $id );
 124+ return '';
84125 }
85126
86127 $wgHooks['MakeGlobalVariablesScript'][] = 'addJSGlobals';
@@ -96,17 +137,83 @@
97138
98139 $wgHooks['UserProfileBeginRight'][] = 'wfUserProfileStatusOutput';
99140
 141+/**
 142+ * Show status updates in user profiles if this feature is enabled.
 143+ *
 144+ * @param $user_profile UserProfile: instance of UserProfile
 145+ * @return Boolean: true
 146+ */
100147 function wfUserProfileStatusOutput( $user_profile ) {
101 - global $wgOut , $wgEnableUserStatus;
 148+ global $wgOut, $wgUser, $wgEnableUserStatus;
 149+
102150 if ( $wgEnableUserStatus ) {
103 - $userStatus = $user_profile->getStatus( $user_profile->user_id );
 151+ $us_class = new UserStatusClass();
 152+ $user_status_array = $us_class->getStatus( $user_profile->user_id );
 153+
 154+ if ( empty( $user_status_array ) ) {
 155+ $userStatus = '';
 156+ } else {
 157+ $userStatus = $user_status_array['us_status'];
 158+ }
 159+
 160+ $editLink = '';
 161+ // This is the version of the status message that we can safely use in
 162+ // JavaScript
 163+ $jsEncodedStatusMsg = Xml::escapeJsString( htmlspecialchars( $userStatus ) );
 164+
 165+ // If the user is viewing their own profile, we can show the "edit"
 166+ // link, provided that the user isn't blocked and that the database is
 167+ // writable
 168+ if ( $user_profile->user_id == $wgUser->getId() ) {
 169+ if ( $wgUser->isBlocked() ) {
 170+ $userStatus = wfMsg( 'userstatus-blocked' );
 171+ }
 172+
 173+ // Database operations require write mode
 174+ if ( wfReadOnly() ) {
 175+ $userStatus = wfMsg( 'userstatus-readonly' );
 176+ }
 177+
 178+ if ( !$wgUser->isBlocked() && !wfReadOnly() ) {
 179+ $editLink = '<br /><a class="us-link" href="javascript:UserStatus.toEditMode();">' .
 180+ wfMsg( 'userstatus-edit' ) . '</a>';
 181+ }
 182+ }
 183+
104184 $output = '<div id="status-box">
105185 <div id="status-box-top"></div>
106186 <div id="status-box-content">
107 - <div id="user-status-block">' . $userStatus . '</div>
108 - </div>
 187+ <div id="user-status-block">' .
 188+ htmlspecialchars( $userStatus ) . $editLink .
 189+ '</div>';
 190+
 191+ // No need to show the editing controls to anyone else except the owner
 192+ // of the profile
 193+ if ( $user_profile->user_id == $wgUser->getId() ) {
 194+ $output .= '<div id="status-edit-controls" style="display: none;">
 195+ <input id="user-status-input" type="text" size="50" value="' .
 196+ htmlspecialchars( $userStatus ) .
 197+ '" onkeyup="javascript:UserStatus.usLettersLeft();" />
 198+ <br />
 199+ <div id="status-bar">
 200+ <a class="us-link" href="javascript:UserStatus.saveStatus(\'' . $user_profile->user_id . '\');">' .
 201+ wfMsg( 'userstatus-save' ) . '</a>
 202+ <a class="us-link" href="javascript:UserStatus.useHistory(\'' . $user_profile->user_id . '\');">' .
 203+ wfMsg( 'userstatus-history' ) . '</a>
 204+ <a class="us-link" href="javascript:UserStatus.toShowMode();">' .
 205+ wfMsg( 'userstatus-cancel' ) . '</a>
 206+ <span id="status-letter-count"></span>
 207+ </div>
 208+ </div><!-- #status-edit-controls -->';
 209+ } else {
 210+ // Public history link to the masses
 211+ $output .= "<script>UserStatus.publicHistoryButton('{$user_profile->user_id}');</script>";
 212+ }
 213+
 214+ $output .= '</div>
109215 </div>';
110 - $wgOut->addHTML($output);
 216+ $wgOut->addHTML( $output );
111217 }
 218+
112219 return true;
113220 }
\ No newline at end of file
Index: trunk/extensions/SocialProfile/UserStatus/UserStatus.css
@@ -1,31 +1,31 @@
22 #status-box {
3 - width : 440px;
 3+ width: 440px;
44 padding: 0px;
55 margin: 0px;
66 }
77
88 #status-box-top {
9 - overflow:visible;
 9+ overflow: visible;
1010 margin-left: 34px;
1111 width: 30px;
12 - height:24px;
13 - background-color:orange;
 12+ height: 24px;
 13+ background-color: orange;
1414 background-image: url('../images/status-corner.png');
1515 }
1616
1717 #status-box-content {
18 - background-color:orange;
19 - padding:10px;
 18+ background-color: orange;
 19+ padding: 10px;
2020 border-radius: 22px;
2121 /*height: 38px;*/
2222 }
2323
24 -#user-status-block {
 24+#user-status-block, #status-edit-controls {
2525 text-align: center;
2626 color: white;
2727 }
2828
29 -#us-link {
 29+.us-link {
3030 color: white;
3131 font-size: 8pt;
3232 text-decoration: underline;
@@ -47,7 +47,7 @@
4848 }
4949
5050 #status-letter-count {
51 - float:right;
 51+ float: right;
5252 margin-right: 20px;
5353 font-size: 8pt;
5454 }
Index: trunk/extensions/SocialProfile/UserStatus/UserStatus.js
@@ -1,106 +1,115 @@
22 var UserStatus = {
33 maxStatusLength : 70,
4 -
5 - toShowMode: function( status, id ) {
6 - var textNode = document.createTextNode (this.returnJS(status));
7 - var textContainer = document.getElementById( 'user-status-block' );
8 - textContainer.innerHTML = "";
9 - textContainer.appendChild (textNode);
10 - textContainer.innerHTML += '<br> <a id="us-link" href="javascript:UserStatus.toEditMode(\'' +
11 - status + '\',' + id + ');">'+_US_EDIT+'</a>';
 4+
 5+ /**
 6+ * Go back to viewing the status update from the editing mode.
 7+ */
 8+ toShowMode: function() {
 9+ jQuery( '#status-edit-controls' ).hide();
 10+ jQuery( '#user-status-block' ).show();
1211 },
13 -
14 - usLettersLeft: function() {
15 - var len = this.maxStatusLength - document.getElementById('user-status-input').value.length;
16 - if ( len < 0 ) {
17 - var usBlock = document.getElementById('user-status-input');
18 - document.getElementById('user-status-input').value = usBlock.value.slice(0,this.maxStatusLength);
 12+
 13+ /**
 14+ * Show the "X letters left" message when the user is typing a status
 15+ * update.
 16+ */
 17+ usLettersLeft: function() {
 18+ var len = this.maxStatusLength - document.getElementById( 'user-status-input' ).value.length;
 19+ if ( len < 0 ) {
 20+ var usBlock = document.getElementById( 'user-status-input' );
 21+ document.getElementById( 'user-status-input' ).value = usBlock.value.slice( 0, this.maxStatusLength );
1922 len++;
2023 }
21 - document.getElementById('status-letter-count').innerHTML =len + " "+_US_LETTERS;
 24+ document.getElementById( 'status-letter-count' ).innerHTML = len + ' ' + _US_LETTERS;
2225 },
23 -
 26+
2427 publicHistoryButton: function( id ) {
25 - document.getElementById( 'user-status-block' ).innerHTML += '<br> <a id="us-link" href="javascript:UserStatus.useHistory(' + id + ');">'+_US_HISTORY+'</a>';
 28+ document.getElementById( 'user-status-block' ).innerHTML +=
 29+ '<br /> <a id="us-link" href="javascript:UserStatus.useHistory(' + id + ');">' + _US_HISTORY + '</a>';
2630 },
27 -
28 - toEditMode: function( status, id ) {
29 - var editbar = '<input id="user-status-input" type="text" size="50" value="' +
30 - this.returnJS(status) + '" onkeyup="javascript:UserStatus.usLettersLeft();">';
31 - editbar += '<br> <div id="status-bar">';
32 - editbar += '<a id="us-link" href="javascript:UserStatus.saveStatus(' + id + ');">'+_US_SAVE+'</a>';
33 - editbar += ' <a id="us-link" href="javascript:UserStatus.useHistory(' + id + ');">'+_US_HISTORY+'</a>';
34 - editbar += ' <a id="us-link" href="javascript:UserStatus.toShowMode(\'' + status + '\',' + id + ');">'+_US_CANCEL+'</a>';
35 - editbar += '<span id="status-letter-count"></span></div>';
36 - document.getElementById( 'user-status-block' ).innerHTML = editbar;
 31+
 32+ /**
 33+ * Enter the edit mode by hiding the current status message and displaying
 34+ * the hidden input field which allows the user to enter a new status
 35+ * update + some other editing tools.
 36+ */
 37+ toEditMode: function() {
 38+ jQuery( '#user-status-block' ).hide();
 39+ jQuery( '#status-edit-controls' ).show();
3740 },
38 -
39 - parseJS:function ( str ) {
40 - var chars = Array( "<", ">", "\"", "'");
41 - var replacements = Array( "@l;", "@r;", "@dq;", "@q;");
42 - for (var i=0; i<chars.length; i++) {
43 - var reg = new RegExp(chars[i], "gi");
44 - if(reg.test(str)) {
45 - str = str.replace(reg, replacements[i]);
46 - }
47 - }
48 - return str;
49 - },
50 -
51 - returnJS:function ( str ) {
52 - var chars = Array( "<", ">", "\"", "'");
53 - var replacements = Array( "@l;", "@r;", "@dq;", "@q;");
54 - for (var i=0; i<chars.length; i++) {
55 - var reg = new RegExp(replacements[i], "gi");
56 - if(reg.test(str)) {
57 - str = str.replace(reg, chars[i]);
58 - }
59 - }
60 - return str;
61 - },
6241
 42+ /**
 43+ * Save a status message into the database.
 44+ *
 45+ * @param id Integer: user ID number
 46+ */
6347 saveStatus: function( id ) {
6448 var div = document.getElementById( 'user-status-block' );
65 - var ustext = document.getElementById( 'user-status-input' ).value;
66 - var ust = this.parseJS(ustext);
67 - sajax_do_call( 'wfSaveStatus', [id, ust], div );
 49+ var ustext = encodeURIComponent( document.getElementById( 'user-status-input' ).value );
 50+ sajax_do_call( 'wfSaveStatus', [id, ustext], function( r ) {
 51+ div.innerHTML = r.responseText;
 52+ jQuery( '#status-edit-controls' ).hide();
 53+ jQuery( '#user-status-block' ).show();
 54+ });
6855 },
6956
70 - useHistory: function( id ){
71 - var historyBlock = document.getElementById('status-history-block');
72 - if(historyBlock===null) {
73 - var statusBlock = document.getElementById('user-status-block');
74 - historyBlock = document.createElement('div');
 57+ /**
 58+ * Show the user's past status messages when they click on the "history"
 59+ * link on their profile.
 60+ *
 61+ * @param id Integer: user ID number
 62+ */
 63+ useHistory: function( id ) {
 64+ var historyBlock = document.getElementById( 'status-history-block' );
 65+ if( historyBlock === null ) {
 66+ var statusBlock;
 67+ if ( document.getElementById( 'status-edit-controls' ) ) {
 68+ // This div is present only when you're viewing your own
 69+ // profile, it doesn't exist when you're viewing other people's
 70+ // profiles
 71+ statusBlock = document.getElementById( 'status-edit-controls' );
 72+ } else {
 73+ statusBlock = document.getElementById( 'user-status-block' );
 74+ }
 75+ historyBlock = document.createElement( 'div' );
7576 historyBlock.id = 'status-history-block';
76 - statusBlock.appendChild(historyBlock);
 77+ statusBlock.appendChild( historyBlock );
7778 sajax_do_call( 'wfGetHistory', [id], historyBlock );
7879 }
79 -
80 - if (historyBlock.style.display == "block") {
81 - historyBlock.style.display = "none";
 80+
 81+ if ( jQuery( '#status-history-block' ).is( 'visible' ) ) {
 82+ jQuery( '#status-history-block' ).hide();
8283 } else {
83 - historyBlock.style.display = "block";
 84+ jQuery( '#status-history-block' ).show();
8485 }
8586 },
8687
87 - fromHistoryToStatus: function( str ) {
88 - document.getElementById('user-status-input').value = this.returnJS(str);
 88+ /**
 89+ * Insert a previously used status message from the history list into the
 90+ * editing <input> whenever the user clicks on an archived status message.
 91+ *
 92+ * @param statusId Integer: status message ID, used in the HTML element as
 93+ * an ID
 94+ */
 95+ insertStatusFromHistory: function( statusId ) {
 96+ document.getElementById( 'user-status-input' ).value =
 97+ jQuery( '#status-history-entry-' + statusId ).text();
8998 },
90 -
 99+
91100 specialGetHistory: function() {
92 - var us_name = document.getElementById("us-name-input").value;
93 - var block = document.getElementById("us-special");
 101+ var us_name = document.getElementById( 'us-name-input' ).value;
 102+ var block = document.getElementById( 'us-special' );
94103 sajax_do_call( 'SpecialGetStatusByName', [us_name], block );
95104 },
96 -
97 - specialHistoryDelete: function(id) {
98 - var block = document.getElementById("us-special");
 105+
 106+ specialHistoryDelete: function( id ) {
 107+ var block = document.getElementById( 'us-special' );
99108 sajax_do_call( 'SpecialHistoryDelete', [id], block );
100109 this.specialGetHistory();
101110 },
102 -
103 - specialStatusDelete: function(id) {
104 - var block = document.getElementById("us-special");
 111+
 112+ specialStatusDelete: function( id ) {
 113+ var block = document.getElementById( 'us-special' );
105114 sajax_do_call( 'SpecialStatusDelete', [id], block );
106115 this.specialGetHistory();
107116 }
Index: trunk/extensions/SocialProfile/UserStatus/UserStatusClass.php
@@ -1,7 +1,7 @@
22 <?php
33 /**
44 * Class to manipulate user-specific status messages.
5 - *
 5+ *
66 * @file
77 */
88 class UserStatusClass {
@@ -30,17 +30,21 @@
3131 $message = array(
3232 'us_id' => $row->us_id,
3333 'us_user_id' => $row->us_user_id,
34 - 'us_status' => htmlspecialchars( $row->us_status ),
 34+ 'us_status' => $row->us_status,
3535 );
3636 }
3737 }
3838
3939 return $message;
4040 }
41 -
 41+
4242 public function removeStatus( $status_id ) {
43 - $dbr = wfGetDB( DB_MASTER );
44 - $dbr->delete('user_status', array( 'us_id' => $status_id ), __METHOD__);
 43+ $dbw = wfGetDB( DB_MASTER );
 44+ $dbw->delete(
 45+ 'user_status',
 46+ array( 'us_id' => $status_id ),
 47+ __METHOD__
 48+ );
4549 return;
4650 }
4751
@@ -51,8 +55,8 @@
5256 * @param $message String: user-supplied status message
5357 */
5458 public function setStatus( $u_id, $message ) {
55 - $message = trim($message);
56 - if (( mb_strlen( $message ) > 90 ) || ( mb_strlen( $message ) < 1 )) {
 59+ $message = trim( $message );
 60+ if ( ( mb_strlen( $message ) > 90 ) || ( mb_strlen( $message ) < 1 ) ) {
5761 // INFO. Letter limit is 70, but here is 90, for special characters.
5862 // ERROR. Message length is too long
5963 return;
@@ -122,7 +126,7 @@
123127 'ush_user_id' => $row->ush_user_id,
124128 'ush_timestamp' => $row->ush_timestamp,
125129 'ush_status' => $row->ush_status,
126 - 'ush_likes' => $row->ush_likes,
 130+ 'ush_likes' => ( isset( $row->ush_likes ) ? $row->ush_likes : 0 ),
127131 );
128132 }
129133
@@ -132,7 +136,7 @@
133137
134138 if ( $mode == 'insert' ) {
135139 $currentStatus = $this->getStatus( $u_id );
136 -
 140+
137141 if ( $i < 4 ) {
138142 $dbw->insert(
139143 'user_status_history',
@@ -158,22 +162,14 @@
159163 return;
160164 }
161165 }
162 -
 166+
163167 public function removeHistoryStatus( $status_id ) {
164 - $dbr = wfGetDB( DB_MASTER );
165 - $dbr->delete('user_status_history', array( 'ush_id' => $status_id ), __METHOD__);
 168+ $dbw = wfGetDB( DB_MASTER );
 169+ $dbw->delete(
 170+ 'user_status_history',
 171+ array( 'ush_id' => $status_id ),
 172+ __METHOD__
 173+ );
166174 return;
167175 }
168 -
169 - public function usHTMLcharacters( $str ) {
170 - $regexp = array( "@q;", "@dq;", "@l;", "@r;" );
171 - $replacement = array ("'", "\"", "<", ">" );
172 -
173 - $newstr=$str;
174 - for ($i=0; $i<count($regexp);$i++) {
175 - $newstr = str_replace($regexp[$i],$replacement[$i],$newstr);
176 - }
177 -
178 - return $newstr;
179 - }
180176 }
\ No newline at end of file
Index: trunk/extensions/SocialProfile/UserProfile/UserProfilePage.php
@@ -1782,32 +1782,4 @@
17831783 return $output;
17841784 }
17851785
1786 - function getStatus( $userId ) {
1787 - global $wgUser;
1788 -
1789 - $us_class = new UserStatusClass();
1790 - $user_status_array = $us_class->getStatus( $userId );
1791 - if ( empty( $user_status_array ) ) {
1792 - $buf = '';
1793 - } else {
1794 - $buf = $user_status_array['us_status'];
1795 - }
1796 -
1797 - // Only owners of the page can change statuses
1798 - if ( $wgUser->getId() == $userId ) {
1799 - if ( $wgUser->isBlocked() ) {
1800 - return wfMsg( 'userstatus-blocked' );
1801 - }
1802 -
1803 - // Database operations require write mode
1804 - if ( wfReadOnly() ) {
1805 - return wfMsg( 'userstatus-readonly' );
1806 - }
1807 -
1808 - return "<script>UserStatus.toShowMode('$buf','$userId');</script>";
1809 - } else {
1810 - return $buf."<script>UserStatus.publicHistoryButton('$userId');</script>";
1811 - }
1812 - }
1813 -
18141786 }

Follow-up revisions

RevisionCommit summaryAuthorDate
r94258SocialProfile: follow-up to r94139: in UserStatus, only show the history when...ashley17:20, 11 August 2011
r94898SocialProfile: follow-up to r90537, r90547, r94139: remove unused globalashley15:33, 18 August 2011

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r94057Fixed bug with quoteszhenya12:38, 8 August 2011
r94128some bugs with html special characters were fixed up.zhenya18:00, 9 August 2011

Status & tagging log