r77326 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r77325‎ | r77326 | r77327 >
Date:12:18, 26 November 2010
Author:catrope
Status:ok
Tags:
Comment:
Document functions added in r75327, r77302 (sign-off feature), fix comments added in r76930. Cast $flags parameter to array in CodeRevision::addSignoff()
Modified paths:
  • /trunk/extensions/CodeReview/backend/CodeRevision.php (modified) (history)
  • /trunk/extensions/CodeReview/ui/CodeRevisionView.php (modified) (history)

Diff [purge]

Index: trunk/extensions/CodeReview/backend/CodeRevision.php
@@ -137,17 +137,17 @@
138138 return $this->mCommonPath;
139139 }
140140
141 - /*
 141+ /**
142142 * List of all possible states a CodeRevision can be in
143 - * return Array
 143+ * @return Array
144144 */
145145 public static function getPossibleStates() {
146146 return array( 'new', 'fixme', 'reverted', 'resolved', 'ok', 'verified', 'deferred', 'old' );
147147 }
148148
149 - /*
 149+ /**
150150 * List of all flags a user can mark themself as having done to a revision
151 - * Return Array
 151+ * @return Array
152152 */
153153 public static function getPossibleFlags() {
154154 return array( 'inspected', 'tested' );
@@ -636,6 +636,11 @@
637637 return $refs;
638638 }
639639
 640+ /**
 641+ * Get all sign-offs for this revision
 642+ * @param $from DB_SLAVE or DB_MASTER
 643+ * @return array of CodeSignoff objects
 644+ */
640645 public function getSignoffs( $from = DB_SLAVE ) {
641646 $db = wfGetDB( $from );
642647 $result = $db->select( 'code_signoffs',
@@ -656,14 +661,14 @@
657662 }
658663
659664 /**
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
663668 */
664669 public function addSignoff( $user, $flags ) {
665670 $dbw = wfGetDB( DB_MASTER );
666671 $rows = array();
667 - foreach ( $flags as $flag ) {
 672+ foreach ( (array)$flags as $flag ) {
668673 $rows[] = array(
669674 'cs_repo_id' => $this->mRepoId,
670675 'cs_rev_id' => $this->mId,
Index: trunk/extensions/CodeReview/ui/CodeRevisionView.php
@@ -218,6 +218,9 @@
219219 return $wgUser->isAllowed( 'codereview-post-comment' ) && !$wgUser->isBlocked();
220220 }
221221
 222+ /**
 223+ * @return bool Whether the current user can sign off on revisions
 224+ */
222225 protected function canSignoff() {
223226 global $wgUser;
224227 return $wgUser->isAllowed( 'codereview-signoff' ) && !$wgUser->isBlocked();
@@ -427,6 +430,11 @@
428431 return wfMsg( 'code-load-diff' );
429432 }
430433
 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+ */
431439 protected function formatSignoffs( $showButtons ) {
432440 $signoffs = implode( "\n",
433441 array_map( array( $this, 'formatSignoffInline' ), $this->mRev->getSignoffs() )
@@ -477,8 +485,9 @@
478486 }
479487
480488 /**
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
483492 */
484493 protected function formatSignoffInline( $signoff ) {
485494 global $wgLang;
@@ -656,7 +665,12 @@
657666 '</div>';
658667 }
659668
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+ */
661675 protected function signoffButtons() {
662676 $strikeButton = Xml::submitButton( wfMsg( 'code-signoff-strike' ), array( 'name' => 'wpStrikeSignoffs' ) );
663677 $signoffText = wfMsgHtml( 'code-signoff-signoff' );

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r75327CodeReview: (bug 24380) Add sign-off feature where any coder can sign off on ...catrope18:16, 24 October 2010
r76930bug 25940 Add API module(s) to add comments/set revision status...reedy00:42, 18 November 2010
r77302(bug 26014) Allow users to strike their own sign-offs. Implemented with a tim...catrope21:39, 25 November 2010

Status & tagging log