Index: trunk/extensions/CodeReview/CodeReview.php |
— | — | @@ -155,6 +155,13 @@ |
156 | 156 | */ |
157 | 157 | $wgCodeReviewDeferredPaths = array(); |
158 | 158 | |
| 159 | +/** |
| 160 | + * UDP comment and status changes notification |
| 161 | + */ |
| 162 | +$wgCRUDPAddress = false; |
| 163 | +$wgCRUDPPort = false; |
| 164 | +$wgCRUDPPrefix = ''; |
| 165 | + |
159 | 166 | # Schema changes |
160 | 167 | $wgHooks['LoadExtensionSchemaUpdates'][] = 'efCodeReviewSchemaUpdates'; |
161 | 168 | |
Index: trunk/extensions/CodeReview/backend/CodeRevision.php |
— | — | @@ -180,6 +180,9 @@ |
181 | 181 | __METHOD__ |
182 | 182 | ); |
183 | 183 | } |
| 184 | + |
| 185 | + $this->sendStatusToUDP( $status, $oldStatus ); |
| 186 | + |
184 | 187 | return true; |
185 | 188 | } |
186 | 189 | |
— | — | @@ -441,6 +444,8 @@ |
442 | 445 | } |
443 | 446 | } |
444 | 447 | |
| 448 | + $this->sendCommentToUDP( $commentId, $text, $url ); |
| 449 | + |
445 | 450 | return $commentId; |
446 | 451 | } |
447 | 452 | |
— | — | @@ -780,4 +785,40 @@ |
781 | 786 | return false; |
782 | 787 | } |
783 | 788 | } |
| 789 | + |
| 790 | + protected function sendCommentToUDP( $commentId, $text, $url = null ) { |
| 791 | + global $wgCodeReviewUDPAddress, $wgCodeReviewUDPPort, $wgCodeReviewUDPPrefix, $wgLang, $wgUser; |
| 792 | + |
| 793 | + if( $wgCodeReviewUDPAddress ) { |
| 794 | + if( is_null( $url ) ) { |
| 795 | + $title = SpecialPage::getTitleFor( 'Code', $this->mRepo->getName() . '/' . $this->mId ); |
| 796 | + $title->setFragment( "#c{$commentId}" ); |
| 797 | + $url = $title->getFullUrl(); |
| 798 | + } |
| 799 | + |
| 800 | + $line = wfMsg( 'code-rev-message' ) . " \00314(" . $this->mRepo->getName() . |
| 801 | + ")\003 \0037" . $this->getIdString() . "\003 \00303" . RecentChange::cleanupForIRC( $wgUser->getName() ) . |
| 802 | + "\003: \00310" . RecentChange::cleanupForIRC( $wgLang->truncate( $text, 100 ) ) . "\003 " . $url; |
| 803 | + |
| 804 | + RecentChange::sendToUDP( $line, $wgCodeReviewUDPAddress, $wgCodeReviewUDPPrefix, $wgCodeReviewUDPPort ); |
| 805 | + } |
| 806 | + } |
| 807 | + |
| 808 | + protected function sendStatusToUDP( $status, $oldStatus ) { |
| 809 | + global $wgCodeReviewUDPAddress, $wgCodeReviewUDPPort, $wgCodeReviewUDPPrefix, $wgUser; |
| 810 | + |
| 811 | + if( $wgCodeReviewUDPAddress ) { |
| 812 | + $title = SpecialPage::getTitleFor( 'Code', $this->mRepo->getName() . '/' . $this->getId() ); |
| 813 | + $url = $title->getFullUrl(); |
| 814 | + |
| 815 | + $line = wfMsg( 'code-rev-status' ) . " \00314(" . $this->mRepo->getName() . |
| 816 | + ")\00303 " . RecentChange::cleanupForIRC( $wgUser->getName() ) . "\003 " . |
| 817 | + /* Remove three apostrophes as they are intended for the parser */ |
| 818 | + str_replace( "'''", '', wfMsg( 'code-change-status', "\0037" . $this->getIdString() . "\003" ) ) . |
| 819 | + ": \00315" . wfMsg( 'code-status-' . $oldStatus ) . "\003 -> \00310" . |
| 820 | + wfMsg( 'code-status-' . $status ) . "\003 " . $url; |
| 821 | + |
| 822 | + RecentChange::sendToUDP( $line, $wgCodeReviewUDPAddress, $wgCodeReviewUDPPrefix, $wgCodeReviewUDPPort ); |
| 823 | + } |
| 824 | + } |
784 | 825 | } |