r84900 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r84899‎ | r84900 | r84901 >
Date:11:57, 28 March 2011
Author:ashley
Status:deferred
Tags:
Comment:
SocialProfile: add/update/tweak documentation, remove some unused variables, shorten some loooooooong lines, fix indentation, change one hacky URL construction to use Linker (in TopAwards.php)
Modified paths:
  • /trunk/extensions/SocialProfile/SystemGifts/SpecialPopulateAwards.php (modified) (history)
  • /trunk/extensions/SocialProfile/SystemGifts/SpecialSystemGiftManager.php (modified) (history)
  • /trunk/extensions/SocialProfile/SystemGifts/SpecialSystemGiftManagerLogo.php (modified) (history)
  • /trunk/extensions/SocialProfile/SystemGifts/SpecialViewSystemGift.php (modified) (history)
  • /trunk/extensions/SocialProfile/SystemGifts/SpecialViewSystemGifts.php (modified) (history)
  • /trunk/extensions/SocialProfile/SystemGifts/SystemGiftsClass.php (modified) (history)
  • /trunk/extensions/SocialProfile/SystemGifts/TopAwards.php (modified) (history)
  • /trunk/extensions/SocialProfile/SystemGifts/UserSystemGiftsClass.php (modified) (history)
  • /trunk/extensions/SocialProfile/UserActivity/UserActivity.body.php (modified) (history)
  • /trunk/extensions/SocialProfile/UserActivity/UserActivityClass.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SocialProfile/SystemGifts/SpecialSystemGiftManager.php
@@ -1,9 +1,16 @@
22 <?php
 3+/**
 4+ * Special:SystemGiftManager -- a special page to create new system gifts
 5+ * (awards)
 6+ *
 7+ * @file
 8+ * @ingroup Extensions
 9+ */
