Index: trunk/extensions/EducationProgram/EducationProgram.php |
— | — | @@ -432,6 +432,20 @@ |
433 | 433 | 'jquery.ui.button', |
434 | 434 | 'jquery.ui.dialog', |
435 | 435 | ), |
| 436 | + 'messages' => array( |
| 437 | + 'ep-articletable-addreviwer-title', |
| 438 | + 'ep-articletable-addreviwer-button', |
| 439 | + 'ep-articletable-addreviwer-cancel', |
| 440 | + 'ep-articletable-addreviwer-text', |
| 441 | + |
| 442 | + 'ep-articletable-remreviwer-title', |
| 443 | + 'ep-articletable-remreviwer-button', |
| 444 | + 'ep-articletable-remreviwer-cancel', |
| 445 | + 'ep-articletable-remreviwer-text', |
| 446 | + 'ep-articletable-remreviwer-title-self', |
| 447 | + 'ep-articletable-remreviwer-button-self', |
| 448 | + 'ep-articletable-remreviwer-text-self', |
| 449 | + ), |
436 | 450 | ); |
437 | 451 | |
438 | 452 | $wgResourceModules['ep.addorg'] = $moduleTemplate + array( |
Index: trunk/extensions/EducationProgram/includes/EPArticle.php |
— | — | @@ -91,9 +91,8 @@ |
92 | 92 | public function canBecomeReviewer( User $user ) { |
93 | 93 | if ( !array_key_exists( $user->getId(), $this->canBecomeReviwer ) ) { |
94 | 94 | $this->canBecomeReviwer[$user->getId()] = $this->getUser()->isAllowed( 'ep-bereviewer' ) |
95 | | - //&& $this->getUser()->getId() !== $student->getField( 'user_id' ) |
96 | | - //&& !in_array( $this->getUser()->getId(), $article->getField( 'reviewers' ) ) |
97 | | - ; |
| 95 | + && $this->getUser()->getId() !== $user->getId() |
| 96 | + && !in_array( $this->getUser()->getId(), $this->getField( 'reviewers' ) ); |
98 | 97 | } |
99 | 98 | |
100 | 99 | return $this->canBecomeReviwer[$user->getId()]; |
Index: trunk/extensions/EducationProgram/includes/EPArticleTable.php |
— | — | @@ -271,7 +271,7 @@ |
272 | 272 | * @since 0.1 |
273 | 273 | * |
274 | 274 | * @param EPArticle $article |
275 | | - * @param integer $userId |
| 275 | + * @param integer $userId User id of the reviewer |
276 | 276 | * |
277 | 277 | * @return string |
278 | 278 | */ |
— | — | @@ -292,6 +292,10 @@ |
293 | 293 | 'href' => '#', |
294 | 294 | 'data-user-id' => $userId, |
295 | 295 | 'data-article-id' => $article->getId(), |
| 296 | + 'data-article-name' => $article->getTitle()->getFullText(), |
| 297 | + 'data-student-name' => $article->getUser()->getName(), |
| 298 | + 'data-reviewer-name' => $user->getName(), |
| 299 | + 'data-reviewer-id' => $user->getId(), |
296 | 300 | 'class' => 'ep-rem-reviewer', |
297 | 301 | ), |
298 | 302 | wfMsg( 'ep-artciles-remreviewer' ) |
— | — | @@ -307,6 +311,8 @@ |
308 | 312 | 'class' => 'ep-rem-reviewer-self', |
309 | 313 | 'disabled' => 'disabled', |
310 | 314 | 'data-article-id' => $article->getId(), |
| 315 | + 'data-article-name' => $article->getField( 'name' ), |
| 316 | + 'data-student-name' => $article->getUser()->getName(), |
311 | 317 | ), |
312 | 318 | wfMsg( 'ep-artciles-remreviewer-self' ) |
313 | 319 | ); |
— | — | @@ -380,6 +386,8 @@ |
381 | 387 | 'class' => 'ep-become-reviewer', |
382 | 388 | 'disabled' => 'disabled', |
383 | 389 | 'data-article-id' => $article->getId(), |
| 390 | + 'data-article-name' => $article->getTitle()->getFullText(), |
| 391 | + 'data-user-name' => $article->getUser()->getName(), |
384 | 392 | ), |
385 | 393 | wfMsg( 'ep-artciles-becomereviewer' ) |
386 | 394 | ); |
Index: trunk/extensions/EducationProgram/EducationProgram.i18n.php |
— | — | @@ -271,18 +271,32 @@ |
272 | 272 | 'epstudentpager-yes' => 'Yes', |
273 | 273 | 'epstudentpager-no' => 'No', |
274 | 274 | |
275 | | - // Student article pager |
| 275 | + // Article table |
276 | 276 | 'epstudentpager-header-student' => 'Student', |
277 | 277 | 'epstudentpager-header-articles' => 'Articles', |
278 | 278 | 'epstudentpager-header-reviewers' => 'Reviewers', |
279 | 279 | 'ep-artciles-remstudent' => 'remove from course', |
280 | | - 'ep-artciles-remreviewer-self' => 'Remove myself as reviewer', |
281 | | - 'ep-artciles-remreviewer' => 'remove as reviewer', |
| 280 | + 'ep-artciles-remreviewer-self' => 'Remove myself as {{GENDER:$1|reviewer}}', |
| 281 | + 'ep-artciles-remreviewer' => 'remove as {{GENDER:$1|reviewer}}', |
282 | 282 | 'ep-artciles-remarticle' => 'remove article', |
283 | 283 | 'ep-artciles-addarticle-text' => 'Add an article:', |
284 | 284 | 'ep-artciles-addarticle-button' => 'Add article', |
285 | | - 'ep-artciles-becomereviewer' => 'Add myself as reviewer', |
| 285 | + 'ep-artciles-becomereviewer' => 'Add myself as {{GENDER:$1|reviewer}}', |
286 | 286 | |
| 287 | + // ep.articletable |
| 288 | + 'ep-articletable-addreviwer-title' => 'Become {{GENDER:$1|reviewer}}', |
| 289 | + 'ep-articletable-addreviwer-button' => 'Become {{GENDER:$1|reviewer}}', |
| 290 | + 'ep-articletable-addreviwer-cancel' => 'Cancel', |
| 291 | + 'ep-articletable-addreviwer-text' => 'You are about to enlist yourself as {{GENDER:$1|reviewer}} for article $2 worked on by $3.', |
| 292 | + |
| 293 | + 'ep-articletable-remreviwer-title' => 'Remove $1 as {{GENDER:$1|reviewer}}', |
| 294 | + 'ep-articletable-remreviwer-title-self' => 'Remove yourself as {{GENDER:$1|reviewer}}', |
| 295 | + 'ep-articletable-remreviwer-button' => 'Remove {{GENDER:$1|reviewer}}', |
| 296 | + 'ep-articletable-remreviwer-button-self' => 'Remove yourself', |
| 297 | + 'ep-articletable-remreviwer-cancel' => 'Cancel', |
| 298 | + 'ep-articletable-remreviwer-text-self' => 'You are about to remove yourself as {{GENDER:$1|reviewer}} for article $2 worked on by $3.', |
| 299 | + 'ep-articletable-remreviwer-text' => 'You are about to remove $4 as {{GENDER:$1|reviewer}} for article $2 worked on by $3.', |
| 300 | + |
287 | 301 | // Article pager |
288 | 302 | 'ep-articles-noresults' => 'There are no articles to list.', |
289 | 303 | |
Index: trunk/extensions/EducationProgram/resources/ep.articletable.js |
— | — | @@ -9,16 +9,39 @@ |
10 | 10 | (function( $, ep ) { |
11 | 11 | |
12 | 12 | function addReviewer() { |
13 | | - $dialog = $( '<div>' ).html( '' ).dialog( { |
14 | | - 'title': ep.msg( 'ep-articletable-addreviwer-title' ), |
| 13 | + var $this = $( this ); |
| 14 | + |
| 15 | + var $form = $( '<form>' ).attr( { |
| 16 | + 'method': 'post', |
| 17 | + 'action': window.location |
| 18 | + } ).msg( |
| 19 | + 'ep-articletable-addreviwer-text', |
| 20 | + mw.user.name, |
| 21 | + $( '<b>' ).text( $this.attr( 'data-article-name' ) ), |
| 22 | + $( '<b>' ).text( $this.attr( 'data-user-name' ) ) |
| 23 | + ); |
| 24 | + |
| 25 | + $form.append( $( '<input>' ).attr( { |
| 26 | + 'type': 'hidden', |
| 27 | + 'name': 'action', |
| 28 | + 'value': 'epaddreviewer' |
| 29 | + } ) ); |
| 30 | + |
| 31 | + $form.append( $( '<input>' ).attr( { |
| 32 | + 'type': 'hidden', |
| 33 | + 'name': 'article-id', |
| 34 | + 'value': $this.attr( 'data-article-id' ) |
| 35 | + } ) ); |
| 36 | + |
| 37 | + var $dialog = $( '<div>' ).html( '' ).dialog( { |
| 38 | + 'title': ep.msg('ep-articletable-addreviwer-title', mw.user.name ), |
15 | 39 | 'minWidth': 550, |
16 | 40 | 'buttons': [ |
17 | 41 | { |
18 | | - 'text': ep.msg( 'ep-articletable-addreviwer-button' ), |
| 42 | + 'text': ep.msg( 'ep-articletable-addreviwer-button', mw.user.name ), |
19 | 43 | 'id': 'ep-addreviwer-button', |
20 | 44 | 'click': function() { |
21 | | - alert( 'submit' ); |
22 | | - // TODO |
| 45 | + $form.submit(); |
23 | 46 | } |
24 | 47 | }, |
25 | 48 | { |
— | — | @@ -30,6 +53,8 @@ |
31 | 54 | } |
32 | 55 | ] |
33 | 56 | } ); |
| 57 | + |
| 58 | + $dialog.append( $form ); |
34 | 59 | } |
35 | 60 | |
36 | 61 | function addArticle() { |
— | — | @@ -45,7 +70,62 @@ |
46 | 71 | } |
47 | 72 | |
48 | 73 | function removeReviewer() { |
49 | | - // TODO |
| 74 | + var $this = $( this ), |
| 75 | + isSelf = $this.attr( 'data-reviewer-name' ) === undefined, |
| 76 | + selfSuffix = isSelf ? '-self' : '', |
| 77 | + reviewerName = isSelf ? mw.user.name : $this.attr( 'data-reviewer-name' ); |
| 78 | + |
| 79 | + var $form = $( '<form>' ).attr( { |
| 80 | + 'method': 'post', |
| 81 | + 'action': window.location |
| 82 | + } ).msg( |
| 83 | + 'ep-articletable-remreviwer-text' + selfSuffix, |
| 84 | + reviewerName, |
| 85 | + $( '<b>' ).text( $this.attr( 'data-article-name' ) ), |
| 86 | + $( '<b>' ).text( $this.attr( 'data-student-name' ) ), |
| 87 | + $( '<b>' ).text( reviewerName ) |
| 88 | + ); |
| 89 | + |
| 90 | + $form.append( $( '<input>' ).attr( { |
| 91 | + 'type': 'hidden', |
| 92 | + 'name': 'action', |
| 93 | + 'value': 'epremreviewer' |
| 94 | + } ) ); |
| 95 | + |
| 96 | + $form.append( $( '<input>' ).attr( { |
| 97 | + 'type': 'hidden', |
| 98 | + 'name': 'article-id', |
| 99 | + 'value': $this.attr( 'data-article-id' ) |
| 100 | + } ) ); |
| 101 | + |
| 102 | + $form.append( $( '<input>' ).attr( { |
| 103 | + 'type': 'hidden', |
| 104 | + 'name': 'user-id', |
| 105 | + 'value': isSelf ? mw.user.id : $this.attr( 'data-reviewer-id' ) |
| 106 | + } ) ); |
| 107 | + |
| 108 | + var $dialog = $( '<div>' ).html( '' ).dialog( { |
| 109 | + 'title': ep.msg('ep-articletable-remreviwer-title' + selfSuffix, reviewerName ), |
| 110 | + 'minWidth': 550, |
| 111 | + 'buttons': [ |
| 112 | + { |
| 113 | + 'text': ep.msg( 'ep-articletable-remreviwer-button' + selfSuffix, reviewerName ), |
| 114 | + 'id': 'ep-remreviwer-button', |
| 115 | + 'click': function() { |
| 116 | + $form.submit(); |
| 117 | + } |
| 118 | + }, |
| 119 | + { |
| 120 | + 'text': ep.msg( 'ep-articletable-remreviwer-cancel' ), |
| 121 | + 'id': 'ep-remreviwer-cancel', |
| 122 | + 'click': function() { |
| 123 | + $dialog.dialog( 'close' ); |
| 124 | + } |
| 125 | + } |
| 126 | + ] |
| 127 | + } ); |
| 128 | + |
| 129 | + $dialog.append( $form ); |
50 | 130 | } |
51 | 131 | |
52 | 132 | $( document ).ready( function() { |
— | — | @@ -54,7 +134,7 @@ |
55 | 135 | |
56 | 136 | $( '.ep-become-reviewer' ).click( addReviewer ); |
57 | 137 | |
58 | | - $( '.ep-rem-reviewer-self' ).click( removeReviewer ); |
| 138 | + $( '.ep-rem-reviewer, .ep-rem-reviewer-self' ).click( removeReviewer ); |
59 | 139 | |
60 | 140 | // TODO |
61 | 141 | } ); |