Index: trunk/extensions/EducationProgram/includes/EPInstructor.php |
— | — | @@ -110,6 +110,7 @@ |
111 | 111 | public function getUserLink() { |
112 | 112 | return Linker::userLink( |
113 | 113 | $this->getUser()->getId(), |
| 114 | + $this->getUser()->getName(), |
114 | 115 | $this->getName() |
115 | 116 | ); |
116 | 117 | } |
— | — | @@ -131,14 +132,18 @@ |
132 | 133 | |
133 | 134 | $links[] = Linker::link( SpecialPage::getTitleFor( 'Contributions', $this->getUser()->getName() ), wfMsgHtml( 'contribslink' ) ); |
134 | 135 | |
135 | | - if ( !is_null( $course ) && $context->getUser()->isAllowed( 'ep-instructor' ) ) { |
| 136 | + if ( !is_null( $course ) && |
| 137 | + ( $context->getUser()->isAllowed( 'ep-instructor' ) || $this->getUser()->getId() == $context->getUser()->getId() ) ) { |
136 | 138 | $links[] = Html::element( |
137 | 139 | 'a', |
138 | 140 | array( |
139 | 141 | 'href' => '#', |
140 | 142 | 'class' => 'ep-instructor-remove', |
141 | 143 | 'data-courseid' => $course->getId(), |
| 144 | + 'data-coursename' => $course->getField( 'name' ), |
142 | 145 | 'data-userid' => $this->getUser()->getId(), |
| 146 | + 'data-username' => $this->getUser()->getName(), |
| 147 | + 'data-bestname' => $this->getName(), |
143 | 148 | ), |
144 | 149 | wfMsg( 'ep-instructor-remove' ) |
145 | 150 | ); |
Index: trunk/extensions/EducationProgram/EducationProgram.i18n.php |
— | — | @@ -383,6 +383,7 @@ |
384 | 384 | 'ep-instructor-remove-retry' => 'Retry', |
385 | 385 | 'ep-instructor-remove-failed' => 'Something went wrong - could not remove the instructor from the course.', |
386 | 386 | 'ep-instructor-cancel-button' => 'Cancel', |
| 387 | + 'ep-instructor-remove-text' => 'You are about to remove $2 (Username: $1) as {{GENDER:$1|instructor}} from course $3. Please enter a brief summary with the reason for this removal.', |
387 | 388 | |
388 | 389 | // EPInstrucor |
389 | 390 | 'ep-instructor-remove' => 'remove from course', |
Index: trunk/extensions/EducationProgram/EducationProgram.php |
— | — | @@ -336,6 +336,7 @@ |
337 | 337 | 'dependencies' => array( |
338 | 338 | 'jquery.ui.dialog', |
339 | 339 | 'ep.api', |
| 340 | + 'mediawiki.jqueryMsg', |
340 | 341 | ), |
341 | 342 | 'messages' => array( |
342 | 343 | 'ep-instructor-remove-title', |
— | — | @@ -346,6 +347,7 @@ |
347 | 348 | 'ep-instructor-remove-retry', |
348 | 349 | 'ep-instructor-remove-failed', |
349 | 350 | 'ep-instructor-cancel-button', |
| 351 | + 'ep-instructor-remove-text', |
350 | 352 | ), |
351 | 353 | ); |
352 | 354 | |
Index: trunk/extensions/EducationProgram/resources/ep.api.js |
— | — | @@ -34,7 +34,8 @@ |
35 | 35 | |
36 | 36 | this.addInstructor = function( args ) { |
37 | 37 | var requestArgs = $.extend( { |
38 | | - 'action': 'addinstructor', |
| 38 | + 'action': 'instructor', |
| 39 | + 'subaction': 'add', |
39 | 40 | 'format': 'json', |
40 | 41 | 'token': window.mw.user.tokens.get( 'editToken' ) |
41 | 42 | }, args ); |
Index: trunk/extensions/EducationProgram/resources/ep.instructor.js |
— | — | @@ -13,46 +13,73 @@ |
14 | 14 | $( '.ep-instructor-remove' ).click( function( event ) { |
15 | 15 | var $this = $( this ), |
16 | 16 | courseId = $this.attr( 'data-courseid' ), |
| 17 | + courseName = $this.attr( 'data-coursename' ), |
17 | 18 | userId = $this.attr( 'data-userid' ), |
| 19 | + userName = $this.attr( 'data-username' ), |
| 20 | + bestName = $this.attr( 'data-bestname' ), |
18 | 21 | $dialog = null; |
| 22 | + |
| 23 | + var doRemove = function() { |
| 24 | + var $remove = $( '#ep-instructor-remove-button' ); |
| 25 | + var $cancel = $( '#ep-instructor-cancel-button' ); |
19 | 26 | |
20 | | - $dialog = $( '<div />' ).html( '' ).dialog( { |
| 27 | + $remove.button( 'option', 'disabled', true ); |
| 28 | + $remove.button( 'option', 'label', mw.msg( 'ep-instructor-removing' ) ); |
| 29 | + |
| 30 | + ep.api.addInstructor( { |
| 31 | + 'courseid': courseId, |
| 32 | + 'userid': userId, |
| 33 | + 'reason': summaryInput.val() |
| 34 | + } ).done( function() { |
| 35 | + $dialog.text( mw.msg( 'ep-instructor-removal-success' ) ); |
| 36 | + $remove.remove(); |
| 37 | + $cancel.button( 'option', 'label', mw.msg( 'ep-instructor-close-button' ) ); |
| 38 | + $cancel.focus(); |
| 39 | + } ).fail( function() { |
| 40 | + $remove.button( 'option', 'disabled', false ); |
| 41 | + $remove.button( 'option', 'label', mw.msg( 'ep-instructor-remove-retry' ) ); |
| 42 | + alert( mw.msg( 'ep-instructor-remove-failed' ) ); |
| 43 | + } ); |
| 44 | + }; |
| 45 | + |
| 46 | + var summaryInput = $( '<input>' ).attr( { |
| 47 | + 'type': 'text', |
| 48 | + 'size': 60, |
| 49 | + 'maxlength': 250 |
| 50 | + } ); |
| 51 | + |
| 52 | + $dialog = $( '<div>' ).html( '' ).dialog( { |
21 | 53 | 'title': mw.msg( 'ep-instructor-remove-title' ), |
22 | 54 | 'minWidth': 550, |
23 | 55 | 'buttons': [ |
24 | 56 | { |
25 | 57 | 'text': mw.msg( 'ep-instructor-remove-button' ), |
26 | | - 'id': 'instructor-remove-button', |
27 | | - 'click': function() { |
28 | | - var $remove = $( '#ep-instructor-remove-button' ); |
29 | | - var $cancel = $( '#reminder-cancel-button' ); |
30 | | - |
31 | | - $remove.button( 'option', 'disabled', true ); |
32 | | - $remove.button( 'option', 'label', mw.msg( 'ep-instructor-removing' ) ); |
33 | | - |
34 | | - ep.api.addInstructor( { |
35 | | - 'courseid': courseId, |
36 | | - 'userid': userId |
37 | | - } ).done( function() { |
38 | | - $dialog.text( mw.msg( 'ep-instructor-removal-success' ) ); |
39 | | - $remove.remove(); |
40 | | - $cancel.button( 'option', 'label', mw.msg( 'ep-instructor-close-button' ) ); |
41 | | - } ).fail( function() { |
42 | | - $remove.button( 'option', 'label', mw.msg( 'ep-instructor-remove-retry' ) ); |
43 | | - $remove.button( 'option', 'disabled', false ); |
44 | | - alert( mw.msg( 'ep-instructor-remove-failed' ) ); |
45 | | - } ); |
46 | | - } |
| 58 | + 'id': 'ep-instructor-remove-button', |
| 59 | + 'click': doRemove |
47 | 60 | }, |
48 | 61 | { |
49 | 62 | 'text': mw.msg( 'ep-instructor-cancel-button' ), |
50 | | - 'id': 'instructor-cancel-button', |
| 63 | + 'id': 'ep-instructor-cancel-button', |
51 | 64 | 'click': function() { |
52 | 65 | $dialog.dialog( 'close' ); |
53 | 66 | } |
54 | 67 | } |
55 | 68 | ] |
56 | 69 | } ); |
| 70 | + |
| 71 | + $dialog.append( $( '<p>' ).text( gM( 'ep-instructor-remove-text', userName, bestName, courseName ) ) ); |
| 72 | + |
| 73 | + $dialog.append( summaryInput ); |
| 74 | + |
| 75 | + summaryInput.focus(); |
| 76 | + |
| 77 | + summaryInput.keypress( function( event ) { |
| 78 | + if ( event.which == '13' ) { |
| 79 | + event.preventDefault(); |
| 80 | + doRemove(); |
| 81 | + } |
| 82 | + } ); |
| 83 | + |
57 | 84 | |
58 | 85 | // TODO: input to provide reason/comment for log |
59 | 86 | } ); |