Index: trunk/extensions/SocialProfile/UserActivity/UserActivity.body.php |
— | — | @@ -0,0 +1,120 @@ |
| 2 | +<?php |
| 3 | + |
| 4 | +class UserHome extends SpecialPage { |
| 5 | + |
| 6 | + /** |
| 7 | + * Constructor |
| 8 | + */ |
| 9 | + public function __construct(){ |
| 10 | + parent::__construct( 'UserActivity' ); |
| 11 | + } |
| 12 | + |
| 13 | + /** |
| 14 | + * Show the special page |
| 15 | + * |
| 16 | + * @param $par Mixed: parameter passed to the page or null |
| 17 | + */ |
| 18 | + public function execute( $par ){ |
| 19 | + global $wgUser, $wgOut, $wgRequest, $wgSitename, $wgScriptPath; |
| 20 | + |
| 21 | + wfLoadExtensionMessages( 'UserActivity' ); |
| 22 | + |
| 23 | + $wgOut->addExtensionStyle( $wgScriptPath . '/extensions/SocialProfile/UserActivity/UserActivity.css' ); |
| 24 | + |
| 25 | + $wgOut->setPageTitle( wfMsg( 'useractivity-title' ) ); |
| 26 | + |
| 27 | + $this_title = SpecialPage::getTitleFor( 'UserActivity' ); |
| 28 | + |
| 29 | + $output = ''; |
| 30 | + |
| 31 | + $rel_type = $wgRequest->getVal( 'rel_type' ); |
| 32 | + $item_type = $wgRequest->getVal( 'item_type' ); |
| 33 | + |
| 34 | + if( !$rel_type ) $rel_type = 1; |
| 35 | + if( !$item_type ) $item_type = 'all'; |
| 36 | + |
| 37 | + if( $item_type == 'edits' || $item_type == 'all' ) $edits = 1; |
| 38 | + if( $item_type == 'votes' || $item_type == 'all' ) $votes = 0; |
| 39 | + if( $item_type == 'comments' || $item_type == 'all' ) $comments = 1; |
| 40 | + if( $item_type == 'gifts' || $item_type == 'all' ) $gifts = 1; |
| 41 | + if( $item_type == 'relationships' || $item_type == 'all' ) $relationships = 1; |
| 42 | + if( $item_type == 'advancements' || $item_type == 'all' ) $messages = 1; |
| 43 | + if( $item_type == 'awards' || $item_type == 'all' ) $system_gifts = 1; |
| 44 | + if( $item_type == 'messages' || $item_type == 'all' ) $messages_sent = 1; |
| 45 | + if( $item_type == 'thoughts' || $item_type == 'all' ) $network_updates = 1; |
| 46 | + |
| 47 | + /* |
| 48 | + $output .= '<div class="user-home-links-container"> |
| 49 | + <h2>' . wfMsg('useractivity-filter') . '</h2> |
| 50 | + <div class="user-home-links">'; |
| 51 | + |
| 52 | + $lines = explode( "\n", wfMsgForContent( 'useractivity-filter' ) ); |
| 53 | + foreach( $lines as $line ) { |
| 54 | + |
| 55 | + if( strpos($line, '*') !== 0 ){ |
| 56 | + continue; |
| 57 | + } else { |
| 58 | + $line = explode( '|' , trim($line, '* '), 3 ); |
| 59 | + $filter = $line[0]; |
| 60 | + $link_text = $line[1]; |
| 61 | + $link_image = $line[2]; |
| 62 | + $output .= "<a href=\"" . $this_title->escapeFullURL("item_type={$filter}") . "\"> |
| 63 | + <img src=\"{$wgScriptPath}/extensions/SocialProfile/images/" . UserActivity::getTypeIcon($link_image) . "\"/>{$link_text} |
| 64 | + </a>"; |
| 65 | + } |
| 66 | + |
| 67 | + } |
| 68 | + |
| 69 | + $output .= '<a href="' . $this_title->escapeFullURL() . '">' . wfMsg( 'useractivity-all' ) . '</a> |
| 70 | + </div> |
| 71 | + </div> |
| 72 | + */ |
| 73 | + |
| 74 | + $output .= '<div class="user-home-feed">'; |
| 75 | + |
| 76 | + $rel = new UserActivity( $wgUser->getName(), ( ( $rel_type == 1 ) ? ' friends' : 'foes' ), 50 ); |
| 77 | + $rel->setActivityToggle( 'show_edits', $edits ); |
| 78 | + $rel->setActivityToggle( 'show_votes', $votes ); |
| 79 | + $rel->setActivityToggle( 'show_comments', $comments ); |
| 80 | + $rel->setActivityToggle( 'show_gifts_rec', $gifts ); |
| 81 | + $rel->setActivityToggle( 'show_relationships', $relationships ); |
| 82 | + $rel->setActivityToggle( 'show_system_messages', $messages ); |
| 83 | + $rel->setActivityToggle( 'show_system_gifts', $system_gifts ); |
| 84 | + $rel->setActivityToggle( 'show_messages_sent', $messages_sent ); |
| 85 | + |
| 86 | + // An extra toggle for ArmchairGM |
| 87 | + if( $wgSitename == 'ArmchairGM' ){ |
| 88 | + $rel->setActivityToggle( 'show_network_updates', $network_updates ); |
| 89 | + } |
| 90 | + |
| 91 | + /** |
| 92 | + * Get all relationship activity |
| 93 | + */ |
| 94 | + $activity = $rel->getActivityListGrouped(); |
| 95 | + $border_fix = ''; |
| 96 | + |
| 97 | + if( $activity ){ |
| 98 | + $x = 1; |
| 99 | + |
| 100 | + foreach( $activity as $item ) { |
| 101 | + |
| 102 | + if( $x < 40 ) { |
| 103 | + |
| 104 | + if( ( ( count( $activity ) > 40 ) && ( $x == 39 ) ) || ( ( count( $activity ) < 40 ) && ( $x == ( count( $activity )-1 ) ) ) ) { |
| 105 | + $border_fix = ' border-fix'; |
| 106 | + } |
| 107 | + |
| 108 | + $output .= "<div class=\"user-home-activity{$border_fix}\"> |
| 109 | + <img src=\"{$wgScriptPath}/extensions/SocialProfile/images/" . UserActivity::getTypeIcon( $item['type'] ) . "\" alt=\"\" border=\"0\" /> |
| 110 | + {$item["data"]} |
| 111 | + </div>"; |
| 112 | + $x++; |
| 113 | + } |
| 114 | + } |
| 115 | + } |
| 116 | + |
| 117 | + $output .= '</div> |
| 118 | + <div class="cleared"></div>'; |
| 119 | + $wgOut->addHTML( $output ); |
| 120 | + } |
| 121 | +} |
\ No newline at end of file |
Property changes on: trunk/extensions/SocialProfile/UserActivity/UserActivity.body.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 122 | + native |
Index: trunk/extensions/SocialProfile/UserActivity/UserActivity.i18n.php |
— | — | @@ -0,0 +1,60 @@ |
| 2 | +<?php |
| 3 | +/** |
| 4 | + * Internationalization file for UserActivity extension. |
| 5 | + * |
| 6 | + * @file |
| 7 | + * @ingroup Extensions |
| 8 | + */ |
| 9 | + |
| 10 | +$messages = array(); |
| 11 | + |
| 12 | +/** English |
| 13 | + * @author Aaron Wright |
| 14 | + * @author David Pean |
| 15 | + */ |
| 16 | +$messages['en'] = array( |
| 17 | + 'useractivity' => "Friend's Activity", |
| 18 | + 'useractivity-award' => 'received an award', |
| 19 | + 'useractivity-all' => 'View All', |
| 20 | + 'useractivity-gift' => 'received a gift from', |
| 21 | + 'useractivity-group-edit' => 'edits', |
| 22 | + 'useractivity-group-comment' => 'comments', |
| 23 | + 'useractivity-group-user_message' => 'messages', |
| 24 | + 'useractivity-group-friend' => 'friends', |
| 25 | + 'useractivity-filter' => 'Filter', |
| 26 | + 'useractivity-network-thought' => 'has a thought for the $1 network', |
| 27 | + 'useractivity-title' => "Friends' Activity", |
| 28 | + 'useractivity-siteactivity' => 'Site Activity', |
| 29 | + 'useractivity-edit' => '{{PLURAL:$1|edited the page|edited the following pages: }}', |
| 30 | + 'useractivity-comment' => '{{PLURAL:$1|commented on the page|commented on the following pages: }}', |
| 31 | + 'useractivity-user_message' => '{{PLURAL:$1|sent a message to|sent messages to}}', |
| 32 | + 'useractivity-votedpage' => 'voted for the page', |
| 33 | + 'useractivity-commentedpage' => 'commented on the page', |
| 34 | + 'useractivity-giftsent' => 'sent a gift to', |
| 35 | + 'useractivity-friend' => '{{PLURAL:$2|is now friends with|are now friends with}}', |
| 36 | + 'useractivity-foe' => '{{PLURAL:$2|is now foes with|are now foes with}}', |
| 37 | +); |
| 38 | + |
| 39 | +/** Finnish (Suomi) |
| 40 | + * @author Jack Phoenix <jack@countervandalism.net> |
| 41 | + */ |
| 42 | +$messages['fi'] = array( |
| 43 | + 'useractivity' => 'Ystävien aktiivisuus', |
| 44 | + 'useractivity-award' => 'sai palkinnon', |
| 45 | + 'useractivity-all' => 'Katso kaikki', |
| 46 | + 'useractivity-gift' => 'sai lahjan käyttäjältä', |
| 47 | + 'useractivity-group-edit' => 'muokkausta', |
| 48 | + 'useractivity-group-comment' => 'kommentit', |
| 49 | + 'useractivity-group-user_message' => 'viestit', |
| 50 | + 'useractivity-group-friend' => 'ystävät', |
| 51 | + 'useractivity-title' => 'Ystävien aktiivisuus', |
| 52 | + 'useractivity-siteactivity' => 'Sivuston aktiivisuus', |
| 53 | + 'useractivity-edit' => '{{PLURAL:$2|muokkasi|muokkasivat}} {{PLURAL:$1|sivua|seuraavia sivuja: }}', |
| 54 | + 'useractivity-comment' => '{{PLURAL:$1|kommentoi sivua|kommentoi seuraavia sivuja: }}', |
| 55 | + 'useractivity-user_message' => '{{PLURAL:$1|lähetti viestin käyttäjälle|lähetti viestejä käyttäjille}}', |
| 56 | + 'useractivity-votedpage' => 'äänesti sivua', |
| 57 | + 'useractivity-commentedpage' => 'kommentoi sivua', |
| 58 | + 'useractivity-giftsent' => 'lähetti lahjan käyttäjälle', |
| 59 | + 'useractivity-friend' => '{{PLURAL:$2|on nyt ystävä käyttäjälle|ovat nyt ystäviä käyttäjille}}', |
| 60 | + 'useractivity-foe' => '{{PLURAL:$2|on nyt vihollinen käyttäjälle|ovat nyt vihollisia käyttäjille}}', |
| 61 | +); |
\ No newline at end of file |
Property changes on: trunk/extensions/SocialProfile/UserActivity/UserActivity.i18n.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 62 | + native |
Index: trunk/extensions/SocialProfile/UserActivity/UserActivity.php |
— | — | @@ -0,0 +1,41 @@ |
| 2 | +<?php |
| 3 | +/** |
| 4 | + * UserActivity extension - shows users' social activity |
| 5 | + * |
| 6 | + * @file |
| 7 | + * @ingroup Extensions |
| 8 | + * @version 1.0 |
| 9 | + * @author Aaron Wright <aaron.wright@gmail.com> |
| 10 | + * @author David Pean <david.pean@gmail.com> |
| 11 | + * @author Jack Phoenix <jack@countervandalism.net> |
| 12 | + * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later |
| 13 | + */ |
| 14 | + |
| 15 | +/** |
| 16 | + * Protect against register_globals vulnerabilities. |
| 17 | + * This line must be present before any global variable is referenced. |
| 18 | + */ |
| 19 | +if( !defined( 'MEDIAWIKI' ) ){ |
| 20 | + die( "Not a valid entry point.\n" ); |
| 21 | +} |
| 22 | + |
| 23 | +// Extension credits that will show up on Special:Version |
| 24 | +$wgExtensionCredits['specialpage'][] = array( |
| 25 | + 'name' => 'UserActivity', |
| 26 | + 'version' => '1.0', |
| 27 | + 'description' => "Shows users' social activity", |
| 28 | + 'author' => array( 'Aaron Wright', 'David Pean', 'Jack Phoenix' ), |
| 29 | + 'url' => 'http://www.mediawiki.org/wiki/Extension:SocialProfile' |
| 30 | +); |
| 31 | + |
| 32 | +// Set up the new special page |
| 33 | +$dir = dirname( __FILE__ ) . '/'; |
| 34 | +$wgExtensionMessagesFiles['UserActivity'] = $dir . 'UserActivity.i18n.php'; |
| 35 | +$wgAutoloadClasses['UserActivity'] = $dir . 'UserActivityClass.php'; |
| 36 | +$wgAutoloadClasses['UserHome'] = $dir . 'UserActivity.body.php'; |
| 37 | +$wgSpecialPages['UserActivity'] = 'UserHome'; |
| 38 | +// Special page group for MW 1.13+ |
| 39 | +$wgSpecialPageGroups['UserActivity'] = 'users'; |
| 40 | + |
| 41 | +// Load <siteactivity> parser hook |
| 42 | +require_once('SiteActivityHook.php'); |
\ No newline at end of file |
Property changes on: trunk/extensions/SocialProfile/UserActivity/UserActivity.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 43 | + native |
Index: trunk/extensions/SocialProfile/UserActivity/UserActivity.css |
— | — | @@ -0,0 +1,84 @@ |
| 2 | +/* User Feed */ |
| 3 | +.user-home-feed { |
| 4 | + width: 60%; |
| 5 | + padding-top: 15px; |
| 6 | + float: left; |
| 7 | +} |
| 8 | + |
| 9 | +.user-home-links-container { |
| 10 | + float: right; |
| 11 | + padding-top: 15px; |
| 12 | + width: 170px; |
| 13 | + padding-top: 15px; |
| 14 | + margin: 2px 0px 0px 0px; |
| 15 | +} |
| 16 | + |
| 17 | +.user-home-links-container h2 { |
| 18 | + color: #333; |
| 19 | + font-size: 16px; |
| 20 | + border-bottom: 1px solid #dcdcdc; |
| 21 | + padding: 0px 0px 3px 0px; |
| 22 | + margin: 0px 0px 5px 0px !important; |
| 23 | +} |
| 24 | + |
| 25 | +.user-home-links-container a { |
| 26 | + display: block; |
| 27 | + padding: 4px 0px 4px 0px; |
| 28 | + text-decoration: none; |
| 29 | + font-weight: bold; |
| 30 | +} |
| 31 | + |
| 32 | +.user-home-links-container img { |
| 33 | + margin: 0px 4px 0px 0px; |
| 34 | + vertical-align: middle; |
| 35 | +} |
| 36 | + |
| 37 | +.user-home-friends-activity { |
| 38 | + padding: 0px 0px 15px 0px; |
| 39 | +} |
| 40 | + |
| 41 | +.user-home-friends-activity h2 { |
| 42 | + letter-spacing: -1px; |
| 43 | + color: #333; |
| 44 | + font-size: 18px; |
| 45 | + margin: 0px 0px 8px 0px !important; |
| 46 | +} |
| 47 | + |
| 48 | +.user-home-activity-timestamp { |
| 49 | + color: #999999; |
| 50 | + font-size: 9px; |
| 51 | + margin: 0px 0px 0px 6px; |
| 52 | +} |
| 53 | + |
| 54 | +.user-home-activity { |
| 55 | + border-bottom: 1px solid #dcdcdc; |
| 56 | + padding: 7px 0px; |
| 57 | +} |
| 58 | + |
| 59 | +.user-home-activity img { |
| 60 | + vertical-align: middle; |
| 61 | + margin: 0px 5px 0px 0px; |
| 62 | +} |
| 63 | + |
| 64 | +.user-home-activity a { |
| 65 | + text-decoration: none; |
| 66 | +} |
| 67 | + |
| 68 | +.border-fix { |
| 69 | + border: none !important; |
| 70 | +} |
| 71 | + |
| 72 | +.item { |
| 73 | + color: #666; |
| 74 | + margin: 2px 25px; |
| 75 | +} |
| 76 | + |
| 77 | +.item a { |
| 78 | + color: #666; |
| 79 | +} |
| 80 | + |
| 81 | +.item img { |
| 82 | + border: 1px solid #dcdcdc; |
| 83 | + padding: 1px; |
| 84 | + background-color: #fff; |
| 85 | +} |
\ No newline at end of file |
Property changes on: trunk/extensions/SocialProfile/UserActivity/UserActivity.css |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 86 | + native |
Index: trunk/extensions/SocialProfile/UserActivity/UserActivityClass.php |
— | — | @@ -0,0 +1,813 @@ |
| 2 | +<?php |
| 3 | +/** |
| 4 | + * UserActivity class |
| 5 | + * @todo FIXME: database queries should use Database class |
| 6 | + */ |
| 7 | +class UserActivity { |
| 8 | + |
| 9 | + /** |
| 10 | + * All member variables should be considered private |
| 11 | + * Please use the accessor functions |
| 12 | + */ |
| 13 | + |
| 14 | + /**#@+ |
| 15 | + * @private |
| 16 | + */ |
| 17 | + var $user_id; # Text form (spaces not underscores) of the main part |
| 18 | + var $user_name; # Text form (spaces not underscores) of the main part |
| 19 | + var $items; # Text form (spaces not underscores) of the main part |
| 20 | + var $rel_type; |
| 21 | + var $show_edits = 1; |
| 22 | + var $show_votes = 0; |
| 23 | + var $show_comments = 1; |
| 24 | + var $show_relationships = 1; |
| 25 | + var $show_gifts_sent = 0; |
| 26 | + var $show_gifts_rec = 1; |
| 27 | + var $show_system_gifts = 1; |
| 28 | + var $show_system_messages = 1; |
| 29 | + var $show_messages_sent = 1; |
| 30 | + var $show_network_updates = 0; |
| 31 | + |
| 32 | + /** |
| 33 | + * Constructor |
| 34 | + * @private |
| 35 | + */ |
| 36 | + /* private */ function __construct( $username, $filter, $item_max ) { |
| 37 | + if( $username ){ |
| 38 | + $title1 = Title::newFromDBkey( $username ); |
| 39 | + $this->user_name = $title1->getText(); |
| 40 | + $this->user_id = User::idFromName( $this->user_name ); |
| 41 | + } |
| 42 | + $this->setFilter( $filter ); |
| 43 | + $this->item_max = $item_max; |
| 44 | + $this->now = time(); |
| 45 | + $this->three_days_ago = $this->now - (60 * 60 * 24 * 3); |
| 46 | + $this->items_grouped = array(); |
| 47 | + } |
| 48 | + |
| 49 | + private function setFilter( $filter ){ |
| 50 | + if( strtoupper( $filter ) == 'USER' ) $this->show_current_user = true; |
| 51 | + if( strtoupper( $filter ) == 'FRIENDS' ) $this->rel_type = 1; |
| 52 | + if( strtoupper( $filter ) == 'FOES' ) $this->rel_type = 2; |
| 53 | + if( strtoupper( $filter ) == 'ALL' ) $this->show_all = true; |
| 54 | + } |
| 55 | + |
| 56 | + public function setActivityToggle( $name, $value ){ |
| 57 | + $this->$name = $value; |
| 58 | + } |
| 59 | + |
| 60 | + private function setEdits(){ |
| 61 | + $dbr = wfGetDB( DB_SLAVE ); |
| 62 | + $rel_sql = ''; |
| 63 | + $user_sql = ''; |
| 64 | + |
| 65 | + if( !empty( $this->rel_type ) ) { |
| 66 | + $rel_sql = " WHERE rc_user IN (SELECT r_user_id_relation FROM {$dbr->tableName( 'user_relationship' )} WHERE r_user_id={$this->user_id} AND r_type={$this->rel_type}) "; |
| 67 | + } |
| 68 | + |
| 69 | + if( !empty( $this->show_current_user ) ) { |
| 70 | + $user_sql = " WHERE rc_user = {$this->user_id}"; |
| 71 | + } |
| 72 | + |
| 73 | + $sql = "SELECT UNIX_TIMESTAMP(rc_timestamp) AS item_date, rc_title, rc_user, rc_user_text, rc_comment, rc_id, rc_minor, rc_new, |
| 74 | + rc_namespace, rc_cur_id, rc_this_oldid, rc_last_oldid |
| 75 | + FROM {$dbr->tableName( 'recentchanges' )} |
| 76 | + {$rel_sql} {$user_sql} |
| 77 | + ORDER BY rc_id DESC LIMIT 0," . $this->item_max; |
| 78 | + $res = $dbr->query( $sql ); |
| 79 | + |
| 80 | + while( $row = $dbr->fetchObject( $res ) ) { |
| 81 | + $title = Title::makeTitle( $row->rc_namespace, $row->rc_title ); |
| 82 | + $this->items_grouped['edit'][$title->getPrefixedText()]['users'][$row->rc_user_text][] = array( |
| 83 | + 'id' => 0, |
| 84 | + 'type' => 'edit', |
| 85 | + 'timestamp' => $row->item_date, |
| 86 | + 'pagetitle' => $row->rc_title, |
| 87 | + 'namespace' => $row->rc_namespace, |
| 88 | + 'username' => $row->rc_user_text, |
| 89 | + 'userid' => $row->rc_user, |
| 90 | + 'comment' => $this->fixItemComment( $row->rc_comment ), |
| 91 | + 'minor' => $row->rc_minor, |
| 92 | + 'new' => $row->rc_new |
| 93 | + ); |
| 94 | + |
| 95 | + // set last timestamp |
| 96 | + $this->items_grouped['edit'][$title->getPrefixedText()]['timestamp'] = $row->item_date; |
| 97 | + //$this->items['edits'][$title->getPrefixedText()]['displayed'] = 0; |
| 98 | + |
| 99 | + $this->items[] = array( |
| 100 | + 'id' => 0, |
| 101 | + 'type' => 'edit', |
| 102 | + 'timestamp' => ($row->item_date), |
| 103 | + 'pagetitle' => $row->rc_title, |
| 104 | + 'namespace' => $row->rc_namespace, |
| 105 | + 'username' => $row->rc_user_text, |
| 106 | + 'userid' => $row->rc_user, |
| 107 | + 'comment' => $this->fixItemComment( $row->rc_comment ), |
| 108 | + 'minor' => $row->rc_minor, |
| 109 | + 'new' => $row->rc_new |
| 110 | + ); |
| 111 | + } |
| 112 | + } |
| 113 | + |
| 114 | + private function setVotes(){ |
| 115 | + $dbr = wfGetDB( DB_SLAVE ); |
| 116 | + |
| 117 | + # Bail out if Vote table doesn't exist |
| 118 | + if( !$dbr->tableExists( 'Vote' ) ){ |
| 119 | + return false; |
| 120 | + } |
| 121 | + |
| 122 | + $rel_sql = ''; |
| 123 | + $user_sql = ''; |
| 124 | + if( $this->rel_type ) |
| 125 | + $rel_sql = " AND vote_user_id IN (SELECT r_user_id_relation FROM {$dbr->tableName( 'user_relationship' )} WHERE r_user_id={$this->user_id} AND r_type={$this->rel_type}) "; |
| 126 | + if( $this->show_current_user ) |
| 127 | + $user_sql = " AND vote_user_id = {$this->user_id}"; |
| 128 | + |
| 129 | + $sql = "SELECT UNIX_TIMESTAMP(vote_date) AS item_date, username, page_title, vote_count, comment_count, vote_ip, vote_user_id |
| 130 | + FROM {$dbr->tableName( 'Vote' )} v, {$dbr->tableName( 'page' )} p |
| 131 | + WHERE v.vote_page_id=p.page_id |
| 132 | + {$rel_sql} {$user_sql} |
| 133 | + ORDER BY vote_date DESC LIMIT 0," . $this->item_max; |
| 134 | + $res = $dbr->query($sql); |
| 135 | + while( $row = $dbr->fetchObject( $res ) ) { |
| 136 | + $username = $row->username; |
| 137 | + $this->items[] = array( |
| 138 | + 'id' => 0, |
| 139 | + 'type' => 'vote', |
| 140 | + 'timestamp' => $row->item_date, |
| 141 | + 'pagetitle' => $row->page_title, |
| 142 | + 'namespace' => $row->page_namespace, |
| 143 | + 'username' => $username, |
| 144 | + 'userid' => $row->vote_user_id, |
| 145 | + 'comment' => '-', |
| 146 | + 'new' => '0', |
| 147 | + 'minor' => 0 |
| 148 | + ); |
| 149 | + } |
| 150 | + } |
| 151 | + |
| 152 | + private function setComments(){ |
| 153 | + $dbr = wfGetDB( DB_SLAVE ); |
| 154 | + |
| 155 | + # Bail out if Comments table doesn't exist |
| 156 | + if( !$dbr->tableExists( 'Comments' ) ){ |
| 157 | + return false; |
| 158 | + } |
| 159 | + |
| 160 | + $rel_sql = ''; |
| 161 | + $user_sql = ''; |
| 162 | + |
| 163 | + if( !empty( $this->rel_type ) ) { |
| 164 | + $rel_sql = "AND Comment_user_id IN (SELECT r_user_id_relation FROM {$dbr->tableName( 'user_relationship' )} WHERE r_user_id={$this->user_id} AND r_type={$this->rel_type})"; |
| 165 | + } |
| 166 | + |
| 167 | + if( !empty( $this->show_current_user ) ) { |
| 168 | + $user_sql = "AND Comment_user_id = {$this->user_id}"; |
| 169 | + } |
| 170 | + |
| 171 | + $sql = "SELECT UNIX_TIMESTAMP(comment_date) AS item_date, Comment_Username, Comment_IP, page_title, Comment_Text, Comment_user_id, page_namespace, CommentID |
| 172 | + FROM {$dbr->tableName( 'Comments' )} c, {$dbr->tableName( 'page' )} p |
| 173 | + WHERE c.comment_page_id=p.page_id |
| 174 | + {$rel_sql} {$user_sql} |
| 175 | + ORDER BY comment_date DESC LIMIT 0," . $this->item_max; |
| 176 | + |
| 177 | + $res = $dbr->query($sql); |
| 178 | + global $wgFilterComments; |
| 179 | + while( $row = $dbr->fetchObject( $res ) ) { |
| 180 | + $show_comment = true; |
| 181 | + |
| 182 | + if( $wgFilterComments ){ |
| 183 | + if ( $row->vote_count <= 4 ){ |
| 184 | + $show_comment = false; |
| 185 | + } |
| 186 | + } |
| 187 | + |
| 188 | + if( $show_comment ) { |
| 189 | + $title = Title::makeTitle( $row->page_namespace, $row->page_title ); |
| 190 | + $this->items_grouped['comment'][$title->getPrefixedText()]['users'][$row->Comment_Username][] = array( |
| 191 | + 'id' => $row->CommentID, |
| 192 | + 'type' => 'comment', |
| 193 | + 'timestamp' => $row->item_date, |
| 194 | + 'pagetitle' => $row->page_title, |
| 195 | + 'namespace' => $row->page_namespace, |
| 196 | + 'username' => $row->Comment_Username, |
| 197 | + 'userid' => $row->Comment_user_id, |
| 198 | + 'comment' => $this->fixItemComment( $row->Comment_Text ), |
| 199 | + 'minor' => 0, |
| 200 | + 'new' => 0 |
| 201 | + ); |
| 202 | + |
| 203 | + // set last timestamp |
| 204 | + $this->items_grouped['comment'][$title->getPrefixedText()]['timestamp'] = $row->item_date; |
| 205 | + |
| 206 | + $username = $row->Comment_Username; |
| 207 | + $this->items[] = array( |
| 208 | + 'id' => $row->CommentID, |
| 209 | + 'type' => 'comment', |
| 210 | + 'timestamp' => $row->item_date, |
| 211 | + 'pagetitle' => $row->page_title, |
| 212 | + 'namespace' => $row->page_namespace, |
| 213 | + 'username' => $username, |
| 214 | + 'userid' => $row->Comment_user_id, |
| 215 | + 'comment' => $this->fixItemComment( $row->Comment_Text ), |
| 216 | + 'new' => '0', |
| 217 | + 'minor' => 0 |
| 218 | + ); |
| 219 | + } |
| 220 | + } |
| 221 | + } |
| 222 | + |
| 223 | + private function setGiftsSent(){ |
| 224 | + $dbr = wfGetDB( DB_SLAVE ); |
| 225 | + if( $this->rel_type ) |
| 226 | + $rel_sql = "WHERE ug_user_id_to IN (SELECT r_user_id_relation FROM {$dbr->tableName( 'user_relationship' )} WHERE r_user_id={$this->user_id} AND r_type={$this->rel_type})"; |
| 227 | + if( $this->show_current_user ) |
| 228 | + $user_sql = "WHERE ug_user_id_from = {$this->user_id}"; |
| 229 | + |
| 230 | + $sql = "SELECT ug_id, ug_user_id_from, ug_user_name_from, ug_user_id_to, ug_user_name_to, UNIX_TIMESTAMP(ug_date) AS item_date,gift_name, gift_id |
| 231 | + FROM {$dbr->tableName( 'user_gift' )} INNER JOIN {$dbr->tableName( 'gift' )} ON gift_id = ug_gift_id |
| 232 | + {$rel_sql} {$user_sql} |
| 233 | + ORDER BY ug_id DESC LIMIT 0,{$this->item_max}"; |
| 234 | + $res = $dbr->query($sql); |
| 235 | + while( $row = $dbr->fetchObject( $res ) ) { |
| 236 | + $this->items[] = array( |
| 237 | + 'id' => $row->ug_id, |
| 238 | + 'type' => 'gift-sent', |
| 239 | + 'timestamp' => $row->item_date, |
| 240 | + 'pagetitle' => $row->gift_name, |
| 241 | + 'namespace' => $row->gift_id, |
| 242 | + 'username' => $row->ug_user_name_from, |
| 243 | + 'userid' => $row->ug_user_id_from, |
| 244 | + 'comment' => $row->ug_user_name_to, |
| 245 | + 'new' => '0', |
| 246 | + 'minor' => 0 |
| 247 | + ); |
| 248 | + } |
| 249 | + } |
| 250 | + |
| 251 | + private function setGiftsRec(){ |
| 252 | + $dbr = wfGetDB( DB_SLAVE ); |
| 253 | + $rel_sql = ''; |
| 254 | + $user_sql = ''; |
| 255 | + |
| 256 | + if( !empty( $this->rel_type ) ) { |
| 257 | + $rel_sql = "WHERE ug_user_id_to in (SELECT r_user_id_relation FROM {$dbr->tableName( 'user_relationship' )} WHERE r_user_id={$this->user_id} AND r_type={$this->rel_type} )"; |
| 258 | + } |
| 259 | + |
| 260 | + if( !empty( $this->show_current_user ) ) { |
| 261 | + $user_sql = "WHERE ug_user_id_to = {$this->user_id}"; |
| 262 | + } |
| 263 | + |
| 264 | + $sql = "SELECT ug_id, ug_user_id_from, ug_user_name_from, ug_user_id_to, ug_user_name_to, UNIX_TIMESTAMP(ug_date) AS item_date,gift_name, gift_id |
| 265 | + FROM {$dbr->tableName( 'user_gift' )} INNER JOIN {$dbr->tableName( 'gift' )} ON gift_id = ug_gift_id |
| 266 | + {$rel_sql} {$user_sql} |
| 267 | + ORDER BY ug_id DESC LIMIT 0,{$this->item_max}"; |
| 268 | + $res = $dbr->query($sql); |
| 269 | + while( $row = $dbr->fetchObject( $res ) ) { |
| 270 | + global $wgUploadPath; |
| 271 | + $user_title = Title::makeTitle( NS_USER, $row->ug_user_name_to ); |
| 272 | + $user_title_from = Title::makeTitle( NS_USER, $row->ug_user_name_from ); |
| 273 | + |
| 274 | + $gift_image = '<img src="' . $wgUploadPath . '/awards/' . Gifts::getGiftImage( $row->gift_id, 'm' ) . '" border="0" alt="" />'; |
| 275 | + $view_gift_link = SpecialPage::getTitleFor( 'ViewGift' ); |
| 276 | + |
| 277 | + $html = wfMsg( 'useractivity-gift' ) . ' ' . "<a href=\"{$user_title_from->escapeFullURL()}\" rel=\"nofollow\">{$user_title_from->getText()}</a> |
| 278 | + <div class=\"item\"> |
| 279 | + <a href=\"" . $view_gift_link->escapeFullURL( 'gift_id=' . $row->ug_id ) . "\" rel=\"nofollow\"> |
| 280 | + {$gift_image} |
| 281 | + {$row->gift_name} |
| 282 | + </a> |
| 283 | + </div>"; |
| 284 | + |
| 285 | + $this->activityLines[] = array( |
| 286 | + 'type' => 'gift-rec', |
| 287 | + 'timestamp' => $row->item_date, |
| 288 | + 'data' => "<b><a href=\"{$user_title->escapeFullURL()}\">{$row->ug_user_name_to}</a></b> {$html}" |
| 289 | + ); |
| 290 | + |
| 291 | + $this->items[] = array( |
| 292 | + 'id' => $row->ug_id, |
| 293 | + 'type' => 'gift-rec', |
| 294 | + 'timestamp' => $row->item_date, |
| 295 | + 'pagetitle' => $row->gift_name, |
| 296 | + 'namespace' => $row->gift_id, |
| 297 | + 'username' => $row->ug_user_name_to, |
| 298 | + 'userid' => $row->ug_user_id_to, |
| 299 | + 'comment' => $row->ug_user_name_from, |
| 300 | + 'new' => '0', |
| 301 | + 'minor' => 0 |
| 302 | + ); |
| 303 | + } |
| 304 | + } |
| 305 | + |
| 306 | + private function setSystemGiftsRec(){ |
| 307 | + $dbr = wfGetDB( DB_SLAVE ); |
| 308 | + $rel_sql = ''; |
| 309 | + $user_sql = ''; |
| 310 | + |
| 311 | + if( !empty( $this->rel_type ) ) { |
| 312 | + $rel_sql = "WHERE sg_user_id in (SELECT r_user_id_relation FROM {$dbr->tableName( 'user_relationship' )} WHERE r_user_id={$this->user_id} AND r_type={$this->rel_type} )"; |
| 313 | + } |
| 314 | + |
| 315 | + if( !empty( $this->show_current_user ) ) { |
| 316 | + $user_sql = "WHERE sg_user_id = {$this->user_id}"; |
| 317 | + } |
| 318 | + |
| 319 | + $sql = "SELECT sg_id, sg_user_id, sg_user_name, UNIX_TIMESTAMP(sg_date) AS item_date,gift_name, gift_id |
| 320 | + FROM {$dbr->tableName( 'user_system_gift' )} INNER JOIN {$dbr->tableName( 'system_gift' )} ON gift_id = sg_gift_id |
| 321 | + {$rel_sql} {$user_sql} |
| 322 | + ORDER BY sg_id DESC LIMIT 0,{$this->item_max}"; |
| 323 | + $res = $dbr->query($sql); |
| 324 | + while( $row = $dbr->fetchObject( $res ) ) { |
| 325 | + global $wgUploadPath; |
| 326 | + $user_title = Title::makeTitle( NS_USER, $row->sg_user_name ); |
| 327 | + $system_gift_image = '<img src="' . $wgUploadPath . '/awards/' . SystemGifts::getGiftImage( $row->gift_id, 'm' ) . '" border="0" alt="" />'; |
| 328 | + $system_gift_link = SpecialPage::getTitleFor( 'ViewSystemGift' ); |
| 329 | + |
| 330 | + $html = wfMsg( 'useractivity-award' ) . " |
| 331 | + <div class=\"item\"> |
| 332 | + <a href=\"" . $system_gift_link->escapeFullURL( 'gift_id=' . $row->sg_id ) . "\" rel=\"nofollow\"> |
| 333 | + {$system_gift_image} |
| 334 | + {$row->gift_name} |
| 335 | + </a> |
| 336 | + </div>"; |
| 337 | + |
| 338 | + $this->activityLines[] = array( |
| 339 | + 'type' => 'system_gift', |
| 340 | + 'timestamp' => $row->item_date, |
| 341 | + 'data' => "<b><a href=\"{$user_title->escapeFullURL()}\">{$row->sg_user_name}</a></b> {$html}" |
| 342 | + ); |
| 343 | + |
| 344 | + $this->items[] = array( |
| 345 | + 'id' => $row->sg_id, |
| 346 | + 'type' => 'system_gift', |
| 347 | + 'timestamp' => $row->item_date, |
| 348 | + 'pagetitle' => $row->gift_name, |
| 349 | + 'namespace' => $row->gift_id, |
| 350 | + 'username' => $row->sg_user_name, |
| 351 | + 'userid' => $row->sg_user_id, |
| 352 | + 'comment' => '-', |
| 353 | + 'new' => '0', |
| 354 | + 'minor' => 0 |
| 355 | + ); |
| 356 | + } |
| 357 | + } |
| 358 | + |
| 359 | + private function setRelationships(){ |
| 360 | + $dbr = wfGetDB( DB_SLAVE ); |
| 361 | + if( !empty( $this->rel_type ) ) { |
| 362 | + $rel_sql = "WHERE r_user_id in (SELECT r_user_id_relation FROM {$dbr->tableName( 'user_relationship' )} WHERE r_user_id={$this->user_id} AND r_type={$this->rel_type} )"; |
| 363 | + } else { |
| 364 | + $rel_sql = ''; |
| 365 | + } |
| 366 | + if( !empty( $this->show_current_user ) ) { |
| 367 | + $user_sql = "WHERE r_user_id = {$this->user_id}"; |
| 368 | + } else { |
| 369 | + $user_sql = ''; |
| 370 | + } |
| 371 | + $sql = "SELECT r_id, r_user_id, r_user_name, r_user_id_relation, r_user_name_relation, r_type, UNIX_TIMESTAMP(r_date) AS item_date |
| 372 | + FROM {$dbr->tableName( 'user_relationship' )} |
| 373 | + {$rel_sql} {$user_sql} |
| 374 | + ORDER BY r_id DESC LIMIT 0,{$this->item_max}"; |
| 375 | + $res = $dbr->query($sql); |
| 376 | + |
| 377 | + while( $row = $dbr->fetchObject( $res ) ) { |
| 378 | + if( $row->r_type == 1 ){ |
| 379 | + $r_type = 'friend'; |
| 380 | + } else { |
| 381 | + $r_type = 'foe'; |
| 382 | + } |
| 383 | + |
| 384 | + $user_name_short = substr( $row->r_user_name, 0, 25 ); |
| 385 | + if( $row->r_user_name != $user_name_short ) |
| 386 | + $user_name_short.= '...'; |
| 387 | + |
| 388 | + //$title = Title::makeTitle( $row->page_namespace, $row->page_title ); |
| 389 | + $this->items_grouped[$r_type][$row->r_user_name_relation]['users'][$row->r_user_name][] = array( |
| 390 | + 'id' => $row->r_id, |
| 391 | + 'type' => $r_type, |
| 392 | + 'timestamp' => $row->item_date, |
| 393 | + 'pagetitle' => '', |
| 394 | + 'namespace' => '', |
| 395 | + 'username' => $user_name_short, |
| 396 | + 'userid' => $row->r_user_id, |
| 397 | + 'comment' => $row->r_user_name_relation, |
| 398 | + 'minor' => 0, |
| 399 | + 'new' => 0 |
| 400 | + ); |
| 401 | + |
| 402 | + // set last timestamp |
| 403 | + $this->items_grouped[$r_type][$row->r_user_name_relation]['timestamp'] = $row->item_date; |
| 404 | + |
| 405 | + $this->items[] = array( |
| 406 | + 'id' => $row->r_id, |
| 407 | + 'type' => $r_type, |
| 408 | + 'timestamp' => $row->item_date, |
| 409 | + 'pagetitle' => '', |
| 410 | + 'namespace' => '', |
| 411 | + 'username' => $row->r_user_name, |
| 412 | + 'userid' => $row->r_user_id, |
| 413 | + 'comment' => $row->r_user_name_relation, |
| 414 | + 'new' => '0', |
| 415 | + 'minor' => 0 |
| 416 | + ); |
| 417 | + } |
| 418 | + } |
| 419 | + |
| 420 | + private function setMessagesSent(){ |
| 421 | + $dbr = wfGetDB( DB_SLAVE ); |
| 422 | + $rel_sql = ''; |
| 423 | + $user_sql = ''; |
| 424 | + |
| 425 | + if( !empty( $this->rel_type ) ) { |
| 426 | + $rel_sql = " ub_user_id_from IN (SELECT r_user_id_relation FROM {$dbr->tableName( 'user_relationship' )} WHERE r_user_id={$this->user_id} AND r_type={$this->rel_type} ) AND"; |
| 427 | + } |
| 428 | + |
| 429 | + if( !empty( $this->show_current_user ) ) { |
| 430 | + $user_sql = " ub_user_id_from = {$this->user_id} AND"; |
| 431 | + } |
| 432 | + |
| 433 | + $sql = "SELECT ub_id, ub_user_id, ub_user_name, ub_user_id_from, ub_user_name_from, UNIX_TIMESTAMP(ub_date) AS item_date, ub_message |
| 434 | + FROM {$dbr->tableName( 'user_board' )} WHERE |
| 435 | + {$rel_sql} {$user_sql} ub_type=0 |
| 436 | + ORDER BY ub_id DESC LIMIT 0,{$this->item_max}"; |
| 437 | + |
| 438 | + $res = $dbr->query($sql); |
| 439 | + while( $row = $dbr->fetchObject( $res ) ) { |
| 440 | + |
| 441 | + $this->items_grouped['user_message'][stripslashes($row->ub_user_name)]['users'][stripslashes($row->ub_user_name_from)][] = array( |
| 442 | + 'id' => $row->ub_id, |
| 443 | + 'type' => 'user_message', |
| 444 | + 'timestamp' => $row->item_date, |
| 445 | + 'pagetitle' => '', |
| 446 | + 'namespace' => '', |
| 447 | + 'username' => stripslashes( $row->ub_user_name_from ), |
| 448 | + 'userid' => $row->ub_user_id_from, |
| 449 | + 'comment' => stripslashes( $row->ub_user_name ), |
| 450 | + 'minor' => 0, |
| 451 | + 'new' => 0 |
| 452 | + ); |
| 453 | + |
| 454 | + // set last timestamp |
| 455 | + $this->items_grouped['user_message'][stripslashes($row->ub_user_name)]['timestamp'] = $row->item_date; |
| 456 | + |
| 457 | + $this->items[] = array( |
| 458 | + 'id' => $row->ub_id, |
| 459 | + 'type' => 'user_message', |
| 460 | + 'timestamp' => $row->item_date, |
| 461 | + 'pagetitle' => '', |
| 462 | + 'namespace' => $this->fixItemComment( $row->ub_message ), |
| 463 | + 'username' => stripslashes( $row->ub_user_name_from ), |
| 464 | + 'userid' => $row->ub_user_id_from, |
| 465 | + 'comment' => stripslashes( $row->ub_user_name ), |
| 466 | + 'new' => '0', |
| 467 | + 'minor' => 0 |
| 468 | + ); |
| 469 | + } |
| 470 | + } |
| 471 | + |
| 472 | + private function setSystemMessages(){ |
| 473 | + $dbr = wfGetDB( DB_SLAVE ); |
| 474 | + $rel_sql = ''; |
| 475 | + $user_sql = ''; |
| 476 | + |
| 477 | + if( !empty( $this->rel_type ) ) { |
| 478 | + $rel_sql = " WHERE um_user_id in (SELECT r_user_id_relation FROM {$dbr->tableName( 'user_relationship' )} WHERE r_user_id={$this->user_id} AND r_type={$this->rel_type} )"; |
| 479 | + } |
| 480 | + |
| 481 | + if( !empty( $this->show_current_user ) ) { |
| 482 | + $user_sql = " WHERE um_user_id = {$this->user_id}"; |
| 483 | + } |
| 484 | + |
| 485 | + $sql = "SELECT um_id, um_user_id, um_user_name, um_type, um_message, UNIX_TIMESTAMP(um_date) AS item_date |
| 486 | + FROM {$dbr->tableName( 'user_system_messages' )} |
| 487 | + {$rel_sql} {$user_sql} |
| 488 | + ORDER BY um_id DESC LIMIT 0,{$this->item_max}"; |
| 489 | + $res = $dbr->query($sql); |
| 490 | + while( $row = $dbr->fetchObject( $res ) ) { |
| 491 | + $user_title = Title::makeTitle( NS_USER, $row->um_user_name ); |
| 492 | + $user_name_short = substr( $row->um_user_name, 0, 15 ); |
| 493 | + if( $row->um_user_name != $user_name_short ) |
| 494 | + $user_name_short.= '...'; |
| 495 | + $this->activityLines[] = array( |
| 496 | + 'type' => 'system_message', |
| 497 | + 'timestamp' => $row->item_date, |
| 498 | + 'data' => "<b><a href=\"{$user_title->escapeFullURL()}\">{$user_name_short}</a></b> {$row->um_message}" |
| 499 | + ); |
| 500 | + |
| 501 | + $this->items[] = array( |
| 502 | + 'id' => $row->um_id, |
| 503 | + 'type' => 'system_message', |
| 504 | + 'timestamp' => $row->item_date, |
| 505 | + 'pagetitle' => '', |
| 506 | + 'namespace' => '', |
| 507 | + 'username' => $row->um_user_name, |
| 508 | + 'userid' => $row->um_user_id, |
| 509 | + 'comment' => $row->um_message, |
| 510 | + 'new' => '0', |
| 511 | + 'minor' => 0 |
| 512 | + ); |
| 513 | + } |
| 514 | + } |
| 515 | + |
| 516 | + /** |
| 517 | + * Retrieves sport network updates from the database (for ArmchairGM) |
| 518 | + */ |
| 519 | + private function setNetworkUpdates(){ |
| 520 | + $dbr = wfGetDB( DB_SLAVE ); |
| 521 | + if( $this->rel_type ) |
| 522 | + $rel_sql = " WHERE us_user_id IN (SELECT r_user_id_relation FROM {$dbr->tableName( 'user_relationship' )} WHERE r_user_id={$this->user_id} AND r_type={$this->rel_type} )"; |
| 523 | + if( $this->show_current_user ) |
| 524 | + $user_sql = " WHERE us_user_id = {$this->user_id}"; |
| 525 | + $sql = "SELECT us_id, us_user_id, us_user_name, us_text, UNIX_TIMESTAMP(us_date) AS item_date, |
| 526 | + us_sport_id, us_team_id |
| 527 | + FROM {$dbr->tableName( 'user_status' )} |
| 528 | + {$rel_sql} {$user_sql} |
| 529 | + ORDER BY us_id DESC LIMIT 0,{$this->item_max}"; |
| 530 | + $res = $dbr->query($sql); |
| 531 | + while( $row = $dbr->fetchObject( $res ) ) { |
| 532 | + if( $row->us_team_id ){ |
| 533 | + $team = SportsTeams::getTeam( $row->us_team_id ); |
| 534 | + $network_name = $team['name']; |
| 535 | + } else { |
| 536 | + $sport = SportsTeams::getSport( $row->us_sport_id ); |
| 537 | + $network_name = $sport['name']; |
| 538 | + } |
| 539 | + $this->items[] = array( |
| 540 | + 'id' => $row->us_id, |
| 541 | + 'type' => 'network_update', |
| 542 | + 'timestamp' => $row->item_date, |
| 543 | + 'pagetitle' => '', |
| 544 | + 'namespace' => '', |
| 545 | + 'username' => $row->us_user_name, |
| 546 | + 'userid' => $row->us_user_id, |
| 547 | + 'comment' => $row->us_text, |
| 548 | + 'sport_id' => $row->us_sport_id, |
| 549 | + 'team_id' => $row->us_team_id, |
| 550 | + 'network' => $network_name |
| 551 | + ); |
| 552 | + |
| 553 | + $user_title = Title::makeTitle( NS_USER, $row->us_user_name ); |
| 554 | + $user_name_short = substr( $row->us_user_name, 0, 15 ); |
| 555 | + if( $row->us_user_name != $user_name_short ) |
| 556 | + $user_name_short.= '...'; |
| 557 | + $page_link = '<a href="' . SportsTeams::getNetworkURL( $row->us_sport_id, $row->us_team_id ) . "\" rel=\"nofollow\">{$network_name}</a> "; |
| 558 | + $network_image = SportsTeams::getLogo( $row->us_sport_id, $row->us_team_id, 's' ); |
| 559 | + |
| 560 | + $html = wfMsg( 'useractivity-network-thought', $page_link ) . ' |
| 561 | + <div class="item"> |
| 562 | + <a href="' . SportsTeams::getNetworkURL( $row->us_sport_id, $row->us_team_id ) . "\" rel=\"nofollow\"> |
| 563 | + {$network_image} |
| 564 | + \"{$row->us_text}\" |
| 565 | + </a> |
| 566 | + </div>"; |
| 567 | + |
| 568 | + $this->activityLines[] = array( |
| 569 | + 'type' => 'network_update', |
| 570 | + 'timestamp' => $row->item_date, |
| 571 | + 'data' => "<b><a href=\"{$user_title->escapeFullURL()}\">{$user_name_short}</a></b> {$html}" |
| 572 | + ); |
| 573 | + |
| 574 | + } |
| 575 | + } |
| 576 | + |
| 577 | + public function getEdits(){ |
| 578 | + $this->setEdits(); |
| 579 | + return $this->items; |
| 580 | + } |
| 581 | + |
| 582 | + public function getVotes(){ |
| 583 | + $this->setVotes(); |
| 584 | + return $this->items; |
| 585 | + } |
| 586 | + |
| 587 | + public function getComments(){ |
| 588 | + $this->setComments(); |
| 589 | + return $this->items; |
| 590 | + } |
| 591 | + |
| 592 | + public function getGiftsSent(){ |
| 593 | + $this->setGiftsSent(); |
| 594 | + return $this->items; |
| 595 | + } |
| 596 | + |
| 597 | + public function getGiftsRec(){ |
| 598 | + $this->setGiftsRec(); |
| 599 | + return $this->items; |
| 600 | + } |
| 601 | + |
| 602 | + public function getSystemGiftsRec(){ |
| 603 | + $this->setSystemGiftsRec(); |
| 604 | + return $this->items; |
| 605 | + } |
| 606 | + |
| 607 | + public function getRelationships(){ |
| 608 | + $this->setRelationships(); |
| 609 | + return $this->items; |
| 610 | + } |
| 611 | + |
| 612 | + public function getSystemMessages(){ |
| 613 | + $this->setSystemMessages(); |
| 614 | + return $this->items; |
| 615 | + } |
| 616 | + |
| 617 | + public function getMessagesSent(){ |
| 618 | + $this->setMessagesSent(); |
| 619 | + return $this->items; |
| 620 | + } |
| 621 | + |
| 622 | + public function getNetworkUpdates(){ |
| 623 | + $this->setNetworkUpdates(); |
| 624 | + return $this->items; |
| 625 | + } |
| 626 | + |
| 627 | + public function getActivityList(){ |
| 628 | + if( $this->show_edits ) $this->setEdits(); |
| 629 | + if( $this->show_votes ) $this->setVotes(); |
| 630 | + if( $this->show_comments ) $this->setComments(); |
| 631 | + if( $this->show_gifts_sent ) $this->setGiftsSent(); |
| 632 | + if( $this->show_gifts_rec ) $this->setGiftsRec(); |
| 633 | + if( $this->show_relationships ) $this->setRelationships(); |
| 634 | + if( $this->show_system_messages ) $this->getSystemMessages(); |
| 635 | + if( $this->show_system_gifts ) $this->getSystemGiftsRec(); |
| 636 | + if( $this->show_messages_sent ) $this->getMessagesSent(); |
| 637 | + if( $this->show_network_updates ) $this->getNetworkUpdates(); |
| 638 | + |
| 639 | + if( $this->items ) |
| 640 | + usort( $this->items, array( 'UserActivity', 'sortItems' ) ); |
| 641 | + return $this->items; |
| 642 | + } |
| 643 | + |
| 644 | + public function getActivityListGrouped(){ |
| 645 | + $this->getActivityList(); |
| 646 | + |
| 647 | + if( $this->show_edits ) $this->simplifyPageActivity( 'edit' ); |
| 648 | + if( $this->show_comments ) $this->simplifyPageActivity( 'comment' ); |
| 649 | + if( $this->show_relationships ) $this->simplifyPageActivity( 'friend' ); |
| 650 | + if( $this->show_relationships ) $this->simplifyPageActivity( 'foe' ); |
| 651 | + if( $this->show_messages_sent ) $this->simplifyPageActivity( 'user_message' ); |
| 652 | + //if( $this->show_system_messages ) $this->simplifyPageActivity( 'system_messages', false ); |
| 653 | + |
| 654 | + if( !isset( $this->activityLines ) ) { |
| 655 | + $this->activityLines = array(); |
| 656 | + } |
| 657 | + if( isset( $this->activityLines ) && is_array( $this->activityLines ) ) |
| 658 | + usort( $this->activityLines, array( 'UserActivity', 'sortItems' ) ); |
| 659 | + return $this->activityLines; |
| 660 | + } |
| 661 | + |
| 662 | + function simplifyPageActivity( $type, $has_page = true ){ |
| 663 | + if( !isset( $this->items_grouped[$type] ) || !is_array( $this->items_grouped[$type] ) ){ |
| 664 | + return ''; |
| 665 | + } |
| 666 | + |
| 667 | + foreach( $this->items_grouped[$type] as $page_name => $page_data ){ |
| 668 | + $users = ''; |
| 669 | + $pages = ''; |
| 670 | + |
| 671 | + if( $type == 'friend' || $type == 'foe' || $type == 'user_message' ) { |
| 672 | + $page_title = Title::newFromText( 'User:' . $page_name ); |
| 673 | + } else { |
| 674 | + $page_title = Title::newFromText( $page_name ); |
| 675 | + } |
| 676 | + |
| 677 | + $count_users = count( $page_data['users'] ); |
| 678 | + $user_index = 0; |
| 679 | + $pages_count = 0; |
| 680 | + |
| 681 | + foreach( $page_data['users'] as $user_name => $action ){ |
| 682 | + |
| 683 | + if( $page_data['timestamp'] < $this->three_days_ago ){ |
| 684 | + continue; |
| 685 | + } |
| 686 | + |
| 687 | + $count_actions = count( $action ); |
| 688 | + |
| 689 | + if( $has_page && !isset( $this->displayed[$type][$page_name] ) ){ |
| 690 | + |
| 691 | + $this->displayed[ $type ][ $page_name ] = 1; |
| 692 | + |
| 693 | + $pages .= " <a href=\"{$page_title->escapeFullURL()}\">{$page_name}</a>"; |
| 694 | + if( $count_users == 1 && $count_actions > 1 ){ |
| 695 | + $pages .= " ($count_actions " . wfMsg( "useractivity-group-{$type}" ) . ")"; |
| 696 | + } |
| 697 | + $pages_count++; |
| 698 | + } |
| 699 | + |
| 700 | + // Single user on this action, |
| 701 | + // see if we can stack any other singles |
| 702 | + if( $count_users == 1 ){ |
| 703 | + foreach( $this->items_grouped[$type] as $page_name2 => $page_data2 ){ |
| 704 | + |
| 705 | + if( !isset( $this->displayed[$type][$page_name2] ) && count( $page_data2['users'] ) == 1 ) { |
| 706 | + |
| 707 | + foreach( $page_data2['users'] as $user_name2 => $action2 ){ |
| 708 | + |
| 709 | + if( $user_name2 == $user_name && $pages_count < 5 ){ |
| 710 | + $count_actions2 = count( $action2 ); |
| 711 | + |
| 712 | + if( $type == 'friend' || $type == 'foe' || $type == 'user_message' ) { |
| 713 | + $page_title2 = Title::newFromText( 'User:' . $page_name2 ); |
| 714 | + } else { |
| 715 | + $page_title2 = Title::newFromText( $page_name2 ); |
| 716 | + } |
| 717 | + |
| 718 | + if( $pages ) |
| 719 | + $pages .= ", "; |
| 720 | + $pages .= " <a href=\"{$page_title2->escapeFullURL()}\">{$page_name2}</a>"; |
| 721 | + if( $count_actions2 > 1 ){ |
| 722 | + $pages .= " ($count_actions2 " . wfMsg( "useractivity-group-{$type}" ) . ")"; |
| 723 | + } |
| 724 | + $pages_count++; |
| 725 | + |
| 726 | + $this->displayed[$type][$page_name2] = 1; |
| 727 | + } |
| 728 | + } |
| 729 | + } |
| 730 | + } |
| 731 | + } |
| 732 | + |
| 733 | + $user_index++; |
| 734 | + |
| 735 | + if( $users && $count_users > 2 ) |
| 736 | + $users .= ', '; |
| 737 | + if( $user_index == $count_users && $count_users > 1 ) |
| 738 | + $users .= wfMsg( 'and' ); |
| 739 | + |
| 740 | + $user_title = Title::makeTitle( NS_USER, $user_name ); |
| 741 | + $user_name_short = substr( $user_name, 0, 15 ); |
| 742 | + if( $user_name != $user_name_short ) |
| 743 | + $user_name_short.= '...'; |
| 744 | + |
| 745 | + $users .= " <b><a href=\"{$user_title->escapeFullURL()}\">{$user_name_short}</a></b>"; |
| 746 | + } |
| 747 | + if( $pages || $has_page == false ){ |
| 748 | + $this->activityLines[] = array( |
| 749 | + 'type' => $type, |
| 750 | + 'timestamp' => $page_data['timestamp'], |
| 751 | + 'data' => $users . ' ' . wfMsgExt( "useractivity-{$type}", 'parsemag', $pages_count, $count_users ) . $pages |
| 752 | + ); |
| 753 | + } |
| 754 | + } |
| 755 | + } |
| 756 | + |
| 757 | + static function getTypeIcon( $type ){ |
| 758 | + switch( $type ) { |
| 759 | + case 'edit': |
| 760 | + return 'editIcon.gif'; |
| 761 | + case 'vote': |
| 762 | + return 'voteIcon.gif'; |
| 763 | + case 'comment': |
| 764 | + return 'comment.gif'; |
| 765 | + case 'gift-sent': |
| 766 | + return 'icon_package.gif'; |
| 767 | + case 'gift-rec': |
| 768 | + return 'icon_package_get.gif'; |
| 769 | + case 'friend': |
| 770 | + return 'addedFriendIcon.png'; |
| 771 | + case 'foe': |
| 772 | + return 'addedFoeIcon.png'; |
| 773 | + case 'challenge_sent': |
| 774 | + return 'challengeIcon.png'; |
| 775 | + case 'challenge_rec': |
| 776 | + return 'challengeIcon.png'; |
| 777 | + case 'system_message': |
| 778 | + return 'challengeIcon.png'; |
| 779 | + case 'system_gift': |
| 780 | + return 'awardIcon.png'; |
| 781 | + case 'user_message': |
| 782 | + return 'emailIcon.gif'; |
| 783 | + case 'network_update': |
| 784 | + return 'note.gif'; |
| 785 | + } |
| 786 | + } |
| 787 | + |
| 788 | + function fixItemComment( $comment ){ |
| 789 | + if( !$comment ){ |
| 790 | + return ''; |
| 791 | + } else { |
| 792 | + $comment = str_replace( "<", "<", $comment ); |
| 793 | + $comment = str_replace( ">", ">", $comment ); |
| 794 | + $comment = str_replace( "&", "%26", $comment ); |
| 795 | + $comment = str_replace( "%26quot;", "\"", $comment ); |
| 796 | + } |
| 797 | + $preview = substr( $comment, 0, 75 ); |
| 798 | + if( $preview != $comment ){ |
| 799 | + $preview .= '...'; |
| 800 | + } |
| 801 | + return stripslashes( $preview ); |
| 802 | + } |
| 803 | + |
| 804 | + private function sortItems( $x, $y ){ |
| 805 | + if( $x['timestamp'] == $y['timestamp'] ){ |
| 806 | + return 0; |
| 807 | + } else if( $x['timestamp'] > $y['timestamp'] ){ |
| 808 | + return -1; |
| 809 | + } else { |
| 810 | + return 1; |
| 811 | + } |
| 812 | + } |
| 813 | + |
| 814 | +} |
\ No newline at end of file |
Property changes on: trunk/extensions/SocialProfile/UserActivity/UserActivityClass.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 815 | + native |
Index: trunk/extensions/SocialProfile/UserActivity/SiteActivityHook.php |
— | — | @@ -0,0 +1,66 @@ |
| 2 | +<?php |
| 3 | +/** |
| 4 | + * Protect against register_globals vulnerabilities. |
| 5 | + * This line must be present before any global variable is referenced. |
| 6 | + */ |
| 7 | +if( !defined( 'MEDIAWIKI' ) ){ |
| 8 | + die( "Not a valid entry point.\n" ); |
| 9 | +} |
| 10 | + |
| 11 | +// Avoid unstubbing $wgParser on setHook() too early on modern (1.12+) MW versions, as per r35980 |
| 12 | +if ( defined( 'MW_SUPPORTS_PARSERFIRSTCALLINIT' ) ) { |
| 13 | + $wgHooks['ParserFirstCallInit'][] = 'wfSiteActivity'; |
| 14 | +} else { |
| 15 | + $wgExtensionFunctions[] = 'wfSiteActivity'; |
| 16 | +} |
| 17 | + |
| 18 | +function wfSiteActivity() { |
| 19 | + global $wgParser; |
| 20 | + $wgParser->setHook( 'siteactivity', 'getSiteActivity' ); |
| 21 | + return true; |
| 22 | +} |
| 23 | + |
| 24 | +function getSiteActivity( $input, $args, &$parser ){ |
| 25 | + global $wgMemc, $wgScriptPath; |
| 26 | + |
| 27 | + $parser->disableCache(); |
| 28 | + |
| 29 | + $limit = ( isset( $args['limit'] ) && is_numeric( $args['limit'] ) ) ? $args['limit'] : 10; |
| 30 | + |
| 31 | + wfLoadExtensionMessages( 'UserActivity' ); |
| 32 | + |
| 33 | + $key = wfMemcKey( 'site_activity', 'all', $limit ); |
| 34 | + $data = $wgMemc->get( $key ); |
| 35 | + if( !$data ){ |
| 36 | + wfDebug( "Got site activity from DB\n" ); |
| 37 | + $rel = new UserActivity( '', 'ALL', $limit ); |
| 38 | + |
| 39 | + $rel->setActivityToggle( 'show_votes', 0 ); |
| 40 | + $rel->setActivityToggle( 'show_network_updates', 0 ); |
| 41 | + $activity = $rel->getActivityListGrouped(); |
| 42 | + $wgMemc->set( $key, $activity, 60 * 2 ); |
| 43 | + } else { |
| 44 | + wfDebug( "Got site activity from cache\n" ); |
| 45 | + $activity = $data; |
| 46 | + } |
| 47 | + |
| 48 | + $output = ''; |
| 49 | + if( $activity ) { |
| 50 | + |
| 51 | + $output .= '<div class="mp-site-activity"><h2>' . wfMsg( 'useractivity-siteactivity' ) . '</h2>'; |
| 52 | + |
| 53 | + $x = 1; |
| 54 | + foreach ( $activity as $item ) { |
| 55 | + if( $x < $limit ) { |
| 56 | + $output .= '<div class="mp-activity' . ( ( $x == $limit ) ? ' mp-activity-boarder-fix' : '' ) . '"> |
| 57 | + <img src="' . $wgScriptPath . '/extensions/SocialProfile/images/' . UserActivity::getTypeIcon( $item['type'] ) . '" alt="' . UserActivity::getTypeIcon( $item['type'] ) . '" border="0" />' |
| 58 | + . $item['data'] . '</div>'; |
| 59 | + $x++; |
| 60 | + } |
| 61 | + } |
| 62 | + |
| 63 | + $output .= '</div>'; |
| 64 | + } |
| 65 | + |
| 66 | + return $output; |
| 67 | +} |
\ No newline at end of file |
Property changes on: trunk/extensions/SocialProfile/UserActivity/SiteActivityHook.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 68 | + native |
Index: trunk/extensions/SocialProfile/install.php |
— | — | @@ -3,6 +3,7 @@ |
4 | 4 | /** |
5 | 5 | * Installation script for the extension SocialProfile. MySQL only. |
6 | 6 | * |
| 7 | + * @file |
7 | 8 | * @ingroup Extensions |
8 | 9 | * @author Rob Church <robchur@gmail.com> |
9 | 10 | * @author Siebrand Mazeland |
— | — | @@ -116,6 +117,16 @@ |
117 | 118 | } |
118 | 119 | } |
119 | 120 | |
| 121 | +# Do nothing if the table exists |
| 122 | +if( $dba->tableExists( 'user_system_messages' ) ) { |
| 123 | + echo( "'user_system_messages' already exists. No action was taken.\n" ); |
| 124 | +} else { |
| 125 | + $sql = $dir . '/UserSystemMessages/user_system_messages.sql'; |
| 126 | + if( $dba->sourceFile( $sql ) ) { |
| 127 | + echo( "The table 'user_system_messages' has been set up correctly.\n" ); |
| 128 | + } |
| 129 | +} |
| 130 | + |
120 | 131 | # Close the connection |
121 | 132 | $dba->close(); |
122 | 133 | echo( "\n" ); |
Index: trunk/extensions/SocialProfile/UserStats/UserStatsClass.php |
— | — | @@ -1,6 +1,16 @@ |
2 | 2 | <?php |
3 | | -if ( ! defined( 'MEDIAWIKI' ) ) |
| 3 | +if ( !defined( 'MEDIAWIKI' ) ) |
4 | 4 | die(); |
| 5 | +/** |
| 6 | + * Four classes for tracking users' social activity |
| 7 | + * UserStatsTrack: main class, used by most other SocialProfile components |
| 8 | + * UserStats: |
| 9 | + * UserLevel: used for getting the names of user levels and points needed to |
| 10 | + * advance to the next level when $wgUserLevels is a properly-defined array. |
| 11 | + * UserEmailTrack: tracks email invitations (ones sent out by InviteContacts extension) |
| 12 | + * @file |
| 13 | + * @ingroup Extensions |
| 14 | + */ |
5 | 15 | |
6 | 16 | $wgUserStatsTrackWeekly = false; |
7 | 17 | $wgUserStatsTrackMonthly = false; |
— | — | @@ -194,12 +204,12 @@ |
195 | 205 | } |
196 | 206 | |
197 | 207 | function updateCommentCount(){ |
198 | | - global $wgUser, $wgDBprefix; |
| 208 | + global $wgUser; |
199 | 209 | if( !$wgUser->isAnon() ) { |
200 | 210 | $dbw = wfGetDB( DB_MASTER ); |
201 | | - $sql = "UPDATE ".$wgDBprefix."user_stats SET "; |
| 211 | + $sql = "UPDATE {$dbw->tableName( 'user_stats' )} SET "; |
202 | 212 | $sql .= 'stats_comment_count='; |
203 | | - $sql .= "(SELECT COUNT(*) AS CommentCount FROM Comments WHERE Comment_user_id = " . $this->user_id; |
| 213 | + $sql .= "(SELECT COUNT(*) AS CommentCount FROM {$dbw->tableName( 'Comments' )} WHERE Comment_user_id = " . $this->user_id; |
204 | 214 | $sql .= ")"; |
205 | 215 | $sql .= " WHERE stats_user_id = " . $this->user_id; |
206 | 216 | $res = $dbw->query($sql); |
— | — | @@ -209,12 +219,12 @@ |
210 | 220 | } |
211 | 221 | |
212 | 222 | function updateCommentIgnored(){ |
213 | | - global $wgUser, $wgDBprefix; |
| 223 | + global $wgUser; |
214 | 224 | if( !$wgUser->isAnon() ) { |
215 | 225 | $dbw = wfGetDB( DB_MASTER ); |
216 | | - $sql = "UPDATE ".$wgDBprefix."user_stats SET "; |
| 226 | + $sql = "UPDATE {$dbw->tableName( 'user_stats' )} SET "; |
217 | 227 | $sql .= 'stats_comment_blocked='; |
218 | | - $sql .= "(SELECT COUNT(*) AS CommentCount FROM Comments_block WHERE cb_user_id_blocked = " . $this->user_id; |
| 228 | + $sql .= "(SELECT COUNT(*) AS CommentCount FROM {$dbw->tableName( 'Comments_block' )} WHERE cb_user_id_blocked = " . $this->user_id; |
219 | 229 | $sql .= ")"; |
220 | 230 | $sql .= " WHERE stats_user_id = " . $this->user_id; |
221 | 231 | $res = $dbw->query($sql); |
— | — | @@ -228,10 +238,10 @@ |
229 | 239 | * Edit count is fetched from revision table |
230 | 240 | */ |
231 | 241 | function updateEditCount(){ |
232 | | - global $wgUser, $wgDBprefix; |
| 242 | + global $wgUser; |
233 | 243 | if( !$wgUser->isAnon() ) { |
234 | 244 | $dbw = wfGetDB( DB_MASTER ); |
235 | | - $sql = "UPDATE ".$wgDBprefix."user_stats SET "; |
| 245 | + $sql = "UPDATE {$dbw->tableName( 'user_stats' )} SET "; |
236 | 246 | $sql .= 'stats_edit_count='; |
237 | 247 | $sql .= "(SELECT count(*) AS EditsCount FROM {$dbr->tableName( 'revision' )} WHERE rev_user = {$this->user_id} "; |
238 | 248 | $sql .= ")"; |
— | — | @@ -243,12 +253,12 @@ |
244 | 254 | } |
245 | 255 | |
246 | 256 | function updateVoteCount(){ |
247 | | - global $wgUser, $wgDBprefix; |
| 257 | + global $wgUser; |
248 | 258 | if( !$wgUser->isAnon() ) { |
249 | 259 | $dbw = wfGetDB( DB_MASTER ); |
250 | | - $sql = "UPDATE ".$wgDBprefix."user_stats SET "; |
| 260 | + $sql = "UPDATE {$dbw->tableName( 'user_stats' )} SET "; |
251 | 261 | $sql .= 'stats_vote_count='; |
252 | | - $sql .= "(SELECT count(*) as VoteCount FROM Vote WHERE vote_user_id = {$this->user_id} "; |
| 262 | + $sql .= "(SELECT count(*) AS VoteCount FROM {$dbw->tableName( 'Vote' )} WHERE vote_user_id = {$this->user_id} "; |
253 | 263 | $sql .= ")"; |
254 | 264 | $sql .= " WHERE stats_user_id = " . $this->user_id; |
255 | 265 | $res = $dbw->query($sql); |
— | — | @@ -258,16 +268,17 @@ |
259 | 269 | } |
260 | 270 | |
261 | 271 | function updateCommentScoreRec( $vote_type ){ |
262 | | - global $wgUser, $wgDBprefix; |
| 272 | + global $wgUser; |
263 | 273 | if( $this->user_id != 0 ) { |
264 | 274 | $dbw = wfGetDB( DB_MASTER ); |
265 | | - $sql = "UPDATE ".$wgDBprefix."user_stats SET "; |
| 275 | + $sql = "UPDATE {$dbw->tableName( 'user_stats' )} SET "; |
266 | 276 | if( $vote_type == 1 ){ |
267 | 277 | $sql .= 'stats_comment_score_positive_rec='; |
268 | 278 | } else { |
269 | 279 | $sql .= 'stats_comment_score_negative_rec='; |
270 | 280 | } |
271 | | - $sql .= "(SELECT COUNT(*) AS CommentVoteCount FROM Comments_Vote WHERE Comment_Vote_ID IN (select CommentID FROM Comments WHERE Comment_user_id = " . $this->user_id . ") AND Comment_Vote_Score=" . $vote_type; |
| 281 | + $sql .= "(SELECT COUNT(*) AS CommentVoteCount FROM {$dbw->tableName( 'Comments_Vote' )} WHERE Comment_Vote_ID IN ( |
| 282 | + SELECT CommentID FROM {$dbw->tableName( 'Comments' )} WHERE Comment_user_id = " . $this->user_id . ") AND Comment_Vote_Score=" . $vote_type; |
272 | 283 | $sql .= ")"; |
273 | 284 | $sql .= " WHERE stats_user_id = " . $this->user_id; |
274 | 285 | $res = $dbw->query($sql); |
— | — | @@ -277,14 +288,14 @@ |
278 | 289 | } |
279 | 290 | |
280 | 291 | function updateCreatedOpinionsCount(){ |
281 | | - global $wgUser, $wgOut, $wgDBprefix; |
| 292 | + global $wgUser, $wgOut; |
282 | 293 | if( !$wgUser->isAnon() && $this->user_id ) { |
283 | 294 | $ctg = 'Opinions by User ' . ( $this->user_name ); |
284 | 295 | $parser = new Parser(); |
285 | 296 | $CtgTitle = Title::newFromText( $parser->transformMsg( trim( $ctg ), $wgOut->parserOptions() ) ); |
286 | 297 | $CtgTitle = $CtgTitle->getDBkey(); |
287 | 298 | $dbw = wfGetDB( DB_MASTER ); |
288 | | - $sql = "UPDATE ".$wgDBprefix."user_stats SET stats_opinions_created="; |
| 299 | + $sql = "UPDATE {$dbw->tableName( 'user_stats' )} SET stats_opinions_created="; |
289 | 300 | $sql .= "(SELECT count(*) AS CreatedOpinions FROM {$dbw->tableName( 'page' )} INNER JOIN {$dbw->tableName( 'categorylinks' )} ON page_id = cl_from WHERE (cl_to) = " . $dbw->addQuotes($CtgTitle) . " "; |
290 | 301 | $sql .= ")"; |
291 | 302 | $sql .= " WHERE stats_user_id = " . $this->user_id; |
— | — | @@ -296,13 +307,13 @@ |
297 | 308 | } |
298 | 309 | |
299 | 310 | function updatePublishedOpinionsCount(){ |
300 | | - global $wgUser, $wgOut, $wgDBprefix; |
| 311 | + global $wgUser, $wgOut; |
301 | 312 | $parser = new Parser(); |
302 | 313 | $dbw = wfGetDB( DB_MASTER ); |
303 | 314 | $ctg = 'Opinions by User ' . ( $this->user_name ); |
304 | 315 | $CtgTitle = Title::newFromText( $parser->transformMsg( trim( $ctg ), $wgOut->parserOptions() ) ); |
305 | 316 | $CtgTitle = $CtgTitle->getDBkey(); |
306 | | - $sql = "UPDATE ".$wgDBprefix."user_stats SET stats_opinions_published = "; |
| 317 | + $sql = "UPDATE {$dbw->tableName( 'user_stats' )} SET stats_opinions_published = "; |
307 | 318 | $sql .= "(SELECT count(*) AS PromotedOpinions FROM {$dbw->tableName( 'page' )} INNER JOIN {$dbw->tableName( 'categorylinks' )} ON page_id = cl_from INNER JOIN published_page ON page_id=published_page_id WHERE (cl_to) = " . $dbw->addQuotes($CtgTitle) . " AND published_type=1 " . " " . $timeSQL; |
308 | 319 | $sql .= ")"; |
309 | 320 | $sql .= " WHERE stats_user_id = " . $this->user_id; |
— | — | @@ -311,46 +322,56 @@ |
312 | 323 | $this->clearCache(); |
313 | 324 | } |
314 | 325 | |
| 326 | + /** |
| 327 | + * Updates the amount of relationships (friends or foes) if the user isn't an anon |
| 328 | + * @param $rel_type Integer: 1 for updating friends |
| 329 | + */ |
315 | 330 | function updateRelationshipCount( $rel_type ){ |
316 | | - global $wgUser, $wgDBprefix; |
| 331 | + global $wgUser; |
317 | 332 | if( !$wgUser->isAnon() ) { |
318 | 333 | $dbw = wfGetDB( DB_MASTER ); |
319 | 334 | if( $rel_type == 1 ){ |
320 | | - $col = "stats_friends_count"; |
| 335 | + $col = 'stats_friends_count'; |
321 | 336 | } else { |
322 | | - $col = "stats_foe_count"; |
| 337 | + $col = 'stats_foe_count'; |
323 | 338 | } |
324 | | - $sql = "UPDATE LOW_PRIORITY ".$wgDBprefix."user_stats SET {$col}= |
325 | | - (SELECT COUNT(*) AS rel_count FROM ".$wgDBprefix."user_relationship WHERE |
| 339 | + $sql = "UPDATE LOW_PRIORITY {$dbw->tableName( 'user_stats' )} SET {$col}= |
| 340 | + (SELECT COUNT(*) AS rel_count FROM {$dbw->tableName( 'user_relationship' )} WHERE |
326 | 341 | r_user_id = {$this->user_id} AND r_type={$rel_type} |
327 | | - ) |
| 342 | + ) |
328 | 343 | WHERE stats_user_id = {$this->user_id}"; |
329 | 344 | $res = $dbw->query($sql); |
330 | 345 | } |
331 | 346 | } |
332 | 347 | |
| 348 | + /** |
| 349 | + * Updates the amount of received gifts if the user isn't an anon |
| 350 | + */ |
333 | 351 | function updateGiftCountRec(){ |
334 | | - global $wgUser, $wgDBprefix; |
| 352 | + global $wgUser; |
335 | 353 | if( !$wgUser->isAnon() ) { |
336 | 354 | $dbw = wfGetDB( DB_MASTER ); |
337 | | - $sql = "UPDATE LOW_PRIORITY ".$wgDBprefix."user_stats SET stats_gifts_rec_count= |
338 | | - (SELECT COUNT(*) AS gift_count FROM ".$wgDBprefix."user_gift WHERE |
| 355 | + $sql = "UPDATE LOW_PRIORITY {$dbw->tableName( 'user_stats' )} SET stats_gifts_rec_count= |
| 356 | + (SELECT COUNT(*) AS gift_count FROM {$dbw->tableName( 'user_gift' )} WHERE |
339 | 357 | ug_user_id_to = {$this->user_id} |
340 | | - ) |
| 358 | + ) |
341 | 359 | WHERE stats_user_id = {$this->user_id}"; |
342 | 360 | |
343 | 361 | $res = $dbw->query($sql); |
344 | 362 | } |
345 | 363 | } |
346 | 364 | |
| 365 | + /** |
| 366 | + * Updates the amount of sent gifts if the user isn't an anon |
| 367 | + */ |
347 | 368 | function updateGiftCountSent(){ |
348 | | - global $wgUser, $wgDBprefix; |
| 369 | + global $wgUser; |
349 | 370 | if( !$wgUser->isAnon() ) { |
350 | 371 | $dbw = wfGetDB( DB_MASTER ); |
351 | | - $sql = "UPDATE LOW_PRIORITY ".$wgDBprefix."user_stats SET stats_gifts_sent_count= |
352 | | - (SELECT COUNT(*) AS gift_count FROM ".$wgDBprefix."user_gift WHERE |
| 372 | + $sql = "UPDATE LOW_PRIORITY {$dbw->tableName( 'user_stats' )} SET stats_gifts_sent_count= |
| 373 | + (SELECT COUNT(*) AS gift_count FROM {$dbw->tableName( 'user_gift' )} WHERE |
353 | 374 | ug_user_id_from = {$this->user_id} |
354 | | - ) |
| 375 | + ) |
355 | 376 | WHERE stats_user_id = {$this->user_id} "; |
356 | 377 | |
357 | 378 | $res = $dbw->query($sql); |
— | — | @@ -358,13 +379,13 @@ |
359 | 380 | } |
360 | 381 | |
361 | 382 | public function updateReferralComplete(){ |
362 | | - global $wgUser, $wgDBprefix; |
| 383 | + global $wgUser; |
363 | 384 | if( !$wgUser->isAnon() ) { |
364 | 385 | $dbw = wfGetDB( DB_MASTER ); |
365 | | - $sql = "UPDATE LOW_PRIORITY ".$wgDBprefix."user_stats SET stats_referrals_completed= |
366 | | - (SELECT COUNT(*) AS thecount FROM ".$wgDBprefix."user_register_track WHERE |
| 386 | + $sql = "UPDATE LOW_PRIORITY {$dbw->tableName( 'user_stats' )} SET stats_referrals_completed= |
| 387 | + (SELECT COUNT(*) AS thecount FROM {$dbw->tableName( 'user_register_track' )} WHERE |
367 | 388 | ur_user_id_referral = {$this->user_id} AND ur_user_name_referral<>'DNL' |
368 | | - ) |
| 389 | + ) |
369 | 390 | WHERE stats_user_id = {$this->user_id} "; |
370 | 391 | |
371 | 392 | $res = $dbw->query($sql); |
— | — | @@ -453,7 +474,7 @@ |
454 | 475 | } |
455 | 476 | } |
456 | 477 | if( $wgEnableFacebook ){ |
457 | | - $s = $dbw->selectRow( 'fb_link_view_opinions', array( 'fb_user_id','fb_user_session_key' ), array( 'fb_user_id_wikia' => $this->user_id ), __METHOD__ ); |
| 478 | + $s = $dbw->selectRow( 'fb_link_view_opinions', array( 'fb_user_id', 'fb_user_session_key' ), array( 'fb_user_id_wikia' => $this->user_id ), __METHOD__ ); |
458 | 479 | if ( $s !== false ) { |
459 | 480 | $new_total_points += $this->point_values['facebook']; |
460 | 481 | } |
— | — | @@ -472,11 +493,12 @@ |
473 | 494 | $level_number_after = $user_level->getLevelNumber(); |
474 | 495 | |
475 | 496 | // Check if user advanced on this update |
476 | | - /*if( $level_number_after > $level_number_before ){ |
| 497 | + if( $level_number_after > $level_number_before ){ |
477 | 498 | $m = new UserSystemMessage(); |
478 | | - $m->addMessage( $this->user_name, 2, "advanced to level <span style=\"font-weight:800;\">{$user_level->getLevelName()}</span>" ); |
| 499 | + wfLoadExtensionMessages( 'SocialProfileUserStats' ); |
| 500 | + $m->addMessage( $this->user_name, 2, wfMsgForContent( 'level-advanced-to', $user_level->getLevelName() ) ); |
479 | 501 | $m->sendAdvancementNotificationEmail( $this->user_id, $user_level->getLevelName() ); |
480 | | - }*/ |
| 502 | + } |
481 | 503 | } |
482 | 504 | $this->clearCache(); |
483 | 505 | } |
— | — | @@ -548,11 +570,11 @@ |
549 | 571 | * Retrieves per-user statistics from the database |
550 | 572 | */ |
551 | 573 | public function getUserStatsDB(){ |
552 | | - global $wgMemc, $wgDBprefix; |
| 574 | + global $wgMemc; |
553 | 575 | |
554 | 576 | wfDebug( "Got user stats for {$this->user_name} from DB\n" ); |
555 | 577 | $dbr = wfGetDB( DB_MASTER ); |
556 | | - $sql = "SELECT * FROM ".$wgDBprefix."user_stats WHERE stats_user_id = {$this->user_id} LIMIT 0,1"; |
| 578 | + $sql = "SELECT * FROM {$dbr->tableName( 'user_stats' )} WHERE stats_user_id = {$this->user_id} LIMIT 0,1"; |
557 | 579 | $res = $dbr->query($sql); |
558 | 580 | $row = $dbr->fetchObject( $res ); |
559 | 581 | $stats['edits'] = number_format( isset( $row->stats_edit_count ) ? $row->stats_edit_count : 0 ); |
— | — | @@ -592,7 +614,6 @@ |
593 | 615 | } |
594 | 616 | |
595 | 617 | static function getTopFansList( $limit = 10 ){ |
596 | | - global $wgDBprefix; |
597 | 618 | $dbr = wfGetDB( DB_MASTER ); |
598 | 619 | |
599 | 620 | if( $limit > 0 ){ |
— | — | @@ -602,7 +623,7 @@ |
603 | 624 | } |
604 | 625 | |
605 | 626 | $sql = "SELECT stats_user_id, stats_user_name, stats_total_points |
606 | | - FROM ".$wgDBprefix."user_stats |
| 627 | + FROM {$dbr->tableName( 'user_stats' )} |
607 | 628 | WHERE stats_user_id <> 0 |
608 | 629 | ORDER BY stats_total_points DESC |
609 | 630 | {$limit_sql}"; |
— | — | @@ -710,9 +731,9 @@ |
711 | 732 | // Set next level and what they need to reach |
712 | 733 | // Check if not already at highest level |
713 | 734 | if( ( $this->level_number ) != count( $this->levels ) ){ |
714 | | - $this->next_level_name = $level_name; |
715 | | - $this->next_level_points_needed = ( $level_points_needed - $this->points ); |
716 | | - return ''; |
| 735 | + $this->next_level_name = $level_name; |
| 736 | + $this->next_level_points_needed = ( $level_points_needed - $this->points ); |
| 737 | + return ''; |
717 | 738 | } |
718 | 739 | } |
719 | 740 | } |
Index: trunk/extensions/SocialProfile/UserStats/UserStats.i18n.php |
— | — | @@ -42,6 +42,7 @@ |
43 | 43 | 'top-fans-stats-gifts-rec-count' => '{{PLURAL:$1|Gift received|Gifts received}}', |
44 | 44 | 'top-fans-stats-gifts-sent-count' => '{{PLURAL:$1|Gift sent|Gifts sent}}', |
45 | 45 | 'right-updatepoints' => 'Update edit counts', |
| 46 | + 'level-advanced-to' => 'advanced to level <span style="font-weight:800;">$1</span>', |
46 | 47 | 'level-advance-subject' => 'You are now a "$1" on {{SITENAME}}!', |
47 | 48 | 'level-advance-body' => 'Hi $1. |
48 | 49 | |
— | — | @@ -570,6 +571,7 @@ |
571 | 572 | 'top-fans-stats-gifts-rec-count' => '{{PLURAL:$1|saatu lahja|saatua lahjaa}}', |
572 | 573 | 'top-fans-stats-gifts-sent-count' => '{{PLURAL:$1|lähetetty lahja|lähetettyä lahjaa}}', |
573 | 574 | 'right-updatepoints' => 'Päivittää muokkausmääriä', |
| 575 | + 'level-advanced-to' => 'pääsi tasolle <span style="font-weight:800;">$1</span>', |
574 | 576 | 'level-advance-subject' => 'Olet nyt "$1" {{GRAMMAR:inessive|{{SITENAME}}}}!', |
575 | 577 | 'level-advance-body' => 'Hei $1: |
576 | 578 | |
Index: trunk/extensions/SocialProfile/UserProfile/UserProfilePage.php |
— | — | @@ -73,7 +73,7 @@ |
74 | 74 | $wgOut->addHTML( $this->getFanBoxes( $this->user_name ) ); |
75 | 75 | $wgOut->addHTML( $this->getUserStats( $this->user_id, $this->user_name ) ); |
76 | 76 | |
77 | | - if ( !wfRunHooks( 'UserProfileEndLeft', array( &$this ) ) ) { |
| 77 | + if ( !wfRunHooks( 'UserProfileEndLeft', array( &$this ) ) ) { |
78 | 78 | wfDebug( __METHOD__ . ": UserProfileEndLeft messed up profile!\n" ); |
79 | 79 | } |
80 | 80 | |
— | — | @@ -89,6 +89,7 @@ |
90 | 90 | } |
91 | 91 | |
92 | 92 | $wgOut->addHTML( $this->getPersonalInfo( $this->user_id, $this->user_name ) ); |
| 93 | + $wgOut->addHTML( $this->getActivity( $this->user_name ) ); |
93 | 94 | $wgOut->addHTML( $this->getUserBoard( $this->user_id, $this->user_name ) ); |
94 | 95 | |
95 | 96 | if ( !wfRunHooks( 'UserProfileEndRight', array( &$this ) ) ) { |
— | — | @@ -148,7 +149,7 @@ |
149 | 150 | $this->getUserStatsRow( wfMsgExt( 'user-stats-comments', 'parsemag', $stats_data['comments'] ), $stats_data['comments'] ) . |
150 | 151 | $this->getUserStatsRow( wfMsgExt( 'user-stats-recruits', 'parsemag', $stats_data['recruits'] ), $stats_data['recruits'] ) . |
151 | 152 | $this->getUserStatsRow( wfMsgExt( 'user-stats-poll-votes', 'parsemag', $stats_data['poll_votes'] ), $stats_data['poll_votes'] ) . |
152 | | - $this->getUserStatsRow( wfMsgExt( 'user-stats-picture-game-votes', 'parsemag', $stats_data['picture_game_votes']), $stats_data['picture_game_votes'] ) . |
| 153 | + $this->getUserStatsRow( wfMsgExt( 'user-stats-picture-game-votes', 'parsemag', $stats_data['picture_game_votes'] ), $stats_data['picture_game_votes'] ) . |
153 | 154 | $this->getUserStatsRow( wfMsgExt( 'user-stats-quiz-points', 'parsemag', $stats_data['quiz_points'] ), $stats_data['quiz_points'] ); |
154 | 155 | if( $stats_data['currency'] != '10,000' ) |
155 | 156 | $output .= $this->getUserStatsRow( wfMsgExt( 'user-stats-pick-points', 'parsemag', $stats_data['currency'] ), $stats_data['currency'] ); |
— | — | @@ -203,7 +204,7 @@ |
204 | 205 | $stats = new UserStats( $user_id, $user_name ); |
205 | 206 | $stats_data = $stats->getUserStats(); |
206 | 207 | $user_level = new UserLevel( $stats_data['points'] ); |
207 | | - $level_link = Title::makeTitle( NS_HELP, wfMsgHtml( 'user-profile-userlevels-link' ) ); |
| 208 | + $level_link = Title::makeTitle( NS_HELP, wfMsgForContent( 'user-profile-userlevels-link' ) ); |
208 | 209 | |
209 | 210 | if( !$this->profile_data ){ |
210 | 211 | $profile = new UserProfile( $user_name ); |
— | — | @@ -226,7 +227,7 @@ |
227 | 228 | } |
228 | 229 | if( $hometown == ', ' ) $hometown = ''; |
229 | 230 | |
230 | | - $joined_data = $profile_data['real_name'] . $location. $hometown . $profile_data['birthday'] . $profile_data['occupation'] . $profile_data['websites'] . $profile_data['places_lived'] . $profile_data['schools'] . $profile_data['about']; |
| 231 | + $joined_data = $profile_data['real_name'] . $location . $hometown . $profile_data['birthday'] . $profile_data['occupation'] . $profile_data['websites'] . $profile_data['places_lived'] . $profile_data['schools'] . $profile_data['about']; |
231 | 232 | $edit_info_link = SpecialPage::getTitleFor( 'UpdateProfile' ); |
232 | 233 | |
233 | 234 | $output = ''; |
— | — | @@ -246,15 +247,15 @@ |
247 | 248 | </div> |
248 | 249 | <div class="cleared"></div> |
249 | 250 | <div class="profile-info-container">'. |
250 | | - $this->getProfileSection( wfMsg( 'user-personal-info-real-name' ), $profile_data['real_name'], false ). |
251 | | - $this->getProfileSection( wfMsg( 'user-personal-info-location' ), $location, false ). |
252 | | - $this->getProfileSection( wfMsg( 'user-personal-info-hometown' ), $hometown, false ). |
253 | | - $this->getProfileSection( wfMsg( 'user-personal-info-birthday' ), $profile_data['birthday'], false ). |
254 | | - $this->getProfileSection( wfMsg( 'user-personal-info-occupation' ), $profile_data['occupation'], false ). |
255 | | - $this->getProfileSection( wfMsg( 'user-personal-info-websites' ), $profile_data['websites'], false ). |
256 | | - $this->getProfileSection( wfMsg( 'user-personal-info-places-lived' ), $profile_data['places_lived'], false ). |
257 | | - $this->getProfileSection( wfMsg( 'user-personal-info-schools' ), $profile_data['schools'], false ). |
258 | | - $this->getProfileSection( wfMsg( 'user-personal-info-about-me' ), $profile_data['about'], false ). |
| 251 | + $this->getProfileSection( wfMsg( 'user-personal-info-real-name' ), $profile_data['real_name'], false ) . |
| 252 | + $this->getProfileSection( wfMsg( 'user-personal-info-location' ), $location, false ) . |
| 253 | + $this->getProfileSection( wfMsg( 'user-personal-info-hometown' ), $hometown, false ) . |
| 254 | + $this->getProfileSection( wfMsg( 'user-personal-info-birthday' ), $profile_data['birthday'], false ) . |
| 255 | + $this->getProfileSection( wfMsg( 'user-personal-info-occupation' ), $profile_data['occupation'], false ) . |
| 256 | + $this->getProfileSection( wfMsg( 'user-personal-info-websites' ), $profile_data['websites'], false ) . |
| 257 | + $this->getProfileSection( wfMsg( 'user-personal-info-places-lived' ), $profile_data['places_lived'], false ) . |
| 258 | + $this->getProfileSection( wfMsg( 'user-personal-info-schools' ), $profile_data['schools'], false ) . |
| 259 | + $this->getProfileSection( wfMsg( 'user-personal-info-about-me' ), $profile_data['about'], false ) . |
259 | 260 | '</div>'; |
260 | 261 | } else if( $wgUser->getName() == $user_name ) { |
261 | 262 | $output .= '<div class="user-section-heading"> |
— | — | @@ -311,11 +312,11 @@ |
312 | 313 | </div> |
313 | 314 | </div> |
314 | 315 | <div class="cleared"></div> |
315 | | - <div class="profile-info-container">'. |
316 | | - $this->getProfileSection( wfMsg( 'custom-info-field1' ), $profile_data['custom_1'], false ). |
317 | | - $this->getProfileSection( wfMsg( 'custom-info-field2' ), $profile_data['custom_2'], false ). |
318 | | - $this->getProfileSection( wfMsg( 'custom-info-field3' ), $profile_data['custom_3'], false ). |
319 | | - $this->getProfileSection( wfMsg( 'custom-info-field4' ), $profile_data['custom_4'], false ). |
| 316 | + <div class="profile-info-container">' . |
| 317 | + $this->getProfileSection( wfMsg( 'custom-info-field1' ), $profile_data['custom_1'], false ) . |
| 318 | + $this->getProfileSection( wfMsg( 'custom-info-field2' ), $profile_data['custom_2'], false ) . |
| 319 | + $this->getProfileSection( wfMsg( 'custom-info-field3' ), $profile_data['custom_3'], false ) . |
| 320 | + $this->getProfileSection( wfMsg( 'custom-info-field4' ), $profile_data['custom_4'], false ) . |
320 | 321 | '</div>'; |
321 | 322 | } else if( $wgUser->getName() == $user_name ) { |
322 | 323 | $output .= '<div class="user-section-heading"> |
— | — | @@ -375,15 +376,15 @@ |
376 | 377 | </div> |
377 | 378 | </div> |
378 | 379 | <div class="cleared"></div> |
379 | | - <div class="profile-info-container">'. |
380 | | - $this->getProfileSection( wfMsg( 'other-info-movies' ), $profile_data['movies'], false ). |
381 | | - $this->getProfileSection( wfMsg( 'other-info-tv' ), $profile_data['tv'], false ). |
382 | | - $this->getProfileSection( wfMsg( 'other-info-music' ), $profile_data['music'], false ). |
383 | | - $this->getProfileSection( wfMsg( 'other-info-books' ), $profile_data['books'], false ). |
384 | | - $this->getProfileSection( wfMsg( 'other-info-video-games' ), $profile_data['video_games'], false ). |
385 | | - $this->getProfileSection( wfMsg( 'other-info-magazines' ), $profile_data['magazines'], false ). |
386 | | - $this->getProfileSection( wfMsg( 'other-info-snacks' ), $profile_data['snacks'], false ). |
387 | | - $this->getProfileSection( wfMsg( 'other-info-drinks' ), $profile_data['drinks'], false ). |
| 380 | + <div class="profile-info-container">' . |
| 381 | + $this->getProfileSection( wfMsg( 'other-info-movies' ), $profile_data['movies'], false ) . |
| 382 | + $this->getProfileSection( wfMsg( 'other-info-tv' ), $profile_data['tv'], false ) . |
| 383 | + $this->getProfileSection( wfMsg( 'other-info-music' ), $profile_data['music'], false ) . |
| 384 | + $this->getProfileSection( wfMsg( 'other-info-books' ), $profile_data['books'], false ) . |
| 385 | + $this->getProfileSection( wfMsg( 'other-info-video-games' ), $profile_data['video_games'], false ) . |
| 386 | + $this->getProfileSection( wfMsg( 'other-info-magazines' ), $profile_data['magazines'], false ) . |
| 387 | + $this->getProfileSection( wfMsg( 'other-info-snacks' ), $profile_data['snacks'], false ) . |
| 388 | + $this->getProfileSection( wfMsg( 'other-info-drinks' ), $profile_data['drinks'], false ) . |
388 | 389 | '</div>'; |
389 | 390 | |
390 | 391 | } else if( $wgUser->getName() == $user_name ) { |
— | — | @@ -415,7 +416,7 @@ |
416 | 417 | $stats = new UserStats( $user_id, $user_name ); |
417 | 418 | $stats_data = $stats->getUserStats(); |
418 | 419 | $user_level = new UserLevel( $stats_data['points'] ); |
419 | | - $level_link = Title::makeTitle( NS_HELP, wfMsgHtml( 'user-profile-userlevels-link' ) ); |
| 420 | + $level_link = Title::makeTitle( NS_HELP, wfMsgForContent( 'user-profile-userlevels-link' ) ); |
420 | 421 | |
421 | 422 | if( !$this->profile_data ){ |
422 | 423 | $profile = new UserProfile( $user_name ); |
— | — | @@ -434,9 +435,7 @@ |
435 | 436 | $add_relationship = SpecialPage::getTitleFor( 'AddRelationship' ); |
436 | 437 | $remove_relationship = SpecialPage::getTitleFor( 'RemoveRelationship' ); |
437 | 438 | $give_gift = SpecialPage::getTitleFor( 'GiveGift' ); |
438 | | - $friends_activity = SpecialPage::getTitleFor( 'UserActivity' ); |
439 | 439 | $send_board_blast = SpecialPage::getTitleFor( 'SendBoardBlast' ); |
440 | | - $similar_fans = SpecialPage::getTitleFor( 'SimilarFans' ); |
441 | 440 | $update_profile = SpecialPage::getTitleFor( 'UpdateProfile' ); |
442 | 441 | $watchlist = SpecialPage::getTitleFor( 'Watchlist' ); |
443 | 442 | $contributions = SpecialPage::getTitleFor( 'Contributions', $user ); |
— | — | @@ -473,10 +472,10 @@ |
474 | 473 | global $wgUserLevels; |
475 | 474 | if( $wgUserLevels ){ |
476 | 475 | $output .= '<div id="points-level"> |
477 | | - <a href="' . $level_link->escapeFullURL() .'">' . wfMsgExt( 'user-profile-points', 'parsemag', $stats_data['points'] ) . '</a> |
| 476 | + <a href="' . $level_link->escapeFullURL() . '">' . wfMsgExt( 'user-profile-points', 'parsemag', $stats_data['points'] ) . '</a> |
478 | 477 | </div> |
479 | 478 | <div id="honorific-level"> |
480 | | - <a href="' . $level_link->escapeFullURL() .'" rel="nofollow">(' . $user_level->getLevelName() .')</a> |
| 479 | + <a href="' . $level_link->escapeFullURL() . '" rel="nofollow">(' . $user_level->getLevelName() . ')</a> |
481 | 480 | </div>'; |
482 | 481 | } |
483 | 482 | $output .= '<div class="cleared"></div> |
— | — | @@ -584,7 +583,7 @@ |
585 | 584 | $output = ''; // Prevent E_NOTICE |
586 | 585 | |
587 | 586 | $count = 4; |
588 | | - $rel = new UserRelationship($user_name); |
| 587 | + $rel = new UserRelationship( $user_name ); |
589 | 588 | $key = wfMemcKey( 'relationship', 'profile', "{$rel->user_id}-{$rel_type}" ); |
590 | 589 | $data = $wgMemc->get( $key ); |
591 | 590 | |
— | — | @@ -656,6 +655,234 @@ |
657 | 656 | return $output; |
658 | 657 | } |
659 | 658 | |
| 659 | + /** |
| 660 | + * Gets the recent social activity related to the current user |
| 661 | + * @param $user_name Mixed: name of the user whose activity we want to fetch |
| 662 | + */ |
| 663 | + function getActivity( $user_name ){ |
| 664 | + global $wgUser, $wgUserProfileDisplay, $wgScriptPath, $wgUploadPath; |
| 665 | + |
| 666 | + // If not enabled in site settings, don't display |
| 667 | + if( $wgUserProfileDisplay['activity'] == false ){ |
| 668 | + return ''; |
| 669 | + } |
| 670 | + |
| 671 | + wfLoadExtensionMessages( 'SocialProfileUserProfile' ); |
| 672 | + |
| 673 | + $output = ''; |
| 674 | + |
| 675 | + $limit = 8; |
| 676 | + $rel = new UserActivity( $user_name, 'user', $limit ); |
| 677 | + $rel->setActivityToggle( 'show_votes', 0 ); |
| 678 | + $rel->setActivityToggle( 'show_gifts_sent', 1 ); |
| 679 | + |
| 680 | + /** |
| 681 | + * Get all relationship activity |
| 682 | + */ |
| 683 | + $activity = $rel->getActivityList(); |
| 684 | + |
| 685 | + if( $activity ){ |
| 686 | + $output .= '<div class="user-section-heading"> |
| 687 | + <div class="user-section-title"> |
| 688 | + ' . wfMsg( 'user-recent-activity-title' ) . ' |
| 689 | + </div> |
| 690 | + <div class="user-section-actions"> |
| 691 | + <div class="action-right"> |
| 692 | + </div> |
| 693 | + <div class="cleared"></div> |
| 694 | + </div> |
| 695 | + </div> |
| 696 | + <div class="cleared"></div>'; |
| 697 | + |
| 698 | + $x = 1; |
| 699 | + |
| 700 | + if( count( $activity ) < $limit ) { |
| 701 | + $style_limit = count( $activity ); |
| 702 | + } else { |
| 703 | + $style_limit = $limit; |
| 704 | + } |
| 705 | + |
| 706 | + foreach( $activity as $item ) { |
| 707 | + $item_html = ''; |
| 708 | + $title = Title::makeTitle( $item['namespace'], $item['pagetitle'] ); |
| 709 | + $user_title = Title::makeTitle( NS_USER, $item['username'] ); |
| 710 | + $user_title_2 = Title::makeTitle( NS_USER, $item['comment'] ); |
| 711 | + |
| 712 | + if( $user_title_2 ) |
| 713 | + $user_link_2 = '<a href="' . $user_title_2->escapeFullURL() . '" rel="nofollow">' . $item['comment'] . '</a>'; |
| 714 | + |
| 715 | + $comment_url = ''; |
| 716 | + if( $item['type'] == 'comment' ) |
| 717 | + $comment_url = "#comment-{$item["id"]}"; |
| 718 | + |
| 719 | + $page_link = '<b><a href="' . $title->escapeFullURL() . "{$comment_url}\">" . $title->getPrefixedText() . '</a></b> '; |
| 720 | + $b = new UserBoard(); // Easier than porting the time-related functions here |
| 721 | + $item_time = '<span class="item-small">' . wfMsg( 'user-time-ago', $b->getTimeAgo( $item['timestamp'] ) ) . '</span>'; |
| 722 | + |
| 723 | + if( $x < $style_limit ) { |
| 724 | + $item_html .= '<div class="activity-item"> |
| 725 | + <img src="' . $wgScriptPath . '/extensions/SocialProfile/images/' . UserActivity::getTypeIcon( $item['type'] ) . '" alt="" border="0" />'; |
| 726 | + } else { |
| 727 | + $item_html .= '<div class="activity-item-bottom"> |
| 728 | + <img src="' . $wgScriptPath . '/extensions/SocialProfile/images/' . UserActivity::getTypeIcon( $item['type'] ) . '" alt="" border="0" />'; |
| 729 | + } |
| 730 | + |
| 731 | + switch( $item['type'] ) { |
| 732 | + case 'edit': |
| 733 | + $item_html .= wfMsg( 'user-recent-activity-edit' ) . " {$page_link} {$item_time} |
| 734 | + <div class=\"item\">"; |
| 735 | + if( $item['comment'] ) |
| 736 | + $item_html .= "\"{$item["comment"]}\""; |
| 737 | + $item_html .= '</div>'; |
| 738 | + break; |
| 739 | + case 'vote': |
| 740 | + $item_html .= wfMsg( 'user-recent-activity-vote' ) . " {$page_link} {$item_time}"; |
| 741 | + break; |
| 742 | + case 'comment': |
| 743 | + $item_html .= wfMsg( 'user-recent-activity-comment' ) . " {$page_link} {$item_time} |
| 744 | + <div class=\"item\"> |
| 745 | + \"{$item["comment"]}\" |
| 746 | + </div>"; |
| 747 | + break; |
| 748 | + case 'gift-sent': |
| 749 | + $gift_image = "<img src=\"{$wgUploadPath}/awards/" . Gifts::getGiftImage( $item['namespace'], 'm' ) . "\" border=\"0\" alt=\"\" />"; |
| 750 | + $item_html .= wfMsg( 'user-recent-activity-gift-sent' ) . " {$user_link_2} {$item_time} |
| 751 | + <div class=\"item\"> |
| 752 | + <a href=\"" . $wgScriptPath . "/index.php?title=Special:ViewGift&gift_id={$item["id"]}\" rel=\"nofollow\"> |
| 753 | + {$gift_image} |
| 754 | + {$item["pagetitle"]} |
| 755 | + </a> |
| 756 | + </div>"; |
| 757 | + break; |
| 758 | + case 'gift-rec': |
| 759 | + $gift_image = "<img src=\"{$wgUploadPath}/awards/" . Gifts::getGiftImage( $item['namespace'], 'm' ) . "\" border=\"0\" alt=\"\" />"; |
| 760 | + $item_html .= wfMsg( 'user-recent-activity-gift-rec' ) . " {$user_link_2} {$item_time}</span> |
| 761 | + <div class=\"item\"> |
| 762 | + <a href=\"" . $wgScriptPath . "/index.php?title=Special:ViewGift&gift_id={$item["id"]}\" rel=\"nofollow\"> |
| 763 | + {$gift_image} |
| 764 | + {$item["pagetitle"]} |
| 765 | + </a> |
| 766 | + </div>"; |
| 767 | + break; |
| 768 | + case 'system_gift': |
| 769 | + $gift_image = "<img src=\"{$wgUploadPath}/awards/" . SystemGifts::getGiftImage( $item['namespace'], 'm' ) . "\" border=\"0\" alt=\"\" />"; |
| 770 | + $item_html .= wfMsg( 'user-recent-system-gift' ) . " {$item_time} |
| 771 | + <div class=\"user-home-item-gift\"> |
| 772 | + <a href=\"" . $wgScriptPath . "/index.php?title=Special:ViewSystemGift&gift_id={$item["id"]}\" rel=\"nofollow\"> |
| 773 | + {$gift_image} |
| 774 | + {$item["pagetitle"]} |
| 775 | + </a> |
| 776 | + </div>"; |
| 777 | + break; |
| 778 | + case 'friend': |
| 779 | + $item_html .= wfMsg( 'user-recent-activity-friend' ) . " <b>{$user_link_2}</b> {$item_time}"; |
| 780 | + break; |
| 781 | + case 'foe': |
| 782 | + $item_html .= wfMsg( 'user-recent-activity-foe' ) . " <b>{$user_link_2}</b> {$item_time}"; |
| 783 | + break; |
| 784 | + case 'system_message': |
| 785 | + $item_html .= "{$item["comment"]} {$item_time}"; |
| 786 | + break; |
| 787 | + case 'user_message': |
| 788 | + $item_html .= wfMsg( 'user-recent-activity-user-message' ) . " <b><a href=\"" . UserBoard::getUserBoardURL( $user_title_2->getText() ) . "\" rel=\"nofollow\">{$item["comment"]}</a></b> {$item_time} |
| 789 | + <div class=\"item\"> |
| 790 | + \"{$item["namespace"]}\" |
| 791 | + </div>"; |
| 792 | + break; |
| 793 | + /*case 'network_update': |
| 794 | + $page_link = '' . $item['network'] . '</a> '; |
| 795 | + $network_image = SportsTeams::getLogo( $item['sport_id'], $item['team_id'], 's' ); |
| 796 | + $item_html .= wfMsg( 'user-recent-activity-network-update' ) . ' |
| 797 | + <div class="item"> |
| 798 | + <a href="' . SportsTeams::getNetworkURL( $item['sport_id'], $item['team_id'] ) . "\" rel=\"nofollow\">{$network_image} \"{$item["comment"]}\"</a> |
| 799 | + </div>"; |
| 800 | + break;*/ |
| 801 | + } |
| 802 | + |
| 803 | + $item_html .= '</div>'; |
| 804 | + |
| 805 | + if( $x <= $limit ){ |
| 806 | + $items_html_type['all'][] = $item_html; |
| 807 | + } |
| 808 | + $items_html_type[$item['type']][] = $item_html; |
| 809 | + |
| 810 | + $x++; |
| 811 | + } |
| 812 | + |
| 813 | + $by_type = ''; |
| 814 | + foreach( $items_html_type['all'] as $item ){ |
| 815 | + $by_type .= $item; |
| 816 | + } |
| 817 | + $output .= "<div id=\"recent-all\">$by_type</div>"; |
| 818 | + |
| 819 | + $by_type = ''; |
| 820 | + if( isset( $items_html_type['edit'] ) && is_array( $items_html_type['edit'] ) ){ |
| 821 | + foreach( $items_html_type['edit'] as $item ){ |
| 822 | + $by_type .= $item; |
| 823 | + } |
| 824 | + } |
| 825 | + |
| 826 | + $by_type = ''; |
| 827 | + if( isset( $items_html_type['comment'] ) && is_array( $items_html_type['comment'] ) ){ |
| 828 | + foreach( $items_html_type['comment'] as $item ){ |
| 829 | + $by_type .= $item; |
| 830 | + } |
| 831 | + } |
| 832 | + |
| 833 | + $by_type = ''; |
| 834 | + if( isset( $items_html_type['gift-sent'] ) && is_array( $items_html_type['gift-sent'] ) ){ |
| 835 | + foreach( $items_html_type['gift-sent'] as $item ){ |
| 836 | + $by_type .= $item; |
| 837 | + } |
| 838 | + } |
| 839 | + |
| 840 | + $by_type = ''; |
| 841 | + if( isset( $items_html_type['gift-rec']) && is_array( $items_html_type['gift-rec'] ) ){ |
| 842 | + foreach( $items_html_type['gift-rec'] as $item ){ |
| 843 | + $by_type .= $item; |
| 844 | + } |
| 845 | + } |
| 846 | + |
| 847 | + $by_type = ''; |
| 848 | + if( isset( $items_html_type['system_gift'] ) && is_array( $items_html_type['system_gift'] ) ){ |
| 849 | + foreach( $items_html_type['system_gift'] as $item ){ |
| 850 | + $by_type .= $item; |
| 851 | + } |
| 852 | + } |
| 853 | + |
| 854 | + $by_type = ''; |
| 855 | + if( isset( $items_html_type['friend'] ) && is_array( $items_html_type['friend'] ) ){ |
| 856 | + foreach( $items_html_type['friend'] as $item ){ |
| 857 | + $by_type .= $item; |
| 858 | + } |
| 859 | + } |
| 860 | + |
| 861 | + $by_type = ''; |
| 862 | + if( isset( $items_html_type['foe']) && is_array( $items_html_type['foe'] ) ){ |
| 863 | + foreach( $items_html_type['foe'] as $item ){ |
| 864 | + $by_type .= $item; |
| 865 | + } |
| 866 | + } |
| 867 | + |
| 868 | + $by_type = ''; |
| 869 | + if( isset( $items_html_type['system_message'] ) && is_array( $items_html_type['system_message'] ) ){ |
| 870 | + foreach( $items_html_type['system_message'] as $item ){ |
| 871 | + $by_type .= $item; |
| 872 | + } |
| 873 | + } |
| 874 | + |
| 875 | + /*$by_type = ''; |
| 876 | + if( isset( $items_html_type['network_update'] ) && is_array( $items_html_type['network_update'] ) ) { |
| 877 | + foreach( $items_html_type['network_update'] as $item ){ |
| 878 | + $by_type .= $item; |
| 879 | + } |
| 880 | + }*/ |
| 881 | + |
| 882 | + } |
| 883 | + |
| 884 | + return $output; |
| 885 | + } |
| 886 | + |
660 | 887 | function getGifts( $user_name ){ |
661 | 888 | global $wgUser, $wgMemc, $wgUserProfileDisplay, $wgUploadPath; |
662 | 889 | |
— | — | @@ -728,7 +955,7 @@ |
729 | 956 | $user = Title::makeTitle( NS_USER, $gift['user_name_from'] ); |
730 | 957 | $gift_image = '<img src="' . $wgUploadPath . '/awards/' . Gifts::getGiftImage( $gift['gift_id'], 'ml' ) . '" border="0" alt="" />'; |
731 | 958 | $gift_link = $user = SpecialPage::getTitleFor( 'ViewGift' ); |
732 | | - $output .= "<a href=\"".$gift_link->escapeFullURL('gift_id='.$gift['id'])."\" ".( ( $gift['status'] == 1 ) ? 'class="user-page-new"' : '' )." rel=\"nofollow\">{$gift_image}</a>"; |
| 959 | + $output .= '<a href="' . $gift_link->escapeFullURL( 'gift_id=' . $gift['id'] ) . '" ' . ( ( $gift['status'] == 1 ) ? 'class="user-page-new"' : '' ) . " rel=\"nofollow\">{$gift_image}</a>"; |
733 | 960 | if( $x == count( $gifts ) || $x != 1 && $x%$per_row == 0 ) $output .= '<div class="cleared"></div>'; |
734 | 961 | $x++; |
735 | 962 | |
— | — | @@ -753,7 +980,7 @@ |
754 | 981 | |
755 | 982 | $output = ''; |
756 | 983 | |
757 | | - // SYSTEM GIFTS |
| 984 | + // System gifts |
758 | 985 | $sg = new UserSystemGifts( $user_name ); |
759 | 986 | |
760 | 987 | // Try cache |
— | — | @@ -809,7 +1036,7 @@ |
810 | 1037 | $gift_image = '<img src="' . $wgUploadPath . '/awards/' . SystemGifts::getGiftImage( $gift['gift_id'], 'ml' ) . '" border="0" alt="" />'; |
811 | 1038 | $gift_link = $user = SpecialPage::getTitleFor( 'ViewSystemGift' ); |
812 | 1039 | |
813 | | - $output .= "<a href=\"".$gift_link->escapeFullURL('gift_id='.$gift['id'])."\" ".( ( $gift['status'] == 1 ) ? 'class="user-page-new"' : '' )." rel=\"nofollow\"> |
| 1040 | + $output .= '<a href="' . $gift_link->escapeFullURL( 'gift_id=' . $gift['id'] ) . '" ' . ( ( $gift['status'] == 1 ) ? 'class="user-page-new"' : '' ) . " rel=\"nofollow\"> |
814 | 1041 | {$gift_image} |
815 | 1042 | </a>"; |
816 | 1043 | |
— | — | @@ -824,7 +1051,7 @@ |
825 | 1052 | } |
826 | 1053 | |
827 | 1054 | function getUserBoard( $user_id, $user_name ){ |
828 | | - global $wgMemc, $wgUser, $wgOut, $wgUserProfileDisplay, $wgUserProfileScripts; |
| 1055 | + global $wgUser, $wgOut, $wgUserProfileDisplay, $wgUserProfileScripts; |
829 | 1056 | |
830 | 1057 | // Load messages, we're gonna need 'em |
831 | 1058 | wfLoadExtensionMessages( 'SocialProfileUserProfile' ); |
— | — | @@ -886,14 +1113,14 @@ |
887 | 1114 | </select><p> |
888 | 1115 | <textarea name="message" id="message" cols="43" rows="4"/></textarea> |
889 | 1116 | <div class="user-page-message-box-button"> |
890 | | - <input type="button" value="' . wfMsg( 'userboard_sendbutton' ) . '" class="site-button" onclick="javascript:send_message();"> |
| 1117 | + <input type="button" value="' . wfMsg( 'userboard_sendbutton' ) . '" class="site-button" onclick="javascript:send_message();" /> |
891 | 1118 | </div> |
892 | 1119 | </div>'; |
893 | 1120 | } else { |
894 | 1121 | $login_link = SpecialPage::getTitleFor( 'Userlogin' ); |
895 | 1122 | |
896 | 1123 | $output .= '<div class="user-page-message-form"> |
897 | | - ' . wfMsg( 'user-board-login-message', $login_link->escapeFullURL() ) . ' |
| 1124 | + ' . wfMsg( 'user-board-login-message', $login_link->escapeFullURL() ) . ' |
898 | 1125 | </div>'; |
899 | 1126 | } |
900 | 1127 | } |
— | — | @@ -918,7 +1145,7 @@ |
919 | 1146 | } |
920 | 1147 | |
921 | 1148 | $wgOut->addScriptFile( $wgFanBoxScripts . '/FanBoxes.js' ); |
922 | | - $wgOut->addStyle( '../..' . $wgFanBoxScripts . '/FanBoxes.css' ); |
| 1149 | + $wgOut->addExtensionStyle( $wgFanBoxScripts . '/FanBoxes.css' ); |
923 | 1150 | |
924 | 1151 | wfLoadExtensionMessages( 'FanBox' ); |
925 | 1152 | |
— | — | @@ -1088,4 +1315,5 @@ |
1089 | 1316 | |
1090 | 1317 | return $output; |
1091 | 1318 | } |
| 1319 | + |
1092 | 1320 | } |
Index: trunk/extensions/SocialProfile/UserProfile/UserProfile.i18n.php |
— | — | @@ -14,6 +14,7 @@ |
15 | 15 | */ |
16 | 16 | $messages['en'] = array( |
17 | 17 | 'populateuserprofiles' => 'Populate user profiles', |
| 18 | + 'user-time-ago' => '$1 ago', |
18 | 19 | 'user-awards-title' => 'Awards', |
19 | 20 | 'user-gifts-title' => 'Gifts', |
20 | 21 | 'user-count-separator' => '$1 of $2', |
— | — | @@ -2738,10 +2739,11 @@ |
2739 | 2740 | |
2740 | 2741 | /** Finnish (Suomi) |
2741 | 2742 | * @author Crt |
2742 | | - * @author Jack Phoenix |
| 2743 | + * @author Jack Phoenix <jack@countervandalism.net> |
2743 | 2744 | */ |
2744 | 2745 | $messages['fi'] = array( |
2745 | 2746 | 'populateuserprofiles' => 'Täytä käyttäjäprofiilit', |
| 2747 | + 'user-time-ago' => '$1 sitten', |
2746 | 2748 | 'user-awards-title' => 'Palkinnot', |
2747 | 2749 | 'user-gifts-title' => 'Lahjat', |
2748 | 2750 | 'user-count-separator' => '$1 / $2', |
Index: trunk/extensions/SocialProfile/UserProfile/UserProfile.php |
— | — | @@ -6,7 +6,6 @@ |
7 | 7 | // Default setup for displaying sections |
8 | 8 | $wgUserPageChoice = true; |
9 | 9 | |
10 | | - |
11 | 10 | $wgUserProfileDisplay['friends'] = false; |
12 | 11 | $wgUserProfileDisplay['foes'] = false; |
13 | 12 | $wgUserProfileDisplay['gifts'] = true; |
— | — | @@ -17,23 +16,23 @@ |
18 | 17 | $wgUserProfileDisplay['interests'] = true; |
19 | 18 | $wgUserProfileDisplay['custom'] = true; |
20 | 19 | $wgUserProfileDisplay['personal'] = true; |
| 20 | +$wgUserProfileDisplay['activity'] = false; // Display recent social activity? |
21 | 21 | $wgUserProfileDisplay['userboxes'] = false; // If FanBoxes extension is installed, setting this to true will display the user's fanboxes on their profile page |
22 | 22 | |
23 | 23 | $wgUpdateProfileInRecentChanges = false; // Show a log entry in recent changes whenever a user updates their profile? |
24 | 24 | $wgUploadAvatarInRecentChanges = false; // Same as above, but for avatar uploading |
25 | 25 | |
26 | 26 | $wgAvailableRights[] = 'avatarremove'; |
27 | | -$wgGroupPermissions['staff']['avatarremove'] = true; |
28 | 27 | $wgGroupPermissions['sysop']['avatarremove'] = true; |
29 | 28 | |
30 | 29 | # Add new log types for profile edits and avatar uploads |
31 | 30 | global $wgLogTypes, $wgLogNames, $wgLogHeaders, $wgLogActions; |
32 | | -$wgLogTypes[] = 'profile'; |
33 | | -$wgLogNames['profile'] = 'profilelogpage'; |
34 | | -$wgLogHeaders['profile'] = 'profilelogpagetext'; |
| 31 | +$wgLogTypes[] = 'profile'; |
| 32 | +$wgLogNames['profile'] = 'profilelogpage'; |
| 33 | +$wgLogHeaders['profile'] = 'profilelogpagetext'; |
35 | 34 | $wgLogActions['profile/profile'] = 'profilelogentry'; |
36 | 35 | |
37 | | -$wgLogTypes[] = 'avatar'; |
| 36 | +$wgLogTypes[] = 'avatar'; |
38 | 37 | $wgLogNames['avatar'] = 'avatarlogpage'; |
39 | 38 | $wgLogHeaders['avatar'] = 'avatarlogpagetext'; |
40 | 39 | $wgLogActions['avatar/avatar'] = 'avatarlogentry'; |
— | — | @@ -41,7 +40,7 @@ |
42 | 41 | $wgHooks['ArticleFromTitle'][] = 'wfUserProfileFromTitle'; |
43 | 42 | |
44 | 43 | /** |
45 | | - * called by ArticleFromTitle hook |
| 44 | + * Called by ArticleFromTitle hook |
46 | 45 | * Calls UserProfilePage instead of standard article |
47 | 46 | * |
48 | 47 | * @param &$title Title object |
— | — | @@ -49,10 +48,9 @@ |
50 | 49 | * @return true |
51 | 50 | */ |
52 | 51 | function wfUserProfileFromTitle( &$title, &$article ){ |
53 | | - global $IP, $wgUser, $wgRequest, $wgOut, $wgMemc, $wgStyleVersion, $wgHooks, |
54 | | - $wgUserPageChoice, $wgUserProfileScripts; |
| 52 | + global $wgRequest, $wgOut, $wgHooks, $wgUserPageChoice, $wgUserProfileScripts; |
55 | 53 | |
56 | | - if ( strpos( $title->getText(), "/" ) === false && ( NS_USER == $title->getNamespace() || NS_USER_PROFILE == $title->getNamespace() ) ) { |
| 54 | + if ( strpos( $title->getText(), '/' ) === false && ( NS_USER == $title->getNamespace() || NS_USER_PROFILE == $title->getNamespace() ) ) { |
57 | 55 | |
58 | 56 | $show_user_page = false; |
59 | 57 | if( $wgUserPageChoice ){ |
— | — | @@ -75,7 +73,7 @@ |
76 | 74 | $wgHooks['ParserLimitReport'][] = 'wfUserProfileMarkUncacheable'; |
77 | 75 | } |
78 | 76 | |
79 | | - $wgOut->addScript( "<link rel='stylesheet' type='text/css' href=\"{$wgUserProfileScripts}/UserProfile.css?{$wgStyleVersion}\"/>\n" ); |
| 77 | + $wgOut->addExtensionStyle( $wgUserProfileScripts . '/UserProfile.css' ); |
80 | 78 | |
81 | 79 | $article = new UserProfilePage( $title ); |
82 | 80 | } |
Index: trunk/extensions/SocialProfile/UserProfile/UserProfileClass.php |
— | — | @@ -39,9 +39,9 @@ |
40 | 40 | * @private |
41 | 41 | */ |
42 | 42 | /* private */ function __construct( $username ) { |
43 | | - $title1 = Title::newFromDBkey($username); |
| 43 | + $title1 = Title::newFromDBkey( $username ); |
44 | 44 | $this->user_name = $title1->getText(); |
45 | | - $this->user_id = User::idFromName($this->user_name); |
| 45 | + $this->user_id = User::idFromName( $this->user_name ); |
46 | 46 | } |
47 | 47 | |
48 | 48 | static function clearCache( $user_id ){ |
— | — | @@ -65,78 +65,78 @@ |
66 | 66 | $dbr = wfGetDB( DB_SLAVE ); |
67 | 67 | $params['LIMIT'] = '5'; |
68 | 68 | $row = $dbr->selectRow( 'user_profile', |
69 | | - "*", |
| 69 | + '*', |
70 | 70 | array( 'up_user_id' => $this->user_id ), __METHOD__, |
71 | 71 | $params |
72 | 72 | ); |
73 | 73 | |
74 | 74 | if( $row ){ |
75 | | - $profile['user_id']= $this->user_id; |
| 75 | + $profile['user_id'] = $this->user_id; |
76 | 76 | } else { |
77 | 77 | $profile['user_page_type'] = 1; |
78 | | - $profile['user_id']= 0; |
| 78 | + $profile['user_id'] = 0; |
79 | 79 | } |
80 | | - $profile['location_city']= isset( $row->up_location_city ) ? $row->up_location_city : ''; |
81 | | - $profile['location_state']= isset( $row->up_location_state ) ? $row->up_location_state : ''; |
82 | | - $profile['location_country']= isset( $row->up_location_country ) ? $row->up_location_country : ''; |
83 | | - $profile['hometown_city']= isset( $row->up_hometown_city ) ? $row->up_hometown_city : ''; |
84 | | - $profile['hometown_state']= isset( $row->up_hometown_state ) ? $row->up_hometown_state : ''; |
85 | | - $profile['hometown_country']= isset( $row->up_hometown_country ) ? $row->up_hometown_country : ''; |
86 | | - $profile['birthday']= $this->formatBirthday( isset( $row->up_birthday ) ? $row->up_birthday : '' ); |
| 80 | + $profile['location_city'] = isset( $row->up_location_city ) ? $row->up_location_city : ''; |
| 81 | + $profile['location_state'] = isset( $row->up_location_state ) ? $row->up_location_state : ''; |
| 82 | + $profile['location_country'] = isset( $row->up_location_country ) ? $row->up_location_country : ''; |
| 83 | + $profile['hometown_city'] = isset( $row->up_hometown_city ) ? $row->up_hometown_city : ''; |
| 84 | + $profile['hometown_state'] = isset( $row->up_hometown_state ) ? $row->up_hometown_state : ''; |
| 85 | + $profile['hometown_country'] = isset( $row->up_hometown_country ) ? $row->up_hometown_country : ''; |
| 86 | + $profile['birthday'] = $this->formatBirthday( isset( $row->up_birthday ) ? $row->up_birthday : '' ); |
87 | 87 | |
88 | | - $profile['about']= isset( $row->up_about ) ? $row->up_about : ''; |
89 | | - $profile['places_lived']= isset( $row->up_places_lived ) ? $row->up_places_lived : ''; |
90 | | - $profile['websites']= isset( $row->up_websites ) ? $row->up_websites : ''; |
91 | | - $profile['relationship']= isset( $row->up_relationship ) ? $row->up_relationship : ''; |
92 | | - $profile['occupation']= isset( $row->up_occupation ) ? $row->up_occupation : ''; |
93 | | - $profile['schools']= isset( $row->up_schools ) ? $row->up_schools : ''; |
94 | | - $profile['movies']= isset( $row->up_movies ) ? $row->up_movies : ''; |
95 | | - $profile['music']= isset( $row->up_music ) ? $row->up_music : ''; |
96 | | - $profile['tv']= isset( $row->up_tv ) ? $row->up_tv : ''; |
97 | | - $profile['books']= isset( $row->up_books ) ? $row->up_books : ''; |
98 | | - $profile['magazines']= isset( $row->up_magazines ) ? $row->up_magazines : ''; |
99 | | - $profile['video_games']= isset( $row->up_video_games ) ? $row->up_video_games : ''; |
100 | | - $profile['snacks']= isset( $row->up_snacks ) ? $row->up_snacks : ''; |
101 | | - $profile['drinks']= isset( $row->up_drinks ) ? $row->up_drinks : ''; |
102 | | - $profile['custom_1']= isset( $row->up_custom_1 ) ? $row->up_custom_1 : ''; |
103 | | - $profile['custom_2']= isset( $row->up_custom_2 ) ? $row->up_custom_2 : ''; |
104 | | - $profile['custom_3']= isset( $row->up_custom_3 ) ? $row->up_custom_3 : ''; |
105 | | - $profile['custom_4']= isset( $row->up_custom_4 ) ? $row->up_custom_4 : ''; |
106 | | - $profile['custom_5']= isset( $row->up_custom_5 ) ? $row->up_custom_5 : ''; |
| 88 | + $profile['about'] = isset( $row->up_about ) ? $row->up_about : ''; |
| 89 | + $profile['places_lived'] = isset( $row->up_places_lived ) ? $row->up_places_lived : ''; |
| 90 | + $profile['websites'] = isset( $row->up_websites ) ? $row->up_websites : ''; |
| 91 | + $profile['relationship'] = isset( $row->up_relationship ) ? $row->up_relationship : ''; |
| 92 | + $profile['occupation'] = isset( $row->up_occupation ) ? $row->up_occupation : ''; |
| 93 | + $profile['schools'] = isset( $row->up_schools ) ? $row->up_schools : ''; |
| 94 | + $profile['movies'] = isset( $row->up_movies ) ? $row->up_movies : ''; |
| 95 | + $profile['music'] = isset( $row->up_music ) ? $row->up_music : ''; |
| 96 | + $profile['tv'] = isset( $row->up_tv ) ? $row->up_tv : ''; |
| 97 | + $profile['books'] = isset( $row->up_books ) ? $row->up_books : ''; |
| 98 | + $profile['magazines'] = isset( $row->up_magazines ) ? $row->up_magazines : ''; |
| 99 | + $profile['video_games'] = isset( $row->up_video_games ) ? $row->up_video_games : ''; |
| 100 | + $profile['snacks'] = isset( $row->up_snacks ) ? $row->up_snacks : ''; |
| 101 | + $profile['drinks'] = isset( $row->up_drinks ) ? $row->up_drinks : ''; |
| 102 | + $profile['custom_1'] = isset( $row->up_custom_1 ) ? $row->up_custom_1 : ''; |
| 103 | + $profile['custom_2'] = isset( $row->up_custom_2 ) ? $row->up_custom_2 : ''; |
| 104 | + $profile['custom_3'] = isset( $row->up_custom_3 ) ? $row->up_custom_3 : ''; |
| 105 | + $profile['custom_4'] = isset( $row->up_custom_4 ) ? $row->up_custom_4 : ''; |
| 106 | + $profile['custom_5'] = isset( $row->up_custom_5 ) ? $row->up_custom_5 : ''; |
107 | 107 | $profile['user_page_type'] = isset( $row->up_type ) ? $row->up_type : ''; |
108 | | - $wgMemc->set($key, $profile); |
| 108 | + $wgMemc->set( $key, $profile ); |
109 | 109 | } |
110 | 110 | |
111 | | - $user = User::newFromId($this->user_id); |
| 111 | + $user = User::newFromId( $this->user_id ); |
112 | 112 | $user->loadFromId(); |
113 | | - $profile['real_name']= $user->getRealName(); |
114 | | - $profile['email']= $user->getEmail(); |
| 113 | + $profile['real_name'] = $user->getRealName(); |
| 114 | + $profile['email'] = $user->getEmail(); |
115 | 115 | |
116 | 116 | return $profile; |
117 | 117 | } |
118 | 118 | |
119 | 119 | function formatBirthday( $birthday ){ |
120 | 120 | global $wgLang; |
121 | | - $dob = explode('-', $birthday); |
122 | | - if( count($dob) == 3 ){ |
| 121 | + $dob = explode( '-', $birthday ); |
| 122 | + if( count( $dob ) == 3 ){ |
123 | 123 | $month = $dob[1]; |
124 | 124 | $day = $dob[2]; |
125 | | - return date("F jS", mktime(0, 0, 0, $month, $day)); |
| 125 | + return date( "F jS", mktime( 0, 0, 0, $month, $day ) ); |
126 | 126 | return $day . ' ' . $wgLang->getMonthNameGen( $month ); |
127 | 127 | } |
128 | 128 | return $birthday; |
129 | 129 | } |
130 | 130 | |
131 | 131 | function getBirthdayYear( $birthday ){ |
132 | | - $dob = explode('-', $birthday); |
133 | | - if( count($dob) == 3 ){ |
| 132 | + $dob = explode( '-', $birthday ); |
| 133 | + if( count( $dob ) == 3 ){ |
134 | 134 | return $dob[0]; |
135 | 135 | } |
136 | | - return "00"; |
| 136 | + return '00'; |
137 | 137 | } |
138 | 138 | |
139 | 139 | public function getProfileComplete(){ |
140 | | - global $wgUser, $wgSitename; |
| 140 | + global $wgUser; |
141 | 141 | |
142 | 142 | $complete_count = 0; |
143 | 143 | |
— | — | @@ -149,12 +149,12 @@ |
150 | 150 | $this->profile_fields_count++; |
151 | 151 | } |
152 | 152 | |
153 | | - //check if avatar |
| 153 | + // Check if user has an avatar |
154 | 154 | $this->profile_fields_count++; |
155 | | - $avatar = new wAvatar($wgUser->getID(), 'l'); |
| 155 | + $avatar = new wAvatar( $wgUser->getID(), 'l' ); |
156 | 156 | if( strpos( $avatar->getAvatarImage(), 'default_' ) === false ) $complete_count++; |
157 | 157 | |
158 | | - return round($complete_count / $this->profile_fields_count * 100); |
| 158 | + return round( $complete_count / $this->profile_fields_count * 100 ); |
159 | 159 | } |
160 | 160 | |
161 | 161 | static function getEditProfileNav( $current_nav ){ |
— | — | @@ -162,14 +162,16 @@ |
163 | 163 | $output = '<div class="profile-tab-bar">'; |
164 | 164 | foreach( $lines as $line ) { |
165 | 165 | |
166 | | - if( strpos($line, '*') !== 0 ){ |
| 166 | + if( strpos( $line, '*' ) !== 0 ){ |
167 | 167 | continue; |
168 | 168 | } else { |
169 | | - $line = explode( '|' , trim($line, '* '), 2 ); |
170 | | - $page = Title::newFromText($line[0]); |
| 169 | + $line = explode( '|' , trim( $line, '* ' ), 2 ); |
| 170 | + $page = Title::newFromText( $line[0] ); |
171 | 171 | $link_text = $line[1]; |
172 | 172 | |
173 | | - $output .= "<div class=\"profile-tab" . ( ( $current_nav == $link_text ) ? '-on' : '' ) . "\"><a href=\"" . $page->escapeFullURL() . "\">{$link_text}</a></div>"; |
| 173 | + $output .= '<div class="profile-tab' . ( ( $current_nav == $link_text ) ? '-on' : '' ) . '"> |
| 174 | + <a href="' . $page->escapeFullURL() . "\">{$link_text}</a> |
| 175 | + </div>"; |
174 | 176 | } |
175 | 177 | } |
176 | 178 | $output .= '<div class="cleared"></div></div>'; |
Index: trunk/extensions/SocialProfile/images/voteIcon.gif |
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
Property changes on: trunk/extensions/SocialProfile/images/voteIcon.gif |
___________________________________________________________________ |
Added: svn:mime-type |
177 | 179 | + application/octet-stream |
Index: trunk/extensions/SocialProfile/images/comment.gif |
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
Property changes on: trunk/extensions/SocialProfile/images/comment.gif |
___________________________________________________________________ |
Added: svn:mime-type |
178 | 180 | + application/octet-stream |
Index: trunk/extensions/SocialProfile/images/icon_package.gif |
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
Property changes on: trunk/extensions/SocialProfile/images/icon_package.gif |
___________________________________________________________________ |
Added: svn:mime-type |
179 | 181 | + application/octet-stream |
Index: trunk/extensions/SocialProfile/UserGifts/UserGifts.js |
— | — | @@ -3,26 +3,26 @@ |
4 | 4 | function selectGift( id ){ |
5 | 5 | // Un-select previously selected gift |
6 | 6 | if( selected_gift ){ |
7 | | - YAHOO.util.Dom.removeClass("give_gift_"+selected_gift, 'g-give-all-selected'); |
| 7 | + YAHOO.util.Dom.removeClass( 'give_gift_' + selected_gift, 'g-give-all-selected' ); |
8 | 8 | } |
9 | 9 | |
10 | 10 | // Select new gift |
11 | | - YAHOO.util.Dom.addClass("give_gift_"+id, 'g-give-all-selected'); |
| 11 | + YAHOO.util.Dom.addClass( 'give_gift_' + id, 'g-give-all-selected' ); |
12 | 12 | |
13 | 13 | selected_gift = id; |
14 | 14 | } |
15 | 15 | |
16 | | -function highlightGift(id){ |
17 | | - YAHOO.util.Dom.addClass("give_gift_"+id, 'g-give-all-highlight'); |
| 16 | +function highlightGift( id ){ |
| 17 | + YAHOO.util.Dom.addClass( 'give_gift_' + id, 'g-give-all-highlight' ); |
18 | 18 | } |
19 | 19 | |
20 | | -function unHighlightGift(id){ |
21 | | - YAHOO.util.Dom.removeClass("give_gift_"+id, 'g-give-all-highlight'); |
| 20 | +function unHighlightGift( id ){ |
| 21 | + YAHOO.util.Dom.removeClass( 'give_gift_' + id, 'g-give-all-highlight' ); |
22 | 22 | } |
23 | 23 | |
24 | 24 | function sendGift(){ |
25 | 25 | if( !selected_gift ){ |
26 | | - alert("Please select a gift") |
| 26 | + alert( 'Please select a gift' ); |
27 | 27 | return false; |
28 | 28 | } |
29 | 29 | document.gift.gift_id.value = selected_gift; |
— | — | @@ -32,5 +32,5 @@ |
33 | 33 | function chooseFriend( friend ){ |
34 | 34 | // Now, this is a rather nasty hack since the original (commented out below) wouldn't work when $wgScriptPath was set |
35 | 35 | //window.location = window.location + "&user=" + friend; |
36 | | - window.location = wgServer + wgScript + "?title=Special:GiveGift" + "&user=" + friend; |
| 36 | + window.location = wgServer + wgScript + '?title=Special:GiveGift' + '&user=' + friend; |
37 | 37 | } |
\ No newline at end of file |
Index: trunk/extensions/SocialProfile/UserGifts/SpecialGiveGift.php |
— | — | @@ -20,12 +20,12 @@ |
21 | 21 | |
22 | 22 | $output = ''; // Prevent E_NOTICE |
23 | 23 | |
24 | | - $wgOut->addScriptFile( $wgUserGiftsScripts.'/UserGifts.js' ); |
25 | | - $wgOut->addStyle( '../..' . $wgUserGiftsScripts . '/UserGifts.css' ); |
| 24 | + $wgOut->addScriptFile( $wgUserGiftsScripts . '/UserGifts.js' ); |
| 25 | + $wgOut->addExtensionStyle( $wgUserGiftsScripts . '/UserGifts.css' ); |
26 | 26 | |
27 | 27 | $usertitle = Title::newFromDBkey( $wgRequest->getVal( 'user' ) ); |
28 | 28 | if( !$usertitle ) { |
29 | | - $wgOut->addHTML( $wgOut->addHTML( $this->displayFormNoUser() ) ); |
| 29 | + $wgOut->addHTML( /*$wgOut->addHTML(*/ $this->displayFormNoUser() /*)*/ ); |
30 | 30 | return false; |
31 | 31 | } |
32 | 32 | |
— | — | @@ -98,13 +98,13 @@ |
99 | 99 | <a href="' . $user_title->escapeFullURL() . '">' . wfMsg( 'g-back-link', $this->user_name_to ) . '</a> |
100 | 100 | </div> |
101 | 101 | <div class="g-message"> |
102 | | - '.wfMsg( 'g-sent-message', $this->user_name_to ).' |
| 102 | + ' . wfMsg( 'g-sent-message', $this->user_name_to ) . ' |
103 | 103 | </div> |
104 | 104 | <div class="g-container"> |
105 | | - '. $gift_image .' |
106 | | - <div class="g-title">'. $sent_gift['name'] .'</div>'; |
| 105 | + ' . $gift_image . ' |
| 106 | + <div class="g-title">' . $sent_gift['name'] . '</div>'; |
107 | 107 | if( $sent_gift['message'] ){ |
108 | | - $output .= '<div class="g-user-message">'. $sent_gift['message'] .'</div>'; |
| 108 | + $output .= '<div class="g-user-message">' . $sent_gift['message'] . '</div>'; |
109 | 109 | } |
110 | 110 | $output .= '</div> |
111 | 111 | <div class="cleared"></div> |
— | — | @@ -139,6 +139,10 @@ |
140 | 140 | |
141 | 141 | $gift = Gifts::getGift( $gift_id ); |
142 | 142 | |
| 143 | + if( empty( $gift ) ) { |
| 144 | + return false; |
| 145 | + } |
| 146 | + |
143 | 147 | if( $gift['access'] == 1 && $wgUser->getID() != $gift['creator_user_id'] ){ |
144 | 148 | return $this->displayFormAll(); |
145 | 149 | } |
— | — | @@ -155,7 +159,7 @@ |
156 | 160 | <div class="g-message"> |
157 | 161 | '.wfMsg( 'g-give-to-user-message', $this->user_name_to, $give_gift_link->escapeFullURL( 'user=' . $this->user_name_to ) )." |
158 | 162 | </div> |
159 | | - <div id=\"give_gift_{$gift["id"]}\" class=\"g-container\"> |
| 163 | + <div id=\"give_gift_{$gift["gift_id"]}\" class=\"g-container\"> |
160 | 164 | {$gift_image} |
161 | 165 | <div class=\"g-title\">{$gift["gift_name"]}</div>"; |
162 | 166 | if( $gift['gift_description'] ){ |
— | — | @@ -228,12 +232,13 @@ |
229 | 233 | |
230 | 234 | $total = Gifts::getGiftCount(); |
231 | 235 | $gifts = Gifts::getGiftList( $per_page, $page, 'gift_name' ); |
| 236 | + $output = ''; |
232 | 237 | |
233 | 238 | if( $gifts ) { |
234 | 239 | |
235 | | - $wgOut->setPagetitle( wfMsg( 'g-give-all-title', $this->user_name_to ) ); |
| 240 | + $wgOut->setPageTitle( wfMsg( 'g-give-all-title', $this->user_name_to ) ); |
236 | 241 | |
237 | | - $output = '<div class="back-links"> |
| 242 | + $output .= '<div class="back-links"> |
238 | 243 | <a href="' . $user->escapeFullURL() . '">' . wfMsg( 'g-back-link', $this->user_name_to ) . '</a> |
239 | 244 | </div> |
240 | 245 | <div class="g-message"> |
— | — | @@ -280,7 +285,7 @@ |
281 | 286 | } |
282 | 287 | } |
283 | 288 | |
284 | | - if( ($total - ($per_page * $page)) > 0 ) { |
| 289 | + if( ( $total - ( $per_page * $page ) ) > 0 ) { |
285 | 290 | $output .= ' <a href="'.$give_gift_link->escapeFullURL( 'user='.$user_safe.'&page='.( $page+1 ) ).'">'.wfMsg( 'g-next' ).'</a>'; |
286 | 291 | } |
287 | 292 | $output .= '</div>'; |
— | — | @@ -289,13 +294,13 @@ |
290 | 295 | /** |
291 | 296 | * Build next/prev nav |
292 | 297 | */ |
293 | | - $output .= '<div class="g-give-all-message-title">'.wfMsg( 'g-give-all-message-title' ).'</div> |
| 298 | + $output .= '<div class="g-give-all-message-title">' . wfMsg( 'g-give-all-message-title' ) . '</div> |
294 | 299 | <textarea name="message" id="message" rows="4" cols="50"></textarea> |
295 | 300 | <div class="g-buttons"> |
296 | | - <input type="hidden" name="gift_id" value="0"> |
297 | | - <input type="hidden" name="user_name" value="'.addslashes( $this->user_name_to ).'"> |
298 | | - <input type="button" class="site-button" value="'.wfMsg( 'g-send-gift' ).'" size="20" onclick="sendGift()"/> |
299 | | - <input type="button" class="site-button" value="'.wfMsg( 'g-cancel' ).'" size="20" onclick="history.go(-1)"/> |
| 301 | + <input type="hidden" name="gift_id" value="0" /> |
| 302 | + <input type="hidden" name="user_name" value="' . addslashes( $this->user_name_to ) . '" /> |
| 303 | + <input type="button" class="site-button" value="' . wfMsg( 'g-send-gift' ) . '" size="20" onclick="sendGift()" /> |
| 304 | + <input type="button" class="site-button" value="' . wfMsg( 'g-cancel' ) . '" size="20" onclick="history.go(-1)" /> |
300 | 305 | </div> |
301 | 306 | </form>'; |
302 | 307 | } else { |
Index: trunk/extensions/SocialProfile/UserSystemMessages/UserSystemMessagesClass.php |
— | — | @@ -0,0 +1,122 @@ |
| 2 | +<?php |
| 3 | +/** |
| 4 | + * UserSystemMessage class |
| 5 | + * Used to send "You have advanced to level [fill in this]" messages |
| 6 | + * to users when User Levels is activated ($wgUserLevels is defined) |
| 7 | + */ |
| 8 | +class UserSystemMessage { |
| 9 | + |
| 10 | + /** |
| 11 | + * Adds the message into the database |
| 12 | + * |
| 13 | + * @param $user_name Mixed: the name of the user who's receiving the message |
| 14 | + * @param $type Integer: 0 by default |
| 15 | + * @param $message Mixed: message to be sent out |
| 16 | + */ |
| 17 | + public function addMessage( $user_name, $type, $message ){ |
| 18 | + $user_id = User::idFromName( $user_name ); |
| 19 | + $dbw = wfGetDB( DB_MASTER ); |
| 20 | + |
| 21 | + $dbw->insert( 'user_system_messages', |
| 22 | + array( |
| 23 | + 'um_user_id' => $user_id, |
| 24 | + 'um_user_name' => $user_name, |
| 25 | + 'um_type' => $type, |
| 26 | + 'um_message' => $message, |
| 27 | + 'um_date' => date("Y-m-d H:i:s"), |
| 28 | + ), __METHOD__ |
| 29 | + ); |
| 30 | + $dbw->commit(); |
| 31 | + } |
| 32 | + |
| 33 | + /** |
| 34 | + * Deletes a message from the user_system_messages table in the database |
| 35 | + * @param $um_id Integer: internal ID number of the message to delete |
| 36 | + */ |
| 37 | + static function deleteMessage( $um_id ){ |
| 38 | + $dbw = wfGetDB( DB_MASTER ); |
| 39 | + $dbw->delete( 'user_system_messages', array( 'um_id' => $um_id ), __METHOD__ ); |
| 40 | + $dbw->commit(); |
| 41 | + } |
| 42 | + |
| 43 | + /** |
| 44 | + * Gets a list of system messages for the current user from the database |
| 45 | + * |
| 46 | + * @param $type Integer: 0 by default |
| 47 | + * @param $limit Integer: LIMIT for database queries, 0 by default |
| 48 | + * @param $page Integer: 0 by default |
| 49 | + * @return $requests |
| 50 | + */ |
| 51 | + public function getMessageList( $type, $limit = 0, $page = 0 ){ |
| 52 | + $dbw = wfGetDB( DB_MASTER ); |
| 53 | + |
| 54 | + $limit_sql = ''; |
| 55 | + if( $limit > 0 ){ |
| 56 | + $limitvalue = 0; |
| 57 | + if( $page ) |
| 58 | + $limitvalue = $page * $limit - ($limit); |
| 59 | + $limit_sql = " LIMIT {$limitvalue},{$limit} "; |
| 60 | + #$params['LIMIT'] = $limitvalue; |
| 61 | + } |
| 62 | + |
| 63 | +/* $params['ORDER BY'] = 'ug_id DESC'; |
| 64 | + $res = $dbw->select( array( 'user_gift', 'gift' ), |
| 65 | + array( |
| 66 | + 'ug_id', 'ug_user_id_from', 'ug_user_name_from', 'ug_gift_id', 'ug_date', 'ug_status', |
| 67 | + 'gift_name', 'gift_description', 'gift_given_count' |
| 68 | + ), |
| 69 | + array( 'ug_user_id_to' => $this->user_id ), |
| 70 | + __METHOD__, |
| 71 | + $params, |
| 72 | + array( 'gift' => array( 'INNER JOIN', 'ug_gift_id = gift_id' ) ) |
| 73 | + );*/ |
| 74 | + $sql = "SELECT ug_id, ug_user_id_from, ug_user_name_from, ug_gift_id, ug_date, ug_status, |
| 75 | + gift_name, gift_description, gift_given_count |
| 76 | + FROM {$dbw->tableName( 'user_gift' )} INNER JOIN {$dbw->tableName( 'gift' )} ON ug_gift_id=gift_id |
| 77 | + WHERE ug_user_id_to = {$this->user_id} |
| 78 | + ORDER BY ug_id DESC |
| 79 | + {$limit_sql}"; |
| 80 | + |
| 81 | + $res = $dbw->query( $sql ); |
| 82 | + $requests = array(); |
| 83 | + while ( $row = $dbw->fetchObject( $res ) ) { |
| 84 | + $requests[] = array( |
| 85 | + 'id' => $row->ug_id, |
| 86 | + 'gift_id' => $row->ug_gift_id, |
| 87 | + 'timestamp' => ( $row->ug_date ), |
| 88 | + 'status' => $row->ug_status, |
| 89 | + 'user_id_from' => $row->ug_user_id_from, |
| 90 | + 'user_name_from' => $row->ug_user_name_from, |
| 91 | + 'gift_name' => $row->gift_name, |
| 92 | + 'gift_description' => $row->gift_description, |
| 93 | + 'gift_given_count' => $row->gift_given_count |
| 94 | + ); |
| 95 | + } |
| 96 | + return $requests; |
| 97 | + } |
| 98 | + |
| 99 | + /** |
| 100 | + * Sends out the "you have advanced to level [fill in this]" messages to the users |
| 101 | + * |
| 102 | + * @param $user_id_to Integer: user ID of the receiver |
| 103 | + * @param $level Mixed: name of the level that the user advanced to |
| 104 | + */ |
| 105 | + public function sendAdvancementNotificationEmail( $user_id_to, $level ){ |
| 106 | + wfLoadExtensionMessages( 'SocialProfileUserStats' ); |
| 107 | + $user = User::newFromId( $user_id_to ); |
| 108 | + $user->loadFromDatabase(); |
| 109 | + if( $user->isEmailConfirmed() && $user->getIntOption( 'notifyhonorifics', 1 ) ){ |
| 110 | + $update_profile_link = SpecialPage::getTitleFor( 'UpdateProfile' ); |
| 111 | + $subject = wfMsgExt( 'level-advance-subject', 'parsemag', |
| 112 | + $level |
| 113 | + ); |
| 114 | + $body = wfMsgExt( 'level-advance-body', 'parsemag', |
| 115 | + ( ( trim( $user->getRealName() ) ) ? $user->getRealName() : $user->getName() ), |
| 116 | + $level, |
| 117 | + $update_profile_link->getFullURL() |
| 118 | + ); |
| 119 | + $user->sendMail( $subject, $body ); |
| 120 | + } |
| 121 | + } |
| 122 | + |
| 123 | +} |
\ No newline at end of file |
Property changes on: trunk/extensions/SocialProfile/UserSystemMessages/UserSystemMessagesClass.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 124 | + native |
Index: trunk/extensions/SocialProfile/UserSystemMessages/user_system_messages.sql |
— | — | @@ -0,0 +1,10 @@ |
| 2 | +CREATE TABLE /*$wgDBprefix*/user_system_messages ( |
| 3 | + `um_id` int(11) NOT NULL auto_increment, |
| 4 | + `um_user_id` int(11) NOT NULL default '0', |
| 5 | + `um_user_name` varchar(255) NOT NULL default '', |
| 6 | + `um_message` varchar(255) NOT NULL default '', |
| 7 | + `um_type` int(5) default '0', |
| 8 | + `um_date` datetime default NULL, |
| 9 | + PRIMARY KEY (`um_id`), |
| 10 | + KEY `up_user_id` (`um_user_id`) |
| 11 | +) ENGINE=InnoDB DEFAULT CHARSET=utf8; |
\ No newline at end of file |
Property changes on: trunk/extensions/SocialProfile/UserSystemMessages/user_system_messages.sql |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 12 | + native |
Index: trunk/extensions/SocialProfile/SocialProfile.php |
— | — | @@ -11,7 +11,7 @@ |
12 | 12 | * |
13 | 13 | * For more info about SocialProfile, please see the README file that was included with SocialProfile. |
14 | 14 | */ |
15 | | -$dir = dirname(__FILE__) . '/'; |
| 15 | +$dir = dirname( __FILE__ ) . '/'; |
16 | 16 | |
17 | 17 | // Internationalization files |
18 | 18 | $wgExtensionMessagesFiles['SocialProfileUserBoard'] = $dir . 'UserBoard/UserBoard.i18n.php'; |
— | — | @@ -42,6 +42,7 @@ |
43 | 43 | $wgAutoloadClasses['UserLevel'] = $dir . 'UserStats/UserStatsClass.php'; |
44 | 44 | $wgAutoloadClasses['UserStats'] = $dir . 'UserStats/UserStatsClass.php'; |
45 | 45 | $wgAutoloadClasses['UserStatsTrack'] = $dir . 'UserStats/UserStatsClass.php'; |
| 46 | +$wgAutoloadClasses['UserSystemMessage'] = $dir . 'UserSystemMessages/UserSystemMessagesClass.php'; |
46 | 47 | $wgAutoloadClasses['TopFansByStat'] = $dir. 'UserStats/TopFansByStat.php'; |
47 | 48 | $wgAutoloadClasses['TopFansRecent'] = $dir . 'UserStats/TopFansRecent.php'; |
48 | 49 | $wgAutoloadClasses['TopUsersPoints'] = $dir. 'UserStats/TopUsers.php'; |
— | — | @@ -91,8 +92,8 @@ |
92 | 93 | $wgExtensionCredits['other'][] = array( |
93 | 94 | 'path' => __FILE__, |
94 | 95 | 'name' => 'SocialProfile', |
95 | | - 'author' => 'Wikia, Inc. (Aaron Wright, David Pean)', |
96 | | - 'version' => '1.3', |
| 96 | + 'author' => array( 'Aaron Wright', 'David Pean', 'Jack Phoenix' ), |
| 97 | + 'version' => '1.4', |
97 | 98 | 'url' => 'http://www.mediawiki.org/wiki/Extension:SocialProfile', |
98 | 99 | 'description' => 'A set of Social Tools for MediaWiki', |
99 | 100 | ); |
— | — | @@ -193,3 +194,4 @@ |
194 | 195 | require_once("{$wgUserProfileDirectory}/UserProfile.php"); // Profile page configuration loader file |
195 | 196 | require_once("$IP/extensions/SocialProfile/UserGifts/Gifts.php"); // UserGifts (user-to-user gifting functionality) loader file |
196 | 197 | require_once("$IP/extensions/SocialProfile/SystemGifts/SystemGifts.php"); // SystemGifts (awards functionality) loader file |
| 198 | +require_once("$IP/extensions/SocialProfile/UserActivity/UserActivity.php"); // UserActivity - recent social changes |
\ No newline at end of file |
Index: trunk/extensions/SocialProfile/UserBoard/UserBoardClass.php |
— | — | @@ -366,10 +366,10 @@ |
367 | 367 | } |
368 | 368 | |
369 | 369 | public function getTimeOffset( $time, $timeabrv, $timename ){ |
| 370 | + wfLoadExtensionMessages( 'SocialProfileUserBoard' ); |
370 | 371 | $timeStr = ''; |
371 | 372 | if( $time[$timeabrv] > 0 ){ |
372 | | - $timeStr = $time[$timeabrv] . ' ' . $timename; |
373 | | - if( $time[$timeabrv] > 1 ) $timeStr .= 's'; |
| 373 | + $timeStr = wfMsgExt( "userboard-time-{$timename}", 'parsemag', $time[$timeabrv] ); |
374 | 374 | } |
375 | 375 | if( $timeStr ) $timeStr .= ' '; |
376 | 376 | return $timeStr; |
— | — | @@ -383,16 +383,17 @@ |
384 | 384 | public function getTimeAgo( $time ){ |
385 | 385 | $timeArray = $this->dateDiff( time(), $time ); |
386 | 386 | $timeStr = ''; |
387 | | - $timeStrD = $this->getTimeOffset( $timeArray, 'd', 'day' ); |
388 | | - $timeStrH = $this->getTimeOffset( $timeArray, 'h', 'hour' ); |
389 | | - $timeStrM = $this->getTimeOffset( $timeArray, 'm', 'minute' ); |
390 | | - $timeStrS = $this->getTimeOffset( $timeArray, 's', 'second' ); |
| 387 | + $timeStrD = $this->getTimeOffset( $timeArray, 'd', 'days' ); |
| 388 | + $timeStrH = $this->getTimeOffset( $timeArray, 'h', 'hours' ); |
| 389 | + $timeStrM = $this->getTimeOffset( $timeArray, 'm', 'minutes' ); |
| 390 | + $timeStrS = $this->getTimeOffset( $timeArray, 's', 'seconds' ); |
391 | 391 | $timeStr = $timeStrD; |
392 | 392 | if( $timeStr < 2 ){ |
393 | 393 | $timeStr.= $timeStrH; |
394 | 394 | $timeStr.= $timeStrM; |
395 | 395 | if( !$timeStr ) $timeStr.= $timeStrS; |
396 | 396 | } |
| 397 | + if( !$timeStr ) $timeStr = wfMsgExt( 'userboard-time-seconds', 'parsemag', 1 ); |
397 | 398 | return $timeStr; |
398 | 399 | } |
399 | 400 | } |
\ No newline at end of file |
Index: trunk/extensions/SocialProfile/UserBoard/UserBoard.i18n.php |
— | — | @@ -55,6 +55,10 @@ |
56 | 56 | 'userboard_loggedout' => 'You must be <a href="$1">logged in</a> to post messages to other users.', |
57 | 57 | 'userboard_showingmessages' => 'Showing {{PLURAL:$4|message $3|messages $2-$3}} of {{PLURAL:$1|$1 message|$1 messages}}', |
58 | 58 | 'right-userboard-delete' => "Delete others' board messages", |
| 59 | + 'userboard-time-days' => '{{PLURAL:$1|one day|$1 days}}', |
| 60 | + 'userboard-time-hours' => '{{PLURAL:$1|one hour|$1 hours}}', |
| 61 | + 'userboard-time-minutes' => '{{PLURAL:$1|one minute|$1 minutes}}', |
| 62 | + 'userboard-time-seconds' => '{{PLURAL:$1|one second|$1 seconds}}', |
59 | 63 | 'message_received_subject' => '$1 wrote on your board on {{SITENAME}}', |
60 | 64 | 'message_received_body' => 'Hi $1. |
61 | 65 | |
— | — | @@ -795,6 +799,10 @@ |
796 | 800 | 'userboard_loggedout' => 'Sinun tulee olla <a href="$1">kirjautunut sisään</a> lähettääksesi viestejä toisille käyttäjille.', |
797 | 801 | 'userboard_showingmessages' => 'Näkyvillä on {{PLURAL:$4|viesti $3|viestit $2–$3}}. Yhteensä {{PLURAL:$1|$1 viesti|$1 viestiä}}.', |
798 | 802 | 'right-userboard-delete' => 'Poistaa toisten käyttäjien keskustelualueviestejä', |
| 803 | + 'userboard-time-days' => '{{PLURAL:$1|päivä|$1 päivää}}', |
| 804 | + 'userboard-time-hours' => '{{PLURAL:$1|tunti|$1 tuntia}}', |
| 805 | + 'userboard-time-minutes' => '{{PLURAL:$1|minuutti|$1 minuuttia}}', |
| 806 | + 'userboard-time-seconds' => '{{PLURAL:$1|sekunti|$1 sekuntia}}', |
799 | 807 | 'message_received_subject' => '$1 kirjoitti keskustelualueellesi {{GRAMMAR:inessive|{{SITENAME}}}}', |
800 | 808 | 'message_received_body' => 'Hei $1: |
801 | 809 | |