Index: trunk/extensions/CodeReview/backend/CodeRevision.php |
— | — | @@ -1027,6 +1027,21 @@ |
1028 | 1028 | } |
1029 | 1029 | |
1030 | 1030 | /** |
| 1031 | + * Remove references to the specified revisions from this revision. |
| 1032 | + * |
| 1033 | + * @param $revs array of revision IDs |
| 1034 | + */ |
| 1035 | + public function removeReferencesTo( $revs ) { |
| 1036 | + $dbw = wfGetDB( DB_MASTER ); |
| 1037 | + $dbw->delete( 'code_relations', array( |
| 1038 | + 'cf_repo_id' => $this->getRepoId(), |
| 1039 | + 'cf_from' => $this->getId(), |
| 1040 | + 'cf_to' => $revs |
| 1041 | + ), __METHOD__ |
| 1042 | + ); |
| 1043 | + } |
| 1044 | + |
| 1045 | + /** |
1031 | 1046 | * Get all sign-offs for this revision |
1032 | 1047 | * @param $from int DB_SLAVE or DB_MASTER |
1033 | 1048 | * @return array of CodeSignoff objects |
Index: trunk/extensions/CodeReview/api/ApiRevisionUpdate.php |
— | — | @@ -66,7 +66,9 @@ |
67 | 67 | $params['removeflags'], |
68 | 68 | $params['addreferences'], |
69 | 69 | $params['removereferences'], |
70 | | - $params['comment'] |
| 70 | + $params['comment'], |
| 71 | + $params['addreferenced'], |
| 72 | + $params['removereferenced'] |
71 | 73 | ); |
72 | 74 | |
73 | 75 | // Forge a response object |
— | — | @@ -134,6 +136,14 @@ |
135 | 137 | ApiBase::PARAM_TYPE => 'integer', |
136 | 138 | ApiBase::PARAM_ISMULTI => true, |
137 | 139 | ), |
| 140 | + 'addreferenced' => array( |
| 141 | + ApiBase::PARAM_TYPE => 'integer', |
| 142 | + ApiBase::PARAM_ISMULTI => true, |
| 143 | + ), |
| 144 | + 'removereferenced' => array( |
| 145 | + ApiBase::PARAM_TYPE => 'integer', |
| 146 | + ApiBase::PARAM_ISMULTI => true, |
| 147 | + ), |
138 | 148 | ); |
139 | 149 | } |
140 | 150 | |
— | — | @@ -149,6 +159,8 @@ |
150 | 160 | 'removeflags' => 'Code Signoff flags to strike from the revision by the current user', |
151 | 161 | 'addreferences' => 'Add references to this revision', |
152 | 162 | 'removereferences' => 'Remove references from this revision', |
| 163 | + 'addreferenced' => 'Add referenced revisions from this revision', |
| 164 | + 'removereferenced' => 'Remove referenced revisions from this revision', |
153 | 165 | ); |
154 | 166 | } |
155 | 167 | |
Index: trunk/extensions/CodeReview/ui/CodeRevisionCommitter.php |
— | — | @@ -15,9 +15,10 @@ |
16 | 16 | } |
17 | 17 | |
18 | 18 | $commentId = $this->revisionUpdate( $this->mStatus, $this->mAddTags, $this->mRemoveTags, |
19 | | - $this->mSignoffFlags, $this->mStrikeSignoffs, $this->mAddReferences, $this->mRemoveReferences, |
20 | | - $this->text, $wgRequest->getIntOrNull( 'wpParent' ), |
21 | | - $wgRequest->getInt( 'wpReview' ) |
| 19 | + $this->mSignoffFlags, $this->mStrikeSignoffs, |
| 20 | + $this->mAddReferences, $this->mRemoveReferences, |
| 21 | + $this->text, $wgRequest->getIntOrNull( 'wpParent' ), $wgRequest->getInt( 'wpReview' ), |
| 22 | + $this->mAddReferenced, $this->mRemoveReferenced |
22 | 23 | ); |
23 | 24 | |
24 | 25 | $redirTarget = null; |
— | — | @@ -62,7 +63,9 @@ |
63 | 64 | */ |
64 | 65 | public function revisionUpdate( $status, $addTags, $removeTags, $addSignoffs, $strikeSignoffs, |
65 | 66 | $addReferences, $removeReferences, $commentText, |
66 | | - $parent = null, $review = 0 ) { |
| 67 | + $parent = null, $review = 0, |
| 68 | + $addReferenced, $removeReferenced |
| 69 | + ) { |
67 | 70 | if ( !$this->mRev ) { |
68 | 71 | return false; |
69 | 72 | } |
— | — | @@ -104,6 +107,14 @@ |
105 | 108 | if ( count( $removeReferences ) && $this->validPost( 'codereview-associate' ) ) { |
106 | 109 | $this->mRev->removeReferencesFrom( $removeReferences ); |
107 | 110 | } |
| 111 | + // Add reference if requested |
| 112 | + if ( count( $addReferenced ) && $this->validPost( 'codereview-associate' ) ) { |
| 113 | + $this->mRev->addReferencesTo( $addReferenced ); |
| 114 | + } |
| 115 | + // Remove references if requested |
| 116 | + if ( count( $removeReferenced ) && $this->validPost( 'codereview-associate' ) ) { |
| 117 | + $this->mRev->removeReferencesFrom( $removeReferenced ); |
| 118 | + } |
108 | 119 | |
109 | 120 | // Add any comments |
110 | 121 | $commentAdded = false; |
Index: trunk/extensions/CodeReview/ui/CodeRevisionView.php |
— | — | @@ -54,7 +54,14 @@ |
55 | 55 | : array(); |
56 | 56 | |
57 | 57 | $this->mRemoveReferences = $wgRequest->getCheck( 'wpRemoveReferences' ) ? |
58 | | - $wgRequest->getIntArray( 'wpReferences', array() ) : array(); |
| 58 | + $wgRequest->getIntArray( 'wpReferenced', array() ) : array(); |
| 59 | + |
| 60 | + $this->mAddReferenced = $wgRequest->getCheck( 'wpAddReferencedSubmit' ) |
| 61 | + ? $this->stringToRevList( $wgRequest->getText( 'wpAddReferenced' ) ) |
| 62 | + : array(); |
| 63 | + |
| 64 | + $this->mRemoveReferenced = $wgRequest->getCheck( 'wpRemoveReferenced' ) ? |
| 65 | + $wgRequest->getIntArray( 'wpReferenced', array() ) : array(); |
59 | 66 | } |
60 | 67 | |
61 | 68 | /** |
— | — | @@ -189,7 +196,7 @@ |
190 | 197 | $referenced = $this->mRev->getFollowedUpRevisions(); |
191 | 198 | if ( count( $referenced ) || $userCanAssociate ) { |
192 | 199 | $html .= "<h2 id='code-referenced'>" . wfMsgHtml( 'code-referenced' ) . |
193 | | - "</h2>\n" . $this->formatReferences( $referenced, /*$userCanAssociate*/false, 'Referenced' ); |
| 200 | + "</h2>\n" . $this->formatReferences( $referenced, $userCanAssociate, 'Referenced' ); |
194 | 201 | } |
195 | 202 | |
196 | 203 | # Add revision comments |