http://www.mediawiki.org/wiki/Special:Code/MediaWiki/70660
Revision: 70660 Author: soxred93 Date: 2010-08-08 05:06:56 +0000 (Sun, 08 Aug 2010) Log Message: ----------- (bug 24107) CodeReview now sends UDP messages when an update is made. Patch by John Du Hart Modified Paths: -------------- trunk/extensions/CodeReview/CodeReview.php trunk/extensions/CodeReview/backend/CodeRevision.php Modified: trunk/extensions/CodeReview/CodeReview.php =================================================================== --- trunk/extensions/CodeReview/CodeReview.php 2010-08-08 02:20:56 UTC (rev 70659) +++ trunk/extensions/CodeReview/CodeReview.php 2010-08-08 05:06:56 UTC (rev 70660) @@ -155,6 +155,13 @@ */ $wgCodeReviewDeferredPaths = array(); +/** + * UDP comment and status changes notification + */ +$wgCRUDPAddress = false; +$wgCRUDPPort = false; +$wgCRUDPPrefix = ''; + # Schema changes $wgHooks['LoadExtensionSchemaUpdates'][] = 'efCodeReviewSchemaUpdates'; Modified: trunk/extensions/CodeReview/backend/CodeRevision.php =================================================================== --- trunk/extensions/CodeReview/backend/CodeRevision.php 2010-08-08 02:20:56 UTC (rev 70659) +++ trunk/extensions/CodeReview/backend/CodeRevision.php 2010-08-08 05:06:56 UTC (rev 70660) @@ -180,6 +180,9 @@ __METHOD__ ); } + + $this->sendStatusToUDP( $status, $oldStatus ); + return true; } @@ -441,6 +444,8 @@ } } + $this->sendCommentToUDP( $commentId, $text, $url ); + return $commentId; } @@ -780,4 +785,40 @@ return false; } } + + protected function sendCommentToUDP( $commentId, $text, $url = null ) { + global $wgCodeReviewUDPAddress, $wgCodeReviewUDPPort, $wgCodeReviewUDPPrefix, $wgLang, $wgUser; + + if( $wgCodeReviewUDPAddress ) { + if( is_null( $url ) ) { + $title = SpecialPage::getTitleFor( 'Code', $this->mRepo->getName() . '/' . $this->mId ); + $title->setFragment( "#c{$commentId}" ); + $url = $title->getFullUrl(); + } + + $line = wfMsg( 'code-rev-message' ) . " \00314(" . $this->mRepo->getName() . + ")\003 \0037" . $this->getIdString() . "\003 \00303" . RecentChange::cleanupForIRC( $wgUser->getName() ) . + "\003: \00310" . RecentChange::cleanupForIRC( $wgLang->truncate( $text, 100 ) ) . "\003 " . $url; + + RecentChange::sendToUDP( $line, $wgCodeReviewUDPAddress, $wgCodeReviewUDPPrefix, $wgCodeReviewUDPPort ); + } + } + + protected function sendStatusToUDP( $status, $oldStatus ) { + global $wgCodeReviewUDPAddress, $wgCodeReviewUDPPort, $wgCodeReviewUDPPrefix, $wgUser; + + if( $wgCodeReviewUDPAddress ) { + $title = SpecialPage::getTitleFor( 'Code', $this->mRepo->getName() . '/' . $this->getId() ); + $url = $title->getFullUrl(); + + $line = wfMsg( 'code-rev-status' ) . " \00314(" . $this->mRepo->getName() . + ")\00303 " . RecentChange::cleanupForIRC( $wgUser->getName() ) . "\003 " . + /* Remove three apostrophes as they are intended for the parser */ + str_replace( "'''", '', wfMsg( 'code-change-status', "\0037" . $this->getIdString() . "\003" ) ) . + ": \00315" . wfMsg( 'code-status-' . $oldStatus ) . "\003 -> \00310" . + wfMsg( 'code-status-' . $status ) . "\003 " . $url; + + RecentChange::sendToUDP( $line, $wgCodeReviewUDPAddress, $wgCodeReviewUDPPrefix, $wgCodeReviewUDPPort ); + } + } } _______________________________________________ MediaWiki-CVS mailing list MediaWiki-CVS@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs