Index: trunk/extensions/Storyboard/jquery/jquery.ajaxscroll.js |
— | — | @@ -133,7 +133,7 @@ |
134 | 134 | } |
135 | 135 | |
136 | 136 | function vEnd() { |
137 | | - if ( ele.scrollTop > 0 && ele.scrollHeight - ele.scrollTop < opt.eBound ) { |
| 137 | + if ( ele.scrollTop > 0 && ele.scrollHeight - ele.scrollTop < opt.eBound && opt.loaded ) { |
138 | 138 | batch( $sp, opt ); |
139 | 139 | return 1; |
140 | 140 | } |
Index: trunk/extensions/Storyboard/Storyboard.i18n.php |
— | — | @@ -98,6 +98,8 @@ |
99 | 99 | 'storyboard-imagedeleted' => 'Image deleted', |
100 | 100 | 'storyboard-showimage' => 'Show image', |
101 | 101 | 'storyboard-hideimage' => 'Hide image', |
| 102 | + 'storyboard-deletestory' => 'Remove', |
| 103 | + 'storyboard-storydeletionconfirm' => 'Are you sure you want to permanently delete this story?' |
102 | 104 | ); |
103 | 105 | |
104 | 106 | /** Message documentation (Message documentation) |
Index: trunk/extensions/Storyboard/specials/StoryReview/StoryReview_body.php |
— | — | @@ -40,7 +40,8 @@ |
41 | 41 | } |
42 | 42 | |
43 | 43 | private function addOutput() { |
44 | | - global $wgOut, $wgRequest, $wgJsMimeType, $wgContLanguageCode, $egStoryboardScriptPath; |
| 44 | + global $wgOut, $wgRequest, $wgJsMimeType, $wgContLanguageCode, $wgUser; |
| 45 | + global $egStoryboardScriptPath; |
45 | 46 | |
46 | 47 | efStoryboardAddJSLocalisation(); |
47 | 48 | $wgOut->addStyle( $egStoryboardScriptPath . '/storyboard.css' ); |
— | — | @@ -58,6 +59,8 @@ |
59 | 60 | $language = $wgRequest->getText( 'language', false ); |
60 | 61 | if ( !$language ) $language = $wgContLanguageCode; |
61 | 62 | |
| 63 | + $canDelete = $wgUser->isAllowed( 'delete' ) ? 'true' : 'false'; |
| 64 | + |
62 | 65 | $wgOut->addHTML( <<<EOT |
63 | 66 | <div id="storyreview-tabs"> |
64 | 67 | <ul> |
— | — | @@ -72,6 +75,7 @@ |
73 | 76 | |
74 | 77 | <script type="$wgJsMimeType"> |
75 | 78 | var storyboardLanguage = "$language"; |
| 79 | + var storyboardCanDelete = $canDelete; |
76 | 80 | |
77 | 81 | jQuery( function() { |
78 | 82 | jQuery( "#storyreview-tabs" ).tabs(); |
Index: trunk/extensions/Storyboard/storyboard.js |
— | — | @@ -136,6 +136,7 @@ |
137 | 137 | /** |
138 | 138 | * Loads new stories into the board by making a getJSON request to the QueryStories API module. |
139 | 139 | * |
| 140 | + * @param ajaxscrollObj |
140 | 141 | * @param $storyboard |
141 | 142 | */ |
142 | 143 | function stbUpdateReviewBoard( ajaxscrollObj, $storyboard ) { |
— | — | @@ -157,7 +158,7 @@ |
158 | 159 | requestArgs, |
159 | 160 | function( data ) { |
160 | 161 | if ( data.query ) { |
161 | | - stbAddStories( ajaxscrollObj, $storyboard, data.query ); |
| 162 | + stbAddStories( ajaxscrollObj, $storyboard, data ); |
162 | 163 | } else { |
163 | 164 | alert( stbMsgExt( 'storyboard-anerroroccured', [data.error.info] ) ); |
164 | 165 | } |
— | — | @@ -168,15 +169,16 @@ |
169 | 170 | /** |
170 | 171 | * Adds a list of stories to the board. |
171 | 172 | * |
| 173 | + * @param ajaxscrollObj |
172 | 174 | * @param $storyboard |
173 | | - * @param query |
| 175 | + * @param data |
174 | 176 | */ |
175 | | -function stbAddStories( ajaxscrollObj, $storyboard, query ) { |
| 177 | +function stbAddStories( ajaxscrollObj, $storyboard, data ) { |
176 | 178 | // Remove the empty boxes. |
177 | 179 | $storyboard.html( '' ); |
178 | 180 | |
179 | | - for ( var i in query.stories ) { |
180 | | - var story = query.stories[i]; |
| 181 | + for ( var i in data.query.stories ) { |
| 182 | + var story = data.query.stories[i]; |
181 | 183 | var $storyBody = jQuery( "<div />" ).addClass( "storyboard-box" ).attr( "id", "story_" + story.id ); |
182 | 184 | |
183 | 185 | var $header = jQuery( "<div />" ).addClass( "story-header" ).appendTo( $storyBody ); |
— | — | @@ -243,9 +245,19 @@ |
244 | 246 | } |
245 | 247 | |
246 | 248 | controlDiv.append( ' ' ); |
247 | | - controlDiv.append( jQuery( "<button />" ).text( stbMsg( "edit" ) ) |
248 | | - .attr( "onclick", "window.location='" + story.modifyurl + "'" ) ); |
| 249 | + controlDiv.append( jQuery( "<button />" ) |
| 250 | + .text( stbMsg( "edit" ) ) |
| 251 | + .attr( "onclick", "window.location='" + story.modifyurl + "'" ) |
| 252 | + ); |
249 | 253 | |
| 254 | + if ( window.storyboardCanDelete ) { |
| 255 | + controlDiv.append( ' ' ); |
| 256 | + controlDiv.append( jQuery( "<button />" ) |
| 257 | + .text( stbMsg( "storyboard-deletestory" ) ) |
| 258 | + .attr( "onclick", "stbDeleteStory( this, " + story.id + " )" ) |
| 259 | + ); |
| 260 | + } |
| 261 | + |
250 | 262 | if ( story.imageurl ) { |
251 | 263 | controlDiv.append( ' ' ); |
252 | 264 | |
— | — | @@ -303,7 +315,7 @@ |
304 | 316 | function( data ) { |
305 | 317 | if ( data.storyreview ) { |
306 | 318 | switch( data.storyreview.action ) { |
307 | | - case 'publish' : case 'unpublish' : case 'hide' : |
| 319 | + case 'publish' : case 'unpublish' : case 'hide' : case 'delete' : |
308 | 320 | sender.innerHTML = stbMsg( 'storyboard-done' ); |
309 | 321 | jQuery( '#story_' + data.storyreview.id ).slideUp( 'slow', function () { |
310 | 322 | jQuery( this ).remove(); |
— | — | @@ -357,7 +369,7 @@ |
358 | 370 | } |
359 | 371 | |
360 | 372 | /** |
361 | | - * Asks the user to confirm the deletion of an image, and if confirmed, calls stbDoStoryAction with action=delete. |
| 373 | + * Asks the user to confirm the deletion of an image, and if confirmed, calls stbDoStoryAction with action=deleteimage. |
362 | 374 | * |
363 | 375 | * @param sender The UI element invocing the action, typically a button. |
364 | 376 | * @param storyid Id identifying the story. |
— | — | @@ -370,4 +382,20 @@ |
371 | 383 | stbDoStoryAction( sender, storyid, 'deleteimage' ); |
372 | 384 | } |
373 | 385 | return confirmed; |
| 386 | +} |
| 387 | + |
| 388 | +/** |
| 389 | + * Asks the user to confirm the deletion of a story, and if confirmed, calls stbDoStoryAction with action=delete. |
| 390 | + * |
| 391 | + * @param sender The UI element invocing the action, typically a button. |
| 392 | + * @param storyid Id identifying the story. |
| 393 | + * |
| 394 | + * @return Boolean indicating whether the deletion was confirmed. |
| 395 | + */ |
| 396 | +function stbDeleteStory( sender, storyid ) { |
| 397 | + var confirmed = confirm( stbMsg( 'storyboard-storydeletionconfirm' ) ); |
| 398 | + if ( confirmed ) { |
| 399 | + stbDoStoryAction( sender, storyid, 'delete' ); |
| 400 | + } |
| 401 | + return confirmed; |
374 | 402 | } |
\ No newline at end of file |
Index: trunk/extensions/Storyboard/api/ApiStoryReview.php |
— | — | @@ -52,10 +52,15 @@ |
53 | 53 | if ( !isset( $params['storyid'] ) ) { |
54 | 54 | $this->dieUsageMsg( array( 'missingparam', 'storyid' ) ); |
55 | 55 | } |
| 56 | + |
56 | 57 | if ( !isset( $params['storyaction'] ) ) { |
57 | 58 | $this->dieUsageMsg( array( 'missingparam', 'storyaction' ) ); |
58 | 59 | } |
59 | 60 | |
| 61 | + if ( $params['storyaction'] == 'delete' && !$wgUser->isAllowed( 'delete' ) ) { |
| 62 | + $this->dieUsageMsg( array( 'badaccess-groups' ) ); |
| 63 | + } |
| 64 | + |
60 | 65 | $dbw = wfGetDB( DB_MASTER ); |
61 | 66 | |
62 | 67 | if ( $params['storyaction'] == 'delete' ) { |
Index: trunk/extensions/Storyboard/Storyboard.php |
— | — | @@ -155,6 +155,8 @@ |
156 | 156 | 'storyboard-publish', |
157 | 157 | 'storyboard-hide', |
158 | 158 | 'storyboard-deleteimage', |
| 159 | + 'storyboard-deletestory', |
| 160 | + 'storyboard-storydeletionconfirm' |
159 | 161 | ); |
160 | 162 | |
161 | 163 | $data = array(); |