Compare commits
848 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 7413ce9896 | |||
| f84f35dda1 | |||
| 71e12dc963 | |||
| ba1d10c500 | |||
| 662fe4b7d6 | |||
| ce077202d0 | |||
| d98c8fcb8e | |||
| 9d2926a4e9 | |||
| 155fd3f64b | |||
| e02955dd79 | |||
| 3f4e07ef3c | |||
| 9569ba7ed8 | |||
| e4e29fd35e | |||
| 69a52e7c4f | |||
| a334d8f967 | |||
| 3ac8fa663a | |||
| 4ec133b8e6 | |||
| 7c4fc5b50b | |||
| c62ccd747c | |||
| fb1b0bc05e | |||
| df4e81835a | |||
| d8a640728c | |||
| 31ae0e5984 | |||
| 3dafe46b2b | |||
| 5f015b62d4 | |||
| 2b567e3687 | |||
| 8a716e2362 | |||
| 20182f8670 | |||
| 99e6bd4799 | |||
| 0af2fd2e05 | |||
| 2cdf1a4650 | |||
| 0cae56b42e | |||
| b9d24254bd | |||
| a31d7a0ed3 | |||
| e815aa8e04 | |||
| e78698c606 | |||
| a2bdb0b02c | |||
| 90c499dbca | |||
| 82bf5b10b9 | |||
| 668ba1e922 | |||
| 3d5df93b80 | |||
| 3bae0b5916 | |||
| 16ee63b4b8 | |||
| 397afd71c3 | |||
| c128731d19 | |||
| 640f8eed6d | |||
| 2fd679c5e1 | |||
| 905185dca4 | |||
| 8169e2f46b | |||
| 3d1cbc0df3 | |||
| b739e2d71a | |||
| bcbfd02574 | |||
| f38508168f | |||
| 9f66e64390 | |||
| 47045e82b0 | |||
| e235de5ef5 | |||
| a49ea30654 | |||
| f4f8cf9a2d | |||
| 9817f08400 | |||
| 45f9c2db5f | |||
| 3fe8ae9bb9 | |||
| 58520c062d | |||
| 0a898cbc46 | |||
| 98157832bf | |||
| 6e6f74da2f | |||
| 4c6b8659f9 | |||
| 5d22b22274 | |||
| fd126f94aa | |||
| f1f174e2bf | |||
| a1db53480c | |||
| 5fe6d41245 | |||
| 4d7a664ee7 | |||
| 74c0b55029 | |||
| 21415acd5a | |||
| edd2686c8b | |||
| bc67dfdb9a | |||
| c8f9a0b63a | |||
| 3b5245cd6b | |||
| 160133ce24 | |||
| a51eaaac45 | |||
| 3afd86559e | |||
| accaf1d277 | |||
| fd3e329d94 | |||
| 913dd6d630 | |||
| 074455a6f5 | |||
| 7fa4cd1617 | |||
| 0707372b03 | |||
| 3dce698981 | |||
| 29ea4e9c56 | |||
| a7f53f09f3 | |||
| f8dea58be9 | |||
| 56e41718da | |||
| 1d168fbd5f | |||
| a6b0ac5362 | |||
| 120300fb99 | |||
| a5fe04b62b | |||
| 9001c7242e | |||
| 22fa5d9a7c | |||
| e53394ba0b | |||
| 56e7d14f26 | |||
| c9fa5b1c05 | |||
| 3af509d6d4 | |||
| 26aaa7e835 | |||
| 2e0b5fef48 | |||
| f3d5fb4dec | |||
| 903d13c0c2 | |||
| b0e5b3b63b | |||
| 5e143a271c | |||
| ffbe597ef1 | |||
| 56c5e1db1b | |||
| ed29fa1274 | |||
| faf4ba4774 | |||
| d8e6e58ec5 | |||
| 4eb3f12797 | |||
| 6ec3ae6f14 | |||
| 339057063c | |||
| b884cf2a74 | |||
| f0c1bcf5a2 | |||
| 3860f948af | |||
| 9507653269 | |||
| 79a6a832d7 | |||
| eec3a5d48d | |||
| e9c306f10e | |||
| b14d76c59f | |||
| 8f93d94ab2 | |||
| b6cd7017c0 | |||
| f9033600cc | |||
| 473285edde | |||
| 48ee721e2f | |||
| acff486664 | |||
| 42122854fc | |||
| 339c954913 | |||
| 7c3fa05126 | |||
| 3342bb835c | |||
| aac67f6384 | |||
| b710f91ed9 | |||
| 441fa9c71d | |||
| fdc57a14bd | |||
| a129b76cc3 | |||
| 409eab3510 | |||
| 4d0a7e2b1f | |||
| cc0188c21c | |||
| 9fc95b6558 | |||
| e24b125a3a | |||
| bdbdd72cdb | |||
| b7da14f1c6 | |||
| 44ec173ea8 | |||
| 6009d1a32e | |||
| 99aaad063e | |||
| 765e7564cc | |||
| 07eca71195 | |||
| 872e445a48 | |||
| 7f8d657531 | |||
| ff43c30f0a | |||
| 35a95edba4 | |||
| bac15e5782 | |||
| 3330b54c2c | |||
| 78c2fa5cab | |||
| 23bb88d28d | |||
| 4b7b1aae4d | |||
| 49e77191cc | |||
| 9832fde1c0 | |||
| 364666f371 | |||
| e1269d87d4 | |||
| a701525345 | |||
| ccce6a7e33 | |||
| 29beeefc70 | |||
| 996e735693 | |||
| 6c475847fb | |||
| 363b35f221 | |||
| f813d99296 | |||
| e03a03a4a9 | |||
| a4241511ed | |||
| fb4e6948d0 | |||
| 70dc5add7d | |||
| f16751f856 | |||
| 69be24a776 | |||
| b74390e38b | |||
| e464af4462 | |||
| ea438c8d7b | |||
| bae745aa57 | |||
| 0547143fad | |||
| 2b062ed6a6 | |||
| 864ca7d700 | |||
| fa0ed51c0a | |||
| d7b7aff004 | |||
| 1923720566 | |||
| 5a566ceac7 | |||
| 82157094e5 | |||
| 115ad6cc9e | |||
| f6376dcbae | |||
| ed22220593 | |||
| 8172f3b2d3 | |||
| b02734b77d | |||
| 8c74ab8623 | |||
| b16b42e9e2 | |||
| d1e338c98b | |||
| 108dd3376c | |||
| a415852d2b | |||
| b747690361 | |||
| d73f22d94e | |||
| 181884b480 | |||
| 9b7738c8fb | |||
| a130109013 | |||
| ac97fc2122 | |||
| 9da82e9ba3 | |||
| 0c6800e771 | |||
| 2d0a11ee94 | |||
| 3dd2dce1cb | |||
| 1c5f24e089 | |||
| 331d346e8f | |||
| 8ee474b89e | |||
| 3f7df55d1c | |||
| c6d7689621 | |||
| 2e941f3356 | |||
| bab65024ad | |||
| dcf82e6079 | |||
| f3ad0ed27d | |||
| b8cc020064 | |||
| fc08030d8e | |||
| 21fcca106d | |||
| 7bb562cdf0 | |||
| ae21b71925 | |||
| 9ff0c0bb84 | |||
| 0ec0602415 | |||
| e013292e25 | |||
| f6aabcf0ed | |||
| 67f0e8fe87 | |||
| 854bec4500 | |||
| 70746c433c | |||
| 39e39bd437 | |||
| db6842cca3 | |||
| 7e84ef4fea | |||
| 778947cd65 | |||
| 1ff3389a54 | |||
| cf1cb68662 | |||
| 123f7f534e | |||
| c74b1ee8d9 | |||
| 9fe39511e2 | |||
| 245197ee2d | |||
| 3c50224079 | |||
| 259aecb26b | |||
| a2043a3168 | |||
| 3d7f23c5e9 | |||
| 8a8dd7d8c8 | |||
| e3a5ed9dd7 | |||
| 71a03114e0 | |||
| 3e6b27698d | |||
| 40f6697f2e | |||
| 7a4f9ba8e0 | |||
| d190fcd9d9 | |||
| 68576ef61d | |||
| bc2289cd52 | |||
| 054bcf69f6 | |||
| a645f67aa5 | |||
| bf821575ec | |||
| 01dbe1fdad | |||
| 93dbb62f45 | |||
| 16254fffc8 | |||
| 20d4ab97c0 | |||
| d1755c12a0 | |||
| 6247d0a82c | |||
| 423030e7dc | |||
| 7033316dad | |||
| 90231b24df | |||
| 5c57df4c9d | |||
| 1d075eadd9 | |||
| dc5d4f435a | |||
| 8309268b42 | |||
| 19ab59bcc0 | |||
| 44d24d1297 | |||
| c4f0004a0a | |||
| cfebb1a538 | |||
| 2a077c0d1b | |||
| 25e77f4f73 | |||
| 829f5e876a | |||
| 9bdc95b702 | |||
| 4ee439dbc2 | |||
| 91986f84c2 | |||
| e154c1b6da | |||
| 9bf629bb64 | |||
| 833e135533 | |||
| 36e6961fa4 | |||
| a9c8c1c951 | |||
| 02d8fb146d | |||
| 6c20303ee1 | |||
| 12445b37fc | |||
| 428b30ce5e | |||
| 90c510cf9d | |||
| ba338db5b5 | |||
| 38ace2266f | |||
| 8e017950e9 | |||
| 69e0f5049f | |||
| 1f65a01980 | |||
| 37fbfb0dda | |||
| b92d962c3f | |||
| 9a77ed006f | |||
| 2a5378d2c6 | |||
| 6353a60ed3 | |||
| e85500a8bf | |||
| d54294de34 | |||
| b5cbe52bfc | |||
| 894446f7fd | |||
| 5b918d0101 | |||
| 25e107e5a2 | |||
| 94dd25e03b | |||
| 0a571db22b | |||
| 3350475e36 | |||
| ee53ceb3eb | |||
| 33222ed24a | |||
| 37102468f7 | |||
| ff21775823 | |||
| c5cf1bc090 | |||
| 78a4cef1e7 | |||
| abef93f5c9 | |||
| a572657497 | |||
| d077d1a024 | |||
| d8ceb62387 | |||
| bd3306f5cd | |||
| ef38e70c41 | |||
| 15343304d2 | |||
| 3de32f8558 | |||
| 4af5c4ebf5 | |||
| 203e8d4032 | |||
| e9a743d385 | |||
| e6aac11d94 | |||
| 8ff9b91e9f | |||
| 4c0d64860a | |||
| 081889f26b | |||
| 55c91c8760 | |||
| 383639a5ef | |||
| 55a2b03ef1 | |||
| f37cd67ded | |||
| c258605a8d | |||
| 25f8e4f241 | |||
| 8dc49e14c4 | |||
| 7abe8c31a6 | |||
| 02d6791d05 | |||
| ed10bfb2b0 | |||
| c86262ed73 | |||
| 4c60068485 | |||
| 57f9291b23 | |||
| e203643539 | |||
| 5b74170932 | |||
| 16daaa05b6 | |||
| b21388d6db | |||
| 16a8d4d4ba | |||
| e83629096b | |||
| 162510801f | |||
| 74b83c18fb | |||
| 5af69f5282 | |||
| ec28569e5c | |||
| 1089612634 | |||
| 04e428f9ae | |||
| b418329b7d | |||
| 6f74e5b2f6 | |||
| ebc5b65ab3 | |||
| b97532dd8e | |||
| d8ff3aae9f | |||
| 9881439068 | |||
| 9064a9af71 | |||
| 5f2f276f82 | |||
| 1e778228a8 | |||
| b42abe0ffc | |||
| 2ab9801b19 | |||
| f70df26e40 | |||
| ac1bbfa1cd | |||
| 6faa04b522 | |||
| cf162f9332 | |||
| e0a555a3a3 | |||
| 0e5acac2d8 | |||
| efff50c096 | |||
| e1bc047bdb | |||
| ea22072a62 | |||
| 824dfb24bd | |||
| 00cb41c2ba | |||
| 61e520aefc | |||
| f7cecf982f | |||
| a767fce382 | |||
| cfe10a4698 | |||
| 01672d5de5 | |||
| 65e06b77a8 | |||
| 7c4bfa5ec7 | |||
| d939a4dec8 | |||
| f52c5f8b6a | |||
| a34c42bd5e | |||
| 98aa996a00 | |||
| 5f152b5c90 | |||
| 3d84e69328 | |||
| 9d705d4901 | |||
| 2018163468 | |||
| 142b18a835 | |||
| abdc9e17fa | |||
| e071bc1aa4 | |||
| 2963abadf9 | |||
| 4d8138c96a | |||
| 7a0664fbb4 | |||
| e1d2c7452b | |||
| a602649f8f | |||
| 85a9d23d91 | |||
| 3f995bef7a | |||
| 1445fd1337 | |||
| 0f9992ca66 | |||
| 08e03a695a | |||
| 077e06f621 | |||
| d0d9c135e1 | |||
| 519adbc684 | |||
| aa15bd56d6 | |||
| f81c3a32f0 | |||
| daeee0afae | |||
| 6ecbacac00 | |||
| d3e1371030 | |||
| e9ec895d92 | |||
| 6ce946c561 | |||
| 84af4013c1 | |||
| 7d45268bc6 | |||
| 46c770079d | |||
| 3a933cdf10 | |||
| 137bd7a8b5 | |||
| 605d6ffcf4 | |||
| 56eda1f10a | |||
| 4a5e1f9d4b | |||
| 02814bfc18 | |||
| 709efab527 | |||
| c91dc553e5 | |||
| 8b9416de53 | |||
| b093fd5e5a | |||
| 4486aa99be | |||
| 87a31bb5d8 | |||
| 90105eb95a | |||
| 06d38548b1 | |||
| b44ae5fb0a | |||
| 633ed1edae | |||
| 07cf0887fd | |||
| 0fa95a3c97 | |||
| 81ff28e7e6 | |||
| 8291579200 | |||
| 61e3665a15 | |||
| 4233aac1e3 | |||
| 548b7112a2 | |||
| 971937e7d0 | |||
| 28557dc456 | |||
| 4a5780ffde | |||
| acb533009f | |||
| 3c3cf6daac | |||
| fe2ff1e8a0 | |||
| dddd0d7a38 | |||
| 2a336b5ef1 | |||
| 1de0c00eb6 | |||
| 669f274735 | |||
| 3fb4392ee0 | |||
| 8bf442dc73 | |||
| 472b9a46ab | |||
| 1b158ee8c9 | |||
| 2a3a22a46d | |||
| 89babfaefa | |||
| 5aba3d6df9 | |||
| 10813a0c78 | |||
| c04ddf28f8 | |||
| d4533f6215 | |||
| eec3d1869d | |||
| 0b7dfe12ed | |||
| 7ae8f60489 | |||
| 46895999f0 | |||
| b700c34f14 | |||
| 1ab970d492 | |||
| db8e600a23 | |||
| c5b133f790 | |||
| acbbf4157d | |||
| af433c5b52 | |||
| ca4548c1c2 | |||
| 7c52ee5027 | |||
| 6fe575509e | |||
| f785edd9e2 | |||
| dacc63f1ae | |||
| 899fe64867 | |||
| 0e3c86746f | |||
| d1d989ce13 | |||
| 009933e28c | |||
| f2fd3f3138 | |||
| de53bada57 | |||
| e3f79e9347 | |||
| 0940ba1f16 | |||
| 53f2f306dd | |||
| a361ff5645 | |||
| def687a6a2 | |||
| 41499f832b | |||
| 0bdf18a7c9 | |||
| fcda7dbb89 | |||
| df9b10e10a | |||
| b3b35530f9 | |||
| 9480023733 | |||
| e8790310bb | |||
| 3b6573536c | |||
| 2011579b26 | |||
| 59b983a5d9 | |||
| 40ae563bee | |||
| 6975216336 | |||
| ffdccab055 | |||
| 33405ffbd0 | |||
| 993a4b8f5c | |||
| a11b507f50 | |||
| 8d9dd85d97 | |||
| c54a83d8bd | |||
| c237be89fb | |||
| 55bf451676 | |||
| 5986099daa | |||
| ea268875fb | |||
| f1631871b8 | |||
| 81fa4095f2 | |||
| 34cdc31ec8 | |||
| 51609ef88a | |||
| 73a418e3c2 | |||
| 2902afd555 | |||
| e2ecc7c6cc | |||
| 53e2f1aad8 | |||
| bb9b19a7fd | |||
| 8e711c3af0 | |||
| 326bbf9ba6 | |||
| cf1479bb2f | |||
| b165e64edc | |||
| cb9fdb814d | |||
| e4f2ea1a42 | |||
| 5147d726b2 | |||
| 96647229fc | |||
| 7ccdba8821 | |||
| 82a0137aa5 | |||
| 60a1365d28 | |||
| 3e7788eebe | |||
| fd59a1780b | |||
| 4094913d53 | |||
| f945ffb908 | |||
| e7a3fe032f | |||
| 6fcebf2424 | |||
| 9d1594b04b | |||
| 9ff506d165 | |||
| 252bd1871b | |||
| 548f536a00 | |||
| 2372ccb774 | |||
| 4ad0926a30 | |||
| f315e3e184 | |||
| 93c3b29893 | |||
| c8ac7e7938 | |||
| 943036314f | |||
| 145a300b73 | |||
| 392ee02d6c | |||
| 28ea78bf7a | |||
| 7fac90712b | |||
| 5b37ed3dda | |||
| a6fa8a7265 | |||
| b843a44e16 | |||
| 38e269ead9 | |||
| de25ddd331 | |||
| 7b293e0126 | |||
| 56db97bb5c | |||
| 05e4341165 | |||
| 0dd05d20b9 | |||
| 9134f9aa9c | |||
| c8e5d9c9eb | |||
| 937777f3fe | |||
| 6b986b7b6a | |||
| 4b195fe9e9 | |||
| a14ef47b44 | |||
| 1c005cbf12 | |||
| 7c87df674e | |||
| ab706cc971 | |||
| 8545a5cc54 | |||
| e0cf9e280a | |||
| 1cb637e42a | |||
| 2894157f15 | |||
| 013c74d058 | |||
| 2d7cbf5923 | |||
| 0288eb2151 | |||
| 0656c0a403 | |||
| 36e22a820c | |||
| 62145412bb | |||
| 8119fbd7bd | |||
| 001ff67298 | |||
| da2104aa0e | |||
| e2bf940699 | |||
| 9592f5dea8 | |||
| 05551bceed | |||
| fece4fd648 | |||
| dec465b3e9 | |||
| cfe170e430 | |||
| 617c624732 | |||
| 00cfd8bc94 | |||
| 8a172fa7cf | |||
| a64fbc87b6 | |||
| 483d768bc0 | |||
| 35cf43cb42 | |||
| 371d354ab3 | |||
| 23371805ea | |||
| 3240c7100e | |||
| 574cc949cd | |||
| 07cb7e3d34 | |||
| b6e65b5312 | |||
| b27d56ea6f | |||
| e52f82253e | |||
| 00714e72ea | |||
| 5f3d7b1949 | |||
| 4923e18d75 | |||
| e0bc694514 | |||
| 021bea1240 | |||
| 24527f63bb | |||
| d835681e35 | |||
| 4da22142bc | |||
| 8242298e4b | |||
| ae8e49e8de | |||
| 5320640ccd | |||
| 28fc596d03 | |||
| f8e493faff | |||
| ac98ad6189 | |||
| 8f87d57c47 | |||
| 828a42c37d | |||
| d479ce3bef | |||
| f30998190f | |||
| ff8ab720f0 | |||
| 66681a5192 | |||
| 4b791f1d17 | |||
| b831bcc2be | |||
| bf79f77357 | |||
| e7bf0155f7 | |||
| bac9070359 | |||
| beae8b9888 | |||
| 04de7affb6 | |||
| e9879c02c6 | |||
| 7bef3664b8 | |||
| 881118184a | |||
| 7397acb145 | |||
| a3db6afa39 | |||
| fd626c4109 | |||
| eab8660e8f | |||
| 3eb9ebb3c8 | |||
| 41e8883ea8 | |||
| 7ec63b27d0 | |||
| 3b52187e25 | |||
| f7d874c76f | |||
| 9f7f501c0a | |||
| 476f72e9bf | |||
| 074236eee7 | |||
| 294c228272 | |||
| c465776d28 | |||
| 4697c46706 | |||
| df7799d989 | |||
| 89375aac4c | |||
| 229aabf7c6 | |||
| d6571ad763 | |||
| 95991122ab | |||
| db81525850 | |||
| 7073fa4c4a | |||
| b2e5a60773 | |||
| 57c7815213 | |||
| 95896749a5 | |||
| c8b7088463 | |||
| c82d7fc832 | |||
| 1f34fa79c2 | |||
| 806129b06e | |||
| eb88700a56 | |||
| 3ca82ed605 | |||
| 6b8399df5e | |||
| 68ea10b079 | |||
| 2eb66f3500 | |||
| bd75b67885 | |||
| 3936796042 | |||
| b43bb8da94 | |||
| 898010f1aa | |||
| d563d48694 | |||
| 0dd189d59d | |||
| d6cf442059 | |||
| 2bf17d606b | |||
| 1583e17c65 | |||
| d85083312c | |||
| 1e838c4e30 | |||
| 65ab8112a3 | |||
| 9309b2dba8 | |||
| b002b36ed3 | |||
| d36249d6d6 | |||
| 48bdd52172 | |||
| 41bb2c3a59 | |||
| 918f6d2c34 | |||
| 3a429ca204 | |||
| d212244375 | |||
| f19cd42709 | |||
| 9bf1621fbc | |||
| aacf3222df | |||
| 6b4c491cb4 | |||
| 69a600a067 | |||
| 25afd64b0f | |||
| fe6d428185 | |||
| 880f8e7b84 | |||
| 6128bf9d25 | |||
| 93f3eb63d1 | |||
| 79406900b5 | |||
| 0408a48010 | |||
| 2dd2bd7ead | |||
| f2867a8672 | |||
| 62e9e694b7 | |||
| b24e6ed930 | |||
| 50b1caaf86 | |||
| 2ddf3ffcd2 | |||
| b73a7519c4 | |||
| 2425229c88 | |||
| 353580b0e3 | |||
| 4539b33788 | |||
| 9b47ec7bb3 | |||
| b9c20952a3 | |||
| e819ff4263 | |||
| a2af7fd407 | |||
| 34e0b4a71e | |||
| 8fb4b73f55 | |||
| b20b1c32bf | |||
| 684806305e | |||
| 1e9130ae6e | |||
| c57fa60f3d | |||
| 617d260dd7 | |||
| b86a48c5b9 | |||
| a2c2ab3e1a | |||
| bbe378a63e | |||
| 9d5ced06c1 | |||
| 6019d2b2f3 | |||
| ccef7fe8d0 | |||
| f2b7928df7 | |||
| 9f6f18d2c2 | |||
| 848fc30a2d | |||
| 8530aac4a8 | |||
| 3bcca35591 | |||
| e3f4094ac8 | |||
| 7df86db31d | |||
| b41f914927 | |||
| a5f68fb2c2 | |||
| 28f23328c5 | |||
| 3e1648723f | |||
| 60a72a03b2 | |||
| 741543e9a7 | |||
| a1a00aeee7 | |||
| 9152878ed3 | |||
| 81b2147092 | |||
| e570ee4b63 | |||
| 0afd953daf | |||
| f224fd9498 | |||
| 69b2bab32e | |||
| f95e28e0ff | |||
| f5cd2c6ef1 | |||
| 10ff22d6f6 | |||
| d0d407f0bb | |||
| 8ad459ed58 | |||
| cf5b51af0e | |||
| b653107b96 | |||
| 18c264790a | |||
| 7523da44fc | |||
| bd9ecafba9 | |||
| 5200c254a1 | |||
| 3d43075cfd | |||
| 5df543a60e | |||
| bed1c4a943 | |||
| 66ff4c0a06 | |||
| 9ea8065f1c | |||
| eadad29dc9 | |||
| e068b3dbe3 | |||
| 5809f6912b | |||
| 815aecf6c7 | |||
| 15d8babd1a | |||
| a78e4e9147 | |||
| d9edd25111 | |||
| 1a76bbe2e4 | |||
| af63cc85df | |||
| dff8438e50 | |||
| ec3fe6e123 | |||
| 770cee9696 | |||
| 1db89f5e6a | |||
| 5c1b768aec | |||
| f2b4305c8e | |||
| 502ecc4c9f | |||
| 34c10b84fb | |||
| f09dcd4b6d | |||
| 2b1b2017a6 | |||
| 592443f4e1 | |||
| dabab94b6e | |||
| 039089f3aa | |||
| 41c548bb23 | |||
| 9cb942820c | |||
| 0ba1ee1dd2 | |||
| 7debccbdee | |||
| 9a211c853d | |||
| ed8cab855e | |||
| 6253f69246 | |||
| 49ac5deff6 | |||
| 6737eda426 | |||
| c7132d7c93 | |||
| d9b9bfd288 | |||
| ec70cf6ef1 | |||
| a6b0b36cdc | |||
| a8380712bb | |||
| 3e839bd513 | |||
| 8633142f53 | |||
| 564b878840 | |||
| c3f59e043c | |||
| 4b0e6f38fa | |||
| fb978df0f0 | |||
| 45353da409 | |||
| 419aed3539 | |||
| 08641906e1 | |||
| 6b5ce20c16 | |||
| 800fb7533e | |||
| 789c8b8194 | |||
| e9aa190a37 | |||
| 786ad3511c | |||
| abfc9e2512 | |||
| e5c2bbd0f7 | |||
| 1494f20da3 | |||
| 4fa4a727b4 | |||
| 4be710795a | |||
| 9ea40f27a0 | |||
| 19ba134d3b | |||
| d0812ba0e6 | |||
| a2b8856558 | |||
| a61e8c8ebe | |||
| 1cf431a329 | |||
| 9ee97228bd | |||
| 43fb824bd2 | |||
| 9d774c9445 | |||
| 8b3d60557c | |||
| 134affd943 | |||
| 5df5bcba99 | |||
| 93fd7cb10c | |||
| 3705a88629 | |||
| 5cb477c4a1 | |||
| 4aabce216c | |||
| b273b20a7c | |||
| f8e05deb35 | |||
| 263e8c144c | |||
| 3e0b5f78a2 | |||
| b574c078a6 | |||
| 37817a0cd8 | |||
| a44c303d63 | |||
| e5ff0d3278 | |||
| faca708484 | |||
| fc14c79fc9 | |||
| 2670a3a684 | |||
| d81d6ea2c3 | |||
| b0cf55f145 | |||
| 5af6c9676e | |||
| 225e058685 | |||
| 3d348a3cc7 | |||
| 896f9ae83b | |||
| 11824b0461 | |||
| 9b57d5bc38 |
@@ -1,3 +0,0 @@
|
||||
--errors=errors,duplicate-properties
|
||||
--warnings=known-properties,display-property-grouping,empty-rules,important
|
||||
--exclude-list=vendor/,lib/editor/tinymce/,lib/yuilib/,theme/bootstrapbase/style/
|
||||
+1
-11
@@ -25,14 +25,4 @@ CVS
|
||||
/.project
|
||||
/.buildpath
|
||||
/.cache
|
||||
phpunit.xml
|
||||
# Composer support. Do not ignore composer.json, or composer.lock. These should be shipped by us.
|
||||
composer.phar
|
||||
/vendor/
|
||||
/behat.yml
|
||||
*/yui/build/*/*-coverage.js
|
||||
/lib/yuilib/*/build/*/*-coverage.js
|
||||
# lib/yuilib/version/module/module-coverage.js
|
||||
/lib/yuilib/*/*/*-coverage.js
|
||||
atlassian-ide-plugin.xml
|
||||
/node_modules/
|
||||
phpunit.xml
|
||||
@@ -1,54 +0,0 @@
|
||||
{
|
||||
"asi": false,
|
||||
"bitwise": true,
|
||||
"boss": false,
|
||||
"browser": true,
|
||||
"curly": true,
|
||||
"debug": false,
|
||||
"eqeqeq": false,
|
||||
"eqnull": false,
|
||||
"es5": false,
|
||||
"esnext": false,
|
||||
"evil": false,
|
||||
"expr": false,
|
||||
"forin": false,
|
||||
"funcscope": false,
|
||||
"globalstrict": false,
|
||||
"immed": true,
|
||||
"indent": 4,
|
||||
"iterator": false,
|
||||
"lastsemic": false,
|
||||
"latedef": true,
|
||||
"laxbreak": true,
|
||||
"laxcomma": false,
|
||||
"loopfunc": false,
|
||||
"maxerr": 500,
|
||||
"maxlen": 132,
|
||||
"multistr": false,
|
||||
"newcap": true,
|
||||
"noarg": true,
|
||||
"noempty": true,
|
||||
"nomen": false,
|
||||
"onecase": false,
|
||||
"onevar": false,
|
||||
"passfail": false,
|
||||
"plusplus": false,
|
||||
"predef": [
|
||||
"M",
|
||||
"define"
|
||||
],
|
||||
"proto": false,
|
||||
"regexdash": false,
|
||||
"regexp": false,
|
||||
"scripturl": false,
|
||||
"shadow": false,
|
||||
"smarttabs": false,
|
||||
"strict": false,
|
||||
"sub": false,
|
||||
"supernew": false,
|
||||
"trailing": true,
|
||||
"undef": true,
|
||||
"unused": true,
|
||||
"white": false,
|
||||
"yui": true
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
{
|
||||
"coverage": false,
|
||||
"lint": "config",
|
||||
"clean": true
|
||||
}
|
||||
-152
@@ -1,152 +0,0 @@
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* @copyright 2014 Andrew Nicols
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
/**
|
||||
* Grunt configuration
|
||||
*/
|
||||
|
||||
module.exports = function(grunt) {
|
||||
var path = require('path'),
|
||||
tasks = {},
|
||||
cwd = process.env.PWD || process.cwd();
|
||||
|
||||
// Project configuration.
|
||||
grunt.initConfig({
|
||||
jshint: {
|
||||
options: {jshintrc: '.jshintrc'},
|
||||
files: ['**/amd/src/*.js']
|
||||
},
|
||||
uglify: {
|
||||
dynamic_mappings: {
|
||||
files: grunt.file.expandMapping(
|
||||
['**/src/*.js', '!**/node_modules/**'],
|
||||
'',
|
||||
{
|
||||
cwd: cwd,
|
||||
rename: function(destBase, destPath) {
|
||||
destPath = destPath.replace('src', 'build');
|
||||
destPath = destPath.replace('.js', '.min.js');
|
||||
destPath = path.resolve(cwd, destPath);
|
||||
return destPath;
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
tasks.shifter = function() {
|
||||
var exec = require('child_process').spawn,
|
||||
done = this.async(),
|
||||
args = [],
|
||||
options = {
|
||||
recursive: true,
|
||||
watch: false,
|
||||
walk: false,
|
||||
module: false
|
||||
},
|
||||
shifter;
|
||||
|
||||
args.push( path.normalize(__dirname + '/node_modules/shifter/bin/shifter'));
|
||||
|
||||
// Determine the most appropriate options to run with based upon the current location.
|
||||
if (path.basename(cwd) === 'src') {
|
||||
// Detect whether we're in a src directory.
|
||||
grunt.log.debug('In a src directory');
|
||||
args.push('--walk');
|
||||
options.walk = true;
|
||||
} else if (path.basename(path.dirname(cwd)) === 'src') {
|
||||
// Detect whether we're in a module directory.
|
||||
grunt.log.debug('In a module directory');
|
||||
options.module = true;
|
||||
}
|
||||
|
||||
if (grunt.option('watch')) {
|
||||
if (!options.walk && !options.module) {
|
||||
grunt.fail.fatal('Unable to watch unless in a src or module directory');
|
||||
}
|
||||
|
||||
// It is not advisable to run with recursivity and watch - this
|
||||
// leads to building the build directory in a race-like fashion.
|
||||
grunt.log.debug('Detected a watch - disabling recursivity');
|
||||
options.recursive = false;
|
||||
args.push('--watch');
|
||||
}
|
||||
|
||||
if (options.recursive) {
|
||||
args.push('--recursive');
|
||||
}
|
||||
|
||||
// Always ignore the node_modules directory.
|
||||
args.push('--excludes', 'node_modules');
|
||||
|
||||
// Add the stderr option if appropriate
|
||||
if (grunt.option('verbose')) {
|
||||
args.push('--lint-stderr');
|
||||
}
|
||||
|
||||
// Actually run shifter.
|
||||
shifter = exec("node", args, {
|
||||
cwd: cwd,
|
||||
stdio: 'inherit',
|
||||
env: process.env
|
||||
});
|
||||
|
||||
// Tidy up after exec.
|
||||
shifter.on('exit', function (code) {
|
||||
if (code) {
|
||||
grunt.fail.fatal('Shifter failed with code: ' + code);
|
||||
} else {
|
||||
grunt.log.ok('Shifter build complete.');
|
||||
done();
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
tasks.startup = function() {
|
||||
// Are we in a YUI directory?
|
||||
if (path.basename(path.resolve(cwd, '../../')) == 'yui') {
|
||||
grunt.task.run('shifter');
|
||||
// Are we in an AMD directory?
|
||||
} else if (path.basename(cwd) == 'amd') {
|
||||
grunt.task.run('jshint');
|
||||
grunt.task.run('uglify');
|
||||
} else {
|
||||
// Run them all!.
|
||||
grunt.task.run('shifter');
|
||||
grunt.task.run('jshint');
|
||||
grunt.task.run('uglify');
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
// Register NPM tasks.
|
||||
grunt.loadNpmTasks('grunt-contrib-uglify');
|
||||
grunt.loadNpmTasks('grunt-contrib-jshint');
|
||||
|
||||
// Register the shifter task.
|
||||
grunt.registerTask('shifter', 'Run Shifter against the current directory', tasks.shifter);
|
||||
|
||||
// Register the startup task.
|
||||
grunt.registerTask('startup', 'Run the correct tasks for the current directory', tasks.startup);
|
||||
|
||||
// Register the default task.
|
||||
grunt.registerTask('default', ['startup']);
|
||||
};
|
||||
+1
-1
@@ -8,7 +8,7 @@ a few minutes:
|
||||
1) Move the Moodle files into your web directory.
|
||||
|
||||
2) Create a single database for Moodle to store all
|
||||
its tables in (or choose an existing database).
|
||||
it's tables in (or choose an existing database).
|
||||
|
||||
3) Visit your Moodle site with a browser, you should
|
||||
be taken to the install.php script, which will lead
|
||||
|
||||
+4
-6
@@ -12,13 +12,13 @@ require_once($CFG->libdir.'/adminlib.php');
|
||||
require_once($CFG->libdir.'/tablelib.php');
|
||||
|
||||
require_login();
|
||||
require_capability('moodle/site:config', context_system::instance());
|
||||
require_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM));
|
||||
|
||||
$returnurl = new moodle_url('/admin/settings.php', array('section'=>'manageauths'));
|
||||
|
||||
$PAGE->set_url($returnurl);
|
||||
|
||||
$action = optional_param('action', '', PARAM_ALPHANUMEXT);
|
||||
$action = optional_param('action', '', PARAM_ACTION);
|
||||
$auth = optional_param('auth', '', PARAM_PLUGIN);
|
||||
|
||||
get_enabled_auth_plugins(true); // fix the list of enabled auths
|
||||
@@ -51,8 +51,7 @@ switch ($action) {
|
||||
if ($auth == $CFG->registerauth) {
|
||||
set_config('registerauth', '');
|
||||
}
|
||||
\core\session\manager::gc(); // Remove stale sessions.
|
||||
core_plugin_manager::reset_caches();
|
||||
session_gc(); // remove stale sessions
|
||||
break;
|
||||
|
||||
case 'enable':
|
||||
@@ -62,8 +61,7 @@ switch ($action) {
|
||||
$authsenabled = array_unique($authsenabled);
|
||||
set_config('auth', implode(',', $authsenabled));
|
||||
}
|
||||
\core\session\manager::gc(); // Remove stale sessions.
|
||||
core_plugin_manager::reset_caches();
|
||||
session_gc(); // remove stale sessions
|
||||
break;
|
||||
|
||||
case 'down':
|
||||
|
||||
+11
-21
@@ -78,9 +78,6 @@ echo '<p style="text-align: center"><input type="submit" value="' . get_string("
|
||||
echo "</div>\n";
|
||||
echo "</form>\n";
|
||||
|
||||
$PAGE->requires->string_for_js('unmaskpassword', 'core_form');
|
||||
$PAGE->requires->yui_module('moodle-auth-passwordunmask', 'M.auth.passwordunmask');
|
||||
|
||||
echo $OUTPUT->footer();
|
||||
exit;
|
||||
|
||||
@@ -90,8 +87,8 @@ exit;
|
||||
// but some may want a custom one if they are offering
|
||||
// other options
|
||||
// Note: lockconfig_ fields have special handling.
|
||||
function print_auth_lock_options($auth, $user_fields, $helptext, $retrieveopts, $updateopts, $customfields = array()) {
|
||||
global $DB, $OUTPUT;
|
||||
function print_auth_lock_options ($auth, $user_fields, $helptext, $retrieveopts, $updateopts) {
|
||||
global $OUTPUT;
|
||||
echo '<tr><td colspan="3">';
|
||||
if ($retrieveopts) {
|
||||
echo $OUTPUT->heading(get_string('auth_data_mapping', 'auth'));
|
||||
@@ -110,21 +107,14 @@ function print_auth_lock_options($auth, $user_fields, $helptext, $retrieveopts,
|
||||
|
||||
$pluginconfig = get_config("auth/$auth");
|
||||
|
||||
// Helptext is on a field with rowspan.
|
||||
// helptext is on a field with rowspan
|
||||
if (empty($helptext)) {
|
||||
$helptext = ' ';
|
||||
$helptext = ' ';
|
||||
}
|
||||
|
||||
// If we have custom fields then merge them with user fields.
|
||||
if (!empty($customfields)) {
|
||||
$user_fields = array_merge($user_fields, $customfields);
|
||||
}
|
||||
|
||||
if (!empty($customfields)) {
|
||||
$customfieldname = $DB->get_records('user_info_field', null, '', 'shortname, name');
|
||||
}
|
||||
foreach ($user_fields as $field) {
|
||||
// Define some vars we'll work with.
|
||||
|
||||
// Define some vars we'll work with
|
||||
if (!isset($pluginconfig->{"field_map_$field"})) {
|
||||
$pluginconfig->{"field_map_$field"} = '';
|
||||
}
|
||||
@@ -138,14 +128,10 @@ function print_auth_lock_options($auth, $user_fields, $helptext, $retrieveopts,
|
||||
$pluginconfig->{"field_lock_$field"} = '';
|
||||
}
|
||||
|
||||
// Define the fieldname we display to the user.
|
||||
// define the fieldname we display to the user
|
||||
$fieldname = $field;
|
||||
if ($fieldname === 'lang') {
|
||||
$fieldname = get_string('language');
|
||||
} elseif (!empty($customfields) && in_array($field, $customfields)) {
|
||||
// If custom field then pick name from database.
|
||||
$fieldshortname = str_replace('profile_field_', '', $fieldname);
|
||||
$fieldname = $customfieldname[$fieldshortname]->name;
|
||||
} elseif (preg_match('/^(.+?)(\d+)$/', $fieldname, $matches)) {
|
||||
$fieldname = get_string($matches[1]) . ' ' . $matches[2];
|
||||
} elseif ($fieldname == 'url') {
|
||||
@@ -169,6 +155,8 @@ function print_auth_lock_options($auth, $user_fields, $helptext, $retrieveopts,
|
||||
echo '<label for="menulockconfig_field_updateremote_'.$field.'">'.get_string('auth_updateremote', 'auth') . '</label> ';
|
||||
echo html_writer::select($updateextoptions, "lockconfig_field_updateremote_{$field}", $pluginconfig->{"field_updateremote_$field"}, false);
|
||||
echo '<br />';
|
||||
|
||||
|
||||
}
|
||||
echo '<label for="menulockconfig_field_lock_'.$field.'">'.get_string('auth_fieldlock', 'auth') . '</label> ';
|
||||
echo html_writer::select($lockoptions, "lockconfig_field_lock_{$field}", $pluginconfig->{"field_lock_$field"}, false);
|
||||
@@ -187,3 +175,5 @@ function print_auth_lock_options($auth, $user_fields, $helptext, $retrieveopts,
|
||||
echo '</tr>';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,76 @@
|
||||
<?php
|
||||
|
||||
// block.php - allows admin to edit all local configuration variables for a block
|
||||
|
||||
require_once('../config.php');
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
|
||||
$blockid = required_param('block', PARAM_INT);
|
||||
|
||||
if(!$blockrecord = blocks_get_record($blockid)) {
|
||||
print_error('blockdoesnotexist', 'error');
|
||||
}
|
||||
|
||||
admin_externalpage_setup('blocksetting'.$blockrecord->name);
|
||||
|
||||
$block = block_instance($blockrecord->name);
|
||||
if($block === false) {
|
||||
print_error('blockcannotinistantiate', 'error');
|
||||
}
|
||||
|
||||
// Define the data we're going to silently include in the instance config form here,
|
||||
// so we can strip them from the submitted data BEFORE handling it.
|
||||
$hiddendata = array(
|
||||
'block' => $blockid,
|
||||
'sesskey' => sesskey()
|
||||
);
|
||||
|
||||
/// If data submitted, then process and store.
|
||||
|
||||
if ($config = data_submitted()) {
|
||||
|
||||
if (!confirm_sesskey()) {
|
||||
print_error('confirmsesskeybad', 'error');
|
||||
}
|
||||
if(!$block->has_config()) {
|
||||
print_error('blockcannotconfig', 'error');
|
||||
}
|
||||
$remove = array_keys($hiddendata);
|
||||
foreach($remove as $item) {
|
||||
unset($config->$item);
|
||||
}
|
||||
$block->config_save($config);
|
||||
redirect("$CFG->wwwroot/$CFG->admin/blocks.php", get_string("changessaved"), 1);
|
||||
exit;
|
||||
}
|
||||
|
||||
/// Otherwise print the form.
|
||||
|
||||
$strmanageblocks = get_string('manageblocks');
|
||||
$strblockname = $block->get_title();
|
||||
|
||||
echo $OUTPUT->header();
|
||||
|
||||
echo $OUTPUT->heading($strblockname);
|
||||
|
||||
echo $OUTPUT->notification('This block still uses an old-style config_global.html file. ' .
|
||||
'It must be updated by a developer to use a settings.php file.');
|
||||
|
||||
echo $OUTPUT->box(get_string('configwarning', 'admin'), 'generalbox boxwidthnormal boxaligncenter');
|
||||
echo '<br />';
|
||||
|
||||
echo '<form method="post" action="block.php">';
|
||||
echo '<p>';
|
||||
foreach($hiddendata as $name => $val) {
|
||||
echo '<input type="hidden" name="'. $name .'" value="'. $val .'" />';
|
||||
}
|
||||
echo '</p>';
|
||||
|
||||
echo $OUTPUT->box_start();
|
||||
include($CFG->dirroot.'/blocks/'. $block->name() .'/config_global.html');
|
||||
echo $OUTPUT->box_end();
|
||||
|
||||
echo '</form>';
|
||||
echo $OUTPUT->footer();
|
||||
|
||||
|
||||
+54
-37
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
// Allows the admin to configure blocks (hide/show, uninstall and configure)
|
||||
// Allows the admin to configure blocks (hide/show, delete and configure)
|
||||
|
||||
require_once('../config.php');
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
@@ -11,13 +11,14 @@
|
||||
$confirm = optional_param('confirm', 0, PARAM_BOOL);
|
||||
$hide = optional_param('hide', 0, PARAM_INT);
|
||||
$show = optional_param('show', 0, PARAM_INT);
|
||||
$delete = optional_param('delete', 0, PARAM_INT);
|
||||
$unprotect = optional_param('unprotect', 0, PARAM_INT);
|
||||
$protect = optional_param('protect', 0, PARAM_INT);
|
||||
|
||||
/// Print headings
|
||||
|
||||
$strmanageblocks = get_string('manageblocks');
|
||||
$struninstall = get_string('uninstallplugin', 'core_admin');
|
||||
$strdelete = get_string('delete');
|
||||
$strversion = get_string('version');
|
||||
$strhide = get_string('hide');
|
||||
$strshow = get_string('show');
|
||||
@@ -36,7 +37,6 @@
|
||||
print_error('blockdoesnotexist', 'error');
|
||||
}
|
||||
$DB->set_field('block', 'visible', '0', array('id'=>$block->id)); // Hide block
|
||||
core_plugin_manager::reset_caches();
|
||||
admin_get_root(true, false); // settings not required - only pages
|
||||
}
|
||||
|
||||
@@ -45,7 +45,6 @@
|
||||
print_error('blockdoesnotexist', 'error');
|
||||
}
|
||||
$DB->set_field('block', 'visible', '1', array('id'=>$block->id)); // Show block
|
||||
core_plugin_manager::reset_caches();
|
||||
admin_get_root(true, false); // settings not required - only pages
|
||||
}
|
||||
|
||||
@@ -79,6 +78,35 @@
|
||||
admin_get_root(true, false); // settings not required - only pages
|
||||
}
|
||||
|
||||
if (!empty($delete) && confirm_sesskey()) {
|
||||
echo $OUTPUT->header();
|
||||
echo $OUTPUT->heading($strmanageblocks);
|
||||
|
||||
if (!$block = blocks_get_record($delete)) {
|
||||
print_error('blockdoesnotexist', 'error');
|
||||
}
|
||||
|
||||
if (get_string_manager()->string_exists('pluginname', "block_$block->name")) {
|
||||
$strblockname = get_string('pluginname', "block_$block->name");
|
||||
} else {
|
||||
$strblockname = $block->name;
|
||||
}
|
||||
|
||||
if (!$confirm) {
|
||||
echo $OUTPUT->confirm(get_string('blockdeleteconfirm', '', $strblockname), 'blocks.php?delete='.$block->id.'&confirm=1', 'blocks.php');
|
||||
echo $OUTPUT->footer();
|
||||
exit;
|
||||
|
||||
} else {
|
||||
uninstall_plugin('block', $block->name);
|
||||
|
||||
$a = new stdClass();
|
||||
$a->block = $strblockname;
|
||||
$a->directory = $CFG->dirroot.'/blocks/'.$block->name;
|
||||
notice(get_string('blockdeletefiles', '', $a), 'blocks.php');
|
||||
}
|
||||
}
|
||||
|
||||
echo $OUTPUT->header();
|
||||
echo $OUTPUT->heading($strmanageblocks);
|
||||
|
||||
@@ -96,11 +124,10 @@
|
||||
|
||||
$table = new flexible_table('admin-blocks-compatible');
|
||||
|
||||
$table->define_columns(array('name', 'instances', 'version', 'hideshow', 'undeletable', 'settings', 'uninstall'));
|
||||
$table->define_headers(array($strname, $strcourses, $strversion, $strhide.'/'.$strshow, $strprotecthdr, $strsettings, $struninstall));
|
||||
$table->define_columns(array('name', 'instances', 'version', 'hideshow', 'undeletable', 'delete', 'settings'));
|
||||
$table->define_headers(array($strname, $strcourses, $strversion, $strhide.'/'.$strshow, $strprotecthdr, $strdelete, $strsettings));
|
||||
$table->define_baseurl($CFG->wwwroot.'/'.$CFG->admin.'/blocks.php');
|
||||
$table->set_attribute('class', 'admintable blockstable generaltable');
|
||||
$table->set_attribute('id', 'compatibleblockstable');
|
||||
$table->set_attribute('class', 'compatibleblockstable blockstable generaltable');
|
||||
$table->setup();
|
||||
$tablerows = array();
|
||||
|
||||
@@ -114,18 +141,17 @@
|
||||
$blocknames[$blockid] = $blockname;
|
||||
}
|
||||
}
|
||||
core_collator::asort($blocknames);
|
||||
collatorlib::asort($blocknames);
|
||||
|
||||
foreach ($blocknames as $blockid=>$strblockname) {
|
||||
$block = $blocks[$blockid];
|
||||
$blockname = $block->name;
|
||||
$dbversion = get_config('block_'.$block->name, 'version');
|
||||
|
||||
if (!file_exists("$CFG->dirroot/blocks/$blockname/block_$blockname.php")) {
|
||||
$blockobject = false;
|
||||
$strblockname = '<span class="notifyproblem">'.$strblockname.' ('.get_string('missingfromdisk').')</span>';
|
||||
$plugin = new stdClass();
|
||||
$plugin->version = $dbversion;
|
||||
$plugin->version = $block->version;
|
||||
|
||||
} else {
|
||||
$plugin = new stdClass();
|
||||
@@ -140,11 +166,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
if ($uninstallurl = core_plugin_manager::instance()->get_uninstall_url('block_'.$blockname, 'manage')) {
|
||||
$uninstall = html_writer::link($uninstallurl, $struninstall);
|
||||
} else {
|
||||
$uninstall = '';
|
||||
}
|
||||
$delete = '<a href="blocks.php?delete='.$blockid.'&sesskey='.sesskey().'">'.$strdelete.'</a>';
|
||||
|
||||
$settings = ''; // By default, no configuration
|
||||
if ($blockobject and $blockobject->has_config()) {
|
||||
@@ -179,17 +201,17 @@
|
||||
$visible = '';
|
||||
} else if ($blocks[$blockid]->visible) {
|
||||
$visible = '<a href="blocks.php?hide='.$blockid.'&sesskey='.sesskey().'" title="'.$strhide.'">'.
|
||||
'<img src="'.$OUTPUT->pix_url('t/hide') . '" class="iconsmall" alt="'.$strhide.'" /></a>';
|
||||
'<img src="'.$OUTPUT->pix_url('i/hide') . '" class="icon" alt="'.$strhide.'" /></a>';
|
||||
} else {
|
||||
$visible = '<a href="blocks.php?show='.$blockid.'&sesskey='.sesskey().'" title="'.$strshow.'">'.
|
||||
'<img src="'.$OUTPUT->pix_url('t/show') . '" class="iconsmall" alt="'.$strshow.'" /></a>';
|
||||
$class = 'dimmed_text';
|
||||
'<img src="'.$OUTPUT->pix_url('i/show') . '" class="icon" alt="'.$strshow.'" /></a>';
|
||||
$class = ' class="dimmed_text"'; // Leading space required!
|
||||
}
|
||||
|
||||
if ($dbversion == $plugin->version) {
|
||||
$version = $dbversion;
|
||||
if ($block->version == $plugin->version) {
|
||||
$version = $block->version;
|
||||
} else {
|
||||
$version = "$dbversion ($plugin->version)";
|
||||
$version = "$block->version ($plugin->version)";
|
||||
}
|
||||
|
||||
if (!$blockobject) {
|
||||
@@ -197,22 +219,22 @@
|
||||
$undeletable = '';
|
||||
} else if (in_array($blockname, $undeletableblocktypes)) {
|
||||
$undeletable = '<a href="blocks.php?unprotect='.$blockid.'&sesskey='.sesskey().'" title="'.$strunprotect.'">'.
|
||||
'<img src="'.$OUTPUT->pix_url('t/unlock') . '" class="iconsmall" alt="'.$strunprotect.'" /></a>';
|
||||
'<img src="'.$OUTPUT->pix_url('t/unlock') . '" class="icon" alt="'.$strunprotect.'" /></a>';
|
||||
} else {
|
||||
$undeletable = '<a href="blocks.php?protect='.$blockid.'&sesskey='.sesskey().'" title="'.$strprotect.'">'.
|
||||
'<img src="'.$OUTPUT->pix_url('t/lock') . '" class="iconsmall" alt="'.$strprotect.'" /></a>';
|
||||
'<img src="'.$OUTPUT->pix_url('t/unlock_gray') . '" class="icon" alt="'.$strprotect.'" /></a>';
|
||||
}
|
||||
|
||||
$row = array(
|
||||
$strblockname,
|
||||
'<span'.$class.'>'.$strblockname.'</span>',
|
||||
$blocklist,
|
||||
$version,
|
||||
'<span'.$class.'>'.$version.'</span>',
|
||||
$visible,
|
||||
$undeletable,
|
||||
$settings,
|
||||
$uninstall,
|
||||
$delete,
|
||||
$settings
|
||||
);
|
||||
$table->add_data($row, $class);
|
||||
$table->add_data($row);
|
||||
}
|
||||
|
||||
$table->print_html();
|
||||
@@ -222,8 +244,8 @@
|
||||
|
||||
$table = new flexible_table('admin-blocks-incompatible');
|
||||
|
||||
$table->define_columns(array('block', 'uninstall'));
|
||||
$table->define_headers(array($strname, $struninstall));
|
||||
$table->define_columns(array('block', 'delete'));
|
||||
$table->define_headers(array($strname, $strdelete));
|
||||
$table->define_baseurl($CFG->wwwroot.'/'.$CFG->admin.'/blocks.php');
|
||||
|
||||
$table->set_attribute('class', 'incompatibleblockstable generaltable');
|
||||
@@ -231,14 +253,9 @@
|
||||
$table->setup();
|
||||
|
||||
foreach ($incompatible as $block) {
|
||||
if ($uninstallurl = core_plugin_manager::instance()->get_uninstall_url('block_'.$block->name, 'manage')) {
|
||||
$uninstall = html_writer::link($uninstallurl, $struninstall);
|
||||
} else {
|
||||
$uninstall = '';
|
||||
}
|
||||
$table->add_data(array(
|
||||
$block->name,
|
||||
$uninstall,
|
||||
'<a href="blocks.php?delete='.$block->id.'&sesskey='.sesskey().'">'.$strdelete.'</a>',
|
||||
));
|
||||
}
|
||||
$table->print_html();
|
||||
|
||||
+23
-21
@@ -17,7 +17,7 @@
|
||||
/**
|
||||
* This file is used to display a categories sub categories, external pages, and settings.
|
||||
*
|
||||
* @since Moodle 2.3
|
||||
* @since 2.3
|
||||
* @package admin
|
||||
* @copyright 2011 Sam Hemelryk
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
@@ -32,7 +32,7 @@ $adminediting = optional_param('adminedit', -1, PARAM_BOOL);
|
||||
|
||||
/// no guest autologin
|
||||
require_login(0, false);
|
||||
$PAGE->set_context(context_system::instance());
|
||||
$PAGE->set_context(get_context_instance(CONTEXT_SYSTEM));
|
||||
$PAGE->set_url('/admin/category.php', array('category' => $category));
|
||||
$PAGE->set_pagetype('admin-setting-' . $category);
|
||||
$PAGE->set_pagelayout('admin');
|
||||
@@ -67,6 +67,7 @@ if ($data = data_submitted() and confirm_sesskey()) {
|
||||
$errormsg = get_string('errorwithsettings', 'admin');
|
||||
$firsterror = reset($adminroot->errors);
|
||||
}
|
||||
$adminroot = admin_get_root(true); //reload tree
|
||||
$settingspage = $adminroot->locate($category, true);
|
||||
}
|
||||
|
||||
@@ -96,26 +97,27 @@ foreach ($settingspage->children as $childpage) {
|
||||
$outputhtml .= $OUTPUT->heading(html_writer::link($childpage->url, $childpage->visiblename), 3);
|
||||
} else if ($childpage instanceof admin_settingpage) {
|
||||
$outputhtml .= $OUTPUT->heading(html_writer::link(new moodle_url('/'.$CFG->admin.'/settings.php', array('section' => $childpage->name)), $childpage->visiblename), 3);
|
||||
// If its a settings page and has settings lets display them.
|
||||
if (!empty($childpage->settings)) {
|
||||
$outputhtml .= html_writer::start_tag('fieldset', array('class' => 'adminsettings'));
|
||||
foreach ($childpage->settings as $setting) {
|
||||
if (empty($setting->nosave)) {
|
||||
$savebutton = true;
|
||||
}
|
||||
$fullname = $setting->get_full_name();
|
||||
if (array_key_exists($fullname, $adminroot->errors)) {
|
||||
$data = $adminroot->errors[$fullname]->data;
|
||||
} else {
|
||||
$data = $setting->get_setting();
|
||||
}
|
||||
$outputhtml .= html_writer::tag('div', '<!-- -->', array('class' => 'clearer'));
|
||||
$outputhtml .= $setting->output_html($data);
|
||||
}
|
||||
$outputhtml .= html_writer::end_tag('fieldset');
|
||||
}
|
||||
} else if ($childpage instanceof admin_category) {
|
||||
$outputhtml .= $OUTPUT->heading(html_writer::link(new moodle_url('/'.$CFG->admin.'/category.php', array('category' => $childpage->name)), get_string('admincategory', 'admin', $childpage->visiblename)), 3);
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
if (!empty($childpage->settings)) {
|
||||
$outputhtml .= html_writer::start_tag('fieldset', array('class' => 'adminsettings'));
|
||||
foreach ($childpage->settings as $setting) {
|
||||
if (empty($setting->nosave)) {
|
||||
$savebutton = true;
|
||||
}
|
||||
$fullname = $setting->get_full_name();
|
||||
if (array_key_exists($fullname, $adminroot->errors)) {
|
||||
$data = $adminroot->errors[$fullname]->data;
|
||||
} else {
|
||||
$data = $setting->get_setting();
|
||||
}
|
||||
$outputhtml .= html_writer::tag('div', '<!-- -->', array('class' => 'clearer'));
|
||||
$outputhtml .= $setting->output_html($data);
|
||||
}
|
||||
$outputhtml .= html_writer::end_tag('fieldset');
|
||||
}
|
||||
}
|
||||
if ($savebutton) {
|
||||
@@ -155,4 +157,4 @@ echo $outputhtml;
|
||||
echo html_writer::end_tag('fieldset');
|
||||
echo html_writer::end_tag('form');
|
||||
|
||||
echo $OUTPUT->footer();
|
||||
echo $OUTPUT->footer();
|
||||
@@ -1,111 +0,0 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* This hack is intended for clustered sites that do not want
|
||||
* to use shared cachedir for component cache.
|
||||
*
|
||||
* This file needs to be called after any change in PHP files in dataroot,
|
||||
* that is before upgrade and install.
|
||||
*
|
||||
* @package core
|
||||
* @copyright 2013 Petr Skoda (skodak) {@link http://skodak.org}
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
|
||||
define('CLI_SCRIPT', true);
|
||||
define('ABORT_AFTER_CONFIG', true); // We need just the values from config.php.
|
||||
define('CACHE_DISABLE_ALL', true); // This prevents reading of existing caches.
|
||||
define('IGNORE_COMPONENT_CACHE', true);
|
||||
|
||||
require(__DIR__.'/../../config.php');
|
||||
require_once($CFG->libdir.'/clilib.php');
|
||||
|
||||
// Now get cli options.
|
||||
list($options, $unrecognized) = cli_get_params(
|
||||
array(
|
||||
'file' => false,
|
||||
'rebuild' => false,
|
||||
'print' => false,
|
||||
'help' => false
|
||||
),
|
||||
array(
|
||||
'h' => 'help'
|
||||
)
|
||||
);
|
||||
|
||||
if ($unrecognized) {
|
||||
$unrecognized = implode("\n ", $unrecognized);
|
||||
cli_error(get_string('cliunknowoption', 'admin', $unrecognized), 2);
|
||||
}
|
||||
|
||||
if (!$options['rebuild'] and !$options['file'] and !$options['print']) {
|
||||
$help =
|
||||
"Create alternative component cache file
|
||||
|
||||
Options:
|
||||
-h, --help Print out this help
|
||||
--rebuild Rebuild \$CFG->alternative_component_cache file
|
||||
--file=filepath Save component cache to file
|
||||
--print Print component cache file content
|
||||
|
||||
Example:
|
||||
\$ php admin/cli/rebuild_alternative_component_cache.php --rebuild
|
||||
";
|
||||
|
||||
echo $help;
|
||||
exit(0);
|
||||
}
|
||||
|
||||
error_reporting(E_ALL | E_STRICT);
|
||||
ini_set('display_errors', 1);
|
||||
|
||||
$content = core_component::get_cache_content();
|
||||
|
||||
if ($options['print']) {
|
||||
echo $content;
|
||||
exit(0);
|
||||
}
|
||||
|
||||
if ($options['rebuild']) {
|
||||
if (empty($CFG->alternative_component_cache)) {
|
||||
fwrite(STDERR, 'config.php does not contain $CFG->alternative_component_cache setting');
|
||||
fwrite(STDERR, "\n");
|
||||
exit(2);
|
||||
}
|
||||
$target = $CFG->alternative_component_cache;
|
||||
} else {
|
||||
$target = $options['file'];
|
||||
}
|
||||
|
||||
if (!$target) {
|
||||
fwrite(STDERR, "Invalid target file $target");
|
||||
fwrite(STDERR, "\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
$bytes = file_put_contents($target, $content);
|
||||
|
||||
if (!$bytes) {
|
||||
fwrite(STDERR, "Error writing to $target");
|
||||
fwrite(STDERR, "\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
// Success.
|
||||
echo "File $target was updated\n";
|
||||
exit(0);
|
||||
@@ -75,7 +75,8 @@ if (!empty($CFG->showcronsql)) {
|
||||
$DB->set_debug(true);
|
||||
}
|
||||
if (!empty($CFG->showcrondebugging)) {
|
||||
set_debugging(DEBUG_DEVELOPER, true);
|
||||
$CFG->debug = DEBUG_DEVELOPER;
|
||||
$CFG->debugdisplay = true;
|
||||
}
|
||||
|
||||
$starttime = microtime();
|
||||
|
||||
@@ -1,119 +0,0 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* This script allows to do backup.
|
||||
*
|
||||
* @package core
|
||||
* @subpackage cli
|
||||
* @copyright 2013 Lancaster University
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
define('CLI_SCRIPT', 1);
|
||||
|
||||
require(dirname(dirname(dirname(__FILE__))).'/config.php');
|
||||
require_once($CFG->libdir.'/clilib.php');
|
||||
require_once($CFG->dirroot . '/backup/util/includes/backup_includes.php');
|
||||
|
||||
// Now get cli options.
|
||||
list($options, $unrecognized) = cli_get_params(array(
|
||||
'courseid' => false,
|
||||
'courseshortname' => '',
|
||||
'destination' => '',
|
||||
'help' => false,
|
||||
), array('h' => 'help'));
|
||||
|
||||
if ($unrecognized) {
|
||||
$unrecognized = implode("\n ", $unrecognized);
|
||||
cli_error(get_string('cliunknowoption', 'admin', $unrecognized));
|
||||
}
|
||||
|
||||
if ($options['help'] || !($options['courseid'] || $options['courseshortname'])) {
|
||||
$help = <<<EOL
|
||||
Perform backup of the given course.
|
||||
|
||||
Options:
|
||||
--courseid=INTEGER Course ID for backup.
|
||||
--courseshortname=STRING Course shortname for backup.
|
||||
--destination=STRING Path where to store backup file. If not set the backup
|
||||
will be stored within the course backup file area.
|
||||
-h, --help Print out this help.
|
||||
|
||||
Example:
|
||||
\$sudo -u www-data /usr/bin/php admin/cli/backup.php --courseid=2 --destination=/moodle/backup/\n
|
||||
EOL;
|
||||
|
||||
echo $help;
|
||||
die;
|
||||
}
|
||||
|
||||
$admin = get_admin();
|
||||
if (!$admin) {
|
||||
mtrace("Error: No admin account was found");
|
||||
die;
|
||||
}
|
||||
|
||||
// Do we need to store backup somewhere else?
|
||||
$dir = rtrim($options['destination'], '/');
|
||||
if (!empty($dir)) {
|
||||
if (!file_exists($dir) || !is_dir($dir) || !is_writable($dir)) {
|
||||
mtrace("Destination directory does not exists or not writable.");
|
||||
die;
|
||||
}
|
||||
}
|
||||
|
||||
// Check that the course exists.
|
||||
if ($options['courseid']) {
|
||||
$course = $DB->get_record('course', array('id' => $options['courseid']), '*', MUST_EXIST);
|
||||
} else if ($options['courseshortname']) {
|
||||
$course = $DB->get_record('course', array('shortname' => $options['courseshortname']), '*', MUST_EXIST);
|
||||
}
|
||||
|
||||
cli_heading('Performing backup...');
|
||||
$bc = new backup_controller(backup::TYPE_1COURSE, $course->id, backup::FORMAT_MOODLE,
|
||||
backup::INTERACTIVE_YES, backup::MODE_GENERAL, $admin->id);
|
||||
// Set the default filename.
|
||||
$format = $bc->get_format();
|
||||
$type = $bc->get_type();
|
||||
$id = $bc->get_id();
|
||||
$users = $bc->get_plan()->get_setting('users')->get_value();
|
||||
$anonymised = $bc->get_plan()->get_setting('anonymize')->get_value();
|
||||
$filename = backup_plan_dbops::get_default_backup_filename($format, $type, $id, $users, $anonymised);
|
||||
$bc->get_plan()->get_setting('filename')->set_value($filename);
|
||||
|
||||
// Execution.
|
||||
$bc->finish_ui();
|
||||
$bc->execute_plan();
|
||||
$results = $bc->get_results();
|
||||
$file = $results['backup_destination']; // May be empty if file already moved to target location.
|
||||
|
||||
// Do we need to store backup somewhere else?
|
||||
if (!empty($dir)) {
|
||||
if ($file) {
|
||||
mtrace("Writing " . $dir.'/'.$filename);
|
||||
if ($file->copy_content_to($dir.'/'.$filename)) {
|
||||
$file->delete();
|
||||
mtrace("Backup completed.");
|
||||
} else {
|
||||
mtrace("Destination directory does not exist or is not writable. Leaving the backup in the course backup file area.");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
mtrace("Backup completed, the new file is listed in the backup area of the given course");
|
||||
}
|
||||
$bc->destroy();
|
||||
exit(0);
|
||||
@@ -1,76 +0,0 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Validate that the current db structure matches the install.xml files.
|
||||
*
|
||||
* @package core
|
||||
* @copyright 2014 Totara Learning Solutions Ltd {@link http://www.totaralms.com/}
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
* @author Petr Skoda <petr.skoda@totaralms.com>
|
||||
*/
|
||||
|
||||
define('CLI_SCRIPT', true);
|
||||
|
||||
require(__DIR__ . '/../../config.php');
|
||||
require_once($CFG->libdir.'/clilib.php');
|
||||
|
||||
$help = "Validate database structure
|
||||
|
||||
Options:
|
||||
-h, --help Print out this help.
|
||||
|
||||
Example:
|
||||
\$ sudo -u www-data /usr/bin/php admin/cli/check_database_schema.php
|
||||
";
|
||||
|
||||
list($options, $unrecognized) = cli_get_params(
|
||||
array(
|
||||
'help' => false,
|
||||
),
|
||||
array(
|
||||
'h' => 'help',
|
||||
)
|
||||
);
|
||||
|
||||
if ($options['help']) {
|
||||
echo $help;
|
||||
exit(0);
|
||||
}
|
||||
|
||||
if (empty($CFG->version)) {
|
||||
echo "Database is not yet installed.\n";
|
||||
exit(2);
|
||||
}
|
||||
|
||||
$dbmanager = $DB->get_manager();
|
||||
$schema = $dbmanager->get_install_xml_schema();
|
||||
|
||||
if (!$errors = $dbmanager->check_database_schema($schema)) {
|
||||
echo "Database structure is ok.\n";
|
||||
exit(0);
|
||||
}
|
||||
|
||||
foreach ($errors as $table => $items) {
|
||||
cli_separator();
|
||||
echo "$table\n";
|
||||
foreach ($items as $item) {
|
||||
echo " * $item\n";
|
||||
}
|
||||
}
|
||||
cli_separator();
|
||||
|
||||
exit(1);
|
||||
@@ -1,125 +0,0 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* This script fixed incorrectly deleted users.
|
||||
*
|
||||
* @package core
|
||||
* @subpackage cli
|
||||
* @copyright 2013 Marina Glancy
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
define('CLI_SCRIPT', true);
|
||||
|
||||
require(__DIR__.'/../../config.php');
|
||||
require_once($CFG->libdir.'/clilib.php');
|
||||
|
||||
// Get cli options.
|
||||
list($options, $unrecognized) = cli_get_params(
|
||||
array(
|
||||
'courses' => false,
|
||||
'fix' => false,
|
||||
'help' => false
|
||||
),
|
||||
array(
|
||||
'h' => 'help',
|
||||
'c' => 'courses',
|
||||
'f' => 'fix'
|
||||
)
|
||||
);
|
||||
|
||||
if ($options['help'] || empty($options['courses'])) {
|
||||
$help =
|
||||
"Checks and fixes that course modules and sections reference each other correctly.
|
||||
|
||||
Compares DB fields course_sections.sequence and course_modules.section
|
||||
checking that:
|
||||
- course_sections.sequence contains each module id not more than once in the course
|
||||
- for each moduleid from course_sections.sequence the field course_modules.section
|
||||
refers to the same section id (this means course_sections.sequence is more
|
||||
important if they are different)
|
||||
- each module in the course is present in one of course_sections.sequence
|
||||
- section sequences do not contain non-existing course modules
|
||||
|
||||
If there are any mismatches, the message is displayed. If --fix is specified,
|
||||
the records in DB are corrected.
|
||||
|
||||
This script may run for a long time on big systems if called for all courses.
|
||||
|
||||
Avoid executing the script when another user may simultaneously edit any of the
|
||||
courses being checked (recommended to run in mainenance mode).
|
||||
|
||||
Options:
|
||||
-c, --courses List courses that need to be checked (comma-separated
|
||||
values or * for all). Required
|
||||
-f, --fix Fix the mismatches in DB. If not specified check only and
|
||||
report problems to STDERR
|
||||
-h, --help Print out this help
|
||||
|
||||
Example:
|
||||
\$sudo -u www-data /usr/bin/php admin/cli/fix_course_sequence.php --courses=*
|
||||
\$sudo -u www-data /usr/bin/php admin/cli/fix_course_sequence.php --courses=2,3,4 --fix
|
||||
";
|
||||
|
||||
echo $help;
|
||||
die;
|
||||
}
|
||||
|
||||
$courseslist = preg_split('/\s*,\s*/', $options['courses'], -1, PREG_SPLIT_NO_EMPTY);
|
||||
if (in_array('*', $courseslist)) {
|
||||
$where = '';
|
||||
$params = array();
|
||||
} else {
|
||||
list($sql, $params) = $DB->get_in_or_equal($courseslist, SQL_PARAMS_NAMED, 'id');
|
||||
$where = 'WHERE id '. $sql;
|
||||
}
|
||||
$coursescount = $DB->get_field_sql('SELECT count(id) FROM {course} '. $where, $params);
|
||||
|
||||
if (!$coursescount) {
|
||||
cli_error('No courses found');
|
||||
}
|
||||
echo "Checking $coursescount courses...\n\n";
|
||||
|
||||
require_once($CFG->dirroot. '/course/lib.php');
|
||||
|
||||
$problems = array();
|
||||
$courses = $DB->get_fieldset_sql('SELECT id FROM {course} '. $where, $params);
|
||||
foreach ($courses as $courseid) {
|
||||
$errors = course_integrity_check($courseid, null, null, true, empty($options['fix']));
|
||||
if ($errors) {
|
||||
if (!empty($options['fix'])) {
|
||||
// Reset the course cache to make sure cache is recalculated next time the course is viewed.
|
||||
rebuild_course_cache($courseid, true);
|
||||
}
|
||||
foreach ($errors as $error) {
|
||||
cli_problem($error);
|
||||
}
|
||||
$problems[] = $courseid;
|
||||
} else {
|
||||
echo "Course [$courseid] is OK\n";
|
||||
}
|
||||
}
|
||||
if (!count($problems)) {
|
||||
echo "\n...All courses are OK\n";
|
||||
} else {
|
||||
if (!empty($options['fix'])) {
|
||||
echo "\n...Found and fixed ".count($problems)." courses with problems". "\n";
|
||||
} else {
|
||||
echo "\n...Found ".count($problems)." courses with problems. To fix run:\n";
|
||||
echo "\$sudo -u www-data /usr/bin/php admin/cli/fix_course_sequence.php --courses=".join(',', $problems)." --fix". "\n";
|
||||
}
|
||||
}
|
||||
@@ -1,91 +0,0 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* This script fixed incorrectly deleted users.
|
||||
*
|
||||
* @package core
|
||||
* @subpackage cli
|
||||
* @copyright 2013 Petr Skoda (http://skodak.org)
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
define('CLI_SCRIPT', true);
|
||||
|
||||
require(__DIR__.'/../../config.php');
|
||||
require_once($CFG->libdir.'/clilib.php');
|
||||
|
||||
|
||||
// Now get cli options.
|
||||
list($options, $unrecognized) = cli_get_params(array('help'=>false),
|
||||
array('h'=>'help'));
|
||||
|
||||
if ($unrecognized) {
|
||||
$unrecognized = implode("\n ", $unrecognized);
|
||||
cli_error(get_string('cliunknowoption', 'admin', $unrecognized));
|
||||
}
|
||||
|
||||
if ($options['help']) {
|
||||
$help =
|
||||
"Fix incorrectly deleted users.
|
||||
|
||||
This scripts detects users that are marked as deleted instead
|
||||
of calling delete_user().
|
||||
|
||||
Deleted users do not have original username, idnumber or email,
|
||||
we must also delete all roles, enrolments, group memberships, etc.
|
||||
|
||||
Please note this script does not delete any public information
|
||||
such as forum posts.
|
||||
|
||||
Options:
|
||||
-h, --help Print out this help
|
||||
|
||||
Example:
|
||||
\$sudo -u www-data /usr/bin/php admin/cli/fix_deleted_users.php
|
||||
";
|
||||
|
||||
echo $help;
|
||||
die;
|
||||
}
|
||||
|
||||
cli_heading('Looking for sloppy user deletes');
|
||||
|
||||
// Look for sloppy deleted users where somebody only flipped the deleted flag.
|
||||
$sql = "SELECT *
|
||||
FROM {user}
|
||||
WHERE deleted = 1 AND email LIKE '%@%' AND username NOT LIKE '%@%'";
|
||||
$rs = $DB->get_recordset_sql($sql);
|
||||
foreach ($rs as $user) {
|
||||
echo "Redeleting user $user->id: $user->username ($user->email)\n";
|
||||
delete_user($user);
|
||||
}
|
||||
|
||||
cli_heading('Deleting all leftovers');
|
||||
|
||||
$DB->set_field('user', 'idnumber', '', array('deleted'=>1));
|
||||
|
||||
$DB->delete_records_select('role_assignments', "userid IN (SELECT id FROM {user} WHERE deleted = 1)");
|
||||
$DB->delete_records_select('cohort_members', "userid IN (SELECT id FROM {user} WHERE deleted = 1)");
|
||||
$DB->delete_records_select('groups_members', "userid IN (SELECT id FROM {user} WHERE deleted = 1)");
|
||||
$DB->delete_records_select('user_enrolments', "userid IN (SELECT id FROM {user} WHERE deleted = 1)");
|
||||
$DB->delete_records_select('user_preferences', "userid IN (SELECT id FROM {user} WHERE deleted = 1)");
|
||||
$DB->delete_records_select('user_info_data', "userid IN (SELECT id FROM {user} WHERE deleted = 1)");
|
||||
$DB->delete_records_select('user_lastaccess', "userid IN (SELECT id FROM {user} WHERE deleted = 1)");
|
||||
$DB->delete_records_select('external_tokens', "userid IN (SELECT id FROM {user} WHERE deleted = 1)");
|
||||
$DB->delete_records_select('external_services_users', "userid IN (SELECT id FROM {user} WHERE deleted = 1)");
|
||||
|
||||
exit(0);
|
||||
@@ -1,103 +0,0 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* This script fixes orphaned question categories.
|
||||
*
|
||||
* Orphaned question categories have had their associated context deleted
|
||||
* but the category itself remains in the database with an invalid context.
|
||||
*
|
||||
* @package core
|
||||
* @subpackage cli
|
||||
* @copyright 2013 Tyler Bannister (tyler.bannister@remote-learner.net)
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
define('CLI_SCRIPT', true);
|
||||
|
||||
require(__DIR__.'/../../config.php');
|
||||
require_once($CFG->libdir.'/clilib.php');
|
||||
require_once($CFG->libdir.'/questionlib.php');
|
||||
|
||||
$long = array('fix' => false, 'help' => false);
|
||||
$short = array('f' => 'fix', 'h' => 'help');
|
||||
|
||||
// Now get cli options.
|
||||
list($options, $unrecognized) = cli_get_params($long, $short);
|
||||
|
||||
if ($unrecognized) {
|
||||
$unrecognized = implode("\n ", $unrecognized);
|
||||
cli_error(get_string('cliunknowoption', 'admin', $unrecognized));
|
||||
}
|
||||
|
||||
if ($options['help']) {
|
||||
$help =
|
||||
"Fix orphaned question categories.
|
||||
|
||||
This scripts detects question categories that have had their
|
||||
context deleted, thus severing them from their original purpose.
|
||||
|
||||
This script will find the orphaned categories and delete the unused
|
||||
questions in each category found. Used questions will not be
|
||||
deleted, instead they will be moved to a rescue question category.
|
||||
|
||||
Options:
|
||||
-h, --help Print out this help
|
||||
-f, --fix Fix the orphaned question categories in the DB.
|
||||
If not specified only check and report problems to STDERR.
|
||||
Example:
|
||||
\$sudo -u www-data /usr/bin/php admin/cli/fix_orphaned_question_categories.php
|
||||
\$sudo -u www-data /usr/bin/php admin/cli/fix_orphaned_question_categories.php -f
|
||||
";
|
||||
|
||||
echo $help;
|
||||
die;
|
||||
}
|
||||
|
||||
cli_heading('Checking for orphaned categories');
|
||||
|
||||
|
||||
$sql = 'SELECT qc.id, qc.contextid, qc.name
|
||||
FROM {question_categories} qc
|
||||
LEFT JOIN {context} c ON qc.contextid = c.id
|
||||
WHERE c.id IS NULL';
|
||||
$categories = $DB->get_recordset_sql($sql);
|
||||
|
||||
$i = 0;
|
||||
foreach ($categories as $category) {
|
||||
$i += 1;
|
||||
echo "Found orphaned category: {$category->name}\n";
|
||||
if (!empty($options['fix'])) {
|
||||
echo "Cleaning...";
|
||||
// One transaction per category.
|
||||
$transaction = $DB->start_delegated_transaction();
|
||||
question_category_delete_safe($category);
|
||||
$transaction->allow_commit();
|
||||
echo " Done!\n";
|
||||
}
|
||||
}
|
||||
|
||||
if (($i > 0) && !empty($options['fix'])) {
|
||||
echo "Found and removed {$i} orphaned question categories\n";
|
||||
} else if ($i > 0) {
|
||||
echo "Found {$i} orphaned question categories. To fix, run:\n";
|
||||
echo "\$sudo -u www-data /usr/bin/php admin/cli/fix_orphaned_question_categories.php --fix\n";
|
||||
} else {
|
||||
echo "No orphaned question categories found.\n";
|
||||
}
|
||||
|
||||
|
||||
$categories->close();
|
||||
+27
-113
@@ -36,12 +36,6 @@ if (isset($_SERVER['REMOTE_ADDR'])) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
// Force OPcache reset if used, we do not want any stale caches
|
||||
// when preparing test environment.
|
||||
if (function_exists('opcache_reset')) {
|
||||
opcache_reset();
|
||||
}
|
||||
|
||||
$help =
|
||||
"Command line Moodle installer, creates config.php and initializes database.
|
||||
Please note you must execute this script with the same uid as apache
|
||||
@@ -64,16 +58,13 @@ Options:
|
||||
--dbname=NAME Database name. Default is moodle
|
||||
--dbuser=USERNAME Database user. Default is root
|
||||
--dbpass=PASSWORD Database password. Default is blank
|
||||
--dbport=NUMBER Use database port.
|
||||
--dbsocket=PATH Use database socket, 1 means default. Available for some databases only.
|
||||
--dbsocket Use database sockets. Available for some databases only.
|
||||
--prefix=STRING Table prefix for above database tables. Default is mdl_
|
||||
--fullname=STRING The fullname of the site
|
||||
--shortname=STRING The shortname of the site
|
||||
--summary=STRING The summary to be displayed on the front page
|
||||
--adminuser=USERNAME Username for the moodle admin account. Default is admin
|
||||
--adminpass=PASSWORD Password for the moodle admin account,
|
||||
required in non-interactive mode.
|
||||
--adminemail=STRING Email address for the moodle admin account.
|
||||
--non-interactive No interactive questions, installation fails if any
|
||||
problem encountered.
|
||||
--agree-license Indicates agreement with software license,
|
||||
@@ -122,11 +113,10 @@ $olddir = getcwd();
|
||||
chdir(dirname($_SERVER['argv'][0]));
|
||||
|
||||
// Servers should define a default timezone in php.ini, but if they don't then make sure something is defined.
|
||||
if (!function_exists('date_default_timezone_set') or !function_exists('date_default_timezone_get')) {
|
||||
fwrite(STDERR, "Timezone functions are not available.\n");
|
||||
exit(1);
|
||||
// This is a quick hack. Ideally we should ask the admin for a value. See MDL-22625 for more on this.
|
||||
if (function_exists('date_default_timezone_set') and function_exists('date_default_timezone_get')) {
|
||||
@date_default_timezone_set(@date_default_timezone_get());
|
||||
}
|
||||
date_default_timezone_set(@date_default_timezone_get());
|
||||
|
||||
// make sure PHP errors are displayed - helps with diagnosing of problems
|
||||
@error_reporting(E_ALL);
|
||||
@@ -137,24 +127,16 @@ date_default_timezone_set(@date_default_timezone_get());
|
||||
/** Used by library scripts to check they are being called by Moodle */
|
||||
define('MOODLE_INTERNAL', true);
|
||||
|
||||
// Disables all caching.
|
||||
define('CACHE_DISABLE_ALL', true);
|
||||
|
||||
define('PHPUNIT_TEST', false);
|
||||
|
||||
define('IGNORE_COMPONENT_CACHE', true);
|
||||
|
||||
// Check that PHP is of a sufficient version
|
||||
if (version_compare(phpversion(), "5.4.4") < 0) {
|
||||
if (version_compare(phpversion(), "5.3.2") < 0) {
|
||||
$phpversion = phpversion();
|
||||
// do NOT localise - lang strings would not work here and we CAN NOT move it after installib
|
||||
fwrite(STDERR, "Moodle 2.7 or later requires at least PHP 5.4.4 (currently using version $phpversion).\n");
|
||||
fwrite(STDERR, "Moodle 2.1 or later requires at least PHP 5.3.2 (currently using version $phpversion).\n");
|
||||
fwrite(STDERR, "Please upgrade your server software or install older Moodle version.\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
// set up configuration
|
||||
global $CFG;
|
||||
$CFG = new stdClass();
|
||||
$CFG->lang = 'en';
|
||||
$CFG->dirroot = dirname(dirname(dirname(__FILE__)));
|
||||
@@ -164,11 +146,6 @@ $CFG->httpswwwroot = $CFG->wwwroot;
|
||||
$CFG->docroot = 'http://docs.moodle.org';
|
||||
$CFG->running_installer = true;
|
||||
$CFG->early_install_lang = true;
|
||||
$CFG->ostype = (stristr(PHP_OS, 'win') && !stristr(PHP_OS, 'darwin')) ? 'WINDOWS' : 'UNIX';
|
||||
$CFG->dboptions = array();
|
||||
$CFG->debug = (E_ALL | E_STRICT);
|
||||
$CFG->debugdisplay = true;
|
||||
$CFG->debugdeveloper = true;
|
||||
|
||||
$parts = explode('/', str_replace('\\', '/', dirname(dirname(__FILE__))));
|
||||
$CFG->admin = array_pop($parts);
|
||||
@@ -177,48 +154,22 @@ $CFG->admin = array_pop($parts);
|
||||
//the problem is that we need specific version of quickforms and hacked excel files :-(
|
||||
ini_set('include_path', $CFG->libdir.'/pear' . PATH_SEPARATOR . ini_get('include_path'));
|
||||
|
||||
require_once($CFG->libdir.'/classes/component.php');
|
||||
require_once($CFG->libdir.'/classes/text.php');
|
||||
require_once($CFG->libdir.'/classes/string_manager.php');
|
||||
require_once($CFG->libdir.'/classes/string_manager_install.php');
|
||||
require_once($CFG->libdir.'/classes/string_manager_standard.php');
|
||||
require_once($CFG->libdir.'/installlib.php');
|
||||
require_once($CFG->libdir.'/clilib.php');
|
||||
require_once($CFG->libdir.'/setuplib.php');
|
||||
require_once($CFG->libdir.'/textlib.class.php');
|
||||
require_once($CFG->libdir.'/weblib.php');
|
||||
require_once($CFG->libdir.'/dmllib.php');
|
||||
require_once($CFG->libdir.'/moodlelib.php');
|
||||
require_once($CFG->libdir.'/deprecatedlib.php');
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
require_once($CFG->libdir.'/componentlib.class.php');
|
||||
require_once($CFG->dirroot.'/cache/lib.php');
|
||||
|
||||
// Register our classloader, in theory somebody might want to replace it to load other hacked core classes.
|
||||
// Required because the database checks below lead to session interaction which is going to lead us to requiring autoloaded classes.
|
||||
if (defined('COMPONENT_CLASSLOADER')) {
|
||||
spl_autoload_register(COMPONENT_CLASSLOADER);
|
||||
} else {
|
||||
spl_autoload_register('core_component::classloader');
|
||||
}
|
||||
|
||||
require($CFG->dirroot.'/version.php');
|
||||
$CFG->target_release = $release;
|
||||
|
||||
\core\session\manager::init_empty_session();
|
||||
global $SESSION;
|
||||
global $USER;
|
||||
|
||||
global $COURSE;
|
||||
$COURSE = new stdClass();
|
||||
$COURSE->id = 1;
|
||||
|
||||
global $SITE;
|
||||
$SITE = $COURSE;
|
||||
define('SITEID', 1);
|
||||
|
||||
//Database types
|
||||
$databases = array('mysqli' => moodle_database::get_driver_instance('mysqli', 'native'),
|
||||
'mariadb'=> moodle_database::get_driver_instance('mariadb', 'native'),
|
||||
'pgsql' => moodle_database::get_driver_instance('pgsql', 'native'),
|
||||
'oci' => moodle_database::get_driver_instance('oci', 'native'),
|
||||
'sqlsrv' => moodle_database::get_driver_instance('sqlsrv', 'native'), // MS SQL*Server PHP driver
|
||||
@@ -248,15 +199,12 @@ list($options, $unrecognized) = cli_get_params(
|
||||
'dbname' => 'moodle',
|
||||
'dbuser' => empty($distro->dbuser) ? 'root' : $distro->dbuser, // let distros set dbuser
|
||||
'dbpass' => '',
|
||||
'dbport' => '',
|
||||
'dbsocket' => '',
|
||||
'dbsocket' => false,
|
||||
'prefix' => 'mdl_',
|
||||
'fullname' => '',
|
||||
'shortname' => '',
|
||||
'summary' => '',
|
||||
'adminuser' => 'admin',
|
||||
'adminpass' => '',
|
||||
'adminemail' => '',
|
||||
'non-interactive' => false,
|
||||
'agree-license' => false,
|
||||
'allow-unstable' => false,
|
||||
@@ -292,8 +240,18 @@ echo get_string('cliinstallheader', 'install', $CFG->target_release)."\n";
|
||||
if ($interactive) {
|
||||
cli_separator();
|
||||
$languages = get_string_manager()->get_list_of_translations();
|
||||
// Do not put the langs into columns because it is not compatible with RTL.
|
||||
$langlist = implode("\n", $languages);
|
||||
// format the langs nicely - 3 per line
|
||||
$c = 0;
|
||||
$langlist = '';
|
||||
foreach ($languages as $key=>$lang) {
|
||||
$c++;
|
||||
$length = iconv_strlen($lang, 'UTF-8');
|
||||
$padded = $lang.str_repeat(' ', 38-$length);
|
||||
$langlist .= $padded;
|
||||
if ($c % 3 == 0) {
|
||||
$langlist .= "\n";
|
||||
}
|
||||
}
|
||||
$default = $CFG->lang;
|
||||
cli_heading(get_string('availablelangs', 'install'));
|
||||
echo $langlist."\n";
|
||||
@@ -341,8 +299,6 @@ if ($interactive) {
|
||||
}
|
||||
}
|
||||
$CFG->directorypermissions = $chmod;
|
||||
$CFG->filepermissions = ($CFG->directorypermissions & 0666);
|
||||
$CFG->umaskpermissions = (($CFG->directorypermissions & 0777) ^ 0777);
|
||||
|
||||
//We need wwwroot before we test dataroot
|
||||
$wwwroot = clean_param($options['wwwroot'], PARAM_URL);
|
||||
@@ -429,9 +385,8 @@ if ($interactive) {
|
||||
cli_error(get_string('pathserrcreatedataroot', 'install', $a));
|
||||
}
|
||||
}
|
||||
$CFG->tempdir = $CFG->dataroot.'/temp';
|
||||
$CFG->cachedir = $CFG->dataroot.'/cache';
|
||||
$CFG->localcachedir = $CFG->dataroot.'/localcache';
|
||||
$CFG->tempdir = $CFG->dataroot.'/temp';
|
||||
$CFG->cachedir = $CFG->dataroot.'/cache';
|
||||
|
||||
// download required lang packs
|
||||
if ($CFG->lang !== 'en') {
|
||||
@@ -547,34 +502,6 @@ if ($interactive) {
|
||||
$CFG->prefix = $options['prefix'];
|
||||
}
|
||||
|
||||
// ask for db port
|
||||
if ($interactive) {
|
||||
cli_separator();
|
||||
cli_heading(get_string('databaseport', 'install'));
|
||||
$prompt = get_string('clitypevaluedefault', 'admin', $options['dbport']);
|
||||
$CFG->dboptions['dbport'] = (int)cli_input($prompt, $options['dbport']);
|
||||
|
||||
} else {
|
||||
$CFG->dboptions['dbport'] = (int)$options['dbport'];
|
||||
}
|
||||
if ($CFG->dboptions['dbport'] <= 0) {
|
||||
$CFG->dboptions['dbport'] = '';
|
||||
}
|
||||
|
||||
// ask for db socket
|
||||
if ($CFG->ostype === 'WINDOWS') {
|
||||
$CFG->dboptions['dbsocket'] = '';
|
||||
|
||||
} else if ($interactive and empty($CFG->dboptions['dbport'])) {
|
||||
cli_separator();
|
||||
cli_heading(get_string('databasesocket', 'install'));
|
||||
$prompt = get_string('clitypevaluedefault', 'admin', $options['dbsocket']);
|
||||
$CFG->dboptions['dbsocket'] = cli_input($prompt, $options['dbsocket']);
|
||||
|
||||
} else {
|
||||
$CFG->dboptions['dbsocket'] = $options['dbsocket'];
|
||||
}
|
||||
|
||||
// ask for db user
|
||||
if ($interactive) {
|
||||
cli_separator();
|
||||
@@ -603,14 +530,14 @@ if ($interactive) {
|
||||
|
||||
$CFG->dbpass = cli_input($prompt, $options['dbpass']);
|
||||
if (function_exists('distro_pre_create_db')) { // Hook for distros needing to do something before DB creation
|
||||
$distro = distro_pre_create_db($database, $CFG->dbhost, $CFG->dbuser, $CFG->dbpass, $CFG->dbname, $CFG->prefix, array('dbpersist'=>0, 'dbport'=>$CFG->dboptions['dbport'], 'dbsocket'=>$CFG->dboptions['dbsocket']), $distro);
|
||||
$distro = distro_pre_create_db($database, $CFG->dbhost, $CFG->dbuser, $CFG->dbpass, $CFG->dbname, $CFG->prefix, array('dbpersist'=>0, 'dbsocket'=>$options['dbsocket']), $distro);
|
||||
}
|
||||
$hint_database = install_db_validate($database, $CFG->dbhost, $CFG->dbuser, $CFG->dbpass, $CFG->dbname, $CFG->prefix, array('dbpersist'=>0, 'dbport'=>$CFG->dboptions['dbport'], 'dbsocket'=>$CFG->dboptions['dbsocket']));
|
||||
$hint_database = install_db_validate($database, $CFG->dbhost, $CFG->dbuser, $CFG->dbpass, $CFG->dbname, $CFG->prefix, array('dbpersist'=>0, 'dbsocket'=>$options['dbsocket']));
|
||||
} while ($hint_database !== '');
|
||||
|
||||
} else {
|
||||
$CFG->dbpass = $options['dbpass'];
|
||||
$hint_database = install_db_validate($database, $CFG->dbhost, $CFG->dbuser, $CFG->dbpass, $CFG->dbname, $CFG->prefix, array('dbpersist'=>0, 'dbport'=>$CFG->dboptions['dbport'], 'dbsocket'=>$CFG->dboptions['dbsocket']));
|
||||
$hint_database = install_db_validate($database, $CFG->dbhost, $CFG->dbuser, $CFG->dbpass, $CFG->dbname, $CFG->prefix, array('dbpersist'=>0, 'dbsocket'=>$options['dbsocket']));
|
||||
if ($hint_database !== '') {
|
||||
cli_error(get_string('dbconnectionerror', 'install'));
|
||||
}
|
||||
@@ -692,20 +619,6 @@ if ($interactive) {
|
||||
}
|
||||
}
|
||||
|
||||
// Ask for the admin email address.
|
||||
if ($interactive) {
|
||||
cli_separator();
|
||||
cli_heading(get_string('cliadminemail', 'install'));
|
||||
$prompt = get_string('clitypevaluedefault', 'admin', $options['adminemail']);
|
||||
$options['adminemail'] = cli_input($prompt);
|
||||
}
|
||||
|
||||
// Validate that the address provided was an e-mail address.
|
||||
if (!empty($options['adminemail']) && !validate_email($options['adminemail'])) {
|
||||
$a = (object) array('option' => 'adminemail', 'value' => $options['adminemail']);
|
||||
cli_error(get_string('cliincorrectvalueerror', 'admin', $a));
|
||||
}
|
||||
|
||||
if ($interactive) {
|
||||
if (!$options['agree-license']) {
|
||||
cli_separator();
|
||||
@@ -764,8 +677,9 @@ if (!$envstatus) {
|
||||
}
|
||||
|
||||
// Test plugin dependencies.
|
||||
require_once($CFG->libdir . '/pluginlib.php');
|
||||
$failed = array();
|
||||
if (!core_plugin_manager::instance()->all_plugins_ok($version, $failed)) {
|
||||
if (!plugin_manager::instance()->all_plugins_ok($version, $failed)) {
|
||||
cli_problem(get_string('pluginscheckfailed', 'admin', array('pluginslist' => implode(', ', array_unique($failed)))));
|
||||
cli_error(get_string('pluginschecktodo', 'admin'));
|
||||
}
|
||||
|
||||
@@ -29,19 +29,12 @@
|
||||
*/
|
||||
|
||||
define('CLI_SCRIPT', true);
|
||||
define('CACHE_DISABLE_ALL', true);
|
||||
|
||||
// extra execution prevention - we can not just require config.php here
|
||||
if (isset($_SERVER['REMOTE_ADDR'])) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
// Force OPcache reset if used, we do not want any stale caches
|
||||
// when preparing test environment.
|
||||
if (function_exists('opcache_reset')) {
|
||||
opcache_reset();
|
||||
}
|
||||
|
||||
$help =
|
||||
"Advanced command line Moodle database installer.
|
||||
Please note you must execute this script with the same uid as apache.
|
||||
@@ -52,7 +45,6 @@ Options:
|
||||
--lang=CODE Installation and default site language. Default is en.
|
||||
--adminuser=USERNAME Username for the moodle admin account. Default is admin.
|
||||
--adminpass=PASSWORD Password for the moodle admin account.
|
||||
--adminemail=STRING Email address for the moodle admin account.
|
||||
--agree-license Indicates agreement with software license.
|
||||
--fullname=STRING Name of the site
|
||||
--shortname=STRING Name of the site
|
||||
@@ -63,10 +55,10 @@ Example:
|
||||
";
|
||||
|
||||
// Check that PHP is of a sufficient version
|
||||
if (version_compare(phpversion(), "5.4.4") < 0) {
|
||||
if (version_compare(phpversion(), "5.3.2") < 0) {
|
||||
$phpversion = phpversion();
|
||||
// do NOT localise - lang strings would not work here and we CAN NOT move it after installib
|
||||
fwrite(STDERR, "Moodle 2.7 or later requires at least PHP 5.4.4 (currently using version $phpversion).\n");
|
||||
fwrite(STDERR, "Moodle 2.1 or later requires at least PHP 5.3.2 (currently using version $phpversion).\n");
|
||||
fwrite(STDERR, "Please upgrade your server software or install older Moodle version.\n");
|
||||
exit(1);
|
||||
}
|
||||
@@ -103,7 +95,6 @@ list($options, $unrecognized) = cli_get_params(
|
||||
'lang' => 'en',
|
||||
'adminuser' => 'admin',
|
||||
'adminpass' => '',
|
||||
'adminemail' => '',
|
||||
'fullname' => '',
|
||||
'shortname' => '',
|
||||
'agree-license' => false,
|
||||
@@ -128,12 +119,6 @@ if ($options['adminpass'] === true or $options['adminpass'] === '') {
|
||||
cli_error('You have to specify admin password. --help prints out the help'); // TODO: localize
|
||||
}
|
||||
|
||||
// Validate that the address provided was an e-mail address.
|
||||
if (!empty($options['adminemail']) && !validate_email($options['adminemail'])) {
|
||||
$a = (object) array('option' => 'adminemail', 'value' => $options['adminemail']);
|
||||
cli_error(get_string('cliincorrectvalueerror', 'admin', $a));
|
||||
}
|
||||
|
||||
$options['lang'] = clean_param($options['lang'], PARAM_SAFEDIR);
|
||||
if (!file_exists($CFG->dirroot.'/install/lang/'.$options['lang'])) {
|
||||
$options['lang'] = 'en';
|
||||
@@ -175,8 +160,9 @@ if (!$envstatus) {
|
||||
}
|
||||
|
||||
// Test plugin dependencies.
|
||||
require_once($CFG->libdir . '/pluginlib.php');
|
||||
$failed = array();
|
||||
if (!core_plugin_manager::instance()->all_plugins_ok($version, $failed)) {
|
||||
if (!plugin_manager::instance()->all_plugins_ok($version, $failed)) {
|
||||
cli_problem(get_string('pluginscheckfailed', 'admin', array('pluginslist' => implode(', ', array_unique($failed)))));
|
||||
cli_error(get_string('pluginschecktodo', 'admin'));
|
||||
}
|
||||
|
||||
+10
-46
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
@@ -15,7 +16,7 @@
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Enable or disable maintenance mode.
|
||||
* Enable or disable maintenance mode
|
||||
*
|
||||
* @package core
|
||||
* @subpackage cli
|
||||
@@ -25,13 +26,12 @@
|
||||
|
||||
define('CLI_SCRIPT', true);
|
||||
|
||||
require(__DIR__.'/../../config.php');
|
||||
require_once("$CFG->libdir/clilib.php");
|
||||
require_once("$CFG->libdir/adminlib.php");
|
||||
require(dirname(dirname(dirname(__FILE__))).'/config.php');
|
||||
require_once($CFG->libdir.'/clilib.php'); // cli only functions
|
||||
|
||||
|
||||
// Now get cli options.
|
||||
list($options, $unrecognized) = cli_get_params(array('enable'=>false, 'enablelater'=>0, 'enableold'=>false, 'disable'=>false, 'help'=>false),
|
||||
// now get cli options
|
||||
list($options, $unrecognized) = cli_get_params(array('enable'=>false, 'disable'=>false, 'help'=>false),
|
||||
array('h'=>'help'));
|
||||
|
||||
if ($unrecognized) {
|
||||
@@ -45,14 +45,12 @@ if ($options['help']) {
|
||||
Current status displayed if not option specified.
|
||||
|
||||
Options:
|
||||
--enable Enable CLI maintenance mode
|
||||
--enablelater=MINUTES Number of minutes before entering CLI maintenance mode
|
||||
--enableold Enable legacy half-maintenance mode
|
||||
--enable Enable maintenance mode
|
||||
--disable Disable maintenance mode
|
||||
-h, --help Print out this help
|
||||
|
||||
Example:
|
||||
\$ sudo -u www-data /usr/bin/php admin/cli/maintenance.php
|
||||
\$sudo -u www-data /usr/bin/php admin/cli/maintenance.php
|
||||
"; //TODO: localize - to be translated later when everything is finished
|
||||
|
||||
echo $help;
|
||||
@@ -61,52 +59,18 @@ Example:
|
||||
|
||||
cli_heading(get_string('sitemaintenancemode', 'admin')." ($CFG->wwwroot)");
|
||||
|
||||
if ($options['enablelater']) {
|
||||
if (file_exists("$CFG->dataroot/climaintenance.html")) {
|
||||
// Already enabled, sorry.
|
||||
echo get_string('clistatusenabled', 'admin')."\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
$time = time() + ($options['enablelater']*60);
|
||||
set_config('maintenance_later', $time);
|
||||
|
||||
echo get_string('clistatusenabledlater', 'admin', userdate($time))."\n";
|
||||
return 0;
|
||||
|
||||
} else if ($options['enable']) {
|
||||
if (file_exists("$CFG->dataroot/climaintenance.html")) {
|
||||
// The maintenance is already enabled, nothing to do.
|
||||
} else {
|
||||
enable_cli_maintenance_mode();
|
||||
}
|
||||
set_config('maintenance_enabled', 0);
|
||||
unset_config('maintenance_later');
|
||||
echo get_string('sitemaintenanceoncli', 'admin')."\n";
|
||||
exit(0);
|
||||
|
||||
} else if ($options['enableold']) {
|
||||
if ($options['enable']) {
|
||||
set_config('maintenance_enabled', 1);
|
||||
unset_config('maintenance_later');
|
||||
echo get_string('sitemaintenanceon', 'admin')."\n";
|
||||
exit(0);
|
||||
|
||||
} else if ($options['disable']) {
|
||||
set_config('maintenance_enabled', 0);
|
||||
unset_config('maintenance_later');
|
||||
if (file_exists("$CFG->dataroot/climaintenance.html")) {
|
||||
unlink("$CFG->dataroot/climaintenance.html");
|
||||
}
|
||||
echo get_string('sitemaintenanceoff', 'admin')."\n";
|
||||
exit(0);
|
||||
}
|
||||
|
||||
if (!empty($CFG->maintenance_enabled) or file_exists("$CFG->dataroot/climaintenance.html")) {
|
||||
if (!empty($CFG->maintenance_enabled)) {
|
||||
echo get_string('clistatusenabled', 'admin')."\n";
|
||||
|
||||
} else if (isset($CFG->maintenance_later)) {
|
||||
echo get_string('clistatusenabledlater', 'admin', userdate($CFG->maintenance_later))."\n";
|
||||
|
||||
} else {
|
||||
echo get_string('clistatusdisabled', 'admin')."\n";
|
||||
}
|
||||
|
||||
@@ -1,202 +0,0 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* MySQL table row compression tool tool.
|
||||
*
|
||||
* @package core
|
||||
* @copyright 2014 Totara Learning Solutions Ltd {@link http://www.totaralms.com/}
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
* @author Petr Skoda <petr.skoda@totaralms.com>
|
||||
*/
|
||||
|
||||
define('CLI_SCRIPT', true);
|
||||
|
||||
require(dirname(__FILE__).'/../../config.php');
|
||||
require_once($CFG->libdir . '/clilib.php');
|
||||
|
||||
if ($DB->get_dbfamily() !== 'mysql') {
|
||||
cli_error('This script is used for MySQL databases only.');
|
||||
}
|
||||
|
||||
$engine = strtolower($DB->get_dbengine());
|
||||
if ($engine !== 'innodb' and $engine !== 'xtradb') {
|
||||
cli_error('This script is for MySQL servers using InnoDB or XtraDB engines only.');
|
||||
}
|
||||
|
||||
list($options, $unrecognized) = cli_get_params(
|
||||
array('help' => false, 'info' => false, 'list' => false, 'fix' => false, 'showsql' => false),
|
||||
array('h' => 'help', 'i' => 'info', 'l' => 'list', 'f' => 'fix', 's' => 'showsql')
|
||||
);
|
||||
|
||||
if ($unrecognized) {
|
||||
$unrecognized = implode("\n ", $unrecognized);
|
||||
cli_error(get_string('cliunknowoption', 'admin', $unrecognized));
|
||||
}
|
||||
|
||||
$help =
|
||||
"Script for detection of row size problems in MySQL InnoDB tables.
|
||||
|
||||
By default InnoDB storage table is using legacy Antelope file format
|
||||
which has major restriction on database row size.
|
||||
Use this script to detect and fix database tables with potential data
|
||||
overflow problems.
|
||||
|
||||
Options:
|
||||
-i, --info Show database information
|
||||
-l, --list List problematic tables
|
||||
-f, --fix Attempt to fix all tables (requires SUPER privilege)
|
||||
-s, --showsql Print SQL statements for fixing of tables
|
||||
-h, --help Print out this help
|
||||
|
||||
Example:
|
||||
\$ sudo -u www-data /usr/bin/php admin/cli/mysql_compressed_rows.php -l
|
||||
";
|
||||
|
||||
/** @var mysql_sql_generator $generator */
|
||||
$generator = $DB->get_manager()->generator;
|
||||
|
||||
$info = $DB->get_server_info();
|
||||
$filepertable = $DB->get_record_sql("SHOW VARIABLES LIKE 'innodb_file_per_table'");
|
||||
$filepertable = $filepertable ? $filepertable->value : '';
|
||||
$fileformat = $DB->get_record_sql("SHOW VARIABLES LIKE 'innodb_file_format'");
|
||||
$fileformat = $fileformat ? $fileformat->value : '';
|
||||
$prefix = $DB->get_prefix();
|
||||
$database = $CFG->dbname;
|
||||
|
||||
if (!empty($options['info'])) {
|
||||
echo "Database version: " . $info['description'] . "\n";
|
||||
echo "Database name: $database\n";
|
||||
echo "Database engine: " . $DB->get_dbengine() . "\n";
|
||||
echo "innodb_file_per_table: $filepertable\n";
|
||||
echo "innodb_file_format: $fileformat\n";
|
||||
|
||||
exit(0);
|
||||
|
||||
} else if (!empty($options['list'])) {
|
||||
$problem = false;
|
||||
foreach ($DB->get_tables(false) as $table) {
|
||||
$columns = $DB->get_columns($table, false);
|
||||
$size = $generator->guess_antelope_row_size($columns);
|
||||
$format = $DB->get_row_format($table);
|
||||
if ($size <= $generator::ANTELOPE_MAX_ROW_SIZE) {
|
||||
continue;
|
||||
}
|
||||
|
||||
echo str_pad($prefix . $table, 32, ' ', STR_PAD_RIGHT);
|
||||
echo str_pad($format, 11, ' ', STR_PAD_RIGHT);
|
||||
|
||||
if ($format === 'Compact' or $format === 'Redundant') {
|
||||
$problem = true;
|
||||
echo " (needs fixing)\n";
|
||||
|
||||
} else if ($format !== 'Compressed' and $format !== 'Dynamic') {
|
||||
echo " (unknown)\n";
|
||||
|
||||
} else {
|
||||
echo "\n";
|
||||
}
|
||||
}
|
||||
|
||||
if ($problem) {
|
||||
exit(1);
|
||||
}
|
||||
exit(0);
|
||||
|
||||
} else if (!empty($options['fix'])) {
|
||||
$fixtables = array();
|
||||
foreach ($DB->get_tables(false) as $table) {
|
||||
$columns = $DB->get_columns($table, false);
|
||||
$size = $generator->guess_antelope_row_size($columns);
|
||||
$format = $DB->get_row_format($table);
|
||||
if ($size <= $generator::ANTELOPE_MAX_ROW_SIZE) {
|
||||
continue;
|
||||
}
|
||||
if ($format === 'Compact' or $format === 'Redundant') {
|
||||
$fixtables[$table] = $table;
|
||||
}
|
||||
}
|
||||
|
||||
if (!$fixtables) {
|
||||
echo "No changes necessary\n";
|
||||
exit(0);
|
||||
}
|
||||
|
||||
if ($filepertable !== 'ON') {
|
||||
try {
|
||||
$DB->execute("SET GLOBAL innodb_file_per_table=1");
|
||||
} catch (dml_exception $e) {
|
||||
echo "Cannot enable GLOBAL innodb_file_per_table setting, use --showsql option and execute the statements manually.";
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
if ($fileformat !== 'Barracuda') {
|
||||
try {
|
||||
$DB->execute("SET GLOBAL innodb_file_format=Barracuda");
|
||||
} catch (dml_exception $e) {
|
||||
echo "Cannot change GLOBAL innodb_file_format setting, use --showsql option and execute the statements manually.";
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
if (!$DB->is_compressed_row_format_supported(false)) {
|
||||
echo "MySQL server is not compatible with compressed row format.";
|
||||
exit(1);
|
||||
}
|
||||
|
||||
foreach ($fixtables as $table) {
|
||||
$DB->change_database_structure("ALTER TABLE {$prefix}$table ROW_FORMAT=Compressed");
|
||||
echo str_pad($prefix . $table, 32, ' ', STR_PAD_RIGHT) . " ... Compressed\n";
|
||||
}
|
||||
|
||||
exit(0);
|
||||
|
||||
} else if (!empty($options['showsql'])) {
|
||||
$fixtables = array();
|
||||
|
||||
foreach ($DB->get_tables(false) as $table) {
|
||||
$columns = $DB->get_columns($table, false);
|
||||
$size = $generator->guess_antelope_row_size($columns);
|
||||
$format = $DB->get_row_format($table);
|
||||
if ($size <= $generator::ANTELOPE_MAX_ROW_SIZE) {
|
||||
continue;
|
||||
}
|
||||
if ($format === 'Compact' or $format === 'Redundant') {
|
||||
$fixtables[$table] = $table;
|
||||
}
|
||||
}
|
||||
if (!$fixtables) {
|
||||
echo "No changes necessary\n";
|
||||
exit(0);
|
||||
}
|
||||
|
||||
echo "Copy the following SQL statements and execute them using account with SUPER privilege:\n\n";
|
||||
echo "USE $database;\n";
|
||||
echo "SET SESSION sql_mode=STRICT_ALL_TABLES;\n";
|
||||
echo "SET GLOBAL innodb_file_per_table=1;\n";
|
||||
echo "SET GLOBAL innodb_file_format=Barracuda;\n";
|
||||
foreach ($fixtables as $table) {
|
||||
echo "ALTER TABLE {$prefix}$table ROW_FORMAT=Compressed;\n";
|
||||
}
|
||||
echo "\n";
|
||||
exit(0);
|
||||
|
||||
} else {
|
||||
echo $help;
|
||||
die;
|
||||
}
|
||||
|
||||
|
||||
+5
-15
@@ -29,20 +29,14 @@
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
// Force OPcache reset if used, we do not want any stale caches
|
||||
// when detecting if upgrade necessary or when running upgrade.
|
||||
if (function_exists('opcache_reset') and !isset($_SERVER['REMOTE_ADDR'])) {
|
||||
opcache_reset();
|
||||
}
|
||||
|
||||
define('CLI_SCRIPT', true);
|
||||
define('CACHE_DISABLE_ALL', true);
|
||||
|
||||
require(dirname(dirname(dirname(__FILE__))).'/config.php');
|
||||
require_once($CFG->libdir.'/adminlib.php'); // various admin-only functions
|
||||
require_once($CFG->libdir.'/upgradelib.php'); // general upgrade/install related functions
|
||||
require_once($CFG->libdir.'/clilib.php'); // cli only functions
|
||||
require_once($CFG->libdir.'/environmentlib.php');
|
||||
require_once($CFG->libdir.'/pluginlib.php');
|
||||
|
||||
// now get cli options
|
||||
list($options, $unrecognized) = cli_get_params(
|
||||
@@ -116,7 +110,7 @@ if (!$envstatus) {
|
||||
|
||||
// Test plugin dependencies.
|
||||
$failed = array();
|
||||
if (!core_plugin_manager::instance()->all_plugins_ok($version, $failed)) {
|
||||
if (!plugin_manager::instance()->all_plugins_ok($version, $failed)) {
|
||||
cli_problem(get_string('pluginscheckfailed', 'admin', array('pluginslist' => implode(', ', array_unique($failed)))));
|
||||
cli_error(get_string('pluginschecktodo', 'admin'));
|
||||
}
|
||||
@@ -156,12 +150,6 @@ if ($interactive) {
|
||||
}
|
||||
|
||||
if ($version > $CFG->version) {
|
||||
// We purge all of MUC's caches here.
|
||||
// Caches are disabled for upgrade by CACHE_DISABLE_ALL so we must set the first arg to true.
|
||||
// This ensures a real config object is loaded and the stores will be purged.
|
||||
// This is the only way we can purge custom caches such as memcache or APC.
|
||||
// Note: all other calls to caches will still used the disabled API.
|
||||
cache_helper::purge_all(true);
|
||||
upgrade_core($version, true);
|
||||
}
|
||||
set_config('release', $release);
|
||||
@@ -171,7 +159,9 @@ set_config('branch', $branch);
|
||||
upgrade_noncore(true);
|
||||
|
||||
// log in as admin - we need doanything permission when applying defaults
|
||||
\core\session\manager::set_user(get_admin());
|
||||
$admins = get_admins();
|
||||
$admin = reset($admins);
|
||||
session_set_user($admin);
|
||||
|
||||
// apply all default settings, just in case do it twice to fill all defaults
|
||||
admin_apply_default_settings(NULL, false);
|
||||
|
||||
@@ -1,83 +0,0 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Allows the admin to enable, disable and uninstall course formats
|
||||
*
|
||||
* @package core_admin
|
||||
* @copyright 2012 Marina Glancy
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
require_once('../config.php');
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
|
||||
$action = required_param('action', PARAM_ALPHANUMEXT);
|
||||
$formatname = required_param('format', PARAM_PLUGIN);
|
||||
|
||||
$syscontext = context_system::instance();
|
||||
$PAGE->set_url('/admin/courseformats.php');
|
||||
$PAGE->set_context($syscontext);
|
||||
|
||||
require_login();
|
||||
require_capability('moodle/site:config', $syscontext);
|
||||
require_sesskey();
|
||||
|
||||
$return = new moodle_url('/admin/settings.php', array('section' => 'manageformats'));
|
||||
|
||||
$formatplugins = core_plugin_manager::instance()->get_plugins_of_type('format');
|
||||
$sortorder = array_flip(array_keys($formatplugins));
|
||||
|
||||
if (!isset($formatplugins[$formatname])) {
|
||||
print_error('courseformatnotfound', 'error', $return, $formatname);
|
||||
}
|
||||
|
||||
switch ($action) {
|
||||
case 'disable':
|
||||
if ($formatplugins[$formatname]->is_enabled()) {
|
||||
if (get_config('moodlecourse', 'format') === $formatname) {
|
||||
print_error('cannotdisableformat', 'error', $return);
|
||||
}
|
||||
set_config('disabled', 1, 'format_'. $formatname);
|
||||
core_plugin_manager::reset_caches();
|
||||
}
|
||||
break;
|
||||
case 'enable':
|
||||
if (!$formatplugins[$formatname]->is_enabled()) {
|
||||
unset_config('disabled', 'format_'. $formatname);
|
||||
core_plugin_manager::reset_caches();
|
||||
}
|
||||
break;
|
||||
case 'up':
|
||||
if ($sortorder[$formatname]) {
|
||||
$currentindex = $sortorder[$formatname];
|
||||
$seq = array_keys($formatplugins);
|
||||
$seq[$currentindex] = $seq[$currentindex-1];
|
||||
$seq[$currentindex-1] = $formatname;
|
||||
set_config('format_plugins_sortorder', implode(',', $seq));
|
||||
}
|
||||
break;
|
||||
case 'down':
|
||||
if ($sortorder[$formatname] < count($sortorder)-1) {
|
||||
$currentindex = $sortorder[$formatname];
|
||||
$seq = array_keys($formatplugins);
|
||||
$seq[$currentindex] = $seq[$currentindex+1];
|
||||
$seq[$currentindex+1] = $formatname;
|
||||
set_config('format_plugins_sortorder', implode(',', $seq));
|
||||
}
|
||||
break;
|
||||
}
|
||||
redirect($return);
|
||||
+16
-2
@@ -53,7 +53,7 @@ require_once($CFG->libdir.'/clilib.php');
|
||||
require_once($CFG->libdir.'/cronlib.php');
|
||||
|
||||
// extra safety
|
||||
\core\session\manager::write_close();
|
||||
session_get_instance()->write_close();
|
||||
|
||||
// check if execution allowed
|
||||
if (!empty($CFG->cronclionly)) {
|
||||
@@ -72,10 +72,24 @@ if (!empty($CFG->cronremotepassword)) {
|
||||
}
|
||||
|
||||
// send mime type and encoding
|
||||
@header('Content-Type: text/plain; charset=utf-8');
|
||||
if (check_browser_version('MSIE')) {
|
||||
//ugly IE hack to work around downloading instead of viewing
|
||||
@header('Content-Type: text/html; charset=utf-8');
|
||||
echo "<xmp>"; //<pre> is not good enough for us here
|
||||
} else {
|
||||
//send proper plaintext header
|
||||
@header('Content-Type: text/plain; charset=utf-8');
|
||||
}
|
||||
|
||||
// we do not want html markup in emulated CLI
|
||||
@ini_set('html_errors', 'off');
|
||||
|
||||
// execute the cron
|
||||
cron_run();
|
||||
|
||||
// finish the IE hack
|
||||
if (check_browser_version('MSIE')) {
|
||||
echo "</xmp>";
|
||||
}
|
||||
|
||||
|
||||
|
||||
+4
-10
@@ -8,18 +8,14 @@ require_once('../config.php');
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
require_once($CFG->libdir.'/tablelib.php');
|
||||
|
||||
$action = required_param('action', PARAM_ALPHANUMEXT);
|
||||
$editor = required_param('editor', PARAM_PLUGIN);
|
||||
$confirm = optional_param('confirm', 0, PARAM_BOOL);
|
||||
|
||||
$PAGE->set_url('/admin/editors.php', array('action'=>$action, 'editor'=>$editor));
|
||||
$PAGE->set_context(context_system::instance());
|
||||
|
||||
require_login();
|
||||
require_capability('moodle/site:config', context_system::instance());
|
||||
require_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM));
|
||||
|
||||
$returnurl = "$CFG->wwwroot/$CFG->admin/settings.php?section=manageeditors";
|
||||
|
||||
$action = optional_param('action', '', PARAM_ACTION);
|
||||
$editor = optional_param('editor', '', PARAM_PLUGIN);
|
||||
|
||||
// get currently installed and enabled auth plugins
|
||||
$available_editors = editors_get_available();
|
||||
if (!empty($editor) and empty($available_editors[$editor])) {
|
||||
@@ -82,7 +78,6 @@ switch ($action) {
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -93,7 +88,6 @@ if (empty($active_editors)) {
|
||||
}
|
||||
|
||||
set_config('texteditors', implode(',', $active_editors));
|
||||
core_plugin_manager::reset_caches();
|
||||
|
||||
if ($return) {
|
||||
redirect ($returnurl);
|
||||
|
||||
+21
-27
@@ -23,12 +23,10 @@
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
define('NO_OUTPUT_BUFFERING', true);
|
||||
|
||||
require_once('../config.php');
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
|
||||
$action = required_param('action', PARAM_ALPHANUMEXT);
|
||||
$action = required_param('action', PARAM_ACTION);
|
||||
$enrol = required_param('enrol', PARAM_PLUGIN);
|
||||
$confirm = optional_param('confirm', 0, PARAM_BOOL);
|
||||
|
||||
@@ -36,7 +34,7 @@ $PAGE->set_url('/admin/enrol.php');
|
||||
$PAGE->set_context(context_system::instance());
|
||||
|
||||
require_login();
|
||||
require_capability('moodle/site:config', context_system::instance());
|
||||
require_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM));
|
||||
require_sesskey();
|
||||
|
||||
$enabled = enrol_get_plugins(true);
|
||||
@@ -50,7 +48,6 @@ switch ($action) {
|
||||
case 'disable':
|
||||
unset($enabled[$enrol]);
|
||||
set_config('enrol_plugins_enabled', implode(',', array_keys($enabled)));
|
||||
core_plugin_manager::reset_caches();
|
||||
$syscontext->mark_dirty(); // resets all enrol caches
|
||||
break;
|
||||
|
||||
@@ -61,7 +58,6 @@ switch ($action) {
|
||||
$enabled = array_keys($enabled);
|
||||
$enabled[] = $enrol;
|
||||
set_config('enrol_plugins_enabled', implode(',', $enabled));
|
||||
core_plugin_manager::reset_caches();
|
||||
$syscontext->mark_dirty(); // resets all enrol caches
|
||||
break;
|
||||
|
||||
@@ -97,36 +93,34 @@ switch ($action) {
|
||||
set_config('enrol_plugins_enabled', implode(',', $enabled));
|
||||
break;
|
||||
|
||||
case 'migrate':
|
||||
case 'uninstall':
|
||||
echo $OUTPUT->header();
|
||||
echo $OUTPUT->heading(get_string('enrolments', 'enrol'));
|
||||
|
||||
if (get_string_manager()->string_exists('pluginname', 'enrol_'.$enrol)) {
|
||||
$strplugin = get_string('pluginname', 'enrol_'.$enrol);
|
||||
} else {
|
||||
$strplugin = $enrol;
|
||||
}
|
||||
|
||||
$PAGE->set_title($strplugin);
|
||||
echo $OUTPUT->header();
|
||||
if (!$confirm) {
|
||||
$uurl = new moodle_url('/admin/enrol.php', array('action'=>'uninstall', 'enrol'=>$enrol, 'sesskey'=>sesskey(), 'confirm'=>1));
|
||||
echo $OUTPUT->confirm(get_string('uninstallconfirm', 'enrol', $strplugin), $uurl, $return);
|
||||
echo $OUTPUT->footer();
|
||||
exit;
|
||||
|
||||
// This may take a long time.
|
||||
core_php_time_limit::raise();
|
||||
} else { // Delete everything!!
|
||||
uninstall_plugin('enrol', $enrol);
|
||||
$syscontext->mark_dirty(); // resets all enrol caches
|
||||
|
||||
// Disable plugin to prevent concurrent cron execution.
|
||||
unset($enabled[$enrol]);
|
||||
set_config('enrol_plugins_enabled', implode(',', array_keys($enabled)));
|
||||
|
||||
echo $OUTPUT->heading(get_string('uninstallmigrating', 'enrol', 'enrol_'.$enrol));
|
||||
|
||||
require_once("$CFG->dirroot/enrol/manual/locallib.php");
|
||||
enrol_manual_migrate_plugin_enrolments($enrol);
|
||||
|
||||
echo $OUTPUT->notification(get_string('success'), 'notifysuccess');
|
||||
|
||||
if (!$return = core_plugin_manager::instance()->get_uninstall_url('enrol_'.$enrol, 'manage')) {
|
||||
$return = new moodle_url('/admin/plugins.php');
|
||||
$a = new stdClass();
|
||||
$a->plugin = $strplugin;
|
||||
$a->directory = "$CFG->dirroot/enrol/$enrol";
|
||||
echo $OUTPUT->notification(get_string('uninstalldeletefiles', 'enrol', $a), 'notifysuccess');
|
||||
echo $OUTPUT->continue_button($return);
|
||||
echo $OUTPUT->footer();
|
||||
exit;
|
||||
}
|
||||
echo $OUTPUT->continue_button($return);
|
||||
echo $OUTPUT->footer();
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@ require_once($CFG->libdir.'/environmentlib.php');
|
||||
require_once($CFG->libdir.'/componentlib.class.php');
|
||||
|
||||
// Parameters
|
||||
$action = optional_param('action', '', PARAM_ALPHANUMEXT);
|
||||
$action = optional_param('action', '', PARAM_ACTION);
|
||||
$version = optional_param('version', '', PARAM_FILE); //
|
||||
|
||||
$extraurlparams = array();
|
||||
@@ -45,7 +45,7 @@ admin_externalpage_setup('environment', '', $extraurlparams);
|
||||
// Handle the 'updatecomponent' action
|
||||
if ($action == 'updatecomponent' && confirm_sesskey()) {
|
||||
// Create component installer and execute it
|
||||
if ($cd = new component_installer('https://download.moodle.org',
|
||||
if ($cd = new component_installer('http://download.moodle.org',
|
||||
'environment',
|
||||
'environment.zip')) {
|
||||
$status = $cd->install(); //returns COMPONENT_(ERROR | UPTODATE | INSTALLED)
|
||||
@@ -53,7 +53,7 @@ if ($action == 'updatecomponent' && confirm_sesskey()) {
|
||||
case COMPONENT_ERROR:
|
||||
if ($cd->get_error() == 'remotedownloaderror') {
|
||||
$a = new stdClass();
|
||||
$a->url = 'https://download.moodle.org/environment/environment.zip';
|
||||
$a->url = 'http://download.moodle.org/environment/environment.zip';
|
||||
$a->dest = $CFG->dataroot . '/';
|
||||
print_error($cd->get_error(), 'error', $PAGE->url, $a);
|
||||
die();
|
||||
@@ -102,7 +102,7 @@ if ($contents = load_environment_xml()) {
|
||||
}
|
||||
|
||||
// Get the results of the environment check.
|
||||
list($envstatus, $environment_results) = check_moodle_environment($version, ENV_SELECT_NEWER);
|
||||
list($envstatus, $environment_results) = check_moodle_environment($version);
|
||||
|
||||
// Display the page.
|
||||
$output = $PAGE->get_renderer('core', 'admin');
|
||||
|
||||
+20
-664
@@ -227,7 +227,7 @@
|
||||
<PHP_EXTENSIONS>
|
||||
<PHP_EXTENSION name="iconv" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="iconvrequired" />
|
||||
<ON_CHECK message="iconvrequired" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="mbstring" level="optional">
|
||||
@@ -237,7 +237,7 @@
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="curl" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="curlrequired" />
|
||||
<ON_CHECK message="curlrequired" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="openssl" level="optional">
|
||||
@@ -277,12 +277,12 @@
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="simplexml" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="simplexmlrequired" />
|
||||
<ON_CHECK message="simplexmlrequired" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="spl" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="splrequired" />
|
||||
<ON_CHECK message="splrequired" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="pcre" level="required">
|
||||
@@ -344,7 +344,7 @@
|
||||
<PHP_EXTENSIONS>
|
||||
<PHP_EXTENSION name="iconv" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="iconvrequired" />
|
||||
<ON_CHECK message="iconvrequired" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="mbstring" level="optional">
|
||||
@@ -354,7 +354,7 @@
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="curl" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="curlrequired" />
|
||||
<ON_CHECK message="curlrequired" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="openssl" level="optional">
|
||||
@@ -394,12 +394,12 @@
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="simplexml" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="simplexmlrequired" />
|
||||
<ON_CHECK message="simplexmlrequired" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="spl" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="splrequired" />
|
||||
<ON_CHECK message="splrequired" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="pcre" level="required">
|
||||
@@ -454,7 +454,7 @@
|
||||
<PHP_EXTENSIONS>
|
||||
<PHP_EXTENSION name="iconv" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="iconvrequired" />
|
||||
<ON_CHECK message="iconvrequired" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="mbstring" level="optional">
|
||||
@@ -464,7 +464,7 @@
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="curl" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="curlrequired" />
|
||||
<ON_CHECK message="curlrequired" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="openssl" level="optional">
|
||||
@@ -504,12 +504,12 @@
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="simplexml" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="simplexmlrequired" />
|
||||
<ON_CHECK message="simplexmlrequired" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="spl" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="splrequired" />
|
||||
<ON_CHECK message="splrequired" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="pcre" level="required">
|
||||
@@ -569,7 +569,7 @@
|
||||
<PHP_EXTENSIONS>
|
||||
<PHP_EXTENSION name="iconv" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="iconvrequired" />
|
||||
<ON_CHECK message="iconvrequired" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="mbstring" level="optional">
|
||||
@@ -579,7 +579,7 @@
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="curl" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="curlrequired" />
|
||||
<ON_CHECK message="curlrequired" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="openssl" level="optional">
|
||||
@@ -619,12 +619,12 @@
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="simplexml" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="simplexmlrequired" />
|
||||
<ON_CHECK message="simplexmlrequired" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="spl" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="splrequired" />
|
||||
<ON_CHECK message="splrequired" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="pcre" level="required">
|
||||
@@ -685,7 +685,7 @@
|
||||
<PHP_EXTENSIONS>
|
||||
<PHP_EXTENSION name="iconv" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="iconvrequired" />
|
||||
<ON_CHECK message="iconvrequired" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="mbstring" level="optional">
|
||||
@@ -695,7 +695,7 @@
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="curl" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="curlrequired" />
|
||||
<ON_CHECK message="curlrequired" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="openssl" level="optional">
|
||||
@@ -735,12 +735,12 @@
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="simplexml" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="simplexmlrequired" />
|
||||
<ON_CHECK message="simplexmlrequired" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="spl" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="splrequired" />
|
||||
<ON_CHECK message="splrequired" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="pcre" level="required">
|
||||
@@ -776,648 +776,4 @@
|
||||
</PHP_SETTING>
|
||||
</PHP_SETTINGS>
|
||||
</MOODLE>
|
||||
<MOODLE version="2.5" requires="2.2">
|
||||
<UNICODE level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="unicoderequired" />
|
||||
</FEEDBACK>
|
||||
</UNICODE>
|
||||
<DATABASE level="required">
|
||||
<VENDOR name="mysql" version="5.1.33" />
|
||||
<VENDOR name="postgres" version="8.3" />
|
||||
<VENDOR name="mssql" version="9.0" />
|
||||
<VENDOR name="odbc_mssql" version="9.0" />
|
||||
<VENDOR name="mssql_n" version="9.0" />
|
||||
<VENDOR name="oracle" version="10.2" />
|
||||
<VENDOR name="sqlite" version="2.0" />
|
||||
</DATABASE>
|
||||
<PHP version="5.3.3" level="required">
|
||||
</PHP>
|
||||
<PCREUNICODE level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="pcreunicodewarning" />
|
||||
</FEEDBACK>
|
||||
</PCREUNICODE>
|
||||
<PHP_EXTENSIONS>
|
||||
<PHP_EXTENSION name="iconv" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="iconvrequired" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="mbstring" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="mbstringrecommended" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="curl" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="curlrequired" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="openssl" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="opensslrecommended" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="tokenizer" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="tokenizerrecommended" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="xmlrpc" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="xmlrpcrecommended" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="soap" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="soaprecommended" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="ctype" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="ctyperequired" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="zip" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="ziprequired" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="gd" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="gdrequired" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="simplexml" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="simplexmlrequired" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="spl" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="splrequired" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="pcre" level="required">
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="dom" level="required">
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="xml" level="required">
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="intl" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="intlrecommended" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="json" level="required">
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="hash" level="required"/>
|
||||
</PHP_EXTENSIONS>
|
||||
<PHP_SETTINGS>
|
||||
<PHP_SETTING name="memory_limit" value="40M" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="settingmemorylimit" />
|
||||
</FEEDBACK>
|
||||
</PHP_SETTING>
|
||||
<PHP_SETTING name="safe_mode" value="0" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="settingsafemode" />
|
||||
</FEEDBACK>
|
||||
</PHP_SETTING>
|
||||
<PHP_SETTING name="file_uploads" value="1" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="settingfileuploads" />
|
||||
</FEEDBACK>
|
||||
</PHP_SETTING>
|
||||
</PHP_SETTINGS>
|
||||
</MOODLE>
|
||||
<MOODLE version="2.6" requires="2.2">
|
||||
<UNICODE level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="unicoderequired" />
|
||||
</FEEDBACK>
|
||||
</UNICODE>
|
||||
<DATABASE level="required">
|
||||
<VENDOR name="mariadb" version="5.3.5" />
|
||||
<VENDOR name="mysql" version="5.1.33" />
|
||||
<VENDOR name="postgres" version="8.3" />
|
||||
<VENDOR name="mssql" version="9.0" />
|
||||
<VENDOR name="oracle" version="10.2" />
|
||||
</DATABASE>
|
||||
<PHP version="5.3.3" level="required">
|
||||
</PHP>
|
||||
<PCREUNICODE level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="pcreunicodewarning" />
|
||||
</FEEDBACK>
|
||||
</PCREUNICODE>
|
||||
<PHP_EXTENSIONS>
|
||||
<PHP_EXTENSION name="iconv" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="iconvrequired" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="mbstring" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="mbstringrecommended" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="curl" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="curlrequired" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="openssl" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="opensslrecommended" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="tokenizer" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="tokenizerrecommended" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="xmlrpc" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="xmlrpcrecommended" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="soap" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="soaprecommended" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="ctype" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="ctyperequired" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="zip" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="ziprequired" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="zlib" level="optional">
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="gd" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="gdrequired" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="simplexml" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="simplexmlrequired" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="spl" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="splrequired" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="pcre" level="required">
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="dom" level="required">
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="xml" level="required">
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="intl" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="intlrecommended" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="json" level="required">
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="hash" level="required"/>
|
||||
</PHP_EXTENSIONS>
|
||||
<PHP_SETTINGS>
|
||||
<PHP_SETTING name="memory_limit" value="64M" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="settingmemorylimit" />
|
||||
</FEEDBACK>
|
||||
</PHP_SETTING>
|
||||
<PHP_SETTING name="safe_mode" value="0" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="settingsafemode" />
|
||||
</FEEDBACK>
|
||||
</PHP_SETTING>
|
||||
<PHP_SETTING name="file_uploads" value="1" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="settingfileuploads" />
|
||||
</FEEDBACK>
|
||||
</PHP_SETTING>
|
||||
<PHP_SETTING name="opcache.enable" value="1" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="opcacherecommended" />
|
||||
</FEEDBACK>
|
||||
</PHP_SETTING>
|
||||
</PHP_SETTINGS>
|
||||
</MOODLE>
|
||||
<MOODLE version="2.7" requires="2.2">
|
||||
<UNICODE level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="unicoderequired" />
|
||||
</FEEDBACK>
|
||||
</UNICODE>
|
||||
<DATABASE level="required">
|
||||
<VENDOR name="mariadb" version="5.5.31" />
|
||||
<VENDOR name="mysql" version="5.5.31" />
|
||||
<VENDOR name="postgres" version="9.1" />
|
||||
<VENDOR name="mssql" version="10.0" />
|
||||
<VENDOR name="oracle" version="10.2" />
|
||||
</DATABASE>
|
||||
<PHP version="5.4.4" level="required">
|
||||
<RESTRICT function="restrict_php_version_7" message="unsupportedphpversion7" />
|
||||
</PHP>
|
||||
<PCREUNICODE level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="pcreunicodewarning" />
|
||||
</FEEDBACK>
|
||||
</PCREUNICODE>
|
||||
<PHP_EXTENSIONS>
|
||||
<PHP_EXTENSION name="iconv" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="iconvrequired" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="mbstring" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="mbstringrecommended" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="curl" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="curlrequired" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="openssl" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="opensslrecommended" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="tokenizer" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="tokenizerrecommended" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="xmlrpc" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="xmlrpcrecommended" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="soap" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="soaprecommended" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="ctype" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="ctyperequired" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="zip" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="ziprequired" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="zlib" level="required">
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="gd" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="gdrequired" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="simplexml" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="simplexmlrequired" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="spl" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="splrequired" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="pcre" level="required">
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="dom" level="required">
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="xml" level="required">
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="intl" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="intlrecommended" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="json" level="required">
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="hash" level="required"/>
|
||||
</PHP_EXTENSIONS>
|
||||
<PHP_SETTINGS>
|
||||
<PHP_SETTING name="memory_limit" value="96M" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="settingmemorylimit" />
|
||||
</FEEDBACK>
|
||||
</PHP_SETTING>
|
||||
<PHP_SETTING name="file_uploads" value="1" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="settingfileuploads" />
|
||||
</FEEDBACK>
|
||||
</PHP_SETTING>
|
||||
<PHP_SETTING name="opcache.enable" value="1" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="opcacherecommended" />
|
||||
</FEEDBACK>
|
||||
</PHP_SETTING>
|
||||
</PHP_SETTINGS>
|
||||
<CUSTOM_CHECKS>
|
||||
<CUSTOM_CHECK file="question/engine/upgrade/upgradelib.php" function="quiz_attempts_upgraded" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="quizattemptsupgradedmessage" />
|
||||
</FEEDBACK>
|
||||
</CUSTOM_CHECK>
|
||||
<CUSTOM_CHECK file="lib/upgradelib.php" function="check_slasharguments" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="slashargumentswarning" />
|
||||
</FEEDBACK>
|
||||
</CUSTOM_CHECK>
|
||||
<CUSTOM_CHECK file="lib/upgradelib.php" function="check_database_tables_row_format" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="unsupporteddbtablerowformat" />
|
||||
</FEEDBACK>
|
||||
</CUSTOM_CHECK>
|
||||
</CUSTOM_CHECKS>
|
||||
</MOODLE>
|
||||
<MOODLE version="2.8" requires="2.2">
|
||||
<UNICODE level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="unicoderequired" />
|
||||
</FEEDBACK>
|
||||
</UNICODE>
|
||||
<DATABASE level="required">
|
||||
<VENDOR name="mariadb" version="5.5.31" />
|
||||
<VENDOR name="mysql" version="5.5.31" />
|
||||
<VENDOR name="postgres" version="9.1" />
|
||||
<VENDOR name="mssql" version="10.0" />
|
||||
<VENDOR name="oracle" version="10.2" />
|
||||
</DATABASE>
|
||||
<PHP version="5.4.4" level="required">
|
||||
<RESTRICT function="restrict_php_version_7" message="unsupportedphpversion7" />
|
||||
</PHP>
|
||||
<PCREUNICODE level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="pcreunicodewarning" />
|
||||
</FEEDBACK>
|
||||
</PCREUNICODE>
|
||||
<PHP_EXTENSIONS>
|
||||
<PHP_EXTENSION name="iconv" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="iconvrequired" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="mbstring" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="mbstringrecommended" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="curl" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="curlrequired" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="openssl" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="opensslrecommended" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="tokenizer" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="tokenizerrecommended" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="xmlrpc" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="xmlrpcrecommended" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="soap" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="soaprecommended" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="ctype" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="ctyperequired" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="zip" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="ziprequired" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="zlib" level="required">
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="gd" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="gdrequired" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="simplexml" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="simplexmlrequired" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="spl" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="splrequired" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="pcre" level="required">
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="dom" level="required">
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="xml" level="required">
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="intl" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="intlrecommended" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="json" level="required">
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="hash" level="required"/>
|
||||
</PHP_EXTENSIONS>
|
||||
<PHP_SETTINGS>
|
||||
<PHP_SETTING name="memory_limit" value="96M" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="settingmemorylimit" />
|
||||
</FEEDBACK>
|
||||
</PHP_SETTING>
|
||||
<PHP_SETTING name="file_uploads" value="1" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="settingfileuploads" />
|
||||
</FEEDBACK>
|
||||
</PHP_SETTING>
|
||||
<PHP_SETTING name="opcache.enable" value="1" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="opcacherecommended" />
|
||||
</FEEDBACK>
|
||||
</PHP_SETTING>
|
||||
</PHP_SETTINGS>
|
||||
<CUSTOM_CHECKS>
|
||||
<CUSTOM_CHECK file="question/engine/upgrade/upgradelib.php" function="quiz_attempts_upgraded" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="quizattemptsupgradedmessage" />
|
||||
</FEEDBACK>
|
||||
</CUSTOM_CHECK>
|
||||
<CUSTOM_CHECK file="lib/upgradelib.php" function="check_slasharguments" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="slashargumentswarning" />
|
||||
</FEEDBACK>
|
||||
</CUSTOM_CHECK>
|
||||
<CUSTOM_CHECK file="lib/upgradelib.php" function="check_database_tables_row_format" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="unsupporteddbtablerowformat" />
|
||||
</FEEDBACK>
|
||||
</CUSTOM_CHECK>
|
||||
</CUSTOM_CHECKS>
|
||||
</MOODLE>
|
||||
<MOODLE version="2.9" requires="2.2">
|
||||
<UNICODE level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="unicoderequired" />
|
||||
</FEEDBACK>
|
||||
</UNICODE>
|
||||
<DATABASE level="required">
|
||||
<VENDOR name="mariadb" version="5.5.31" />
|
||||
<VENDOR name="mysql" version="5.5.31" />
|
||||
<VENDOR name="postgres" version="9.1" />
|
||||
<VENDOR name="mssql" version="10.0" />
|
||||
<VENDOR name="oracle" version="10.2" />
|
||||
</DATABASE>
|
||||
<PHP version="5.4.4" level="required">
|
||||
<RESTRICT function="restrict_php_version_7" message="unsupportedphpversion7" />
|
||||
</PHP>
|
||||
<PCREUNICODE level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="pcreunicodewarning" />
|
||||
</FEEDBACK>
|
||||
</PCREUNICODE>
|
||||
<PHP_EXTENSIONS>
|
||||
<PHP_EXTENSION name="iconv" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="iconvrequired" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="mbstring" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="mbstringrecommended" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="curl" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="curlrequired" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="openssl" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="opensslrecommended" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="tokenizer" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="tokenizerrecommended" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="xmlrpc" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="xmlrpcrecommended" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="soap" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="soaprecommended" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="ctype" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="ctyperequired" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="zip" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="ziprequired" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="zlib" level="required">
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="gd" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="gdrequired" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="simplexml" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="simplexmlrequired" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="spl" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="splrequired" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="pcre" level="required">
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="dom" level="required">
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="xml" level="required">
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="intl" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="intlrecommended" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="json" level="required">
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="hash" level="required"/>
|
||||
</PHP_EXTENSIONS>
|
||||
<PHP_SETTINGS>
|
||||
<PHP_SETTING name="memory_limit" value="96M" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="settingmemorylimit" />
|
||||
</FEEDBACK>
|
||||
</PHP_SETTING>
|
||||
<PHP_SETTING name="file_uploads" value="1" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="settingfileuploads" />
|
||||
</FEEDBACK>
|
||||
</PHP_SETTING>
|
||||
<PHP_SETTING name="opcache.enable" value="1" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="opcacherecommended" />
|
||||
</FEEDBACK>
|
||||
</PHP_SETTING>
|
||||
</PHP_SETTINGS>
|
||||
<CUSTOM_CHECKS>
|
||||
<CUSTOM_CHECK file="lib/upgradelib.php" function="check_database_storage_engine" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="unsupporteddbstorageengine" />
|
||||
</FEEDBACK>
|
||||
</CUSTOM_CHECK>
|
||||
<CUSTOM_CHECK file="question/engine/upgrade/upgradelib.php" function="quiz_attempts_upgraded" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="quizattemptsupgradedmessage" />
|
||||
</FEEDBACK>
|
||||
</CUSTOM_CHECK>
|
||||
<CUSTOM_CHECK file="lib/upgradelib.php" function="check_slasharguments" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="slashargumentswarning" />
|
||||
</FEEDBACK>
|
||||
</CUSTOM_CHECK>
|
||||
<CUSTOM_CHECK file="lib/upgradelib.php" function="check_database_tables_row_format" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="unsupporteddbtablerowformat" />
|
||||
</FEEDBACK>
|
||||
</CUSTOM_CHECK>
|
||||
</CUSTOM_CHECKS>
|
||||
</MOODLE>
|
||||
</COMPATIBILITY_MATRIX>
|
||||
|
||||
+204
-170
@@ -1,232 +1,261 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// //
|
||||
// NOTICE OF COPYRIGHT //
|
||||
// //
|
||||
// Moodle - Modular Object-Oriented Dynamic Learning Environment //
|
||||
// http://moodle.org //
|
||||
// //
|
||||
// Copyright (C) 1999 onwards Martin Dougiamas http://dougiamas.com //
|
||||
// //
|
||||
// This program is free software; you can redistribute it and/or modify //
|
||||
// it under the terms of the GNU General Public License as published by //
|
||||
// the Free Software Foundation; either version 2 of the License, or //
|
||||
// (at your option) any later version. //
|
||||
// //
|
||||
// This program is distributed in the hope that it will be useful, //
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
|
||||
// GNU General Public License for more details: //
|
||||
// //
|
||||
// http://www.gnu.org/copyleft/gpl.html //
|
||||
// //
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
* Filter management page.
|
||||
* Processes actions from the admin_setting_managefilters object (defined in
|
||||
* adminlib.php).
|
||||
*
|
||||
* @package core
|
||||
* @copyright 1999 onwards Martin Dougiamas http://dougiamas.com
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
|
||||
* @package administration
|
||||
*//** */
|
||||
|
||||
require_once(dirname(__FILE__) . '/../config.php');
|
||||
require_once($CFG->libdir . '/adminlib.php');
|
||||
require_once(dirname(__FILE__) . '/../config.php');
|
||||
require_once($CFG->libdir . '/adminlib.php');
|
||||
|
||||
$action = optional_param('action', '', PARAM_ALPHA);
|
||||
$filterpath = optional_param('filterpath', '', PARAM_PLUGIN);
|
||||
$action = optional_param('action', '', PARAM_ACTION);
|
||||
$filterpath = optional_param('filterpath', '', PARAM_PATH);
|
||||
|
||||
require_login();
|
||||
$systemcontext = context_system::instance();
|
||||
require_capability('moodle/site:config', $systemcontext);
|
||||
require_login();
|
||||
$systemcontext = get_context_instance(CONTEXT_SYSTEM);
|
||||
require_capability('moodle/site:config', $systemcontext);
|
||||
|
||||
admin_externalpage_setup('managefilters');
|
||||
$returnurl = "$CFG->wwwroot/$CFG->admin/filters.php";
|
||||
admin_externalpage_setup('managefilters');
|
||||
|
||||
// Clean up bogus filter states first.
|
||||
$plugininfos = core_plugin_manager::instance()->get_plugins_of_type('filter');
|
||||
$filters = array();
|
||||
$states = filter_get_global_states();
|
||||
foreach ($states as $state) {
|
||||
if (!isset($plugininfos[$state->filter]) and !get_config('filter_'.$state->filter, 'version')) {
|
||||
// Purge messy leftovers after incorrectly uninstalled plugins and unfinished installs.
|
||||
$DB->delete_records('filter_active', array('filter' => $state->filter));
|
||||
$DB->delete_records('filter_config', array('filter' => $state->filter));
|
||||
error_log('Deleted bogus "filter_'.$state->filter.'" states and config data.');
|
||||
} else {
|
||||
$filters[$state->filter] = $state;
|
||||
$filters = filter_get_global_states();
|
||||
|
||||
// In case any new filters have been installed, but not put in the table yet.
|
||||
$fitlernames = filter_get_all_installed();
|
||||
$newfilters = $fitlernames;
|
||||
foreach ($filters as $filter => $notused) {
|
||||
unset($newfilters[$filter]);
|
||||
}
|
||||
}
|
||||
|
||||
// Add properly installed and upgraded filters to the global states table.
|
||||
foreach ($plugininfos as $filter => $info) {
|
||||
if (isset($filters[$filter])) {
|
||||
continue;
|
||||
}
|
||||
/** @var \core\plugininfo\base $info */
|
||||
if ($info->is_installed_and_upgraded()) {
|
||||
filter_set_global_state($filter, TEXTFILTER_DISABLED);
|
||||
$states = filter_get_global_states();
|
||||
foreach ($states as $state) {
|
||||
if ($state->filter === $filter) {
|
||||
$filters[$filter] = $state;
|
||||
break;
|
||||
}
|
||||
/// Process actions ============================================================
|
||||
|
||||
if ($action) {
|
||||
if (!isset($filters[$filterpath]) && !isset($newfilters[$filterpath])) {
|
||||
throw new moodle_exception('filternotinstalled', 'error', $returnurl, $filterpath);
|
||||
}
|
||||
|
||||
if (!confirm_sesskey()) {
|
||||
redirect($returnurl);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($action) {
|
||||
require_sesskey();
|
||||
}
|
||||
|
||||
// Process actions.
|
||||
switch ($action) {
|
||||
switch ($action) {
|
||||
|
||||
case 'setstate':
|
||||
if (isset($filters[$filterpath]) and $newstate = optional_param('newstate', '', PARAM_INT)) {
|
||||
if ($newstate = optional_param('newstate', '', PARAM_INTEGER)) {
|
||||
filter_set_global_state($filterpath, $newstate);
|
||||
if ($newstate == TEXTFILTER_DISABLED) {
|
||||
filter_set_applies_to_strings($filterpath, false);
|
||||
}
|
||||
unset($newfilters[$filterpath]);
|
||||
}
|
||||
break;
|
||||
|
||||
case 'setapplyto':
|
||||
if (isset($filters[$filterpath])) {
|
||||
$applytostrings = optional_param('stringstoo', false, PARAM_BOOL);
|
||||
filter_set_applies_to_strings($filterpath, $applytostrings);
|
||||
}
|
||||
$applytostrings = optional_param('stringstoo', false, PARAM_BOOL);
|
||||
filter_set_applies_to_strings($filterpath, $applytostrings);
|
||||
break;
|
||||
|
||||
case 'down':
|
||||
if (isset($filters[$filterpath])) {
|
||||
filter_set_global_state($filterpath, $filters[$filterpath]->active, 1);
|
||||
$oldpos = $filters[$filterpath]->sortorder;
|
||||
if ($oldpos <= count($filters)) {
|
||||
filter_set_global_state($filterpath, $filters[$filterpath]->active, $oldpos + 1);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case 'up':
|
||||
if (isset($filters[$filterpath])) {
|
||||
$oldpos = $filters[$filterpath]->sortorder;
|
||||
filter_set_global_state($filterpath, $filters[$filterpath]->active, -1);
|
||||
if ($oldpos >= 1) {
|
||||
filter_set_global_state($filterpath, $filters[$filterpath]->active, $oldpos - 1);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
// Reset caches and return.
|
||||
if ($action) {
|
||||
reset_text_filters_cache();
|
||||
core_plugin_manager::reset_caches();
|
||||
redirect(new moodle_url('/admin/filters.php'));
|
||||
}
|
||||
case 'delete':
|
||||
if (!empty($filternames[$filterpath])) {
|
||||
$filtername = $filternames[$filterpath];
|
||||
} else {
|
||||
$filtername = $filterpath;
|
||||
}
|
||||
|
||||
// Print the page heading.
|
||||
echo $OUTPUT->header();
|
||||
echo $OUTPUT->heading(get_string('filtersettings', 'admin'));
|
||||
if (substr($filterpath, 0, 4) == 'mod/') {
|
||||
$mod = basename($filterpath);
|
||||
$a = new stdClass;
|
||||
$a->filter = $filtername;
|
||||
$a->module = get_string('modulename', $mod);
|
||||
print_error('cannotdeletemodfilter', 'admin', $returnurl, $a);
|
||||
}
|
||||
|
||||
$states = filter_get_global_states();
|
||||
$stringfilters = filter_get_string_filters();
|
||||
// If not yet confirmed, display a confirmation message.
|
||||
if (!optional_param('confirm', '', PARAM_BOOL)) {
|
||||
$title = get_string('deletefilterareyousure', 'admin', $filtername);
|
||||
echo $OUTPUT->header();
|
||||
echo $OUTPUT->heading($title);
|
||||
|
||||
$table = new html_table();
|
||||
$table->head = array(get_string('filter'), get_string('isactive', 'filters'),
|
||||
get_string('order'), get_string('applyto', 'filters'), get_string('settings'), get_string('uninstallplugin', 'core_admin'));
|
||||
$table->colclasses = array ('leftalign', 'leftalign', 'centeralign', 'leftalign', 'leftalign', 'leftalign');
|
||||
$table->attributes['class'] = 'admintable generaltable';
|
||||
$table->id = 'filterssetting';
|
||||
$table->data = array();
|
||||
$linkcontinue = new moodle_url($returnurl, array('action' => 'delete', 'filterpath' => $filterpath, 'confirm' => 1));
|
||||
$formcancel = new single_button(new moodle_url($returnurl), get_string('no'), 'get');
|
||||
echo $OUTPUT->confirm(get_string('deletefilterareyousuremessage', 'admin', $filtername), $linkcontinue, $formcancel);
|
||||
echo $OUTPUT->footer();
|
||||
exit;
|
||||
}
|
||||
|
||||
$lastactive = null;
|
||||
foreach ($states as $state) {
|
||||
if ($state->active != TEXTFILTER_DISABLED) {
|
||||
$lastactive = $state->filter;
|
||||
// Do the deletion.
|
||||
$title = get_string('deletingfilter', 'admin', $filtername);
|
||||
echo $OUTPUT->header();
|
||||
echo $OUTPUT->heading($title);
|
||||
|
||||
// Delete all data for this plugin.
|
||||
filter_delete_all_for_filter($filterpath);
|
||||
|
||||
$a = new stdClass;
|
||||
$a->filter = $filtername;
|
||||
$a->directory = $filterpath;
|
||||
echo $OUTPUT->box(get_string('deletefilterfiles', 'admin', $a), 'generalbox', 'notice');
|
||||
echo $OUTPUT->continue_button($returnurl);
|
||||
echo $OUTPUT->footer();
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
// Iterate through filters adding to display table.
|
||||
$firstrow = true;
|
||||
foreach ($states as $state) {
|
||||
$filter = $state->filter;
|
||||
if (!isset($plugininfos[$filter])) {
|
||||
continue;
|
||||
// Add any missing filters to the DB table.
|
||||
foreach ($newfilters as $filter => $notused) {
|
||||
filter_set_global_state($filter, TEXTFILTER_DISABLED);
|
||||
}
|
||||
$plugininfo = $plugininfos[$filter];
|
||||
$applytostrings = isset($stringfilters[$filter]) && $state->active != TEXTFILTER_DISABLED;
|
||||
$row = get_table_row($plugininfo, $state, $firstrow, $filter == $lastactive, $applytostrings);
|
||||
$table->data[] = $row;
|
||||
if ($state->active == TEXTFILTER_DISABLED) {
|
||||
|
||||
// Reset caches and return
|
||||
if ($action) {
|
||||
reset_text_filters_cache();
|
||||
redirect($returnurl);
|
||||
}
|
||||
|
||||
/// End of process actions =====================================================
|
||||
|
||||
/// Print the page heading.
|
||||
echo $OUTPUT->header();
|
||||
echo $OUTPUT->heading(get_string('filtersettings', 'admin'));
|
||||
|
||||
$activechoices = array(
|
||||
TEXTFILTER_DISABLED => get_string('disabled', 'filters'),
|
||||
TEXTFILTER_OFF => get_string('offbutavailable', 'filters'),
|
||||
TEXTFILTER_ON => get_string('on', 'filters'),
|
||||
);
|
||||
$applytochoices = array(
|
||||
0 => get_string('content', 'filters'),
|
||||
1 => get_string('contentandheadings', 'filters'),
|
||||
);
|
||||
|
||||
$filters = filter_get_global_states();
|
||||
|
||||
// In case any new filters have been installed, but not put in the table yet.
|
||||
$filternames = filter_get_all_installed();
|
||||
$newfilters = $filternames;
|
||||
foreach ($filters as $filter => $notused) {
|
||||
unset($newfilters[$filter]);
|
||||
}
|
||||
$stringfilters = filter_get_string_filters();
|
||||
|
||||
$table = new html_table();
|
||||
$table->head = array(get_string('filter'), get_string('isactive', 'filters'),
|
||||
get_string('order'), get_string('applyto', 'filters'), get_string('settings'), get_string('delete'));
|
||||
$table->align = array('left', 'left', 'center', 'left', 'left');
|
||||
$table->width = '100%';
|
||||
$table->data = array();
|
||||
|
||||
$lastactive = null;
|
||||
foreach ($filters as $filter => $filterinfo) {
|
||||
if ($filterinfo->active != TEXTFILTER_DISABLED) {
|
||||
$lastactive = $filter;
|
||||
}
|
||||
}
|
||||
|
||||
// iterate through filters adding to display table
|
||||
$firstrow = true;
|
||||
foreach ($filters as $filter => $filterinfo) {
|
||||
$applytostrings = isset($stringfilters[$filter]) && $filterinfo->active != TEXTFILTER_DISABLED;
|
||||
$row = get_table_row($filterinfo, $firstrow, $filter == $lastactive, $applytostrings);
|
||||
$table->data[] = $row;
|
||||
if ($filterinfo->active == TEXTFILTER_DISABLED) {
|
||||
$table->rowclasses[] = 'dimmed_text';
|
||||
} else {
|
||||
$table->rowclasses[] = '';
|
||||
}
|
||||
$firstrow = false;
|
||||
}
|
||||
foreach ($newfilters as $filter => $filtername) {
|
||||
$filterinfo = new stdClass;
|
||||
$filterinfo->filter = $filter;
|
||||
$filterinfo->active = TEXTFILTER_DISABLED;
|
||||
$row = get_table_row($filterinfo, false, false, false);
|
||||
$table->data[] = $row;
|
||||
$table->rowclasses[] = 'dimmed_text';
|
||||
} else {
|
||||
$table->rowclasses[] = '';
|
||||
}
|
||||
$firstrow = false;
|
||||
}
|
||||
|
||||
echo html_writer::table($table);
|
||||
echo '<p class="filtersettingnote">' . get_string('filterallwarning', 'filters') . '</p>';
|
||||
echo $OUTPUT->footer();
|
||||
die;
|
||||
echo html_writer::table($table);
|
||||
echo '<p class="filtersettingnote">' . get_string('filterallwarning', 'filters') . '</p>';
|
||||
echo $OUTPUT->footer();
|
||||
|
||||
/// Display helper functions ===================================================
|
||||
|
||||
/**
|
||||
* Return action URL.
|
||||
*
|
||||
* @param string $filterpath
|
||||
* @param string $action
|
||||
* @return moodle_url
|
||||
*/
|
||||
function filters_action_url($filterpath, $action) {
|
||||
if ($action === 'delete') {
|
||||
return core_plugin_manager::instance()->get_uninstall_url('filter_'.$filterpath, 'manage');
|
||||
}
|
||||
return new moodle_url('/admin/filters.php', array('sesskey'=>sesskey(), 'filterpath'=>$filterpath, 'action'=>$action));
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct table record.
|
||||
*
|
||||
* @param \core\plugininfo\filter $plugininfo
|
||||
* @param stdClass $state
|
||||
* @param bool $isfirstrow
|
||||
* @param bool $islastactive
|
||||
* @param bool $applytostrings
|
||||
* @return array data
|
||||
*/
|
||||
function get_table_row(\core\plugininfo\filter $plugininfo, $state, $isfirstrow, $islastactive, $applytostrings) {
|
||||
global $OUTPUT;
|
||||
function get_table_row($filterinfo, $isfirstrow, $islastactive, $applytostrings) {
|
||||
global $CFG, $OUTPUT, $activechoices, $applytochoices, $filternames; //TODO: this is sloppy coding style!!
|
||||
$row = array();
|
||||
$filter = $state->filter;
|
||||
$active = $plugininfo->is_installed_and_upgraded();
|
||||
$filter = $filterinfo->filter;
|
||||
|
||||
static $activechoices;
|
||||
static $applytochoices;
|
||||
if (!isset($activechoices)) {
|
||||
$activechoices = array(
|
||||
TEXTFILTER_DISABLED => get_string('disabled', 'core_filters'),
|
||||
TEXTFILTER_OFF => get_string('offbutavailable', 'core_filters'),
|
||||
TEXTFILTER_ON => get_string('on', 'core_filters'),
|
||||
);
|
||||
$applytochoices = array(
|
||||
0 => get_string('content', 'core_filters'),
|
||||
1 => get_string('contentandheadings', 'core_filters'),
|
||||
);
|
||||
// Filter name
|
||||
if (!empty($filternames[$filter])) {
|
||||
$row[] = $filternames[$filter];
|
||||
} else {
|
||||
$row[] = '<span class="error">' . get_string('filemissing', '', $filter) . '</span>';
|
||||
}
|
||||
|
||||
// Filter name.
|
||||
$displayname = $plugininfo->displayname;
|
||||
if (!$plugininfo->rootdir) {
|
||||
$displayname = '<span class="error">' . $displayname . ' - ' . get_string('status_missing', 'core_plugin') . '</span>';
|
||||
} else if (!$active) {
|
||||
$displayname = '<span class="error">' . $displayname . ' - ' . get_string('error') . '</span>';
|
||||
}
|
||||
$row[] = $displayname;
|
||||
|
||||
// Disable/off/on.
|
||||
$select = new single_select(filters_action_url($filter, 'setstate'), 'newstate', $activechoices, $state->active, null, 'active' . $filter);
|
||||
// Disable/off/on
|
||||
$select = new single_select(filters_action_url($filter, 'setstate'), 'newstate', $activechoices, $filterinfo->active, null, 'active' . basename($filter));
|
||||
$select->set_label(get_string('isactive', 'filters'), array('class' => 'accesshide'));
|
||||
$row[] = $OUTPUT->render($select);
|
||||
|
||||
// Re-order.
|
||||
// Re-order
|
||||
$updown = '';
|
||||
$spacer = '<img src="' . $OUTPUT->pix_url('spacer') . '" class="iconsmall" alt="" />';
|
||||
if ($state->active != TEXTFILTER_DISABLED) {
|
||||
$spacer = '<img src="' . $OUTPUT->pix_url('spacer') . '" class="iconsmall" alt="" /> ';
|
||||
if ($filterinfo->active != TEXTFILTER_DISABLED) {
|
||||
if (!$isfirstrow) {
|
||||
$updown .= $OUTPUT->action_icon(filters_action_url($filter, 'up'), new pix_icon('t/up', get_string('up'), '', array('class' => 'iconsmall')));
|
||||
$updown .= $OUTPUT->action_icon(filters_action_url($filter, 'up'), new pix_icon('t/up', get_string('up')));
|
||||
} else {
|
||||
$updown .= $spacer;
|
||||
}
|
||||
if (!$islastactive) {
|
||||
$updown .= $OUTPUT->action_icon(filters_action_url($filter, 'down'), new pix_icon('t/down', get_string('down'), '', array('class' => 'iconsmall')));
|
||||
$updown .= $OUTPUT->action_icon(filters_action_url($filter, 'down'), new pix_icon('t/down', get_string('down')));
|
||||
} else {
|
||||
$updown .= $spacer;
|
||||
}
|
||||
@@ -234,20 +263,25 @@ function get_table_row(\core\plugininfo\filter $plugininfo, $state, $isfirstrow,
|
||||
$row[] = $updown;
|
||||
|
||||
// Apply to strings.
|
||||
$select = new single_select(filters_action_url($filter, 'setapplyto'), 'stringstoo', $applytochoices, $applytostrings, null, 'applyto' . $filter);
|
||||
$select = new single_select(filters_action_url($filter, 'setapplyto'), 'stringstoo', $applytochoices, $applytostrings, null, 'applyto' . basename($filter));
|
||||
$select->set_label(get_string('applyto', 'filters'), array('class' => 'accesshide'));
|
||||
$select->disabled = ($state->active == TEXTFILTER_DISABLED);
|
||||
$select->disabled = $filterinfo->active == TEXTFILTER_DISABLED;
|
||||
$row[] = $OUTPUT->render($select);
|
||||
|
||||
// Settings link, if required.
|
||||
if ($active and filter_has_global_settings($filter)) {
|
||||
$row[] = html_writer::link(new moodle_url('/admin/settings.php', array('section'=>'filtersetting'.$filter)), get_string('settings'));
|
||||
// Settings link, if required
|
||||
if (filter_has_global_settings($filter)) {
|
||||
$row[] = '<a href="' . $CFG->wwwroot . '/' . $CFG->admin . '/settings.php?section=filtersetting' .
|
||||
str_replace('/', '',$filter) . '">' . get_string('settings') . '</a>';
|
||||
} else {
|
||||
$row[] = '';
|
||||
}
|
||||
|
||||
// Uninstall.
|
||||
$row[] = html_writer::link(filters_action_url($filter, 'delete'), get_string('uninstallplugin', 'core_admin'));
|
||||
// Delete
|
||||
if (substr($filter, 0, 4) != 'mod/') {
|
||||
$row[] = '<a href="' . filters_action_url($filter, 'delete') . '">' . get_string('delete') . '</a>';
|
||||
} else {
|
||||
$row[] = '';
|
||||
}
|
||||
|
||||
return $row;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,150 @@
|
||||
<?php
|
||||
/** This expects the output from a command like
|
||||
* clamscan -r --infected --no-summary <files> 2>&1 | php -d error_log=/path/to/log thisfile.php
|
||||
* also it's important that the output of clamscan prints the FULL PATH to each infected file, so use absolute paths for area to scan
|
||||
* also it should be run as root, or whatever the webserver runs as so that it has the right permissions in the quarantine dir etc.
|
||||
* php -d error_log=/path/to/log thisfile.php will override the default error log for php cli, which is stderr, so if you want this script to just print stuff out, use php thisfile.php instead.
|
||||
*/
|
||||
|
||||
die('TODO: MDL-19380');
|
||||
|
||||
$fd = fopen('php://stdin','r');
|
||||
if (!$fd) {
|
||||
exit();
|
||||
}
|
||||
|
||||
require_once(dirname(dirname(__FILE__)).'/config.php');
|
||||
require_once($CFG->libdir.'/eventslib.php');
|
||||
require_once($CFG->dirroot.'/lib/uploadlib.php'); // contains virus handling stuff.
|
||||
|
||||
$site = get_site();
|
||||
|
||||
while(!feof($fd)) {
|
||||
$entry = fgets($fd);
|
||||
if (strlen(trim($entry)) == 0) {
|
||||
continue;
|
||||
}
|
||||
if (!$file = validate_line($entry)) {
|
||||
continue;
|
||||
}
|
||||
$bits = explode('/',$file);
|
||||
$a->filename = $bits[count($bits)-1];
|
||||
|
||||
if (!$log = $DB->get_record("log", array("module"=>"upload", "info"=>$file, "action"=>"upload"))) {
|
||||
$a->action = clam_handle_infected_file($file,0,false);
|
||||
clam_replace_infected_file($file);
|
||||
notify_admins_unknown($file,$a);
|
||||
continue;
|
||||
}
|
||||
$action = clam_handle_infected_file($file,$log->userid,true);
|
||||
clam_replace_infected_file($file);
|
||||
|
||||
list($ctxselect, $ctxjoin) = context_instance_preload_sql('c.id', CONTEXT_COURSE, 'ctx');
|
||||
$sql = "SELECT c.id, c.fullname $ctxselect FROM {course} c $ctxjoin WHERE c.id = :courseid";
|
||||
$course = $DB->get_record_sql($sql, array('courseid' => $log->course));
|
||||
context_instance_preload($course);
|
||||
|
||||
$user = $DB->get_record("user", array("id"=>$log->userid));
|
||||
$subject = get_string('virusfoundsubject','moodle',format_string($site->fullname));
|
||||
$a->date = userdate($log->time);
|
||||
|
||||
$a->action = $action;
|
||||
$a->course = format_string($course->fullname, true, array('context' => get_context_instance(CONTEXT_COURSE, $course->id)));
|
||||
$a->user = fullname($user);
|
||||
|
||||
notify_user($user,$subject,$a);
|
||||
notify_admins($user,$subject,$a);
|
||||
}
|
||||
fclose($fd);
|
||||
|
||||
|
||||
function notify_user($user,$subject,$a) {
|
||||
|
||||
if (!$user) {
|
||||
return false;
|
||||
}
|
||||
$body = get_string('virusfoundlater','moodle',$a);
|
||||
|
||||
$eventdata = new stdClass();
|
||||
$eventdata->modulename = 'moodle';
|
||||
$eventdata->userfrom = get_admin();
|
||||
$eventdata->userto = $user;
|
||||
$eventdata->subject = $subject;
|
||||
$eventdata->fullmessage = $body;
|
||||
$eventdata->fullmessageformat = FORMAT_PLAIN;
|
||||
$eventdata->fullmessagehtml = '';
|
||||
$eventdata->smallmessage = '';
|
||||
message_send($eventdata);
|
||||
}
|
||||
|
||||
|
||||
function notify_admins($user,$subject,$a) {
|
||||
|
||||
$admins = get_admins();
|
||||
|
||||
$body = get_string('virusfoundlateradmin','moodle',$a);
|
||||
foreach ($admins as $admin) {
|
||||
$eventdata = new stdClass();
|
||||
$eventdata->modulename = 'moodle';
|
||||
$eventdata->userfrom = $admin;
|
||||
$eventdata->userto = $admin;
|
||||
$eventdata->subject = $subject;
|
||||
$eventdata->fullmessage = $body;
|
||||
$eventdata->fullmessageformat = FORMAT_PLAIN;
|
||||
$eventdata->fullmessagehtml = '';
|
||||
$eventdata->smallmessage = '';
|
||||
message_send($eventdata);
|
||||
}
|
||||
}
|
||||
|
||||
function notify_admins_unknown($file,$a) {
|
||||
|
||||
global $site;
|
||||
|
||||
$admins = get_admins();
|
||||
$subject = get_string('virusfoundsubject','moodle',format_string($site->fullname));
|
||||
$body = get_string('virusfoundlateradminnolog','moodle',$a);
|
||||
foreach ($admins as $admin) {
|
||||
$eventdata = new stdClass();
|
||||
$eventdata->modulename = 'moodle';
|
||||
$eventdata->userfrom = $admin;
|
||||
$eventdata->userto = $admin;
|
||||
$eventdata->subject = $subject;
|
||||
$eventdata->fullmessage = $body;
|
||||
$eventdata->fullmessageformat = FORMAT_PLAIN;
|
||||
$eventdata->fullmessagehtml = '';
|
||||
$eventdata->smallmessage = '';
|
||||
message_send($eventdata);
|
||||
}
|
||||
}
|
||||
|
||||
function validate_line($line) {
|
||||
global $CFG;
|
||||
if (strpos($line,"FOUND") === false) {
|
||||
return false;
|
||||
}
|
||||
$index = strpos($line,":");
|
||||
$file = substr($line,0,$index);
|
||||
if (!(strpos($file,$CFG->dataroot) === false)) {
|
||||
if (!file_exists($file)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if ($file{0} == "/") {
|
||||
$file = $CFG->dataroot.$file;
|
||||
}
|
||||
else {
|
||||
$file = $CFG->dataroot."/".$file;
|
||||
}
|
||||
if (!file_exists($file)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
// clean up
|
||||
$file = preg_replace('/\.\//','/',$file);
|
||||
$file = preg_replace('/\/\//','/',$file);
|
||||
return $file;
|
||||
}
|
||||
|
||||
|
||||
+86
-250
@@ -30,10 +30,10 @@ if (!file_exists('../config.php')) {
|
||||
}
|
||||
|
||||
// Check that PHP is of a sufficient version as soon as possible
|
||||
if (version_compare(phpversion(), '5.4.4') < 0) {
|
||||
if (version_compare(phpversion(), '5.3.2') < 0) {
|
||||
$phpversion = phpversion();
|
||||
// do NOT localise - lang strings would not work here and we CAN NOT move it to later place
|
||||
echo "Moodle 2.7 or later requires at least PHP 5.4.4 (currently using version $phpversion).<br />";
|
||||
echo "Moodle 2.1 or later requires at least PHP 5.3.2 (currently using version $phpversion).<br />";
|
||||
echo "Please upgrade your server software or install older Moodle version.";
|
||||
die();
|
||||
}
|
||||
@@ -45,86 +45,36 @@ if (!function_exists('iconv')) {
|
||||
die();
|
||||
}
|
||||
|
||||
// Make sure php5-json is available.
|
||||
if (!function_exists('json_encode') || !function_exists('json_decode')) {
|
||||
// This also shouldn't happen.
|
||||
echo 'Moodle requires the json PHP extension. Please install or enable the json extension.';
|
||||
die();
|
||||
}
|
||||
|
||||
define('NO_OUTPUT_BUFFERING', true);
|
||||
|
||||
if ((isset($_GET['cache']) and $_GET['cache'] === '0')
|
||||
or (isset($_POST['cache']) and $_POST['cache'] === '0')
|
||||
or (!isset($_POST['cache']) and !isset($_GET['cache']) and empty($_GET['sesskey']) and empty($_POST['sesskey']))) {
|
||||
// Prevent caching at all cost when visiting this page directly,
|
||||
// we redirect to self once we known no upgrades are necessary.
|
||||
// Note: $_GET and $_POST are used here intentionally because our param cleaning is not loaded yet.
|
||||
// Note2: the sesskey is present in all block editing hacks, we can not redirect there, so enable caching.
|
||||
define('CACHE_DISABLE_ALL', true);
|
||||
|
||||
// Force OPcache reset if used, we do not want any stale caches
|
||||
// when detecting if upgrade necessary or when running upgrade.
|
||||
if (function_exists('opcache_reset')) {
|
||||
opcache_reset();
|
||||
}
|
||||
$cache = 0;
|
||||
|
||||
} else {
|
||||
$cache = 1;
|
||||
}
|
||||
|
||||
require('../config.php');
|
||||
|
||||
// Invalidate the cache of version.php in any circumstances to help core_component
|
||||
// detecting if the version has changed and component cache should be reset.
|
||||
if (function_exists('opcache_invalidate')) {
|
||||
opcache_invalidate($CFG->dirroot . '/version.php', true);
|
||||
}
|
||||
// Make sure the component cache gets rebuilt if necessary, any method that
|
||||
// indirectly calls the protected init() method is good here.
|
||||
core_component::get_core_subsystems();
|
||||
|
||||
require_once($CFG->libdir.'/adminlib.php'); // various admin-only functions
|
||||
require_once($CFG->libdir.'/upgradelib.php'); // general upgrade/install related functions
|
||||
require_once($CFG->libdir.'/pluginlib.php'); // available updates notifications
|
||||
|
||||
$id = optional_param('id', '', PARAM_TEXT);
|
||||
$confirmupgrade = optional_param('confirmupgrade', 0, PARAM_BOOL);
|
||||
$confirmrelease = optional_param('confirmrelease', 0, PARAM_BOOL);
|
||||
$confirmplugins = optional_param('confirmplugincheck', 0, PARAM_BOOL);
|
||||
$showallplugins = optional_param('showallplugins', 0, PARAM_BOOL);
|
||||
$agreelicense = optional_param('agreelicense', 0, PARAM_BOOL);
|
||||
$fetchupdates = optional_param('fetchupdates', 0, PARAM_BOOL);
|
||||
$newaddonreq = optional_param('installaddonrequest', null, PARAM_RAW);
|
||||
|
||||
// Set up PAGE.
|
||||
$url = new moodle_url('/admin/index.php');
|
||||
$url->param('cache', $cache);
|
||||
$PAGE->set_url($url);
|
||||
unset($url);
|
||||
|
||||
// Are we returning from an add-on installation request at moodle.org/plugins?
|
||||
if ($newaddonreq and !$cache and empty($CFG->disableonclickaddoninstall)) {
|
||||
$target = new moodle_url('/admin/tool/installaddon/index.php', array(
|
||||
'installaddonrequest' => $newaddonreq,
|
||||
'confirm' => 0));
|
||||
if (!isloggedin() or isguestuser()) {
|
||||
// Login and go the the add-on tool page.
|
||||
$SESSION->wantsurl = $target->out();
|
||||
redirect(get_login_url());
|
||||
}
|
||||
redirect($target);
|
||||
}
|
||||
// Check some PHP server settings
|
||||
|
||||
$PAGE->set_url('/admin/index.php');
|
||||
$PAGE->set_pagelayout('admin'); // Set a default pagelayout
|
||||
|
||||
$documentationlink = '<a href="http://docs.moodle.org/en/Installation">Installation docs</a>';
|
||||
|
||||
// Check some PHP server settings
|
||||
|
||||
if (ini_get_bool('session.auto_start')) {
|
||||
print_error('phpvaroff', 'debug', '', (object)array('name'=>'session.auto_start', 'link'=>$documentationlink));
|
||||
}
|
||||
|
||||
if (ini_get_bool('magic_quotes_runtime')) {
|
||||
print_error('phpvaroff', 'debug', '', (object)array('name'=>'magic_quotes_runtime', 'link'=>$documentationlink));
|
||||
}
|
||||
|
||||
if (!ini_get_bool('file_uploads')) {
|
||||
print_error('phpvaron', 'debug', '', (object)array('name'=>'file_uploads', 'link'=>$documentationlink));
|
||||
}
|
||||
@@ -154,6 +104,10 @@ if (!$version or !$release) {
|
||||
print_error('withoutversion', 'debug'); // without version, stop
|
||||
}
|
||||
|
||||
// Turn off xmlstrictheaders during upgrade.
|
||||
$origxmlstrictheaders = !empty($CFG->xmlstrictheaders);
|
||||
$CFG->xmlstrictheaders = false;
|
||||
|
||||
if (!core_tables_exist()) {
|
||||
$PAGE->set_pagelayout('maintenance');
|
||||
$PAGE->set_popup_notification_allowed(false);
|
||||
@@ -164,7 +118,7 @@ if (!core_tables_exist()) {
|
||||
$strinstallation = get_string('installation', 'install');
|
||||
|
||||
// remove current session content completely
|
||||
\core\session\manager::terminate_current();
|
||||
session_get_instance()->terminate_current();
|
||||
|
||||
if (empty($agreelicense)) {
|
||||
$strlicense = get_string('license');
|
||||
@@ -174,7 +128,6 @@ if (!core_tables_exist()) {
|
||||
$PAGE->set_heading($strinstallation);
|
||||
$PAGE->set_cacheable(false);
|
||||
|
||||
/** @var core_admin_renderer $output */
|
||||
$output = $PAGE->get_renderer('core', 'admin');
|
||||
echo $output->install_licence_page();
|
||||
die();
|
||||
@@ -189,7 +142,6 @@ if (!core_tables_exist()) {
|
||||
$PAGE->set_heading($strinstallation . ' - Moodle ' . $CFG->target_release);
|
||||
$PAGE->set_cacheable(false);
|
||||
|
||||
/** @var core_admin_renderer $output */
|
||||
$output = $PAGE->get_renderer('core', 'admin');
|
||||
echo $output->install_environment_page($maturity, $envstatus, $environment_results, $release);
|
||||
die();
|
||||
@@ -197,7 +149,7 @@ if (!core_tables_exist()) {
|
||||
|
||||
// check plugin dependencies
|
||||
$failed = array();
|
||||
if (!core_plugin_manager::instance()->all_plugins_ok($version, $failed)) {
|
||||
if (!plugin_manager::instance()->all_plugins_ok($version, $failed)) {
|
||||
$PAGE->navbar->add(get_string('pluginscheck', 'admin'));
|
||||
$PAGE->set_title($strinstallation);
|
||||
$PAGE->set_heading($strinstallation . ' - Moodle ' . $CFG->target_release);
|
||||
@@ -236,65 +188,39 @@ if (!core_tables_exist()) {
|
||||
// Check version of Moodle code on disk compared with database
|
||||
// and upgrade if possible.
|
||||
|
||||
if (!$cache) {
|
||||
// Do not try to do anything fancy in non-cached mode,
|
||||
// this prevents themes from fetching data from non-existent tables.
|
||||
$PAGE->set_pagelayout('maintenance');
|
||||
$PAGE->set_popup_notification_allowed(false);
|
||||
}
|
||||
|
||||
$stradministration = get_string('administration');
|
||||
$PAGE->set_context(context_system::instance());
|
||||
$PAGE->set_context(get_context_instance(CONTEXT_SYSTEM));
|
||||
|
||||
if (empty($CFG->version)) {
|
||||
print_error('missingconfigversion', 'debug');
|
||||
}
|
||||
|
||||
// Detect config cache inconsistency, this happens when you switch branches on dev servers.
|
||||
if ($CFG->version != $DB->get_field('config', 'value', array('name'=>'version'))) {
|
||||
if ($version > $CFG->version) { // upgrade
|
||||
purge_all_caches();
|
||||
redirect(new moodle_url('/admin/index.php'), 'Config cache inconsistency detected, resetting caches...');
|
||||
}
|
||||
|
||||
if (!$cache and $version > $CFG->version) { // upgrade
|
||||
|
||||
// Warning about upgrading a test site.
|
||||
$testsite = false;
|
||||
if (defined('BEHAT_SITE_RUNNING')) {
|
||||
$testsite = 'behat';
|
||||
}
|
||||
|
||||
// We purge all of MUC's caches here.
|
||||
// Caches are disabled for upgrade by CACHE_DISABLE_ALL so we must set the first arg to true.
|
||||
// This ensures a real config object is loaded and the stores will be purged.
|
||||
// This is the only way we can purge custom caches such as memcache or APC.
|
||||
// Note: all other calls to caches will still used the disabled API.
|
||||
cache_helper::purge_all(true);
|
||||
// We then purge the regular caches.
|
||||
purge_all_caches();
|
||||
|
||||
/** @var core_admin_renderer $output */
|
||||
$output = $PAGE->get_renderer('core', 'admin');
|
||||
$PAGE->set_pagelayout('maintenance');
|
||||
$PAGE->set_popup_notification_allowed(false);
|
||||
|
||||
if (upgrade_stale_php_files_present()) {
|
||||
$PAGE->set_title($stradministration);
|
||||
$PAGE->set_cacheable(false);
|
||||
|
||||
$output = $PAGE->get_renderer('core', 'admin');
|
||||
echo $output->upgrade_stale_php_files_page();
|
||||
die();
|
||||
}
|
||||
|
||||
if (empty($confirmupgrade)) {
|
||||
$a = new stdClass();
|
||||
$a->oldversion = "$CFG->release (".sprintf('%.2f', $CFG->version).")";
|
||||
$a->newversion = "$release (".sprintf('%.2f', $version).")";
|
||||
$a->oldversion = "$CFG->release ($CFG->version)";
|
||||
$a->newversion = "$release ($version)";
|
||||
$strdatabasechecking = get_string('databasechecking', '', $a);
|
||||
|
||||
$PAGE->set_title($stradministration);
|
||||
$PAGE->set_heading($strdatabasechecking);
|
||||
$PAGE->set_cacheable(false);
|
||||
|
||||
echo $output->upgrade_confirm_page($a->newversion, $maturity, $testsite);
|
||||
$output = $PAGE->get_renderer('core', 'admin');
|
||||
echo $output->upgrade_confirm_page($a->newversion, $maturity);
|
||||
die();
|
||||
|
||||
} else if (empty($confirmrelease)){
|
||||
@@ -307,6 +233,7 @@ if (!$cache and $version > $CFG->version) { // upgrade
|
||||
$PAGE->set_heading($strcurrentrelease);
|
||||
$PAGE->set_cacheable(false);
|
||||
|
||||
$output = $PAGE->get_renderer('core', 'admin');
|
||||
echo $output->upgrade_environment_page($release, $envstatus, $environment_results);
|
||||
die();
|
||||
|
||||
@@ -318,45 +245,33 @@ if (!$cache and $version > $CFG->version) { // upgrade
|
||||
$PAGE->set_heading($strplugincheck);
|
||||
$PAGE->set_cacheable(false);
|
||||
|
||||
$reloadurl = new moodle_url('/admin/index.php', array('confirmupgrade' => 1, 'confirmrelease' => 1, 'cache' => 0));
|
||||
$reloadurl = new moodle_url('/admin/index.php', array('confirmupgrade' => 1, 'confirmrelease' => 1));
|
||||
|
||||
if ($fetchupdates) {
|
||||
// No sesskey support guaranteed here, because sessions might not work yet.
|
||||
$updateschecker = \core\update\checker::instance();
|
||||
if ($updateschecker->enabled()) {
|
||||
$updateschecker->fetch();
|
||||
}
|
||||
redirect($reloadurl);
|
||||
}
|
||||
|
||||
$deployer = \core\update\deployer::instance();
|
||||
if ($deployer->enabled()) {
|
||||
$deployer->initialize($reloadurl, $reloadurl);
|
||||
|
||||
$deploydata = $deployer->submitted_data();
|
||||
if (!empty($deploydata)) {
|
||||
// No sesskey support guaranteed here, because sessions might not work yet.
|
||||
echo $output->upgrade_plugin_confirm_deploy_page($deployer, $deploydata);
|
||||
die();
|
||||
}
|
||||
}
|
||||
|
||||
echo $output->upgrade_plugin_check_page(core_plugin_manager::instance(), \core\update\checker::instance(),
|
||||
$version, $showallplugins, $reloadurl,
|
||||
new moodle_url('/admin/index.php', array('confirmupgrade'=>1, 'confirmrelease'=>1, 'confirmplugincheck'=>1, 'cache'=>0)));
|
||||
die();
|
||||
|
||||
} else {
|
||||
// Always verify plugin dependencies!
|
||||
// check plugin dependencies first
|
||||
$failed = array();
|
||||
if (!core_plugin_manager::instance()->all_plugins_ok($version, $failed)) {
|
||||
$reloadurl = new moodle_url('/admin/index.php', array('confirmupgrade' => 1, 'confirmrelease' => 1, 'cache' => 0));
|
||||
if (!plugin_manager::instance()->all_plugins_ok($version, $failed)) {
|
||||
$output = $PAGE->get_renderer('core', 'admin');
|
||||
echo $output->unsatisfied_dependencies_page($version, $failed, $reloadurl);
|
||||
die();
|
||||
}
|
||||
unset($failed);
|
||||
|
||||
// Launch main upgrade.
|
||||
if ($fetchupdates) {
|
||||
// no sesskey support guaranteed here
|
||||
if (empty($CFG->disableupdatenotifications)) {
|
||||
available_update_checker::instance()->fetch();
|
||||
}
|
||||
redirect($reloadurl);
|
||||
}
|
||||
|
||||
$output = $PAGE->get_renderer('core', 'admin');
|
||||
echo $output->upgrade_plugin_check_page(plugin_manager::instance(), available_update_checker::instance(),
|
||||
$version, $showallplugins, $reloadurl,
|
||||
new moodle_url('/admin/index.php', array('confirmupgrade'=>1, 'confirmrelease'=>1, 'confirmplugincheck'=>1)));
|
||||
die();
|
||||
|
||||
} else {
|
||||
// Launch main upgrade
|
||||
upgrade_core($version, true);
|
||||
}
|
||||
} else if ($version < $CFG->version) {
|
||||
@@ -365,70 +280,51 @@ if (!$cache and $version > $CFG->version) { // upgrade
|
||||
}
|
||||
|
||||
// Updated human-readable release version if necessary
|
||||
if (!$cache and $release <> $CFG->release) { // Update the release version
|
||||
if ($release <> $CFG->release) { // Update the release version
|
||||
set_config('release', $release);
|
||||
}
|
||||
|
||||
if (!$cache and $branch <> $CFG->branch) { // Update the branch
|
||||
if ($branch <> $CFG->branch) { // Update the branch
|
||||
set_config('branch', $branch);
|
||||
}
|
||||
|
||||
if (!$cache and moodle_needs_upgrading()) {
|
||||
if (moodle_needs_upgrading()) {
|
||||
if (!$PAGE->headerprinted) {
|
||||
// means core upgrade or installation was not already done
|
||||
|
||||
if (!$confirmplugins) {
|
||||
$strplugincheck = get_string('plugincheck');
|
||||
|
||||
$PAGE->set_pagelayout('maintenance');
|
||||
$PAGE->set_popup_notification_allowed(false);
|
||||
$PAGE->navbar->add($strplugincheck);
|
||||
$PAGE->set_title($strplugincheck);
|
||||
$PAGE->set_heading($strplugincheck);
|
||||
$PAGE->set_cacheable(false);
|
||||
|
||||
if ($fetchupdates) {
|
||||
require_sesskey();
|
||||
$updateschecker = \core\update\checker::instance();
|
||||
if ($updateschecker->enabled()) {
|
||||
$updateschecker->fetch();
|
||||
}
|
||||
// no sesskey support guaranteed here
|
||||
available_update_checker::instance()->fetch();
|
||||
redirect($PAGE->url);
|
||||
}
|
||||
|
||||
/** @var core_admin_renderer $output */
|
||||
$output = $PAGE->get_renderer('core', 'admin');
|
||||
|
||||
$deployer = \core\update\deployer::instance();
|
||||
if ($deployer->enabled()) {
|
||||
$deployer->initialize($PAGE->url, $PAGE->url);
|
||||
|
||||
$deploydata = $deployer->submitted_data();
|
||||
if (!empty($deploydata)) {
|
||||
require_sesskey();
|
||||
echo $output->upgrade_plugin_confirm_deploy_page($deployer, $deploydata);
|
||||
die();
|
||||
}
|
||||
// check plugin dependencies first
|
||||
$failed = array();
|
||||
if (!plugin_manager::instance()->all_plugins_ok($version, $failed)) {
|
||||
echo $output->unsatisfied_dependencies_page($version, $failed, $PAGE->url);
|
||||
die();
|
||||
}
|
||||
unset($failed);
|
||||
|
||||
// Show plugins info.
|
||||
echo $output->upgrade_plugin_check_page(core_plugin_manager::instance(), \core\update\checker::instance(),
|
||||
// dependencies check passed, let's rock!
|
||||
echo $output->upgrade_plugin_check_page(plugin_manager::instance(), available_update_checker::instance(),
|
||||
$version, $showallplugins,
|
||||
new moodle_url($PAGE->url),
|
||||
new moodle_url('/admin/index.php', array('confirmplugincheck'=>1, 'cache'=>0)));
|
||||
new moodle_url('/admin/index.php', array('confirmplugincheck'=>1)));
|
||||
die();
|
||||
}
|
||||
|
||||
// Make sure plugin dependencies are always checked.
|
||||
$failed = array();
|
||||
if (!core_plugin_manager::instance()->all_plugins_ok($version, $failed)) {
|
||||
/** @var core_admin_renderer $output */
|
||||
$output = $PAGE->get_renderer('core', 'admin');
|
||||
$reloadurl = new moodle_url('/admin/index.php', array('cache' => 0));
|
||||
echo $output->unsatisfied_dependencies_page($version, $failed, $reloadurl);
|
||||
die();
|
||||
}
|
||||
unset($failed);
|
||||
}
|
||||
|
||||
// install/upgrade all plugins and other parts
|
||||
upgrade_noncore(true);
|
||||
}
|
||||
@@ -461,10 +357,6 @@ if (during_initial_install()) {
|
||||
}
|
||||
}
|
||||
|
||||
// Cleanup SESSION to make sure other code does not complain in the future.
|
||||
unset($SESSION->has_timed_out);
|
||||
unset($SESSION->wantsurl);
|
||||
|
||||
// at this stage there can be only one admin unless more were added by install - users may change username, so do not rely on that
|
||||
$adminids = explode(',', $CFG->siteadmins);
|
||||
$adminuser = get_complete_user_data('id', reset($adminids));
|
||||
@@ -488,40 +380,14 @@ if (during_initial_install()) {
|
||||
upgrade_finished('upgradesettings.php');
|
||||
}
|
||||
|
||||
if (has_capability('moodle/site:config', context_system::instance())) {
|
||||
if ($fetchupdates) {
|
||||
require_sesskey();
|
||||
$updateschecker = \core\update\checker::instance();
|
||||
if ($updateschecker->enabled()) {
|
||||
$updateschecker->fetch();
|
||||
}
|
||||
redirect(new moodle_url('/admin/index.php', array('cache' => 0)));
|
||||
}
|
||||
}
|
||||
|
||||
// Now we can be sure everything was upgraded and caches work fine,
|
||||
// redirect if necessary to make sure caching is enabled.
|
||||
if (!$cache) {
|
||||
redirect(new moodle_url('/admin/index.php', array('cache' => 1)));
|
||||
}
|
||||
// Turn xmlstrictheaders back on now.
|
||||
$CFG->xmlstrictheaders = $origxmlstrictheaders;
|
||||
unset($origxmlstrictheaders);
|
||||
|
||||
// Check for valid admin user - no guest autologin
|
||||
require_login(0, false);
|
||||
if (isguestuser()) {
|
||||
// Login as real user!
|
||||
$SESSION->wantsurl = (string)new moodle_url('/admin/index.php');
|
||||
redirect(get_login_url());
|
||||
}
|
||||
$context = context_system::instance();
|
||||
|
||||
if (!has_capability('moodle/site:config', $context)) {
|
||||
// Do not throw exception display an empty page with administration menu if visible for current user.
|
||||
$PAGE->set_title($SITE->fullname);
|
||||
$PAGE->set_heading($SITE->fullname);
|
||||
echo $OUTPUT->header();
|
||||
echo $OUTPUT->footer();
|
||||
exit;
|
||||
}
|
||||
$context = get_context_instance(CONTEXT_SYSTEM);
|
||||
require_capability('moodle/site:config', $context);
|
||||
|
||||
// check that site is properly customized
|
||||
$site = get_site();
|
||||
@@ -529,10 +395,14 @@ if (empty($site->shortname)) {
|
||||
// probably new installation - lets return to frontpage after this step
|
||||
// remove settings that we want uninitialised
|
||||
unset_config('registerauth');
|
||||
unset_config('timezone'); // Force admin to select timezone!
|
||||
redirect('upgradesettings.php?return=site');
|
||||
}
|
||||
|
||||
// Check if we are returning from moodle.org registration and if so, we mark that fact to remove reminders
|
||||
if (!empty($id) and $id == $CFG->siteidentifier) {
|
||||
set_config('registered', time());
|
||||
}
|
||||
|
||||
// setup critical warnings before printing admin tree block
|
||||
$insecuredataroot = is_dataroot_insecure(true);
|
||||
$SESSION->admin_critical_warning = ($insecuredataroot==INSECURE_DATAROOT_ERROR);
|
||||
@@ -544,68 +414,34 @@ if (any_new_admin_settings($adminroot)){
|
||||
redirect('upgradesettings.php');
|
||||
}
|
||||
|
||||
// Return to original page that started the plugin uninstallation if necessary.
|
||||
if (isset($SESSION->pluginuninstallreturn)) {
|
||||
$return = $SESSION->pluginuninstallreturn;
|
||||
unset($SESSION->pluginuninstallreturn);
|
||||
if ($return) {
|
||||
redirect($return);
|
||||
}
|
||||
}
|
||||
|
||||
// Everything should now be set up, and the user is an admin
|
||||
|
||||
// Print default admin page with notifications.
|
||||
$errorsdisplayed = defined('WARN_DISPLAY_ERRORS_ENABLED');
|
||||
|
||||
// We make the assumption that at least one schedule task should run once per day.
|
||||
$lastcron = $DB->get_field_sql('SELECT MAX(lastruntime) FROM {task_scheduled}');
|
||||
$lastcron = $DB->get_field_sql('SELECT MAX(lastcron) FROM {modules}');
|
||||
$cronoverdue = ($lastcron < time() - 3600 * 24);
|
||||
$dbproblems = $DB->diagnose();
|
||||
$maintenancemode = !empty($CFG->maintenance_enabled);
|
||||
|
||||
// Available updates for Moodle core.
|
||||
$updateschecker = \core\update\checker::instance();
|
||||
$availableupdates = array();
|
||||
$availableupdatesfetch = null;
|
||||
|
||||
if (empty($CFG->disableupdatenotifications)) {
|
||||
// Only compute the update information when it is going to be displayed to the user.
|
||||
$availableupdates['core'] = $updateschecker->get_update_info('core',
|
||||
array('minmaturity' => $CFG->updateminmaturity, 'notifybuilds' => $CFG->updatenotifybuilds));
|
||||
|
||||
// Available updates for contributed plugins
|
||||
$pluginman = core_plugin_manager::instance();
|
||||
foreach ($pluginman->get_plugins() as $plugintype => $plugintypeinstances) {
|
||||
foreach ($plugintypeinstances as $pluginname => $plugininfo) {
|
||||
if (!empty($plugininfo->availableupdates)) {
|
||||
foreach ($plugininfo->availableupdates as $pluginavailableupdate) {
|
||||
if ($pluginavailableupdate->version > $plugininfo->versiondisk) {
|
||||
if (!isset($availableupdates[$plugintype.'_'.$pluginname])) {
|
||||
$availableupdates[$plugintype.'_'.$pluginname] = array();
|
||||
}
|
||||
$availableupdates[$plugintype.'_'.$pluginname][] = $pluginavailableupdate;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// The timestamp of the most recent check for available updates
|
||||
$availableupdatesfetch = $updateschecker->get_last_timefetched();
|
||||
}
|
||||
$updateschecker = available_update_checker::instance();
|
||||
$availableupdates = $updateschecker->get_update_info('core',
|
||||
array('minmaturity' => $CFG->updateminmaturity, 'notifybuilds' => $CFG->updatenotifybuilds));
|
||||
$availableupdatesfetch = $updateschecker->get_last_timefetched();
|
||||
|
||||
$buggyiconvnomb = (!function_exists('mb_convert_encoding') and @iconv('UTF-8', 'UTF-8//IGNORE', '100'.chr(130).'€') !== '100€');
|
||||
//check if the site is registered on Moodle.org
|
||||
$registered = $DB->count_records('registration_hubs', array('huburl' => HUB_MOODLEORGHUBURL, 'confirmed' => 1));
|
||||
// Check if there are any cache warnings.
|
||||
$cachewarnings = cache_helper::warnings();
|
||||
|
||||
admin_externalpage_setup('adminnotifications');
|
||||
|
||||
/* @var core_admin_renderer $output */
|
||||
$output = $PAGE->get_renderer('core', 'admin');
|
||||
if ($fetchupdates) {
|
||||
require_sesskey();
|
||||
$updateschecker->fetch();
|
||||
redirect($PAGE->url);
|
||||
}
|
||||
|
||||
echo $output->admin_notifications_page($maturity, $insecuredataroot, $errorsdisplayed, $cronoverdue, $dbproblems,
|
||||
$maintenancemode, $availableupdates, $availableupdatesfetch, $buggyiconvnomb,
|
||||
$registered, $cachewarnings);
|
||||
$output = $PAGE->get_renderer('core', 'admin');
|
||||
echo $output->admin_notifications_page($maturity, $insecuredataroot, $errorsdisplayed,
|
||||
$cronoverdue, $dbproblems, $maintenancemode, $availableupdates, $availableupdatesfetch, $buggyiconvnomb,
|
||||
$registered);
|
||||
|
||||
+12
-1
@@ -18,7 +18,7 @@
|
||||
/**
|
||||
* This file contains functions used by the admin pages
|
||||
*
|
||||
* @since Moodle 2.1
|
||||
* @since 2.1
|
||||
* @package admin
|
||||
* @copyright 2011 Andrew Davis
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
@@ -35,5 +35,16 @@ function admin_page_type_list($pagetype, $parentcontext, $currentcontext) {
|
||||
'admin-*' => get_string('page-admin-x', 'pagetype'),
|
||||
$pagetype => get_string('page-admin-current', 'pagetype')
|
||||
);
|
||||
// Add the missing * (any page) option for them. MDL-30340
|
||||
// TODO: These pages are really 'pagetype-varying' - MDL-30564 -
|
||||
// and some day we should stop behaving that way, so proper pagetypes
|
||||
// can be specified for it (like course-category-* or so).
|
||||
// Luckly... the option we are introducing '*' is independent
|
||||
// of that varying behavior, so will work.
|
||||
if ($pagetype == 'admin-course-category') {
|
||||
$array += array(
|
||||
'*' => get_string('page-x', 'pagetype')
|
||||
);
|
||||
}
|
||||
return $array;
|
||||
}
|
||||
|
||||
+2
-2
@@ -24,11 +24,11 @@ require_once($CFG->libdir.'/adminlib.php');
|
||||
require_once($CFG->libdir.'/licenselib.php');
|
||||
|
||||
require_login();
|
||||
require_capability('moodle/site:config', context_system::instance());
|
||||
require_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM));
|
||||
|
||||
$returnurl = "$CFG->wwwroot/$CFG->admin/settings.php?section=managelicenses";
|
||||
|
||||
$action = optional_param('action', '', PARAM_ALPHANUMEXT);
|
||||
$action = optional_param('action', '', PARAM_ACTION);
|
||||
$license = optional_param('license', '', PARAM_SAFEDIR);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
+42
-10
@@ -33,21 +33,55 @@ require_once($CFG->libdir.'/tablelib.php');
|
||||
|
||||
admin_externalpage_setup('managelocalplugins');
|
||||
|
||||
$delete = optional_param('delete', '', PARAM_PLUGIN);
|
||||
$confirm = optional_param('confirm', '', PARAM_BOOL);
|
||||
|
||||
/// If data submitted, then process and store.
|
||||
|
||||
if (!empty($delete) and confirm_sesskey()) {
|
||||
echo $OUTPUT->header();
|
||||
echo $OUTPUT->heading(get_string('localplugins'));
|
||||
|
||||
if (!$confirm) {
|
||||
if (get_string_manager()->string_exists('pluginname', 'local_' . $delete)) {
|
||||
$strpluginname = get_string('pluginname', 'local_' . $delete);
|
||||
} else {
|
||||
$strpluginname = $delete;
|
||||
}
|
||||
echo $OUTPUT->confirm(get_string('localplugindeleteconfirm', '', $strpluginname),
|
||||
new moodle_url($PAGE->url, array('delete' => $delete, 'confirm' => 1)),
|
||||
$PAGE->url);
|
||||
echo $OUTPUT->footer();
|
||||
die();
|
||||
|
||||
} else {
|
||||
uninstall_plugin('local', $delete);
|
||||
$a = new stdclass();
|
||||
$a->name = $delete;
|
||||
$pluginlocation = get_plugin_types();
|
||||
$a->directory = $pluginlocation['local'] . '/' . $delete;
|
||||
echo $OUTPUT->notification(get_string('plugindeletefiles', '', $a), 'notifysuccess');
|
||||
echo $OUTPUT->continue_button($PAGE->url);
|
||||
echo $OUTPUT->footer();
|
||||
die();
|
||||
}
|
||||
}
|
||||
|
||||
echo $OUTPUT->header();
|
||||
echo $OUTPUT->heading(get_string('localplugins'));
|
||||
|
||||
/// Print the table of all installed local plugins
|
||||
|
||||
$table = new flexible_table('localplugins_administration_table');
|
||||
$table->define_columns(array('name', 'version', 'uninstall'));
|
||||
$table->define_headers(array(get_string('plugin'), get_string('version'), get_string('uninstallplugin', 'core_admin')));
|
||||
$table->define_columns(array('name', 'version', 'delete'));
|
||||
$table->define_headers(array(get_string('plugin'), get_string('version'), get_string('delete')));
|
||||
$table->define_baseurl($PAGE->url);
|
||||
$table->set_attribute('id', 'localplugins');
|
||||
$table->set_attribute('class', 'admintable generaltable');
|
||||
$table->set_attribute('class', 'generaltable generalbox boxaligncenter boxwidthwide');
|
||||
$table->setup();
|
||||
|
||||
$plugins = array();
|
||||
foreach (core_component::get_plugin_list('local') as $plugin => $plugindir) {
|
||||
foreach (get_plugin_list('local') as $plugin => $plugindir) {
|
||||
if (get_string_manager()->string_exists('pluginname', 'local_' . $plugin)) {
|
||||
$strpluginname = get_string('pluginname', 'local_' . $plugin);
|
||||
} else {
|
||||
@@ -55,13 +89,11 @@ foreach (core_component::get_plugin_list('local') as $plugin => $plugindir) {
|
||||
}
|
||||
$plugins[$plugin] = $strpluginname;
|
||||
}
|
||||
core_collator::asort($plugins);
|
||||
collatorlib::asort($plugins);
|
||||
|
||||
foreach ($plugins as $plugin => $name) {
|
||||
$uninstall = '';
|
||||
if ($uninstallurl = core_plugin_manager::instance()->get_uninstall_url('local_'.$plugin, 'manage')) {
|
||||
$uninstall = html_writer::link($uninstallurl, get_string('uninstallplugin', 'core_admin'));
|
||||
}
|
||||
$delete = new moodle_url($PAGE->url, array('delete' => $plugin, 'sesskey' => sesskey()));
|
||||
$delete = html_writer::link($delete, get_string('delete'));
|
||||
|
||||
$version = get_config('local_' . $plugin);
|
||||
if (!empty($version->version)) {
|
||||
@@ -70,7 +102,7 @@ foreach ($plugins as $plugin => $name) {
|
||||
$version = '?';
|
||||
}
|
||||
|
||||
$table->add_data(array($name, $version, $uninstall));
|
||||
$table->add_data(array($name, $version, $delete));
|
||||
}
|
||||
|
||||
$table->print_html();
|
||||
|
||||
+30
-6
@@ -29,11 +29,13 @@ require_once($CFG->libdir.'/adminlib.php');
|
||||
admin_externalpage_setup('managemessageoutputs');
|
||||
|
||||
// Require site configuration capability
|
||||
require_capability('moodle/site:config', context_system::instance());
|
||||
require_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM));
|
||||
|
||||
// Get the submitted params
|
||||
$disable = optional_param('disable', 0, PARAM_INT);
|
||||
$enable = optional_param('enable', 0, PARAM_INT);
|
||||
$uninstall = optional_param('uninstall', 0, PARAM_INT);
|
||||
$confirm = optional_param('confirm', false, PARAM_BOOL);
|
||||
|
||||
$headingtitle = get_string('managemessageoutputs', 'message');
|
||||
|
||||
@@ -42,7 +44,6 @@ if (!empty($disable) && confirm_sesskey()) {
|
||||
print_error('outputdoesnotexist', 'message');
|
||||
}
|
||||
$DB->set_field('message_processors', 'enabled', '0', array('id'=>$processor->id)); // Disable output
|
||||
core_plugin_manager::reset_caches();
|
||||
}
|
||||
|
||||
if (!empty($enable) && confirm_sesskey()) {
|
||||
@@ -50,15 +51,38 @@ if (!empty($enable) && confirm_sesskey()) {
|
||||
print_error('outputdoesnotexist', 'message');
|
||||
}
|
||||
$DB->set_field('message_processors', 'enabled', '1', array('id'=>$processor->id)); // Enable output
|
||||
core_plugin_manager::reset_caches();
|
||||
}
|
||||
|
||||
if ($disable || $enable) {
|
||||
if (!empty($uninstall) && confirm_sesskey()) {
|
||||
echo $OUTPUT->header();
|
||||
echo $OUTPUT->heading($headingtitle);
|
||||
|
||||
if (!$processor = $DB->get_record('message_processors', array('id'=>$uninstall))) {
|
||||
print_error('outputdoesnotexist', 'message');
|
||||
}
|
||||
|
||||
$processorname = get_string('pluginname', 'message_'.$processor->name);
|
||||
|
||||
if (!$confirm) {
|
||||
echo $OUTPUT->confirm(get_string('processordeleteconfirm', 'message', $processorname), 'message.php?uninstall='.$processor->id.'&confirm=1', 'message.php');
|
||||
echo $OUTPUT->footer();
|
||||
exit;
|
||||
|
||||
} else {
|
||||
message_processor_uninstall($processor->name);
|
||||
$a = new stdClass();
|
||||
$a->processor = $processorname;
|
||||
$a->directory = $CFG->dirroot.'/message/output/'.$processor->name;
|
||||
notice(get_string('processordeletefiles', 'message', $a), 'message.php');
|
||||
}
|
||||
}
|
||||
|
||||
if ($disable || $enable || $uninstall) {
|
||||
$url = new moodle_url('message.php');
|
||||
redirect($url);
|
||||
}
|
||||
// Page settings
|
||||
$PAGE->set_context(context_system::instance());
|
||||
$PAGE->set_context(get_context_instance(CONTEXT_SYSTEM));
|
||||
|
||||
// Grab the renderer
|
||||
$renderer = $PAGE->get_renderer('core', 'message');
|
||||
@@ -71,4 +95,4 @@ $messageoutputs = $renderer->manage_messageoutputs($processors);
|
||||
echo $OUTPUT->header();
|
||||
echo $OUTPUT->heading($headingtitle);
|
||||
echo $messageoutputs;
|
||||
echo $OUTPUT->footer();
|
||||
echo $OUTPUT->footer();
|
||||
@@ -16,11 +16,13 @@ require_login();
|
||||
|
||||
admin_externalpage_setup('ssoaccesscontrol');
|
||||
|
||||
echo $OUTPUT->header();
|
||||
|
||||
if (!extension_loaded('openssl')) {
|
||||
print_error('requiresopenssl', 'mnet');
|
||||
}
|
||||
|
||||
$sitecontext = context_system::instance();
|
||||
$sitecontext = get_context_instance(CONTEXT_SYSTEM);
|
||||
$sesskey = sesskey();
|
||||
$formerror = array();
|
||||
|
||||
@@ -63,11 +65,9 @@ if (!empty($action) and confirm_sesskey()) {
|
||||
|
||||
if (mnet_update_sso_access_control($idrec->username, $idrec->mnet_host_id, $accessctrl)) {
|
||||
if ($accessctrl == 'allow') {
|
||||
redirect('access_control.php', get_string('ssl_acl_allow','mnet', array('user' => $idrec->username,
|
||||
'host' => $mnethosts[$idrec->mnet_host_id])));
|
||||
} else if ($accessctrl == 'deny') {
|
||||
redirect('access_control.php', get_string('ssl_acl_deny','mnet', array('user' => $idrec->username,
|
||||
'host' => $mnethosts[$idrec->mnet_host_id])));
|
||||
redirect('access_control.php', get_string('ssl_acl_allow','mnet', array('uset'=>$idrec->username, 'host'=>$mnethosts[$idrec->mnet_host_id])));
|
||||
} elseif ($accessctrl == 'deny') {
|
||||
redirect('access_control.php', get_string('ssl_acl_deny','mnet', array('user'=>$idrec->username, 'host'=>$mnethosts[$idrec->mnet_host_id])));
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -103,7 +103,7 @@ if ($form = data_submitted() and confirm_sesskey()) {
|
||||
$usernames = explode(',', $form->username);
|
||||
|
||||
foreach ($usernames as $username) {
|
||||
$username = trim(core_text::strtolower($username));
|
||||
$username = trim(textlib::strtolower($username));
|
||||
if (!empty($username)) {
|
||||
if (mnet_update_sso_access_control($username, $form->mnet_host_id, $form->accessctrl)) {
|
||||
if ($form->accessctrl == 'allow') {
|
||||
@@ -118,8 +118,6 @@ if ($form = data_submitted() and confirm_sesskey()) {
|
||||
exit;
|
||||
}
|
||||
|
||||
echo $OUTPUT->header();
|
||||
|
||||
// Explain
|
||||
echo $OUTPUT->box(get_string('ssoacldescr','mnet'));
|
||||
// Are the needed bits enabled?
|
||||
|
||||
@@ -36,7 +36,7 @@ $hostid = required_param('hostid', PARAM_INT);
|
||||
|
||||
require_login();
|
||||
|
||||
$context = context_system::instance();
|
||||
$context = get_context_instance(CONTEXT_SYSTEM);
|
||||
require_capability('moodle/site:config', $context, $USER->id, true, "nopermissions");
|
||||
|
||||
$mnet = get_mnet_environment();
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<?php
|
||||
<?PHP
|
||||
|
||||
// Allows the admin to configure mnet stuff
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
require_login();
|
||||
admin_externalpage_setup('net');
|
||||
|
||||
$context = context_system::instance();
|
||||
$context = get_context_instance(CONTEXT_SYSTEM);
|
||||
|
||||
require_capability('moodle/site:config', $context, $USER->id, true, "nopermissions");
|
||||
|
||||
@@ -85,7 +85,7 @@
|
||||
echo $OUTPUT->header();
|
||||
?>
|
||||
<form method="post" action="index.php">
|
||||
<table align="center" width="635" class="generaltable" border="0" cellpadding="5" cellspacing="0">
|
||||
<table align="center" width="635" class="generalbox" border="0" cellpadding="5" cellspacing="0">
|
||||
<tr>
|
||||
<td class="generalboxcontent">
|
||||
<table cellpadding="9" cellspacing="0" >
|
||||
@@ -106,7 +106,7 @@
|
||||
</table>
|
||||
</form>
|
||||
<form method="post" action="index.php">
|
||||
<table align="center" width="635" class="generaltable" border="0" cellpadding="5" cellspacing="0">
|
||||
<table align="center" width="635" class="generalbox" border="0" cellpadding="5" cellspacing="0">
|
||||
<tr>
|
||||
<td class="generalboxcontent">
|
||||
<table cellpadding="9" cellspacing="0" >
|
||||
|
||||
@@ -78,13 +78,9 @@ class mnet_review_host_form extends moodleform {
|
||||
$mnet_peer = $this->_customdata['peer'];
|
||||
|
||||
$mform->addElement('hidden', 'last_connect_time');
|
||||
$mform->setType('last_connect_time', PARAM_INT);
|
||||
$mform->addElement('hidden', 'id');
|
||||
$mform->setType('id', PARAM_INT);
|
||||
$mform->addElement('hidden', 'applicationid');
|
||||
$mform->setType('applicationid', PARAM_INT);
|
||||
$mform->addElement('hidden', 'oldpublickey');
|
||||
$mform->setType('oldpublickey', PARAM_PEM);
|
||||
|
||||
$mform->addElement('text', 'name', get_string('site'), array('maxlength' => 80, 'size' => 50));
|
||||
$mform->setType('name', PARAM_NOTAGS);
|
||||
@@ -94,17 +90,8 @@ class mnet_review_host_form extends moodleform {
|
||||
$mform->setType('wwwroot', PARAM_URL);
|
||||
$mform->addRule('wwwroot', get_string('maximumchars', '', 255), 'maxlength', 255, 'client');
|
||||
|
||||
$options = array(
|
||||
mnet_peer::SSL_NONE => get_string('none'),
|
||||
mnet_peer::SSL_HOST => get_string('verifyhostonly', 'core_mnet'),
|
||||
mnet_peer::SSL_HOST_AND_PEER => get_string('verifyhostandpeer', 'core_mnet')
|
||||
);
|
||||
$mform->addElement('select', 'sslverification', get_string('sslverification', 'core_mnet'), $options);
|
||||
$mform->setDefault('sslverification', mnet_peer::SSL_HOST_AND_PEER);
|
||||
$mform->addHelpButton('sslverification', 'sslverification', 'core_mnet');
|
||||
|
||||
$themes = array('' => get_string('forceno'));
|
||||
foreach (array_keys(core_component::get_plugin_list('theme')) as $themename) {
|
||||
foreach (array_keys(get_plugin_list('theme')) as $themename) {
|
||||
$themes[$themename] = get_string('pluginname', 'theme_'.$themename);
|
||||
}
|
||||
$mform->addElement('select', 'theme', get_string('forcetheme'), $themes);
|
||||
@@ -161,7 +148,6 @@ class mnet_review_host_form extends moodleform {
|
||||
$mform->addGroup($radioarray, 'radioar', get_string('deleted'), array(' ', ' '), false);
|
||||
} else {
|
||||
$mform->addElement('hidden', 'deleted');
|
||||
$mform->setType('deleted', PARAM_BOOL);
|
||||
}
|
||||
|
||||
// finished with static stuff, print save button
|
||||
|
||||
@@ -34,7 +34,7 @@ require_once($CFG->dirroot.'/'.$CFG->admin.'/mnet/peer_forms.php');
|
||||
|
||||
require_login();
|
||||
|
||||
$context = context_system::instance();
|
||||
$context = get_context_instance(CONTEXT_SYSTEM);
|
||||
require_capability('moodle/site:config', $context, $USER->id, true, 'nopermissions');
|
||||
|
||||
/// Initialize variables.
|
||||
@@ -172,7 +172,6 @@ if ($formdata = $reviewform->get_data()) {
|
||||
$mnet_peer->public_key = $formdata->public_key;
|
||||
$credentials = $mnet_peer->check_credentials($mnet_peer->public_key);
|
||||
$mnet_peer->public_key_expires = $credentials['validTo_time_t'];
|
||||
$mnet_peer->sslverification = $formdata->sslverification;
|
||||
|
||||
if ($mnet_peer->commit()) {
|
||||
redirect(new moodle_url('/admin/mnet/peers.php', array('hostid' => $mnet_peer->id)), get_string('changessaved'));
|
||||
|
||||
@@ -34,7 +34,7 @@ $hostid = required_param('hostid', PARAM_INT);
|
||||
$mnet_peer = new mnet_peer();
|
||||
$mnet_peer->set_id($hostid);
|
||||
|
||||
$context = context_system::instance();
|
||||
$context = get_context_instance(CONTEXT_SYSTEM);
|
||||
|
||||
require_capability('moodle/site:config', $context, $USER->id, true, 'nopermissions');
|
||||
admin_externalpage_setup('mnetpeers');
|
||||
|
||||
@@ -50,8 +50,6 @@ class mnet_profile_form extends moodleform {
|
||||
}
|
||||
|
||||
$mform->addElement('hidden', 'hostid', $this->_customdata['hostid']);
|
||||
$mform->setType('hostid', PARAM_INT);
|
||||
|
||||
$fields = mnet_profile_field_options();
|
||||
|
||||
// Fields to import ----------------------------------------------------
|
||||
|
||||
@@ -33,7 +33,7 @@ $mnet = get_mnet_environment();
|
||||
require_login();
|
||||
admin_externalpage_setup('mnetpeers');
|
||||
|
||||
$context = context_system::instance();
|
||||
$context = get_context_instance(CONTEXT_SYSTEM);
|
||||
require_capability('moodle/site:config', $context, $USER->id, true, "nopermissions");
|
||||
|
||||
$hostid = required_param('hostid', PARAM_INT);
|
||||
|
||||
@@ -39,7 +39,6 @@ class mnet_services_form extends moodleform {
|
||||
$myservices = mnet_get_service_info($mnet_peer);
|
||||
|
||||
$mform->addElement('hidden', 'hostid', $mnet_peer->id);
|
||||
$mform->setType('hostid', PARAM_INT);
|
||||
|
||||
$count = 0;
|
||||
foreach ($myservices as $name => $versions) {
|
||||
@@ -56,8 +55,6 @@ class mnet_services_form extends moodleform {
|
||||
$mform->addElement('html', '<h3>' . get_string($name.'_name', $langmodule , $mnet_peer->name) . '</h3>' . get_string($name.'_description', $langmodule, $mnet_peer->name));
|
||||
|
||||
$mform->addElement('hidden', 'exists[' . $version['serviceid'] . ']', 1);
|
||||
// Temporary fix until MDL-38885 gets integrated.
|
||||
$mform->setType('exists', PARAM_BOOL);
|
||||
|
||||
$pubstr = get_string('publish','mnet');
|
||||
if (!empty($version['hostsubscribes'])) {
|
||||
|
||||
@@ -34,12 +34,21 @@ if (!defined('MOODLE_INTERNAL')) {
|
||||
}
|
||||
|
||||
$strmnetservices = get_string('mnetservices', 'mnet');
|
||||
$strmnetlog = get_string('mnetlog', 'mnet');
|
||||
$strmnetedithost = get_string('reviewhostdetails', 'mnet');
|
||||
|
||||
$logurl = $CFG->wwwroot.
|
||||
'/report/log/index.php?chooselog=1&showusers=1&showcourses=1&host_course='.$mnet_peer->id.
|
||||
'%2F1&user='.'0'.
|
||||
'&date=0'.
|
||||
'&modid=&modaction=0&logformat=showashtml';
|
||||
$tabs = array();
|
||||
if (isset($mnet_peer->id) && $mnet_peer->id > 0) {
|
||||
$tabs[] = new tabobject('mnetdetails', 'peers.php?step=update&hostid='.$mnet_peer->id, $strmnetedithost, $strmnetedithost, false);
|
||||
$tabs[] = new tabobject('mnetservices', 'services.php?hostid='.$mnet_peer->id, $strmnetservices, $strmnetservices, false);
|
||||
if ($mnet_peer->application->name == 'moodle' && $mnet_peer->id != $CFG->mnet_all_hosts_id) {
|
||||
$tabs[] = new tabobject('mnetlog', $logurl, $strmnetlog, $strmnetlog, false);
|
||||
}
|
||||
$tabs[] = new tabobject('mnetprofilefields', 'profilefields.php?hostid=' . $mnet_peer->id, get_string('profilefields', 'mnet'), get_string('profilefields', 'mnet'), false);
|
||||
} else {
|
||||
$tabs[] = new tabobject('mnetdetails', '#', $strmnetedithost, $strmnetedithost, false);
|
||||
|
||||
@@ -24,7 +24,7 @@ if ($CFG->mnet_dispatcher_mode === 'off') {
|
||||
require_login();
|
||||
admin_externalpage_setup('mnettestclient');
|
||||
|
||||
$context = context_system::instance();
|
||||
$context = get_context_instance(CONTEXT_SYSTEM);
|
||||
require_capability('moodle/site:config', $context);
|
||||
|
||||
error_reporting(DEBUG_ALL);
|
||||
@@ -66,19 +66,12 @@ if (!empty($hostid) && array_key_exists($hostid, $hosts)) {
|
||||
|
||||
$mnet_request->set_method('system/listServices');
|
||||
$mnet_request->send($mnet_peer);
|
||||
|
||||
$services = $mnet_request->response;
|
||||
$yesno = array('No', 'Yes');
|
||||
$servicenames = array();
|
||||
|
||||
echo $OUTPUT->heading(get_string('servicesavailableonhost', 'mnet', $host->wwwroot));
|
||||
|
||||
if (!empty($mnet_request->error)) {
|
||||
echo $OUTPUT->heading(get_string('error'), 3);
|
||||
echo html_writer::alist($mnet_request->error);
|
||||
$services = array();
|
||||
}
|
||||
|
||||
$table = new html_table();
|
||||
$table->head = array(
|
||||
get_string('serviceid', 'mnet'),
|
||||
@@ -134,7 +127,6 @@ if (!empty($hostid) && array_key_exists($hostid, $hosts)) {
|
||||
echo html_writer::table($table);
|
||||
|
||||
|
||||
$mnet_request = new mnet_xmlrpc_client();
|
||||
$mnet_request->set_method('system/listMethods');
|
||||
if (isset($servicename) && array_key_exists($servicename, $serviceinfo)) {
|
||||
echo $OUTPUT->heading(get_string('methodsavailableonhostinservice', 'mnet', (object)array('host' => $host->wwwroot, 'service' => $servicename)));
|
||||
@@ -147,11 +139,6 @@ if (!empty($hostid) && array_key_exists($hostid, $hosts)) {
|
||||
$mnet_request->send($mnet_peer);
|
||||
$methods = $mnet_request->response;
|
||||
|
||||
if (!empty($mnet_request->error)) {
|
||||
echo $OUTPUT->heading(get_string('error'), 3);
|
||||
echo html_writer::alist($mnet_request->error);
|
||||
$methods = array();
|
||||
}
|
||||
|
||||
$table = new html_table();
|
||||
$table->head = array(
|
||||
@@ -184,12 +171,6 @@ if (!empty($hostid) && array_key_exists($hostid, $hosts)) {
|
||||
|
||||
echo $OUTPUT->heading(get_string('methodsignature', 'mnet', $method));
|
||||
|
||||
if (!empty($mnet_request->error)) {
|
||||
echo $OUTPUT->heading(get_string('error'), 3);
|
||||
echo html_writer::alist($mnet_request->error);
|
||||
$signature = array();
|
||||
}
|
||||
|
||||
$table = new html_table();
|
||||
$table->head = array(
|
||||
get_string('position', 'mnet'),
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
require_login();
|
||||
admin_externalpage_setup('trustedhosts');
|
||||
|
||||
$context = context_system::instance();
|
||||
$context = get_context_instance(CONTEXT_SYSTEM);
|
||||
|
||||
require_capability('moodle/site:config', $context, $USER->id, true, "nopermissions");
|
||||
|
||||
|
||||
+63
-32
@@ -13,12 +13,14 @@
|
||||
|
||||
$show = optional_param('show', '', PARAM_PLUGIN);
|
||||
$hide = optional_param('hide', '', PARAM_PLUGIN);
|
||||
$delete = optional_param('delete', '', PARAM_PLUGIN);
|
||||
$confirm = optional_param('confirm', '', PARAM_BOOL);
|
||||
|
||||
|
||||
/// Print headings
|
||||
|
||||
$stractivities = get_string("activities");
|
||||
$struninstall = get_string('uninstallplugin', 'core_admin');
|
||||
$strdelete = get_string("delete");
|
||||
$strversion = get_string("version");
|
||||
$strhide = get_string("hide");
|
||||
$strshow = get_string("show");
|
||||
@@ -40,14 +42,14 @@
|
||||
SET visibleold=visible, visible=0
|
||||
WHERE module=?";
|
||||
$DB->execute($sql, array($module->id));
|
||||
// Increment course.cacherev for courses where we just made something invisible.
|
||||
// This will force cache rebuilding on the next request.
|
||||
increment_revision_number('course', 'cacherev',
|
||||
"id IN (SELECT DISTINCT course
|
||||
// clear the course modinfo cache for courses
|
||||
// where we just deleted something
|
||||
$sql = "UPDATE {course}
|
||||
SET modinfo=''
|
||||
WHERE id IN (SELECT DISTINCT course
|
||||
FROM {course_modules}
|
||||
WHERE visibleold=1 AND module=?)",
|
||||
array($module->id));
|
||||
core_plugin_manager::reset_caches();
|
||||
WHERE visibleold=1 AND module=?)";
|
||||
$DB->execute($sql, array($module->id));
|
||||
admin_get_root(true, false); // settings not required - only pages
|
||||
}
|
||||
|
||||
@@ -57,17 +59,49 @@
|
||||
}
|
||||
$DB->set_field("modules", "visible", "1", array("id"=>$module->id)); // Show main module
|
||||
$DB->set_field('course_modules', 'visible', '1', array('visibleold'=>1, 'module'=>$module->id)); // Get the previous saved visible state for the course module.
|
||||
// Increment course.cacherev for courses where we just made something visible.
|
||||
// This will force cache rebuilding on the next request.
|
||||
increment_revision_number('course', 'cacherev',
|
||||
"id IN (SELECT DISTINCT course
|
||||
// clear the course modinfo cache for courses
|
||||
// where we just made something visible
|
||||
$sql = "UPDATE {course}
|
||||
SET modinfo = ''
|
||||
WHERE id IN (SELECT DISTINCT course
|
||||
FROM {course_modules}
|
||||
WHERE visible=1 AND module=?)",
|
||||
array($module->id));
|
||||
core_plugin_manager::reset_caches();
|
||||
WHERE visible=1 AND module=?)";
|
||||
$DB->execute($sql, array($module->id));
|
||||
admin_get_root(true, false); // settings not required - only pages
|
||||
}
|
||||
|
||||
if (!empty($delete) and confirm_sesskey()) {
|
||||
echo $OUTPUT->header();
|
||||
echo $OUTPUT->heading($stractivities);
|
||||
|
||||
if (get_string_manager()->string_exists('modulename', $delete)) {
|
||||
$strmodulename = get_string('modulename', $delete);
|
||||
} else {
|
||||
$strmodulename = $delete;
|
||||
}
|
||||
|
||||
if (!$confirm) {
|
||||
echo $OUTPUT->confirm(get_string("moduledeleteconfirm", "", $strmodulename), "modules.php?delete=$delete&confirm=1", "modules.php");
|
||||
echo $OUTPUT->footer();
|
||||
exit;
|
||||
|
||||
} else { // Delete everything!!
|
||||
|
||||
if ($delete == "forum") {
|
||||
print_error("cannotdeleteforummodule", 'forum');
|
||||
}
|
||||
|
||||
uninstall_plugin('mod', $delete);
|
||||
$a = new stdClass();
|
||||
$a->module = $strmodulename;
|
||||
$a->directory = "$CFG->dirroot/mod/$delete";
|
||||
echo $OUTPUT->notification(get_string("moduledeletefiles", "", $a), 'notifysuccess');
|
||||
echo $OUTPUT->continue_button("modules.php");
|
||||
echo $OUTPUT->footer();
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
echo $OUTPUT->header();
|
||||
echo $OUTPUT->heading($stractivities);
|
||||
|
||||
@@ -80,11 +114,11 @@
|
||||
/// Print the table of all modules
|
||||
// construct the flexible table ready to display
|
||||
$table = new flexible_table(MODULE_TABLE);
|
||||
$table->define_columns(array('name', 'instances', 'version', 'hideshow', 'uninstall', 'settings'));
|
||||
$table->define_headers(array($stractivitymodule, $stractivities, $strversion, "$strhide/$strshow", $strsettings, $struninstall));
|
||||
$table->define_columns(array('name', 'instances', 'version', 'hideshow', 'delete', 'settings'));
|
||||
$table->define_headers(array($stractivitymodule, $stractivities, $strversion, "$strhide/$strshow", $strdelete, $strsettings));
|
||||
$table->define_baseurl($CFG->wwwroot.'/'.$CFG->admin.'/modules.php');
|
||||
$table->set_attribute('id', 'modules');
|
||||
$table->set_attribute('class', 'admintable generaltable');
|
||||
$table->set_attribute('class', 'generaltable');
|
||||
$table->setup();
|
||||
|
||||
foreach ($modules as $module) {
|
||||
@@ -99,10 +133,7 @@
|
||||
$missing = false;
|
||||
}
|
||||
|
||||
$uninstall = '';
|
||||
if ($uninstallurl = core_plugin_manager::instance()->get_uninstall_url('mod_'.$module->name, 'manage')) {
|
||||
$uninstall = html_writer::link($uninstallurl, $struninstall);
|
||||
}
|
||||
$delete = "<a href=\"modules.php?delete=$module->name&sesskey=".sesskey()."\">$strdelete</a>";
|
||||
|
||||
if (file_exists("$CFG->dirroot/mod/$module->name/settings.php") ||
|
||||
file_exists("$CFG->dirroot/mod/$module->name/settingstree.php")) {
|
||||
@@ -130,28 +161,28 @@
|
||||
$class = '';
|
||||
} else if ($module->visible) {
|
||||
$visible = "<a href=\"modules.php?hide=$module->name&sesskey=".sesskey()."\" title=\"$strhide\">".
|
||||
"<img src=\"" . $OUTPUT->pix_url('t/hide') . "\" class=\"iconsmall\" alt=\"$strhide\" /></a>";
|
||||
"<img src=\"" . $OUTPUT->pix_url('i/hide') . "\" class=\"icon\" alt=\"$strhide\" /></a>";
|
||||
$class = '';
|
||||
} else {
|
||||
$visible = "<a href=\"modules.php?show=$module->name&sesskey=".sesskey()."\" title=\"$strshow\">".
|
||||
"<img src=\"" . $OUTPUT->pix_url('t/show') . "\" class=\"iconsmall\" alt=\"$strshow\" /></a>";
|
||||
$class = 'dimmed_text';
|
||||
"<img src=\"" . $OUTPUT->pix_url('i/show') . "\" class=\"icon\" alt=\"$strshow\" /></a>";
|
||||
$class = ' class="dimmed_text"';
|
||||
}
|
||||
if ($module->name == "forum") {
|
||||
$uninstall = "";
|
||||
$delete = "";
|
||||
$visible = "";
|
||||
$class = "";
|
||||
}
|
||||
$version = get_config('mod_'.$module->name, 'version');
|
||||
|
||||
|
||||
$table->add_data(array(
|
||||
$strmodulename,
|
||||
'<span'.$class.'>'.$strmodulename.'</span>',
|
||||
$countlink,
|
||||
$version,
|
||||
'<span'.$class.'>'.$module->version.'</span>',
|
||||
$visible,
|
||||
$settings,
|
||||
$uninstall,
|
||||
), $class);
|
||||
$delete,
|
||||
$settings
|
||||
));
|
||||
}
|
||||
|
||||
$table->print_html();
|
||||
|
||||
@@ -0,0 +1,166 @@
|
||||
<?php
|
||||
|
||||
if (!isset($CFG)) {
|
||||
|
||||
require('../config.php');
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
|
||||
admin_externalpage_setup('oacleanup');
|
||||
|
||||
echo $OUTPUT->header();
|
||||
online_assignment_cleanup(true);
|
||||
echo $OUTPUT->footer();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
function online_assignment_cleanup($output=false) {
|
||||
global $CFG, $DB, $OUTPUT;
|
||||
|
||||
if ($output) {
|
||||
echo $OUTPUT->heading('Online Assignment Cleanup');
|
||||
echo '<center>';
|
||||
}
|
||||
|
||||
|
||||
/// We don't want to run this code if we are doing an upgrade from an assignment
|
||||
/// version earlier than 2005041400
|
||||
/// because the assignment type field will not exist
|
||||
$amv = $DB->get_field('modules', 'version', array('name'=>'assignment'));
|
||||
if ((int)$amv < 2005041400) {
|
||||
if ($output) {
|
||||
echo '</center>';
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
/// get the module id for assignments from db
|
||||
$arecord = $DB->get_record('modules', array('name', 'assignment'));
|
||||
$aid = $arecord->id;
|
||||
|
||||
|
||||
/// get a list of all courses on this site
|
||||
list($ctxselect, $ctxjoin) = context_instance_preload_sql('c.id', CONTEXT_COURSE, 'ctx');
|
||||
$sql = "SELECT c.* $ctxselect FROM {course} c $ctxjoin";
|
||||
$courses = $DB->get_records_sql($sql);
|
||||
|
||||
/// cycle through each course
|
||||
foreach ($courses as $course) {
|
||||
context_instance_preload($course);
|
||||
$context = get_context_instance(CONTEXT_COURSE, $course->id);
|
||||
|
||||
if (empty($course->fullname)) {
|
||||
$fullname = get_string('course').': '.$course->id;
|
||||
} else {
|
||||
$fullname = format_string($course->fullname, true, array('context' => $context));
|
||||
}
|
||||
if ($output) echo $OUTPUT->heading($fullname);
|
||||
|
||||
/// retrieve a list of sections beyond what is currently being shown
|
||||
$sql = "SELECT *
|
||||
FROM {course_sections}
|
||||
WHERE course=? AND section>?
|
||||
ORDER BY section ASC";
|
||||
$params = array($course->id, $course->numsections);
|
||||
if (!($xsections = $DB->get_records_sql($sql, $params))) {
|
||||
if ($output) echo 'No extra sections<br />';
|
||||
continue;
|
||||
}
|
||||
|
||||
/// cycle through each of the xtra sections
|
||||
foreach ($xsections as $xsection) {
|
||||
|
||||
if ($output) echo 'Checking Section: '.$xsection->section.'<br />';
|
||||
|
||||
/// grab any module instances from the sequence field
|
||||
if (!empty($xsection->sequence)) {
|
||||
$instances = explode(',', $xsection->sequence);
|
||||
|
||||
/// cycle through the instances
|
||||
foreach ($instances as $instance) {
|
||||
/// is this an instance of an online assignment
|
||||
$sql = "SELECT a.id
|
||||
FROM {course_modules} cm, {assignment} a
|
||||
WHERE cm.id = ? AND cm.module = ? AND
|
||||
cm.instance = a.id AND a.assignmenttype = 'online'";
|
||||
$params = array($instance, $aid);
|
||||
|
||||
/// if record exists then we need to move instance to it's correct section
|
||||
if ($DB->record_exists_sql($sql, $params)) {
|
||||
|
||||
/// check the new section id
|
||||
/// the journal update erroneously stored it in course_sections->section
|
||||
$newsection = $xsection->section;
|
||||
/// double check the new section
|
||||
if ($newsection > $course->numsections) {
|
||||
/// get the record for section 0 for this course
|
||||
if (!($zerosection = $DB->get_record('course_sections', array('course'=>$course->id, 'section'=>'0')))) {
|
||||
continue;
|
||||
}
|
||||
$newsection = $zerosection->id;
|
||||
}
|
||||
|
||||
/// grab the section record
|
||||
if (!($section = $DB->get_record('course_sections', array('id'=>$newsection)))) {
|
||||
if ($output) {
|
||||
echo 'Serious error: Cannot retrieve section: '.$newsection.' for course: '. $fullname .'<br />';
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
/// explode the sequence
|
||||
if (($sequence = explode(',', $section->sequence)) === false) {
|
||||
$sequence = array();
|
||||
}
|
||||
|
||||
/// add instance to correct section
|
||||
array_push($sequence, $instance);
|
||||
|
||||
/// implode the sequence
|
||||
$section->sequence = implode(',', $sequence);
|
||||
|
||||
$DB->set_field('course_sections', 'sequence', $section->sequence, array('id'=>$section->id));
|
||||
|
||||
/// now we need to remove the instance from the old sequence
|
||||
|
||||
/// grab the old section record
|
||||
if (!($section = $DB->get_record('course_sections', array('id'=>$xsection->id)))) {
|
||||
if ($output) echo 'Serious error: Cannot retrieve old section: '.$xsection->id.' for course: '.$fullname.'<br />';
|
||||
continue;
|
||||
}
|
||||
|
||||
/// explode the sequence
|
||||
if (($sequence = explode(',', $section->sequence)) === false) {
|
||||
$sequence = array();
|
||||
}
|
||||
|
||||
/// remove the old value from the array
|
||||
$key = array_search($instance, $sequence);
|
||||
unset($sequence[$key]);
|
||||
|
||||
/// implode the sequence
|
||||
$section->sequence = implode(',', $sequence);
|
||||
|
||||
$DB->set_field('course_sections', 'sequence', $section->sequence, array('id'=>$section->id));
|
||||
|
||||
|
||||
if ($output) echo 'Online Assignment (instance '.$instance.') moved from section '.$section->id.': to section '.$newsection.'<br />';
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// if the summary and sequence are empty then remove this section
|
||||
if (empty($xsection->summary) and empty($xsection->sequence)) {
|
||||
$DB->delete_records('course_sections', array('id'=>$xsection->id));
|
||||
if ($output) echo 'Deleting empty section '.$xsection->section.'<br />';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
echo '</center>';
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -11,7 +11,7 @@
|
||||
echo '<div class="phpinfo">';
|
||||
|
||||
ob_start();
|
||||
phpinfo(INFO_GENERAL + INFO_CONFIGURATION + INFO_MODULES + INFO_VARIABLES);
|
||||
phpinfo(INFO_GENERAL + INFO_CONFIGURATION + INFO_MODULES);
|
||||
$html = ob_get_contents();
|
||||
ob_end_clean();
|
||||
|
||||
|
||||
@@ -1,86 +0,0 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Provides an overview of installed plagiarism plugins
|
||||
*
|
||||
* Displays the list of found plagiarism plugins, their version (if found) and
|
||||
* a link to uninstall the plagiarism plugin.
|
||||
*
|
||||
* @see http://docs.moodle.org/dev/Plagiarism_API
|
||||
* @package admin
|
||||
* @copyright 2012 Dan Marsden <dan@danmarsden.com>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
require_once(dirname(dirname(__FILE__)) . '/config.php');
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
require_once($CFG->libdir.'/tablelib.php');
|
||||
|
||||
|
||||
admin_externalpage_setup('manageplagiarismplugins');
|
||||
|
||||
echo $OUTPUT->header();
|
||||
|
||||
// Print the table of all installed plagiarism plugins.
|
||||
|
||||
$txt = get_strings(array('settings', 'name', 'version'));
|
||||
$txt->uninstall = get_string('uninstallplugin', 'core_admin');
|
||||
|
||||
$plagiarismplugins = core_component::get_plugin_list('plagiarism');
|
||||
if (empty($plagiarismplugins)) {
|
||||
echo $OUTPUT->notification(get_string('nopluginsinstalled', 'plagiarism'));
|
||||
echo $OUTPUT->footer();
|
||||
exit;
|
||||
}
|
||||
|
||||
echo $OUTPUT->heading(get_string('availableplugins', 'plagiarism'), 3, 'main');
|
||||
echo $OUTPUT->box_start('generalbox authsui');
|
||||
|
||||
$table = new html_table();
|
||||
$table->head = array($txt->name, $txt->version, $txt->uninstall, $txt->settings);
|
||||
$table->colclasses = array('mdl-left', 'mdl-align', 'mdl-align', 'mdl-align');
|
||||
$table->data = array();
|
||||
$table->attributes['class'] = 'manageplagiarismtable generaltable';
|
||||
|
||||
// Iterate through auth plugins and add to the display table.
|
||||
$authcount = count($plagiarismplugins);
|
||||
foreach ($plagiarismplugins as $plugin => $dir) {
|
||||
if (file_exists($dir.'/settings.php')) {
|
||||
$displayname = "<span>".get_string($plugin, 'plagiarism_'.$plugin)."</span>";
|
||||
// Settings link.
|
||||
$url = new moodle_url("/plagiarism/$plugin/settings.php");
|
||||
$settings = html_writer::link($url, $txt->settings);
|
||||
// Get version.
|
||||
$version = get_config('plagiarism_' . $plugin);
|
||||
if (!empty($version->version)) {
|
||||
$version = $version->version;
|
||||
} else {
|
||||
$version = '?';
|
||||
}
|
||||
// uninstall link.
|
||||
$uninstall = '';
|
||||
if ($uninstallurl = core_plugin_manager::instance()->get_uninstall_url('plagiarism_'.$plugin, 'manage')) {
|
||||
$uninstall = html_writer::link($uninstallurl, $txt->uninstall);
|
||||
}
|
||||
$table->data[] = array($displayname, $version, $uninstall, $settings);
|
||||
}
|
||||
}
|
||||
echo html_writer::table($table);
|
||||
echo get_string('configplagiarismplugins', 'plagiarism');
|
||||
echo $OUTPUT->box_end();
|
||||
|
||||
echo $OUTPUT->footer();
|
||||
+8
-169
@@ -18,15 +18,6 @@
|
||||
/**
|
||||
* UI for general plugins management
|
||||
*
|
||||
* Supported HTTP parameters:
|
||||
*
|
||||
* ?fetchremote=1 - check for available updates
|
||||
* ?updatesonly=1 - display plugins with available update only
|
||||
* ?contribonly=1 - display non-standard add-ons only
|
||||
* ?uninstall=foo_bar - uninstall the given plugin
|
||||
* ?delete=foo_bar - delete the plugin folder (it must not be installed)
|
||||
* &confirm=1 - confirm the uninstall or delete action
|
||||
*
|
||||
* @package core
|
||||
* @subpackage admin
|
||||
* @copyright 2011 David Mudrak <david@moodle.com>
|
||||
@@ -35,173 +26,21 @@
|
||||
|
||||
require_once(dirname(dirname(__FILE__)) . '/config.php');
|
||||
require_once($CFG->libdir . '/adminlib.php');
|
||||
require_once($CFG->libdir . '/filelib.php');
|
||||
|
||||
$fetchremote = optional_param('fetchremote', false, PARAM_BOOL);
|
||||
$updatesonly = optional_param('updatesonly', false, PARAM_BOOL);
|
||||
$contribonly = optional_param('contribonly', false, PARAM_BOOL);
|
||||
$uninstall = optional_param('uninstall', '', PARAM_COMPONENT);
|
||||
$delete = optional_param('delete', '', PARAM_COMPONENT);
|
||||
$confirmed = optional_param('confirm', false, PARAM_BOOL);
|
||||
$return = optional_param('return', 'overview', PARAM_ALPHA);
|
||||
|
||||
// NOTE: do not use admin_externalpage_setup() here because it loads
|
||||
// full admin tree which is not possible during uninstallation.
|
||||
|
||||
require_login();
|
||||
$syscontext = context_system::instance();
|
||||
require_capability('moodle/site:config', $syscontext);
|
||||
|
||||
$pluginman = core_plugin_manager::instance();
|
||||
|
||||
if ($uninstall) {
|
||||
require_sesskey();
|
||||
|
||||
if (!$confirmed) {
|
||||
admin_externalpage_setup('pluginsoverview');
|
||||
} else {
|
||||
$PAGE->set_url('/admin/plugins.php');
|
||||
$PAGE->set_context($syscontext);
|
||||
$PAGE->set_pagelayout('maintenance');
|
||||
$PAGE->set_popup_notification_allowed(false);
|
||||
}
|
||||
|
||||
/** @var core_admin_renderer $output */
|
||||
$output = $PAGE->get_renderer('core', 'admin');
|
||||
|
||||
$pluginfo = $pluginman->get_plugin_info($uninstall);
|
||||
|
||||
// Make sure we know the plugin.
|
||||
if (is_null($pluginfo)) {
|
||||
throw new moodle_exception('err_uninstalling_unknown_plugin', 'core_plugin', '', array('plugin' => $uninstall),
|
||||
'core_plugin_manager::get_plugin_info() returned null for the plugin to be uninstalled');
|
||||
}
|
||||
|
||||
$pluginname = $pluginman->plugin_name($pluginfo->component);
|
||||
$PAGE->set_title($pluginname);
|
||||
$PAGE->navbar->add(get_string('uninstalling', 'core_plugin', array('name' => $pluginname)));
|
||||
|
||||
if (!$pluginman->can_uninstall_plugin($pluginfo->component)) {
|
||||
throw new moodle_exception('err_cannot_uninstall_plugin', 'core_plugin', '',
|
||||
array('plugin' => $pluginfo->component),
|
||||
'core_plugin_manager::can_uninstall_plugin() returned false');
|
||||
}
|
||||
|
||||
if (!$confirmed) {
|
||||
$continueurl = new moodle_url($PAGE->url, array('uninstall' => $pluginfo->component, 'sesskey' => sesskey(), 'confirm' => 1, 'return'=>$return));
|
||||
$cancelurl = $pluginfo->get_return_url_after_uninstall($return);
|
||||
echo $output->plugin_uninstall_confirm_page($pluginman, $pluginfo, $continueurl, $cancelurl);
|
||||
exit();
|
||||
|
||||
} else {
|
||||
$SESSION->pluginuninstallreturn = $pluginfo->get_return_url_after_uninstall($return);
|
||||
$progress = new progress_trace_buffer(new text_progress_trace(), false);
|
||||
$pluginman->uninstall_plugin($pluginfo->component, $progress);
|
||||
$progress->finished();
|
||||
|
||||
if ($pluginman->is_plugin_folder_removable($pluginfo->component)) {
|
||||
$continueurl = new moodle_url($PAGE->url, array('delete' => $pluginfo->component, 'sesskey' => sesskey(), 'confirm' => 1));
|
||||
echo $output->plugin_uninstall_results_removable_page($pluginman, $pluginfo, $progress, $continueurl);
|
||||
// Reset op code caches.
|
||||
if (function_exists('opcache_reset')) {
|
||||
opcache_reset();
|
||||
}
|
||||
exit();
|
||||
|
||||
} else {
|
||||
echo $output->plugin_uninstall_results_page($pluginman, $pluginfo, $progress);
|
||||
// Reset op code caches.
|
||||
if (function_exists('opcache_reset')) {
|
||||
opcache_reset();
|
||||
}
|
||||
exit();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($delete and $confirmed) {
|
||||
require_sesskey();
|
||||
|
||||
$PAGE->set_url('/admin/plugins.php');
|
||||
$PAGE->set_context($syscontext);
|
||||
$PAGE->set_pagelayout('maintenance');
|
||||
$PAGE->set_popup_notification_allowed(false);
|
||||
|
||||
/** @var core_admin_renderer $output */
|
||||
$output = $PAGE->get_renderer('core', 'admin');
|
||||
|
||||
$pluginfo = $pluginman->get_plugin_info($delete);
|
||||
|
||||
// Make sure we know the plugin.
|
||||
if (is_null($pluginfo)) {
|
||||
throw new moodle_exception('err_removing_unknown_plugin', 'core_plugin', '', array('plugin' => $delete),
|
||||
'core_plugin_manager::get_plugin_info() returned null for the plugin to be deleted');
|
||||
}
|
||||
|
||||
$pluginname = $pluginman->plugin_name($pluginfo->component);
|
||||
$PAGE->set_title($pluginname);
|
||||
$PAGE->navbar->add(get_string('uninstalling', 'core_plugin', array('name' => $pluginname)));
|
||||
|
||||
// Make sure it is not installed.
|
||||
if (!is_null($pluginfo->versiondb)) {
|
||||
throw new moodle_exception('err_removing_installed_plugin', 'core_plugin', '',
|
||||
array('plugin' => $pluginfo->component, 'versiondb' => $pluginfo->versiondb),
|
||||
'core_plugin_manager::get_plugin_info() returned not-null versiondb for the plugin to be deleted');
|
||||
}
|
||||
|
||||
// Make sure the folder is removable.
|
||||
if (!$pluginman->is_plugin_folder_removable($pluginfo->component)) {
|
||||
throw new moodle_exception('err_removing_unremovable_folder', 'core_plugin', '',
|
||||
array('plugin' => $pluginfo->component, 'rootdir' => $pluginfo->rootdir),
|
||||
'plugin root folder is not removable as expected');
|
||||
}
|
||||
|
||||
// Make sure the folder is within Moodle installation tree.
|
||||
if (strpos($pluginfo->rootdir, $CFG->dirroot) !== 0) {
|
||||
throw new moodle_exception('err_unexpected_plugin_rootdir', 'core_plugin', '',
|
||||
array('plugin' => $pluginfo->component, 'rootdir' => $pluginfo->rootdir, 'dirroot' => $CFG->dirroot),
|
||||
'plugin root folder not in the moodle dirroot');
|
||||
}
|
||||
|
||||
// So long, and thanks for all the bugs.
|
||||
fulldelete($pluginfo->rootdir);
|
||||
// Reset op code caches.
|
||||
if (function_exists('opcache_reset')) {
|
||||
opcache_reset();
|
||||
}
|
||||
// We need to execute upgrade to make sure everything including caches is up to date.
|
||||
redirect(new moodle_url('/admin/index.php'));
|
||||
}
|
||||
require_once($CFG->libdir . '/pluginlib.php');
|
||||
|
||||
require_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM));
|
||||
admin_externalpage_setup('pluginsoverview');
|
||||
|
||||
/** @var core_admin_renderer $output */
|
||||
$output = $PAGE->get_renderer('core', 'admin');
|
||||
$fetchremote = optional_param('fetchremote', false, PARAM_BOOL);
|
||||
|
||||
$checker = \core\update\checker::instance();
|
||||
|
||||
// Filtering options.
|
||||
$options = array(
|
||||
'updatesonly' => $updatesonly,
|
||||
'contribonly' => $contribonly,
|
||||
);
|
||||
$pluginman = plugin_manager::instance();
|
||||
$checker = available_update_checker::instance();
|
||||
|
||||
if ($fetchremote) {
|
||||
require_sesskey();
|
||||
$checker->fetch();
|
||||
redirect(new moodle_url($PAGE->url, $options));
|
||||
redirect($PAGE->url);
|
||||
}
|
||||
|
||||
$deployer = \core\update\deployer::instance();
|
||||
if ($deployer->enabled()) {
|
||||
$myurl = new moodle_url($PAGE->url, array('updatesonly' => $updatesonly, 'contribonly' => $contribonly));
|
||||
$deployer->initialize($myurl, new moodle_url('/admin'));
|
||||
|
||||
$deploydata = $deployer->submitted_data();
|
||||
if (!empty($deploydata)) {
|
||||
echo $output->upgrade_plugin_confirm_deploy_page($deployer, $deploydata);
|
||||
die();
|
||||
}
|
||||
}
|
||||
|
||||
echo $output->plugin_management_page($pluginman, $checker, $options);
|
||||
$output = $PAGE->get_renderer('core', 'admin');
|
||||
echo $output->plugin_management_page($pluginman, $checker);
|
||||
|
||||
+3
-5
@@ -5,7 +5,7 @@ require_once($CFG->libdir . '/portfoliolib.php');
|
||||
require_once($CFG->libdir . '/portfolio/forms.php');
|
||||
require_once($CFG->libdir . '/adminlib.php');
|
||||
|
||||
$portfolio = optional_param('pf', '', PARAM_ALPHANUMEXT);
|
||||
$portfolio = optional_param('pf', '', PARAM_FORMAT);
|
||||
$action = optional_param('action', '', PARAM_ALPHA);
|
||||
$sure = optional_param('sure', '', PARAM_ALPHA);
|
||||
|
||||
@@ -35,7 +35,7 @@ if ($action == 'newon') {
|
||||
|
||||
admin_externalpage_setup($pagename);
|
||||
|
||||
require_capability('moodle/site:config', context_system::instance());
|
||||
require_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM));
|
||||
|
||||
$baseurl = "$CFG->wwwroot/$CFG->admin/portfolio.php";
|
||||
$sesskeyurl = "$CFG->wwwroot/$CFG->admin/portfolio.php?sesskey=" . sesskey();
|
||||
@@ -88,7 +88,6 @@ if (($action == 'edit') || ($action == 'new')) {
|
||||
} else {
|
||||
portfolio_static_function($plugin, 'create_instance', $plugin, $fromform->name, $fromform);
|
||||
}
|
||||
core_plugin_manager::reset_caches();
|
||||
$savedstr = get_string('instancesaved', 'portfolio');
|
||||
redirect($baseurl, $savedstr, 1);
|
||||
exit;
|
||||
@@ -117,7 +116,6 @@ if (($action == 'edit') || ($action == 'new')) {
|
||||
|
||||
$instance->set('visible', $visible);
|
||||
$instance->save();
|
||||
core_plugin_manager::reset_caches();
|
||||
$return = true;
|
||||
} else if ($action == 'delete') {
|
||||
$instance = portfolio_instance($portfolio);
|
||||
@@ -162,7 +160,7 @@ if (($action == 'edit') || ($action == 'new')) {
|
||||
|
||||
$output = $OUTPUT->box_start('generalbox');
|
||||
|
||||
$plugins = core_component::get_plugin_list('portfolio');
|
||||
$plugins = get_plugin_list('portfolio');
|
||||
$plugins = array_keys($plugins);
|
||||
$instances = portfolio_instances(false, false);
|
||||
$usedplugins = array();
|
||||
|
||||
+30
-30
@@ -27,37 +27,37 @@ require_once('../config.php');
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
|
||||
$confirm = optional_param('confirm', 0, PARAM_BOOL);
|
||||
$returnurl = optional_param('returnurl', null, PARAM_LOCALURL);
|
||||
|
||||
// If we have got here as a confirmed aciton, do it.
|
||||
if ($confirm && isloggedin() && confirm_sesskey()) {
|
||||
require_capability('moodle/site:config', context_system::instance());
|
||||
|
||||
// Valid request. Purge, and redirect the user back to where they came from.
|
||||
purge_all_caches();
|
||||
|
||||
if ($returnurl) {
|
||||
$returnurl = $CFG->wwwroot . $returnurl;
|
||||
} else {
|
||||
$returnurl = new moodle_url('/admin/purgecaches.php');
|
||||
}
|
||||
redirect($returnurl, get_string('purgecachesfinished', 'admin'));
|
||||
}
|
||||
|
||||
// Otherwise, show a button to actually purge the caches.
|
||||
admin_externalpage_setup('purgecaches');
|
||||
|
||||
$actionurl = new moodle_url('/admin/purgecaches.php', array('sesskey'=>sesskey(), 'confirm'=>1));
|
||||
if ($returnurl) {
|
||||
$actionurl->param('returnurl', $returnurl);
|
||||
require_login();
|
||||
require_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM));
|
||||
|
||||
if ($confirm) {
|
||||
require_sesskey();
|
||||
|
||||
// Valid request. Purge, and redisplay the form so it is easy to purge again
|
||||
// in the near future.
|
||||
purge_all_caches();
|
||||
redirect(new moodle_url('/admin/purgecaches.php'), get_string('purgecachesfinished', 'admin'));
|
||||
|
||||
} else {
|
||||
// Show a confirm form.
|
||||
echo $OUTPUT->header();
|
||||
echo $OUTPUT->heading(get_string('purgecaches', 'admin'));
|
||||
|
||||
$url = new moodle_url('/admin/purgecaches.php', array('sesskey'=>sesskey(), 'confirm'=>1));
|
||||
$button = new single_button($url, get_string('purgecaches','admin'), 'post');
|
||||
|
||||
// Cancel button takes them back to the page the were on, if possible,
|
||||
// otherwise to the site home page.
|
||||
$return = new moodle_url('/');
|
||||
if (isset($_SERVER['HTTP_REFERER']) and !empty($_SERVER['HTTP_REFERER'])) {
|
||||
if ($_SERVER['HTTP_REFERER'] !== "$CFG->wwwroot/$CFG->admin/purgecaches.php") {
|
||||
$return = $_SERVER['HTTP_REFERER'];
|
||||
}
|
||||
}
|
||||
|
||||
echo $OUTPUT->confirm(get_string('purgecachesconfirm', 'admin'), $button, $return);
|
||||
echo $OUTPUT->footer();
|
||||
}
|
||||
|
||||
echo $OUTPUT->header();
|
||||
echo $OUTPUT->heading(get_string('purgecaches', 'admin'));
|
||||
|
||||
echo $OUTPUT->box_start('generalbox', 'notice');
|
||||
echo html_writer::tag('p', get_string('purgecachesconfirm', 'admin'));
|
||||
echo $OUTPUT->single_button($actionurl, get_string('purgecaches', 'admin'), 'post');
|
||||
echo $OUTPUT->box_end();
|
||||
|
||||
echo $OUTPUT->footer();
|
||||
|
||||
+78
-17
@@ -28,18 +28,19 @@
|
||||
require_once(dirname(__FILE__) . '/../config.php');
|
||||
require_once($CFG->libdir . '/questionlib.php');
|
||||
require_once($CFG->libdir . '/adminlib.php');
|
||||
require_once($CFG->libdir . '/pluginlib.php');
|
||||
require_once($CFG->libdir . '/tablelib.php');
|
||||
|
||||
// Check permissions.
|
||||
require_login();
|
||||
$systemcontext = context_system::instance();
|
||||
$systemcontext = get_context_instance(CONTEXT_SYSTEM);
|
||||
require_capability('moodle/question:config', $systemcontext);
|
||||
|
||||
admin_externalpage_setup('manageqbehaviours');
|
||||
$thispageurl = new moodle_url('/admin/qbehaviours.php');
|
||||
|
||||
$behaviours = core_component::get_plugin_list('qbehaviour');
|
||||
$pluginmanager = core_plugin_manager::instance();
|
||||
$behaviours = get_plugin_list('qbehaviour');
|
||||
$pluginmanager = plugin_manager::instance();
|
||||
|
||||
// Get some data we will need - question counts and which types are needed.
|
||||
$counts = $DB->get_records_sql_menu("
|
||||
@@ -91,7 +92,6 @@ if (($disable = optional_param('disable', '', PARAM_PLUGIN)) && confirm_sesskey(
|
||||
$disabledbehaviours[] = $disable;
|
||||
set_config('disabledbehaviours', implode(',', $disabledbehaviours), 'question');
|
||||
}
|
||||
core_plugin_manager::reset_caches();
|
||||
redirect($thispageurl);
|
||||
}
|
||||
|
||||
@@ -109,7 +109,6 @@ if (($enable = optional_param('enable', '', PARAM_PLUGIN)) && confirm_sesskey())
|
||||
unset($disabledbehaviours[$key]);
|
||||
set_config('disabledbehaviours', implode(',', $disabledbehaviours), 'question');
|
||||
}
|
||||
core_plugin_manager::reset_caches();
|
||||
redirect($thispageurl);
|
||||
}
|
||||
|
||||
@@ -137,6 +136,70 @@ if (($down = optional_param('down', '', PARAM_PLUGIN)) && confirm_sesskey()) {
|
||||
redirect($thispageurl);
|
||||
}
|
||||
|
||||
// Delete.
|
||||
if (($delete = optional_param('delete', '', PARAM_PLUGIN)) && confirm_sesskey()) {
|
||||
// Check it is OK to delete this question type.
|
||||
if ($delete == 'missing') {
|
||||
print_error('cannotdeletemissingbehaviour', 'question', $thispageurl);
|
||||
}
|
||||
|
||||
if (!isset($behaviours[$delete])) {
|
||||
print_error('unknownbehaviour', 'question', $thispageurl, $delete);
|
||||
}
|
||||
|
||||
$behaviourname = $sortedbehaviours[$delete];
|
||||
if ($counts[$delete] > 0) {
|
||||
print_error('cannotdeletebehaviourinuse', 'question', $thispageurl, $behaviourname);
|
||||
}
|
||||
if ($needed[$delete] > 0) {
|
||||
print_error('cannotdeleteneededbehaviour', 'question', $thispageurl, $behaviourname);
|
||||
}
|
||||
|
||||
// If not yet confirmed, display a confirmation message.
|
||||
if (!optional_param('confirm', '', PARAM_BOOL)) {
|
||||
echo $OUTPUT->header();
|
||||
echo $OUTPUT->heading(get_string('deletebehaviourareyousure', 'question', $behaviourname));
|
||||
echo $OUTPUT->confirm(
|
||||
get_string('deletebehaviourareyousuremessage', 'question', $behaviourname),
|
||||
new moodle_url($thispageurl, array('delete' => $delete, 'confirm' => 1)),
|
||||
$thispageurl);
|
||||
echo $OUTPUT->footer();
|
||||
exit;
|
||||
}
|
||||
|
||||
// Do the deletion.
|
||||
echo $OUTPUT->header();
|
||||
echo $OUTPUT->heading(get_string('deletingbehaviour', 'question', $behaviourname));
|
||||
|
||||
// Delete any configuration records.
|
||||
if (!unset_all_config_for_plugin('qbehaviour_' . $delete)) {
|
||||
echo $OUTPUT->notification(get_string('errordeletingconfig', 'admin', 'qbehaviour_' . $delete));
|
||||
}
|
||||
if (($key = array_search($delete, $disabledbehaviours)) !== false) {
|
||||
unset($disabledbehaviours[$key]);
|
||||
set_config('disabledbehaviours', implode(',', $disabledbehaviours), 'question');
|
||||
}
|
||||
$behaviourorder = array_keys($sortedbehaviours);
|
||||
if (($key = array_search($delete, $behaviourorder)) !== false) {
|
||||
unset($behaviourorder[$key]);
|
||||
set_config('behavioursortorder', implode(',', $behaviourorder), 'question');
|
||||
}
|
||||
|
||||
// Then the tables themselves
|
||||
drop_plugin_tables($delete, get_plugin_directory('qbehaviour', $delete) . '/db/install.xml', false);
|
||||
|
||||
// Remove event handlers and dequeue pending events
|
||||
events_uninstall('qbehaviour_' . $delete);
|
||||
|
||||
$a = new stdClass();
|
||||
$a->behaviour = $behaviourname;
|
||||
$a->directory = get_plugin_directory('qbehaviour', $delete);
|
||||
echo $OUTPUT->box(get_string('qbehaviourdeletefiles', 'question', $a), 'generalbox', 'notice');
|
||||
echo $OUTPUT->continue_button($thispageurl);
|
||||
echo $OUTPUT->footer();
|
||||
exit;
|
||||
}
|
||||
|
||||
// End of process actions ==================================================
|
||||
|
||||
// Print the page heading.
|
||||
@@ -147,12 +210,12 @@ echo $OUTPUT->heading(get_string('manageqbehaviours', 'admin'));
|
||||
$table = new flexible_table('qbehaviouradmintable');
|
||||
$table->define_baseurl($thispageurl);
|
||||
$table->define_columns(array('behaviour', 'numqas', 'version', 'requires',
|
||||
'available', 'uninstall'));
|
||||
'available', 'delete'));
|
||||
$table->define_headers(array(get_string('behaviour', 'question'), get_string('numqas', 'question'),
|
||||
get_string('version'), get_string('requires', 'admin'),
|
||||
get_string('availableq', 'question'), get_string('uninstallplugin', 'core_admin')));
|
||||
get_string('availableq', 'question'), get_string('delete')));
|
||||
$table->set_attribute('id', 'qbehaviours');
|
||||
$table->set_attribute('class', 'generaltable admintable');
|
||||
$table->set_attribute('class', 'generaltable generalbox boxaligncenter boxwidthwide');
|
||||
$table->setup();
|
||||
|
||||
// Add a row for each question type.
|
||||
@@ -195,7 +258,7 @@ foreach ($sortedbehaviours as $behaviour => $behaviourname) {
|
||||
$rowclass = 'dimmed_text';
|
||||
}
|
||||
} else {
|
||||
$icons = $OUTPUT->spacer(array('class' => 'iconsmall'));
|
||||
$icons = $OUTPUT->spacer() . ' ';
|
||||
}
|
||||
|
||||
// Move icons.
|
||||
@@ -207,11 +270,9 @@ foreach ($sortedbehaviours as $behaviour => $behaviourname) {
|
||||
if ($needed[$behaviour]) {
|
||||
$row[] = '';
|
||||
} else {
|
||||
$uninstallurl = core_plugin_manager::instance()->get_uninstall_url('qbehaviour_'.$behaviour, 'manage');
|
||||
if ($uninstallurl) {
|
||||
$row[] = html_writer::link($uninstallurl, get_string('uninstallplugin', 'core_admin'),
|
||||
$row[] = html_writer::link(new moodle_url($thispageurl,
|
||||
array('delete' => $behaviour, 'sesskey' => sesskey())), get_string('delete'),
|
||||
array('title' => get_string('uninstallbehaviour', 'question')));
|
||||
}
|
||||
}
|
||||
|
||||
$table->add_data($row, $rowclass);
|
||||
@@ -223,10 +284,10 @@ echo $OUTPUT->footer();
|
||||
|
||||
function question_behaviour_enable_disable_icons($behaviour, $enabled) {
|
||||
if ($enabled) {
|
||||
return question_behaviour_icon_html('disable', $behaviour, 't/hide',
|
||||
return question_behaviour_icon_html('disable', $behaviour, 'i/hide',
|
||||
get_string('enabled', 'question'), get_string('disable'));
|
||||
} else {
|
||||
return question_behaviour_icon_html('enable', $behaviour, 't/show',
|
||||
return question_behaviour_icon_html('enable', $behaviour, 'i/show',
|
||||
get_string('disabled', 'question'), get_string('enable'));
|
||||
}
|
||||
}
|
||||
@@ -235,7 +296,7 @@ function question_behaviour_icon_html($action, $behaviour, $icon, $alt, $tip) {
|
||||
global $OUTPUT;
|
||||
return $OUTPUT->action_icon(new moodle_url('/admin/qbehaviours.php',
|
||||
array($action => $behaviour, 'sesskey' => sesskey())),
|
||||
new pix_icon($icon, $alt, 'moodle', array('title' => '', 'class' => 'iconsmall')),
|
||||
null, array('title' => $tip));
|
||||
new pix_icon($icon, $alt, 'moodle', array('title' => '')),
|
||||
null, array('title' => $tip)) . ' ';
|
||||
}
|
||||
|
||||
|
||||
+78
-21
@@ -28,11 +28,12 @@
|
||||
require_once(dirname(__FILE__) . '/../config.php');
|
||||
require_once($CFG->libdir . '/questionlib.php');
|
||||
require_once($CFG->libdir . '/adminlib.php');
|
||||
require_once($CFG->libdir . '/pluginlib.php');
|
||||
require_once($CFG->libdir . '/tablelib.php');
|
||||
|
||||
// Check permissions.
|
||||
require_login();
|
||||
$systemcontext = context_system::instance();
|
||||
$systemcontext = get_context_instance(CONTEXT_SYSTEM);
|
||||
require_capability('moodle/question:config', $systemcontext);
|
||||
$canviewreports = has_capability('report/questioninstances:view', $systemcontext);
|
||||
|
||||
@@ -40,7 +41,7 @@ admin_externalpage_setup('manageqtypes');
|
||||
$thispageurl = new moodle_url('/admin/qtypes.php');
|
||||
|
||||
$qtypes = question_bank::get_all_qtypes();
|
||||
$pluginmanager = core_plugin_manager::instance();
|
||||
$pluginmanager = plugin_manager::instance();
|
||||
|
||||
// Get some data we will need - question counts and which types are needed.
|
||||
$counts = $DB->get_records_sql("
|
||||
@@ -121,6 +122,64 @@ if (($down = optional_param('down', '', PARAM_PLUGIN)) && confirm_sesskey()) {
|
||||
redirect($thispageurl);
|
||||
}
|
||||
|
||||
// Delete.
|
||||
if (($delete = optional_param('delete', '', PARAM_PLUGIN)) && confirm_sesskey()) {
|
||||
// Check it is OK to delete this question type.
|
||||
if ($delete == 'missingtype') {
|
||||
print_error('cannotdeletemissingqtype', 'question', $thispageurl);
|
||||
}
|
||||
|
||||
if (!isset($qtypes[$delete])) {
|
||||
print_error('unknownquestiontype', 'question', $thispageurl, $delete);
|
||||
}
|
||||
|
||||
$qtypename = $qtypes[$delete]->local_name();
|
||||
if ($counts[$delete]->numquestions + $counts[$delete]->numhidden > 0) {
|
||||
print_error('cannotdeleteqtypeinuse', 'question', $thispageurl, $qtypename);
|
||||
}
|
||||
|
||||
if ($needed[$delete] > 0) {
|
||||
print_error('cannotdeleteqtypeneeded', 'question', $thispageurl, $qtypename);
|
||||
}
|
||||
|
||||
// If not yet confirmed, display a confirmation message.
|
||||
if (!optional_param('confirm', '', PARAM_BOOL)) {
|
||||
$qtypename = $qtypes[$delete]->local_name();
|
||||
echo $OUTPUT->header();
|
||||
echo $OUTPUT->heading(get_string('deleteqtypeareyousure', 'question', $qtypename));
|
||||
echo $OUTPUT->confirm(get_string('deleteqtypeareyousuremessage', 'question', $qtypename),
|
||||
new moodle_url($thispageurl, array('delete' => $delete, 'confirm' => 1)),
|
||||
$thispageurl);
|
||||
echo $OUTPUT->footer();
|
||||
exit;
|
||||
}
|
||||
|
||||
// Do the deletion.
|
||||
echo $OUTPUT->header();
|
||||
echo $OUTPUT->heading(get_string('deletingqtype', 'question', $qtypename));
|
||||
|
||||
// Delete any configuration records.
|
||||
if (!unset_all_config_for_plugin('qtype_' . $delete)) {
|
||||
echo $OUTPUT->notification(get_string('errordeletingconfig', 'admin', 'qtype_' . $delete));
|
||||
}
|
||||
unset_config($delete . '_disabled', 'question');
|
||||
unset_config($delete . '_sortorder', 'question');
|
||||
|
||||
// Then the tables themselves
|
||||
drop_plugin_tables($delete, $qtypes[$delete]->plugin_dir() . '/db/install.xml', false);
|
||||
|
||||
// Remove event handlers and dequeue pending events
|
||||
events_uninstall('qtype_' . $delete);
|
||||
|
||||
$a = new stdClass();
|
||||
$a->qtype = $qtypename;
|
||||
$a->directory = $qtypes[$delete]->plugin_dir();
|
||||
echo $OUTPUT->box(get_string('qtypedeletefiles', 'question', $a), 'generalbox', 'notice');
|
||||
echo $OUTPUT->continue_button($thispageurl);
|
||||
echo $OUTPUT->footer();
|
||||
exit;
|
||||
}
|
||||
|
||||
// End of process actions ==================================================
|
||||
|
||||
// Print the page heading.
|
||||
@@ -131,12 +190,12 @@ echo $OUTPUT->heading(get_string('manageqtypes', 'admin'));
|
||||
$table = new flexible_table('qtypeadmintable');
|
||||
$table->define_baseurl($thispageurl);
|
||||
$table->define_columns(array('questiontype', 'numquestions', 'version', 'requires',
|
||||
'availableto', 'uninstall', 'settings'));
|
||||
'availableto', 'delete', 'settings'));
|
||||
$table->define_headers(array(get_string('questiontype', 'question'), get_string('numquestions', 'question'),
|
||||
get_string('version'), get_string('requires', 'admin'), get_string('availableq', 'question'),
|
||||
get_string('settings'), get_string('uninstallplugin', 'core_admin')));
|
||||
get_string('delete'), get_string('settings')));
|
||||
$table->set_attribute('id', 'qtypes');
|
||||
$table->set_attribute('class', 'admintable generaltable');
|
||||
$table->set_attribute('class', 'generaltable generalbox boxaligncenter boxwidthwide');
|
||||
$table->setup();
|
||||
|
||||
// Add a row for each question type.
|
||||
@@ -198,7 +257,7 @@ foreach ($sortedqtypes as $qtypename => $localname) {
|
||||
$rowclass = 'dimmed_text';
|
||||
}
|
||||
} else {
|
||||
$icons = $OUTPUT->spacer();
|
||||
$icons = $OUTPUT->spacer() . ' ';
|
||||
}
|
||||
|
||||
// Move icons.
|
||||
@@ -206,6 +265,15 @@ foreach ($sortedqtypes as $qtypename => $localname) {
|
||||
$icons .= question_type_icon_html('down', $qtypename, 't/down', get_string('down'), '');
|
||||
$row[] = $icons;
|
||||
|
||||
// Delete link, if available.
|
||||
if ($needed[$qtypename]) {
|
||||
$row[] = '';
|
||||
} else {
|
||||
$row[] = html_writer::link(new moodle_url($thispageurl,
|
||||
array('delete' => $qtypename, 'sesskey' => sesskey())), get_string('delete'),
|
||||
array('title' => get_string('uninstallqtype', 'question')));
|
||||
}
|
||||
|
||||
// Settings link, if available.
|
||||
$settings = admin_get_root()->locate('qtypesetting' . $qtypename);
|
||||
if ($settings instanceof admin_externalpage) {
|
||||
@@ -217,17 +285,6 @@ foreach ($sortedqtypes as $qtypename => $localname) {
|
||||
$row[] = '';
|
||||
}
|
||||
|
||||
// Uninstall link, if available.
|
||||
if ($needed[$qtypename]) {
|
||||
$row[] = '';
|
||||
} else {
|
||||
$uninstallurl = core_plugin_manager::instance()->get_uninstall_url('qtype_'.$qtypename, 'manage');
|
||||
if ($uninstallurl) {
|
||||
$row[] = html_writer::link($uninstallurl, get_string('uninstallplugin', 'core_admin'),
|
||||
array('title' => get_string('uninstallqtype', 'question')));
|
||||
}
|
||||
}
|
||||
|
||||
$table->add_data($row, $rowclass);
|
||||
}
|
||||
|
||||
@@ -237,10 +294,10 @@ echo $OUTPUT->footer();
|
||||
|
||||
function question_types_enable_disable_icons($qtypename, $createable) {
|
||||
if ($createable) {
|
||||
return question_type_icon_html('disable', $qtypename, 't/hide',
|
||||
return question_type_icon_html('disable', $qtypename, 'i/hide',
|
||||
get_string('enabled', 'question'), get_string('disable'));
|
||||
} else {
|
||||
return question_type_icon_html('enable', $qtypename, 't/show',
|
||||
return question_type_icon_html('enable', $qtypename, 'i/show',
|
||||
get_string('disabled', 'question'), get_string('enable'));
|
||||
}
|
||||
}
|
||||
@@ -249,7 +306,7 @@ function question_type_icon_html($action, $qtypename, $icon, $alt, $tip) {
|
||||
global $OUTPUT;
|
||||
return $OUTPUT->action_icon(new moodle_url('/admin/qtypes.php',
|
||||
array($action => $qtypename, 'sesskey' => sesskey())),
|
||||
new pix_icon($icon, $alt, 'moodle', array('title' => '', 'class' => 'iconsmall')),
|
||||
null, array('title' => $tip));
|
||||
new pix_icon($icon, $alt, 'moodle', array('title' => '')),
|
||||
null, array('title' => $tip)) . ' ';
|
||||
}
|
||||
|
||||
|
||||
@@ -58,14 +58,17 @@ if (!empty($registeredhub) and $registeredhub->token == $token) {
|
||||
|
||||
echo $OUTPUT->header();
|
||||
echo $OUTPUT->heading(get_string('registrationconfirmed', 'hub'), 3, 'main');
|
||||
$hublink = html_writer::tag('a', $hubname, array('href' => $url));
|
||||
|
||||
$registeredhub->token = $newtoken;
|
||||
$registeredhub->confirmed = 1;
|
||||
$registeredhub->hubname = $hubname;
|
||||
$registrationmanager->update_registeredhub($registeredhub);
|
||||
|
||||
// Display notification message.
|
||||
echo $OUTPUT->notification(get_string('registrationconfirmedon', 'hub'), 'notifysuccess');
|
||||
//display notficiation message
|
||||
$notificationmessage = $OUTPUT->notification(
|
||||
get_string('registrationconfirmedon', 'hub', $hublink), 'notifysuccess');
|
||||
echo $notificationmessage;
|
||||
|
||||
//display continue button
|
||||
$registrationpage = new moodle_url('/admin/registration/index.php');
|
||||
|
||||
@@ -49,10 +49,8 @@ class site_unregistration_form extends moodleform {
|
||||
$unregisterlabel = get_string('unregister', 'hub');
|
||||
$mform->addElement('checkbox', 'unpublishalladvertisedcourses', '',
|
||||
' ' . get_string('unpublishalladvertisedcourses', 'hub'));
|
||||
$mform->setType('unpublishalladvertisedcourses', PARAM_INT);
|
||||
$mform->addElement('checkbox', 'unpublishalluploadedcourses', '',
|
||||
' ' . get_string('unpublishalluploadedcourses', 'hub'));
|
||||
$mform->setType('unpublishalluploadedcourses', PARAM_INT);
|
||||
|
||||
$mform->addElement('hidden', 'confirm', 1);
|
||||
$mform->setType('confirm', PARAM_INT);
|
||||
@@ -84,6 +82,7 @@ class site_clean_registration_data_form extends moodleform {
|
||||
$unregisterlabel = get_string('forceunregister', 'hub');
|
||||
$mform->addElement('static', '', get_string('warning', 'hub'), get_string('forceunregisterconfirmation', 'hub', $hubname));
|
||||
|
||||
|
||||
$mform->addElement('hidden', 'confirm', 1);
|
||||
$mform->setType('confirm', PARAM_INT);
|
||||
$mform->addElement('hidden', 'unregistration', 1);
|
||||
@@ -137,8 +136,8 @@ class hub_selector_form extends moodleform {
|
||||
$options = array();
|
||||
foreach ($hubs as $hub) {
|
||||
//to not display a name longer than 100 character (too big)
|
||||
if (core_text::strlen($hub['name']) > 100) {
|
||||
$hubname = core_text::substr($hub['name'], 0, 100);
|
||||
if (textlib::strlen($hub['name']) > 100) {
|
||||
$hubname = textlib::substr($hub['name'], 0, 100);
|
||||
$hubname = $hubname . "...";
|
||||
} else {
|
||||
$hubname = $hub['name'];
|
||||
@@ -150,7 +149,6 @@ class hub_selector_form extends moodleform {
|
||||
if (!empty($hubs)) {
|
||||
$mform->addElement('select', 'publichub', get_string('publichub', 'hub'),
|
||||
$options, array("size" => 15));
|
||||
$mform->setType('publichub', PARAM_URL);
|
||||
}
|
||||
|
||||
$mform->addElement('static', 'or', '', get_string('orenterprivatehub', 'hub'));
|
||||
@@ -158,10 +156,8 @@ class hub_selector_form extends moodleform {
|
||||
//Private hub
|
||||
$mform->addElement('text', 'unlistedurl', get_string('privatehuburl', 'hub'),
|
||||
array('class' => 'registration_textfield'));
|
||||
$mform->setType('unlistedurl', PARAM_URL);
|
||||
$mform->addElement('text', 'password', get_string('password'),
|
||||
array('class' => 'registration_textfield'));
|
||||
$mform->setType('password', PARAM_RAW);
|
||||
|
||||
$this->add_action_buttons(false, get_string('selecthub', 'hub'));
|
||||
}
|
||||
@@ -175,8 +171,11 @@ class hub_selector_form extends moodleform {
|
||||
|
||||
$unlistedurl = $this->_form->_submitValues['unlistedurl'];
|
||||
|
||||
if (empty($unlistedurl)) {
|
||||
$errors['unlistedurl'] = get_string('badurlformat', 'hub');
|
||||
if (!empty($unlistedurl)) {
|
||||
$unlistedurltotest = clean_param($unlistedurl, PARAM_URL);
|
||||
if (empty($unlistedurltotest)) {
|
||||
$errors['unlistedurl'] = get_string('badurlformat', 'hub');
|
||||
}
|
||||
}
|
||||
|
||||
return $errors;
|
||||
@@ -204,7 +203,7 @@ class site_registration_form extends moodleform {
|
||||
$cleanhuburl = clean_param($huburl, PARAM_ALPHANUMEXT);
|
||||
$sitename = get_config('hub', 'site_name_' . $cleanhuburl);
|
||||
if ($sitename === false) {
|
||||
$sitename = format_string($site->fullname, true, array('context' => context_course::instance(SITEID)));
|
||||
$sitename = format_string($site->fullname, true, array('context' => get_context_instance(CONTEXT_COURSE, SITEID)));
|
||||
}
|
||||
$sitedescription = get_config('hub', 'site_description_' . $cleanhuburl);
|
||||
if ($sitedescription === false) {
|
||||
@@ -244,11 +243,7 @@ class site_registration_form extends moodleform {
|
||||
$postsnumber = get_config('hub', 'site_postsnumber_' . $cleanhuburl);
|
||||
$questionsnumber = get_config('hub', 'site_questionsnumber_' . $cleanhuburl);
|
||||
$resourcesnumber = get_config('hub', 'site_resourcesnumber_' . $cleanhuburl);
|
||||
$badgesnumber = get_config('hub', 'site_badges_' . $cleanhuburl);
|
||||
$issuedbadgesnumber = get_config('hub', 'site_issuedbadges_' . $cleanhuburl);
|
||||
$mediancoursesize = get_config('hub', 'site_mediancoursesize_' . $cleanhuburl);
|
||||
$participantnumberaveragecfg = get_config('hub', 'site_participantnumberaverage_' . $cleanhuburl);
|
||||
$modulenumberaveragecfg = get_config('hub', 'site_modulenumberaverage_' . $cleanhuburl);
|
||||
|
||||
//hidden parameters
|
||||
$mform->addElement('hidden', 'huburl', $huburl);
|
||||
@@ -275,7 +270,6 @@ class site_registration_form extends moodleform {
|
||||
$options[HUB_SITELINKPUBLISHED] = $registrationmanager->get_site_privacy_string(HUB_SITELINKPUBLISHED);
|
||||
$mform->addElement('select', 'privacy', get_string('siteprivacy', 'hub'), $options);
|
||||
$mform->setDefault('privacy', $privacy);
|
||||
$mform->setType('privacy', PARAM_ALPHA);
|
||||
$mform->addHelpButton('privacy', 'privacy', 'hub');
|
||||
unset($options);
|
||||
|
||||
@@ -287,7 +281,7 @@ class site_registration_form extends moodleform {
|
||||
$mform->addHelpButton('description', 'sitedesc', 'hub');
|
||||
|
||||
$languages = get_string_manager()->get_list_of_languages();
|
||||
core_collator::asort($languages);
|
||||
collatorlib::asort($languages);
|
||||
$mform->addElement('select', 'language', get_string('sitelang', 'hub'),
|
||||
$languages);
|
||||
$mform->setType('language', PARAM_ALPHANUMEXT);
|
||||
@@ -309,13 +303,11 @@ class site_registration_form extends moodleform {
|
||||
$countries = get_string_manager()->get_list_of_countries();
|
||||
$mform->addElement('select', 'countrycode', get_string('sitecountry', 'hub'), $countries);
|
||||
$mform->setDefault('countrycode', $country);
|
||||
$mform->setType('countrycode', PARAM_ALPHANUMEXT);
|
||||
$mform->addHelpButton('countrycode', 'sitecountry', 'hub');
|
||||
|
||||
$mform->addElement('text', 'geolocation', get_string('sitegeolocation', 'hub'),
|
||||
array('class' => 'registration_textfield'));
|
||||
$mform->setDefault('geolocation', $geolocation);
|
||||
$mform->setType('geolocation', PARAM_RAW);
|
||||
$mform->addHelpButton('geolocation', 'sitegeolocation', 'hub');
|
||||
|
||||
$mform->addElement('text', 'contactname', get_string('siteadmin', 'hub'),
|
||||
@@ -333,7 +325,7 @@ class site_registration_form extends moodleform {
|
||||
$mform->addElement('text', 'contactemail', get_string('siteemail', 'hub'),
|
||||
array('class' => 'registration_textfield'));
|
||||
$mform->addRule('contactemail', $strrequired, 'required', null, 'client');
|
||||
$mform->setType('contactemail', PARAM_EMAIL);
|
||||
$mform->setType('contactemail', PARAM_TEXT);
|
||||
$mform->setDefault('contactemail', $contactemail);
|
||||
$mform->addHelpButton('contactemail', 'siteemail', 'hub');
|
||||
|
||||
@@ -342,7 +334,6 @@ class site_registration_form extends moodleform {
|
||||
$options[1] = get_string("registrationcontactyes");
|
||||
$mform->addElement('select', 'contactable', get_string('siteregistrationcontact', 'hub'), $options);
|
||||
$mform->setDefault('contactable', $contactable);
|
||||
$mform->setType('contactable', PARAM_INT);
|
||||
$mform->addHelpButton('contactable', 'siteregistrationcontact', 'hub');
|
||||
unset($options);
|
||||
|
||||
@@ -351,7 +342,6 @@ class site_registration_form extends moodleform {
|
||||
$options[1] = get_string("registrationyes");
|
||||
$mform->addElement('select', 'emailalert', get_string('siteregistrationemail', 'hub'), $options);
|
||||
$mform->setDefault('emailalert', $emailalert);
|
||||
$mform->setType('emailalert', PARAM_INT);
|
||||
$mform->addHelpButton('emailalert', 'siteregistrationemail', 'hub');
|
||||
unset($options);
|
||||
|
||||
@@ -382,111 +372,80 @@ class site_registration_form extends moodleform {
|
||||
require_once($CFG->dirroot . "/course/lib.php");
|
||||
$participantnumberaverage = number_format(average_number_of_participants(), 2);
|
||||
$modulenumberaverage = number_format(average_number_of_courses_modules(), 2);
|
||||
require_once($CFG->libdir . '/badgeslib.php');
|
||||
$badges = $DB->count_records_select('badge', 'status <> ' . BADGE_STATUS_ARCHIVED);
|
||||
$issuedbadges = $DB->count_records('badge_issued');
|
||||
|
||||
if (HUB_MOODLEORGHUBURL != $huburl) {
|
||||
$mform->addElement('checkbox', 'courses', get_string('sendfollowinginfo', 'hub'),
|
||||
" " . get_string('coursesnumber', 'hub', $coursecount));
|
||||
$mform->setDefault('courses', $coursesnumber != -1);
|
||||
$mform->setType('courses', PARAM_INT);
|
||||
$mform->setDefault('courses', true);
|
||||
$mform->addHelpButton('courses', 'sendfollowinginfo', 'hub');
|
||||
|
||||
$mform->addElement('checkbox', 'users', '',
|
||||
" " . get_string('usersnumber', 'hub', $usercount));
|
||||
$mform->setDefault('users', $usersnumber != -1);
|
||||
$mform->setType('users', PARAM_INT);
|
||||
$mform->setDefault('users', true);
|
||||
|
||||
$mform->addElement('checkbox', 'roleassignments', '',
|
||||
" " . get_string('roleassignmentsnumber', 'hub', $roleassigncount));
|
||||
$mform->setDefault('roleassignments', $roleassignmentsnumber != -1);
|
||||
$mform->setType('roleassignments', PARAM_INT);
|
||||
$mform->setDefault('roleassignments', true);
|
||||
|
||||
$mform->addElement('checkbox', 'posts', '',
|
||||
" " . get_string('postsnumber', 'hub', $postcount));
|
||||
$mform->setDefault('posts', $postsnumber != -1);
|
||||
$mform->setType('posts', PARAM_INT);
|
||||
$mform->setDefault('posts', true);
|
||||
|
||||
$mform->addElement('checkbox', 'questions', '',
|
||||
" " . get_string('questionsnumber', 'hub', $questioncount));
|
||||
$mform->setDefault('questions', $questionsnumber != -1);
|
||||
$mform->setType('questions', PARAM_INT);
|
||||
$mform->setDefault('questions', true);
|
||||
|
||||
$mform->addElement('checkbox', 'resources', '',
|
||||
" " . get_string('resourcesnumber', 'hub', $resourcecount));
|
||||
$mform->setDefault('resources', $resourcesnumber != -1);
|
||||
$mform->setType('resources', PARAM_INT);
|
||||
|
||||
$mform->addElement('checkbox', 'badges', '',
|
||||
" " . get_string('badgesnumber', 'hub', $badges));
|
||||
$mform->setDefault('badges', $badgesnumber != -1);
|
||||
$mform->setType('resources', PARAM_INT);
|
||||
|
||||
$mform->addElement('checkbox', 'issuedbadges', '',
|
||||
" " . get_string('issuedbadgesnumber', 'hub', $issuedbadges));
|
||||
$mform->setDefault('issuedbadges', $issuedbadgesnumber != -1);
|
||||
$mform->setType('resources', PARAM_INT);
|
||||
$mform->setDefault('resources', true);
|
||||
|
||||
$mform->addElement('checkbox', 'participantnumberaverage', '',
|
||||
" " . get_string('participantnumberaverage', 'hub', $participantnumberaverage));
|
||||
$mform->setDefault('participantnumberaverage', $participantnumberaveragecfg != -1);
|
||||
$mform->setType('participantnumberaverage', PARAM_FLOAT);
|
||||
$mform->setDefault('participantnumberaverage', true);
|
||||
|
||||
$mform->addElement('checkbox', 'modulenumberaverage', '',
|
||||
" " . get_string('modulenumberaverage', 'hub', $modulenumberaverage));
|
||||
$mform->setDefault('modulenumberaverage', $modulenumberaveragecfg != -1);
|
||||
$mform->setType('modulenumberaverage', PARAM_FLOAT);
|
||||
$mform->setDefault('modulenumberaverage', true);
|
||||
} else {
|
||||
$mform->addElement('static', 'courseslabel', get_string('sendfollowinginfo', 'hub'),
|
||||
" " . get_string('coursesnumber', 'hub', $coursecount));
|
||||
$mform->addElement('hidden', 'courses', 1);
|
||||
$mform->setType('courses', PARAM_INT);
|
||||
$mform->addElement('hidden', 'courses', true);
|
||||
$mform->setType('courses', PARAM_FLOAT);
|
||||
$mform->addHelpButton('courseslabel', 'sendfollowinginfo', 'hub');
|
||||
|
||||
$mform->addElement('static', 'userslabel', '',
|
||||
" " . get_string('usersnumber', 'hub', $usercount));
|
||||
$mform->addElement('hidden', 'users', 1);
|
||||
$mform->setType('users', PARAM_INT);
|
||||
$mform->addElement('hidden', 'users', true);
|
||||
$mform->setType('users', PARAM_FLOAT);
|
||||
|
||||
$mform->addElement('static', 'roleassignmentslabel', '',
|
||||
" " . get_string('roleassignmentsnumber', 'hub', $roleassigncount));
|
||||
$mform->addElement('hidden', 'roleassignments', 1);
|
||||
$mform->setType('roleassignments', PARAM_INT);
|
||||
$mform->addElement('hidden', 'roleassignments', true);
|
||||
$mform->setType('roleassignments', PARAM_FLOAT);
|
||||
|
||||
$mform->addElement('static', 'postslabel', '',
|
||||
" " . get_string('postsnumber', 'hub', $postcount));
|
||||
$mform->addElement('hidden', 'posts', 1);
|
||||
$mform->setType('posts', PARAM_INT);
|
||||
$mform->addElement('hidden', 'posts', true);
|
||||
$mform->setType('posts', PARAM_FLOAT);
|
||||
|
||||
$mform->addElement('static', 'questionslabel', '',
|
||||
" " . get_string('questionsnumber', 'hub', $questioncount));
|
||||
$mform->addElement('hidden', 'questions', 1);
|
||||
$mform->setType('questions', PARAM_INT);
|
||||
$mform->addElement('hidden', 'questions', true);
|
||||
$mform->setType('questions', PARAM_FLOAT);
|
||||
|
||||
$mform->addElement('static', 'resourceslabel', '',
|
||||
" " . get_string('resourcesnumber', 'hub', $resourcecount));
|
||||
$mform->addElement('hidden', 'resources', 1);
|
||||
$mform->setType('resources', PARAM_INT);
|
||||
|
||||
$mform->addElement('static', 'badgeslabel', '',
|
||||
" " . get_string('badgesnumber', 'hub', $badges));
|
||||
$mform->addElement('hidden', 'badges', 1);
|
||||
$mform->setType('badges', PARAM_INT);
|
||||
|
||||
$mform->addElement('static', 'issuedbadgeslabel', '',
|
||||
" " . get_string('issuedbadgesnumber', 'hub', $issuedbadges));
|
||||
$mform->addElement('hidden', 'issuedbadges', true);
|
||||
$mform->setType('issuedbadges', PARAM_INT);
|
||||
$mform->addElement('hidden', 'resources', true);
|
||||
$mform->setType('resources', PARAM_FLOAT);
|
||||
|
||||
$mform->addElement('static', 'participantnumberaveragelabel', '',
|
||||
" " . get_string('participantnumberaverage', 'hub', $participantnumberaverage));
|
||||
$mform->addElement('hidden', 'participantnumberaverage', 1);
|
||||
$mform->addElement('hidden', 'participantnumberaverage', true);
|
||||
$mform->setType('participantnumberaverage', PARAM_FLOAT);
|
||||
|
||||
$mform->addElement('static', 'modulenumberaveragelabel', '',
|
||||
" " . get_string('modulenumberaverage', 'hub', $modulenumberaverage));
|
||||
$mform->addElement('hidden', 'modulenumberaverage', 1);
|
||||
$mform->addElement('hidden', 'modulenumberaverage', true);
|
||||
$mform->setType('modulenumberaverage', PARAM_FLOAT);
|
||||
}
|
||||
|
||||
|
||||
@@ -22,9 +22,9 @@
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL
|
||||
* @copyright (C) 1999 onwards Martin Dougiamas http://dougiamas.com
|
||||
*
|
||||
* On this page the administrator selects which hub he wants to register (except for moodle.net)
|
||||
* Admins can register with moodle.net via the site admin menu "Registration" link.
|
||||
* On this page the administrator can also unregister from any hubs including moodle.net.
|
||||
* On this page the administrator selects which hub he wants to register,
|
||||
* except for MOOCH. Admins can register with MOOCH with the top admin menu "Registration" link.
|
||||
* On this page the administrator can also unregister from any hubs, including MOOCH.
|
||||
*/
|
||||
|
||||
require('../../config.php');
|
||||
|
||||
+27
-42
@@ -53,30 +53,31 @@ class registration_manager {
|
||||
public function cron() {
|
||||
global $CFG;
|
||||
if (extension_loaded('xmlrpc')) {
|
||||
$function = 'hub_update_site_info';
|
||||
require_once($CFG->dirroot . "/webservice/xmlrpc/lib.php");
|
||||
//check if the last registration cron update was less than a week ago
|
||||
$lastcron = get_config('registration', 'crontime');
|
||||
if ($lastcron === false or $lastcron < strtotime("-7 day")) { //set to a week, see MDL-23704
|
||||
$function = 'hub_update_site_info';
|
||||
require_once($CFG->dirroot . "/webservice/xmlrpc/lib.php");
|
||||
|
||||
// Update all hubs where the site is registered.
|
||||
$hubs = $this->get_registered_on_hubs();
|
||||
if (empty($hubs)) {
|
||||
mtrace(get_string('registrationwarning', 'admin'));
|
||||
}
|
||||
foreach ($hubs as $hub) {
|
||||
// Update the registration.
|
||||
$siteinfo = $this->get_site_info($hub->huburl);
|
||||
$params = array('siteinfo' => $siteinfo);
|
||||
$serverurl = $hub->huburl . "/local/hub/webservice/webservices.php";
|
||||
$xmlrpcclient = new webservice_xmlrpc_client($serverurl, $hub->token);
|
||||
try {
|
||||
$result = $xmlrpcclient->call($function, $params);
|
||||
$this->update_registeredhub($hub); // To update timemodified.
|
||||
mtrace(get_string('siteupdatedcron', 'hub', $hub->hubname));
|
||||
} catch (Exception $e) {
|
||||
$errorparam = new stdClass();
|
||||
$errorparam->errormessage = $e->getMessage();
|
||||
$errorparam->hubname = $hub->hubname;
|
||||
mtrace(get_string('errorcron', 'hub', $errorparam));
|
||||
//update all hub where the site is registered on
|
||||
$hubs = $this->get_registered_on_hubs();
|
||||
foreach ($hubs as $hub) {
|
||||
//update the registration
|
||||
$siteinfo = $this->get_site_info($hub->huburl);
|
||||
$params = array('siteinfo' => $siteinfo);
|
||||
$serverurl = $hub->huburl . "/local/hub/webservice/webservices.php";
|
||||
$xmlrpcclient = new webservice_xmlrpc_client($serverurl, $hub->token);
|
||||
try {
|
||||
$result = $xmlrpcclient->call($function, $params);
|
||||
mtrace(get_string('siteupdatedcron', 'hub', $hub->hubname));
|
||||
} catch (Exception $e) {
|
||||
$errorparam = new stdClass();
|
||||
$errorparam->errormessage = $e->getMessage();
|
||||
$errorparam->hubname = $hub->hubname;
|
||||
mtrace(get_string('errorcron', 'hub', $errorparam));
|
||||
}
|
||||
}
|
||||
set_config('crontime', time(), 'registration');
|
||||
}
|
||||
} else {
|
||||
mtrace(get_string('errorcronnoxmlrpc', 'hub'));
|
||||
@@ -117,7 +118,6 @@ class registration_manager {
|
||||
*/
|
||||
public function add_registeredhub($hub) {
|
||||
global $DB;
|
||||
$hub->timemodified = time();
|
||||
$id = $DB->insert_record('registration_hubs', $hub);
|
||||
return $id;
|
||||
}
|
||||
@@ -171,16 +171,15 @@ class registration_manager {
|
||||
|
||||
/**
|
||||
* Update a registered hub (mostly use to update the confirmation status)
|
||||
* @param object $hub the hub
|
||||
* @param object $communication the hub
|
||||
*/
|
||||
public function update_registeredhub($hub) {
|
||||
public function update_registeredhub($communication) {
|
||||
global $DB;
|
||||
$hub->timemodified = time();
|
||||
$DB->update_record('registration_hubs', $hub);
|
||||
$DB->update_record('registration_hubs', $communication);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return all hubs where the site is registered
|
||||
* Return all hubs where the site is registered on
|
||||
*/
|
||||
public function get_registered_on_hubs() {
|
||||
global $DB;
|
||||
@@ -248,20 +247,6 @@ class registration_manager {
|
||||
$resourcecount = $DB->count_records('resource');
|
||||
}
|
||||
$siteinfo['resources'] = $resourcecount;
|
||||
// Badge statistics.
|
||||
require_once($CFG->libdir . '/badgeslib.php');
|
||||
if (get_config('hub', 'site_badges_' . $cleanhuburl) == -1) {
|
||||
$badges = -1;
|
||||
} else {
|
||||
$badges = $DB->count_records_select('badge', 'status <> ' . BADGE_STATUS_ARCHIVED);
|
||||
}
|
||||
$siteinfo['badges'] = $badges;
|
||||
if (get_config('hub', 'site_issuedbadges_' . $cleanhuburl) == -1) {
|
||||
$issuedbadges = -1;
|
||||
} else {
|
||||
$issuedbadges = $DB->count_records('badge_issued');
|
||||
}
|
||||
$siteinfo['issuedbadges'] = $issuedbadges;
|
||||
//TODO
|
||||
require_once($CFG->dirroot . "/course/lib.php");
|
||||
if (get_config('hub', 'site_participantnumberaverage_' . $cleanhuburl) == -1) {
|
||||
|
||||
@@ -62,18 +62,7 @@ $siteregistrationform = new site_registration_form('',
|
||||
$fromform = $siteregistrationform->get_data();
|
||||
|
||||
if (!empty($fromform) and confirm_sesskey()) {
|
||||
|
||||
// Set to -1 all optional data marked as "don't send" by the admin.
|
||||
// The function get_site_info() will not calculate the optional data if config is set to -1.
|
||||
$inputnames = array('courses', 'users', 'roleassignments', 'posts', 'questions', 'resources',
|
||||
'badges', 'issuedbadges', 'modulenumberaverage', 'participantnumberaverage');
|
||||
foreach ($inputnames as $inputname) {
|
||||
if (empty($fromform->{$inputname})) {
|
||||
$fromform->{$inputname} = -1;
|
||||
}
|
||||
}
|
||||
|
||||
// Save the settings.
|
||||
//save the settings
|
||||
$cleanhuburl = clean_param($huburl, PARAM_ALPHANUMEXT);
|
||||
set_config('site_name_' . $cleanhuburl, $fromform->name, 'hub');
|
||||
set_config('site_description_' . $cleanhuburl, $fromform->description, 'hub');
|
||||
@@ -95,8 +84,6 @@ if (!empty($fromform) and confirm_sesskey()) {
|
||||
set_config('site_postsnumber_' . $cleanhuburl, $fromform->posts, 'hub');
|
||||
set_config('site_questionsnumber_' . $cleanhuburl, $fromform->questions, 'hub');
|
||||
set_config('site_resourcesnumber_' . $cleanhuburl, $fromform->resources, 'hub');
|
||||
set_config('site_badges_' . $cleanhuburl, $fromform->badges, 'hub');
|
||||
set_config('site_issuedbadges_' . $cleanhuburl, $fromform->issuedbadges, 'hub');
|
||||
set_config('site_modulenumberaverage_' . $cleanhuburl, $fromform->modulenumberaverage, 'hub');
|
||||
set_config('site_participantnumberaverage_' . $cleanhuburl, $fromform->participantnumberaverage, 'hub');
|
||||
}
|
||||
@@ -116,7 +103,6 @@ if ($update and confirm_sesskey()) {
|
||||
$xmlrpcclient = new webservice_xmlrpc_client($serverurl, $registeredhub->token);
|
||||
try {
|
||||
$result = $xmlrpcclient->call($function, $params);
|
||||
$registrationmanager->update_registeredhub($registeredhub); // To update timemodified.
|
||||
} catch (Exception $e) {
|
||||
$error = $OUTPUT->notification(get_string('errorregistration', 'hub', $e->getMessage()));
|
||||
}
|
||||
@@ -127,21 +113,6 @@ if ($update and confirm_sesskey()) {
|
||||
if (!empty($fromform) and empty($update) and confirm_sesskey()) {
|
||||
|
||||
if (!empty($fromform) and confirm_sesskey()) { // if the register button has been clicked
|
||||
|
||||
// Retrieve the optional info (specially course number, user number, module number average...).
|
||||
$siteinfo = $registrationmanager->get_site_info($huburl);
|
||||
$fromform->courses = $siteinfo['courses'];
|
||||
$fromform->users = $siteinfo['users'];
|
||||
$fromform->enrolments = $siteinfo['enrolments'];
|
||||
$fromform->posts = $siteinfo['posts'];
|
||||
$fromform->questions = $siteinfo['questions'];
|
||||
$fromform->resources = $siteinfo['resources'];
|
||||
$fromform->badges = $siteinfo['badges'];
|
||||
$fromform->issuedbadges = $siteinfo['issuedbadges'];
|
||||
$fromform->modulenumberaverage = $siteinfo['modulenumberaverage'];
|
||||
$fromform->participantnumberaverage = $siteinfo['participantnumberaverage'];
|
||||
$fromform->street = $siteinfo['street'];
|
||||
|
||||
$params = (array) $fromform; //we are using the form input as the redirection parameters (token, url and name)
|
||||
|
||||
$unconfirmedhub = $registrationmanager->get_unconfirmedhub($huburl);
|
||||
@@ -176,20 +147,8 @@ if (!empty($error)) {
|
||||
echo $error;
|
||||
}
|
||||
|
||||
// Some Moodle.org registration explanation.
|
||||
//some Moodle.org resitration explanation
|
||||
if ($huburl == HUB_MOODLEORGHUBURL) {
|
||||
if (!empty($registeredhub->token)) {
|
||||
if ($registeredhub->timemodified == 0) {
|
||||
$registrationmessage = get_string('pleaserefreshregistrationunknown', 'admin');
|
||||
} else {
|
||||
$lastupdated = userdate($registeredhub->timemodified, get_string('strftimedate', 'langconfig'));
|
||||
$registrationmessage = get_string('pleaserefreshregistration', 'admin', $lastupdated);
|
||||
}
|
||||
} else {
|
||||
$registrationmessage = get_string('registrationwarning', 'admin');
|
||||
}
|
||||
echo $OUTPUT->notification($registrationmessage);
|
||||
|
||||
echo $OUTPUT->heading(get_string('registerwithmoodleorg', 'admin'));
|
||||
$renderer = $PAGE->get_renderer('core', 'register');
|
||||
echo $renderer->moodleorg_registration_message();
|
||||
|
||||
@@ -31,18 +31,18 @@
|
||||
class core_register_renderer extends plugin_renderer_base {
|
||||
|
||||
/**
|
||||
* Display message about the benefits of registering on Moodle.org
|
||||
* Display Moodle.org registration message about benefit to register on Moodle.org
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function moodleorg_registration_message() {
|
||||
$moodleorgstatslink = html_writer::link('http://moodle.net/stats',
|
||||
get_string('statsmoodleorg', 'admin'),
|
||||
array('target' => '_blank'));
|
||||
|
||||
$moodleorgregmsg = get_string('registermoodleorg', 'admin');
|
||||
$moodleorgurl = html_writer::link('http://moodle.org', 'Moodle.org');
|
||||
$moodleorgstatsurl = html_writer::link('http://moodle.org/stats', get_string('statsmoodleorg', 'admin'));
|
||||
$moochurl = html_writer::link(HUB_MOODLEORGHUBURL, 'MOOCH');
|
||||
$moodleorgregmsg = get_string('registermoodleorg', 'admin', $moodleorgurl);
|
||||
$items = array(get_string('registermoodleorgli1', 'admin'),
|
||||
get_string('registermoodleorgli2', 'admin', $moodleorgstatslink));
|
||||
get_string('registermoodleorgli2', 'admin', $moodleorgstatsurl),
|
||||
get_string('registermoodleorgli3', 'admin', $moochurl));
|
||||
$moodleorgregmsg .= html_writer::alist($items);
|
||||
return $moodleorgregmsg;
|
||||
}
|
||||
@@ -92,4 +92,4 @@ class core_register_renderer extends plugin_renderer_base {
|
||||
return html_writer::table($table);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
+106
-436
@@ -25,6 +25,7 @@
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
require_once($CFG->libdir . '/pluginlib.php');
|
||||
|
||||
/**
|
||||
* Standard HTML output renderer for core_admin subsystem
|
||||
@@ -120,7 +121,7 @@ class core_admin_renderer extends plugin_renderer_base {
|
||||
$output .= $this->header();
|
||||
$output .= $this->heading(get_string('pluginscheck', 'admin'));
|
||||
$output .= $this->warning(get_string('pluginscheckfailed', 'admin', array('pluginslist' => implode(', ', array_unique($failed)))));
|
||||
$output .= $this->plugins_check_table(core_plugin_manager::instance(), $version, array('xdep' => true));
|
||||
$output .= $this->plugins_check_table(plugin_manager::instance(), $version, array('xdep' => true));
|
||||
$output .= $this->warning(get_string('pluginschecktodo', 'admin'));
|
||||
$output .= $this->continue_button($reloadurl);
|
||||
|
||||
@@ -134,20 +135,17 @@ class core_admin_renderer extends plugin_renderer_base {
|
||||
* during upgrade.
|
||||
* @param string $strnewversion
|
||||
* @param int $maturity
|
||||
* @param string $testsite
|
||||
* @return string HTML to output.
|
||||
*/
|
||||
public function upgrade_confirm_page($strnewversion, $maturity, $testsite) {
|
||||
public function upgrade_confirm_page($strnewversion, $maturity) {
|
||||
$output = '';
|
||||
|
||||
$continueurl = new moodle_url('/admin/index.php', array('confirmupgrade' => 1, 'cache' => 0));
|
||||
$continue = new single_button($continueurl, get_string('continue'), 'get');
|
||||
$cancelurl = new moodle_url('/admin/index.php');
|
||||
$continueurl = new moodle_url('index.php', array('confirmupgrade' => 1));
|
||||
$cancelurl = new moodle_url('index.php');
|
||||
|
||||
$output .= $this->header();
|
||||
$output .= $this->maturity_warning($maturity);
|
||||
$output .= $this->test_site_warning($testsite);
|
||||
$output .= $this->confirm(get_string('upgradesure', 'admin', $strnewversion), $continue, $cancelurl);
|
||||
$output .= $this->confirm(get_string('upgradesure', 'admin', $strnewversion), $continueurl, $cancelurl);
|
||||
$output .= $this->footer();
|
||||
|
||||
return $output;
|
||||
@@ -170,7 +168,7 @@ class core_admin_renderer extends plugin_renderer_base {
|
||||
$output .= $this->environment_check_table($envstatus, $environment_results);
|
||||
|
||||
if (!$envstatus) {
|
||||
$output .= $this->upgrade_reload(new moodle_url('/admin/index.php'), array('confirmupgrade' => 1, 'cache' => 0));
|
||||
$output .= $this->upgrade_reload(new moodle_url('/admin/index.php'), array('confirmupgrade' => 1));
|
||||
|
||||
} else {
|
||||
$output .= $this->notification(get_string('environmentok', 'admin'), 'notifysuccess');
|
||||
@@ -179,7 +177,7 @@ class core_admin_renderer extends plugin_renderer_base {
|
||||
$output .= $this->box(get_string('langpackwillbeupdated', 'admin'), 'generalbox', 'notice');
|
||||
}
|
||||
|
||||
$output .= $this->continue_button(new moodle_url('/admin/index.php', array('confirmupgrade' => 1, 'confirmrelease' => 1, 'cache' => 0)));
|
||||
$output .= $this->continue_button(new moodle_url('/admin/index.php', array('confirmupgrade' => 1, 'confirmrelease' => 1)));
|
||||
}
|
||||
|
||||
$output .= $this->footer();
|
||||
@@ -189,15 +187,15 @@ class core_admin_renderer extends plugin_renderer_base {
|
||||
|
||||
/**
|
||||
* Display the upgrade page that lists all the plugins that require attention.
|
||||
* @param core_plugin_manager $pluginman provides information about the plugins.
|
||||
* @param \core\update\checker $checker provides information about available updates.
|
||||
* @param plugin_manager $pluginman provides information about the plugins.
|
||||
* @param available_update_checker $checker provides information about available updates.
|
||||
* @param int $version the version of the Moodle code from version.php.
|
||||
* @param bool $showallplugins
|
||||
* @param moodle_url $reloadurl
|
||||
* @param moodle_url $continueurl
|
||||
* @return string HTML to output.
|
||||
*/
|
||||
public function upgrade_plugin_check_page(core_plugin_manager $pluginman, \core\update\checker $checker,
|
||||
public function upgrade_plugin_check_page(plugin_manager $pluginman, available_update_checker $checker,
|
||||
$version, $showallplugins, $reloadurl, $continueurl) {
|
||||
global $CFG;
|
||||
|
||||
@@ -236,62 +234,6 @@ class core_admin_renderer extends plugin_renderer_base {
|
||||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* Prints a page with a summary of plugin deployment to be confirmed.
|
||||
*
|
||||
* @param \core\update\deployer $deployer
|
||||
* @param array $data deployer's data package as returned by {@link \core\update\deployer::submitted_data()}
|
||||
* @return string
|
||||
*/
|
||||
public function upgrade_plugin_confirm_deploy_page(\core\update\deployer $deployer, array $data) {
|
||||
|
||||
if (!$deployer->initialized()) {
|
||||
throw new coding_exception('Unable to render a page for non-initialized deployer.');
|
||||
}
|
||||
|
||||
if (empty($data['updateinfo'])) {
|
||||
throw new coding_exception('Missing required data component.');
|
||||
}
|
||||
|
||||
$updateinfo = $data['updateinfo'];
|
||||
|
||||
$output = '';
|
||||
$output .= $this->header();
|
||||
$output .= $this->container_start('generalbox updateplugin', 'notice');
|
||||
|
||||
$a = new stdClass();
|
||||
if (get_string_manager()->string_exists('pluginname', $updateinfo->component)) {
|
||||
$a->name = get_string('pluginname', $updateinfo->component);
|
||||
} else {
|
||||
$a->name = $updateinfo->component;
|
||||
}
|
||||
|
||||
if (isset($updateinfo->release)) {
|
||||
$a->version = $updateinfo->release . ' (' . $updateinfo->version . ')';
|
||||
} else {
|
||||
$a->version = $updateinfo->version;
|
||||
}
|
||||
$a->url = $updateinfo->download;
|
||||
|
||||
$output .= $this->output->heading(get_string('updatepluginconfirm', 'core_plugin'));
|
||||
$output .= $this->output->container(format_text(get_string('updatepluginconfirminfo', 'core_plugin', $a)), 'updatepluginconfirminfo');
|
||||
$output .= $this->output->container(get_string('updatepluginconfirmwarning', 'core_plugin', 'updatepluginconfirmwarning'));
|
||||
|
||||
if ($repotype = $deployer->plugin_external_source($data['updateinfo'])) {
|
||||
$output .= $this->output->container(get_string('updatepluginconfirmexternal', 'core_plugin', $repotype), 'updatepluginconfirmexternal');
|
||||
}
|
||||
|
||||
$widget = $deployer->make_execution_widget($data['updateinfo'], $data['returnurl']);
|
||||
$output .= $this->output->render($widget);
|
||||
|
||||
$output .= $this->output->single_button($data['callerurl'], get_string('cancel', 'core'), 'get');
|
||||
|
||||
$output .= $this->container_end();
|
||||
$output .= $this->footer();
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the admin notifications page.
|
||||
* @param int $maturity
|
||||
@@ -301,15 +243,14 @@ class core_admin_renderer extends plugin_renderer_base {
|
||||
* @param bool $dbproblems warn db has problems
|
||||
* @param bool $maintenancemode warn in maintenance mode
|
||||
* @param bool $buggyiconvnomb warn iconv problems
|
||||
* @param array|null $availableupdates array of \core\update\info objects or null
|
||||
* @param array|null $availableupdates array of available_update_info objects or null
|
||||
* @param int|null $availableupdatesfetch timestamp of the most recent updates fetch or null (unknown)
|
||||
* @param string[] $cachewarnings An array containing warnings from the Cache API.
|
||||
*
|
||||
* @return string HTML to output.
|
||||
*/
|
||||
public function admin_notifications_page($maturity, $insecuredataroot, $errorsdisplayed,
|
||||
$cronoverdue, $dbproblems, $maintenancemode, $availableupdates, $availableupdatesfetch,
|
||||
$buggyiconvnomb, $registered, array $cachewarnings = array()) {
|
||||
$buggyiconvnomb, $registered) {
|
||||
global $CFG;
|
||||
$output = '';
|
||||
|
||||
@@ -322,7 +263,6 @@ class core_admin_renderer extends plugin_renderer_base {
|
||||
$output .= $this->cron_overdue_warning($cronoverdue);
|
||||
$output .= $this->db_problems($dbproblems);
|
||||
$output .= $this->maintenance_mode_warning($maintenancemode);
|
||||
$output .= $this->cache_warnings($cachewarnings);
|
||||
$output .= $this->registration_warning($registered);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
@@ -338,30 +278,22 @@ class core_admin_renderer extends plugin_renderer_base {
|
||||
/**
|
||||
* Display the plugin management page (admin/plugins.php).
|
||||
*
|
||||
* The filtering options array may contain following items:
|
||||
* bool contribonly - show only contributed extensions
|
||||
* bool updatesonly - show only plugins with an available update
|
||||
*
|
||||
* @param core_plugin_manager $pluginman
|
||||
* @param \core\update\checker $checker
|
||||
* @param array $options filtering options
|
||||
* @param plugin_manager $pluginman
|
||||
* @param available_update_checker $checker
|
||||
* @return string HTML to output.
|
||||
*/
|
||||
public function plugin_management_page(core_plugin_manager $pluginman, \core\update\checker $checker, array $options = array()) {
|
||||
public function plugin_management_page(plugin_manager $pluginman, available_update_checker $checker) {
|
||||
global $CFG;
|
||||
|
||||
$output = '';
|
||||
|
||||
$output .= $this->header();
|
||||
$output .= $this->heading(get_string('pluginsoverview', 'core_admin'));
|
||||
$output .= $this->plugins_overview_panel($pluginman, $options);
|
||||
$output .= $this->plugins_overview_panel($pluginman);
|
||||
|
||||
if (empty($CFG->disableupdatenotifications)) {
|
||||
$output .= $this->container_start('checkforupdates');
|
||||
$output .= $this->single_button(
|
||||
new moodle_url($this->page->url, array_merge($options, array('fetchremote' => 1))),
|
||||
get_string('checkforupdates', 'core_plugin')
|
||||
);
|
||||
$output .= $this->single_button(new moodle_url($this->page->url, array('fetchremote' => 1)), get_string('checkforupdates', 'core_plugin'));
|
||||
if ($timefetched = $checker->get_last_timefetched()) {
|
||||
$output .= $this->container(get_string('checkforupdateslast', 'core_plugin',
|
||||
userdate($timefetched, get_string('strftimedatetime', 'core_langconfig'))));
|
||||
@@ -369,104 +301,12 @@ class core_admin_renderer extends plugin_renderer_base {
|
||||
$output .= $this->container_end();
|
||||
}
|
||||
|
||||
$output .= $this->box($this->plugins_control_panel($pluginman, $options), 'generalbox');
|
||||
$output .= $this->box($this->plugins_control_panel($pluginman), 'generalbox');
|
||||
$output .= $this->footer();
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* Display a page to confirm the plugin uninstallation.
|
||||
*
|
||||
* @param core_plugin_manager $pluginman
|
||||
* @param \core\plugininfo\base $pluginfo
|
||||
* @param moodle_url $continueurl URL to continue after confirmation
|
||||
* @param moodle_url $cancelurl URL to to go if cancelled
|
||||
* @return string
|
||||
*/
|
||||
public function plugin_uninstall_confirm_page(core_plugin_manager $pluginman, \core\plugininfo\base $pluginfo, moodle_url $continueurl, moodle_url $cancelurl) {
|
||||
$output = '';
|
||||
|
||||
$pluginname = $pluginman->plugin_name($pluginfo->component);
|
||||
|
||||
$confirm = '<p>' . get_string('uninstallconfirm', 'core_plugin', array('name' => $pluginname)) . '</p>';
|
||||
if ($extraconfirm = $pluginfo->get_uninstall_extra_warning()) {
|
||||
$confirm .= $extraconfirm;
|
||||
}
|
||||
|
||||
$output .= $this->output->header();
|
||||
$output .= $this->output->heading(get_string('uninstalling', 'core_plugin', array('name' => $pluginname)));
|
||||
$output .= $this->output->confirm($confirm, $continueurl, $cancelurl);
|
||||
$output .= $this->output->footer();
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* Display a page with results of plugin uninstallation and offer removal of plugin files.
|
||||
*
|
||||
* @param core_plugin_manager $pluginman
|
||||
* @param \core\plugininfo\base $pluginfo
|
||||
* @param progress_trace_buffer $progress
|
||||
* @param moodle_url $continueurl URL to continue to remove the plugin folder
|
||||
* @return string
|
||||
*/
|
||||
public function plugin_uninstall_results_removable_page(core_plugin_manager $pluginman, \core\plugininfo\base $pluginfo,
|
||||
progress_trace_buffer $progress, moodle_url $continueurl) {
|
||||
$output = '';
|
||||
|
||||
$pluginname = $pluginman->plugin_name($pluginfo->component);
|
||||
|
||||
// Do not show navigation here, they must click one of the buttons.
|
||||
$this->page->set_pagelayout('maintenance');
|
||||
$this->page->set_cacheable(false);
|
||||
|
||||
$output .= $this->output->header();
|
||||
$output .= $this->output->heading(get_string('uninstalling', 'core_plugin', array('name' => $pluginname)));
|
||||
|
||||
$output .= $this->output->box($progress->get_buffer(), 'generalbox uninstallresultmessage');
|
||||
|
||||
$confirm = $this->output->container(get_string('uninstalldeleteconfirm', 'core_plugin',
|
||||
array('name' => $pluginname, 'rootdir' => $pluginfo->rootdir)), 'uninstalldeleteconfirm');
|
||||
|
||||
if ($repotype = $pluginman->plugin_external_source($pluginfo->component)) {
|
||||
$confirm .= $this->output->container(get_string('uninstalldeleteconfirmexternal', 'core_plugin', $repotype),
|
||||
'uninstalldeleteconfirmexternal');
|
||||
}
|
||||
|
||||
// After any uninstall we must execute full upgrade to finish the cleanup!
|
||||
$output .= $this->output->confirm($confirm, $continueurl, new moodle_url('/admin/index.php'));
|
||||
$output .= $this->output->footer();
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* Display a page with results of plugin uninstallation and inform about the need to remove plugin files manually.
|
||||
*
|
||||
* @param core_plugin_manager $pluginman
|
||||
* @param \core\plugininfo\base $pluginfo
|
||||
* @param progress_trace_buffer $progress
|
||||
* @return string
|
||||
*/
|
||||
public function plugin_uninstall_results_page(core_plugin_manager $pluginman, \core\plugininfo\base $pluginfo, progress_trace_buffer $progress) {
|
||||
$output = '';
|
||||
|
||||
$pluginname = $pluginfo->component;
|
||||
|
||||
$output .= $this->output->header();
|
||||
$output .= $this->output->heading(get_string('uninstalling', 'core_plugin', array('name' => $pluginname)));
|
||||
|
||||
$output .= $this->output->box($progress->get_buffer(), 'generalbox uninstallresultmessage');
|
||||
|
||||
$output .= $this->output->box(get_string('uninstalldelete', 'core_plugin',
|
||||
array('name' => $pluginname, 'rootdir' => $pluginfo->rootdir)), 'generalbox uninstalldelete');
|
||||
$output .= $this->output->continue_button(new moodle_url('/admin/index.php'));
|
||||
$output .= $this->output->footer();
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the plugin management page (admin/environment.php).
|
||||
* @param array $versions
|
||||
@@ -564,23 +404,11 @@ class core_admin_renderer extends plugin_renderer_base {
|
||||
* @return string HTML to output.
|
||||
*/
|
||||
public function cron_overdue_warning($cronoverdue) {
|
||||
global $CFG;
|
||||
if (!$cronoverdue) {
|
||||
return '';
|
||||
}
|
||||
|
||||
if (empty($CFG->cronclionly)) {
|
||||
$url = new moodle_url('/admin/cron.php');
|
||||
if (!empty($CFG->cronremotepassword)) {
|
||||
$url = new moodle_url('/admin/cron.php', array('password' => $CFG->cronremotepassword));
|
||||
}
|
||||
|
||||
return $this->warning(get_string('cronwarning', 'admin', $url->out()) . ' ' .
|
||||
$this->help_icon('cron', 'admin'));
|
||||
}
|
||||
|
||||
// $CFG->cronclionly is not empty: cron can run only from CLI.
|
||||
return $this->warning(get_string('cronwarningcli', 'admin') . ' ' .
|
||||
return $this->warning(get_string('cronwarning', 'admin') . ' ' .
|
||||
$this->help_icon('cron', 'admin'));
|
||||
}
|
||||
|
||||
@@ -597,19 +425,6 @@ class core_admin_renderer extends plugin_renderer_base {
|
||||
return $this->warning($dbproblems);
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders cache warnings if there are any.
|
||||
*
|
||||
* @param string[] $cachewarnings
|
||||
* @return string
|
||||
*/
|
||||
public function cache_warnings(array $cachewarnings) {
|
||||
if (!count($cachewarnings)) {
|
||||
return '';
|
||||
}
|
||||
return join("\n", array_map(array($this, 'warning'), $cachewarnings));
|
||||
}
|
||||
|
||||
/**
|
||||
* Render an appropriate message if the site in in maintenance mode.
|
||||
* @param bool $maintenancemode
|
||||
@@ -637,26 +452,10 @@ class core_admin_renderer extends plugin_renderer_base {
|
||||
}
|
||||
|
||||
$maturitylevel = get_string('maturity' . $maturity, 'admin');
|
||||
return $this->warning(
|
||||
return $this->box(
|
||||
$this->container(get_string('maturitycorewarning', 'admin', $maturitylevel)) .
|
||||
$this->container($this->doc_link('admin/versions', get_string('morehelp'))),
|
||||
'error');
|
||||
}
|
||||
|
||||
/*
|
||||
* If necessary, displays a warning about upgrading a test site.
|
||||
*
|
||||
* @param string $testsite
|
||||
* @return string HTML
|
||||
*/
|
||||
protected function test_site_warning($testsite) {
|
||||
|
||||
if (!$testsite) {
|
||||
return '';
|
||||
}
|
||||
|
||||
$warning = (get_string('testsiteupgradewarning', 'admin', $testsite));
|
||||
return $this->warning($warning, 'error');
|
||||
'generalbox maturitywarning');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -671,7 +470,7 @@ class core_admin_renderer extends plugin_renderer_base {
|
||||
$copyrighttext = '<a href="http://moodle.org/">Moodle</a> '.
|
||||
'<a href="http://docs.moodle.org/dev/Releases" title="'.$CFG->version.'">'.$CFG->release.'</a><br />'.
|
||||
'Copyright © 1999 onwards, Martin Dougiamas<br />'.
|
||||
'and <a href="http://moodle.org/dev">many other contributors</a>.<br />'.
|
||||
'and <a href="http://docs.moodle.org/dev/Credits">many other contributors</a>.<br />'.
|
||||
'<a href="http://docs.moodle.org/dev/License">GNU Public License</a>';
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@@ -688,54 +487,29 @@ class core_admin_renderer extends plugin_renderer_base {
|
||||
return ''; // No worries.
|
||||
}
|
||||
|
||||
$level = 'warning';
|
||||
|
||||
if ($maturity == MATURITY_ALPHA) {
|
||||
$level = 'error';
|
||||
}
|
||||
|
||||
$maturitylevel = get_string('maturity' . $maturity, 'admin');
|
||||
$warningtext = get_string('maturitycoreinfo', 'admin', $maturitylevel);
|
||||
$warningtext .= ' ' . $this->doc_link('admin/versions', get_string('morehelp'));
|
||||
return $this->warning($warningtext, $level);
|
||||
return $this->box(
|
||||
get_string('maturitycoreinfo', 'admin', $maturitylevel) . ' ' .
|
||||
$this->doc_link('admin/versions', get_string('morehelp')),
|
||||
'generalbox adminwarning maturityinfo maturity'.$maturity);
|
||||
}
|
||||
|
||||
/**
|
||||
* Displays the info about available Moodle core and plugin updates
|
||||
* Displays the info about available Moodle updates
|
||||
*
|
||||
* The structure of the $updates param has changed since 2.4. It contains not only updates
|
||||
* for the core itself, but also for all other installed plugins.
|
||||
*
|
||||
* @param array|null $updates array of (string)component => array of \core\update\info objects or null
|
||||
* @param array|null $updates array of available_update_info objects or null
|
||||
* @param int|null $fetch timestamp of the most recent updates fetch or null (unknown)
|
||||
* @return string
|
||||
*/
|
||||
protected function available_updates($updates, $fetch) {
|
||||
|
||||
$updateinfo = '';
|
||||
$someupdateavailable = false;
|
||||
$updateinfo = $this->box_start('generalbox adminwarning availableupdatesinfo');
|
||||
if (is_array($updates)) {
|
||||
if (is_array($updates['core'])) {
|
||||
$someupdateavailable = true;
|
||||
$updateinfo .= $this->heading(get_string('updateavailable', 'core_admin'), 3);
|
||||
foreach ($updates['core'] as $update) {
|
||||
$updateinfo .= $this->moodle_available_update_info($update);
|
||||
}
|
||||
$updateinfo .= html_writer::tag('p', get_string('updateavailablerecommendation', 'core_admin'),
|
||||
array('class' => 'updateavailablerecommendation'));
|
||||
$updateinfo .= $this->heading(get_string('updateavailable', 'core_admin'), 3);
|
||||
foreach ($updates as $update) {
|
||||
$updateinfo .= $this->moodle_available_update_info($update);
|
||||
}
|
||||
unset($updates['core']);
|
||||
// If something has left in the $updates array now, it is updates for plugins.
|
||||
if (!empty($updates)) {
|
||||
$someupdateavailable = true;
|
||||
$updateinfo .= $this->heading(get_string('updateavailableforplugin', 'core_admin'), 3);
|
||||
$pluginsoverviewurl = new moodle_url('/admin/plugins.php', array('updatesonly' => 1));
|
||||
$updateinfo .= $this->container(get_string('pluginsoverviewsee', 'core_admin',
|
||||
array('url' => $pluginsoverviewurl->out())));
|
||||
}
|
||||
}
|
||||
|
||||
if (!$someupdateavailable) {
|
||||
} else {
|
||||
$now = time();
|
||||
if ($fetch and ($fetch <= $now) and ($now - $fetch < HOURSECS)) {
|
||||
$updateinfo .= $this->heading(get_string('updateavailablenot', 'core_admin'), 3);
|
||||
@@ -743,15 +517,16 @@ class core_admin_renderer extends plugin_renderer_base {
|
||||
}
|
||||
|
||||
$updateinfo .= $this->container_start('checkforupdates');
|
||||
$fetchurl = new moodle_url('/admin/index.php', array('fetchupdates' => 1, 'sesskey' => sesskey(), 'cache' => 0));
|
||||
$updateinfo .= $this->single_button($fetchurl, get_string('checkforupdates', 'core_plugin'));
|
||||
$updateinfo .= $this->single_button(new moodle_url($this->page->url, array('fetchupdates' => 1)), get_string('checkforupdates', 'core_plugin'));
|
||||
if ($fetch) {
|
||||
$updateinfo .= $this->container(get_string('checkforupdateslast', 'core_plugin',
|
||||
userdate($fetch, get_string('strftimedatetime', 'core_langconfig'))));
|
||||
}
|
||||
$updateinfo .= $this->container_end();
|
||||
|
||||
return $this->warning($updateinfo);
|
||||
$updateinfo .= $this->box_end();
|
||||
|
||||
return $updateinfo;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -764,7 +539,7 @@ class core_admin_renderer extends plugin_renderer_base {
|
||||
|
||||
if (!$registered) {
|
||||
|
||||
$registerbutton = $this->single_button(new moodle_url('/admin/registration/register.php',
|
||||
$registerbutton = $this->single_button(new moodle_url('registration/register.php',
|
||||
array('huburl' => HUB_MOODLEORGHUBURL, 'hubname' => 'Moodle.org')),
|
||||
get_string('register', 'admin'));
|
||||
|
||||
@@ -778,9 +553,9 @@ class core_admin_renderer extends plugin_renderer_base {
|
||||
/**
|
||||
* Helper method to render the information about the available Moodle update
|
||||
*
|
||||
* @param \core\update\info $updateinfo information about the available Moodle core update
|
||||
* @param available_update_info $updateinfo information about the available Moodle core update
|
||||
*/
|
||||
protected function moodle_available_update_info(\core\update\info $updateinfo) {
|
||||
protected function moodle_available_update_info(available_update_info $updateinfo) {
|
||||
|
||||
$boxclasses = 'moodleupdateinfo';
|
||||
$info = array();
|
||||
@@ -834,7 +609,7 @@ class core_admin_renderer extends plugin_renderer_base {
|
||||
function upgrade_reload($url) {
|
||||
return html_writer::empty_tag('br') .
|
||||
html_writer::tag('div',
|
||||
html_writer::link($url, $this->pix_icon('i/reload', '', '', array('class' => 'icon icon-pre')) .
|
||||
html_writer::link($url, $this->pix_icon('i/reload', '') .
|
||||
get_string('reload'), array('title' => get_string('reload'))),
|
||||
array('class' => 'continuebutton')) . html_writer::empty_tag('br');
|
||||
}
|
||||
@@ -847,12 +622,12 @@ class core_admin_renderer extends plugin_renderer_base {
|
||||
* (bool)full = false: whether to display up-to-date plugins, too
|
||||
* (bool)xdep = false: display the plugins with unsatisified dependecies only
|
||||
*
|
||||
* @param core_plugin_manager $pluginman provides information about the plugins.
|
||||
* @param plugin_manager $pluginman provides information about the plugins.
|
||||
* @param int $version the version of the Moodle code from version.php.
|
||||
* @param array $options rendering options
|
||||
* @return string HTML code
|
||||
*/
|
||||
public function plugins_check_table(core_plugin_manager $pluginman, $version, array $options = array()) {
|
||||
public function plugins_check_table(plugin_manager $pluginman, $version, array $options = array()) {
|
||||
global $CFG;
|
||||
|
||||
$plugininfo = $pluginman->get_plugins();
|
||||
@@ -908,7 +683,7 @@ class core_admin_renderer extends plugin_renderer_base {
|
||||
$row = new html_table_row();
|
||||
$row->attributes['class'] = 'type-' . $plugin->type . ' name-' . $plugin->type . '_' . $plugin->name;
|
||||
|
||||
if ($this->page->theme->resolve_image_location('icon', $plugin->type . '_' . $plugin->name, null)) {
|
||||
if ($this->page->theme->resolve_image_location('icon', $plugin->type . '_' . $plugin->name)) {
|
||||
$icon = $this->output->pix_icon('icon', '', $plugin->type . '_' . $plugin->name, array('class' => 'smallicon pluginicon'));
|
||||
} else {
|
||||
$icon = $this->output->pix_icon('spacer', '', 'moodle', array('class' => 'smallicon pluginicon noicon'));
|
||||
@@ -945,7 +720,7 @@ class core_admin_renderer extends plugin_renderer_base {
|
||||
$requires = new html_table_cell($this->required_column($plugin, $pluginman, $version));
|
||||
|
||||
$statusisboring = in_array($statuscode, array(
|
||||
core_plugin_manager::PLUGIN_STATUS_NODB, core_plugin_manager::PLUGIN_STATUS_UPTODATE));
|
||||
plugin_manager::PLUGIN_STATUS_NODB, plugin_manager::PLUGIN_STATUS_UPTODATE));
|
||||
|
||||
$coredependency = $plugin->is_core_dependency_satisfied($version);
|
||||
$otherpluginsdependencies = $pluginman->are_dependencies_satisfied($plugin->get_other_required_plugins());
|
||||
@@ -957,7 +732,7 @@ class core_admin_renderer extends plugin_renderer_base {
|
||||
continue;
|
||||
}
|
||||
|
||||
} else if ($statusisboring and $dependenciesok and empty($availableupdates)) {
|
||||
} else if ($isstandard and $statusisboring and $dependenciesok and empty($availableupdates)) {
|
||||
// no change is going to happen to the plugin - display it only
|
||||
// if the user wants to see the full list
|
||||
if (empty($options['full'])) {
|
||||
@@ -992,7 +767,7 @@ class core_admin_renderer extends plugin_renderer_base {
|
||||
$out .= $this->output->heading(get_string('nonehighlighted', 'core_plugin'));
|
||||
if (empty($options['full'])) {
|
||||
$out .= html_writer::link(new moodle_url('/admin/index.php',
|
||||
array('confirmupgrade' => 1, 'confirmrelease' => 1, 'showallplugins' => 1, 'cache' => 0)),
|
||||
array('confirmupgrade' => 1, 'confirmrelease' => 1, 'showallplugins' => 1)),
|
||||
get_string('nonehighlightedinfo', 'core_plugin'));
|
||||
}
|
||||
$out .= $this->output->container_end();
|
||||
@@ -1002,11 +777,11 @@ class core_admin_renderer extends plugin_renderer_base {
|
||||
$out .= $this->output->heading(get_string('somehighlighted', 'core_plugin', $sumofhighlighted));
|
||||
if (empty($options['full'])) {
|
||||
$out .= html_writer::link(new moodle_url('/admin/index.php',
|
||||
array('confirmupgrade' => 1, 'confirmrelease' => 1, 'showallplugins' => 1, 'cache' => 0)),
|
||||
array('confirmupgrade' => 1, 'confirmrelease' => 1, 'showallplugins' => 1)),
|
||||
get_string('somehighlightedinfo', 'core_plugin'));
|
||||
} else {
|
||||
$out .= html_writer::link(new moodle_url('/admin/index.php',
|
||||
array('confirmupgrade' => 1, 'confirmrelease' => 1, 'showallplugins' => 0, 'cache' => 0)),
|
||||
array('confirmupgrade' => 1, 'confirmrelease' => 1, 'showallplugins' => 0)),
|
||||
get_string('somehighlightedonly', 'core_plugin'));
|
||||
}
|
||||
$out .= $this->output->container_end();
|
||||
@@ -1021,12 +796,12 @@ class core_admin_renderer extends plugin_renderer_base {
|
||||
|
||||
/**
|
||||
* Formats the information that needs to go in the 'Requires' column.
|
||||
* @param \core\plugininfo\base $plugin the plugin we are rendering the row for.
|
||||
* @param core_plugin_manager $pluginman provides data on all the plugins.
|
||||
* @param plugininfo_base $plugin the plugin we are rendering the row for.
|
||||
* @param plugin_manager $pluginman provides data on all the plugins.
|
||||
* @param string $version
|
||||
* @return string HTML code
|
||||
*/
|
||||
protected function required_column(\core\plugininfo\base $plugin, core_plugin_manager $pluginman, $version) {
|
||||
protected function required_column(plugininfo_base $plugin, plugin_manager $pluginman, $version) {
|
||||
$requires = array();
|
||||
|
||||
if (!empty($plugin->versionrequires)) {
|
||||
@@ -1041,28 +816,19 @@ class core_admin_renderer extends plugin_renderer_base {
|
||||
}
|
||||
|
||||
foreach ($plugin->get_other_required_plugins() as $component => $requiredversion) {
|
||||
$ok = true;
|
||||
$otherplugin = $pluginman->get_plugin_info($component);
|
||||
$actions = array();
|
||||
|
||||
if (is_null($otherplugin)) {
|
||||
// The required plugin is not installed.
|
||||
$class = 'requires-failed requires-missing';
|
||||
$installurl = new moodle_url('https://moodle.org/plugins/view.php', array('plugin' => $component));
|
||||
$uploadurl = new moodle_url('/admin/tool/installaddon/');
|
||||
$actions[] = html_writer::link($installurl, get_string('dependencyinstall', 'core_plugin'));
|
||||
$actions[] = html_writer::link($uploadurl, get_string('dependencyupload', 'core_plugin'));
|
||||
|
||||
$ok = false;
|
||||
} else if ($requiredversion != ANY_VERSION and $otherplugin->versiondisk < $requiredversion) {
|
||||
// The required plugin is installed but needs to be updated.
|
||||
$class = 'requires-failed requires-outdated';
|
||||
if (!$otherplugin->is_standard()) {
|
||||
$updateurl = new moodle_url($this->page->url, array('sesskey' => sesskey(), 'fetchupdates' => 1));
|
||||
$actions[] = html_writer::link($updateurl, get_string('checkforupdates', 'core_plugin'));
|
||||
}
|
||||
$ok = false;
|
||||
}
|
||||
|
||||
} else {
|
||||
// Already installed plugin with sufficient version.
|
||||
if ($ok) {
|
||||
$class = 'requires-ok';
|
||||
} else {
|
||||
$class = 'requires-failed';
|
||||
}
|
||||
|
||||
if ($requiredversion != ANY_VERSION) {
|
||||
@@ -1070,11 +836,9 @@ class core_admin_renderer extends plugin_renderer_base {
|
||||
} else {
|
||||
$str = 'otherplugin';
|
||||
}
|
||||
|
||||
$requires[] = html_writer::tag('li',
|
||||
html_writer::div(get_string($str, 'core_plugin',
|
||||
array('component' => $component, 'version' => $requiredversion)), 'component').
|
||||
html_writer::div(implode(' | ', $actions), 'actions'),
|
||||
get_string($str, 'core_plugin',
|
||||
array('component' => $component, 'version' => $requiredversion)),
|
||||
array('class' => $class));
|
||||
}
|
||||
|
||||
@@ -1087,11 +851,10 @@ class core_admin_renderer extends plugin_renderer_base {
|
||||
/**
|
||||
* Prints an overview about the plugins - number of installed, number of extensions etc.
|
||||
*
|
||||
* @param core_plugin_manager $pluginman provides information about the plugins
|
||||
* @param array $options filtering options
|
||||
* @param plugin_manager $pluginman provides information about the plugins
|
||||
* @return string as usually
|
||||
*/
|
||||
public function plugins_overview_panel(core_plugin_manager $pluginman, array $options = array()) {
|
||||
public function plugins_overview_panel(plugin_manager $pluginman) {
|
||||
global $CFG;
|
||||
|
||||
$plugininfo = $pluginman->get_plugins();
|
||||
@@ -1100,7 +863,7 @@ class core_admin_renderer extends plugin_renderer_base {
|
||||
|
||||
foreach ($plugininfo as $type => $plugins) {
|
||||
foreach ($plugins as $name => $plugin) {
|
||||
if ($plugin->get_status() === core_plugin_manager::PLUGIN_STATUS_MISSING) {
|
||||
if ($plugin->get_status() === plugin_manager::PLUGIN_STATUS_MISSING) {
|
||||
continue;
|
||||
}
|
||||
$numtotal++;
|
||||
@@ -1117,49 +880,14 @@ class core_admin_renderer extends plugin_renderer_base {
|
||||
}
|
||||
|
||||
$info = array();
|
||||
$filter = array();
|
||||
$somefilteractive = false;
|
||||
$info[] = html_writer::tag('span', get_string('numtotal', 'core_plugin', $numtotal), array('class' => 'info total'));
|
||||
$info[] = html_writer::tag('span', get_string('numdisabled', 'core_plugin', $numdisabled), array('class' => 'info disabled'));
|
||||
$info[] = html_writer::tag('span', get_string('numextension', 'core_plugin', $numextension), array('class' => 'info extension'));
|
||||
if ($numextension > 0) {
|
||||
if (empty($options['contribonly'])) {
|
||||
$filter[] = html_writer::link(
|
||||
new moodle_url($this->page->url, array('contribonly' => 1)),
|
||||
get_string('filtercontribonly', 'core_plugin'),
|
||||
array('class' => 'filter-item show-contribonly')
|
||||
);
|
||||
} else {
|
||||
$filter[] = html_writer::tag('span', get_string('filtercontribonlyactive', 'core_plugin'),
|
||||
array('class' => 'filter-item active show-contribonly'));
|
||||
$somefilteractive = true;
|
||||
}
|
||||
}
|
||||
if ($numupdatable > 0) {
|
||||
$info[] = html_writer::tag('span', get_string('numupdatable', 'core_plugin', $numupdatable), array('class' => 'info updatable'));
|
||||
if (empty($options['updatesonly'])) {
|
||||
$filter[] = html_writer::link(
|
||||
new moodle_url($this->page->url, array('updatesonly' => 1)),
|
||||
get_string('filterupdatesonly', 'core_plugin'),
|
||||
array('class' => 'filter-item show-updatesonly')
|
||||
);
|
||||
} else {
|
||||
$filter[] = html_writer::tag('span', get_string('filterupdatesonlyactive', 'core_plugin'),
|
||||
array('class' => 'filter-item active show-updatesonly'));
|
||||
$somefilteractive = true;
|
||||
}
|
||||
}
|
||||
if ($somefilteractive) {
|
||||
$filter[] = html_writer::link($this->page->url, get_string('filterall', 'core_plugin'), array('class' => 'filter-item show-all'));
|
||||
}
|
||||
|
||||
$output = $this->output->box(implode(html_writer::tag('span', ' ', array('class' => 'separator')), $info), '', 'plugins-overview-panel');
|
||||
|
||||
if (!empty($filter)) {
|
||||
$output .= $this->output->box(implode(html_writer::tag('span', ' ', array('class' => 'separator')), $filter), '', 'plugins-overview-filter');
|
||||
}
|
||||
|
||||
return $output;
|
||||
return $this->output->box(implode(html_writer::tag('span', ' ', array('class' => 'separator')), $info), '', 'plugins-overview-panel');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1167,44 +895,14 @@ class core_admin_renderer extends plugin_renderer_base {
|
||||
*
|
||||
* This default implementation renders all plugins into one big table.
|
||||
*
|
||||
* @param core_plugin_manager $pluginman provides information about the plugins.
|
||||
* @param array $options filtering options
|
||||
* @param plugin_manager $pluginman provides information about the plugins.
|
||||
* @return string HTML code
|
||||
*/
|
||||
public function plugins_control_panel(core_plugin_manager $pluginman, array $options = array()) {
|
||||
public function plugins_control_panel(plugin_manager $pluginman) {
|
||||
global $CFG;
|
||||
|
||||
$plugininfo = $pluginman->get_plugins();
|
||||
|
||||
// Filter the list of plugins according the options.
|
||||
if (!empty($options['updatesonly'])) {
|
||||
$updateable = array();
|
||||
foreach ($plugininfo as $plugintype => $pluginnames) {
|
||||
foreach ($pluginnames as $pluginname => $pluginfo) {
|
||||
if (!empty($pluginfo->availableupdates)) {
|
||||
foreach ($pluginfo->availableupdates as $pluginavailableupdate) {
|
||||
if ($pluginavailableupdate->version > $pluginfo->versiondisk) {
|
||||
$updateable[$plugintype][$pluginname] = $pluginfo;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
$plugininfo = $updateable;
|
||||
}
|
||||
|
||||
if (!empty($options['contribonly'])) {
|
||||
$contribs = array();
|
||||
foreach ($plugininfo as $plugintype => $pluginnames) {
|
||||
foreach ($pluginnames as $pluginname => $pluginfo) {
|
||||
if (!$pluginfo->is_standard()) {
|
||||
$contribs[$plugintype][$pluginname] = $pluginfo;
|
||||
}
|
||||
}
|
||||
}
|
||||
$plugininfo = $contribs;
|
||||
}
|
||||
|
||||
if (empty($plugininfo)) {
|
||||
return '';
|
||||
}
|
||||
@@ -1215,32 +913,26 @@ class core_admin_renderer extends plugin_renderer_base {
|
||||
get_string('displayname', 'core_plugin'),
|
||||
get_string('source', 'core_plugin'),
|
||||
get_string('version', 'core_plugin'),
|
||||
get_string('release', 'core_plugin'),
|
||||
get_string('availability', 'core_plugin'),
|
||||
get_string('actions', 'core_plugin'),
|
||||
get_string('notes','core_plugin'),
|
||||
);
|
||||
$table->headspan = array(1, 1, 1, 1, 1, 2, 1);
|
||||
$table->colclasses = array(
|
||||
'pluginname', 'source', 'version', 'release', 'availability', 'settings', 'uninstall', 'notes'
|
||||
'pluginname', 'source', 'version', 'availability', 'actions', 'notes'
|
||||
);
|
||||
|
||||
foreach ($plugininfo as $type => $plugins) {
|
||||
$heading = $pluginman->plugintype_name_plural($type);
|
||||
$pluginclass = core_plugin_manager::resolve_plugininfo_class($type);
|
||||
if ($manageurl = $pluginclass::get_manage_url()) {
|
||||
$heading = html_writer::link($manageurl, $heading);
|
||||
}
|
||||
$header = new html_table_cell(html_writer::tag('span', $heading, array('id'=>'plugin_type_cell_'.$type)));
|
||||
|
||||
$header = new html_table_cell($pluginman->plugintype_name_plural($type));
|
||||
$header->header = true;
|
||||
$header->colspan = array_sum($table->headspan);
|
||||
$header->colspan = count($table->head);
|
||||
$header = new html_table_row(array($header));
|
||||
$header->attributes['class'] = 'plugintypeheader type-' . $type;
|
||||
$table->data[] = $header;
|
||||
|
||||
if (empty($plugins)) {
|
||||
$msg = new html_table_cell(get_string('noneinstalled', 'core_plugin'));
|
||||
$msg->colspan = array_sum($table->headspan);
|
||||
$msg->colspan = count($table->head);
|
||||
$row = new html_table_row(array($msg));
|
||||
$row->attributes['class'] .= 'msg msg-noneinstalled';
|
||||
$table->data[] = $row;
|
||||
@@ -1252,20 +944,17 @@ class core_admin_renderer extends plugin_renderer_base {
|
||||
$row->attributes['class'] = 'type-' . $plugin->type . ' name-' . $plugin->type . '_' . $plugin->name;
|
||||
|
||||
if ($this->page->theme->resolve_image_location('icon', $plugin->type . '_' . $plugin->name)) {
|
||||
$icon = $this->output->pix_icon('icon', '', $plugin->type . '_' . $plugin->name, array('class' => 'icon pluginicon'));
|
||||
$icon = $this->output->pix_icon('icon', '', $plugin->type . '_' . $plugin->name, array('class' => 'smallicon pluginicon'));
|
||||
} else {
|
||||
$icon = $this->output->pix_icon('spacer', '', 'moodle', array('class' => 'icon pluginicon noicon'));
|
||||
$icon = $this->output->pix_icon('spacer', '', 'moodle', array('class' => 'smallicon pluginicon noicon'));
|
||||
}
|
||||
$status = $plugin->get_status();
|
||||
$row->attributes['class'] .= ' status-'.$status;
|
||||
if ($status === core_plugin_manager::PLUGIN_STATUS_MISSING) {
|
||||
$msg = html_writer::tag('span', get_string('status_missing', 'core_plugin'), array('class' => 'statusmsg'));
|
||||
} else if ($status === core_plugin_manager::PLUGIN_STATUS_NEW) {
|
||||
$msg = html_writer::tag('span', get_string('status_new', 'core_plugin'), array('class' => 'statusmsg'));
|
||||
if ($plugin->get_status() === plugin_manager::PLUGIN_STATUS_MISSING) {
|
||||
$msg = html_writer::tag('span', get_string('status_missing', 'core_plugin'), array('class' => 'notifyproblem'));
|
||||
$row->attributes['class'] .= ' missingfromdisk';
|
||||
} else {
|
||||
$msg = '';
|
||||
}
|
||||
$pluginname = html_writer::tag('div', $icon . '' . $plugin->displayname . ' ' . $msg, array('class' => 'displayname')).
|
||||
$pluginname = html_writer::tag('div', $icon . ' ' . $plugin->displayname . ' ' . $msg, array('class' => 'displayname')).
|
||||
html_writer::tag('div', $plugin->component, array('class' => 'componentname'));
|
||||
$pluginname = new html_table_cell($pluginname);
|
||||
|
||||
@@ -1278,33 +967,33 @@ class core_admin_renderer extends plugin_renderer_base {
|
||||
}
|
||||
|
||||
$version = new html_table_cell($plugin->versiondb);
|
||||
$release = new html_table_cell($plugin->release);
|
||||
|
||||
$isenabled = $plugin->is_enabled();
|
||||
if (is_null($isenabled)) {
|
||||
$availability = new html_table_cell('');
|
||||
} else if ($isenabled) {
|
||||
$row->attributes['class'] .= ' enabled';
|
||||
$availability = new html_table_cell(get_string('pluginenabled', 'core_plugin'));
|
||||
$icon = $this->output->pix_icon('i/hide', get_string('pluginenabled', 'core_plugin'));
|
||||
$availability = new html_table_cell($icon . ' ' . get_string('pluginenabled', 'core_plugin'));
|
||||
} else {
|
||||
$row->attributes['class'] .= ' disabled';
|
||||
$availability = new html_table_cell(get_string('plugindisabled', 'core_plugin'));
|
||||
$icon = $this->output->pix_icon('i/show', get_string('plugindisabled', 'core_plugin'));
|
||||
$availability = new html_table_cell($icon . ' ' . get_string('plugindisabled', 'core_plugin'));
|
||||
}
|
||||
|
||||
$actions = array();
|
||||
|
||||
$settingsurl = $plugin->get_settings_url();
|
||||
if (!is_null($settingsurl)) {
|
||||
$settings = html_writer::link($settingsurl, get_string('settings', 'core_plugin'), array('class' => 'settings'));
|
||||
} else {
|
||||
$settings = '';
|
||||
$actions[] = html_writer::link($settingsurl, get_string('settings', 'core_plugin'), array('class' => 'settings'));
|
||||
}
|
||||
$settings = new html_table_cell($settings);
|
||||
|
||||
if ($uninstallurl = $pluginman->get_uninstall_url($plugin->component, 'overview')) {
|
||||
$uninstall = html_writer::link($uninstallurl, get_string('uninstall', 'core_plugin'));
|
||||
} else {
|
||||
$uninstall = '';
|
||||
$uninstallurl = $plugin->get_uninstall_url();
|
||||
if (!is_null($uninstallurl)) {
|
||||
$actions[] = html_writer::link($uninstallurl, get_string('uninstall', 'core_plugin'), array('class' => 'uninstall'));
|
||||
}
|
||||
$uninstall = new html_table_cell($uninstall);
|
||||
|
||||
$actions = new html_table_cell(implode(html_writer::tag('span', ' ', array('class' => 'separator')), $actions));
|
||||
|
||||
$requriedby = $pluginman->other_plugins_that_require($plugin->component);
|
||||
if ($requriedby) {
|
||||
@@ -1324,7 +1013,7 @@ class core_admin_renderer extends plugin_renderer_base {
|
||||
$notes = new html_table_cell($requiredby.$updateinfo);
|
||||
|
||||
$row->cells = array(
|
||||
$pluginname, $source, $version, $release, $availability, $settings, $uninstall, $notes
|
||||
$pluginname, $source, $version, $availability, $actions, $notes
|
||||
);
|
||||
$table->data[] = $row;
|
||||
}
|
||||
@@ -1339,9 +1028,9 @@ class core_admin_renderer extends plugin_renderer_base {
|
||||
* The passed objects always provides at least the 'version' property containing
|
||||
* the (higher) version of the plugin available.
|
||||
*
|
||||
* @param \core\update\info $updateinfo information about the available update for the plugin
|
||||
* @param available_update_info $updateinfo information about the available update for the plugin
|
||||
*/
|
||||
protected function plugin_available_update_info(\core\update\info $updateinfo) {
|
||||
protected function plugin_available_update_info(available_update_info $updateinfo) {
|
||||
|
||||
$boxclasses = 'pluginupdateinfo';
|
||||
$info = array();
|
||||
@@ -1369,23 +1058,6 @@ class core_admin_renderer extends plugin_renderer_base {
|
||||
$box = $this->output->box_start($boxclasses);
|
||||
$box .= html_writer::tag('div', get_string('updateavailable', 'core_plugin', $updateinfo->version), array('class' => 'version'));
|
||||
$box .= $this->output->box(implode(html_writer::tag('span', ' ', array('class' => 'separator')), $info), '');
|
||||
|
||||
$deployer = \core\update\deployer::instance();
|
||||
if ($deployer->initialized()) {
|
||||
$impediments = $deployer->deployment_impediments($updateinfo);
|
||||
if (empty($impediments)) {
|
||||
$widget = $deployer->make_confirm_widget($updateinfo);
|
||||
$box .= $this->output->render($widget);
|
||||
} else {
|
||||
if (isset($impediments['notwritable'])) {
|
||||
$box .= $this->output->help_icon('notwritable', 'core_plugin', get_string('notwritable', 'core_plugin'));
|
||||
}
|
||||
if (isset($impediments['notdownloadable'])) {
|
||||
$box .= $this->output->help_icon('notdownloadable', 'core_plugin', get_string('notdownloadable', 'core_plugin'));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$box .= $this->output->box_end();
|
||||
|
||||
return $box;
|
||||
@@ -1396,7 +1068,7 @@ class core_admin_renderer extends plugin_renderer_base {
|
||||
* configuration and how it suits Moodle needs.
|
||||
*
|
||||
* @param boolean $result final result of the check (true/false)
|
||||
* @param environment_results[] $environment_results array of results gathered
|
||||
* @param array $environment_results array of results gathered
|
||||
* @return string HTML to output.
|
||||
*/
|
||||
public function environment_check_table($result, $environment_results) {
|
||||
@@ -1408,12 +1080,12 @@ class core_admin_renderer extends plugin_renderer_base {
|
||||
get_string('name'),
|
||||
get_string('info'),
|
||||
get_string('report'),
|
||||
get_string('plugin'),
|
||||
get_string('status'),
|
||||
);
|
||||
$servertable->colclasses = array('centeralign name', 'centeralign info', 'leftalign report', 'leftalign plugin', 'centeralign status');
|
||||
$servertable->attributes['class'] = 'admintable environmenttable generaltable';
|
||||
$servertable->id = 'serverstatus';
|
||||
$servertable->align = array('center', 'center', 'left', 'center');
|
||||
$servertable->wrap = array('nowrap', '', '', 'nowrap');
|
||||
$servertable->size = array('10', 10, '100%', '10');
|
||||
$servertable->attributes['class'] = 'environmenttable generaltable';
|
||||
|
||||
$serverdata = array('ok'=>array(), 'warn'=>array(), 'error'=>array());
|
||||
|
||||
@@ -1421,12 +1093,12 @@ class core_admin_renderer extends plugin_renderer_base {
|
||||
$othertable->head = array(
|
||||
get_string('info'),
|
||||
get_string('report'),
|
||||
get_string('plugin'),
|
||||
get_string('status'),
|
||||
);
|
||||
$othertable->colclasses = array('aligncenter info', 'alignleft report', 'alignleft plugin', 'aligncenter status');
|
||||
$othertable->attributes['class'] = 'admintable environmenttable generaltable';
|
||||
$othertable->id = 'otherserverstatus';
|
||||
$othertable->align = array('center', 'left', 'center');
|
||||
$othertable->wrap = array('', '', 'nowrap');
|
||||
$othertable->size = array(10, '100%', '10');
|
||||
$othertable->attributes['class'] = 'environmenttable generaltable';
|
||||
|
||||
$otherdata = array('ok'=>array(), 'warn'=>array(), 'error'=>array());
|
||||
|
||||
@@ -1440,7 +1112,6 @@ class core_admin_renderer extends plugin_renderer_base {
|
||||
$type = $environment_result->getPart();
|
||||
$info = $environment_result->getInfo();
|
||||
$status = $environment_result->getStatus();
|
||||
$plugin = $environment_result->getPluginName();
|
||||
$error_code = $environment_result->getErrorCode();
|
||||
// Process Report field
|
||||
$rec = new stdClass();
|
||||
@@ -1517,8 +1188,7 @@ class core_admin_renderer extends plugin_renderer_base {
|
||||
if (!empty($info)){
|
||||
$linkparts[] = $info;
|
||||
}
|
||||
// Plugin environments do not have docs pages yet.
|
||||
if (empty($CFG->docroot) or $environment_result->plugin) {
|
||||
if (empty($CFG->docroot)) {
|
||||
$report = get_string($stringtouse, 'admin', $rec);
|
||||
} else {
|
||||
$report = $this->doc_link(join($linkparts, '/'), get_string($stringtouse, 'admin', $rec));
|
||||
@@ -1544,9 +1214,9 @@ class core_admin_renderer extends plugin_renderer_base {
|
||||
|
||||
// Add the row to the table
|
||||
if ($environment_result->getPart() == 'custom_check'){
|
||||
$otherdata[$messagetype][] = array ($info, $report, $plugin, $status);
|
||||
$otherdata[$messagetype][] = array ($info, $report, $status);
|
||||
} else {
|
||||
$serverdata[$messagetype][] = array ($type, $info, $report, $plugin, $status);
|
||||
$serverdata[$messagetype][] = array ($type, $info, $report, $status);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+43
-25
@@ -18,7 +18,7 @@
|
||||
* Provides an overview of installed reports
|
||||
*
|
||||
* Displays the list of found reports, their version (if found) and
|
||||
* a link to uninstall the report.
|
||||
* a link to delete the report.
|
||||
*
|
||||
* The code is based on admin/localplugins.php by David Mudrak.
|
||||
*
|
||||
@@ -33,24 +33,55 @@ require_once($CFG->libdir.'/tablelib.php');
|
||||
|
||||
admin_externalpage_setup('managereports');
|
||||
|
||||
$delete = optional_param('delete', '', PARAM_PLUGIN);
|
||||
$confirm = optional_param('confirm', '', PARAM_BOOL);
|
||||
|
||||
/// If data submitted, then process and store.
|
||||
|
||||
if (!empty($delete) and confirm_sesskey()) {
|
||||
echo $OUTPUT->header();
|
||||
echo $OUTPUT->heading(get_string('reports'));
|
||||
|
||||
if (!$confirm) {
|
||||
if (get_string_manager()->string_exists('pluginname', 'report_' . $delete)) {
|
||||
$strpluginname = get_string('pluginname', 'report_' . $delete);
|
||||
} else {
|
||||
$strpluginname = $delete;
|
||||
}
|
||||
echo $OUTPUT->confirm(get_string('reportsdeleteconfirm', 'admin', $strpluginname),
|
||||
new moodle_url($PAGE->url, array('delete' => $delete, 'confirm' => 1)),
|
||||
$PAGE->url);
|
||||
echo $OUTPUT->footer();
|
||||
die();
|
||||
|
||||
} else {
|
||||
uninstall_plugin('report', $delete);
|
||||
$a = new stdclass();
|
||||
$a->name = $delete;
|
||||
$pluginlocation = get_plugin_types();
|
||||
$a->directory = $pluginlocation['report'] . '/' . $delete;
|
||||
echo $OUTPUT->notification(get_string('plugindeletefiles', '', $a), 'notifysuccess');
|
||||
echo $OUTPUT->continue_button($PAGE->url);
|
||||
echo $OUTPUT->footer();
|
||||
die();
|
||||
}
|
||||
}
|
||||
|
||||
echo $OUTPUT->header();
|
||||
echo $OUTPUT->heading(get_string('reports'));
|
||||
|
||||
/// Print the table of all installed report plugins
|
||||
|
||||
$struninstall = get_string('uninstallplugin', 'core_admin');
|
||||
|
||||
$table = new flexible_table('reportplugins_administration_table');
|
||||
$table->define_columns(array('name', 'logstoressupported', 'version', 'uninstall'));
|
||||
$table->define_headers(array(get_string('plugin'), get_string('logstoressupported', 'admin'), get_string('version'),
|
||||
$struninstall));
|
||||
$table->define_columns(array('name', 'version', 'delete'));
|
||||
$table->define_headers(array(get_string('plugin'), get_string('version'), get_string('delete')));
|
||||
$table->define_baseurl($PAGE->url);
|
||||
$table->set_attribute('id', 'reportplugins');
|
||||
$table->set_attribute('class', 'admintable generaltable');
|
||||
$table->set_attribute('class', 'generaltable generalbox boxaligncenter boxwidthwide');
|
||||
$table->setup();
|
||||
|
||||
$plugins = array();
|
||||
foreach (core_component::get_plugin_list('report') as $plugin => $plugindir) {
|
||||
foreach (get_plugin_list('report') as $plugin => $plugindir) {
|
||||
if (get_string_manager()->string_exists('pluginname', 'report_' . $plugin)) {
|
||||
$strpluginname = get_string('pluginname', 'report_' . $plugin);
|
||||
} else {
|
||||
@@ -58,7 +89,7 @@ foreach (core_component::get_plugin_list('report') as $plugin => $plugindir) {
|
||||
}
|
||||
$plugins[$plugin] = $strpluginname;
|
||||
}
|
||||
core_collator::asort($plugins);
|
||||
collatorlib::asort($plugins);
|
||||
|
||||
$like = $DB->sql_like('plugin', '?', true, true, false, '|');
|
||||
$params = array('report|_%');
|
||||
@@ -72,22 +103,9 @@ foreach ($installed as $config) {
|
||||
}
|
||||
}
|
||||
|
||||
$logmanager = get_log_manager();
|
||||
|
||||
foreach ($plugins as $plugin => $name) {
|
||||
$uninstall = '';
|
||||
if ($uninstallurl = core_plugin_manager::instance()->get_uninstall_url('report_'.$plugin, 'manage')) {
|
||||
$uninstall = html_writer::link($uninstallurl, $struninstall);
|
||||
}
|
||||
|
||||
$stores = $logmanager->get_supported_logstores('report_' . $plugin);
|
||||
if ($stores === false) {
|
||||
$supportedstores = get_string('logstorenotrequired', 'admin');
|
||||
} else if (!empty($stores)) {
|
||||
$supportedstores = implode(', ', $stores);
|
||||
} else {
|
||||
$supportedstores = get_string('nosupportedlogstore', 'admin');;
|
||||
}
|
||||
$delete = new moodle_url($PAGE->url, array('delete' => $plugin, 'sesskey' => sesskey()));
|
||||
$delete = html_writer::link($delete, get_string('delete'));
|
||||
|
||||
if (!isset($versions[$plugin])) {
|
||||
if (file_exists("$CFG->dirroot/report/$plugin/version.php")) {
|
||||
@@ -108,7 +126,7 @@ foreach ($plugins as $plugin => $name) {
|
||||
}
|
||||
}
|
||||
|
||||
$table->add_data(array($name, $supportedstores, $version, $uninstall));
|
||||
$table->add_data(array($name, $version, $delete));
|
||||
}
|
||||
|
||||
$table->print_html();
|
||||
|
||||
+17
-37
@@ -19,7 +19,7 @@ require_once($CFG->dirroot . '/repository/lib.php');
|
||||
require_once($CFG->libdir . '/adminlib.php');
|
||||
|
||||
$repository = optional_param('repos', '', PARAM_ALPHANUMEXT);
|
||||
$action = optional_param('action', '', PARAM_ALPHANUMEXT);
|
||||
$action = optional_param('action', '', PARAM_ACTION);
|
||||
$sure = optional_param('sure', '', PARAM_ALPHA);
|
||||
$downloadcontents = optional_param('downloadcontents', false, PARAM_BOOL);
|
||||
|
||||
@@ -47,7 +47,7 @@ if ($action == 'newon') {
|
||||
$visible = false;
|
||||
}
|
||||
|
||||
require_capability('moodle/site:config', context_system::instance());
|
||||
require_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM));
|
||||
admin_externalpage_setup($pagename);
|
||||
|
||||
$sesskeyurl = $CFG->wwwroot.'/'.$CFG->admin.'/repository.php?sesskey=' . sesskey();
|
||||
@@ -140,15 +140,12 @@ if (($action == 'edit') || ($action == 'new')) {
|
||||
$success = $repositorytype->update_options($settings);
|
||||
} else {
|
||||
$type = new repository_type($plugin, (array)$fromform, $visible);
|
||||
$type->create();
|
||||
$success = true;
|
||||
if (!$repoid = $type->create()) {
|
||||
$success = false;
|
||||
}
|
||||
$data = data_submitted();
|
||||
}
|
||||
if ($success) {
|
||||
// configs saved
|
||||
core_plugin_manager::reset_caches();
|
||||
redirect($baseurl);
|
||||
} else {
|
||||
print_error('instancenotsaved', 'repository', $baseurl);
|
||||
@@ -189,7 +186,6 @@ if (($action == 'edit') || ($action == 'new')) {
|
||||
print_error('invalidplugin', 'repository', '', $repository);
|
||||
}
|
||||
$repositorytype->update_visibility(true);
|
||||
core_plugin_manager::reset_caches();
|
||||
$return = true;
|
||||
} else if ($action == 'hide') {
|
||||
if (!confirm_sesskey()) {
|
||||
@@ -200,7 +196,6 @@ if (($action == 'edit') || ($action == 'new')) {
|
||||
print_error('invalidplugin', 'repository', '', $repository);
|
||||
}
|
||||
$repositorytype->update_visibility(false);
|
||||
core_plugin_manager::reset_caches();
|
||||
$return = true;
|
||||
} else if ($action == 'delete') {
|
||||
$repositorytype = repository::get_type_by_typename($repository);
|
||||
@@ -211,7 +206,6 @@ if (($action == 'edit') || ($action == 'new')) {
|
||||
}
|
||||
|
||||
if ($repositorytype->delete($downloadcontents)) {
|
||||
core_plugin_manager::reset_caches();
|
||||
redirect($baseurl);
|
||||
} else {
|
||||
print_error('instancenotdeleted', 'repository', $baseurl);
|
||||
@@ -264,7 +258,6 @@ if (($action == 'edit') || ($action == 'new')) {
|
||||
$strshow = get_string('on', 'repository');
|
||||
$strhide = get_string('off', 'repository');
|
||||
$strdelete = get_string('disabled', 'repository');
|
||||
$struninstall = get_string('uninstallplugin', 'core_admin');
|
||||
|
||||
$actionchoicesforexisting = array(
|
||||
'show' => $strshow,
|
||||
@@ -287,21 +280,18 @@ if (($action == 'edit') || ($action == 'new')) {
|
||||
|
||||
// Table to list plug-ins
|
||||
$table = new html_table();
|
||||
$table->head = array(get_string('name'), get_string('isactive', 'repository'), get_string('order'), $settingsstr, $struninstall);
|
||||
|
||||
$table->colclasses = array('leftalign', 'centeralign', 'centeralign', 'centeralign', 'centeralign', 'centeralign');
|
||||
$table->id = 'repositoriessetting';
|
||||
$table->head = array(get_string('name'), get_string('isactive', 'repository'), get_string('order'), $settingsstr);
|
||||
$table->align = array('left', 'center', 'center', 'center', 'center');
|
||||
$table->data = array();
|
||||
$table->attributes['class'] = 'admintable generaltable';
|
||||
|
||||
// Get list of used plug-ins
|
||||
$repositorytypes = repository::get_types();
|
||||
// Array to store plugins being used
|
||||
$alreadyplugins = array();
|
||||
if (!empty($repositorytypes)) {
|
||||
$totalrepositorytypes = count($repositorytypes);
|
||||
$instances = repository::get_types();
|
||||
if (!empty($instances)) {
|
||||
// Array to store plugins being used
|
||||
$alreadyplugins = array();
|
||||
$totalinstances = count($instances);
|
||||
$updowncount = 1;
|
||||
foreach ($repositorytypes as $i) {
|
||||
foreach ($instances as $i) {
|
||||
$settings = '';
|
||||
$typename = $i->get_typename();
|
||||
// Display edit link only if you can config the type or if it has multiple instances (e.g. has instance config)
|
||||
@@ -324,10 +314,9 @@ if (($action == 'edit') || ($action == 'new')) {
|
||||
$userinstances = array();
|
||||
|
||||
foreach ($instances as $instance) {
|
||||
$repocontext = context::instance_by_id($instance->instance->contextid);
|
||||
if ($repocontext->contextlevel == CONTEXT_COURSE) {
|
||||
if ($instance->context->contextlevel == CONTEXT_COURSE) {
|
||||
$courseinstances[] = $instance;
|
||||
} else if ($repocontext->contextlevel == CONTEXT_USER) {
|
||||
} else if ($instance->context->contextlevel == CONTEXT_USER) {
|
||||
$userinstances[] = $instance;
|
||||
}
|
||||
}
|
||||
@@ -375,7 +364,7 @@ if (($action == 'edit') || ($action == 'new')) {
|
||||
else {
|
||||
$updown .= $spacer;
|
||||
}
|
||||
if ($updowncount < $totalrepositorytypes) {
|
||||
if ($updowncount < $totalinstances) {
|
||||
$updown .= "<a href=\"$sesskeyurl&action=movedown&repos=".$typename."\">";
|
||||
$updown .= "<img src=\"" . $OUTPUT->pix_url('t/down') . "\" alt=\"down\" /></a>";
|
||||
}
|
||||
@@ -385,12 +374,7 @@ if (($action == 'edit') || ($action == 'new')) {
|
||||
|
||||
$updowncount++;
|
||||
|
||||
$uninstall = '';
|
||||
if ($uninstallurl = core_plugin_manager::instance()->get_uninstall_url('repository_' . $typename, 'manage')) {
|
||||
$uninstall = html_writer::link($uninstallurl, $struninstall);
|
||||
}
|
||||
|
||||
$table->data[] = array($i->get_readablename(), $OUTPUT->render($select), $updown, $settings, $uninstall);
|
||||
$table->data[] = array($i->get_readablename(), $OUTPUT->render($select), $updown, $settings);
|
||||
|
||||
if (!in_array($typename, $alreadyplugins)) {
|
||||
$alreadyplugins[] = $typename;
|
||||
@@ -399,18 +383,14 @@ if (($action == 'edit') || ($action == 'new')) {
|
||||
}
|
||||
|
||||
// Get all the plugins that exist on disk
|
||||
$plugins = core_component::get_plugin_list('repository');
|
||||
$plugins = get_plugin_list('repository');
|
||||
if (!empty($plugins)) {
|
||||
foreach ($plugins as $plugin => $dir) {
|
||||
// Check that it has not already been listed
|
||||
if (!in_array($plugin, $alreadyplugins)) {
|
||||
$select = new single_select(repository_action_url($plugin, 'repos'), 'action', $actionchoicesfornew, 'delete', null, 'applyto' . basename($plugin));
|
||||
$select->set_label(get_string('action'), array('class' => 'accesshide'));
|
||||
$uninstall = '';
|
||||
if ($uninstallurl = core_plugin_manager::instance()->get_uninstall_url('repository_' . $plugin, 'manage')) {
|
||||
$uninstall = html_writer::link($uninstallurl, $struninstall);
|
||||
}
|
||||
$table->data[] = array(get_string('pluginname', 'repository_'.$plugin), $OUTPUT->render($select), '', '', $uninstall);
|
||||
$table->data[] = array(get_string('pluginname', 'repository_'.$plugin), $OUTPUT->render($select), '', '');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -62,9 +62,6 @@ $return = true;
|
||||
if (!empty($edit) || !empty($new)) {
|
||||
if (!empty($edit)) {
|
||||
$instance = repository::get_instance($edit);
|
||||
if (!$instance->can_be_edited_by_user()) {
|
||||
throw new repository_exception('nopermissiontoaccess', 'repository');
|
||||
}
|
||||
$instancetype = repository::get_type_by_id($instance->options['typeid']);
|
||||
$classname = 'repository_' . $instancetype->get_typename();
|
||||
$configs = $instance->get_instance_option_names();
|
||||
@@ -102,7 +99,6 @@ if (!empty($edit) || !empty($new)) {
|
||||
$data = data_submitted();
|
||||
}
|
||||
if ($success) {
|
||||
core_plugin_manager::reset_caches();
|
||||
redirect($parenturl);
|
||||
} else {
|
||||
print_error('instancenotsaved', 'repository', $parenturl);
|
||||
@@ -119,20 +115,16 @@ if (!empty($edit) || !empty($new)) {
|
||||
} else if (!empty($hide)) {
|
||||
$instance = repository::get_type_by_typename($hide);
|
||||
$instance->hide();
|
||||
core_plugin_manager::reset_caches();
|
||||
$return = true;
|
||||
} else if (!empty($delete)) {
|
||||
$instance = repository::get_instance($delete);
|
||||
//if you try to delete an instance set as readonly, display an error message
|
||||
if ($instance->readonly) {
|
||||
// If you try to delete an instance set as readonly, display an error message.
|
||||
throw new repository_exception('readonlyinstance', 'repository');
|
||||
} else if (!$instance->can_be_edited_by_user()) {
|
||||
throw new repository_exception('nopermissiontoaccess', 'repository');
|
||||
}
|
||||
throw new repository_exception('readonlyinstance', 'repository');
|
||||
}
|
||||
if ($sure) {
|
||||
if ($instance->delete($downloadcontents)) {
|
||||
$deletedstr = get_string('instancedeleted', 'repository');
|
||||
core_plugin_manager::reset_caches();
|
||||
redirect($parenturl, $deletedstr, 3);
|
||||
} else {
|
||||
print_error('instancenotdeleted', 'repository', $parenturl);
|
||||
|
||||
+24
-21
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
@@ -15,15 +16,16 @@
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Select site administrators.
|
||||
* Lets you site administrators
|
||||
*
|
||||
* @package core_role
|
||||
* @copyright 2010 Petr Skoda {@link http://skodak.org}
|
||||
* @package core
|
||||
* @subpackage role
|
||||
* @copyright 2010 Petr Skoda (skodak) http://skodak.org
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
require_once(__DIR__ . '/../../config.php');
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
require_once(dirname(__FILE__) . '/../../config.php');
|
||||
require_once($CFG->dirroot . '/' . $CFG->admin . '/roles/lib.php');
|
||||
|
||||
$confirmadd = optional_param('confirmadd', 0, PARAM_INT);
|
||||
$confirmdel = optional_param('confirmdel', 0, PARAM_INT);
|
||||
@@ -35,10 +37,10 @@ if (!is_siteadmin()) {
|
||||
die;
|
||||
}
|
||||
|
||||
$admisselector = new core_role_admins_existing_selector();
|
||||
$admisselector = new admins_existing_selector();
|
||||
$admisselector->set_extra_fields(array('username', 'email'));
|
||||
|
||||
$potentialadmisselector = new core_role_admins_potential_selector();
|
||||
$potentialadmisselector = new admins_potential_selector();
|
||||
$potentialadmisselector->set_extra_fields(array('username', 'email'));
|
||||
|
||||
if (optional_param('add', false, PARAM_BOOL) and confirm_sesskey()) {
|
||||
@@ -46,8 +48,7 @@ if (optional_param('add', false, PARAM_BOOL) and confirm_sesskey()) {
|
||||
$user = reset($userstoadd);
|
||||
$username = fullname($user) . " ($user->username, $user->email)";
|
||||
echo $OUTPUT->header();
|
||||
$yesurl = new moodle_url('/admin/roles/admins.php', array('confirmadd'=>$user->id, 'sesskey'=>sesskey()));
|
||||
echo $OUTPUT->confirm(get_string('confirmaddadmin', 'core_role', $username), $yesurl, $PAGE->url);
|
||||
echo $OUTPUT->confirm(get_string('confirmaddadmin', 'role', $username), new moodle_url('/admin/roles/admins.php', array('confirmadd'=>$user->id, 'sesskey'=>sesskey())), $PAGE->url);
|
||||
echo $OUTPUT->footer();
|
||||
die;
|
||||
}
|
||||
@@ -56,12 +57,11 @@ if (optional_param('add', false, PARAM_BOOL) and confirm_sesskey()) {
|
||||
if ($userstoremove = $admisselector->get_selected_users()) {
|
||||
$user = reset($userstoremove);
|
||||
if ($USER->id == $user->id) {
|
||||
// Can not remove self.
|
||||
//can not remove self
|
||||
} else {
|
||||
$username = fullname($user) . " ($user->username, $user->email)";
|
||||
echo $OUTPUT->header();
|
||||
$yesurl = new moodle_url('/admin/roles/admins.php', array('confirmdel'=>$user->id, 'sesskey'=>sesskey()));
|
||||
echo $OUTPUT->confirm(get_string('confirmdeladmin', 'core_role', $username), $yesurl, $PAGE->url);
|
||||
echo $OUTPUT->confirm(get_string('confirmdeladmin', 'role', $username), new moodle_url('/admin/roles/admins.php', array('confirmdel'=>$user->id, 'sesskey'=>sesskey())), $PAGE->url);
|
||||
echo $OUTPUT->footer();
|
||||
die;
|
||||
}
|
||||
@@ -72,7 +72,7 @@ if (optional_param('add', false, PARAM_BOOL) and confirm_sesskey()) {
|
||||
$newmain = reset($newmain);
|
||||
$newmain = $newmain->id;
|
||||
$admins = array();
|
||||
foreach (explode(',', $CFG->siteadmins) as $admin) {
|
||||
foreach(explode(',', $CFG->siteadmins) as $admin) {
|
||||
$admin = (int)$admin;
|
||||
if ($admin) {
|
||||
$admins[$admin] = $admin;
|
||||
@@ -89,7 +89,7 @@ if (optional_param('add', false, PARAM_BOOL) and confirm_sesskey()) {
|
||||
|
||||
} else if ($confirmadd and confirm_sesskey()) {
|
||||
$admins = array();
|
||||
foreach (explode(',', $CFG->siteadmins) as $admin) {
|
||||
foreach(explode(',', $CFG->siteadmins) as $admin) {
|
||||
$admin = (int)$admin;
|
||||
if ($admin) {
|
||||
$admins[$admin] = $admin;
|
||||
@@ -101,7 +101,7 @@ if (optional_param('add', false, PARAM_BOOL) and confirm_sesskey()) {
|
||||
|
||||
} else if ($confirmdel and confirm_sesskey() and $confirmdel != $USER->id) {
|
||||
$admins = array();
|
||||
foreach (explode(',', $CFG->siteadmins) as $admin) {
|
||||
foreach(explode(',', $CFG->siteadmins) as $admin) {
|
||||
$admin = (int)$admin;
|
||||
if ($admin) {
|
||||
$admins[$admin] = $admin;
|
||||
@@ -112,12 +112,12 @@ if (optional_param('add', false, PARAM_BOOL) and confirm_sesskey()) {
|
||||
redirect($PAGE->url);
|
||||
}
|
||||
|
||||
// Print header.
|
||||
/// Print header
|
||||
echo $OUTPUT->header();
|
||||
?>
|
||||
|
||||
<div id="addadmisform">
|
||||
<h3 class="main"><?php print_string('manageadmins', 'core_role'); ?></h3>
|
||||
<h3 class="main"><?php print_string('manageadmins', 'role'); ?></h3>
|
||||
|
||||
<form id="assignform" method="post" action="<?php echo $PAGE->url ?>">
|
||||
<div>
|
||||
@@ -127,18 +127,18 @@ echo $OUTPUT->header();
|
||||
<tr>
|
||||
<td id='existingcell'>
|
||||
<p>
|
||||
<label for="removeselect"><?php print_string('existingadmins', 'core_role'); ?></label>
|
||||
<label for="removeselect"><?php print_string('existingadmins', 'role'); ?></label>
|
||||
</p>
|
||||
<?php $admisselector->display(); ?>
|
||||
</td>
|
||||
<td id="buttonscell">
|
||||
<td id='buttonscell'>
|
||||
<p class="arrow_button">
|
||||
<input name="add" id="add" type="submit" value="<?php echo $OUTPUT->larrow().' '.get_string('add'); ?>" title="<?php print_string('add'); ?>" /><br />
|
||||
<input name="remove" id="remove" type="submit" value="<?php echo get_string('remove').' '.$OUTPUT->rarrow(); ?>" title="<?php print_string('remove'); ?>" />
|
||||
<input name="main" id="main" type="submit" value="<?php echo get_string('mainadminset', 'core_role'); ?>" title="<?php print_string('mainadminset', 'core_role'); ?>" />
|
||||
<input name="main" id="main" type="submit" value="<?php echo get_string('mainadminset', 'role'); ?>" title="<?php print_string('mainadminset', 'role'); ?>" />
|
||||
</p>
|
||||
</td>
|
||||
<td id="potentialcell">
|
||||
<td id='potentialcell'>
|
||||
<p>
|
||||
<label for="addselect"><?php print_string('users'); ?></label>
|
||||
</p>
|
||||
@@ -152,4 +152,7 @@ echo $OUTPUT->header();
|
||||
|
||||
<?php
|
||||
|
||||
//this must be after calling display() on the selectors so their setup JS executes first
|
||||
//////$PAGE->requires->js_function_call('init_add_remove_admis_page');
|
||||
|
||||
echo $OUTPUT->footer();
|
||||
|
||||
+12
-24
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
@@ -15,21 +16,23 @@
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Allow overriding of roles by other roles.
|
||||
* Allow overriding of roles by other roles
|
||||
*
|
||||
* @package core_role
|
||||
* @package core
|
||||
* @subpackage role
|
||||
* @copyright 1999 onwards Martin Dougiamas (http://dougiamas.com)
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
require_once(dirname(__FILE__) . '/../../config.php');
|
||||
require_once($CFG->libdir . '/adminlib.php');
|
||||
require_once($CFG->dirroot . '/' . $CFG->admin . '/roles/lib.php');
|
||||
|
||||
$mode = required_param('mode', PARAM_ALPHANUMEXT);
|
||||
$mode = required_param('mode', PARAM_ACTION);
|
||||
$classformode = array(
|
||||
'assign' => 'core_role_allow_assign_page',
|
||||
'override' => 'core_role_allow_override_page',
|
||||
'switch' => 'core_role_allow_switch_page'
|
||||
'assign' => 'role_allow_assign_page',
|
||||
'override' => 'role_allow_override_page',
|
||||
'switch' => 'role_allow_switch_page'
|
||||
);
|
||||
if (!isset($classformode[$mode])) {
|
||||
print_error('invalidmode', '', '', $mode);
|
||||
@@ -38,30 +41,15 @@ if (!isset($classformode[$mode])) {
|
||||
$baseurl = new moodle_url('/admin/roles/allow.php', array('mode'=>$mode));
|
||||
admin_externalpage_setup('defineroles', '', array(), $baseurl);
|
||||
|
||||
$syscontext = context_system::instance();
|
||||
$syscontext = get_context_instance(CONTEXT_SYSTEM);
|
||||
require_capability('moodle/role:manage', $syscontext);
|
||||
|
||||
$controller = new $classformode[$mode]();
|
||||
|
||||
if (optional_param('submit', false, PARAM_BOOL) && data_submitted() && confirm_sesskey()) {
|
||||
$controller->process_submission();
|
||||
$syscontext->mark_dirty();
|
||||
$event = null;
|
||||
// Create event depending on mode.
|
||||
switch ($mode) {
|
||||
case 'assign':
|
||||
$event = \core\event\role_allow_assign_updated::create(array('context' => $syscontext));
|
||||
break;
|
||||
case 'override':
|
||||
$event = \core\event\role_allow_override_updated::create(array('context' => $syscontext));
|
||||
break;
|
||||
case 'switch':
|
||||
$event = \core\event\role_allow_switch_updated::create(array('context' => $syscontext));
|
||||
break;
|
||||
}
|
||||
if ($event) {
|
||||
$event->trigger();
|
||||
}
|
||||
mark_context_dirty($syscontext->path);
|
||||
add_to_log(SITEID, 'role', 'edit allow ' . $mode, str_replace($CFG->wwwroot . '/', '', $baseurl), '', '', $USER->id);
|
||||
redirect($baseurl);
|
||||
}
|
||||
|
||||
|
||||
+50
-73
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
@@ -15,21 +16,21 @@
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Assign roles to users.
|
||||
* Lets you assign roles to users in a particular context.
|
||||
*
|
||||
* @package core_role
|
||||
* @package core
|
||||
* @subpackage role
|
||||
* @copyright 1999 onwards Martin Dougiamas (http://dougiamas.com)
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
require_once(__DIR__ . '/../../config.php');
|
||||
require_once(dirname(__FILE__) . '/../../config.php');
|
||||
require_once($CFG->dirroot . '/' . $CFG->admin . '/roles/lib.php');
|
||||
|
||||
define("MAX_USERS_TO_LIST_PER_ROLE", 10);
|
||||
|
||||
$contextid = required_param('contextid', PARAM_INT);
|
||||
$roleid = optional_param('roleid', 0, PARAM_INT);
|
||||
$returnto = optional_param('return', null, PARAM_ALPHANUMEXT);
|
||||
$contextid = required_param('contextid',PARAM_INT);
|
||||
$roleid = optional_param('roleid', 0, PARAM_INT);
|
||||
|
||||
list($context, $course, $cm) = get_context_info_array($contextid);
|
||||
|
||||
@@ -50,25 +51,25 @@ if ($course) {
|
||||
}
|
||||
|
||||
|
||||
// Security.
|
||||
// security
|
||||
require_login($course, false, $cm);
|
||||
require_capability('moodle/role:assign', $context);
|
||||
$PAGE->set_url($url);
|
||||
$PAGE->set_context($context);
|
||||
|
||||
$contextname = $context->get_context_name();
|
||||
$contextname = print_context_name($context);
|
||||
$courseid = $course->id;
|
||||
|
||||
// These are needed early because of tabs.php.
|
||||
// These are needed early because of tabs.php
|
||||
list($assignableroles, $assigncounts, $nameswithcounts) = get_assignable_roles($context, ROLENAME_BOTH, true);
|
||||
$overridableroles = get_overridable_roles($context, ROLENAME_BOTH);
|
||||
|
||||
// Make sure this user can assign this role.
|
||||
// Make sure this user can assign this role
|
||||
if ($roleid && !isset($assignableroles[$roleid])) {
|
||||
$a = new stdClass;
|
||||
$a->roleid = $roleid;
|
||||
$a->context = $contextname;
|
||||
print_error('cannotassignrolehere', '', $context->get_url(), $a);
|
||||
print_error('cannotassignrolehere', '', get_context_url($context), $a);
|
||||
}
|
||||
|
||||
// Work out an appropriate page title.
|
||||
@@ -76,12 +77,12 @@ if ($roleid) {
|
||||
$a = new stdClass;
|
||||
$a->role = $assignableroles[$roleid];
|
||||
$a->context = $contextname;
|
||||
$title = get_string('assignrolenameincontext', 'core_role', $a);
|
||||
$title = get_string('assignrolenameincontext', 'role', $a);
|
||||
} else {
|
||||
if ($isfrontpage) {
|
||||
$title = get_string('frontpageroles', 'admin');
|
||||
} else {
|
||||
$title = get_string('assignrolesin', 'core_role', $contextname);
|
||||
$title = get_string('assignrolesin', 'role', $contextname);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -91,10 +92,10 @@ if ($roleid) {
|
||||
// Create the user selector objects.
|
||||
$options = array('context' => $context, 'roleid' => $roleid);
|
||||
|
||||
$potentialuserselector = core_role_get_potential_user_selector($context, 'addselect', $options);
|
||||
$currentuserselector = new core_role_existing_role_holders('removeselect', $options);
|
||||
$potentialuserselector = roles_get_potential_user_selector($context, 'addselect', $options);
|
||||
$currentuserselector = new existing_role_holders('removeselect', $options);
|
||||
|
||||
// Process incoming role assignments.
|
||||
// Process incoming role assignments
|
||||
$errors = array();
|
||||
if (optional_param('add', false, PARAM_BOOL) && confirm_sesskey()) {
|
||||
$userstoassign = $potentialuserselector->get_selected_users();
|
||||
@@ -111,41 +112,39 @@ if ($roleid) {
|
||||
$potentialuserselector->invalidate_selected_users();
|
||||
$currentuserselector->invalidate_selected_users();
|
||||
|
||||
$rolename = $assignableroles[$roleid];
|
||||
add_to_log($course->id, 'role', 'assign', 'admin/roles/assign.php?contextid='.$context->id.'&roleid='.$roleid, $rolename, '', $USER->id);
|
||||
// Counts have changed, so reload.
|
||||
list($assignableroles, $assigncounts, $nameswithcounts) = get_assignable_roles($context, ROLENAME_BOTH, true);
|
||||
}
|
||||
}
|
||||
|
||||
// Process incoming role unassignments.
|
||||
// Process incoming role unassignments
|
||||
if (optional_param('remove', false, PARAM_BOOL) && confirm_sesskey()) {
|
||||
$userstounassign = $currentuserselector->get_selected_users();
|
||||
if (!empty($userstounassign)) {
|
||||
|
||||
foreach ($userstounassign as $removeuser) {
|
||||
// Unassign only roles that are added manually, no messing with other components!!!
|
||||
//unassign only roles that are added manually, no messing with other components!!!
|
||||
role_unassign($roleid, $removeuser->id, $context->id, '');
|
||||
}
|
||||
|
||||
$potentialuserselector->invalidate_selected_users();
|
||||
$currentuserselector->invalidate_selected_users();
|
||||
|
||||
$rolename = $assignableroles[$roleid];
|
||||
add_to_log($course->id, 'role', 'unassign', 'admin/roles/assign.php?contextid='.$context->id.'&roleid='.$roleid, $rolename, '', $USER->id);
|
||||
// Counts have changed, so reload.
|
||||
list($assignableroles, $assigncounts, $nameswithcounts) = get_assignable_roles($context, ROLENAME_BOTH, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($user) && ($user->id != $USER->id)) {
|
||||
$PAGE->navigation->extend_for_user($user);
|
||||
$PAGE->navbar->includesettingsbase = true;
|
||||
}
|
||||
|
||||
$PAGE->set_pagelayout('admin');
|
||||
$PAGE->set_title($title);
|
||||
|
||||
switch ($context->contextlevel) {
|
||||
case CONTEXT_SYSTEM:
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
admin_externalpage_setup('assignroles', '', array('contextid' => $contextid, 'roleid' => $roleid));
|
||||
break;
|
||||
case CONTEXT_USER:
|
||||
@@ -154,17 +153,17 @@ switch ($context->contextlevel) {
|
||||
$showroles = 1;
|
||||
break;
|
||||
case CONTEXT_COURSECAT:
|
||||
$PAGE->set_heading($SITE->fullname);
|
||||
$PAGE->set_heading("$SITE->fullname: ".get_string("categories"));
|
||||
break;
|
||||
case CONTEXT_COURSE:
|
||||
if ($isfrontpage) {
|
||||
$PAGE->set_heading(get_string('frontpage', 'admin'));
|
||||
admin_externalpage_setup('frontpageroles', '', array('contextid' => $contextid, 'roleid' => $roleid));
|
||||
} else {
|
||||
$PAGE->set_heading($course->fullname);
|
||||
}
|
||||
break;
|
||||
case CONTEXT_MODULE:
|
||||
$PAGE->set_heading($context->get_context_name(false));
|
||||
$PAGE->set_heading(print_context_name($context, false));
|
||||
$PAGE->set_cacheable(false);
|
||||
break;
|
||||
case CONTEXT_BLOCK:
|
||||
@@ -175,28 +174,25 @@ switch ($context->contextlevel) {
|
||||
echo $OUTPUT->header();
|
||||
|
||||
// Print heading.
|
||||
echo $OUTPUT->heading_with_help($title, 'assignroles', 'core_role');
|
||||
echo $OUTPUT->heading_with_help($title, 'assignroles', 'role');
|
||||
|
||||
if ($roleid) {
|
||||
// Show UI for assigning a particular role to users.
|
||||
// Print a warning if we are assigning system roles.
|
||||
if ($context->contextlevel == CONTEXT_SYSTEM) {
|
||||
echo $OUTPUT->notification(get_string('globalroleswarning', 'core_role'));
|
||||
echo $OUTPUT->box(get_string('globalroleswarning', 'role'));
|
||||
}
|
||||
|
||||
// Print the form.
|
||||
$assignurl = new moodle_url($PAGE->url, array('roleid'=>$roleid));
|
||||
if ($returnto !== null) {
|
||||
$assignurl->param('return', $returnto);
|
||||
}
|
||||
$assignurl = new moodle_url($PAGE->url, array('roleid'=>$roleid));
|
||||
?>
|
||||
<form id="assignform" method="post" action="<?php echo $assignurl ?>"><div>
|
||||
<input type="hidden" name="sesskey" value="<?php echo sesskey() ?>" />
|
||||
|
||||
<table id="assigningrole" summary="" class="admintable roleassigntable generaltable" cellspacing="0">
|
||||
<table summary="" class="roleassigntable generaltable generalbox boxaligncenter" cellspacing="0">
|
||||
<tr>
|
||||
<td id="existingcell">
|
||||
<p><label for="removeselect"><?php print_string('extusers', 'core_role'); ?></label></p>
|
||||
<p><label for="removeselect"><?php print_string('extusers', 'role'); ?></label></p>
|
||||
<?php $currentuserselector->display() ?>
|
||||
</td>
|
||||
<td id="buttonscell">
|
||||
@@ -209,7 +205,7 @@ if ($roleid) {
|
||||
</div>
|
||||
</td>
|
||||
<td id="potentialcell">
|
||||
<p><label for="addselect"><?php print_string('potusers', 'core_role'); ?></label></p>
|
||||
<p><label for="addselect"><?php print_string('potusers', 'role'); ?></label></p>
|
||||
<?php $potentialuserselector->display() ?>
|
||||
</td>
|
||||
</tr>
|
||||
@@ -233,45 +229,37 @@ if ($roleid) {
|
||||
// Print a form to swap roles, and a link back to the all roles list.
|
||||
echo '<div class="backlink">';
|
||||
|
||||
$newroleurl = new moodle_url($PAGE->url);
|
||||
if ($returnto !== null) {
|
||||
$newroleurl->param('return', $returnto);
|
||||
}
|
||||
$select = new single_select($newroleurl, 'roleid', $nameswithcounts, $roleid, null);
|
||||
$select->label = get_string('assignanotherrole', 'core_role');
|
||||
$select = new single_select($PAGE->url, 'roleid', $nameswithcounts, $roleid, null);
|
||||
$select->label = get_string('assignanotherrole', 'role');
|
||||
echo $OUTPUT->render($select);
|
||||
$backurl = new moodle_url('/admin/roles/assign.php', array('contextid' => $contextid));
|
||||
if ($returnto !== null) {
|
||||
$backurl->param('return', $returnto);
|
||||
}
|
||||
echo '<p><a href="' . $backurl->out() . '">' . get_string('backtoallroles', 'core_role') . '</a></p>';
|
||||
echo '<p><a href="' . $backurl->out() . '">' . get_string('backtoallroles', 'role') . '</a></p>';
|
||||
echo '</div>';
|
||||
|
||||
} else if (empty($assignableroles)) {
|
||||
// Print a message that there are no roles that can me assigned here.
|
||||
echo $OUTPUT->heading(get_string('notabletoassignroleshere', 'core_role'), 3);
|
||||
echo $OUTPUT->heading(get_string('notabletoassignroleshere', 'role'), 3);
|
||||
|
||||
} else {
|
||||
// Show UI for choosing a role to assign.
|
||||
|
||||
// Print a warning if we are assigning system roles.
|
||||
if ($context->contextlevel == CONTEXT_SYSTEM) {
|
||||
echo $OUTPUT->notification(get_string('globalroleswarning', 'core_role'));
|
||||
echo $OUTPUT->box(get_string('globalroleswarning', 'role'));
|
||||
}
|
||||
|
||||
// Print instruction.
|
||||
echo $OUTPUT->heading(get_string('chooseroletoassign', 'core_role'), 3);
|
||||
// Print instruction
|
||||
echo $OUTPUT->heading(get_string('chooseroletoassign', 'role'), 3);
|
||||
|
||||
// Get the names of role holders for roles with between 1 and MAX_USERS_TO_LIST_PER_ROLE users,
|
||||
// and so determine whether to show the extra column.
|
||||
$roleholdernames = array();
|
||||
$strmorethanmax = get_string('morethan', 'core_role', MAX_USERS_TO_LIST_PER_ROLE);
|
||||
$strmorethanmax = get_string('morethan', 'role', MAX_USERS_TO_LIST_PER_ROLE);
|
||||
$showroleholders = false;
|
||||
foreach ($assignableroles as $roleid => $notused) {
|
||||
$roleusers = '';
|
||||
if (0 < $assigncounts[$roleid] && $assigncounts[$roleid] <= MAX_USERS_TO_LIST_PER_ROLE) {
|
||||
$userfields = 'u.id, u.username, ' . get_all_user_name_fields(true, 'u');
|
||||
$roleusers = get_role_users($roleid, $context, false, $userfields);
|
||||
$roleusers = get_role_users($roleid, $context, false, 'u.id, u.lastname, u.firstname');
|
||||
if (!empty($roleusers)) {
|
||||
$strroleusers = array();
|
||||
foreach ($roleusers as $user) {
|
||||
@@ -282,32 +270,28 @@ if ($roleid) {
|
||||
}
|
||||
} else if ($assigncounts[$roleid] > MAX_USERS_TO_LIST_PER_ROLE) {
|
||||
$assignurl = new moodle_url($PAGE->url, array('roleid'=>$roleid));
|
||||
if ($returnto !== null) {
|
||||
$assignurl->param('return', $returnto);
|
||||
}
|
||||
$roleholdernames[$roleid] = '<a href="'.$assignurl.'">'.$strmorethanmax.'</a>';
|
||||
} else {
|
||||
$roleholdernames[$roleid] = '';
|
||||
}
|
||||
}
|
||||
|
||||
// Print overview table.
|
||||
// Print overview table
|
||||
$table = new html_table();
|
||||
$table->id = 'assignrole';
|
||||
$table->head = array(get_string('role'), get_string('description'), get_string('userswiththisrole', 'core_role'));
|
||||
$table->colclasses = array('leftalign role', 'leftalign', 'centeralign userrole');
|
||||
$table->attributes['class'] = 'admintable generaltable';
|
||||
$table->tablealign = 'center';
|
||||
$table->width = '60%';
|
||||
$table->head = array(get_string('role'), get_string('description'), get_string('userswiththisrole', 'role'));
|
||||
$table->wrap = array('nowrap', '', 'nowrap');
|
||||
$table->align = array('left', 'left', 'center');
|
||||
if ($showroleholders) {
|
||||
$table->headspan = array(1, 1, 2);
|
||||
$table->colclasses[] = 'leftalign roleholder';
|
||||
$table->wrap[] = 'nowrap';
|
||||
$table->align[] = 'left';
|
||||
}
|
||||
|
||||
foreach ($assignableroles as $roleid => $rolename) {
|
||||
$description = format_string($DB->get_field('role', 'description', array('id'=>$roleid)));
|
||||
$assignurl = new moodle_url($PAGE->url, array('roleid'=>$roleid));
|
||||
if ($returnto !== null) {
|
||||
$assignurl->param('return', $returnto);
|
||||
}
|
||||
$row = array('<a href="'.$assignurl.'">'.$rolename.'</a>',
|
||||
$description, $assigncounts[$roleid]);
|
||||
if ($showroleholders) {
|
||||
@@ -319,15 +303,8 @@ if ($roleid) {
|
||||
echo html_writer::table($table);
|
||||
|
||||
if ($context->contextlevel > CONTEXT_USER) {
|
||||
|
||||
if ($context->contextlevel === CONTEXT_COURSECAT && $returnto === 'management') {
|
||||
$url = new moodle_url('/course/management.php', array('categoryid' => $context->instanceid));
|
||||
} else {
|
||||
$url = $context->get_url();
|
||||
}
|
||||
|
||||
echo html_writer::start_tag('div', array('class'=>'backlink'));
|
||||
echo html_writer::tag('a', get_string('backto', '', $contextname), array('href' => $url));
|
||||
echo html_writer::tag('a', get_string('backto', '', $contextname), array('href'=>get_context_url($context)));
|
||||
echo html_writer::end_tag('div');
|
||||
}
|
||||
}
|
||||
|
||||
+30
-32
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
@@ -17,14 +18,16 @@
|
||||
/**
|
||||
* Shows the result of has_capability for every capability for a user in a context.
|
||||
*
|
||||
* @package core_role
|
||||
* @package core
|
||||
* @subpackage role
|
||||
* @copyright 1999 onwards Martin Dougiamas (http://dougiamas.com)
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
require_once(dirname(__FILE__) . '/../../config.php');
|
||||
require_once($CFG->dirroot . '/' . $CFG->admin . '/roles/lib.php');
|
||||
|
||||
$contextid = required_param('contextid', PARAM_INT);
|
||||
$contextid = required_param('contextid',PARAM_INT);
|
||||
|
||||
list($context, $course, $cm) = get_context_info_array($contextid);
|
||||
|
||||
@@ -44,42 +47,37 @@ if ($course) {
|
||||
}
|
||||
}
|
||||
|
||||
// Security first.
|
||||
// security first
|
||||
require_login($course, false, $cm);
|
||||
if (!has_any_capability(array('moodle/role:assign', 'moodle/role:safeoverride', 'moodle/role:override', 'moodle/role:manage'), $context)) {
|
||||
print_error('nopermissions', 'error', '', get_string('checkpermissions', 'core_role'));
|
||||
print_error('nopermissions', 'error', '', get_string('checkpermissions', 'role'));
|
||||
}
|
||||
$PAGE->set_url($url);
|
||||
|
||||
if ($context->contextlevel == CONTEXT_USER and $USER->id != $context->instanceid) {
|
||||
$PAGE->navbar->includesettingsbase = true;
|
||||
$PAGE->navigation->extend_for_user($user);
|
||||
$PAGE->set_context(context_course::instance($course->id));
|
||||
} else {
|
||||
$PAGE->set_context($context);
|
||||
}
|
||||
|
||||
$PAGE->set_context($context);
|
||||
|
||||
$courseid = $course->id;
|
||||
$contextname = $context->get_context_name();
|
||||
$contextname = print_context_name($context);
|
||||
|
||||
// Get the user_selector we will need.
|
||||
// Teachers within a course just get to see the same list of enrolled users.
|
||||
// Admins (people with moodle/role:manage) can run this report for any user.
|
||||
$options = array('accesscontext' => $context);
|
||||
$userselector = new core_role_check_users_selector('reportuser', $options);
|
||||
$userselector->set_rows(20);
|
||||
// Teachers within a course just get to see the same list of people they can
|
||||
// assign roles to. Admins (people with moodle/role:manage) can run this report for any user.
|
||||
$options = array('context' => $context, 'roleid' => 0);
|
||||
if (has_capability('moodle/role:manage', $context)) {
|
||||
$userselector = new potential_assignees_course_and_above('reportuser', $options);
|
||||
} else {
|
||||
$userselector = roles_get_potential_user_selector($context, 'reportuser', $options);
|
||||
}
|
||||
$userselector->set_multiselect(false);
|
||||
$userselector->set_rows(10);
|
||||
|
||||
// Work out an appropriate page title.
|
||||
$title = get_string('checkpermissionsin', 'core_role', $contextname);
|
||||
$title = get_string('checkpermissionsin', 'role', $contextname);
|
||||
|
||||
$PAGE->set_pagelayout('admin');
|
||||
$PAGE->set_title($title);
|
||||
|
||||
switch ($context->contextlevel) {
|
||||
case CONTEXT_SYSTEM:
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
admin_externalpage_setup('checkpermissions', '', array('contextid' => $contextid));
|
||||
break;
|
||||
case CONTEXT_USER:
|
||||
@@ -88,17 +86,17 @@ switch ($context->contextlevel) {
|
||||
$showroles = 1;
|
||||
break;
|
||||
case CONTEXT_COURSECAT:
|
||||
$PAGE->set_heading($SITE->fullname);
|
||||
$PAGE->set_heading("$SITE->fullname: ".get_string("categories"));
|
||||
break;
|
||||
case CONTEXT_COURSE:
|
||||
if ($isfrontpage) {
|
||||
$PAGE->set_heading(get_string('frontpage', 'admin'));
|
||||
admin_externalpage_setup('frontpageroles', '', array('contextid' => $contextid), $CFG->wwwroot . '/' . $CFG->admin . '/roles/check.php');
|
||||
} else {
|
||||
$PAGE->set_heading($course->fullname);
|
||||
}
|
||||
break;
|
||||
case CONTEXT_MODULE:
|
||||
$PAGE->set_heading($context->get_context_name(false));
|
||||
$PAGE->set_heading(print_context_name($context, false));
|
||||
$PAGE->set_cacheable(false);
|
||||
break;
|
||||
case CONTEXT_BLOCK:
|
||||
@@ -124,7 +122,7 @@ if (!is_null($reportuser)) {
|
||||
echo $OUTPUT->box_start('generalbox boxaligncenter boxwidthwide');
|
||||
|
||||
if (!empty($roleassignments)) {
|
||||
echo $OUTPUT->heading(get_string('rolesforuser', 'core_role', fullname($reportuser)), 3);
|
||||
echo $OUTPUT->heading(get_string('rolesforuser', 'role', fullname($reportuser)), 3);
|
||||
echo html_writer::start_tag('ul');
|
||||
|
||||
$systemcontext = context_system::instance();
|
||||
@@ -138,20 +136,20 @@ if (!is_null($reportuser)) {
|
||||
array('action' => 'view', 'roleid' => $ra->roleid)), $rolename);
|
||||
}
|
||||
|
||||
echo html_writer::tag('li', get_string('roleincontext', 'core_role',
|
||||
echo html_writer::tag('li', get_string('roleincontext', 'role',
|
||||
array('role' => $rolename, 'context' => $link)));
|
||||
}
|
||||
echo html_writer::end_tag('ul');
|
||||
}
|
||||
|
||||
echo $OUTPUT->heading(get_string('permissionsforuser', 'core_role', fullname($reportuser)), 3);
|
||||
$table = new core_role_check_capability_table($context, $reportuser, $contextname);
|
||||
echo $OUTPUT->heading(get_string('permissionsforuser', 'role', fullname($reportuser)), 3);
|
||||
$table = new check_capability_table($context, $reportuser, $contextname);
|
||||
$table->display();
|
||||
echo $OUTPUT->box_end();
|
||||
|
||||
$selectheading = get_string('selectanotheruser', 'core_role');
|
||||
$selectheading = get_string('selectanotheruser', 'role');
|
||||
} else {
|
||||
$selectheading = get_string('selectauser', 'core_role');
|
||||
$selectheading = get_string('selectauser', 'role');
|
||||
}
|
||||
|
||||
// Show UI for choosing a user to report on.
|
||||
@@ -172,14 +170,14 @@ echo $OUTPUT->heading('<label for="reportuser">' . $selectheading . '</label>',
|
||||
$userselector->display();
|
||||
|
||||
// Submit button and the end of the form.
|
||||
echo '<p id="chooseusersubmit"><input type="submit" value="' . get_string('showthisuserspermissions', 'core_role') . '" /></p>';
|
||||
echo '<p id="chooseusersubmit"><input type="submit" value="' . get_string('showthisuserspermissions', 'role') . '" /></p>';
|
||||
echo '</form>';
|
||||
echo $OUTPUT->box_end();
|
||||
|
||||
// Appropriate back link.
|
||||
if ($context->contextlevel > CONTEXT_USER) {
|
||||
echo html_writer::start_tag('div', array('class'=>'backlink'));
|
||||
echo html_writer::tag('a', get_string('backto', '', $contextname), array('href'=>$context->get_url()));
|
||||
echo html_writer::tag('a', get_string('backto', '', $contextname), array('href'=>get_context_url($context)));
|
||||
echo html_writer::end_tag('div');
|
||||
}
|
||||
|
||||
|
||||
@@ -1,98 +0,0 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Existing admin user selector.
|
||||
*
|
||||
* @package core_role
|
||||
* @copyright 2010 Petr Skoda {@link http://skodak.org}
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
require_once($CFG->dirroot.'/user/selector/lib.php');
|
||||
|
||||
class core_role_admins_existing_selector extends user_selector_base {
|
||||
/**
|
||||
* Create instance.
|
||||
*
|
||||
* @param string $name control name
|
||||
* @param array $options should have two elements with keys groupid and courseid.
|
||||
*/
|
||||
public function __construct($name = null, $options = array()) {
|
||||
if (is_null($name)) {
|
||||
$name = 'removeselect';
|
||||
}
|
||||
$options['multiselect'] = false;
|
||||
parent::__construct($name, $options);
|
||||
}
|
||||
|
||||
public function find_users($search) {
|
||||
global $DB, $CFG;
|
||||
list($wherecondition, $params) = $this->search_sql($search, '');
|
||||
|
||||
$fields = 'SELECT ' . $this->required_fields_sql('');
|
||||
|
||||
if ($wherecondition) {
|
||||
$wherecondition = "$wherecondition AND id IN ($CFG->siteadmins)";
|
||||
} else {
|
||||
$wherecondition = "id IN ($CFG->siteadmins)";
|
||||
}
|
||||
$sql = " FROM {user}
|
||||
WHERE $wherecondition";
|
||||
|
||||
list($sort, $sortparams) = users_order_by_sql('', $search, $this->accesscontext);
|
||||
$params = array_merge($params, $sortparams);
|
||||
$order = ' ORDER BY ' . $sort;
|
||||
|
||||
$availableusers = $DB->get_records_sql($fields . $sql . $order, $params);
|
||||
|
||||
if (empty($availableusers)) {
|
||||
return array();
|
||||
}
|
||||
|
||||
$mainadmin = array();
|
||||
$mainadminuser = get_admin();
|
||||
if ($mainadminuser && isset($availableusers[$mainadminuser->id])) {
|
||||
$mainadmin = array($mainadminuser->id => $availableusers[$mainadminuser->id]);
|
||||
unset($availableusers[$mainadminuser->id]);
|
||||
}
|
||||
|
||||
$result = array();
|
||||
if ($mainadmin) {
|
||||
$result[get_string('mainadmin', 'core_role')] = $mainadmin;
|
||||
}
|
||||
|
||||
if ($availableusers) {
|
||||
if ($search) {
|
||||
$groupname = get_string('extusersmatching', 'core_role', $search);
|
||||
} else {
|
||||
$groupname = get_string('extusers', 'core_role');
|
||||
}
|
||||
$result[$groupname] = $availableusers;
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
protected function get_options() {
|
||||
global $CFG;
|
||||
$options = parent::get_options();
|
||||
$options['file'] = $CFG->admin . '/roles/lib.php';
|
||||
return $options;
|
||||
}
|
||||
}
|
||||
@@ -1,91 +0,0 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Potential admin user selector.
|
||||
*
|
||||
* @package core_role
|
||||
* @copyright 2010 Petr Skoda {@link http://skodak.org}
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
require_once($CFG->dirroot.'/user/selector/lib.php');
|
||||
|
||||
class core_role_admins_potential_selector extends user_selector_base {
|
||||
/**
|
||||
* Create instance.
|
||||
*
|
||||
* @param string $name control name
|
||||
* @param array $options should have two elements with keys groupid and courseid.
|
||||
*/
|
||||
public function __construct($name = null, $options = array()) {
|
||||
global $CFG;
|
||||
if (is_null($name)) {
|
||||
$name = 'addselect';
|
||||
}
|
||||
$options['multiselect'] = false;
|
||||
$options['exclude'] = explode(',', $CFG->siteadmins);
|
||||
parent::__construct($name, $options);
|
||||
}
|
||||
|
||||
public function find_users($search) {
|
||||
global $CFG, $DB;
|
||||
list($wherecondition, $params) = $this->search_sql($search, '');
|
||||
|
||||
$fields = 'SELECT ' . $this->required_fields_sql('');
|
||||
$countfields = 'SELECT COUNT(1)';
|
||||
|
||||
$sql = " FROM {user}
|
||||
WHERE $wherecondition AND mnethostid = :localmnet";
|
||||
|
||||
// It could be dangerous to make remote users admins and also this could lead to other problems.
|
||||
$params['localmnet'] = $CFG->mnet_localhost_id;
|
||||
|
||||
list($sort, $sortparams) = users_order_by_sql('', $search, $this->accesscontext);
|
||||
$order = ' ORDER BY ' . $sort;
|
||||
|
||||
// Check to see if there are too many to show sensibly.
|
||||
if (!$this->is_validating()) {
|
||||
$potentialcount = $DB->count_records_sql($countfields . $sql, $params);
|
||||
if ($potentialcount > $this->maxusersperpage) {
|
||||
return $this->too_many_results($search, $potentialcount);
|
||||
}
|
||||
}
|
||||
|
||||
$availableusers = $DB->get_records_sql($fields . $sql . $order, array_merge($params, $sortparams));
|
||||
|
||||
if (empty($availableusers)) {
|
||||
return array();
|
||||
}
|
||||
|
||||
if ($search) {
|
||||
$groupname = get_string('potusersmatching', 'core_role', $search);
|
||||
} else {
|
||||
$groupname = get_string('potusers', 'core_role');
|
||||
}
|
||||
|
||||
return array($groupname => $availableusers);
|
||||
}
|
||||
|
||||
protected function get_options() {
|
||||
global $CFG;
|
||||
$options = parent::get_options();
|
||||
$options['file'] = $CFG->admin . '/roles/lib.php';
|
||||
return $options;
|
||||
}
|
||||
}
|
||||
@@ -1,49 +0,0 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Role assign matrix.
|
||||
*
|
||||
* @package core_role
|
||||
* @copyright 1999 onwards Martin Dougiamas (http://dougiamas.com)
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
/**
|
||||
* Subclass of role_allow_role_page for the Allow assigns tab.
|
||||
*/
|
||||
class core_role_allow_assign_page extends core_role_allow_role_page {
|
||||
public function __construct() {
|
||||
parent::__construct('role_allow_assign', 'allowassign');
|
||||
}
|
||||
|
||||
protected function set_allow($fromroleid, $targetroleid) {
|
||||
allow_assign($fromroleid, $targetroleid);
|
||||
}
|
||||
|
||||
protected function get_cell_tooltip($fromrole, $targetrole) {
|
||||
$a = new stdClass;
|
||||
$a->fromrole = $fromrole->localname;
|
||||
$a->targetrole = $targetrole->localname;
|
||||
return get_string('allowroletoassign', 'core_role', $a);
|
||||
}
|
||||
|
||||
public function get_intro_text() {
|
||||
return get_string('configallowassign', 'core_admin');
|
||||
}
|
||||
}
|
||||
@@ -1,49 +0,0 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Role override matrix.
|
||||
*
|
||||
* @package core_role
|
||||
* @copyright 1999 onwards Martin Dougiamas (http://dougiamas.com)
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
/**
|
||||
* Subclass of role_allow_role_page for the Allow overrides tab.
|
||||
*/
|
||||
class core_role_allow_override_page extends core_role_allow_role_page {
|
||||
public function __construct() {
|
||||
parent::__construct('role_allow_override', 'allowoverride');
|
||||
}
|
||||
|
||||
protected function set_allow($fromroleid, $targetroleid) {
|
||||
allow_override($fromroleid, $targetroleid);
|
||||
}
|
||||
|
||||
protected function get_cell_tooltip($fromrole, $targetrole) {
|
||||
$a = new stdClass;
|
||||
$a->fromrole = $fromrole->localname;
|
||||
$a->targetrole = $targetrole->localname;
|
||||
return get_string('allowroletooverride', 'core_role', $a);
|
||||
}
|
||||
|
||||
public function get_intro_text() {
|
||||
return get_string('configallowoverride2', 'core_admin');
|
||||
}
|
||||
}
|
||||
@@ -1,164 +0,0 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Base class for allow matrices.
|
||||
*
|
||||
* @package core_role
|
||||
* @copyright 1999 onwards Martin Dougiamas (http://dougiamas.com)
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
/**
|
||||
* Base class for managing the data in the grid of checkboxes on the role allow
|
||||
* allow/overrides/switch editing pages (allow.php).
|
||||
*/
|
||||
abstract class core_role_allow_role_page {
|
||||
protected $tablename;
|
||||
protected $targetcolname;
|
||||
protected $roles;
|
||||
protected $allowed = null;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param string $tablename the table where our data is stored.
|
||||
* @param string $targetcolname the name of the target role id column.
|
||||
*/
|
||||
public function __construct($tablename, $targetcolname) {
|
||||
$this->tablename = $tablename;
|
||||
$this->targetcolname = $targetcolname;
|
||||
$this->load_required_roles();
|
||||
}
|
||||
|
||||
/**
|
||||
* Load information about all the roles we will need information about.
|
||||
*/
|
||||
protected function load_required_roles() {
|
||||
// Get all roles.
|
||||
$this->roles = role_fix_names(get_all_roles(), context_system::instance(), ROLENAME_ORIGINAL);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the data with the new settings submitted by the user.
|
||||
*/
|
||||
public function process_submission() {
|
||||
global $DB;
|
||||
// Delete all records, then add back the ones that should be allowed.
|
||||
$DB->delete_records($this->tablename);
|
||||
foreach ($this->roles as $fromroleid => $notused) {
|
||||
foreach ($this->roles as $targetroleid => $alsonotused) {
|
||||
if (optional_param('s_' . $fromroleid . '_' . $targetroleid, false, PARAM_BOOL)) {
|
||||
$this->set_allow($fromroleid, $targetroleid);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set one allow in the database.
|
||||
* @param int $fromroleid
|
||||
* @param int $targetroleid
|
||||
*/
|
||||
protected abstract function set_allow($fromroleid, $targetroleid);
|
||||
|
||||
/**
|
||||
* Load the current allows from the database.
|
||||
*/
|
||||
public function load_current_settings() {
|
||||
global $DB;
|
||||
// Load the current settings.
|
||||
$this->allowed = array();
|
||||
foreach ($this->roles as $role) {
|
||||
// Make an array $role->id => false. This is probably too clever for its own good.
|
||||
$this->allowed[$role->id] = array_combine(array_keys($this->roles), array_fill(0, count($this->roles), false));
|
||||
}
|
||||
$rs = $DB->get_recordset($this->tablename);
|
||||
foreach ($rs as $allow) {
|
||||
$this->allowed[$allow->roleid][$allow->{$this->targetcolname}] = true;
|
||||
}
|
||||
$rs->close();
|
||||
}
|
||||
|
||||
/**
|
||||
* Is target allowed?
|
||||
*
|
||||
* @param integer $targetroleid a role id.
|
||||
* @return boolean whether the user should be allowed to select this role as a target role.
|
||||
*/
|
||||
protected function is_allowed_target($targetroleid) {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns structure that can be passed to print_table,
|
||||
* containing one cell for each checkbox.
|
||||
* @return html_table a table
|
||||
*/
|
||||
public function get_table() {
|
||||
$table = new html_table();
|
||||
$table->tablealign = 'center';
|
||||
$table->cellpadding = 5;
|
||||
$table->cellspacing = 0;
|
||||
$table->width = '90%';
|
||||
$table->align = array('left');
|
||||
$table->rotateheaders = true;
|
||||
$table->head = array(' ');
|
||||
$table->colclasses = array('');
|
||||
|
||||
// Add role name headers.
|
||||
foreach ($this->roles as $targetrole) {
|
||||
$table->head[] = $targetrole->localname;
|
||||
$table->align[] = 'left';
|
||||
if ($this->is_allowed_target($targetrole->id)) {
|
||||
$table->colclasses[] = '';
|
||||
} else {
|
||||
$table->colclasses[] = 'dimmed_text';
|
||||
}
|
||||
}
|
||||
|
||||
// Now the rest of the table.
|
||||
foreach ($this->roles as $fromrole) {
|
||||
$row = array($fromrole->localname);
|
||||
foreach ($this->roles as $targetrole) {
|
||||
$checked = '';
|
||||
$disabled = '';
|
||||
if ($this->allowed[$fromrole->id][$targetrole->id]) {
|
||||
$checked = 'checked="checked" ';
|
||||
}
|
||||
if (!$this->is_allowed_target($targetrole->id)) {
|
||||
$disabled = 'disabled="disabled" ';
|
||||
}
|
||||
$name = 's_' . $fromrole->id . '_' . $targetrole->id;
|
||||
$tooltip = $this->get_cell_tooltip($fromrole, $targetrole);
|
||||
$row[] = '<input type="checkbox" name="' . $name . '" id="' . $name .
|
||||
'" title="' . $tooltip . '" value="1" ' . $checked . $disabled . '/>' .
|
||||
'<label for="' . $name . '" class="accesshide">' . $tooltip . '</label>';
|
||||
}
|
||||
$table->data[] = $row;
|
||||
}
|
||||
|
||||
return $table;
|
||||
}
|
||||
|
||||
/**
|
||||
* Snippet of text displayed above the table, telling the admin what to do.
|
||||
* @return string
|
||||
*/
|
||||
public abstract function get_intro_text();
|
||||
}
|
||||
@@ -1,61 +0,0 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Role witch matrix.
|
||||
*
|
||||
* @package core_role
|
||||
* @copyright 1999 onwards Martin Dougiamas (http://dougiamas.com)
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
/**
|
||||
* Subclass of role_allow_role_page for the Allow switches tab.
|
||||
*/
|
||||
class core_role_allow_switch_page extends core_role_allow_role_page {
|
||||
protected $allowedtargetroles;
|
||||
|
||||
public function __construct() {
|
||||
parent::__construct('role_allow_switch', 'allowswitch');
|
||||
}
|
||||
|
||||
protected function load_required_roles() {
|
||||
global $DB;
|
||||
parent::load_required_roles();
|
||||
$this->allowedtargetroles = $DB->get_records_menu('role', null, 'id');
|
||||
}
|
||||
|
||||
protected function set_allow($fromroleid, $targetroleid) {
|
||||
allow_switch($fromroleid, $targetroleid);
|
||||
}
|
||||
|
||||
protected function is_allowed_target($targetroleid) {
|
||||
return isset($this->allowedtargetroles[$targetroleid]);
|
||||
}
|
||||
|
||||
protected function get_cell_tooltip($fromrole, $targetrole) {
|
||||
$a = new stdClass;
|
||||
$a->fromrole = $fromrole->localname;
|
||||
$a->targetrole = $targetrole->localname;
|
||||
return get_string('allowroletoswitch', 'core_role', $a);
|
||||
}
|
||||
|
||||
public function get_intro_text() {
|
||||
return get_string('configallowswitch', 'core_admin');
|
||||
}
|
||||
}
|
||||
@@ -1,61 +0,0 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Library code used by the roles administration interfaces.
|
||||
*
|
||||
* @package core_role
|
||||
* @copyright 1999 onwards Martin Dougiamas (http://dougiamas.com)
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
require_once($CFG->dirroot.'/user/selector/lib.php');
|
||||
|
||||
/**
|
||||
* Base class to avoid duplicating code.
|
||||
*/
|
||||
abstract class core_role_assign_user_selector_base extends user_selector_base {
|
||||
protected $roleid;
|
||||
protected $context;
|
||||
|
||||
/**
|
||||
* @param string $name control name
|
||||
* @param array $options should have two elements with keys groupid and courseid.
|
||||
*/
|
||||
public function __construct($name, $options) {
|
||||
global $CFG;
|
||||
if (isset($options['context'])) {
|
||||
$this->context = $options['context'];
|
||||
} else {
|
||||
$this->context = context::instance_by_id($options['contextid']);
|
||||
}
|
||||
$options['accesscontext'] = $this->context;
|
||||
parent::__construct($name, $options);
|
||||
$this->roleid = $options['roleid'];
|
||||
require_once($CFG->dirroot . '/group/lib.php');
|
||||
}
|
||||
|
||||
protected function get_options() {
|
||||
global $CFG;
|
||||
$options = parent::get_options();
|
||||
$options['file'] = $CFG->admin . '/roles/lib.php';
|
||||
$options['roleid'] = $this->roleid;
|
||||
$options['contextid'] = $this->context->id;
|
||||
return $options;
|
||||
}
|
||||
}
|
||||
@@ -1,179 +0,0 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Base capability table.
|
||||
*
|
||||
* @package core_role
|
||||
* @copyright 1999 onwards Martin Dougiamas (http://dougiamas.com)
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
/**
|
||||
* This class represents a table with one row for each of a list of capabilities
|
||||
* where the first cell in the row contains the capability name, and there is
|
||||
* arbitrary stuff in the rest of the row. This class is used by
|
||||
* admin/roles/manage.php, override.php and check.php.
|
||||
*
|
||||
* An ajaxy search UI shown at the top, if JavaScript is on.
|
||||
*/
|
||||
abstract class core_role_capability_table_base {
|
||||
/** The context this table relates to. */
|
||||
protected $context;
|
||||
|
||||
/** The capabilities to display. Initialised as $context->get_capabilities(). */
|
||||
protected $capabilities = array();
|
||||
|
||||
/** Added as an id="" attribute to the table on output. */
|
||||
protected $id;
|
||||
|
||||
/** Added to the class="" attribute on output. */
|
||||
protected $classes = array('rolecap');
|
||||
|
||||
/** Default number of capabilities in the table for the search UI to be shown. */
|
||||
const NUM_CAPS_FOR_SEARCH = 12;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
* @param context $context the context this table relates to.
|
||||
* @param string $id what to put in the id="" attribute.
|
||||
*/
|
||||
public function __construct(context $context, $id) {
|
||||
$this->context = $context;
|
||||
$this->capabilities = $context->get_capabilities();
|
||||
$this->id = $id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Use this to add class="" attributes to the table. You get the rolecap by
|
||||
* default.
|
||||
* @param array $classnames of class names.
|
||||
*/
|
||||
public function add_classes($classnames) {
|
||||
$this->classes = array_unique(array_merge($this->classes, $classnames));
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the table.
|
||||
*/
|
||||
public function display() {
|
||||
if (count($this->capabilities) > self::NUM_CAPS_FOR_SEARCH) {
|
||||
global $PAGE;
|
||||
$jsmodule = array(
|
||||
'name' => 'rolescapfilter',
|
||||
'fullpath' => '/admin/roles/module.js',
|
||||
'strings' => array(
|
||||
array('filter', 'moodle'),
|
||||
array('clear', 'moodle'), ),
|
||||
'requires' => array('node', 'cookie', 'escape')
|
||||
);
|
||||
$PAGE->requires->js_init_call('M.core_role.init_cap_table_filter', array($this->id, $this->context->id), false,
|
||||
$jsmodule);
|
||||
}
|
||||
echo '<table class="' . implode(' ', $this->classes) . '" id="' . $this->id . '">' . "\n<thead>\n";
|
||||
echo '<tr><th class="name" align="left" scope="col">' . get_string('capability', 'core_role') . '</th>';
|
||||
$this->add_header_cells();
|
||||
echo "</tr>\n</thead>\n<tbody>\n";
|
||||
|
||||
// Loop over capabilities.
|
||||
$contextlevel = 0;
|
||||
$component = '';
|
||||
foreach ($this->capabilities as $capability) {
|
||||
if ($this->skip_row($capability)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Prints a breaker if component or name or context level has changed.
|
||||
if (component_level_changed($capability, $component, $contextlevel)) {
|
||||
$this->print_heading_row($capability);
|
||||
}
|
||||
$contextlevel = $capability->contextlevel;
|
||||
$component = $capability->component;
|
||||
|
||||
// Start the row.
|
||||
echo '<tr class="' . implode(' ', array_unique(array_merge(array('rolecap'),
|
||||
$this->get_row_classes($capability)))) . '">';
|
||||
|
||||
// Table cell for the capability name.
|
||||
echo '<th scope="row" class="name"><span class="cap-desc">' . get_capability_docs_link($capability) .
|
||||
'<span class="cap-name">' . $capability->name . '</span></span></th>';
|
||||
|
||||
// Add the cells specific to this table.
|
||||
$this->add_row_cells($capability);
|
||||
|
||||
// End the row.
|
||||
echo "</tr>\n";
|
||||
}
|
||||
|
||||
// End of the table.
|
||||
echo "</tbody>\n</table>\n";
|
||||
}
|
||||
|
||||
/**
|
||||
* Used to output a heading rows when the context level or component changes.
|
||||
* @param stdClass $capability gives the new component and contextlevel.
|
||||
*/
|
||||
protected function print_heading_row($capability) {
|
||||
echo '<tr class="rolecapheading header"><td colspan="' . (1 + $this->num_extra_columns()) . '" class="header"><strong>' .
|
||||
get_component_string($capability->component, $capability->contextlevel) .
|
||||
'</strong></td></tr>';
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* For subclasses to override, output header cells, after the initial capability one.
|
||||
*/
|
||||
protected abstract function add_header_cells();
|
||||
|
||||
/**
|
||||
* For subclasses to override, return the number of cells that add_header_cells/add_row_cells output.
|
||||
*/
|
||||
protected abstract function num_extra_columns();
|
||||
|
||||
/**
|
||||
* For subclasses to override. Allows certain capabilties
|
||||
* to be left out of the table.
|
||||
*
|
||||
* @param object $capability the capability this row relates to.
|
||||
* @return boolean. If true, this row is omitted from the table.
|
||||
*/
|
||||
protected function skip_row($capability) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* For subclasses to override. A change to reaturn class names that are added
|
||||
* to the class="" attribute on the <tr> for this capability.
|
||||
*
|
||||
* @param stdClass $capability the capability this row relates to.
|
||||
* @return array of class name strings.
|
||||
*/
|
||||
protected function get_row_classes($capability) {
|
||||
return array();
|
||||
}
|
||||
|
||||
/**
|
||||
* For subclasses to override. Output the data cells for this capability. The
|
||||
* capability name cell will already have been output.
|
||||
*
|
||||
* You can rely on get_row_classes always being called before add_row_cells.
|
||||
*
|
||||
* @param stdClass $capability the capability this row relates to.
|
||||
*/
|
||||
protected abstract function add_row_cells($capability);
|
||||
}
|
||||
@@ -1,193 +0,0 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Capabilities table with risks.
|
||||
*
|
||||
* @package core_role
|
||||
* @copyright 1999 onwards Martin Dougiamas (http://dougiamas.com)
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
/**
|
||||
* This subclass is the bases for both the define roles and override roles
|
||||
* pages. As well as adding the risks columns, this also provides generic
|
||||
* facilities for showing a certain number of permissions columns, and
|
||||
* recording the current and submitted permissions for each capability.
|
||||
*/
|
||||
abstract class core_role_capability_table_with_risks extends core_role_capability_table_base {
|
||||
protected $allrisks;
|
||||
protected $allpermissions; // We don't need perms ourselves, but all our subclasses do.
|
||||
protected $strperms; // Language string cache.
|
||||
protected $risksurl; // URL in moodledocs about risks.
|
||||
protected $riskicons = array(); // Cache to avoid regenerating the HTML for each risk icon.
|
||||
/** @var array The capabilities to highlight as default/inherited. */
|
||||
protected $parentpermissions;
|
||||
protected $displaypermissions;
|
||||
protected $permissions;
|
||||
protected $changed;
|
||||
protected $roleid;
|
||||
|
||||
public function __construct($context, $id, $roleid) {
|
||||
parent::__construct($context, $id);
|
||||
|
||||
$this->allrisks = get_all_risks();
|
||||
$this->risksurl = get_docs_url(s(get_string('risks', 'core_role')));
|
||||
|
||||
$this->allpermissions = array(
|
||||
CAP_INHERIT => 'inherit',
|
||||
CAP_ALLOW => 'allow',
|
||||
CAP_PREVENT => 'prevent' ,
|
||||
CAP_PROHIBIT => 'prohibit',
|
||||
);
|
||||
|
||||
$this->strperms = array();
|
||||
foreach ($this->allpermissions as $permname) {
|
||||
$this->strperms[$permname] = get_string($permname, 'core_role');
|
||||
}
|
||||
|
||||
$this->roleid = $roleid;
|
||||
$this->load_current_permissions();
|
||||
|
||||
// Fill in any blank permissions with an explicit CAP_INHERIT, and init a locked field.
|
||||
foreach ($this->capabilities as $capid => $cap) {
|
||||
if (!isset($this->permissions[$cap->name])) {
|
||||
$this->permissions[$cap->name] = CAP_INHERIT;
|
||||
}
|
||||
$this->capabilities[$capid]->locked = false;
|
||||
}
|
||||
}
|
||||
|
||||
protected function load_current_permissions() {
|
||||
global $DB;
|
||||
|
||||
// Load the overrides/definition in this context.
|
||||
if ($this->roleid) {
|
||||
$this->permissions = $DB->get_records_menu('role_capabilities', array('roleid' => $this->roleid,
|
||||
'contextid' => $this->context->id), '', 'capability,permission');
|
||||
} else {
|
||||
$this->permissions = array();
|
||||
}
|
||||
}
|
||||
|
||||
protected abstract function load_parent_permissions();
|
||||
|
||||
/**
|
||||
* Update $this->permissions based on submitted data, while making a list of
|
||||
* changed capabilities in $this->changed.
|
||||
*/
|
||||
public function read_submitted_permissions() {
|
||||
$this->changed = array();
|
||||
|
||||
foreach ($this->capabilities as $cap) {
|
||||
if ($cap->locked || $this->skip_row($cap)) {
|
||||
// The user is not allowed to change the permission for this capability.
|
||||
continue;
|
||||
}
|
||||
|
||||
$permission = optional_param($cap->name, null, PARAM_PERMISSION);
|
||||
if (is_null($permission)) {
|
||||
// A permission was not specified in submitted data.
|
||||
continue;
|
||||
}
|
||||
|
||||
// If the permission has changed, update $this->permissions and
|
||||
// Record the fact there is data to save.
|
||||
if ($this->permissions[$cap->name] != $permission) {
|
||||
$this->permissions[$cap->name] = $permission;
|
||||
$this->changed[] = $cap->name;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Save the new values of any permissions that have been changed.
|
||||
*/
|
||||
public function save_changes() {
|
||||
// Set the permissions.
|
||||
foreach ($this->changed as $changedcap) {
|
||||
assign_capability($changedcap, $this->permissions[$changedcap],
|
||||
$this->roleid, $this->context->id, true);
|
||||
}
|
||||
|
||||
// Force accessinfo refresh for users visiting this context.
|
||||
$this->context->mark_dirty();
|
||||
}
|
||||
|
||||
public function display() {
|
||||
$this->load_parent_permissions();
|
||||
foreach ($this->capabilities as $cap) {
|
||||
if (!isset($this->parentpermissions[$cap->name])) {
|
||||
$this->parentpermissions[$cap->name] = CAP_INHERIT;
|
||||
}
|
||||
}
|
||||
parent::display();
|
||||
}
|
||||
|
||||
protected function add_header_cells() {
|
||||
global $OUTPUT;
|
||||
echo '<th colspan="' . count($this->displaypermissions) . '" scope="col">' .
|
||||
get_string('permission', 'core_role') . ' ' . $OUTPUT->help_icon('permission', 'core_role') . '</th>';
|
||||
echo '<th class="risk" colspan="' . count($this->allrisks) . '" scope="col">' . get_string('risks', 'core_role') . '</th>';
|
||||
}
|
||||
|
||||
protected function num_extra_columns() {
|
||||
return count($this->displaypermissions) + count($this->allrisks);
|
||||
}
|
||||
|
||||
protected function get_row_classes($capability) {
|
||||
$rowclasses = array();
|
||||
foreach ($this->allrisks as $riskname => $risk) {
|
||||
if ($risk & (int)$capability->riskbitmask) {
|
||||
$rowclasses[] = $riskname;
|
||||
}
|
||||
}
|
||||
return $rowclasses;
|
||||
}
|
||||
|
||||
protected abstract function add_permission_cells($capability);
|
||||
|
||||
protected function add_row_cells($capability) {
|
||||
$this->add_permission_cells($capability);
|
||||
// One cell for each possible risk.
|
||||
foreach ($this->allrisks as $riskname => $risk) {
|
||||
echo '<td class="risk ' . str_replace('risk', '', $riskname) . '">';
|
||||
if ($risk & (int)$capability->riskbitmask) {
|
||||
echo $this->get_risk_icon($riskname);
|
||||
}
|
||||
echo '</td>';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Print a risk icon, as a link to the Risks page on Moodle Docs.
|
||||
*
|
||||
* @param string $type the type of risk, will be one of the keys from the
|
||||
* get_all_risks array. Must start with 'risk'.
|
||||
*/
|
||||
public function get_risk_icon($type) {
|
||||
global $OUTPUT;
|
||||
if (!isset($this->riskicons[$type])) {
|
||||
$iconurl = $OUTPUT->pix_url('i/' . str_replace('risk', 'risk_', $type));
|
||||
$text = '<img src="' . $iconurl . '" alt="' . get_string($type . 'short', 'admin') . '" />';
|
||||
$action = new popup_action('click', $this->risksurl, 'docspopup');
|
||||
$this->riskicons[$type] = $OUTPUT->action_link($this->risksurl, $text, $action, array('title'=>get_string($type, 'admin')));
|
||||
}
|
||||
return $this->riskicons[$type];
|
||||
}
|
||||
}
|
||||
@@ -1,84 +0,0 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Library code used by the roles administration interfaces.
|
||||
*
|
||||
* @package core_role
|
||||
* @copyright 1999 onwards Martin Dougiamas (http://dougiamas.com)
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
/**
|
||||
* Subclass of core_role_capability_table_base for use on the Check permissions page.
|
||||
*
|
||||
* We have one additional column, Allowed, which contains yes/no.
|
||||
*/
|
||||
class core_role_check_capability_table extends core_role_capability_table_base {
|
||||
protected $user;
|
||||
protected $fullname;
|
||||
protected $contextname;
|
||||
protected $stryes;
|
||||
protected $strno;
|
||||
private $hascap;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* @param object $context the context this table relates to.
|
||||
* @param object $user the user we are generating the results for.
|
||||
* @param string $contextname $context->get_context_name() - to save recomputing.
|
||||
*/
|
||||
public function __construct($context, $user, $contextname) {
|
||||
parent::__construct($context, 'explaincaps');
|
||||
$this->user = $user;
|
||||
$this->fullname = fullname($user);
|
||||
$this->contextname = $contextname;
|
||||
$this->stryes = get_string('yes');
|
||||
$this->strno = get_string('no');
|
||||
}
|
||||
|
||||
protected function add_header_cells() {
|
||||
echo '<th>' . get_string('allowed', 'core_role') . '</th>';
|
||||
}
|
||||
|
||||
protected function num_extra_columns() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
protected function get_row_classes($capability) {
|
||||
$this->hascap = has_capability($capability->name, $this->context, $this->user->id);
|
||||
if ($this->hascap) {
|
||||
return array('yes');
|
||||
} else {
|
||||
return array('no');
|
||||
}
|
||||
}
|
||||
|
||||
protected function add_row_cells($capability) {
|
||||
if ($this->hascap) {
|
||||
$result = $this->stryes;
|
||||
} else {
|
||||
$result = $this->strno;
|
||||
}
|
||||
$a = new stdClass;
|
||||
$a->fullname = $this->fullname;
|
||||
$a->capability = $capability->name;
|
||||
$a->context = $this->contextname;
|
||||
echo '<td>' . $result . '</td>';
|
||||
}
|
||||
}
|
||||
@@ -1,153 +0,0 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* User selector.
|
||||
*
|
||||
* @package core_role
|
||||
* @copyright 1999 onwards Martin Dougiamas (http://dougiamas.com)
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
require_once($CFG->dirroot.'/user/selector/lib.php');
|
||||
|
||||
/**
|
||||
* User selector subclass for the selection of users in the check permissions page.
|
||||
*
|
||||
* @copyright 2012 Petr Skoda {@link http://skodak.org}
|
||||
*/
|
||||
class core_role_check_users_selector extends user_selector_base {
|
||||
/** @var bool limit listing of users to enrolled only */
|
||||
protected $onlyenrolled;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param string $name the control name/id for use in the HTML.
|
||||
* @param array $options other options needed to construct this selector.
|
||||
* You must be able to clone a userselector by doing new get_class($us)($us->get_name(), $us->get_options());
|
||||
*/
|
||||
public function __construct($name, $options) {
|
||||
if (!isset($options['multiselect'])) {
|
||||
$options['multiselect'] = false;
|
||||
}
|
||||
parent::__construct($name, $options);
|
||||
|
||||
$coursecontext = $this->accesscontext->get_course_context(false);
|
||||
if ($coursecontext and $coursecontext->id != SITEID and !has_capability('moodle/role:manage', $coursecontext)) {
|
||||
// Prevent normal teachers from looking up all users.
|
||||
$this->onlyenrolled = true;
|
||||
} else {
|
||||
$this->onlyenrolled = false;
|
||||
}
|
||||
}
|
||||
|
||||
public function find_users($search) {
|
||||
global $DB;
|
||||
|
||||
list($wherecondition, $params) = $this->search_sql($search, 'u');
|
||||
|
||||
$fields = 'SELECT ' . $this->required_fields_sql('u');
|
||||
$countfields = 'SELECT COUNT(1)';
|
||||
|
||||
$coursecontext = $this->accesscontext->get_course_context(false);
|
||||
|
||||
if ($coursecontext and $coursecontext != SITEID) {
|
||||
$sql1 = " FROM {user} u
|
||||
JOIN {user_enrolments} ue ON (ue.userid = u.id)
|
||||
JOIN {enrol} e ON (e.id = ue.enrolid AND e.courseid = :courseid1)
|
||||
WHERE $wherecondition";
|
||||
$params['courseid1'] = $coursecontext->instanceid;
|
||||
|
||||
if ($this->onlyenrolled) {
|
||||
$sql2 = null;
|
||||
} else {
|
||||
$sql2 = " FROM {user} u
|
||||
LEFT JOIN ({user_enrolments} ue
|
||||
JOIN {enrol} e ON (e.id = ue.enrolid AND e.courseid = :courseid2)) ON (ue.userid = u.id)
|
||||
WHERE $wherecondition
|
||||
AND ue.id IS NULL";
|
||||
$params['courseid2'] = $coursecontext->instanceid;
|
||||
}
|
||||
|
||||
} else {
|
||||
if ($this->onlyenrolled) {
|
||||
// Bad luck, current user may not view only enrolled users.
|
||||
return array();
|
||||
}
|
||||
$sql1 = null;
|
||||
$sql2 = " FROM {user} u
|
||||
WHERE $wherecondition";
|
||||
}
|
||||
|
||||
$params['contextid'] = $this->accesscontext->id;
|
||||
|
||||
list($sort, $sortparams) = users_order_by_sql('u', $search, $this->accesscontext);
|
||||
$order = ' ORDER BY ' . $sort;
|
||||
|
||||
$result = array();
|
||||
|
||||
if ($search) {
|
||||
$groupname1 = get_string('enrolledusersmatching', 'enrol', $search);
|
||||
$groupname2 = get_string('potusersmatching', 'core_role', $search);
|
||||
} else {
|
||||
$groupname1 = get_string('enrolledusers', 'enrol');
|
||||
$groupname2 = get_string('potusers', 'core_role');
|
||||
}
|
||||
|
||||
if ($sql1) {
|
||||
$enrolleduserscount = $DB->count_records_sql($countfields . $sql1, $params);
|
||||
if (!$this->is_validating() and $enrolleduserscount > $this->maxusersperpage) {
|
||||
$result[$groupname1] = array();
|
||||
$toomany = $this->too_many_results($search, $enrolleduserscount);
|
||||
$result[implode(' - ', array_keys($toomany))] = array();
|
||||
|
||||
} else {
|
||||
$enrolledusers = $DB->get_records_sql($fields . $sql1 . $order, array_merge($params, $sortparams));
|
||||
if ($enrolledusers) {
|
||||
$result[$groupname1] = $enrolledusers;
|
||||
}
|
||||
}
|
||||
if ($sql2) {
|
||||
$result[''] = array();
|
||||
}
|
||||
}
|
||||
if ($sql2) {
|
||||
$otheruserscount = $DB->count_records_sql($countfields . $sql2, $params);
|
||||
if (!$this->is_validating() and $otheruserscount > $this->maxusersperpage) {
|
||||
$result[$groupname2] = array();
|
||||
$toomany = $this->too_many_results($search, $otheruserscount);
|
||||
$result[implode(' - ', array_keys($toomany))] = array();
|
||||
} else {
|
||||
$otherusers = $DB->get_records_sql($fields . $sql2 . $order, array_merge($params, $sortparams));
|
||||
if ($otherusers) {
|
||||
$result[$groupname2] = $otherusers;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
protected function get_options() {
|
||||
global $CFG;
|
||||
$options = parent::get_options();
|
||||
$options['file'] = $CFG->admin . '/roles/lib.php';
|
||||
return $options;
|
||||
}
|
||||
}
|
||||
@@ -1,648 +0,0 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Advanced role definition form.
|
||||
*
|
||||
* @package core_role
|
||||
* @copyright 1999 onwards Martin Dougiamas (http://dougiamas.com)
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
|
||||
/**
|
||||
* As well as tracking the permissions information about the role we are creating
|
||||
* or editing, we also track the other information about the role. (This class is
|
||||
* starting to be more and more like a formslib form in some respects.)
|
||||
*/
|
||||
class core_role_define_role_table_advanced extends core_role_capability_table_with_risks {
|
||||
/** @var stdClass Used to store other information (besides permissions) about the role we are creating/editing. */
|
||||
protected $role;
|
||||
/** @var array Used to store errors found when validating the data. */
|
||||
protected $errors;
|
||||
protected $contextlevels;
|
||||
protected $allcontextlevels;
|
||||
protected $disabled = '';
|
||||
|
||||
protected $allowassign;
|
||||
protected $allowoverride;
|
||||
protected $allowswitch;
|
||||
|
||||
public function __construct($context, $roleid) {
|
||||
$this->roleid = $roleid;
|
||||
parent::__construct($context, 'defineroletable', $roleid);
|
||||
$this->displaypermissions = $this->allpermissions;
|
||||
$this->strperms[$this->allpermissions[CAP_INHERIT]] = get_string('notset', 'core_role');
|
||||
|
||||
$this->allcontextlevels = array();
|
||||
$levels = context_helper::get_all_levels();
|
||||
foreach ($levels as $level => $classname) {
|
||||
$this->allcontextlevels[$level] = context_helper::get_level_name($level);
|
||||
}
|
||||
}
|
||||
|
||||
protected function load_current_permissions() {
|
||||
global $DB;
|
||||
if ($this->roleid) {
|
||||
if (!$this->role = $DB->get_record('role', array('id' => $this->roleid))) {
|
||||
throw new moodle_exception('invalidroleid');
|
||||
}
|
||||
$contextlevels = get_role_contextlevels($this->roleid);
|
||||
// Put the contextlevels in the array keys, as well as the values.
|
||||
if (!empty($contextlevels)) {
|
||||
$this->contextlevels = array_combine($contextlevels, $contextlevels);
|
||||
} else {
|
||||
$this->contextlevels = array();
|
||||
}
|
||||
$this->allowassign = array_keys($this->get_allow_roles_list('assign'));
|
||||
$this->allowoverride = array_keys($this->get_allow_roles_list('override'));
|
||||
$this->allowswitch = array_keys($this->get_allow_roles_list('switch'));
|
||||
|
||||
} else {
|
||||
$this->role = new stdClass;
|
||||
$this->role->name = '';
|
||||
$this->role->shortname = '';
|
||||
$this->role->description = '';
|
||||
$this->role->archetype = '';
|
||||
$this->contextlevels = array();
|
||||
$this->allowassign = array();
|
||||
$this->allowoverride = array();
|
||||
$this->allowswitch = array();
|
||||
}
|
||||
parent::load_current_permissions();
|
||||
}
|
||||
|
||||
public function read_submitted_permissions() {
|
||||
global $DB;
|
||||
$this->errors = array();
|
||||
|
||||
// Role short name. We clean this in a special way. We want to end up
|
||||
// with only lowercase safe ASCII characters.
|
||||
$shortname = optional_param('shortname', null, PARAM_RAW);
|
||||
if (!is_null($shortname)) {
|
||||
$this->role->shortname = $shortname;
|
||||
$this->role->shortname = core_text::specialtoascii($this->role->shortname);
|
||||
$this->role->shortname = core_text::strtolower(clean_param($this->role->shortname, PARAM_ALPHANUMEXT));
|
||||
if (empty($this->role->shortname)) {
|
||||
$this->errors['shortname'] = get_string('errorbadroleshortname', 'core_role');
|
||||
}
|
||||
}
|
||||
if ($DB->record_exists_select('role', 'shortname = ? and id <> ?', array($this->role->shortname, $this->roleid))) {
|
||||
$this->errors['shortname'] = get_string('errorexistsroleshortname', 'core_role');
|
||||
}
|
||||
|
||||
// Role name.
|
||||
$name = optional_param('name', null, PARAM_TEXT);
|
||||
if (!is_null($name)) {
|
||||
$this->role->name = $name;
|
||||
// Hack: short names of standard roles are equal to archetypes, empty name means localised via lang packs.
|
||||
$archetypes = get_role_archetypes();
|
||||
if (!isset($archetypes[$shortname]) and html_is_blank($this->role->name)) {
|
||||
$this->errors['name'] = get_string('errorbadrolename', 'core_role');
|
||||
}
|
||||
}
|
||||
if ($this->role->name !== '' and $DB->record_exists_select('role', 'name = ? and id <> ?', array($this->role->name, $this->roleid))) {
|
||||
$this->errors['name'] = get_string('errorexistsrolename', 'core_role');
|
||||
}
|
||||
|
||||
// Description.
|
||||
$description = optional_param('description', null, PARAM_RAW);
|
||||
if (!is_null($description)) {
|
||||
$this->role->description = $description;
|
||||
}
|
||||
|
||||
// Legacy type.
|
||||
$archetype = optional_param('archetype', null, PARAM_RAW);
|
||||
if (isset($archetype)) {
|
||||
$archetypes = get_role_archetypes();
|
||||
if (isset($archetypes[$archetype])) {
|
||||
$this->role->archetype = $archetype;
|
||||
} else {
|
||||
$this->role->archetype = '';
|
||||
}
|
||||
}
|
||||
|
||||
// Assignable context levels.
|
||||
foreach ($this->allcontextlevels as $cl => $notused) {
|
||||
$assignable = optional_param('contextlevel' . $cl, null, PARAM_BOOL);
|
||||
if (!is_null($assignable)) {
|
||||
if ($assignable) {
|
||||
$this->contextlevels[$cl] = $cl;
|
||||
} else {
|
||||
unset($this->contextlevels[$cl]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Allowed roles.
|
||||
$allow = optional_param_array('allowassign', null, PARAM_INT);
|
||||
if (!is_null($allow)) {
|
||||
$this->allowassign = $allow;
|
||||
}
|
||||
$allow = optional_param_array('allowoverride', null, PARAM_INT);
|
||||
if (!is_null($allow)) {
|
||||
$this->allowoverride = $allow;
|
||||
}
|
||||
$allow = optional_param_array('allowswitch', null, PARAM_INT);
|
||||
if (!is_null($allow)) {
|
||||
$this->allowswitch = $allow;
|
||||
}
|
||||
|
||||
// Now read the permissions for each capability.
|
||||
parent::read_submitted_permissions();
|
||||
}
|
||||
|
||||
public function is_submission_valid() {
|
||||
return empty($this->errors);
|
||||
}
|
||||
|
||||
/**
|
||||
* Call this after the table has been initialised,
|
||||
* this resets everything to that role.
|
||||
*
|
||||
* @param int $roleid role id or 0 for no role
|
||||
* @param array $options array with following keys:
|
||||
* 'name', 'shortname', 'description', 'permissions', 'archetype',
|
||||
* 'contextlevels', 'allowassign', 'allowoverride', 'allowswitch'
|
||||
*/
|
||||
public function force_duplicate($roleid, array $options) {
|
||||
global $DB;
|
||||
|
||||
if ($roleid == 0) {
|
||||
// This means reset to nothing == remove everything.
|
||||
|
||||
if ($options['shortname']) {
|
||||
$this->role->shortname = '';
|
||||
}
|
||||
|
||||
if ($options['name']) {
|
||||
$this->role->name = '';
|
||||
}
|
||||
|
||||
if ($options['description']) {
|
||||
$this->role->description = '';
|
||||
}
|
||||
|
||||
if ($options['archetype']) {
|
||||
$this->role->archetype = '';
|
||||
}
|
||||
|
||||
if ($options['contextlevels']) {
|
||||
$this->contextlevels = array();
|
||||
}
|
||||
|
||||
if ($options['allowassign']) {
|
||||
$this->allowassign = array();
|
||||
}
|
||||
if ($options['allowoverride']) {
|
||||
$this->allowoverride = array();
|
||||
}
|
||||
if ($options['allowswitch']) {
|
||||
$this->allowswitch = array();
|
||||
}
|
||||
|
||||
if ($options['permissions']) {
|
||||
foreach ($this->capabilities as $capid => $cap) {
|
||||
$this->permissions[$cap->name] = CAP_INHERIT;
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$role = $DB->get_record('role', array('id'=>$roleid), '*', MUST_EXIST);
|
||||
|
||||
if ($options['shortname']) {
|
||||
$this->role->shortname = $role->shortname;
|
||||
}
|
||||
|
||||
if ($options['name']) {
|
||||
$this->role->name = $role->name;
|
||||
}
|
||||
|
||||
if ($options['description']) {
|
||||
$this->role->description = $role->description;
|
||||
}
|
||||
|
||||
if ($options['archetype']) {
|
||||
$this->role->archetype = $role->archetype;
|
||||
}
|
||||
|
||||
if ($options['contextlevels']) {
|
||||
$this->contextlevels = array();
|
||||
$levels = get_role_contextlevels($roleid);
|
||||
foreach ($levels as $cl) {
|
||||
$this->contextlevels[$cl] = $cl;
|
||||
}
|
||||
}
|
||||
|
||||
if ($options['allowassign']) {
|
||||
$this->allowassign = array_keys($this->get_allow_roles_list('assign', $roleid));
|
||||
}
|
||||
if ($options['allowoverride']) {
|
||||
$this->allowoverride = array_keys($this->get_allow_roles_list('override', $roleid));
|
||||
}
|
||||
if ($options['allowswitch']) {
|
||||
$this->allowswitch = array_keys($this->get_allow_roles_list('switch', $roleid));
|
||||
}
|
||||
|
||||
if ($options['permissions']) {
|
||||
$this->permissions = $DB->get_records_menu('role_capabilities',
|
||||
array('roleid' => $roleid, 'contextid' => context_system::instance()->id),
|
||||
'', 'capability,permission');
|
||||
|
||||
foreach ($this->capabilities as $capid => $cap) {
|
||||
if (!isset($this->permissions[$cap->name])) {
|
||||
$this->permissions[$cap->name] = CAP_INHERIT;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Change the role definition to match given archetype.
|
||||
*
|
||||
* @param string $archetype
|
||||
* @param array $options array with following keys:
|
||||
* 'name', 'shortname', 'description', 'permissions', 'archetype',
|
||||
* 'contextlevels', 'allowassign', 'allowoverride', 'allowswitch'
|
||||
*/
|
||||
public function force_archetype($archetype, array $options) {
|
||||
$archetypes = get_role_archetypes();
|
||||
if (!isset($archetypes[$archetype])) {
|
||||
throw new coding_exception('Unknown archetype: '.$archetype);
|
||||
}
|
||||
|
||||
if ($options['shortname']) {
|
||||
$this->role->shortname = '';
|
||||
}
|
||||
|
||||
if ($options['name']) {
|
||||
$this->role->name = '';
|
||||
}
|
||||
|
||||
if ($options['description']) {
|
||||
$this->role->description = '';
|
||||
}
|
||||
|
||||
if ($options['archetype']) {
|
||||
$this->role->archetype = $archetype;
|
||||
}
|
||||
|
||||
if ($options['contextlevels']) {
|
||||
$this->contextlevels = array();
|
||||
$defaults = get_default_contextlevels($archetype);
|
||||
foreach ($defaults as $cl) {
|
||||
$this->contextlevels[$cl] = $cl;
|
||||
}
|
||||
}
|
||||
|
||||
if ($options['allowassign']) {
|
||||
$this->allowassign = get_default_role_archetype_allows('assign', $archetype);
|
||||
}
|
||||
if ($options['allowoverride']) {
|
||||
$this->allowoverride = get_default_role_archetype_allows('override', $archetype);
|
||||
}
|
||||
if ($options['allowswitch']) {
|
||||
$this->allowswitch = get_default_role_archetype_allows('switch', $archetype);
|
||||
}
|
||||
|
||||
if ($options['permissions']) {
|
||||
$defaultpermissions = get_default_capabilities($archetype);
|
||||
foreach ($this->permissions as $k => $v) {
|
||||
if (isset($defaultpermissions[$k])) {
|
||||
$this->permissions[$k] = $defaultpermissions[$k];
|
||||
continue;
|
||||
}
|
||||
$this->permissions[$k] = CAP_INHERIT;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Change the role definition to match given preset.
|
||||
*
|
||||
* @param string $xml
|
||||
* @param array $options array with following keys:
|
||||
* 'name', 'shortname', 'description', 'permissions', 'archetype',
|
||||
* 'contextlevels', 'allowassign', 'allowoverride', 'allowswitch'
|
||||
*/
|
||||
public function force_preset($xml, array $options) {
|
||||
if (!$info = core_role_preset::parse_preset($xml)) {
|
||||
throw new coding_exception('Invalid role preset');
|
||||
}
|
||||
|
||||
if ($options['shortname']) {
|
||||
if (isset($info['shortname'])) {
|
||||
$this->role->shortname = $info['shortname'];
|
||||
}
|
||||
}
|
||||
|
||||
if ($options['name']) {
|
||||
if (isset($info['name'])) {
|
||||
$this->role->name = $info['name'];
|
||||
}
|
||||
}
|
||||
|
||||
if ($options['description']) {
|
||||
if (isset($info['description'])) {
|
||||
$this->role->description = $info['description'];
|
||||
}
|
||||
}
|
||||
|
||||
if ($options['archetype']) {
|
||||
if (isset($info['archetype'])) {
|
||||
$this->role->archetype = $info['archetype'];
|
||||
}
|
||||
}
|
||||
|
||||
if ($options['contextlevels']) {
|
||||
if (isset($info['contextlevels'])) {
|
||||
$this->contextlevels = $info['contextlevels'];
|
||||
}
|
||||
}
|
||||
|
||||
foreach (array('assign', 'override', 'switch') as $type) {
|
||||
if ($options['allow'.$type]) {
|
||||
if (isset($info['allow'.$type])) {
|
||||
$this->{'allow'.$type} = $info['allow'.$type];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($options['permissions']) {
|
||||
foreach ($this->permissions as $k => $v) {
|
||||
// Note: do not set everything else to CAP_INHERIT here
|
||||
// because the xml file might not contain all capabilities.
|
||||
if (isset($info['permissions'][$k])) {
|
||||
$this->permissions[$k] = $info['permissions'][$k];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function get_role_name() {
|
||||
return $this->role->name;
|
||||
}
|
||||
|
||||
public function get_role_id() {
|
||||
return $this->role->id;
|
||||
}
|
||||
|
||||
public function get_archetype() {
|
||||
return $this->role->archetype;
|
||||
}
|
||||
|
||||
protected function load_parent_permissions() {
|
||||
$this->parentpermissions = get_default_capabilities($this->role->archetype);
|
||||
}
|
||||
|
||||
public function save_changes() {
|
||||
global $DB;
|
||||
|
||||
if (!$this->roleid) {
|
||||
// Creating role.
|
||||
$this->role->id = create_role($this->role->name, $this->role->shortname, $this->role->description, $this->role->archetype);
|
||||
$this->roleid = $this->role->id; // Needed to make the parent::save_changes(); call work.
|
||||
} else {
|
||||
// Updating role.
|
||||
$DB->update_record('role', $this->role);
|
||||
}
|
||||
|
||||
// Assignable contexts.
|
||||
set_role_contextlevels($this->role->id, $this->contextlevels);
|
||||
|
||||
// Set allowed roles.
|
||||
$this->save_allow('assign');
|
||||
$this->save_allow('override');
|
||||
$this->save_allow('switch');
|
||||
|
||||
// Permissions.
|
||||
parent::save_changes();
|
||||
}
|
||||
|
||||
protected function save_allow($type) {
|
||||
global $DB;
|
||||
|
||||
$current = array_keys($this->get_allow_roles_list($type));
|
||||
$wanted = $this->{'allow'.$type};
|
||||
|
||||
$addfunction = 'allow_'.$type;
|
||||
$deltable = 'role_allow_'.$type;
|
||||
$field = 'allow'.$type;
|
||||
|
||||
foreach ($current as $roleid) {
|
||||
if (!in_array($roleid, $wanted)) {
|
||||
$DB->delete_records($deltable, array('roleid'=>$this->roleid, $field=>$roleid));
|
||||
continue;
|
||||
}
|
||||
$key = array_search($roleid, $wanted);
|
||||
unset($wanted[$key]);
|
||||
}
|
||||
|
||||
foreach ($wanted as $roleid) {
|
||||
if ($roleid == -1) {
|
||||
$roleid = $this->roleid;
|
||||
}
|
||||
$addfunction($this->roleid, $roleid);
|
||||
}
|
||||
}
|
||||
|
||||
protected function get_name_field($id) {
|
||||
return '<input type="text" id="' . $id . '" name="' . $id . '" maxlength="254" value="' . s($this->role->name) . '" />';
|
||||
}
|
||||
|
||||
protected function get_shortname_field($id) {
|
||||
return '<input type="text" id="' . $id . '" name="' . $id . '" maxlength="254" value="' . s($this->role->shortname) . '" />';
|
||||
}
|
||||
|
||||
protected function get_description_field($id) {
|
||||
return '<textarea class="form-textarea" id="'. s($id) .'" name="description" rows="10" cols="50">' .
|
||||
htmlspecialchars($this->role->description) .
|
||||
'</textarea>';
|
||||
}
|
||||
|
||||
protected function get_archetype_field($id) {
|
||||
$options = array();
|
||||
$options[''] = get_string('none');
|
||||
foreach (get_role_archetypes() as $type) {
|
||||
$options[$type] = get_string('archetype'.$type, 'role');
|
||||
}
|
||||
return html_writer::select($options, 'archetype', $this->role->archetype, false);
|
||||
}
|
||||
|
||||
protected function get_assignable_levels_control() {
|
||||
$output = '';
|
||||
foreach ($this->allcontextlevels as $cl => $clname) {
|
||||
$extraarguments = $this->disabled;
|
||||
if (in_array($cl, $this->contextlevels)) {
|
||||
$extraarguments .= 'checked="checked" ';
|
||||
}
|
||||
if (!$this->disabled) {
|
||||
$output .= '<input type="hidden" name="contextlevel' . $cl . '" value="0" />';
|
||||
}
|
||||
$output .= '<input type="checkbox" id="cl' . $cl . '" name="contextlevel' . $cl .
|
||||
'" value="1" ' . $extraarguments . '/> ';
|
||||
$output .= '<label for="cl' . $cl . '">' . $clname . "</label><br />\n";
|
||||
}
|
||||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array of roles of the allowed type.
|
||||
*
|
||||
* @param string $type Must be one of: assign, switch, or override.
|
||||
* @param int $roleid (null means current role)
|
||||
* @return array
|
||||
*/
|
||||
protected function get_allow_roles_list($type, $roleid = null) {
|
||||
global $DB;
|
||||
|
||||
if ($type !== 'assign' and $type !== 'switch' and $type !== 'override') {
|
||||
debugging('Invalid role allowed type specified', DEBUG_DEVELOPER);
|
||||
return array();
|
||||
}
|
||||
|
||||
if ($roleid === null) {
|
||||
$roleid = $this->roleid;
|
||||
}
|
||||
|
||||
if (empty($roleid)) {
|
||||
return array();
|
||||
}
|
||||
|
||||
$sql = "SELECT r.*
|
||||
FROM {role} r
|
||||
JOIN {role_allow_{$type}} a ON a.allow{$type} = r.id
|
||||
WHERE a.roleid = :roleid
|
||||
ORDER BY r.sortorder ASC";
|
||||
return $DB->get_records_sql($sql, array('roleid'=>$roleid));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array of roles with the allowed type.
|
||||
*
|
||||
* @param string $type Must be one of: assign, switch, or override.
|
||||
* @return array Am array of role names with the allowed type
|
||||
*/
|
||||
protected function get_allow_role_control($type) {
|
||||
if ($type !== 'assign' and $type !== 'switch' and $type !== 'override') {
|
||||
debugging('Invalid role allowed type specified', DEBUG_DEVELOPER);
|
||||
return '';
|
||||
}
|
||||
|
||||
$property = 'allow'.$type;
|
||||
$selected = $this->$property;
|
||||
|
||||
$options = array();
|
||||
foreach (role_get_names(null, ROLENAME_ALIAS) as $role) {
|
||||
$options[$role->id] = $role->localname;
|
||||
}
|
||||
if ($this->roleid == 0) {
|
||||
$options[-1] = get_string('thisnewrole', 'core_role');
|
||||
}
|
||||
return html_writer::select($options, 'allow'.$type.'[]', $selected, false, array('multiple'=>'multiple', 'size'=>10));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns information about the risks associated with a role.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function get_role_risks_info() {
|
||||
return '';
|
||||
}
|
||||
|
||||
protected function print_field($name, $caption, $field) {
|
||||
global $OUTPUT;
|
||||
// Attempt to generate HTML like formslib.
|
||||
echo '<div class="fitem">';
|
||||
echo '<div class="fitemtitle">';
|
||||
if ($name) {
|
||||
echo '<label for="' . $name . '">';
|
||||
}
|
||||
echo $caption;
|
||||
if ($name) {
|
||||
echo "</label>\n";
|
||||
}
|
||||
echo '</div>';
|
||||
if (isset($this->errors[$name])) {
|
||||
$extraclass = ' error';
|
||||
} else {
|
||||
$extraclass = '';
|
||||
}
|
||||
echo '<div class="felement' . $extraclass . '">';
|
||||
echo $field;
|
||||
if (isset($this->errors[$name])) {
|
||||
echo $OUTPUT->error_text($this->errors[$name]);
|
||||
}
|
||||
echo '</div>';
|
||||
echo '</div>';
|
||||
}
|
||||
|
||||
protected function print_show_hide_advanced_button() {
|
||||
echo '<p class="definenotice">' . get_string('highlightedcellsshowdefault', 'core_role') . ' </p>';
|
||||
echo '<div class="advancedbutton">';
|
||||
echo '<input type="submit" name="toggleadvanced" value="' . get_string('hideadvanced', 'form') . '" />';
|
||||
echo '</div>';
|
||||
}
|
||||
|
||||
public function display() {
|
||||
global $OUTPUT;
|
||||
// Extra fields at the top of the page.
|
||||
echo '<div class="topfields clearfix">';
|
||||
$this->print_field('shortname', get_string('roleshortname', 'core_role').' '.$OUTPUT->help_icon('roleshortname', 'core_role'), $this->get_shortname_field('shortname'));
|
||||
$this->print_field('name', get_string('customrolename', 'core_role').' '.$OUTPUT->help_icon('customrolename', 'core_role'), $this->get_name_field('name'));
|
||||
$this->print_field('edit-description', get_string('customroledescription', 'core_role').' '.$OUTPUT->help_icon('customroledescription', 'core_role'),
|
||||
$this->get_description_field('description'));
|
||||
$this->print_field('menuarchetype', get_string('archetype', 'core_role').' '.$OUTPUT->help_icon('archetype', 'core_role'), $this->get_archetype_field('archetype'));
|
||||
$this->print_field('', get_string('maybeassignedin', 'core_role'), $this->get_assignable_levels_control());
|
||||
$this->print_field('menuallowassign', get_string('allowassign', 'core_role'), $this->get_allow_role_control('assign'));
|
||||
$this->print_field('menuallowoverride', get_string('allowoverride', 'core_role'), $this->get_allow_role_control('override'));
|
||||
$this->print_field('menuallowswitch', get_string('allowswitch', 'core_role'), $this->get_allow_role_control('switch'));
|
||||
if ($risks = $this->get_role_risks_info()) {
|
||||
$this->print_field('', get_string('rolerisks', 'core_role'), $risks);
|
||||
}
|
||||
echo "</div>";
|
||||
|
||||
$this->print_show_hide_advanced_button();
|
||||
|
||||
// Now the permissions table.
|
||||
parent::display();
|
||||
}
|
||||
|
||||
protected function add_permission_cells($capability) {
|
||||
// One cell for each possible permission.
|
||||
foreach ($this->displaypermissions as $perm => $permname) {
|
||||
$strperm = $this->strperms[$permname];
|
||||
$extraclass = '';
|
||||
if ($perm == $this->parentpermissions[$capability->name]) {
|
||||
$extraclass = ' capdefault';
|
||||
}
|
||||
$checked = '';
|
||||
if ($this->permissions[$capability->name] == $perm) {
|
||||
$checked = 'checked="checked" ';
|
||||
}
|
||||
echo '<td class="' . $permname . $extraclass . '">';
|
||||
echo '<label><input type="radio" name="' . $capability->name .
|
||||
'" value="' . $perm . '" ' . $checked . '/> ';
|
||||
echo '<span class="note">' . $strperm . '</span>';
|
||||
echo '</label></td>';
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,63 +0,0 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Library code used by the roles administration interfaces.
|
||||
*
|
||||
* @package core_role
|
||||
* @copyright 1999 onwards Martin Dougiamas (http://dougiamas.com)
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
class core_role_define_role_table_basic extends core_role_define_role_table_advanced {
|
||||
protected $stradvmessage;
|
||||
protected $strallow;
|
||||
|
||||
public function __construct($context, $roleid) {
|
||||
parent::__construct($context, $roleid);
|
||||
$this->displaypermissions = array(CAP_ALLOW => $this->allpermissions[CAP_ALLOW]);
|
||||
$this->stradvmessage = get_string('useshowadvancedtochange', 'core_role');
|
||||
$this->strallow = $this->strperms[$this->allpermissions[CAP_ALLOW]];
|
||||
}
|
||||
|
||||
protected function print_show_hide_advanced_button() {
|
||||
echo '<div class="advancedbutton">';
|
||||
echo '<input type="submit" name="toggleadvanced" value="' . get_string('showadvanced', 'form') . '" />';
|
||||
echo '</div>';
|
||||
}
|
||||
|
||||
protected function add_permission_cells($capability) {
|
||||
$perm = $this->permissions[$capability->name];
|
||||
$permname = $this->allpermissions[$perm];
|
||||
$defaultperm = $this->allpermissions[$this->parentpermissions[$capability->name]];
|
||||
echo '<td class="' . $permname . '">';
|
||||
if ($perm == CAP_ALLOW || $perm == CAP_INHERIT) {
|
||||
$checked = '';
|
||||
if ($perm == CAP_ALLOW) {
|
||||
$checked = 'checked="checked" ';
|
||||
}
|
||||
echo '<input type="hidden" name="' . $capability->name . '" value="' . CAP_INHERIT . '" />';
|
||||
echo '<label><input type="checkbox" name="' . $capability->name .
|
||||
'" value="' . CAP_ALLOW . '" ' . $checked . '/> ' . $this->strallow . '</label>';
|
||||
} else {
|
||||
echo '<input type="hidden" name="' . $capability->name . '" value="' . $perm . '" />';
|
||||
echo $this->strperms[$permname] . '<span class="note">' . $this->stradvmessage . '</span>';
|
||||
}
|
||||
echo '</td>';
|
||||
}
|
||||
}
|
||||
@@ -1,153 +0,0 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Existing user selector.
|
||||
*
|
||||
* @package core_role
|
||||
* @copyright 1999 onwards Martin Dougiamas (http://dougiamas.com)
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
/**
|
||||
* User selector subclass for the list of users who already have the role in
|
||||
* question on the assign roles page.
|
||||
*/
|
||||
class core_role_existing_role_holders extends core_role_assign_user_selector_base {
|
||||
|
||||
public function find_users($search) {
|
||||
global $DB;
|
||||
|
||||
list($wherecondition, $params) = $this->search_sql($search, 'u');
|
||||
list($ctxcondition, $ctxparams) = $DB->get_in_or_equal($this->context->get_parent_context_ids(true), SQL_PARAMS_NAMED, 'ctx');
|
||||
$params = array_merge($params, $ctxparams);
|
||||
$params['roleid'] = $this->roleid;
|
||||
|
||||
list($sort, $sortparams) = users_order_by_sql('u', $search, $this->accesscontext);
|
||||
$params = array_merge($params, $sortparams);
|
||||
|
||||
$fields = "SELECT ra.id AS raid," . $this->required_fields_sql('u') . ",ra.contextid,ra.component ";
|
||||
$countfields = "SELECT COUNT(1) ";
|
||||
$sql = "FROM {role_assignments} ra
|
||||
JOIN {user} u ON u.id = ra.userid
|
||||
JOIN {context} ctx ON ra.contextid = ctx.id
|
||||
WHERE $wherecondition
|
||||
AND ctx.id $ctxcondition
|
||||
AND ra.roleid = :roleid";
|
||||
$order = " ORDER BY ctx.depth DESC, ra.component, $sort";
|
||||
|
||||
if (!$this->is_validating()) {
|
||||
$existinguserscount = $DB->count_records_sql($countfields . $sql, $params);
|
||||
if ($existinguserscount > $this->maxusersperpage) {
|
||||
return $this->too_many_results($search, $existinguserscount);
|
||||
}
|
||||
}
|
||||
|
||||
$contextusers = $DB->get_records_sql($fields . $sql . $order, $params);
|
||||
|
||||
// No users at all.
|
||||
if (empty($contextusers)) {
|
||||
return array();
|
||||
}
|
||||
|
||||
// We have users. Out put them in groups by context depth.
|
||||
// To help the loop below, tack a dummy user on the end of the results
|
||||
// array, to trigger output of the last group.
|
||||
$dummyuser = new stdClass;
|
||||
$dummyuser->contextid = 0;
|
||||
$dummyuser->id = 0;
|
||||
$dummyuser->component = '';
|
||||
$contextusers[] = $dummyuser;
|
||||
$results = array(); // The results array we are building up.
|
||||
$doneusers = array(); // Ensures we only list each user at most once.
|
||||
$currentcontextid = $this->context->id;
|
||||
$currentgroup = array();
|
||||
foreach ($contextusers as $user) {
|
||||
if (isset($doneusers[$user->id])) {
|
||||
continue;
|
||||
}
|
||||
$doneusers[$user->id] = 1;
|
||||
if ($user->contextid != $currentcontextid) {
|
||||
// We have got to the end of the previous group. Add it to the results array.
|
||||
if ($currentcontextid == $this->context->id) {
|
||||
$groupname = $this->this_con_group_name($search, count($currentgroup));
|
||||
} else {
|
||||
$groupname = $this->parent_con_group_name($search, $currentcontextid);
|
||||
}
|
||||
$results[$groupname] = $currentgroup;
|
||||
// Get ready for the next group.
|
||||
$currentcontextid = $user->contextid;
|
||||
$currentgroup = array();
|
||||
}
|
||||
// Add this user to the group we are building up.
|
||||
unset($user->contextid);
|
||||
if ($currentcontextid != $this->context->id) {
|
||||
$user->disabled = true;
|
||||
}
|
||||
if ($user->component !== '') {
|
||||
// Bad luck, you can tweak only manual role assignments.
|
||||
$user->disabled = true;
|
||||
}
|
||||
unset($user->component);
|
||||
$currentgroup[$user->id] = $user;
|
||||
}
|
||||
|
||||
return $results;
|
||||
}
|
||||
|
||||
protected function this_con_group_name($search, $numusers) {
|
||||
if ($this->context->contextlevel == CONTEXT_SYSTEM) {
|
||||
// Special case in the System context.
|
||||
if ($search) {
|
||||
return get_string('extusersmatching', 'core_role', $search);
|
||||
} else {
|
||||
return get_string('extusers', 'core_role');
|
||||
}
|
||||
}
|
||||
$contexttype = context_helper::get_level_name($this->context->contextlevel);
|
||||
if ($search) {
|
||||
$a = new stdClass;
|
||||
$a->search = $search;
|
||||
$a->contexttype = $contexttype;
|
||||
if ($numusers) {
|
||||
return get_string('usersinthisxmatching', 'core_role', $a);
|
||||
} else {
|
||||
return get_string('noneinthisxmatching', 'core_role', $a);
|
||||
}
|
||||
} else {
|
||||
if ($numusers) {
|
||||
return get_string('usersinthisx', 'core_role', $contexttype);
|
||||
} else {
|
||||
return get_string('noneinthisx', 'core_role', $contexttype);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected function parent_con_group_name($search, $contextid) {
|
||||
$context = context::instance_by_id($contextid);
|
||||
$contextname = $context->get_context_name(true, true);
|
||||
if ($search) {
|
||||
$a = new stdClass;
|
||||
$a->contextname = $contextname;
|
||||
$a->search = $search;
|
||||
return get_string('usersfrommatching', 'core_role', $a);
|
||||
} else {
|
||||
return get_string('usersfrom', 'core_role', $contextname);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,102 +0,0 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* override permissions table.
|
||||
*
|
||||
* @package core_role
|
||||
* @copyright 1999 onwards Martin Dougiamas (http://dougiamas.com)
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
class core_role_override_permissions_table_advanced extends core_role_capability_table_with_risks {
|
||||
protected $strnotset;
|
||||
protected $haslockedcapabilities = false;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* This method loads loads all the information about the current state of
|
||||
* the overrides, then updates that based on any submitted data. It also
|
||||
* works out which capabilities should be locked for this user.
|
||||
*
|
||||
* @param object $context the context this table relates to.
|
||||
* @param integer $roleid the role being overridden.
|
||||
* @param boolean $safeoverridesonly If true, the user is only allowed to override
|
||||
* capabilities with no risks.
|
||||
*/
|
||||
public function __construct($context, $roleid, $safeoverridesonly) {
|
||||
parent::__construct($context, 'overriderolestable', $roleid);
|
||||
$this->displaypermissions = $this->allpermissions;
|
||||
$this->strnotset = get_string('notset', 'core_role');
|
||||
|
||||
// Determine which capabilities should be locked.
|
||||
if ($safeoverridesonly) {
|
||||
foreach ($this->capabilities as $capid => $cap) {
|
||||
if (!is_safe_capability($cap)) {
|
||||
$this->capabilities[$capid]->locked = true;
|
||||
$this->haslockedcapabilities = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected function load_parent_permissions() {
|
||||
// Get the capabilities from the parent context, so that can be shown in the interface.
|
||||
$parentcontext = $this->context->get_parent_context();
|
||||
$this->parentpermissions = role_context_capabilities($this->roleid, $parentcontext);
|
||||
}
|
||||
|
||||
public function has_locked_capabilities() {
|
||||
return $this->haslockedcapabilities;
|
||||
}
|
||||
|
||||
protected function add_permission_cells($capability) {
|
||||
$disabled = '';
|
||||
if ($capability->locked || $this->parentpermissions[$capability->name] == CAP_PROHIBIT) {
|
||||
$disabled = ' disabled="disabled"';
|
||||
}
|
||||
|
||||
// One cell for each possible permission.
|
||||
foreach ($this->displaypermissions as $perm => $permname) {
|
||||
$strperm = $this->strperms[$permname];
|
||||
$extraclass = '';
|
||||
if ($perm != CAP_INHERIT && $perm == $this->parentpermissions[$capability->name]) {
|
||||
$extraclass = ' capcurrent';
|
||||
}
|
||||
$checked = '';
|
||||
if ($this->permissions[$capability->name] == $perm) {
|
||||
$checked = 'checked="checked" ';
|
||||
}
|
||||
echo '<td class="' . $permname . $extraclass . '">';
|
||||
echo '<label><input type="radio" name="' . $capability->name .
|
||||
'" value="' . $perm . '" ' . $checked . $disabled . '/> ';
|
||||
if ($perm == CAP_INHERIT) {
|
||||
$inherited = $this->parentpermissions[$capability->name];
|
||||
if ($inherited == CAP_INHERIT) {
|
||||
$inherited = $this->strnotset;
|
||||
} else {
|
||||
$inherited = $this->strperms[$this->allpermissions[$inherited]];
|
||||
}
|
||||
$strperm .= ' (' . $inherited . ')';
|
||||
}
|
||||
echo '<span class="note">' . $strperm . '</span>';
|
||||
echo '</label></td>';
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,66 +0,0 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Allow something form.
|
||||
*
|
||||
* @package core_role
|
||||
* @copyright 2009 Petr Skoda {@link http://skodak.org}
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
require_once("$CFG->libdir/formslib.php");
|
||||
|
||||
class core_role_permission_allow_form extends moodleform {
|
||||
|
||||
/**
|
||||
* Define the form.
|
||||
*/
|
||||
protected function definition() {
|
||||
global $CFG;
|
||||
|
||||
$mform = $this->_form;
|
||||
list($context, $capability, $overridableroles) = $this->_customdata;
|
||||
|
||||
list($needed, $forbidden) = get_roles_with_cap_in_context($context, $capability->name);
|
||||
foreach ($needed as $id => $unused) {
|
||||
unset($overridableroles[$id]);
|
||||
}
|
||||
foreach ($forbidden as $id => $unused) {
|
||||
unset($overridableroles[$id]);
|
||||
}
|
||||
|
||||
$mform->addElement('header', 'allowheader', get_string('roleallowheader', 'core_role'));
|
||||
|
||||
$mform->addElement('select', 'roleid', get_string('roleselect', 'core_role'), $overridableroles);
|
||||
|
||||
$mform->addElement('hidden', 'capability');
|
||||
$mform->setType('capability', PARAM_CAPABILITY);
|
||||
$mform->setDefault('capability', $capability->name);
|
||||
|
||||
$mform->addElement('hidden', 'contextid');
|
||||
$mform->setType('contextid', PARAM_INT);
|
||||
$mform->setDefault('contextid', $context->id);
|
||||
|
||||
$mform->addElement('hidden', 'allow');
|
||||
$mform->setType('allow', PARAM_INT);
|
||||
$mform->setDefault('allow', 1);
|
||||
|
||||
$this->add_action_buttons(true, get_string('allow', 'core_role'));
|
||||
}
|
||||
}
|
||||
@@ -1,64 +0,0 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Prohibit something form.
|
||||
*
|
||||
* @package core_role
|
||||
* @copyright 2009 Petr Skoda {@link http://skodak.org}
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
require_once("$CFG->libdir/formslib.php");
|
||||
|
||||
|
||||
class core_role_permission_prohibit_form extends moodleform {
|
||||
|
||||
/**
|
||||
* Define the form.
|
||||
*/
|
||||
protected function definition() {
|
||||
global $CFG;
|
||||
|
||||
$mform = $this->_form;
|
||||
list($context, $capability, $overridableroles) = $this->_customdata;
|
||||
|
||||
list($needed, $forbidden) = get_roles_with_cap_in_context($context, $capability->name);
|
||||
foreach ($forbidden as $id => $unused) {
|
||||
unset($overridableroles[$id]);
|
||||
}
|
||||
|
||||
$mform->addElement('header', 'ptohibitheader', get_string('roleprohibitheader', 'core_role'));
|
||||
|
||||
$mform->addElement('select', 'roleid', get_string('roleselect', 'core_role'), $overridableroles);
|
||||
|
||||
$mform->addElement('hidden', 'capability');
|
||||
$mform->setType('capability', PARAM_CAPABILITY);
|
||||
$mform->setDefault('capability', $capability->name);
|
||||
|
||||
$mform->addElement('hidden', 'contextid');
|
||||
$mform->setType('contextid', PARAM_INT);
|
||||
$mform->setDefault('contextid', $context->id);
|
||||
|
||||
$mform->addElement('hidden', 'prohibit');
|
||||
$mform->setType('prohibit', PARAM_INT);
|
||||
$mform->setDefault('prohibit', 1);
|
||||
|
||||
$this->add_action_buttons(true, get_string('prohibit', 'core_role'));
|
||||
}
|
||||
}
|
||||
@@ -1,150 +0,0 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Library code used by the roles administration interfaces.
|
||||
*
|
||||
* @package core_role
|
||||
* @copyright 2009 Petr Skoda {@link http://skodak.org}
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
/**
|
||||
* Subclass of core_role_capability_table_base for use on the Permissions page.
|
||||
*/
|
||||
class core_role_permissions_table extends core_role_capability_table_base {
|
||||
protected $contextname;
|
||||
protected $allowoverrides;
|
||||
protected $allowsafeoverrides;
|
||||
protected $overridableroles;
|
||||
protected $roles;
|
||||
protected $icons = array();
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
* @param context $context the context this table relates to.
|
||||
* @param string $contextname $context->get_context_name() - to save recomputing.
|
||||
* @param array $allowoverrides
|
||||
* @param array $allowsafeoverrides
|
||||
* @param array $overridableroles
|
||||
*/
|
||||
public function __construct($context, $contextname, $allowoverrides, $allowsafeoverrides, $overridableroles) {
|
||||
parent::__construct($context, 'permissions');
|
||||
$this->contextname = $contextname;
|
||||
$this->allowoverrides = $allowoverrides;
|
||||
$this->allowsafeoverrides = $allowsafeoverrides;
|
||||
$this->overridableroles = $overridableroles;
|
||||
|
||||
$roles = get_all_roles($context);
|
||||
$this->roles = role_fix_names(array_reverse($roles, true), $context, ROLENAME_ALIAS, true);
|
||||
|
||||
}
|
||||
|
||||
protected function add_header_cells() {
|
||||
echo '<th>' . get_string('risks', 'core_role') . '</th>';
|
||||
echo '<th>' . get_string('neededroles', 'core_role') . '</th>';
|
||||
echo '<th>' . get_string('prohibitedroles', 'core_role') . '</th>';
|
||||
}
|
||||
|
||||
protected function num_extra_columns() {
|
||||
return 3;
|
||||
}
|
||||
|
||||
protected function add_row_cells($capability) {
|
||||
global $OUTPUT, $PAGE;
|
||||
|
||||
$context = $this->context;
|
||||
$contextid = $this->context->id;
|
||||
$allowoverrides = $this->allowoverrides;
|
||||
$allowsafeoverrides = $this->allowsafeoverrides;
|
||||
$overridableroles = $this->overridableroles;
|
||||
$roles = $this->roles;
|
||||
|
||||
|
||||
list($needed, $forbidden) = get_roles_with_cap_in_context($context, $capability->name);
|
||||
$neededroles = array();
|
||||
$forbiddenroles = array();
|
||||
$allowable = $overridableroles;
|
||||
$forbitable = $overridableroles;
|
||||
foreach ($neededroles as $id => $unused) {
|
||||
unset($allowable[$id]);
|
||||
}
|
||||
foreach ($forbidden as $id => $unused) {
|
||||
unset($allowable[$id]);
|
||||
unset($forbitable[$id]);
|
||||
}
|
||||
|
||||
foreach ($roles as $id => $name) {
|
||||
if (isset($needed[$id])) {
|
||||
$neededroles[$id] = $roles[$id];
|
||||
if (isset($overridableroles[$id]) and ($allowoverrides or ($allowsafeoverrides and is_safe_capability($capability)))) {
|
||||
$preventurl = new moodle_url($PAGE->url, array('contextid'=>$contextid, 'roleid'=>$id, 'capability'=>$capability->name, 'prevent'=>1));
|
||||
$neededroles[$id] .= $OUTPUT->action_icon($preventurl, new pix_icon('t/delete', get_string('prevent', 'core_role')));
|
||||
}
|
||||
}
|
||||
}
|
||||
$neededroles = implode(', ', $neededroles);
|
||||
foreach ($roles as $id => $name) {
|
||||
if (isset($forbidden[$id]) and ($allowoverrides or ($allowsafeoverrides and is_safe_capability($capability)))) {
|
||||
$forbiddenroles[$id] = $roles[$id];
|
||||
if (isset($overridableroles[$id]) and prohibit_is_removable($id, $context, $capability->name)) {
|
||||
$unprohibiturl = new moodle_url($PAGE->url, array('contextid'=>$contextid, 'roleid'=>$id, 'capability'=>$capability->name, 'unprohibit'=>1));
|
||||
$forbiddenroles[$id] .= $OUTPUT->action_icon($unprohibiturl, new pix_icon('t/delete', get_string('delete')));
|
||||
}
|
||||
}
|
||||
}
|
||||
$forbiddenroles = implode(', ', $forbiddenroles);
|
||||
|
||||
if ($allowable and ($allowoverrides or ($allowsafeoverrides and is_safe_capability($capability)))) {
|
||||
$allowurl = new moodle_url($PAGE->url, array('contextid'=>$contextid, 'capability'=>$capability->name, 'allow'=>1));
|
||||
$neededroles .= '<div class="allowmore">'.$OUTPUT->action_icon($allowurl, new pix_icon('t/add', get_string('allow', 'core_role'))).'</div>';
|
||||
}
|
||||
|
||||
if ($forbitable and ($allowoverrides or ($allowsafeoverrides and is_safe_capability($capability)))) {
|
||||
$prohibiturl = new moodle_url($PAGE->url, array('contextid'=>$contextid, 'capability'=>$capability->name, 'prohibit'=>1));
|
||||
$forbiddenroles .= '<div class="prohibitmore">'.$OUTPUT->action_icon($prohibiturl, new pix_icon('t/add', get_string('prohibit', 'core_role'))).'</div>';
|
||||
}
|
||||
|
||||
$risks = $this->get_risks($capability);
|
||||
|
||||
echo '<td>' . $risks . '</td>';
|
||||
echo '<td>' . $neededroles . '</td>';
|
||||
echo '<td>' . $forbiddenroles . '</td>';
|
||||
}
|
||||
|
||||
protected function get_risks($capability) {
|
||||
global $OUTPUT;
|
||||
|
||||
$allrisks = get_all_risks();
|
||||
$risksurl = new moodle_url(get_docs_url(s(get_string('risks', 'core_role'))));
|
||||
|
||||
$return = '';
|
||||
|
||||
foreach ($allrisks as $type => $risk) {
|
||||
if ($risk & (int)$capability->riskbitmask) {
|
||||
if (!isset($this->icons[$type])) {
|
||||
$pixicon = new pix_icon('/i/' . str_replace('risk', 'risk_', $type), get_string($type . 'short', 'admin'));
|
||||
$this->icons[$type] = $OUTPUT->action_icon($risksurl, $pixicon, new popup_action('click', $risksurl));
|
||||
}
|
||||
$return .= $this->icons[$type];
|
||||
}
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
}
|
||||
@@ -1,86 +0,0 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Library code used by the roles administration interfaces.
|
||||
*
|
||||
* @package core_role
|
||||
* @copyright 1999 onwards Martin Dougiamas (http://dougiamas.com)
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
/**
|
||||
* User selector subclass for the list of potential users on the assign roles page,
|
||||
* when we are assigning in a context below the course level. (CONTEXT_MODULE and
|
||||
* some CONTEXT_BLOCK).
|
||||
*
|
||||
* This returns only enrolled users in this context.
|
||||
*/
|
||||
class core_role_potential_assignees_below_course extends core_role_assign_user_selector_base {
|
||||
public function find_users($search) {
|
||||
global $DB;
|
||||
|
||||
list($enrolsql, $eparams) = get_enrolled_sql($this->context);
|
||||
|
||||
// Now we have to go to the database.
|
||||
list($wherecondition, $params) = $this->search_sql($search, 'u');
|
||||
$params = array_merge($params, $eparams);
|
||||
|
||||
if ($wherecondition) {
|
||||
$wherecondition = ' AND ' . $wherecondition;
|
||||
}
|
||||
|
||||
$fields = 'SELECT ' . $this->required_fields_sql('u');
|
||||
$countfields = 'SELECT COUNT(u.id)';
|
||||
|
||||
$sql = " FROM ($enrolsql) enrolled_users_view
|
||||
JOIN {user} u ON u.id = enrolled_users_view.id
|
||||
LEFT JOIN {role_assignments} ra ON (ra.userid = enrolled_users_view.id AND
|
||||
ra.roleid = :roleid AND ra.contextid = :contextid)
|
||||
WHERE ra.id IS NULL
|
||||
$wherecondition";
|
||||
$params['contextid'] = $this->context->id;
|
||||
$params['roleid'] = $this->roleid;
|
||||
|
||||
list($sort, $sortparams) = users_order_by_sql('u', $search, $this->accesscontext);
|
||||
$order = ' ORDER BY ' . $sort;
|
||||
|
||||
// Check to see if there are too many to show sensibly.
|
||||
if (!$this->is_validating()) {
|
||||
$potentialmemberscount = $DB->count_records_sql($countfields . $sql, $params);
|
||||
if ($potentialmemberscount > $this->maxusersperpage) {
|
||||
return $this->too_many_results($search, $potentialmemberscount);
|
||||
}
|
||||
}
|
||||
|
||||
// If not, show them.
|
||||
$availableusers = $DB->get_records_sql($fields . $sql . $order, array_merge($params, $sortparams));
|
||||
|
||||
if (empty($availableusers)) {
|
||||
return array();
|
||||
}
|
||||
|
||||
if ($search) {
|
||||
$groupname = get_string('potusersmatching', 'core_role', $search);
|
||||
} else {
|
||||
$groupname = get_string('potusers', 'core_role');
|
||||
}
|
||||
|
||||
return array($groupname => $availableusers);
|
||||
}
|
||||
}
|
||||
@@ -1,76 +0,0 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Library code used by the roles administration interfaces.
|
||||
*
|
||||
* @package core_role
|
||||
* @copyright 1999 onwards Martin Dougiamas (http://dougiamas.com)
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
/**
|
||||
* User selector subclass for the list of potential users on the assign roles page,
|
||||
* when we are assigning in a context at or above the course level. In this case we
|
||||
* show all the users in the system who do not already have the role.
|
||||
*/
|
||||
class core_role_potential_assignees_course_and_above extends core_role_assign_user_selector_base {
|
||||
public function find_users($search) {
|
||||
global $DB;
|
||||
|
||||
list($wherecondition, $params) = $this->search_sql($search, '');
|
||||
|
||||
$fields = 'SELECT ' . $this->required_fields_sql('');
|
||||
$countfields = 'SELECT COUNT(1)';
|
||||
|
||||
$sql = " FROM {user}
|
||||
WHERE $wherecondition
|
||||
AND id NOT IN (
|
||||
SELECT r.userid
|
||||
FROM {role_assignments} r
|
||||
WHERE r.contextid = :contextid
|
||||
AND r.roleid = :roleid)";
|
||||
|
||||
list($sort, $sortparams) = users_order_by_sql('', $search, $this->accesscontext);
|
||||
$order = ' ORDER BY ' . $sort;
|
||||
|
||||
$params['contextid'] = $this->context->id;
|
||||
$params['roleid'] = $this->roleid;
|
||||
|
||||
if (!$this->is_validating()) {
|
||||
$potentialmemberscount = $DB->count_records_sql($countfields . $sql, $params);
|
||||
if ($potentialmemberscount > $this->maxusersperpage) {
|
||||
return $this->too_many_results($search, $potentialmemberscount);
|
||||
}
|
||||
}
|
||||
|
||||
$availableusers = $DB->get_records_sql($fields . $sql . $order, array_merge($params, $sortparams));
|
||||
|
||||
if (empty($availableusers)) {
|
||||
return array();
|
||||
}
|
||||
|
||||
if ($search) {
|
||||
$groupname = get_string('potusersmatching', 'core_role', $search);
|
||||
} else {
|
||||
$groupname = get_string('potusers', 'core_role');
|
||||
}
|
||||
|
||||
return array($groupname => $availableusers);
|
||||
}
|
||||
}
|
||||
@@ -1,314 +0,0 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* New role XML processing.
|
||||
*
|
||||
* @package core_role
|
||||
* @copyright 2013 Petr Skoda {@link http://skodak.org}
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
/**
|
||||
* XML role file manipulation class.
|
||||
*
|
||||
* @package core_role
|
||||
* @copyright 2013 Petr Skoda {@link http://skodak.org}
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class core_role_preset {
|
||||
|
||||
/**
|
||||
* Send role export xml file to browser.
|
||||
*
|
||||
* @param int $roleid
|
||||
* @return void does not return, send the file to output
|
||||
*/
|
||||
public static function send_export_xml($roleid) {
|
||||
global $CFG, $DB;
|
||||
require_once($CFG->libdir . '/filelib.php');
|
||||
|
||||
$role = $DB->get_record('role', array('id'=>$roleid), '*', MUST_EXIST);
|
||||
|
||||
if ($role->shortname) {
|
||||
$filename = $role->shortname.'.xml';
|
||||
} else {
|
||||
$filename = 'role.xml';
|
||||
}
|
||||
$xml = self::get_export_xml($roleid);
|
||||
send_file($xml, $filename, 0, false, true, true);
|
||||
die();
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate role export xml file.
|
||||
*
|
||||
* @param $roleid
|
||||
* @return string
|
||||
*/
|
||||
public static function get_export_xml($roleid) {
|
||||
global $DB;
|
||||
|
||||
$role = $DB->get_record('role', array('id'=>$roleid), '*', MUST_EXIST);
|
||||
|
||||
$dom = new DOMDocument('1.0', 'UTF-8');
|
||||
$top = $dom->createElement('role');
|
||||
$dom->appendChild($top);
|
||||
|
||||
$top->appendChild($dom->createElement('shortname', $role->shortname));
|
||||
$top->appendChild($dom->createElement('name', $role->name));
|
||||
$top->appendChild($dom->createElement('description', $role->description));
|
||||
$top->appendChild($dom->createElement('archetype', $role->archetype));
|
||||
|
||||
$contextlevels = $dom->createElement('contextlevels');
|
||||
$top->appendChild($contextlevels);
|
||||
foreach (get_role_contextlevels($roleid) as $level) {
|
||||
$name = context_helper::get_class_for_level($level);
|
||||
$name = preg_replace('/^context_/', '', $name);
|
||||
$contextlevels->appendChild($dom->createElement('level', $name));
|
||||
}
|
||||
|
||||
foreach (array('assign', 'override', 'switch') as $type) {
|
||||
$allows = $dom->createElement('allow'.$type);
|
||||
$top->appendChild($allows);
|
||||
$records = $DB->get_records('role_allow_'.$type, array('roleid'=>$roleid), "allow$type ASC");
|
||||
foreach ($records as $record) {
|
||||
if (!$ar = $DB->get_record('role', array('id'=>$record->{'allow'.$type}))) {
|
||||
continue;
|
||||
}
|
||||
$allows->appendChild($dom->createElement('shortname', $ar->shortname));
|
||||
}
|
||||
}
|
||||
|
||||
$permissions = $dom->createElement('permissions');
|
||||
$top->appendChild($permissions);
|
||||
|
||||
$capabilities = $DB->get_records_sql_menu(
|
||||
"SELECT capability, permission
|
||||
FROM {role_capabilities}
|
||||
WHERE contextid = :syscontext AND roleid = :roleid
|
||||
ORDER BY capability ASC",
|
||||
array('syscontext'=>context_system::instance()->id, 'roleid'=>$roleid));
|
||||
|
||||
$allcapabilities = $DB->get_records('capabilities', array(), 'name ASC');
|
||||
foreach ($allcapabilities as $cap) {
|
||||
if (!isset($capabilities[$cap->name])) {
|
||||
$permissions->appendChild($dom->createElement('inherit', $cap->name));
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($capabilities as $capability => $permission) {
|
||||
if ($permission == CAP_ALLOW) {
|
||||
$permissions->appendChild($dom->createElement('allow', $capability));
|
||||
}
|
||||
}
|
||||
foreach ($capabilities as $capability => $permission) {
|
||||
if ($permission == CAP_PREVENT) {
|
||||
$permissions->appendChild($dom->createElement('prevent', $capability));
|
||||
}
|
||||
}
|
||||
foreach ($capabilities as $capability => $permission) {
|
||||
if ($permission == CAP_PROHIBIT) {
|
||||
$permissions->appendChild($dom->createElement('prohibit', $capability));
|
||||
}
|
||||
}
|
||||
|
||||
return $dom->saveXML();
|
||||
}
|
||||
|
||||
/**
|
||||
* Is this XML valid role preset?
|
||||
*
|
||||
* @param string $xml
|
||||
* @return bool
|
||||
*/
|
||||
public static function is_valid_preset($xml) {
|
||||
$dom = new DOMDocument();
|
||||
if (!$dom->loadXML($xml)) {
|
||||
return false;
|
||||
} else {
|
||||
$val = @$dom->schemaValidate(__DIR__.'/../role_schema.xml');
|
||||
if (!$val) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse role preset xml file.
|
||||
*
|
||||
* @param string $xml
|
||||
* @return array role info, null on error
|
||||
*/
|
||||
public static function parse_preset($xml) {
|
||||
global $DB;
|
||||
|
||||
$info = array();
|
||||
|
||||
if (!self::is_valid_preset($xml)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$dom = new DOMDocument();
|
||||
$dom->loadXML($xml);
|
||||
|
||||
$info['shortname'] = self::get_node_value($dom, '/role/shortname');
|
||||
if (isset($info['shortname'])) {
|
||||
$info['shortname'] = strtolower(clean_param($info['shortname'], PARAM_ALPHANUMEXT));
|
||||
}
|
||||
|
||||
$info['name'] = self::get_node_value($dom, '/role/name');
|
||||
if (isset($value)) {
|
||||
$info['name'] = clean_param($info['name'], PARAM_TEXT);
|
||||
}
|
||||
|
||||
$info['description'] = self::get_node_value($dom, '/role/description');
|
||||
if (isset($value)) {
|
||||
$info['description'] = clean_param($info['description'], PARAM_CLEANHTML);
|
||||
}
|
||||
|
||||
$info['archetype'] = self::get_node_value($dom, '/role/archetype');
|
||||
if (isset($value)) {
|
||||
$archetypes = get_role_archetypes();
|
||||
if (!isset($archetypes[$info['archetype']])) {
|
||||
$info['archetype'] = null;
|
||||
}
|
||||
}
|
||||
|
||||
$values = self::get_node_children_values($dom, '/role/contextlevels', 'level');
|
||||
if (isset($values)) {
|
||||
$info['contextlevels'] = array();
|
||||
$levelmap = array_flip(context_helper::get_all_levels());
|
||||
foreach ($values as $value) {
|
||||
$level = 'context_'.$value;
|
||||
if (isset($levelmap[$level])) {
|
||||
$cl = $levelmap[$level];
|
||||
$info['contextlevels'][$cl] = $cl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach (array('assign', 'override', 'switch') as $type) {
|
||||
$values = self::get_node_children_values($dom, '/role/allow'.$type, 'shortname');
|
||||
if (!isset($values)) {
|
||||
$info['allow'.$type] = null;
|
||||
continue;
|
||||
}
|
||||
$info['allow'.$type] = array();
|
||||
foreach ($values as $value) {
|
||||
if ($value === $info['shortname']) {
|
||||
array_unshift($info['allow'.$type], -1); // Means self.
|
||||
}
|
||||
if ($role = $DB->get_record('role', array('shortname'=>$value))) {
|
||||
$info['allow'.$type][] = $role->id;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$info['permissions'] = array();
|
||||
$values = self::get_node_children_values($dom, '/role/permissions', 'inherit');
|
||||
if (isset($values)) {
|
||||
foreach ($values as $value) {
|
||||
if ($value = clean_param($value, PARAM_CAPABILITY)) {
|
||||
$info['permissions'][$value] = CAP_INHERIT;
|
||||
}
|
||||
}
|
||||
}
|
||||
$values = self::get_node_children_values($dom, '/role/permissions', 'allow');
|
||||
if (isset($values)) {
|
||||
foreach ($values as $value) {
|
||||
if ($value = clean_param($value, PARAM_CAPABILITY)) {
|
||||
$info['permissions'][$value] = CAP_ALLOW;
|
||||
}
|
||||
}
|
||||
}
|
||||
$values = self::get_node_children_values($dom, '/role/permissions', 'prevent');
|
||||
if (isset($values)) {
|
||||
foreach ($values as $value) {
|
||||
if ($value = clean_param($value, PARAM_CAPABILITY)) {
|
||||
$info['permissions'][$value] = CAP_PREVENT;
|
||||
}
|
||||
}
|
||||
}
|
||||
$values = self::get_node_children_values($dom, '/role/permissions', 'prohibit');
|
||||
if (isset($values)) {
|
||||
foreach ($values as $value) {
|
||||
if ($value = clean_param($value, PARAM_CAPABILITY)) {
|
||||
$info['permissions'][$value] = CAP_PROHIBIT;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $info;
|
||||
}
|
||||
|
||||
protected static function get_node(DOMDocument $dom, $path) {
|
||||
$parts = explode('/', $path);
|
||||
$elname = end($parts);
|
||||
|
||||
$nodes = $dom->getElementsByTagName($elname);
|
||||
|
||||
if ($nodes->length == 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
foreach ($nodes as $node) {
|
||||
if ($node->getNodePath() === $path) {
|
||||
return $node;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
protected static function get_node_value(DOMDocument $dom, $path) {
|
||||
if (!$node = self::get_node($dom, $path)) {
|
||||
return null;
|
||||
}
|
||||
return $node->nodeValue;
|
||||
}
|
||||
|
||||
protected static function get_node_children(DOMDocument $dom, $path, $tagname) {
|
||||
if (!$node = self::get_node($dom, $path)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$return = array();
|
||||
foreach ($node->childNodes as $child) {
|
||||
if ($child->nodeName === $tagname) {
|
||||
$return[] = $child;
|
||||
}
|
||||
}
|
||||
return $return;
|
||||
}
|
||||
|
||||
protected static function get_node_children_values(DOMDocument $dom, $path, $tagname) {
|
||||
$children = self::get_node_children($dom, $path, $tagname);
|
||||
|
||||
if ($children === null) {
|
||||
return null;
|
||||
}
|
||||
$return = array();
|
||||
foreach ($children as $child) {
|
||||
$return[] = $child->nodeValue;
|
||||
}
|
||||
return $return;
|
||||
}
|
||||
}
|
||||
@@ -1,120 +0,0 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Role add/reset selection form.
|
||||
*
|
||||
* @package core_role
|
||||
* @copyright 2013 Petr Skoda {@link http://skodak.org}
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
require_once("$CFG->libdir/formslib.php");
|
||||
|
||||
|
||||
/**
|
||||
* Role add/reset selection form.
|
||||
*
|
||||
* @package core_role
|
||||
* @copyright 2013 Petr Skoda {@link http://skodak.org}
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class core_role_preset_form extends moodleform {
|
||||
|
||||
/**
|
||||
* Definition of this form.
|
||||
*/
|
||||
protected function definition() {
|
||||
$mform = $this->_form;
|
||||
|
||||
$data = $this->_customdata;
|
||||
$options = array();
|
||||
|
||||
$group = get_string('other');
|
||||
$options[$group] = array();
|
||||
$options[$group][0] = get_string('norole', 'core_role');
|
||||
|
||||
$group = get_string('role', 'core');
|
||||
$options[$group] = array();
|
||||
foreach (role_get_names(null, ROLENAME_BOTH) as $role) {
|
||||
// Allow reset to self too, it may be useful when importing incomplete XML preset.
|
||||
$options[$group][$role->id] = $role->localname;
|
||||
}
|
||||
|
||||
$group = get_string('archetype', 'core_role');
|
||||
$options[$group] = array();
|
||||
foreach (get_role_archetypes() as $type) {
|
||||
$options[$group][$type] = get_string('archetype'.$type, 'core_role');
|
||||
}
|
||||
|
||||
$mform->addElement('header', 'presetheader', get_string('roleresetdefaults', 'core_role'));
|
||||
|
||||
$mform->addElement('selectgroups', 'resettype', get_string('roleresetrole', 'core_role'), $options);
|
||||
|
||||
$mform->addElement('filepicker', 'rolepreset', get_string('rolerepreset', 'core_role'));
|
||||
|
||||
if ($data['roleid']) {
|
||||
$mform->addElement('header', 'resetheader', get_string('resetrole', 'core_role'));
|
||||
|
||||
$mform->addElement('advcheckbox', 'shortname', get_string('roleshortname', 'core_role'));
|
||||
$mform->addElement('advcheckbox', 'name', get_string('customrolename', 'core_role'));
|
||||
$mform->addElement('advcheckbox', 'description', get_string('customroledescription', 'core_role'));
|
||||
$mform->addElement('advcheckbox', 'archetype', get_string('archetype', 'core_role'));
|
||||
$mform->addElement('advcheckbox', 'contextlevels', get_string('maybeassignedin', 'core_role'));
|
||||
$mform->addElement('advcheckbox', 'allowassign', get_string('allowassign', 'core_role'));
|
||||
$mform->addElement('advcheckbox', 'allowoverride', get_string('allowoverride', 'core_role'));
|
||||
$mform->addElement('advcheckbox', 'allowswitch', get_string('allowswitch', 'core_role'));
|
||||
$mform->addElement('advcheckbox', 'permissions', get_string('permissions', 'core_role'));
|
||||
}
|
||||
|
||||
$mform->addElement('hidden', 'roleid');
|
||||
$mform->setType('roleid', PARAM_INT);
|
||||
|
||||
$mform->addElement('hidden', 'action');
|
||||
$mform->setType('action', PARAM_ALPHA);
|
||||
|
||||
$mform->addElement('hidden', 'return');
|
||||
$mform->setType('return', PARAM_ALPHA);
|
||||
|
||||
$this->add_action_buttons(true, get_string('continue', 'core'));
|
||||
|
||||
$this->set_data($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate this form.
|
||||
*
|
||||
* @param array $data submitted data
|
||||
* @param array $files not used
|
||||
* @return array errors
|
||||
*/
|
||||
public function validation($data, $files) {
|
||||
$errors = parent::validation($data, $files);
|
||||
|
||||
if ($files = $this->get_draft_files('rolepreset')) {
|
||||
/** @var stored_file $file */
|
||||
$file = reset($files);
|
||||
$xml = $file->get_content();
|
||||
if (!core_role_preset::is_valid_preset($xml)) {
|
||||
$errors['rolepreset'] = get_string('invalidpresetfile', 'core_role');
|
||||
}
|
||||
}
|
||||
|
||||
return $errors;
|
||||
}
|
||||
}
|
||||
@@ -1,136 +0,0 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Library code used by the roles administration interfaces.
|
||||
*
|
||||
* @package core_role
|
||||
* @copyright 1999 onwards Martin Dougiamas (http://dougiamas.com)
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
class core_role_view_role_definition_table extends core_role_define_role_table_advanced {
|
||||
public function __construct($context, $roleid) {
|
||||
parent::__construct($context, $roleid);
|
||||
$this->displaypermissions = array(CAP_ALLOW => $this->allpermissions[CAP_ALLOW]);
|
||||
$this->disabled = 'disabled="disabled" ';
|
||||
}
|
||||
|
||||
public function save_changes() {
|
||||
throw new moodle_exception('invalidaccess');
|
||||
}
|
||||
|
||||
protected function get_name_field($id) {
|
||||
return role_get_name($this->role);
|
||||
}
|
||||
|
||||
protected function get_shortname_field($id) {
|
||||
return $this->role->shortname;
|
||||
}
|
||||
|
||||
protected function get_description_field($id) {
|
||||
return role_get_description($this->role);
|
||||
}
|
||||
|
||||
protected function get_archetype_field($id) {
|
||||
if (empty($this->role->archetype)) {
|
||||
return get_string('none');
|
||||
} else {
|
||||
return get_string('archetype'.$this->role->archetype, 'core_role');
|
||||
}
|
||||
}
|
||||
|
||||
protected function get_allow_role_control($type) {
|
||||
if ($roles = $this->get_allow_roles_list($type)) {
|
||||
$roles = role_fix_names($roles, null, ROLENAME_ORIGINAL, true);
|
||||
return implode(', ', $roles);
|
||||
} else {
|
||||
return get_string('none');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected function print_show_hide_advanced_button() {
|
||||
// Do nothing.
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns HTML risk icons.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function get_role_risks_info() {
|
||||
global $OUTPUT;
|
||||
|
||||
if (empty($this->roleid)) {
|
||||
return '';
|
||||
}
|
||||
|
||||
$risks = array();
|
||||
$allrisks = get_all_risks();
|
||||
foreach ($this->capabilities as $capability) {
|
||||
$perm = $this->permissions[$capability->name];
|
||||
if ($perm != CAP_ALLOW) {
|
||||
continue;
|
||||
}
|
||||
foreach ($allrisks as $type => $risk) {
|
||||
if ($risk & (int)$capability->riskbitmask) {
|
||||
$risks[$type] = $risk;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$risksurl = new moodle_url(get_docs_url(s(get_string('risks', 'core_role'))));
|
||||
foreach ($risks as $type => $risk) {
|
||||
$pixicon = new pix_icon('/i/' . str_replace('risk', 'risk_', $type), get_string($type . 'short', 'admin'));
|
||||
$risks[$type] = $OUTPUT->action_icon($risksurl, $pixicon, new popup_action('click', $risksurl));
|
||||
}
|
||||
|
||||
return implode(' ', $risks);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the row should be skipped.
|
||||
*
|
||||
* @param string $capability
|
||||
* @return bool
|
||||
*/
|
||||
protected function skip_row($capability) {
|
||||
$perm = $this->permissions[$capability->name];
|
||||
if ($perm == CAP_INHERIT) {
|
||||
// Do not print empty rows in role overview, admins need to know quickly what is allowed and prohibited,
|
||||
// if they want to see the list of all capabilities they can go to edit role page.
|
||||
return true;
|
||||
}
|
||||
parent::skip_row($capability);
|
||||
}
|
||||
|
||||
protected function add_permission_cells($capability) {
|
||||
$perm = $this->permissions[$capability->name];
|
||||
$permname = $this->allpermissions[$perm];
|
||||
$defaultperm = $this->allpermissions[$this->parentpermissions[$capability->name]];
|
||||
if ($permname != $defaultperm) {
|
||||
$default = get_string('defaultx', 'core_role', $this->strperms[$defaultperm]);
|
||||
} else {
|
||||
$default = " ";
|
||||
}
|
||||
echo '<td class="' . $permname . '">' . $this->strperms[$permname] . '<span class="note">' .
|
||||
$default . '</span></td>';
|
||||
|
||||
}
|
||||
}
|
||||
+122
-228
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
@@ -18,271 +19,164 @@
|
||||
* Lets the user edit role definitions.
|
||||
*
|
||||
* Responds to actions:
|
||||
* add - add a new role (allows import, duplicate, archetype)
|
||||
* export - save xml role definition
|
||||
* add - add a new role
|
||||
* duplicate - like add, only initialise the new role by using an existing one.
|
||||
* edit - edit the definition of a role
|
||||
* view - view the definition of a role
|
||||
*
|
||||
* @package core_role
|
||||
* @package core
|
||||
* @subpackage role
|
||||
* @copyright 1999 onwards Martin Dougiamas (http://dougiamas.com)
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
require_once(dirname(__FILE__) . '/../../config.php');
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
|
||||
$action = required_param('action', PARAM_ALPHA);
|
||||
if (!in_array($action, array('add', 'export', 'edit', 'reset', 'view'))) {
|
||||
throw new moodle_exception('invalidaccess');
|
||||
}
|
||||
if ($action != 'add') {
|
||||
$roleid = required_param('roleid', PARAM_INT);
|
||||
} else {
|
||||
$roleid = 0;
|
||||
}
|
||||
$resettype = optional_param('resettype', '', PARAM_RAW);
|
||||
$return = optional_param('return', 'manage', PARAM_ALPHA);
|
||||
|
||||
// Get the base URL for this and related pages into a convenient variable.
|
||||
$baseurl = new moodle_url('/admin/roles/define.php', array('action'=>$action, 'roleid'=>$roleid));
|
||||
$manageurl = new moodle_url('/admin/roles/manage.php');
|
||||
if ($return === 'manage') {
|
||||
$returnurl = $manageurl;
|
||||
} else {
|
||||
$returnurl = new moodle_url('/admin/roles/define.php', array('action'=>'view', 'roleid'=>$roleid));;
|
||||
}
|
||||
|
||||
// Check access permissions.
|
||||
$systemcontext = context_system::instance();
|
||||
require_login();
|
||||
require_capability('moodle/role:manage', $systemcontext);
|
||||
admin_externalpage_setup('defineroles', '', array('action' => $action, 'roleid' => $roleid), new moodle_url('/admin/roles/define.php'));
|
||||
|
||||
// Export role.
|
||||
if ($action === 'export') {
|
||||
core_role_preset::send_export_xml($roleid);
|
||||
die;
|
||||
}
|
||||
|
||||
// Handle the toggle advanced mode button.
|
||||
$showadvanced = get_user_preferences('definerole_showadvanced', false);
|
||||
if (optional_param('toggleadvanced', false, PARAM_BOOL)) {
|
||||
$showadvanced = !$showadvanced;
|
||||
set_user_preference('definerole_showadvanced', $showadvanced);
|
||||
}
|
||||
|
||||
// Get some basic data we are going to need.
|
||||
$roles = get_all_roles();
|
||||
$rolenames = role_fix_names($roles, $systemcontext, ROLENAME_ORIGINAL);
|
||||
$rolescount = count($roles);
|
||||
|
||||
if ($action === 'add') {
|
||||
$title = get_string('addinganewrole', 'core_role');
|
||||
} else if ($action == 'view') {
|
||||
$title = get_string('viewingdefinitionofrolex', 'core_role', $rolenames[$roleid]->localname);
|
||||
} else if ($action == 'reset') {
|
||||
$title = get_string('resettingrole', 'core_role', $rolenames[$roleid]->localname);
|
||||
} else {
|
||||
$title = get_string('editingrolex', 'core_role', $rolenames[$roleid]->localname);
|
||||
}
|
||||
|
||||
// Decide how to create new role.
|
||||
if ($action === 'add' and $resettype !== 'none') {
|
||||
$mform = new core_role_preset_form(null, array('action'=>'add', 'roleid'=>0, 'resettype'=>'0', 'return'=>'manage'));
|
||||
if ($mform->is_cancelled()) {
|
||||
redirect($manageurl);
|
||||
|
||||
} else if ($data = $mform->get_data()) {
|
||||
$resettype = $data->resettype;
|
||||
$options = array(
|
||||
'shortname' => 1,
|
||||
'name' => 1,
|
||||
'description' => 1,
|
||||
'permissions' => 1,
|
||||
'archetype' => 1,
|
||||
'contextlevels' => 1,
|
||||
'allowassign' => 1,
|
||||
'allowoverride' => 1,
|
||||
'allowswitch' => 1);
|
||||
if ($showadvanced) {
|
||||
$definitiontable = new core_role_define_role_table_advanced($systemcontext, 0);
|
||||
} else {
|
||||
$definitiontable = new core_role_define_role_table_basic($systemcontext, 0);
|
||||
}
|
||||
if (is_number($resettype)) {
|
||||
// Duplicate the role.
|
||||
$definitiontable->force_duplicate($resettype, $options);
|
||||
} else {
|
||||
// Must be an archetype.
|
||||
$definitiontable->force_archetype($resettype, $options);
|
||||
}
|
||||
|
||||
if ($xml = $mform->get_file_content('rolepreset')) {
|
||||
$definitiontable->force_preset($xml, $options);
|
||||
}
|
||||
require_once(dirname(__FILE__) . '/../../config.php');
|
||||
require_once($CFG->dirroot . '/' . $CFG->admin . '/roles/lib.php');
|
||||
|
||||
$action = required_param('action', PARAM_ALPHA);
|
||||
if (!in_array($action, array('add', 'duplicate', 'edit', 'view'))) {
|
||||
throw new moodle_exception('invalidaccess');
|
||||
}
|
||||
if ($action != 'add') {
|
||||
$roleid = required_param('roleid', PARAM_INTEGER);
|
||||
} else {
|
||||
echo $OUTPUT->header();
|
||||
echo $OUTPUT->heading_with_help($title, 'roles', 'core_role');
|
||||
$mform->display();
|
||||
echo $OUTPUT->footer();
|
||||
die;
|
||||
$roleid = 0;
|
||||
}
|
||||
|
||||
} else if ($action === 'reset' and $resettype !== 'none') {
|
||||
if (!$role = $DB->get_record('role', array('id'=>$roleid))) {
|
||||
/// Get the base URL for this and related pages into a convenient variable.
|
||||
$manageurl = $CFG->wwwroot . '/' . $CFG->admin . '/roles/manage.php';
|
||||
$defineurl = $CFG->wwwroot . '/' . $CFG->admin . '/roles/define.php';
|
||||
if ($action == 'duplicate') {
|
||||
$baseurl = $defineurl . '?action=add';
|
||||
} else {
|
||||
$baseurl = $defineurl . '?action=' . $action;
|
||||
if ($roleid) {
|
||||
$baseurl .= '&roleid=' . $roleid;
|
||||
}
|
||||
}
|
||||
|
||||
/// Check access permissions.
|
||||
$systemcontext = get_context_instance(CONTEXT_SYSTEM);
|
||||
require_login();
|
||||
require_capability('moodle/role:manage', $systemcontext);
|
||||
admin_externalpage_setup('defineroles', '', array('action' => $action, 'roleid' => $roleid), $defineurl);
|
||||
|
||||
/// Handle the cancel button.
|
||||
if (optional_param('cancel', false, PARAM_BOOL)) {
|
||||
redirect($manageurl);
|
||||
}
|
||||
$resettype = empty($role->archetype) ? '0' : $role->archetype;
|
||||
$mform = new core_role_preset_form(null,
|
||||
array('action'=>'reset', 'roleid'=>$roleid, 'resettype'=>$resettype , 'permissions'=>1, 'archetype'=>1, 'contextlevels'=>1, 'return'=>$return));
|
||||
if ($mform->is_cancelled()) {
|
||||
redirect($returnurl);
|
||||
|
||||
} else if ($data = $mform->get_data()) {
|
||||
$resettype = $data->resettype;
|
||||
$options = array(
|
||||
'shortname' => $data->shortname,
|
||||
'name' => $data->name,
|
||||
'description' => $data->description,
|
||||
'permissions' => $data->permissions,
|
||||
'archetype' => $data->archetype,
|
||||
'contextlevels' => $data->contextlevels,
|
||||
'allowassign' => $data->allowassign,
|
||||
'allowoverride' => $data->allowoverride,
|
||||
'allowswitch' => $data->allowswitch);
|
||||
if ($showadvanced) {
|
||||
$definitiontable = new core_role_define_role_table_advanced($systemcontext, $roleid);
|
||||
} else {
|
||||
$definitiontable = new core_role_define_role_table_basic($systemcontext, $roleid);
|
||||
}
|
||||
if (is_number($resettype)) {
|
||||
// Duplicate the role.
|
||||
$definitiontable->force_duplicate($resettype, $options);
|
||||
} else {
|
||||
// Must be an archetype.
|
||||
$definitiontable->force_archetype($resettype, $options);
|
||||
}
|
||||
|
||||
if ($xml = $mform->get_file_content('rolepreset')) {
|
||||
$definitiontable->force_preset($xml, $options);
|
||||
}
|
||||
|
||||
} else {
|
||||
echo $OUTPUT->header();
|
||||
echo $OUTPUT->heading_with_help($title, 'roles', 'core_role');
|
||||
$mform->display();
|
||||
echo $OUTPUT->footer();
|
||||
die;
|
||||
/// Handle the toggle advanced mode button.
|
||||
$showadvanced = get_user_preferences('definerole_showadvanced', false);
|
||||
if (optional_param('toggleadvanced', false, PARAM_BOOL)) {
|
||||
$showadvanced = !$showadvanced;
|
||||
set_user_preference('definerole_showadvanced', $showadvanced);
|
||||
}
|
||||
|
||||
} else {
|
||||
// Create the table object.
|
||||
if ($action === 'view') {
|
||||
$definitiontable = new core_role_view_role_definition_table($systemcontext, $roleid);
|
||||
/// Get some basic data we are going to need.
|
||||
$roles = get_all_roles();
|
||||
$rolenames = role_fix_names($roles, $systemcontext, ROLENAME_ORIGINAL);
|
||||
$rolescount = count($roles);
|
||||
|
||||
/// Create the table object.
|
||||
if ($action == 'view') {
|
||||
$definitiontable = new view_role_definition_table($systemcontext, $roleid);
|
||||
} else if ($showadvanced) {
|
||||
$definitiontable = new core_role_define_role_table_advanced($systemcontext, $roleid);
|
||||
$definitiontable = new define_role_table_advanced($systemcontext, $roleid);
|
||||
} else {
|
||||
$definitiontable = new core_role_define_role_table_basic($systemcontext, $roleid);
|
||||
$definitiontable = new define_role_table_basic($systemcontext, $roleid);
|
||||
}
|
||||
$definitiontable->read_submitted_permissions();
|
||||
}
|
||||
|
||||
// Handle the cancel button.
|
||||
if (optional_param('cancel', false, PARAM_BOOL)) {
|
||||
redirect($returnurl);
|
||||
}
|
||||
|
||||
// Process submission in necessary.
|
||||
if (optional_param('savechanges', false, PARAM_BOOL) && confirm_sesskey() && $definitiontable->is_submission_valid()) {
|
||||
$definitiontable->save_changes();
|
||||
$tableroleid = $definitiontable->get_role_id();
|
||||
// Trigger event.
|
||||
$event = \core\event\role_capabilities_updated::create(
|
||||
array(
|
||||
'context' => $systemcontext,
|
||||
'objectid' => $roleid
|
||||
)
|
||||
);
|
||||
$event->set_legacy_logdata(array(SITEID, 'role', $action, 'admin/roles/define.php?action=view&roleid=' . $tableroleid,
|
||||
$definitiontable->get_role_name(), '', $USER->id));
|
||||
if (!empty($role)) {
|
||||
$event->add_record_snapshot('role', $role);
|
||||
if ($action == 'duplicate') {
|
||||
$definitiontable->make_copy();
|
||||
}
|
||||
$event->trigger();
|
||||
|
||||
if ($action === 'add') {
|
||||
redirect(new moodle_url('/admin/roles/define.php', array('action'=>'view', 'roleid'=>$definitiontable->get_role_id())));
|
||||
/// Process submission in necessary.
|
||||
if (optional_param('savechanges', false, PARAM_BOOL) && confirm_sesskey() && $definitiontable->is_submission_valid()) {
|
||||
$definitiontable->save_changes();
|
||||
add_to_log(SITEID, 'role', $action, 'admin/roles/define.php?action=view&roleid=' .
|
||||
$definitiontable->get_role_id(), $definitiontable->get_role_name(), '', $USER->id);
|
||||
redirect($manageurl);
|
||||
}
|
||||
|
||||
/// Print the page header and tabs.
|
||||
echo $OUTPUT->header();
|
||||
|
||||
$currenttab = 'manage';
|
||||
include('managetabs.php');
|
||||
|
||||
if ($action == 'add') {
|
||||
$title = get_string('addinganewrole', 'role');
|
||||
} else if ($action == 'duplicate') {
|
||||
$title = get_string('addingrolebycopying', 'role', $rolenames[$roleid]->localname);
|
||||
} else if ($action == 'view') {
|
||||
$title = get_string('viewingdefinitionofrolex', 'role', $rolenames[$roleid]->localname);
|
||||
} else if ($action == 'edit') {
|
||||
$title = get_string('editingrolex', 'role', $rolenames[$roleid]->localname);
|
||||
}
|
||||
echo $OUTPUT->heading_with_help($title, 'roles', 'role');
|
||||
|
||||
/// Work out some button labels.
|
||||
if ($action == 'add' || $action == 'duplicate') {
|
||||
$submitlabel = get_string('createthisrole', 'role');
|
||||
} else {
|
||||
redirect($returnurl);
|
||||
$submitlabel = get_string('savechanges');
|
||||
}
|
||||
}
|
||||
|
||||
// Print the page header and tabs.
|
||||
echo $OUTPUT->header();
|
||||
/// On the view page, show some extra controls at the top.
|
||||
if ($action == 'view') {
|
||||
echo $OUTPUT->container_start('buttons');
|
||||
$options = array();
|
||||
$options['roleid'] = $roleid;
|
||||
$options['action'] = 'edit';
|
||||
echo $OUTPUT->single_button(new moodle_url($defineurl, $options), get_string('edit'));
|
||||
$options['action'] = 'reset';
|
||||
if ($definitiontable->get_archetype()) {
|
||||
echo $OUTPUT->single_button(new moodle_url($manageurl, $options), get_string('resetrole', 'role'));
|
||||
} else {
|
||||
echo $OUTPUT->single_button(new moodle_url($manageurl, $options), get_string('resetrolenolegacy', 'role'));
|
||||
}
|
||||
$options['action'] = 'duplicate';
|
||||
echo $OUTPUT->single_button(new moodle_url($defineurl, $options), get_string('duplicaterole', 'role'));
|
||||
echo $OUTPUT->single_button(new moodle_url($manageurl), get_string('listallroles', 'role'));
|
||||
echo $OUTPUT->container_end();
|
||||
}
|
||||
|
||||
$currenttab = 'manage';
|
||||
require('managetabs.php');
|
||||
|
||||
echo $OUTPUT->heading_with_help($title, 'roles', 'core_role');
|
||||
|
||||
// Work out some button labels.
|
||||
if ($action === 'add') {
|
||||
$submitlabel = get_string('createthisrole', 'core_role');
|
||||
} else {
|
||||
$submitlabel = get_string('savechanges');
|
||||
}
|
||||
|
||||
// On the view page, show some extra controls at the top.
|
||||
if ($action === 'view') {
|
||||
echo $OUTPUT->container_start('buttons');
|
||||
$url = new moodle_url('/admin/roles/define.php', array('action'=>'edit', 'roleid'=>$roleid, 'return'=>'define'));
|
||||
echo $OUTPUT->single_button(new moodle_url($url), get_string('edit'));
|
||||
$url = new moodle_url('/admin/roles/define.php', array('action'=>'reset', 'roleid'=>$roleid, 'return'=>'define'));
|
||||
echo $OUTPUT->single_button(new moodle_url($url), get_string('resetrole', 'core_role'));
|
||||
$url = new moodle_url('/admin/roles/define.php', array('action'=>'export', 'roleid'=>$roleid));
|
||||
echo $OUTPUT->single_button(new moodle_url($url), get_string('export', 'core_role'));
|
||||
echo $OUTPUT->single_button($manageurl, get_string('listallroles', 'core_role'));
|
||||
echo $OUTPUT->container_end();
|
||||
}
|
||||
|
||||
// Start the form.
|
||||
echo $OUTPUT->box_start('generalbox');
|
||||
if ($action === 'view') {
|
||||
echo '<div class="mform">';
|
||||
} else {
|
||||
// Start the form.
|
||||
echo $OUTPUT->box_start('generalbox');
|
||||
if ($action == 'view') {
|
||||
echo '<div class="mform">';
|
||||
} else {
|
||||
?>
|
||||
<form id="rolesform" class="mform" action="<?php p($baseurl->out(false)); ?>" method="post"><div>
|
||||
<form id="rolesform" class="mform" action="<?php echo $baseurl; ?>" method="post"><div>
|
||||
<input type="hidden" name="sesskey" value="<?php p(sesskey()) ?>" />
|
||||
<input type="hidden" name="return" value="<?php p($return); ?>" />
|
||||
<input type="hidden" name="resettype" value="none" />
|
||||
<div class="submit buttons">
|
||||
<input type="submit" name="savechanges" value="<?php p($submitlabel); ?>" />
|
||||
<input type="submit" name="savechanges" value="<?php echo $submitlabel; ?>" />
|
||||
<input type="submit" name="cancel" value="<?php print_string('cancel'); ?>" />
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
|
||||
// Print the form controls.
|
||||
$definitiontable->display();
|
||||
// Print the form controls.
|
||||
$definitiontable->display();
|
||||
|
||||
// Close the stuff we left open above.
|
||||
if ($action === 'view') {
|
||||
echo '</div>';
|
||||
} else {
|
||||
?>
|
||||
/// Close the stuff we left open above.
|
||||
if ($action == 'view') {
|
||||
echo '</div>';
|
||||
} else {
|
||||
?>
|
||||
<div class="submit buttons">
|
||||
<input type="submit" name="savechanges" value="<?php p($submitlabel); ?>" />
|
||||
<input type="submit" name="savechanges" value="<?php echo $submitlabel; ?>" />
|
||||
<input type="submit" name="cancel" value="<?php print_string('cancel'); ?>" />
|
||||
</div>
|
||||
</div></form>
|
||||
<?php
|
||||
}
|
||||
echo $OUTPUT->box_end();
|
||||
<?php
|
||||
}
|
||||
echo $OUTPUT->box_end();
|
||||
|
||||
// Print a link back to the all roles list.
|
||||
echo '<div class="backlink">';
|
||||
echo '<p><a href="' . s($manageurl->out(false)) . '">' . get_string('backtoallroles', 'core_role') . '</a></p>';
|
||||
echo '</div>';
|
||||
/// Print a link back to the all roles list.
|
||||
echo '<div class="backlink">';
|
||||
echo '<p><a href="' . $manageurl . '">' . get_string('backtoallroles', 'role') . '</a></p>';
|
||||
echo '</div>';
|
||||
|
||||
echo $OUTPUT->footer();
|
||||
echo $OUTPUT->footer();
|
||||
|
||||
+1580
-18
File diff suppressed because it is too large
Load Diff
+204
-160
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
@@ -22,196 +23,239 @@
|
||||
* delete - delete a role (with are-you-sure)
|
||||
* moveup - change the sort order
|
||||
* movedown - change the sort order
|
||||
* reset - set a role's permissions back to the default for that legacy role type.
|
||||
*
|
||||
* For all but the first two of those, you also need a roleid parameter, and
|
||||
* possibly some other data.
|
||||
*
|
||||
* @package core_role
|
||||
* @package core
|
||||
* @subpackage role
|
||||
* @copyright 1999 onwards Martin Dougiamas (http://dougiamas.com)
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
require_once(dirname(__FILE__) . '/../../config.php');
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
require_once($CFG->dirroot . '/' . $CFG->admin . '/roles/lib.php');
|
||||
require_once(dirname(__FILE__) . '/../../config.php');
|
||||
require_once($CFG->dirroot . '/' . $CFG->admin . '/roles/lib.php');
|
||||
|
||||
$action = optional_param('action', '', PARAM_ALPHA);
|
||||
if ($action) {
|
||||
$roleid = required_param('roleid', PARAM_INT);
|
||||
} else {
|
||||
$roleid = 0;
|
||||
}
|
||||
$action = optional_param('action', '', PARAM_ALPHA);
|
||||
if ($action) {
|
||||
$roleid = required_param('roleid', PARAM_INT);
|
||||
}
|
||||
|
||||
// Get the base URL for this and related pages into a convenient variable.
|
||||
$baseurl = $CFG->wwwroot . '/' . $CFG->admin . '/roles/manage.php';
|
||||
$defineurl = $CFG->wwwroot . '/' . $CFG->admin . '/roles/define.php';
|
||||
/// Get the base URL for this and related pages into a convenient variable.
|
||||
$baseurl = $CFG->wwwroot . '/' . $CFG->admin . '/roles/manage.php';
|
||||
$defineurl = $CFG->wwwroot . '/' . $CFG->admin . '/roles/define.php';
|
||||
|
||||
// Check access permissions.
|
||||
$systemcontext = context_system::instance();
|
||||
require_login();
|
||||
require_capability('moodle/role:manage', $systemcontext);
|
||||
admin_externalpage_setup('defineroles');
|
||||
/// Check access permissions.
|
||||
$systemcontext = get_context_instance(CONTEXT_SYSTEM);
|
||||
require_login();
|
||||
require_capability('moodle/role:manage', $systemcontext);
|
||||
admin_externalpage_setup('defineroles');
|
||||
|
||||
// Get some basic data we are going to need.
|
||||
$roles = role_fix_names(get_all_roles(), $systemcontext, ROLENAME_ORIGINAL);
|
||||
/// Get some basic data we are going to need.
|
||||
$roles = get_all_roles();
|
||||
role_fix_names($roles, $systemcontext, ROLENAME_ORIGINAL);
|
||||
|
||||
$undeletableroles = array();
|
||||
$undeletableroles[$CFG->notloggedinroleid] = 1;
|
||||
$undeletableroles[$CFG->guestroleid] = 1;
|
||||
$undeletableroles[$CFG->defaultuserroleid] = 1;
|
||||
$undeletableroles = array();
|
||||
$undeletableroles[$CFG->notloggedinroleid] = 1;
|
||||
$undeletableroles[$CFG->guestroleid] = 1;
|
||||
$undeletableroles[$CFG->defaultuserroleid] = 1;
|
||||
|
||||
// Process submitted data.
|
||||
$confirmed = (optional_param('confirm', false, PARAM_BOOL) && data_submitted() && confirm_sesskey());
|
||||
switch ($action) {
|
||||
case 'delete':
|
||||
if (isset($undeletableroles[$roleid])) {
|
||||
print_error('cannotdeletethisrole', '', $baseurl);
|
||||
}
|
||||
if (!$confirmed) {
|
||||
// Show confirmation.
|
||||
echo $OUTPUT->header();
|
||||
$optionsyes = array('action'=>'delete', 'roleid'=>$roleid, 'sesskey'=>sesskey(), 'confirm'=>1);
|
||||
$a = new stdClass();
|
||||
$a->id = $roleid;
|
||||
$a->name = $roles[$roleid]->name;
|
||||
$a->shortname = $roles[$roleid]->shortname;
|
||||
$a->count = $DB->count_records_select('role_assignments',
|
||||
'roleid = ?', array($roleid), 'COUNT(DISTINCT userid)');
|
||||
///.Process submitted data.
|
||||
$confirmed = optional_param('confirm', false, PARAM_BOOL) && data_submitted() && confirm_sesskey();
|
||||
switch ($action) {
|
||||
case 'delete':
|
||||
if (isset($undeletableroles[$roleid])) {
|
||||
print_error('cannotdeletethisrole', '', $baseurl);
|
||||
}
|
||||
if (!$confirmed) {
|
||||
// show confirmation
|
||||
echo $OUTPUT->header();
|
||||
$optionsyes = array('action'=>'delete', 'roleid'=>$roleid, 'sesskey'=>sesskey(), 'confirm'=>1);
|
||||
$a = new stdClass();
|
||||
$a->id = $roleid;
|
||||
$a->name = $roles[$roleid]->name;
|
||||
$a->shortname = $roles[$roleid]->shortname;
|
||||
$a->count = $DB->count_records('role_assignments', array('roleid'=>$roleid));
|
||||
|
||||
$formcontinue = new single_button(new moodle_url($baseurl, $optionsyes), get_string('yes'));
|
||||
$formcancel = new single_button(new moodle_url($baseurl), get_string('no'), 'get');
|
||||
echo $OUTPUT->confirm(get_string('deleterolesure', 'core_role', $a), $formcontinue, $formcancel);
|
||||
echo $OUTPUT->footer();
|
||||
die;
|
||||
}
|
||||
if (!delete_role($roleid)) {
|
||||
// The delete failed, but mark the context dirty in case.
|
||||
$systemcontext->mark_dirty();
|
||||
print_error('cannotdeleterolewithid', 'error', $baseurl, $roleid);
|
||||
}
|
||||
// Deleted a role sitewide...
|
||||
$systemcontext->mark_dirty();
|
||||
redirect($baseurl);
|
||||
break;
|
||||
$formcontinue = new single_button(new moodle_url($baseurl, $optionsyes), get_string('yes'));
|
||||
$formcancel = new single_button(new moodle_url($baseurl), get_string('no'), 'get');
|
||||
echo $OUTPUT->confirm(get_string('deleterolesure', 'role', $a), $formcontinue, $formcancel);
|
||||
echo $OUTPUT->footer();
|
||||
die;
|
||||
}
|
||||
if (!delete_role($roleid)) {
|
||||
// The delete failed, but mark the context dirty in case.
|
||||
mark_context_dirty($systemcontext->path);
|
||||
print_error('cannotdeleterolewithid', 'error', $baseurl, $roleid);
|
||||
}
|
||||
// Deleted a role sitewide...
|
||||
mark_context_dirty($systemcontext->path);
|
||||
add_to_log(SITEID, 'role', 'delete', 'admin/roles/manage.php', $roles[$roleid]->localname, '', $USER->id);
|
||||
redirect($baseurl);
|
||||
break;
|
||||
|
||||
case 'moveup':
|
||||
if (confirm_sesskey()) {
|
||||
$prevrole = null;
|
||||
$thisrole = null;
|
||||
foreach ($roles as $role) {
|
||||
if ($role->id == $roleid) {
|
||||
$thisrole = $role;
|
||||
break;
|
||||
case 'moveup':
|
||||
if (confirm_sesskey()) {
|
||||
$prevrole = null;
|
||||
$thisrole = null;
|
||||
foreach ($roles as $role) {
|
||||
if ($role->id == $roleid) {
|
||||
$thisrole = $role;
|
||||
break;
|
||||
} else {
|
||||
$prevrole = $role;
|
||||
}
|
||||
}
|
||||
if (is_null($thisrole) || is_null($prevrole)) {
|
||||
print_error('cannotmoverolewithid', 'error', '', $roleid);
|
||||
}
|
||||
if (!switch_roles($thisrole, $prevrole)) {
|
||||
print_error('cannotmoverolewithid', 'error', '', $roleid);
|
||||
}
|
||||
}
|
||||
|
||||
redirect($baseurl);
|
||||
break;
|
||||
|
||||
case 'movedown':
|
||||
if (confirm_sesskey()) {
|
||||
$thisrole = null;
|
||||
$nextrole = null;
|
||||
foreach ($roles as $role) {
|
||||
if ($role->id == $roleid) {
|
||||
$thisrole = $role;
|
||||
} else if (!is_null($thisrole)) {
|
||||
$nextrole = $role;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (is_null($nextrole)) {
|
||||
print_error('cannotmoverolewithid', 'error', '', $roleid);
|
||||
}
|
||||
if (!switch_roles($thisrole, $nextrole)) {
|
||||
print_error('cannotmoverolewithid', 'error', '', $roleid);
|
||||
}
|
||||
}
|
||||
|
||||
redirect($baseurl);
|
||||
break;
|
||||
|
||||
case 'reset':
|
||||
if (!$confirmed) {
|
||||
// show confirmation
|
||||
echo $OUTPUT->header();
|
||||
$optionsyes = array('action'=>'reset', 'roleid'=>$roleid, 'sesskey'=>sesskey(), 'confirm'=>1);
|
||||
$optionsno = array('action'=>'view', 'roleid'=>$roleid);
|
||||
$a = new stdClass();
|
||||
$a->id = $roleid;
|
||||
$a->name = $roles[$roleid]->name;
|
||||
$a->shortname = $roles[$roleid]->shortname;
|
||||
$a->legacytype = $roles[$roleid]->archetype;
|
||||
if (empty($a->legacytype)) {
|
||||
$warning = get_string('resetrolesurenolegacy', 'role', $a);
|
||||
} else {
|
||||
$prevrole = $role;
|
||||
$warning = get_string('resetrolesure', 'role', $a);
|
||||
}
|
||||
$formcontinue = new single_button(new moodle_url('manage.php', $optionsyes), get_string('yes'));
|
||||
$formcancel = new single_button(new moodle_url('manage.php', $optionsno), get_string('no'), 'get');
|
||||
echo $OUTPUT->confirm($warning, $formcontinue, $formcancel);
|
||||
echo $OUTPUT->footer();
|
||||
die;
|
||||
}
|
||||
if (is_null($thisrole) || is_null($prevrole)) {
|
||||
print_error('cannotmoverolewithid', 'error', '', $roleid);
|
||||
|
||||
// Reset context levels for standard archetypes
|
||||
if ($roles[$roleid]->archetype) {
|
||||
set_role_contextlevels($roleid, get_default_contextlevels($roles[$roleid]->archetype));
|
||||
}
|
||||
if (!switch_roles($thisrole, $prevrole)) {
|
||||
print_error('cannotmoverolewithid', 'error', '', $roleid);
|
||||
}
|
||||
}
|
||||
|
||||
redirect($baseurl);
|
||||
break;
|
||||
//reset or delete the capabilities
|
||||
reset_role_capabilities($roleid);
|
||||
|
||||
case 'movedown':
|
||||
if (confirm_sesskey()) {
|
||||
$thisrole = null;
|
||||
$nextrole = null;
|
||||
foreach ($roles as $role) {
|
||||
if ($role->id == $roleid) {
|
||||
$thisrole = $role;
|
||||
} else if (!is_null($thisrole)) {
|
||||
$nextrole = $role;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (is_null($nextrole)) {
|
||||
print_error('cannotmoverolewithid', 'error', '', $roleid);
|
||||
}
|
||||
if (!switch_roles($thisrole, $nextrole)) {
|
||||
print_error('cannotmoverolewithid', 'error', '', $roleid);
|
||||
}
|
||||
}
|
||||
// Mark context dirty, log and redirect.
|
||||
mark_context_dirty($systemcontext->path);
|
||||
add_to_log(SITEID, 'role', 'reset', 'admin/roles/manage.php?action=reset&roleid=' . $roleid, $roles[$roleid]->localname, '', $USER->id);
|
||||
redirect($defineurl . '?action=view&roleid=' . $roleid);
|
||||
break;
|
||||
}
|
||||
|
||||
redirect($baseurl);
|
||||
break;
|
||||
/// Print the page header and tabs.
|
||||
echo $OUTPUT->header();
|
||||
|
||||
}
|
||||
$currenttab = 'manage';
|
||||
include_once('managetabs.php');
|
||||
|
||||
// Print the page header and tabs.
|
||||
echo $OUTPUT->header();
|
||||
|
||||
$currenttab = 'manage';
|
||||
require('managetabs.php');
|
||||
|
||||
// Initialise table.
|
||||
$table = new html_table();
|
||||
$table->colclasses = array('leftalign', 'leftalign', 'leftalign', 'leftalign');
|
||||
$table->id = 'roles';
|
||||
$table->attributes['class'] = 'admintable generaltable';
|
||||
$table->head = array(
|
||||
get_string('role') . ' ' . $OUTPUT->help_icon('roles', 'core_role'),
|
||||
get_string('description'),
|
||||
get_string('roleshortname', 'core_role'),
|
||||
get_string('edit')
|
||||
);
|
||||
|
||||
// Get some strings outside the loop.
|
||||
$stredit = get_string('edit');
|
||||
$strdelete = get_string('delete');
|
||||
$strmoveup = get_string('moveup');
|
||||
$strmovedown = get_string('movedown');
|
||||
|
||||
// Print a list of roles with edit/copy/delete/reorder icons.
|
||||
$table->data = array();
|
||||
$firstrole = reset($roles);
|
||||
$lastrole = end($roles);
|
||||
foreach ($roles as $role) {
|
||||
// Basic data.
|
||||
$row = array(
|
||||
'<a href="' . $defineurl . '?action=view&roleid=' . $role->id . '">' . $role->localname . '</a>',
|
||||
role_get_description($role),
|
||||
s($role->shortname),
|
||||
'',
|
||||
/// Initialise table.
|
||||
$table = new html_table();
|
||||
$table->tablealign = 'center';
|
||||
$table->align = array('left', 'left', 'left', 'left');
|
||||
$table->wrap = array('nowrap', '', 'nowrap','nowrap');
|
||||
$table->width = '90%';
|
||||
$table->head = array(
|
||||
get_string('role') . ' ' . $OUTPUT->help_icon('roles', 'role'),
|
||||
get_string('description'),
|
||||
get_string('roleshortname', 'role'),
|
||||
get_string('edit')
|
||||
);
|
||||
|
||||
// Move up.
|
||||
if ($role->sortorder != $firstrole->sortorder) {
|
||||
$row[3] .= get_action_icon($baseurl . '?action=moveup&roleid=' . $role->id . '&sesskey=' . sesskey(), 'up', $strmoveup, $strmoveup);
|
||||
} else {
|
||||
$row[3] .= get_spacer();
|
||||
}
|
||||
// Move down.
|
||||
if ($role->sortorder != $lastrole->sortorder) {
|
||||
$row[3] .= get_action_icon($baseurl . '?action=movedown&roleid=' . $role->id . '&sesskey=' . sesskey(), 'down', $strmovedown, $strmovedown);
|
||||
} else {
|
||||
$row[3] .= get_spacer();
|
||||
}
|
||||
// Edit.
|
||||
$row[3] .= get_action_icon($defineurl . '?action=edit&roleid=' . $role->id,
|
||||
'edit', $stredit, get_string('editxrole', 'core_role', $role->localname));
|
||||
// Delete.
|
||||
if (isset($undeletableroles[$role->id])) {
|
||||
$row[3] .= get_spacer();
|
||||
} else {
|
||||
$row[3] .= get_action_icon($baseurl . '?action=delete&roleid=' . $role->id,
|
||||
'delete', $strdelete, get_string('deletexrole', 'core_role', $role->localname));
|
||||
}
|
||||
/// Get some strings outside the loop.
|
||||
$stredit = get_string('edit');
|
||||
$strduplicate = get_string('duplicate');
|
||||
$strdelete = get_string('delete');
|
||||
$strmoveup = get_string('moveup');
|
||||
$strmovedown = get_string('movedown');
|
||||
|
||||
$table->data[] = $row;
|
||||
}
|
||||
echo html_writer::table($table);
|
||||
/// Print a list of roles with edit/copy/delete/reorder icons.
|
||||
$table->data = array();
|
||||
$firstrole = reset($roles);
|
||||
$lastrole = end($roles);
|
||||
foreach ($roles as $role) {
|
||||
|
||||
echo $OUTPUT->container_start('buttons');
|
||||
echo $OUTPUT->single_button(new moodle_url($defineurl, array('action' => 'add')), get_string('addrole', 'core_role'), 'get');
|
||||
echo $OUTPUT->container_end();
|
||||
/// Basic data.
|
||||
$row = array(
|
||||
'<a href="' . $defineurl . '?action=view&roleid=' . $role->id . '">' . $role->localname . '</a>',
|
||||
format_text($role->description, FORMAT_HTML),
|
||||
s($role->shortname),
|
||||
'',
|
||||
);
|
||||
|
||||
echo $OUTPUT->footer();
|
||||
die;
|
||||
/// Icons:
|
||||
// move up
|
||||
if ($role->sortorder != $firstrole->sortorder) {
|
||||
$row[3] .= get_action_icon($baseurl . '?action=moveup&roleid=' . $role->id . '&sesskey=' . sesskey(), 'up', $strmoveup, $strmoveup);
|
||||
} else {
|
||||
$row[3] .= get_spacer();
|
||||
}
|
||||
// move down
|
||||
if ($role->sortorder != $lastrole->sortorder) {
|
||||
$row[3] .= get_action_icon($baseurl . '?action=movedown&roleid=' . $role->id . '&sesskey=' . sesskey(), 'down', $strmovedown, $strmovedown);
|
||||
} else {
|
||||
$row[3] .= get_spacer();
|
||||
}
|
||||
// edit
|
||||
$row[3] .= get_action_icon($defineurl . '?action=edit&roleid=' . $role->id,
|
||||
'edit', $stredit, get_string('editxrole', 'role', $role->localname));
|
||||
// duplicate
|
||||
$row[3] .= get_action_icon($defineurl . '?action=duplicate&roleid=' . $role->id,
|
||||
'copy', $strduplicate, get_string('createrolebycopying', 'role', $role->localname));
|
||||
// delete
|
||||
if (isset($undeletableroles[$role->id])) {
|
||||
$row[3] .= get_spacer();
|
||||
} else {
|
||||
$row[3] .= get_action_icon($baseurl . '?action=delete&roleid=' . $role->id,
|
||||
'delete', $strdelete, get_string('deletexrole', 'role', $role->localname));
|
||||
}
|
||||
|
||||
$table->data[] = $row;
|
||||
}
|
||||
echo html_writer::table($table);
|
||||
|
||||
echo $OUTPUT->container_start('buttons');
|
||||
echo $OUTPUT->single_button(new moodle_url($defineurl, array('action' => 'add')), get_string('addrole', 'role'), 'get');
|
||||
echo $OUTPUT->container_end();
|
||||
|
||||
echo $OUTPUT->footer();
|
||||
die;
|
||||
|
||||
function get_action_icon($url, $icon, $alt, $tooltip) {
|
||||
global $OUTPUT;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
@@ -17,18 +18,22 @@
|
||||
/**
|
||||
* Defines the tab bar used on the manage/allow assign/allow overrides pages.
|
||||
*
|
||||
* @package core_role
|
||||
* @package core
|
||||
* @subpackage role
|
||||
* @copyright 1999 onwards Martin Dougiamas (http://dougiamas.com)
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
if (!defined('MOODLE_INTERNAL')) {
|
||||
die('Direct access to this script is forbidden.'); // It must be included from a Moodle page
|
||||
}
|
||||
|
||||
$toprow = array();
|
||||
$toprow[] = new tabobject('manage', new moodle_url('/admin/roles/manage.php'), get_string('manageroles', 'core_role'));
|
||||
$toprow[] = new tabobject('assign', new moodle_url('/admin/roles/allow.php', array('mode'=>'assign')), get_string('allowassign', 'core_role'));
|
||||
$toprow[] = new tabobject('override', new moodle_url('/admin/roles/allow.php', array('mode'=>'override')), get_string('allowoverride', 'core_role'));
|
||||
$toprow[] = new tabobject('switch', new moodle_url('/admin/roles/allow.php', array('mode'=>'switch')), get_string('allowswitch', 'core_role'));
|
||||
$toprow[] = new tabobject('manage', new moodle_url('/admin/roles/manage.php'), get_string('manageroles', 'role'));
|
||||
$toprow[] = new tabobject('assign', new moodle_url('/admin/roles/allow.php', array('mode'=>'assign')), get_string('allowassign', 'role'));
|
||||
$toprow[] = new tabobject('override', new moodle_url('/admin/roles/allow.php', array('mode'=>'override')), get_string('allowoverride', 'role'));
|
||||
$toprow[] = new tabobject('switch', new moodle_url('/admin/roles/allow.php', array('mode'=>'switch')), get_string('allowswitch', 'role'));
|
||||
$tabs = array($toprow);
|
||||
|
||||
echo $OUTPUT->tabtree($toprow, $currenttab);
|
||||
print_tabs($tabs, $currenttab);
|
||||
|
||||
|
||||
@@ -51,11 +51,11 @@ M.core_role.init_cap_table_filter = function(Y, tableid, contextid) {
|
||||
marginRight : 'auto'
|
||||
});
|
||||
// Create the capability search input.
|
||||
this.input = Y.Node.create('<input type="text" id="'+this.table.get('id')+'capabilitysearch" value="'+Y.Escape.html(filtervalue)+'" />');
|
||||
this.input = Y.Node.create('<input type="text" id="'+this.table.get('id')+'capabilitysearch" value="'+filtervalue+'" />');
|
||||
// Create a label for the search input.
|
||||
this.label = Y.Node.create('<label for="'+this.input.get('id')+'">'+M.util.get_string('filter', 'moodle')+' </label>');
|
||||
this.label = Y.Node.create('<label for="'+this.input.get('id')+'">'+M.str.moodle.filter+' </label>');
|
||||
// Create a clear button to clear the input.
|
||||
this.button = Y.Node.create('<input type="button" value="'+M.util.get_string('clear', 'moodle')+'" />').set('disabled', filtervalue=='');
|
||||
this.button = Y.Node.create('<input type="button" value="'+M.str.moodle.clear+'" />').set('disabled', filtervalue=='');
|
||||
|
||||
// Tie it all together
|
||||
this.div.append(this.label).append(this.input).append(this.button);
|
||||
|
||||
+27
-50
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
@@ -17,15 +18,17 @@
|
||||
/**
|
||||
* Lets you override role definitions in contexts.
|
||||
*
|
||||
* @package core_role
|
||||
* @package core
|
||||
* @subpackage role
|
||||
* @copyright 1999 onwards Martin Dougiamas (http://dougiamas.com)
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
require('../../config.php');
|
||||
require_once("$CFG->dirroot/$CFG->admin/roles/lib.php");
|
||||
|
||||
$contextid = required_param('contextid', PARAM_INT);
|
||||
$roleid = required_param('roleid', PARAM_INT);
|
||||
$contextid = required_param('contextid', PARAM_INT); // context id
|
||||
$roleid = required_param('roleid', PARAM_INT); // requested role id
|
||||
|
||||
list($context, $course, $cm) = get_context_info_array($contextid);
|
||||
|
||||
@@ -45,7 +48,7 @@ if ($course) {
|
||||
}
|
||||
}
|
||||
|
||||
// Security first.
|
||||
// security first
|
||||
require_login($course, false, $cm);
|
||||
$safeoverridesonly = false;
|
||||
if (!has_capability('moodle/role:override', $context)) {
|
||||
@@ -53,19 +56,9 @@ if (!has_capability('moodle/role:override', $context)) {
|
||||
$safeoverridesonly = true;
|
||||
}
|
||||
$PAGE->set_url($url);
|
||||
$PAGE->set_context($context);
|
||||
$PAGE->set_pagelayout('admin');
|
||||
|
||||
if ($context->contextlevel == CONTEXT_USER and $USER->id != $context->instanceid) {
|
||||
$PAGE->navigation->extend_for_user($user);
|
||||
$PAGE->set_context(context_course::instance($course->id));
|
||||
navigation_node::override_active_url(new moodle_url('/admin/roles/permissions.php',
|
||||
array('contextid'=>$context->id, 'userid'=>$context->instanceid, 'courseid'=>$course->id)));
|
||||
|
||||
} else {
|
||||
$PAGE->set_context($context);
|
||||
navigation_node::override_active_url(new moodle_url('/admin/roles/permissions.php', array('contextid'=>$context->id)));
|
||||
}
|
||||
|
||||
$courseid = $course->id;
|
||||
|
||||
$returnurl = new moodle_url('/admin/roles/permissions.php', array('contextid' => $context->id));
|
||||
@@ -77,15 +70,15 @@ if (optional_param('cancel', false, PARAM_BOOL)) {
|
||||
|
||||
$role = $DB->get_record('role', array('id'=>$roleid), '*', MUST_EXIST);
|
||||
|
||||
// These are needed early.
|
||||
// These are needed early
|
||||
$assignableroles = get_assignable_roles($context, ROLENAME_BOTH);
|
||||
list($overridableroles, $overridecounts, $nameswithcounts) = get_overridable_roles($context, ROLENAME_BOTH, true);
|
||||
|
||||
// Work out an appropriate page title.
|
||||
$contextname = $context->get_context_name();
|
||||
$straction = get_string('overrideroles', 'core_role'); // Used by tabs.php.
|
||||
$contextname = print_context_name($context);
|
||||
$straction = get_string('overrideroles', 'role'); // Used by tabs.php
|
||||
$a = (object)array('context' => $contextname, 'role' => $overridableroles[$roleid]);
|
||||
$title = get_string('overridepermissionsforrole', 'core_role', $a);
|
||||
$title = get_string('overridepermissionsforrole', 'role', $a);
|
||||
|
||||
$currenttab = 'permissions';
|
||||
|
||||
@@ -101,17 +94,17 @@ switch ($context->contextlevel) {
|
||||
$showroles = 1;
|
||||
break;
|
||||
case CONTEXT_COURSECAT:
|
||||
$PAGE->set_heading($SITE->fullname);
|
||||
$PAGE->set_heading("$SITE->fullname: ".get_string("categories"));
|
||||
break;
|
||||
case CONTEXT_COURSE:
|
||||
if ($isfrontpage) {
|
||||
$PAGE->set_heading(get_string('frontpage', 'admin'));
|
||||
admin_externalpage_setup('frontpageroles', '', array(), $PAGE->url);
|
||||
} else {
|
||||
$PAGE->set_heading($course->fullname);
|
||||
}
|
||||
break;
|
||||
case CONTEXT_MODULE:
|
||||
$PAGE->set_heading($context->get_context_name(false));
|
||||
$PAGE->set_heading(print_context_name($context, false));
|
||||
$PAGE->set_cacheable(false);
|
||||
break;
|
||||
case CONTEXT_BLOCK:
|
||||
@@ -119,61 +112,45 @@ switch ($context->contextlevel) {
|
||||
break;
|
||||
}
|
||||
|
||||
// Make sure this user can override that role.
|
||||
// Make sure this user can override that role
|
||||
if (empty($overridableroles[$roleid])) {
|
||||
$a = new stdClass;
|
||||
$a->roleid = $roleid;
|
||||
$a->context = $contextname;
|
||||
print_error('cannotoverriderolehere', '', $context->get_url(), $a);
|
||||
print_error('cannotoverriderolehere', '', get_context_url($context), $a);
|
||||
}
|
||||
|
||||
// If we are actually overriding a role, create the table object, and save changes if appropriate.
|
||||
$overridestable = new core_role_override_permissions_table_advanced($context, $roleid, $safeoverridesonly);
|
||||
$overridestable = new override_permissions_table_advanced($context, $roleid, $safeoverridesonly);
|
||||
$overridestable->read_submitted_permissions();
|
||||
|
||||
if (optional_param('savechanges', false, PARAM_BOOL) && confirm_sesskey()) {
|
||||
$overridestable->save_changes();
|
||||
$rolename = $overridableroles[$roleid];
|
||||
// Trigger event.
|
||||
$event = \core\event\role_capabilities_updated::create(
|
||||
array(
|
||||
'context' => $context,
|
||||
'objectid' => $roleid,
|
||||
)
|
||||
);
|
||||
|
||||
$event->set_legacy_logdata(
|
||||
array(
|
||||
$course->id, 'role', 'override', 'admin/roles/override.php?contextid=' . $context->id . '&roleid=' . $roleid,
|
||||
$rolename, '', $USER->id
|
||||
)
|
||||
);
|
||||
$event->add_record_snapshot('role', $role);
|
||||
$event->trigger();
|
||||
|
||||
add_to_log($course->id, 'role', 'override', 'admin/roles/override.php?contextid='.$context->id.'&roleid='.$roleid, $rolename, '', $USER->id);
|
||||
redirect($returnurl);
|
||||
}
|
||||
|
||||
// Finally start page output.
|
||||
// Finally start page output
|
||||
echo $OUTPUT->header();
|
||||
echo $OUTPUT->heading_with_help($title, 'overridepermissions', 'core_role');
|
||||
echo $OUTPUT->heading_with_help($title, 'overridepermissions', 'role');
|
||||
|
||||
// Show UI for overriding roles.
|
||||
if (!empty($capabilities)) {
|
||||
echo $OUTPUT->box(get_string('nocapabilitiesincontext', 'core_role'), 'generalbox boxaligncenter');
|
||||
echo $OUTPUT->box(get_string('nocapabilitiesincontext', 'role'), 'generalbox boxaligncenter');
|
||||
|
||||
} else {
|
||||
// Print the capabilities overrideable in this context.
|
||||
// Print the capabilities overrideable in this context
|
||||
echo $OUTPUT->box_start('generalbox capbox');
|
||||
echo html_writer::start_tag('form', array('id'=>'overrideform', 'action'=>$PAGE->url->out(), 'method'=>'post'));
|
||||
echo html_writer::start_tag('div');
|
||||
echo html_writer::empty_tag('input', array('type'=>'hidden', 'name'=>'sesskey', 'value'=>sesskey()));
|
||||
echo html_writer::empty_tag('input', array('type'=>'hidden', 'name'=>'roleid', 'value'=>$roleid));
|
||||
echo html_writer::tag('p', get_string('highlightedcellsshowinherit', 'core_role'), array('class'=>'overridenotice'));
|
||||
echo html_writer::tag('p', get_string('highlightedcellsshowinherit', 'role'), array('class'=>'overridenotice'));
|
||||
|
||||
$overridestable->display();
|
||||
if ($overridestable->has_locked_capabilities()) {
|
||||
echo '<p class="overridenotice">' . get_string('safeoverridenotice', 'core_role') . "</p>\n";
|
||||
echo '<p class="overridenotice">' . get_string('safeoverridenotice', 'role') . "</p>\n";
|
||||
}
|
||||
|
||||
echo html_writer::start_tag('div', array('class'=>'submit_buttons'));
|
||||
@@ -188,9 +165,9 @@ if (!empty($capabilities)) {
|
||||
// Print a form to swap roles, and a link back to the all roles list.
|
||||
echo html_writer::start_tag('div', array('class'=>'backlink'));
|
||||
$select = new single_select($PAGE->url, 'roleid', $nameswithcounts, $roleid, null);
|
||||
$select->label = get_string('overrideanotherrole', 'core_role');
|
||||
$select->label = get_string('overrideanotherrole', 'role');
|
||||
echo $OUTPUT->render($select);
|
||||
echo html_writer::tag('p', html_writer::tag('a', get_string('backtoallroles', 'core_role'), array('href'=>$returnurl)));
|
||||
echo html_writer::tag('p', html_writer::tag('a', get_string('backtoallroles', 'role'), array('href'=>$returnurl)));
|
||||
echo html_writer::end_tag('div');
|
||||
|
||||
echo $OUTPUT->footer();
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user