Index: trunk/extensions/CodeReview/backend/CodeRevision.php |
— | — | @@ -137,17 +137,17 @@ |
138 | 138 | return $this->mCommonPath; |
139 | 139 | } |
140 | 140 | |
141 | | - /* |
| 141 | + /** |
142 | 142 | * List of all possible states a CodeRevision can be in |
143 | | - * return Array |
| 143 | + * @return Array |
144 | 144 | */ |
145 | 145 | public static function getPossibleStates() { |
146 | 146 | return array( 'new', 'fixme', 'reverted', 'resolved', 'ok', 'verified', 'deferred', 'old' ); |
147 | 147 | } |
148 | 148 | |
149 | | - /* |
| 149 | + /** |
150 | 150 | * List of all flags a user can mark themself as having done to a revision |
151 | | - * Return Array |
| 151 | + * @return Array |
152 | 152 | */ |
153 | 153 | public static function getPossibleFlags() { |
154 | 154 | return array( 'inspected', 'tested' ); |
— | — | @@ -636,6 +636,11 @@ |
637 | 637 | return $refs; |
638 | 638 | } |
639 | 639 | |
| 640 | + /** |
| 641 | + * Get all sign-offs for this revision |
| 642 | + * @param $from DB_SLAVE or DB_MASTER |
| 643 | + * @return array of CodeSignoff objects |
| 644 | + */ |
640 | 645 | public function getSignoffs( $from = DB_SLAVE ) { |
641 | 646 | $db = wfGetDB( $from ); |
642 | 647 | $result = $db->select( 'code_signoffs', |
— | — | @@ -656,14 +661,14 @@ |
657 | 662 | } |
658 | 663 | |
659 | 664 | /** |
660 | | - * @param $user User |
661 | | - * @param $flags |
662 | | - * @return void |
| 665 | + * Add signoffs for this revision |
| 666 | + * @param $user User object for the user who did the sign-off |
| 667 | + * @param $flags array of flags (strings, see getPossibleFlags()). Each flag is added as a separate sign-off |
663 | 668 | */ |
664 | 669 | public function addSignoff( $user, $flags ) { |
665 | 670 | $dbw = wfGetDB( DB_MASTER ); |
666 | 671 | $rows = array(); |
667 | | - foreach ( $flags as $flag ) { |
| 672 | + foreach ( (array)$flags as $flag ) { |
668 | 673 | $rows[] = array( |
669 | 674 | 'cs_repo_id' => $this->mRepoId, |
670 | 675 | 'cs_rev_id' => $this->mId, |
Index: trunk/extensions/CodeReview/ui/CodeRevisionView.php |
— | — | @@ -218,6 +218,9 @@ |
219 | 219 | return $wgUser->isAllowed( 'codereview-post-comment' ) && !$wgUser->isBlocked(); |
220 | 220 | } |
221 | 221 | |
| 222 | + /** |
| 223 | + * @return bool Whether the current user can sign off on revisions |
| 224 | + */ |
222 | 225 | protected function canSignoff() { |
223 | 226 | global $wgUser; |
224 | 227 | return $wgUser->isAllowed( 'codereview-signoff' ) && !$wgUser->isBlocked(); |
— | — | @@ -427,6 +430,11 @@ |
428 | 431 | return wfMsg( 'code-load-diff' ); |
429 | 432 | } |
430 | 433 | |
| 434 | + /** |
| 435 | + * Format the sign-offs table |
| 436 | + * @param $showButtons bool Whether the buttons to strike and submit sign-offs should be shown |
| 437 | + * @return string HTML |
| 438 | + */ |
431 | 439 | protected function formatSignoffs( $showButtons ) { |
432 | 440 | $signoffs = implode( "\n", |
433 | 441 | array_map( array( $this, 'formatSignoffInline' ), $this->mRev->getSignoffs() ) |
— | — | @@ -477,8 +485,9 @@ |
478 | 486 | } |
479 | 487 | |
480 | 488 | /** |
481 | | - * @param $signoff CodeSignoff |
482 | | - * @return string |
| 489 | + * Format a single sign-off row. Helper function for formatSignoffs() |
| 490 | + * @param $signoff CodeSignoff |
| 491 | + * @return string HTML |
483 | 492 | */ |
484 | 493 | protected function formatSignoffInline( $signoff ) { |
485 | 494 | global $wgLang; |
— | — | @@ -656,7 +665,12 @@ |
657 | 666 | '</div>'; |
658 | 667 | } |
659 | 668 | |
660 | | - /** TODO : checkboxes should be disabled if user already has set the flag */ |
| 669 | + // TODO : checkboxes should be disabled if user already has set the flag |
| 670 | + /** |
| 671 | + * Render the bottom row of the sign-offs table containing the buttons to |
| 672 | + * strike and submit sign-offs |
| 673 | + * @return string HTML |
| 674 | + */ |
661 | 675 | protected function signoffButtons() { |
662 | 676 | $strikeButton = Xml::submitButton( wfMsg( 'code-signoff-strike' ), array( 'name' => 'wpStrikeSignoffs' ) ); |
663 | 677 | $signoffText = wfMsgHtml( 'code-signoff-signoff' ); |