310
411 class SystemGiftManager extends SpecialPage {
512
613 /**
7 - * Constructor
 14+ * Constructor -- set up the new special page
815 */
916 public function __construct() {
1017 parent::__construct( 'SystemGiftManager'/*class*/, 'awardsmanage'/*restriction*/ );
@@ -19,19 +26,19 @@
2027
2128 $wgOut->setPageTitle( wfMsg( 'systemgiftmanager' ) );
2229
23 - # If the user doesn't have the required 'awardsmanage' permission, display an error
 30+ // If the user doesn't have the required 'awardsmanage' permission, display an error
2431 if ( !$wgUser->isAllowed( 'awardsmanage' ) ) {
2532 $wgOut->permissionRequired( 'awardsmanage' );
2633 return;
2734 }
2835
29 - # Show a message if the database is in read-only mode
 36+ // Show a message if the database is in read-only mode
3037 if ( wfReadOnly() ) {
3138 $wgOut->readOnlyPage();
3239 return;
3340 }
3441
35 - # If user is blocked, s/he doesn't need to access this page
 42+ // If user is blocked, s/he doesn't need to access this page
3643 if ( $wgUser->isBlocked() ) {
3744 $wgOut->blockedPage();
3845 return;
@@ -43,14 +50,18 @@
4451 if ( $wgRequest->wasPosted() ) {
4552 $g = new SystemGifts();
4653
47 - if ( !( $_POST['id'] ) ) {
 54+ if ( !( $_POST['id'] ) ) { // @todo FIXME/CHECKME: why $_POST? Why not $wgRequest?
 55+ // Add the new system gift to the database
4856 $gift_id = $g->addGift(
4957 $wgRequest->getVal( 'gift_name' ),
5058 $wgRequest->getVal( 'gift_description' ),
5159 $wgRequest->getVal( 'gift_category' ),
5260 $wgRequest->getVal( 'gift_threshold' )
5361 );
54 - $wgOut->addHTML( '<span class="view-status">' . wfMsg( 'ga-created' ) . '</span><br /><br />' );
 62+ $wgOut->addHTML(
 63+ '<span class="view-status">' . wfMsg( 'ga-created' ) .
 64+ '</span><br /><br />'
 65+ );
5566 } else {
5667 $gift_id = $wgRequest->getVal( 'id' );
5768 $g->updateGift(
@@ -60,7 +71,10 @@
6172 $wgRequest->getVal( 'gift_category' ),
6273 $wgRequest->getVal( 'gift_threshold' )
6374 );
64 - $wgOut->addHTML( '<span class="view-status">' . wfMsg( 'ga-saved' ) . '</span><br /><br />' );
 75+ $wgOut->addHTML(
 76+ '<span class="view-status">' . wfMsg( 'ga-saved' ) .
 77+ '</span><br /><br />'
 78+ );
6579 }
6680 $g->update_system_gifts();
6781 $wgOut->addHTML( $this->displayForm( $gift_id ) );
@@ -69,7 +83,11 @@
7084 if ( $gift_id || $wgRequest->getVal( 'method' ) == 'edit' ) {
7185 $wgOut->addHTML( $this->displayForm( $gift_id ) );
7286 } else {
73 - $wgOut->addHTML( '<div><b><a href="' . $wgScriptPath . '/index.php?title=Special:SystemGiftManager&amp;method=edit">' . wfMsg( 'ga-addnew' ) . '</a></b></div>' );
 87+ $wgOut->addHTML(
 88+ '<div><b><a href="' . $wgScriptPath .
 89+ '/index.php?title=Special:SystemGiftManager&amp;method=edit">' .
 90+ wfMsg( 'ga-addnew' ) . '</a></b></div>'
 91+ );
7492 $wgOut->addHTML( $this->displayGiftList() );
7593 }
7694 }
Index: trunk/extensions/SocialProfile/SystemGifts/SpecialViewSystemGift.php
@@ -1,9 +1,15 @@
22 <?php
 3+/**
 4+ * A special page to view an individual system gift (award).
 5+ *
 6+ * @file
 7+ * @ingroup Extensions
 8+ */
39
410 class ViewSystemGift extends UnlistedSpecialPage {
511
612 /**
7 - * Constructor
 13+ * Constructor -- set up the new special page
814 */
915 public function __construct() {
1016 parent::__construct( 'ViewSystemGift' );
@@ -22,6 +28,8 @@
2329 $output = ''; // Prevent E_NOTICE
2430 $user_name = ''; // Prevent E_NOTICE
2531
 32+ // If gift ID wasn't passed in the URL parameters or if it's not
 33+ // numeric, display an error message
2634 $gift_id = $wgRequest->getVal( 'gift_id' );
2735 if ( !$gift_id || !is_numeric( $gift_id ) ) {
2836 $wgOut->setPageTitle( wfMsg( 'ga-error-title' ) );
@@ -29,14 +37,14 @@
3038 return false;
3139 }
3240
 41+ // We assume the current user by default
3342 if ( !$user_name ) {
3443 $user_name = $wgUser->getName();
3544 }
 45+
3646 $gift = UserSystemGifts::getUserGift( $gift_id );
3747 $id = User::idFromName( $user_name );
3848
39 - $user_safe = urlencode( $gift['user_name'] );
40 -
4149 if ( $gift ) {
4250 if ( $gift['status'] == 1 ) {
4351 if ( $gift['user_name'] == $wgUser->getName() ) {
@@ -68,14 +76,17 @@
6977
7078 $output .= $wgOut->setPageTitle( wfMsg( 'ga-gift-title', $gift['user_name'], $gift['name'] ) );
7179
 80+ $profileURL = Title::makeTitle( NS_USER, $gift['user_name'] )->escapeFullURL();
7281 $output .= '<div class="back-links">'
73 - . wfMsg( 'ga-back-link', Title::makeTitle( NS_USER, $gift['user_name'] )->escapeFullURL(), $gift['user_name'] ) .
 82+ . wfMsg( 'ga-back-link', $profileURL, $gift['user_name'] ) .
7483 '</div>';
7584
7685 $message = $wgOut->parse( trim( $gift['description'] ), false );
7786 $output .= '<div class="ga-description-container">';
7887
79 - $gift_image = "<img src=\"{$wgUploadPath}/awards/" . SystemGifts::getGiftImage( $gift['gift_id'], 'l' ) . '" border="0" alt=""/>';
 88+ $gift_image = "<img src=\"{$wgUploadPath}/awards/" .
 89+ SystemGifts::getGiftImage( $gift['gift_id'], 'l' ) .
 90+ '" border="0" alt=""/>';
8091
8192 $output .= "<div class=\"ga-description\">
8293 {$gift_image}
Index: trunk/extensions/SocialProfile/SystemGifts/SpecialSystemGiftManagerLogo.php
@@ -1,4 +1,12 @@
22 <?php
 3+/**
 4+ * A special page to upload images for system gifts (awards).
 5+ * This is mostly copied from an old version of Special:Upload and changed a
 6+ * bit.
 7+ *
 8+ * @file
 9+ * @ingroup Extensions
 10+ */
311
412 class SystemGiftManagerLogo extends UnlistedSpecialPage {
513
@@ -11,7 +19,7 @@
1220 var $gift_id;
1321
1422 /**
15 - * Constructor
 23+ * Constructor -- set up the new special page
1624 */
1725 public function __construct() {
1826 parent::__construct( 'SystemGiftManagerLogo' );
@@ -25,19 +33,19 @@
2634 public function execute( $par ) {
2735 global $wgRequest, $wgOut, $wgUser;
2836
29 - # If the user doesn't have the required 'awardsmanage' permission, display an error
 37+ // If the user doesn't have the required 'awardsmanage' permission, display an error
3038 if ( !$wgUser->isAllowed( 'awardsmanage' ) ) {
3139 $wgOut->permissionRequired( 'awardsmanage' );
3240 return;
3341 }
3442
35 - # Show a message if the database is in read-only mode
 43+ // Show a message if the database is in read-only mode
3644 if ( wfReadOnly() ) {
3745 $wgOut->readOnlyPage();
3846 return;
3947 }
4048
41 - # If user is blocked, s/he doesn't need to access this page
 49+ // If user is blocked, s/he doesn't need to access this page
4250 if ( $wgUser->isBlocked() ) {
4351 $wgOut->blockedPage();
4452 return;
Index: trunk/extensions/SocialProfile/SystemGifts/SpecialPopulateAwards.php
@@ -1,9 +1,16 @@
22 <?php
 3+/**
 4+ * Special:PopulateAwards -- basically just a special page that calls
 5+ * SystemGifts' update_system_gifts() function and does nothing else
 6+ *
 7+ * @file
 8+ * @ingroup Extensions
 9+ */
310
411 class PopulateAwards extends UnlistedSpecialPage {
512
613 /**
7 - * Constructor
 14+ * Constructor -- set up the new special page
815 */
916 public function __construct() {
1017 parent::__construct( 'PopulateAwards'/*class*/, 'awardsmanage' /*restriction*/ );
@@ -17,19 +24,19 @@
1825 public function execute( $gift_category ) {
1926 global $wgUser, $wgOut, $wgUserLevels;
2027
21 - # If the user doesn't have the required 'awardsmanage' permission, display an error
 28+ // If the user doesn't have the required 'awardsmanage' permission, display an error
2229 if ( !$wgUser->isAllowed( 'awardsmanage' ) ) {
2330 $wgOut->permissionRequired( 'awardsmanage' );
2431 return;
2532 }
2633
27 - # Show a message if the database is in read-only mode
 34+ // Show a message if the database is in read-only mode
2835 if ( wfReadOnly() ) {
2936 $wgOut->readOnlyPage();
3037 return;
3138 }
3239
33 - # If user is blocked, s/he doesn't need to access this page
 40+ // If user is blocked, s/he doesn't need to access this page
3441 if ( $wgUser->isBlocked() ) {
3542 $wgOut->blockedPage();
3643 return;
Index: trunk/extensions/SocialProfile/SystemGifts/SpecialViewSystemGifts.php
@@ -1,9 +1,15 @@
22 <?php
 3+/**
 4+ * A special page to view the list of system gifts (awards) a user has.
 5+ *
 6+ * @file
 7+ * @ingroup Extensions
 8+ */
39
410 class ViewSystemGifts extends SpecialPage {
511
612 /**
7 - * Constructor
 13+ * Constructor -- set up the new special page
814 */
915 public function __construct() {
1016 parent::__construct( 'ViewSystemGifts' );
@@ -91,21 +97,26 @@
9298 if ( $gifts ) {
9399 $x = 1;
94100 foreach ( $gifts as $gift ) {
95 - $gift_image = "<img src=\"{$wgUploadPath}/awards/" . SystemGifts::getGiftImage( $gift['gift_id'], 'ml' ) . "\" border=\"0\" alt=\"\" />";
 101+ $gift_image = "<img src=\"{$wgUploadPath}/awards/" .
 102+ SystemGifts::getGiftImage( $gift['gift_id'], 'ml' ) .
 103+ '" border="0" alt="" />';
96104
97105 $output .= "<div class=\"ga-item\">
98106 {$gift_image}
99 - <a href=\"" . $view_system_gift_link->escapeFullURL( 'gift_id=' . $gift['id'] ) . "\">{$gift["gift_name"]}</a>";
 107+ <a href=\"" .
 108+ $view_system_gift_link->escapeFullURL( 'gift_id=' . $gift['id'] ) .
 109+ "\">{$gift['gift_name']}</a>";
100110
101 - if ( $gift['status'] == 1 ) {
102 - if ( $user_name == $wgUser->getName() ) {
103 - $rel->clearUserGiftStatus( $gift['id'] );
104 - $rel->decNewSystemGiftCount( $wgUser->getID() );
105 - }
106 - $output .= '<span class="ga-new">' . wfMsg( 'ga-new' ) . '</span>';
 111+ if ( $gift['status'] == 1 ) {
 112+ if ( $user_name == $wgUser->getName() ) {
 113+ $rel->clearUserGiftStatus( $gift['id'] );
 114+ $rel->decNewSystemGiftCount( $wgUser->getID() );
107115 }
 116+ $output .= '<span class="ga-new">' .
 117+ wfMsg( 'ga-new' ) . '</span>';
 118+ }
108119
109 - $output .= '<div class="cleared"></div>
 120+ $output .= '<div class="cleared"></div>
110121 </div>';
111122 if ( $x == count( $gifts ) || $x != 1 && $x % $per_row == 0 ) {
112123 $output .= '<div class="cleared"></div>';
@@ -125,7 +136,10 @@
126137 if ( $numofpages > 1 ) {
127138 $output .= '<div class="page-nav">';
128139 if ( $page > 1 ) {
129 - $output .= '<a href="' . $page_link->escapeFullURL( 'user=' . $user_name . '&rel_type=' . $rel_type . '&page=' . ( $page - 1 ) ) . '">' . wfMsg( 'ga-previous' ) . '</a> ';
 140+ $output .= '<a href="' . $page_link->escapeFullURL(
 141+ 'user=' . $user_name . '&rel_type=' . $rel_type .
 142+ '&page=' . ( $page - 1 ) ) . '">' .
 143+ wfMsg( 'ga-previous' ) . '</a> ';
130144 }
131145
132146 if ( ( $total % $per_page ) != 0 ) {
@@ -142,12 +156,17 @@
143157 if ( $i == $page ) {
144158 $output .= ( $i . ' ' );
145159 } else {
146 - $output .= '<a href="' . $page_link->escapeFullURL( 'user=' . $user_name . '&rel_type=' . $rel_type . '&page=' . $i ) . "\">$i</a> ";
 160+ $output .= '<a href="' . $page_link->escapeFullURL(
 161+ 'user=' . $user_name . '&rel_type=' . $rel_type .
 162+ '&page=' . $i ) . "\">$i</a> ";
147163 }
148164 }
149165
150166 if ( ( $total - ( $per_page * $page ) ) > 0 ) {
151 - $output .= ' <a href="' . $page_link->escapeFullURL( 'user=' . $user_name . '&rel_type=' . $rel_type . '&page=' . ( $page + 1 ) ) . '">' . wfMsg( 'ga-next' ) . '</a>';
 167+ $output .= ' <a href="' . $page_link->escapeFullURL(
 168+ 'user=' . $user_name . '&rel_type=' . $rel_type .
 169+ '&page=' . ( $page + 1 ) ) . '">' . wfMsg( 'ga-next' ) .
 170+ '</a>';
152171 }
153172 $output .= '</div>';
154173 }
Index: trunk/extensions/SocialProfile/SystemGifts/TopAwards.php
@@ -1,9 +1,16 @@
22 <?php
 3+/**
 4+ * Special:TopAwards -- a special page to show the awards with the most
 5+ * recipients (I think)
 6+ *
 7+ * @file
 8+ * @ingroup Extensions
 9+ */
310
411 class TopAwards extends UnlistedSpecialPage {
512
613 /**
7 - * Constructor
 14+ * Constructor -- set up the new special page
815 */
916 public function __construct() {
1017 parent::__construct( 'TopAwards' );
@@ -32,7 +39,7 @@
3340 );
3441
3542 // Set title
36 - if ( !( $category_number ) or $category_number > 4 ) {
 43+ if ( !( $category_number ) || $category_number > 4 ) {
3744 $category_number = 0;
3845 $page_category = $categories[$category_number]['category_name'];
3946 } else {
@@ -43,8 +50,11 @@
4451 $dbr = wfGetDB( DB_SLAVE );
4552 $res = $dbr->select(
4653 array( 'user_system_gift', 'system_gift' ),
47 - array( 'sg_user_name', 'sg_user_id', 'gift_category', 'MAX(gift_threshold) AS top_gift' ),
4854 array(
 55+ 'sg_user_name', 'sg_user_id', 'gift_category',
 56+ 'MAX(gift_threshold) AS top_gift'
 57+ ),
 58+ array(
4959 "gift_category = {$categories[$category_number]['category_id']}",
5060 "gift_threshold > {$categories[$category_number]['category_threshold']}"
5161 ),
@@ -62,17 +72,16 @@
6373 $output = '<div class="top-awards-navigation">
6474 <h1>Award Categories</h1>';
6575
66 - $nav_x = 0;
 76+ $nav_x = 0;
6777
68 - foreach ( $categories as $award_type ) {
69 -
70 - if ( $nav_x == $category_number ) {
71 - $output .= "<p><b>{$award_type['category_name']}s</b></p>";
72 - } else {
73 - $output .= "<p><a href=\"" . $wgScriptPath . "/index.php?title=Special:TopAwards&category={$nav_x}\">{$award_type['category_name']}s</a></p>";
74 - }
75 - $nav_x++;
 78+ foreach ( $categories as $award_type ) {
 79+ if ( $nav_x == $category_number ) {
 80+ $output .= "<p><b>{$award_type['category_name']}s</b></p>";
 81+ } else {
 82+ $output .= "<p><a href=\"" . $wgScriptPath . "/index.php?title=Special:TopAwards&category={$nav_x}\">{$award_type['category_name']}s</a></p>";
7683 }
 84+ $nav_x++;
 85+ }
7786
7887 $output .= '</div>';
7988 $output .= '<div class="top-awards">';
@@ -82,7 +91,9 @@
8392 $user_id = $row->sg_user_id;
8493 $avatar = new wAvatar( $user_id, 'm' );
8594 $top_gift = $row->top_gift;
86 - $gift_name = number_format( $top_gift ) . " {$categories[$category_number][category_name]}" . ( ( $top_gift > 1 ) ? 's' : '' ) . " Milestone";
 95+ $gift_name = number_format( $top_gift ) .
 96+ " {$categories[$category_number][category_name]}" .
 97+ ( ( $top_gift > 1 ) ? 's' : '' ) . " Milestone";
8798
8899 if ( $gift_name !== $gift_name_check ) {
89100 $x = 1;
@@ -93,10 +104,14 @@
94105 $x++;
95106 }
96107
 108+ $userLink = $wgUser->getSkin()->link(
 109+ Title::makeTitle( NS_USER, $row->sg_user_name ),
 110+ $user_name
 111+ );
97112 $output .= "<div class=\"top-award\">
98113 <span class=\"top-award-number\">{$x}.</span>
99114 {$avatar->getAvatarURL()}
100 - <a href=\"" . $wgScriptPath . "/index.php?title=User:{$row->sg_user_name}\">{$user_name}</a>
 115+ {$userLink}
101116 </div>";
102117
103118 $gift_name_check = $gift_name;
Index: trunk/extensions/SocialProfile/SystemGifts/UserSystemGiftsClass.php
@@ -65,6 +65,15 @@
6666 return $sg_gift_id;
6767 }
6868
 69+ /**
 70+ * Sends notification e-mail to the user with the ID $user_id_to whenever
 71+ * they get a new system gift (award) if their e-mail address is confirmed
 72+ * and they have opted in to these notifications on their social
 73+ * preferences.
 74+ *
 75+ * @param $user_id_to Integer: user ID of the recipient
 76+ * @param $gift_id Integer: system gift ID number
 77+ */
6978 public function sendGiftNotificationEmail( $user_id_to, $gift_id ) {
7079 $gift = SystemGifts::getGift( $gift_id );
7180 $user = User::newFromId( $user_id_to );
@@ -75,8 +84,13 @@
7685 $subject = wfMsgExt( 'system_gift_received_subject', 'parsemag',
7786 $gift['gift_name']
7887 );
 88+ if ( trim( $user->getRealName() ) ) {
 89+ $name = $user->getRealName();
 90+ } else {
 91+ $name = $user->getName();
 92+ }
7993 $body = wfMsgExt( 'system_gift_received_body', 'parsemag',
80 - ( ( trim( $user->getRealName() ) ) ? $user->getRealName() : $user->getName() ),
 94+ $name,
8195 $gift['gift_name'],
8296 $gift['gift_description'],
8397 $gifts_link->getFullURL(),
@@ -87,6 +101,14 @@
88102 }
89103 }
90104
 105+ /**
 106+ * Checks if the user with the ID $user_id has the system gift with the ID
 107+ * $gift_id by querying the user_system_gift table.
 108+ *
 109+ * @param $user_id Integer: user ID
 110+ * @param $gift_id Integer: system gift ID
 111+ * @return Boolean: true if the user has the gift, otherwise false
 112+ */
91113 public function doesUserHaveGift( $user_id, $gift_id ) {
92114 $dbr = wfGetDB( DB_SLAVE );
93115 $s = $dbr->selectRow(
@@ -305,14 +327,21 @@
306328 return $new_gift_count;
307329 }
308330
 331+ /**
 332+ * Get the list of this user's system gifts.
 333+ *
 334+ * @param $type Unused
 335+ * @param $limit Integer: LIMIT for the SQL query
 336+ * @param $page Integer: if greater than 0, used to build the OFFSET for
 337+ * the SQL query
 338+ * @return Array: array of system gift information
 339+ */
309340 public function getUserGiftList( $type, $limit = 0, $page = 0 ) {
310341 $dbr = wfGetDB( DB_SLAVE );
311342
312343 $limitvalue = 0;
313 - if ( $limit > 0 ) {
314 - if ( $page ) {
315 - $limitvalue = $page * $limit - ( $limit );
316 - }
 344+ if ( $limit > 0 && $page ) {
 345+ $limitvalue = $page * $limit - ( $limit );
317346 }
318347
319348 $res = $dbr->select(
Index: trunk/extensions/SocialProfile/SystemGifts/SystemGiftsClass.php
@@ -30,11 +30,11 @@
3131 * @private
3232 */
3333 /* private */ function __construct() {
34 -
3534 }
3635
3736 /**
38 - * Adds awards for all registered users
 37+ * Adds awards for all registered users, updates statistics and purges
 38+ * caches.
3939 * Special:PopulateAwards calls this function
4040 */
4141 public function update_system_gifts() {
@@ -92,6 +92,15 @@
9393 $wgOut->addHTML( "{$x} awards were given out" );
9494 }
9595
 96+ /**
 97+ * Checks if the given user has then given award (system gift) via their ID
 98+ * numbers.
 99+ *
 100+ * @param $user_id Integer: user ID number
 101+ * @param $gift_id Integer: award (system gift) ID number
 102+ * @return Boolean|Integer: false if the user doesn't have the specified
 103+ * gift, else the gift's ID number
 104+ */
96105 public function doesUserHaveGift( $user_id, $gift_id ) {
97106 $dbr = wfGetDB( DB_SLAVE );
98107 $s = $dbr->selectRow(
@@ -108,11 +117,13 @@
109118 }
110119
111120 /**
112 - * Adds a new system gift to the database
 121+ * Adds a new system gift to the database.
 122+ *
113123 * @param $name Mixed: gift name
114124 * @param $description Mixed: gift description
115 - * @param $category
116 - * @param $threshold
 125+ * @param $category Integer: see the $categories class member variable
 126+ * @param $threshold Integer: threshold number (i.e. 50 or 100 or whatever)
 127+ * @return Integer: the inserted gift's ID number
117128 */
118129 public function addGift( $name, $description, $category, $threshold ) {
119130 $dbw = wfGetDB( DB_MASTER );
@@ -131,7 +142,8 @@
132143 }
133144
134145 /**
135 - * Updates data for a system gift
 146+ * Updates the data for a system gift.
 147+ *
136148 * @param $id Integer: system gift unique ID number
137149 * @param $name Mixed: gift name
138150 * @param $description Mixed: gift description
@@ -179,6 +191,8 @@
180192 /**
181193 * Fetches the system gift with the ID $id from the database
182194 * @param $id Integer: ID number of the system gift to be fetched
 195+ * @return Array: array of gift information, including, but not limited to,
 196+ * the gift ID, its name, description, category, threshold
183197 */
184198 static function getGift( $id ) {
185199 $dbr = wfGetDB( DB_SLAVE );
@@ -204,7 +218,8 @@
205219 }
206220
207221 /**
208 - * Gets the associated image for a system gift
 222+ * Gets the associated image for a system gift.
 223+ *
209224 * @param $id Integer: system gift ID number
210225 * @param $size String: image size (s, m, ml or l)
211226 * @return String: gift image filename (following the format
@@ -267,12 +282,14 @@
268283 'gift_given_count' => $row->gift_given_count
269284 );
270285 }
 286+
271287 return $gifts;
272288 }
273289
274290 /**
275291 * Gets the amount of available system gifts from the database.
276 - * @return integer
 292+ *
 293+ * @return Integer: the amount of all system gifts on the database
277294 */
278295 static function getGiftCount() {
279296 $dbr = wfGetDB( DB_SLAVE );
Index: trunk/extensions/SocialProfile/UserActivity/UserActivityClass.php
@@ -28,6 +28,12 @@
2929
3030 /**
3131 * Constructor
 32+ *
 33+ * @param $username String: username (usually $wgUser's username)
 34+ * @param $filter String: passed to setFilter(); can be either 'user',
 35+ * 'friends', 'foes' or 'all', depending on what
 36+ * kind of information is wanted
 37+ * @param $item_max Integer: maximum amount of items to display in the feed
3238 */
3339 public function __construct( $username, $filter, $item_max ) {
3440 if ( $username ) {
@@ -64,6 +70,10 @@
6571 $this->$name = $value;
6672 }
6773
 74+ /**
 75+ * Get recent edits from the recentchanges table and set them in the
 76+ * appropriate class member variables.
 77+ */
6878 private function setEdits() {
6979 $dbr = wfGetDB( DB_SLAVE );
7080
@@ -147,6 +157,10 @@
148158 }
149159 }
150160
 161+ /**
 162+ * Get recent votes from the Vote table (provided by VoteNY extension) and
 163+ * set them in the appropriate class member variables.
 164+ */
151165 private function setVotes() {
152166 $dbr = wfGetDB( DB_SLAVE );
153167
@@ -212,6 +226,10 @@
213227 }
214228 }
215229
 230+ /**
 231+ * Get recent comments from the Comments table (provided by the Comments
 232+ * extension) and set them in the appropriate class member variables.
 233+ */
216234 private function setComments() {
217235 $dbr = wfGetDB( DB_SLAVE );
218236
@@ -306,6 +324,10 @@
307325 }
308326 }
309327
 328+ /**
 329+ * Get recently sent user-to-user gifts from the user_gift and gift tables
 330+ * and set them in the appropriate class member variables.
 331+ */
310332 private function setGiftsSent() {
311333 $dbr = wfGetDB( DB_SLAVE );
312334
@@ -366,6 +388,10 @@
367389 }
368390 }
369391
 392+ /**
 393+ * Get recently received user-to-user gifts from the user_gift and gift
 394+ * tables and set them in the appropriate class member variables.
 395+ */
370396 private function setGiftsRec() {
371397 $dbr = wfGetDB( DB_SLAVE );
372398
@@ -452,6 +478,11 @@
453479 }
454480 }
455481
 482+ /**
 483+ * Get recently received system gifts (awards) from the user_system_gift
 484+ * and system_gift tables and set them in the appropriate class member
 485+ * variables.
 486+ */
456487 private function setSystemGiftsRec() {
457488 $dbr = wfGetDB( DB_SLAVE );
458489
@@ -532,6 +563,10 @@
533564 }
534565 }
535566
 567+ /**
 568+ * Get recent changes in user relationships from the user_relationship
 569+ * table and set them in the appropriate class member variables.
 570+ */
536571 private function setRelationships() {
537572 $dbr = wfGetDB( DB_SLAVE );
538573
@@ -618,6 +653,10 @@
619654 }
620655 }
621656
 657+ /**
 658+ * Get recently sent public user board messages from the user_board table
 659+ * and set them in the appropriate class member variables.
 660+ */
622661 private function setMessagesSent() {
623662 $dbr = wfGetDB( DB_SLAVE );
624663
@@ -703,6 +742,11 @@
704743 }
705744 }
706745
 746+ /**
 747+ * Get recent system messages (i.e. "User Foo advanced to level Bar") from
 748+ * the user_system_messages table and set them in the appropriate class
 749+ * member variables.
 750+ */
707751 private function setSystemMessages() {
708752 $dbr = wfGetDB( DB_SLAVE );
709753
@@ -880,6 +924,10 @@
881925 return $this->activityLines;
882926 }
883927
 928+ /**
 929+ * @param $type String: activity type, such as 'friend' or 'foe' or 'edit'
 930+ * @param $has_page Boolean: true by default
 931+ */
884932 function simplifyPageActivity( $type, $has_page = true ) {
885933 if ( !isset( $this->items_grouped[$type] ) || !is_array( $this->items_grouped[$type] ) ) {
886934 return '';
@@ -1000,6 +1048,13 @@
10011049 }
10021050 }
10031051
 1052+ /**
 1053+ * Get the correct icon for the given activity type.
 1054+ *
 1055+ * @param $type String: activity type, such as 'edit' or 'friend' (etc.)
 1056+ * @return String: image file name (images are located in SocialProfile's
 1057+ * images/ directory)
 1058+ */
10041059 static function getTypeIcon( $type ) {
10051060 switch( $type ) {
10061061 case 'edit':
@@ -1025,6 +1080,15 @@
10261081 }
10271082 }
10281083
 1084+ /**
 1085+ * "Fixes" a comment (such as a recent changes edit summary) by converting
 1086+ * certain characters (such as the ampersand) into their encoded
 1087+ * equivalents and, if necessary, truncates the comment and finally applies
 1088+ * stripslashes() to the comment.
 1089+ *
 1090+ * @param $comment String: comment to "fix"
 1091+ * @return String: "fixed" comment
 1092+ */
10291093 function fixItemComment( $comment ) {
10301094 if ( !$comment ) {
10311095 return '';
@@ -1041,11 +1105,20 @@
10421106 return stripslashes( $preview );
10431107 }
10441108
 1109+ /**
 1110+ * Compares the timestamps of two given objects to decide how to sort them.
 1111+ * Called by getActivityList() and getActivityListGrouped().
 1112+ *
 1113+ * @param $x Object
 1114+ * @param $y Object
 1115+ * @return Integer: 0 if the timestamps are the same, -1 if $x's timestamp
 1116+ * is greater than $y's, else 1
 1117+ */
10451118 private static function sortItems( $x, $y ) {
10461119 if( $x['timestamp'] == $y['timestamp'] ) {
10471120 return 0;
10481121 } elseif ( $x['timestamp'] > $y['timestamp'] ) {
1049 - return - 1;
 1122+ return -1;
10501123 } else {
10511124 return 1;
10521125 }
Index: trunk/extensions/SocialProfile/UserActivity/UserActivity.body.php
@@ -1,8 +1,16 @@
22 <?php
 3+/**
 4+ * Special:UserActivity - a special page for showing recent social activity
 5+ * The class is called "UserHome" because the "UserActivity" class is at
 6+ * UserActivityClass.php.
 7+ *
 8+ * @file
 9+ * @ingroup Extensions
 10+ */
311
412 class UserHome extends SpecialPage {
513 /**
6 - * Constructor
 14+ * Constructor -- set up the new special page
715 */
816 public function __construct() {
917 parent::__construct( 'UserActivity' );
@@ -32,6 +40,7 @@
3341 $item_type = 'all';
3442 }
3543
 44+ // If not otherwise specified, display everything but votes in the feed
3645 if ( $item_type == 'edits' || $item_type == 'all' ) {
3746 $edits = 1;
3847 }

Status & tagging log