Index: trunk/extensions/CodeReview/CodeReview.php |
— | — | @@ -72,11 +72,13 @@ |
73 | 73 | $wgAvailableRights[] = 'codereview-remove-tag'; |
74 | 74 | $wgAvailableRights[] = 'codereview-post-comment'; |
75 | 75 | $wgAvailableRights[] = 'codereview-set-status'; |
| 76 | +$wgAvailableRights[] = 'codereview-link-user'; |
76 | 77 | |
77 | 78 | $wgGroupPermissions['*']['codereview-add-tag'] = true; |
78 | 79 | $wgGroupPermissions['*']['codereview-remove-tag'] = true; |
79 | 80 | $wgGroupPermissions['*']['codereview-post-comment'] = true; |
80 | 81 | $wgGroupPermissions['*']['codereview-set-status'] = true; |
| 82 | +$wgGroupPermissions['*']['codereview-link-user'] = true; |
81 | 83 | |
82 | 84 | $wgGroupPermissions['steward']['repoadmin'] = true; // temp |
83 | 85 | |
Index: trunk/extensions/CodeReview/CodeRevisionAuthorView.php |
— | — | @@ -9,6 +9,86 @@ |
10 | 10 | function getPager() { |
11 | 11 | return new SvnRevAuthorTablePager( $this, $this->mAuthor ); |
12 | 12 | } |
| 13 | + |
| 14 | + function execute() { |
| 15 | + global $wgOut, $wgUser, $wgRequest; |
| 16 | + |
| 17 | + $name = $wgRequest->getVal( 'user' ); |
| 18 | + |
| 19 | + if ( $name ) { |
| 20 | + $this->linkTo( $name ); |
| 21 | + return; |
| 22 | + } |
| 23 | + |
| 24 | + $user = $this->authorWikiUser( $this->mAuthor ); |
| 25 | + if ( $user ) { |
| 26 | + $auth = wfMsgHtml( 'code-author-haslink', |
| 27 | + $this->mSkin->userLink( $user->getId(), $user->getName() ) . |
| 28 | + $this->mSkin->userToolLinks( $user->getId(), $user->getName() ) |
| 29 | + ); |
| 30 | + $wgOut->addHtml($auth); |
| 31 | + } |
| 32 | + |
| 33 | + parent::execute(); |
| 34 | + |
| 35 | + if ( $wgUser->isAllowed( 'codereview-link-user' ) && !$user ) { |
| 36 | + $wgOut->addHtml( |
| 37 | + Xml::openElement( 'form', |
| 38 | + array( 'method' => 'get', |
| 39 | + 'action' => $this->getPager()->getTitle()->getLocalUrl(), |
| 40 | + 'name' => 'uluser', |
| 41 | + 'id' => 'mw-codeauthor-form1' |
| 42 | + ) |
| 43 | + ) . |
| 44 | + Xml::openElement( 'fieldset' ) . |
| 45 | + Xml::element( 'legend', array(), wfMsg( 'code-author-dolink' ) ) . |
| 46 | + Xml::inputLabel( wfMsg( 'code-author-name' ), 'user', 'username', 30, '') . ' ' . |
| 47 | + Xml::submitButton( wfMsg( 'ok' ) ) . |
| 48 | + Xml::closeElement( 'fieldset' ) . |
| 49 | + Xml::closeElement( 'form' ) . "\n" |
| 50 | + ); |
| 51 | + } |
| 52 | + } |
| 53 | + |
| 54 | + /* |
| 55 | + * Link the author to the wikiuser $name |
| 56 | + */ |
| 57 | + function linkTo ( $name ) { |
| 58 | + global $wgOut, $wgUser; |
| 59 | + |
| 60 | + if ( !$wgUser->isAllowed( 'codereview-link-user' ) ) { |
| 61 | + $wgOut->permissionRequired( 'codereview-link-user' ); |
| 62 | + return; |
| 63 | + } |
| 64 | + |
| 65 | + if( $name == '' ) { |
| 66 | + $wgOut->addWikiMsg( 'nouserspecified' ); |
| 67 | + return; |
| 68 | + } |
| 69 | + $user = User::newFromName( $name ); |
| 70 | + |
| 71 | + if( !$user || $user->isAnon() ) { |
| 72 | + $wgOut->addWikiMsg( 'nosuchusershort', $name ); |
| 73 | + return; |
| 74 | + } |
| 75 | + $dbw = wfGetDB( DB_MASTER ); |
| 76 | + $dbw->insert( |
| 77 | + 'code_authors', |
| 78 | + array( |
| 79 | + 'ca_repo_id' => $this->mRepo->getId(), |
| 80 | + 'ca_author' => $this->mAuthor, |
| 81 | + 'ca_user_text' => $user->getName() |
| 82 | + ), |
| 83 | + __METHOD__ |
| 84 | + ); |
| 85 | + $authorlink = $this->mSkin->link( $this->getPager()->getTitle(), $this->mAuthor); |
| 86 | + $userlink = $this->mSkin->userLink( $user->getId(), $user->getName() ); |
| 87 | + $wgOut->addHtml( |
| 88 | + '<div class="successbox">' . |
| 89 | + wfMsgHtml( 'code-author-success', $authorlink, $userlink) . |
| 90 | + '</div>' |
| 91 | + ); |
| 92 | + } |
13 | 93 | } |
14 | 94 | |
15 | 95 | class SvnRevAuthorTablePager extends SvnRevTablePager { |
Index: trunk/extensions/CodeReview/CodeReview.i18n.php |
— | — | @@ -13,6 +13,10 @@ |
14 | 14 | 'code-comments' => 'Comments', |
15 | 15 | 'code-desc' => '[[Special:Code|Code review tool]] with [[Special:RepoAdmin|Subversion support]]', |
16 | 16 | 'code-no-repo' => 'No repository configured!', |
| 17 | + 'code-author-haslink' => 'This author is linked to the wikiuser $1', |
| 18 | + 'code-author-dolink' => 'Link this author to a wiki user :', |
| 19 | + 'code-author-name' => 'Enter a username:', |
| 20 | + 'code-author-success' => 'The author $1 has been successfully linked to the wiki user $2', |
17 | 21 | 'code-field-id' => 'Revision', |
18 | 22 | 'code-field-author' => 'Author', |
19 | 23 | 'code-field-message' => 'Comment', |
— | — | @@ -253,6 +257,9 @@ |
254 | 258 | 'code' => 'Vérification du code', |
255 | 259 | 'code-comments' => 'Commentaires', |
256 | 260 | 'code-desc' => '[[Special:Code|Outils pour revoir le code]] avec [[Special:RepoAdmin|support de Subversion]]', |
| 261 | + 'code-author-haslink' => 'Cet auteur est lié au compte $1 de ce wiki', |
| 262 | + 'code-author-dolink' => 'Associer cet auteur à un compte wiki local :', |
| 263 | + 'code-author-name' => 'Entrez un nom d\'utilisateur :', |
257 | 264 | 'code-no-repo' => 'Pas de dépôt configuré !', |
258 | 265 | 'code-field-id' => 'Révision', |
259 | 266 | 'code-field-author' => 'Auteur', |
Index: trunk/extensions/CodeReview/SpecialCode.php |
— | — | @@ -90,9 +90,11 @@ |
91 | 91 | |
92 | 92 | abstract function execute(); |
93 | 93 | |
94 | | - function authorLink( $author ) { |
95 | | - /* |
96 | | - // Leave this for later for now... |
| 94 | + /* |
| 95 | + * returns a User object if $author has a wikiuser associated, |
| 96 | + * of false |
| 97 | + */ |
| 98 | + function authorWikiUser( $author ) { |
97 | 99 | static $userLinks = array(); |
98 | 100 | if( isset( $userLinks[$author] ) ) |
99 | 101 | return $userLinks[$author]; |
— | — | @@ -111,12 +113,13 @@ |
112 | 114 | if( $wikiUser ) |
113 | 115 | $user = User::newFromName( $wikiUser ); |
114 | 116 | if( $user instanceof User ) |
115 | | - $link = $author . ' (' . $this->mSkin->userLink( $user->getId(), $user->getName() ) . ')'; |
| 117 | + $res = $user; |
116 | 118 | else |
117 | | - $link = htmlspecialchars( $author ); |
118 | | - return $userLinks[$author] = $link; |
119 | | - */ |
120 | | - |
| 119 | + $res = false; |
| 120 | + return $userLinks[$author] = $res; |
| 121 | + } |
| 122 | + |
| 123 | + function authorLink( $author ) { |
121 | 124 | $repo = $this->mRepo->getName(); |
122 | 125 | $special = SpecialPage::getTitleFor( 'Code', "$repo/author/$author" ); |
123 | 126 | return $this->mSkin->link( $special, htmlspecialchars( $author ) ); |