Index: trunk/phase3/skins/common/protect.js |
— | — | @@ -33,16 +33,36 @@ |
34 | 34 | check.checked = true; |
35 | 35 | protectEnable(true); |
36 | 36 | } |
| 37 | + |
| 38 | + allowCascade(); |
37 | 39 | |
38 | 40 | return true; |
39 | 41 | } |
40 | 42 | return false; |
41 | 43 | } |
42 | 44 | |
| 45 | +function allowCascade() { |
| 46 | + var pr_types = document.getElementsByTagName("select"); |
| 47 | + for (var i = 0; i < pr_types.length; i++) { |
| 48 | + if (pr_types[i].id.match(/^mwProtect-level-/)) { |
| 49 | + var selected_level = pr_types[i].getElementsByTagName("option")[pr_types[i].selectedIndex].value; |
| 50 | + for (var k=0; k < wgCascadeableLevels.length; k++) { |
| 51 | + if ( wgCascadeableLevels[k] != selected_level ) { |
| 52 | + document.getElementById('mwProtect-cascade').disabled=true; |
| 53 | + return false; |
| 54 | + } |
| 55 | + } |
| 56 | + } |
| 57 | + } |
| 58 | + document.getElementById('mwProtect-cascade').disabled=false; |
| 59 | + return true; |
| 60 | +} |
| 61 | + |
43 | 62 | function protectLevelsUpdate(source) { |
44 | 63 | if (!protectUnchained()) { |
45 | 64 | protectUpdateAll(source.selectedIndex); |
46 | 65 | } |
| 66 | + allowCascade(); |
47 | 67 | } |
48 | 68 | |
49 | 69 | function protectChainUpdate() { |
Index: trunk/phase3/includes/ProtectionForm.php |
— | — | @@ -323,8 +323,17 @@ |
324 | 324 | } |
325 | 325 | |
326 | 326 | function buildCleanupScript() { |
327 | | - return '<script type="text/javascript">protectInitialize("mwProtectSet","' . |
328 | | - wfEscapeJsString( wfMsg( 'protect-unchain' ) ) . '")</script>'; |
| 327 | + global $wgRestrictionLevels, $wgGroupPermissions; |
| 328 | + $script = 'var wgCascadeableLevels='; |
| 329 | + $CascadeableLevels = array(); |
| 330 | + foreach( $wgRestrictionLevels as $key ) { |
| 331 | + if ( isset($wgGroupPermissions[$key]['protect']) && $wgGroupPermissions[$key]['protect'] ) { |
| 332 | + $CascadeableLevels[]="'" . wfEscapeJsString($key) . "'"; |
| 333 | + } |
| 334 | + } |
| 335 | + $script .= "[" . implode(',',$CascadeableLevels) . "];\n"; |
| 336 | + $script .= 'protectInitialize("mwProtectSet","' . wfEscapeJsString( wfMsg( 'protect-unchain' ) ) . '")'; |
| 337 | + return '<script type="text/javascript">' . $script . '</script>'; |
329 | 338 | } |
330 | 339 | |
331 | 340 | /** |