r107140 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r107139‎ | r107140 | r107141 >
Date:08:45, 23 December 2011
Author:nikerabbit
Status:ok
Tags:
Comment:
Stylize
Modified paths:
  • /trunk/extensions/MarkAsHelpful/includes/MarkAsHelpfulItem.php (modified) (history)

Diff [purge]

Index: trunk/extensions/MarkAsHelpful/includes/MarkAsHelpfulItem.php
@@ -39,7 +39,7 @@
4040 * @param $key string - the name of a property
4141 */
4242 public function getProperty( $key ) {
43 - if( array_key_exists( $key, $this->property) ) {
 43+ if ( array_key_exists( $key, $this->property ) ) {
4444 return $this->property[$key];
4545 } else {
4646 return null;
@@ -48,11 +48,11 @@
4949
5050 /**
5151 * Setter method
52 - * @param $key string - the name of the property
 52+ * @param $key string - the name of the property
5353 * @param $value mixed - the valud of the property
5454 */
5555 public function setProperty( $key, $value ) {
56 - if( array_key_exists( $key, $this->property) ) {
 56+ if ( array_key_exists( $key, $this->property ) ) {
5757 $this->property[$key] = $value;
5858 }
5959 }
@@ -137,23 +137,23 @@
138138 * @exception MWMarkAsHelpFulItemSearchKeyException
139139 */
140140 public function loadFromDatabase( $conds ) {
141 -
 141+
142142 $searchKey = array_keys ( $conds );
143 -
 143+
144144 $flag = sort( $searchKey );
145 -
 145+
146146 if ( !$flag ) {
147147 return false;
148148 }
149 -
150 - $searchKey = implode(',', $searchKey );
151 -
 149+
 150+ $searchKey = implode( ',', $searchKey );
 151+
152152 $allowableSearchKey = array ( 'mah_id', 'mah_item,mah_type,mah_user_id,mah_user_ip' );
153 -
 153+
154154 if ( !in_array( $searchKey, $allowableSearchKey ) ) {
155155 throw new MWMarkAsHelpFulItemSearchKeyException( 'Invalid search key!' );
156156 }
157 -
 157+
158158 $dbr = wfGetDB( DB_SLAVE );
159159
160160 $res = $dbr->selectRow(
@@ -163,8 +163,8 @@
164164 __METHOD__
165165 );
166166
167 - if( $res !== false ) {
168 - foreach( $this->property as $key => $val ) {
 167+ if ( $res !== false ) {
 168+ foreach ( $this->property as $key => $val ) {
169169 $this->setProperty( $key, $res->$key );
170170 }
171171
@@ -178,7 +178,7 @@
179179 /**
180180 * To mark an item as helpful, this function should be called after either loadFromRequest() or setProperty()
181181 * data must be validated if called from setProperty()
182 - *
 182+ *
183183 */
184184 public function mark() {
185185 if ( $this->userHasMarked() ) {
@@ -205,15 +205,15 @@
206206 * @param $currentUser Object - the current user who is browsing the site
207207 */
208208 public function unmark( $currentUser ) {
209 -
 209+
210210 if ( $currentUser->isAnon() ) {
211211 return;
212212 }
213 -
 213+
214214 if ( $this->getProperty( 'mah_id' ) ) {
215 -
 215+
216216 if ( !$this->getProperty( 'mah_type' ) ) {
217 - if( !$this->loadFromDatabase( array( 'mah_id' => $this->getProperty( 'mah_id' ) ) ) ) {
 217+ if ( !$this->loadFromDatabase( array( 'mah_id' => $this->getProperty( 'mah_id' ) ) ) ) {
218218 return;
219219 }
220220 }
@@ -221,11 +221,11 @@
222222 $user = $this->getUser();
223223
224224 if ( $user ) {
225 -
 225+
226226 if ( !$user->isAnon() ) {
227 -
 227+
228228 if ( $currentUser->getId() == $user->getId() ) {
229 -
 229+
230230 $dbw = wfGetDB( DB_MASTER );
231231
232232 $dbw->delete(
@@ -233,11 +233,11 @@
234234 array( 'mah_id' => $this->getProperty( 'mah_id' ) ),
235235 __METHOD__
236236 );
237 -
 237+
238238 }
239 -
 239+
240240 }
241 -
 241+
242242 }
243243 }
244244
@@ -310,9 +310,9 @@
311311
312312 $list = array();
313313
314 - foreach( $res AS $val ) {
315 - $list[$val->user_id] = array( 'user_name' => $val->user_name,
316 - 'user_id' => $val->user_id,
 314+ foreach ( $res AS $val ) {
 315+ $list[$val->user_id] = array( 'user_name' => $val->user_name,
 316+ 'user_id' => $val->user_id,
317317 'user_ip' => $val->mah_user_ip );
318318 }
319319

Status & tagging log